Presentation is loading. Please wait.

Presentation is loading. Please wait.

Image Enhancement – Simple Intensity Processing

Similar presentations


Presentation on theme: "Image Enhancement – Simple Intensity Processing"— Presentation transcript:

1 Image Enhancement – Simple Intensity Processing
Dr. Jiajun Wang School of Electronics & Information Engineering Soochow University

2 Image Enhancement - 1 Outline Review Image enhancement vs. restoration Different approaches Point processing

3 Image Enhancement - 1 Review

4 Image Enhancement - 1 Enhancement vs. restoration Image enhancement : processing the image so that the results is more suitable than the original image for a specific application Image restoration : recover image from distortions to its original image

5 Spatial domain processing
Image Enhancement - 1 Different approaches Spatial domain processing Point processing : E.g., contrast stretching Mask processing : and its neighbors covered by mask) E.g., spatial filters Frequency domain processing Select H(u,v) so that the desired image g(x,y) exhibits some highlighted features of f(x,y)

6 Image Enhancement - 1 Spatial domain approaches

7 Image Enhancement - 1 Point processing Simple intensity transforms
Image negatives Log and power-low transforms Contrast stretching Compression of dynamic range Gray-level slicing Bit-plane slicing Histogram methods Histogram equalization Histogram specification Image subtraction Image averaging

8 Image Enhancement – Point Processing
Image negative ImageNegative.m iptsetpref('ImshowBorder', 'tight') img1 = imread('..\images\xrp1.tif'); figure imshow(img1); title('original image'); img2 = imcomplement(img1); imshow(img2); title('negative image');

9 Image Enhancement – Point Processing
Log transforms Log transforms stretch the low gray-level values while compress the high gray level values.

10 Image Enhancement – Point Processing
Log transforms – example Log transforms stretch the low gray-level values while compress the high gray level values. LogTransform.m clear all close all iptsetpref('ImshowBorder', 'tight') img = zeros(256, 256); img(120:136, 120:136) = 1; figure imshow(img); fimg = fft2(img); fimg = fftshift(fimg); MagImg = abs(fimg); imshow(MagImg,[]); maxV = max(max(MagImg)); limg = log(1+MagImg); imshow(limg,[]); Original image Fourier transform Log transform of FT

11 Image Enhancement – Point Processing
Power-law transforms The power-low transformations are much more versatile.

12 Image Enhancement – Point Processing
Gamma correction The power-low transformations are much more versatile.

13 Image Enhancement – Point Processing
Power-low transform example The power-low transformations are much more versatile.

14 Image Enhancement – Point Processing
Power-low transform example The power-low transformations are much more versatile.

15 Image Enhancement – Point Processing
Piecewise-linear Transformation

16 Image Enhancement – Point Processing
Contrast stretching ImageStreching.m iptsetpref('ImshowBorder', 'tight') img1 = imread('..\images\AllKnives.tif'); figure imshow(img1); title('original image'); minV = double(min(min(img1)))/65535; maxV = double(max(max(img1)))/65535; img2 = imadjust(img1, [minV,maxV], []); imshow(img2); title('streching image'); %imshow(img1, []); % another simple approach Original image Stretched image

17 Image Enhancement – Point Processing
Gray-level slicing

18 Image Enhancement – Point Processing
Bit-plane slicing

19 Image Enhancement – Point Processing
Bit-plane slicing (cont’)

20 Image Enhancement – Point Processing
Histogram equalization Gray-level histogram is a function showing, for each gray level, the number of pixels in the image that have that gray level Normalized histogram (probability):

21 Image Enhancement – Point Processing
Histogram equalization (cont.)

22 Image Enhancement – Point Processing
Histogram equalization (cont.) s=T(r) T is single-valued and monotonically increasing s is value-limited in [0,1]

23 Image Enhancement – Point Processing
Histogram equalization (cont.) PDF relation between ps and pr If the cumulative distribution function is used as the transform then the PDF of the transformed image is

24 Image Enhancement – Point Processing
Histogram equalization (cont.) Transform function is the probability density function (pdf) The transform function is the cumulative distribution function (CDF) Why ? To make the pdf of the transformed image uniform, i.e., to make the histogram of the transformed image uniform.

25 Image Enhancement – Point Processing
Histogram equalization (cont.) HE - discrete form HE steps G – Number of gray levels, N – Number of pixels Calculate the histogram H[r], r=1,2,…G-1 Normalize the histogram H[r] = H[r]/N; Form the CDF: Hc[0] = H[0], Hc[r] = Hc[r-1] + H[r] Set s = T[p] = round (Hc[p] (G-1))

