Presentation is loading. Please wait.

Presentation is loading. Please wait.

M ATLAB L ECTURE 2 Image Enhancement in the Spatial Domain (MATLAB)

Similar presentations


Presentation on theme: "M ATLAB L ECTURE 2 Image Enhancement in the Spatial Domain (MATLAB)"— Presentation transcript:

1 M ATLAB L ECTURE 2 Image Enhancement in the Spatial Domain (MATLAB)

2 I MAGE E NHANCEMENT IN THE S PATIAL D OMAIN

3 S PATIAL D OMAIN : B ACKGROUND g(x, y) = T [f(x, y)] f(x, y) : input image g(x, y) : output image T : an operator on f (Transformation Function)

4 I N M ATLAB : F UNCTION IMADJUST Adjust image intensity values or colormap Syntax : (in gray images) J = imadjust(I) maps the values in intensity image I to new values in J. This increases the contrast of the output image J. J = imadjust(I,[low_in high_in],[low_out high_out]) maps the values in intensity image I to new values in J such that values between low_in and high_in map to values between low_out and high_out.

5 F UNCTION I MADJUST J = imadjust(...,gamma) maps the values in intensity image I to new values in J, where gamma specifies the shape of the curve describing the relationship between the values in I and J.

6 F UNCTION IMADJUST ( CONT.) If gamma is less than 1, the mapping is weighted toward higher (brighter) output values. If gamma is greater than1, the mapping is weighted toward lower (darker) output values. If you omit the argument, gamma defaults to 1(linear mapping).

7 I MAGE A DJUST E XAMPLES ( MATLAB CODE ) Adjust a low-contrast grayscale image. I = imread('pout.tif'); J = imadjust(I); figure, imshow(I), figure, imshow(J)

8 I MAGE A DJUST E XAMPLES Adjust the grayscale image, specifying the contrast limits. K1 = imadjust(I,[0.3 0.7],[.2.6]); figure, imshow(K1) K2 = imadjust(I,[0.3 0.7],[]); figure, imshow(K2)

9 I MAGE A DJUST E XAMPLES Adjust the gamma L1 = imadjust(I,[0.3 0.7], [ ],2); figure, imshow(L1) L2 = imadjust(I,[0.3 0.7], [ ],.3); figure, imshow(L2)

10 N EGATIVE IMAGE Obtaining a negative image I = imread('pout.tif'); K1 =imadjust(I, [0 1], [1 0]); K2 = imcomplement(I); imshow(I), figure, imshow(K1), figure, imshow(K2)

11 STRETCHLIM E XAMPLE Contrast Stretching: I = imread('pout.tif'); J = imadjust(I,stretchlim(I),[]); imshow(I), figure, imshow(J)

12 L OGARITHMIC AND CONTRAST STRETCHING Logarithmic: g=c*log(1+double(f)) Contrast stretching : compress the input levels lower than m into a narrow range of dark levels in the output image; similarly, it compresses the values above m into a narrow band of light levels in the output.

13 L OGARITHMIC AND CONTRAST STRETCHING E XAMPLE I = imread('pout.tif'); g=c*log(1+double(I)) gs=im2uint8(mat2gray(g));

14 T HRESHOLDING E XAMPLE I = imread('pout.tif'); threshold = graythresh(I); BW = im2bw(I,threshold); imshow(BW);

15 I N M ATLAB : IM 2 BW Convert an image to a binary image, based on threshold Syntax: BW = im2bw(I,level) BW = im2bw(X,map,level) BW = im2bw(RGB,level)

16 I M 2 BW : E XAMPLE Im2bw: Example load trees BW = im2bw(X,map,0.4); Imview(X,map), imview(BW)


Download ppt "M ATLAB L ECTURE 2 Image Enhancement in the Spatial Domain (MATLAB)"

Similar presentations


Ads by Google