320 likes | 523 Views
Roger S. Gaborski. Introduction to Computer Vision. Chest Radiographic Image. What information can we extract from the image? Techniques we can try: Thresholding Imadjust Edge detection. Histogram of Image. Threshold = .4. Threshold = .6. Otsu’s Thresholding Method.
E N D
Roger S. Gaborski Introduction to Computer Vision Roger S. Gaborski
Chest Radiographic Image Roger S. Gaborski
What information can we extract from the image? • Techniques we can try: • Thresholding • Imadjust • Edge detection Roger S. Gaborski
Histogram of Image Roger S. Gaborski
Threshold = .4 Roger S. Gaborski
Threshold = .6 Roger S. Gaborski
Otsu’s Thresholding Method • Algorithm assumes the image’s histogram is bi-model • Finds the optimal threshold to separate the two classes of pixels Roger S. Gaborski
Matlab - Otsu’s Method • level = graythresh(Ig) • figure, imshow(Ig>level), title('Graythresh Level') • level = 0.5373 Roger S. Gaborski
Threshold Level Determined by Otsu Method Roger S. Gaborski
Otsu’s method, continued • Since the histogram is not bi-modal should not expect good separation between lungs and bones Roger S. Gaborski
imadjust Roger S. Gaborski
Original and imadjust Image Roger S. Gaborski
Edge Detection fh = fspecial('sobel'); %horiz edge fv = fh'; %vertical edge i_horiz = imfilter(Ig, fh); figure, imshow(i_horiz, []), title('Horizontal Edges') i_vert = imfilter(Ig, fv); figure, imshow(i_vert, []),title('Vertical Edges') Roger S. Gaborski
Horizontal Edges Roger S. Gaborski
Vertical Edges Roger S. Gaborski
Canny- stddev = 2 Roger S. Gaborski
Canny- stddev = 3 Roger S. Gaborski
Laplacian of Gaussian, stddev =2 Roger S. Gaborski
Laplacian of Gaussian, stddev=3 Roger S. Gaborski
Laplacian of Gaussian, stddev =2.5 Roger S. Gaborski
Sensitivity of standard deviation: • Compare the last three images • Significant difference with a small change in standard deviation • How do you automatically choose the standard deviation if you have a large collection of images that you need to process? Roger S. Gaborski
Reconsider Thresholding • Does it make sense to have only one threshold value? • Physically, maybe the image cannot be separated into only 2 classes • Consider more than one thresholding values Roger S. Gaborski
IMQUANTIZE • imquantize Quantize image using specified quantization levels and output values. • QUANT_A = imquantize(A, LEVELS) uses the quantization levels specified • in the 1xN vector LEVELS to convert image A into an output image • QUANT_A with N+1 discrete levels. The entries in LEVELS have to be in • strictly increasing order. The output image QUANT_A contains integer • values in the range [1 (N+1)] assigned as per the criterion below: • If A(k) <= LEVELS(1), then QUANT_A(k) = 1 • If LEVELS(m-1) < A(k) <= LEVELS(m), then QUANT_A(k) = m • If A(k) >LEVELS(N), then QUANT_A(k) = N+1 Roger S. Gaborski
> A =[1:10] A = 1 2 3 4 5 6 7 8 9 10 LEVELS = [5] L = imquantize(A,LEVELS) L = 1 1 1 1 1 2 2 2 2 2 LEVELS = [3,7] L = imquantize(A,LEVELS) L = 1 1 1 2 2 2 2 3 3 3 1 to 3 is first level, 4-7 is second level and 8 to 10 is 3rd level Roger S. Gaborski
label2rgb • label2rgb Convert label matrix to RGB image. • The RGB matrix can then be visualized LEVELS = [3,7] L = imquantize(A,LEVELS) L = 1 1 1 2 2 2 2 3 3 3 1 to 3 is first level, 4-7 is second level and 8to 10 is 3rd level iData=label2rgb(L) iData(:,:,1) = 0 0 0 0 0 0 0 255 255 255 iData (:,:,2) = 0 0 0 255 255 255 255 255 255 255 iData(:,:,3) = 255 255 255 255 255 255 255 0 0 0 figure, imshow(iData,'InitialMagnification','fit') Roger S. Gaborski
iData Roger S. Gaborski
THRESH = multithresh(A, N) • THRESH = multithresh(A, N) computes N thresholds for image A using the Otsu's method and returns them in THRESH. • THRESH is a 1xN vector which can be used to convert A into an image with (N+1) discrete levels using IMQUANTIZE. Roger S. Gaborski
>> I = imread('chestRadiograph1.png'); • I = rgb2gray(I); • thresh = multithresh(I,3) = 113 137 159 • seg_I = imquantize(I,thresh); • RGB = label2rgb(seg_I); • figure, imshow(RGB) Roger S. Gaborski
Multi-level Thresholding Roger S. Gaborski