26 Image Enhancement – Point Processing
Histogram equalization (cont.)

27 Image Enhancement – Point Processing
Histogram equalization (cont.) Discussion Can contrast stretching achieve similar result as histogram equalization? If yes, why histogram equalization then? Why isn’t the transformed histogram uniform?

28 Image Enhancement – Point Processing
Histogram matching (specification) The desired shape of histogram is specified (not necessarily uniform) Derivation of histogram matching function: z=G-1(T(r)) s uniform r input z desired z=G-1(s) s=T(r) histogram equalization histogram equalization s=G(z)

29 Inverse function of G Original -> uniform (equalization)
Desired -> uniform (equalization) Inverse function of G

30 Image Enhancement – Point Processing
Image averaging original image f(x,y) + noisy image g(x,y) noise n(x,y)

31 Image Enhancement – Point Processing
Image averaging (cont.) If the noise is uncorrelated and has zero expectation, then

32 Image Enhancement – Point Processing
Image averaging – example Original image Noised image (Gaussian)

33 Image Enhancement – Point Processing
Image averaging – example (cont’) clear all close all iptsetpref('ImshowBorder', 'tight') img1 = imread('..\images\lenna.bmp'); img1 = rgb2gray(img1); figure imshow(img1); title('original image'); img = zeros(size(img1)); for i=1:10 img2 = imnoise(img1, 'gaussian'); img = imadd(img, double(img2)); end img = uint8(img/10); imshow(img) imshow(img2) Noised image (Gaussian) Average of 10 noised image

34 Image Enhancement – Point Processing
Image subtraction ImageSubtract.m clear all close all iptsetpref('ImshowBorder', 'tight') img1 = imread('..\images\lenna.bmp'); img1 = rgb2gray(img1); figure imshow(img1); title('original image'); h = fspecial('gaussian', [5 5], 1); % Gaussian filter img = imfilter(img1,h); imshow(img) img2 = imsubtract(img1, img); img2 = imcomplement(img2); imshow(img2,[]); Difference between original and blurred image

35 Image Enhancement – Spatial Filters
Dr. Jiajun Wang School of Electronics and Information Engineering Soochow University

36 Image Enhancement - 2 Outline Review - Different approaches Spatial filters Smoothing filters Sharpening filters Summery

37 Different approaches - review
Image Enhancement - 2 Different approaches - review Spatial domain processing Point processing : E.g., contrast stretching Mask processing : and its neighbors covered by mask) E.g., spatial filters Frequency domain processing Select H(u,v) so that the desired image g(x,y) exhibits some highlighted features of f(x,y)

38 Image Enhancement - 2 Spatial filtering Mask 1D : FIR window
2D : spatial mask Use spatial filters (masks) for linear and nonlinear image enhancement. The process consists of moving the filter mask from point to point in an image. At each point (x,y), the response of the filter at that point is calculated using a predefined relationship. The mask is in general of odd sizes.

39 Spatial filtering (cont’)
Image Enhancement - 2 Spatial filtering (cont’) Operation Steps Select a single pixel. Determine the pixel’s neighborhood. Apply a function to the values of the pixels in the neighborhood. This function must return a scalar. Find the pixel in the output image whose position corresponds to that of the center pixel in the input image. Set this output pixel to the value returned by the function. Repeat steps 1 through 4 for each pixel in the input image.

40 Padding of borders Image Enhancement - 2 Spatial filtering (cont’)
Determine the center pixel: For any m-by-n neighborhood, the center pixel is floor(([m n]+1)/2). Some of the pixels in a neighborhood may be missing, especially if the center pixel is on the border of the image. Notice that in the figure, the upper left and bottom right neighborhoods include “pixels” that are not part of the image. To process these neighborhoods, sliding neighborhood operations pad the borders of the image, usually with 0’s. In other words, these functions process the border pixels by assuming that the image is surrounded by additional rows and columns of 0’s. These rows and columns do not become part of the output image and are used only as parts of the neighborhoods of the actual pixels in the image. - Boundary padding options X Input array values outside the bounds of the array are implicitly assumed to have the value X. When no boundary option is specified, IMFILTER uses X = 0. 'symmetric' Input array values outside the bounds of the array are computed by mirror-reflecting the array across the array border. 'replicate' Input array values outside the bounds of the array are assumed to equal the nearest array border value. 'circular' Input array values outside the bounds of the array are computed by implicitly assuming the input array is periodic.

