2018년 9월 27일 목요일

기계시각의 이미지 프로세싱 #001

1. 영상의 이진화

    임계값, threshold, 문턱값, 기준값을 이용하여 영상의 모든 픽셀을 검사하여 문턱값보다 높을 경우 1, 낮을 경우 0 으로 하는 이진 영상(binary image)를 만들어 내는 것. 매트랩에서는 영상의 이진화를 im2bw 라는 함수를 이용하여 간단히 수행.

img = imread('2.bmp');
BW = im2bw(img,0.5);  ! 0.5 = 127.5 값
s  = regionprops(BW,'centroid');
centroids = cat(1, s.Centroid);
imshow(BW);
hold on;
plot(centroids(:,1), centroids(:,2), 'b*');
hold off;



2.  영상 이진화(binarization, thresholding)
   영상의 밝기 분포를 보고 임계값을 찾아주는 방법 Otzu's method (N. Otsu, “A threshold selection method from gray-level histograms,” IEEE Trans. Syst., Man, Cybern., vol. SMC-9, pp. 62-66, 1979).   임계값을 0-255까지 변화시켜  밝기평균의 차의 제곱의 최대값을 찾는 방법.