MATLAB LECTURE 2 Image Enhancement in the Spatial
MATLAB LECTURE 2 Image Enhancement in the Spatial Domain (MATLAB)
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
SPATIAL DOMAIN: BACKGROUND g(x, y) = T [f(x, y)] f(x, y) : input image � g(x, y) : output image � T : an operator on f (Transformation Function) �
IN MATLAB: FUNCTION 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.
FUNCTION IMADJUST 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.
FUNCTION IMADJUST (CONT. ) If gamma is less than 1, the mapping is weighted toward higher (brighter) output values. If gamma is greater than 1, the mapping is weighted toward lower (darker) output values. If you omit the argument, gamma defaults to 1(linear mapping).
IMAGE ADJUST EXAMPLES (MATLAB CODE) Adjust a low-contrast grayscale image. I = imread('pout. tif'); J = imadjust(I); figure, imshow(I), figure, imshow(J)
IMAGE ADJUST EXAMPLES Adjust the grayscale image, specifying the contrast limits. K 1 = imadjust(I, [0. 3 0. 7], [. 2. 6]); figure, imshow(K 1) K 2 = imadjust(I, [0. 3 0. 7], []); figure, imshow(K 2)
IMAGE ADJUST EXAMPLES Adjust the gamma L 1 = imadjust(I, [0. 3 0. 7], [ ], 2); figure, imshow(L 1) L 2 = imadjust(I, [0. 3 0. 7], [ ], . 3); figure, imshow(L 2)
NEGATIVE IMAGE Obtaining a negative image I = imread('pout. tif'); K 1 =imadjust(I, [0 1] , [1 0]); K 2 = imcomplement(I); imshow(I), figure, imshow(K 1), figure, imshow(K 2)
STRETCHLIM EXAMPLE Contrast Stretching: I = imread('pout. tif'); J = imadjust(I, stretchlim(I), []); imshow(I), figure, imshow(J)
LOGARITHMIC 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.
LOGARITHMIC AND CONTRAST STRETCHING EXAMPLE I = imread('pout. tif'); g=c*log(1+double(I)) gs=im 2 uint 8(mat 2 gray(g));
THRESHOLDING EXAMPLE I = imread('pout. tif'); threshold = graythresh(I); BW = im 2 bw(I, threshold); imshow(BW);
IN MATLAB: IM 2 BW Convert an image to a binary image, based on threshold Syntax: BW = im 2 bw(I, level) BW = im 2 bw(X, map, level) BW = im 2 bw(RGB, level)
IM 2 BW: EXAMPLE Im 2 bw: Example load trees BW = im 2 bw(X, map, 0. 4); Imview(X, map), imview(BW)
- Slides: 16