41 Purpose: blurring or noise reduction Low pass spatial filtering
Image Enhancement - 2 Smoothing filters Purpose: blurring or noise reduction Low pass spatial filtering Neighborhood averaging Can use different size of masks Sum of the mask coefficients is 1 Drawbacks: blur edges and other sharp features Median filtering Nonlinear The gray level of each pixel is replaced by the median of its neighbors Good at denoising Objective of blurring: removal of small objects from an image prior to (large) object extraction, or bridging of small gaps in lines or curves.

42 Smoothing filters (cont.)
Image Enhancement - 2 Smoothing filters (cont.) The basic strategy behind weighted averaging is simply an attempt to reduce blurring in the smoothing process. However, in practice, it is difficult in general to see the difference between the images smoothed by using either of the masks above because of their small sizes.

43 Smoothing filters - examples
Image Enhancement - 2 Smoothing filters - examples ImageSmoothing.m I = uint8(zeros(128,128)); I(:,33:64) = uint8(64); I(:,65:96) = uint8(128); I(:,97:128) = uint8(192) figure;imshow(I) figure;plot(I(64,:)); K = imfilter(I, fspecial('average',9)); figure;imshow(K) figure;plot(K(64,:)); L = medfilt2(I,[3 3]); figure, imshow(L) figure, plot(L(64,:));

44 Smoothing filters - examples
Image Enhancement - 2 Smoothing filters - examples The above figure illustrates the effects of smoothing as a function of filter size.

45 Median filters Max filters Min filters Image Enhancement - 2
Order statistics filters Median filters Max filters Min filters

46 Median filters - examples
Image Enhancement - 2 Median filters - examples MedianFiltering.m clear all close all iptsetpref('ImshowBorder', 'tight') I = imread('eight.tif'); J = imnoise(I,'salt & pepper',0.02); imshow(I) figure, imshow(J) K = filter2(fspecial('average',3),J)/255; L = medfilt2(J,[3 3]); figure, imshow(K) figure, imshow(L)

47 Image Enhancement - 2 Sharpening filters Purpose Approach
Highlight fine details or enhance details that have been blurred Approach First-order derivative Second-order derivative Basic high pass spatial filters Sum of the mask coefficients is 0 Visual effect : enhanced edges on a dark background Basic idea: sharpening could be accomplished by digital differentiation. Image differentiation enhances edges and other discontinuities. Requirements for first- and second-order derivatives. See pp. 125. First-order derivatives produce thick edges and second-order derivatives produce much finer ones. 2nd –order derivatives enhance fine details (include noises) much more than the 1st order derivatives. 2nd –order derivatives have a transition from positive to negative and thus produce double edges. See pp. 127.

48 Image Enhancement - 2 Sharpening filters (cont.)

49 Laplacian – second order derivative
Image Enhancement - 2 Sharpening filters - Laplacian Laplacian – second order derivative

50 Image Enhancement - 2 Sharpening filters – Laplacian (cont.)

51 Image Enhancement - 2 Sharpening filters - Laplacian examples

52 Sharpening filters - Laplacian examples
Image Enhancement - 2 Sharpening filters - Laplacian examples ImageSharpening.m I = imread('moon.tif'); figure; imshow(I); h1 = [0 1 0; ; 0 1 0]; % Laplacian derivative I1 = imfilter(I, h1); figure; imshow(I1); I11 = double(I)-double(I1); I11 = mat2gray(I11); figure; imshow(I11); h2 = [0 -1 0; ; ]; % Laplacian filter I2 = imfilter(I, h2); figure; imshow(I2); h3 = fspecial('unsharp'); % unsharp filter I3 = imfilter(I,h3); figure, imshow(I3)

53 Sharpening filters – High boosting
Image Enhancement - 2 Sharpening filters – High boosting Unsharp masking Subtracting a blurred image from its original High-boosting filtering Highpass = Original – Lowpass High boost = (A)Original – Lowpass = (A-1)Original + Highpass Visual effect : brighten while sharpening on the original image

54 Sharpening filters (cont.)
Image Enhancement - 2 Sharpening filters (cont.) One of the principal applications of boost filtering is when the image is darker than desired.

55 Image Enhancement - 2 Sharpening filters - examples

56 Image Enhancement - 2 Sharpening filters - Gradient First order derivative filters

57 Image Enhancement - 2 Sharpening filters (cont.)

58 Image Enhancement - 2 Sharpening filters - examples

59 Smoothing filters (blurr details)
Image Enhancement - 2 Summery Smoothing filters (blurr details) Average median Sharpening filters (highlight details) Highpass filters Unsharp masking High-boost filters Derivative filters


Download ppt "Image Enhancement – Simple Intensity Processing"

Similar presentations


Ads by Google