Download presentation

Presentation is loading. Please wait.

Published byCarter Elliott Modified over 3 years ago

1
Histogram Processing The histogram of a digital image with gray levels in the range [0, L-1] is a discrete function h(r k ) = n k where r k is the k th gray level and n k is the number of pixels in the image having gray level r k. For practical applications, one has to normalize a histogram by dividing each of its values by the total number of pixels in the image, n. Thus p(r k ) gives an estimate of the probability of occurrence of gray level r k. The sum of all components of a normalized histogram is equal to 1.

2
Histogram Processing Histogram techniques are used in image compression and segmentation. Let us see gray level images which are dark, light, low-contrast and high contrast and its corresponding histograms. For a dark image, histogram is on the low (dark) side of gray scale. For a bright image, histogram is biased towards high side of the gray scale. An image with low contrast has a histogram that is narrow and centered toward the middle of the gray scale. This implies a dull, washed-out gray look. An image whose pixels is occupying entire range of gray levels and distributed uniformly, has high contrast and show variety of gray tones. Thus it has a high dynamic range. It is also possible to develop a transformation function that can automatically achieve this effect, based on information in the histogram of the input image.

3

4

5
Contrast Stretch One of the simple techniques to expand the histogram to fill entire gray-scale range is contrast stretch or full-scale histogram stretch. Commercial digital video cameras for home and professional use a full-scale histogram stretch to the acquired image before being stored in camera memory. It is called as automatic gain control (AGC) on these devices.

6
Contrast Stretch Let f has a compressed histogram with maximum gray- level value B and minimum value A. A = min{f(x,y)}B = max{f(x,y)} We need to find an operation that maps gray levels A and B in the original image to gray levels 0 and K-1 in the transformed image. This is expressed as: PA + L =0 AndPB + L = K-1 Solving for the unknowns (P,L), the solutions are: P = (K – 1)/(B – A) AndL = -A* (K -1)/(B – A) Hence the overall full scale histogram stretch is given as: g(x,y) = ((K -1)/(B – A))* (f(x,y) – A).

7
Histogram Equalization It is one of the important nonlinear point operations. Contrast stretch tries to fill the available gray-scale range. But here we insist that it should be uniformly distributed over the range. Hence its goal is to produce a flat histogram. An image with a perfectly flat histogram contains largest possible amount of information

8
Histogram Equalization Assume that the intensity levels are continuous quantities normalized to the range [0,1] and let p r (r) denote the probability density function (PDF) of the intensity levels in a given image. Let us perform the transformation on the input levels to obtain output (processed) intensity levels, s, s = T(r) = integrate (p r (w)dw Here w is the dummy variable of integration. We want the probability density function of the output levels is to be uniform; that is P s (s) = 1for 0 s 1 = 0 otherwise

9
Histogram Equalization This transformation increases dynamic range and lead to higher contrast. But this transformation is nothing but the cumulative distribution function (CDF). For discrete quantities, we work with summations and the equalization transformation becomes s k = T ( r k ) = Σ p r (r j )for j = 1 to k = Σ (n i /n)for j = 1 to k and k varies from 1,2, …, L. Here s k is the intensity value in the output image corresponding to value r k in the input image.

10

11

12

13
histogram equalization % Read a gray scale image and 1. compute the cumulative probability % function and plot it. 2. scale the cumulative probability function to % Map each histogram values H(s)to probability density value % Pf(s). 4. compute the cumulative probability value and plot clear all; close all; clc; a = imread('cameraman.tif'); %a = imnoise(a,'salt & pepper',0.1); [m n]=size(a); figure,imshow(a); figure,imhist(a); a = double(a); gmin = min(min(a)); gmax = max(max(a));

14
% Cumulative probability function Pf. Pf = zeros(1,256); for i=1:m for j=1:n f = a(i,j) +1; for x = f:256 Pf(x) = Pf(x) +1; end Pf = Pf / (m*n); figure,plot(Pf); % histogram equalization g1 = (gmax - gmin) * Pf + gmin; figure,plot(g1); B1 = zeros(m,n); for i=1:m for j=1:n B1(i,j)=g1(a(i,j)+1); end figure,imshow(uint8(B1)); figure,imhist(uint8(B1)); % Cumulative probability function Pf Pf = zeros(1,256); for i=1:m for j=1:n f = round(B1(i,j))+1; for x = f:256 Pf(x) = Pf(x) +1; end Pf = Pf / (m*n); figure,plot(Pf);

15
Histogram Matching (Specification) Histogram equalization automatically determines a transformation function that seeks to produce an output image that has a uniform histogram. But there are applications where uniform histogram is not required. In fact, one has to specify the shape of the histogram that we want the processed image to have. The method used to generate a processed image that has a specified histogram is called histogram matching or histogram specification.

16
Histogram Matching (Specification) Once again consider the continuous gray levels r and z and let p r (r) and p z (z) denote their corresponding continuous probability density functions. Here r and z denote gray levels of input and processed output images. We can estimate pr(r) from the given input image, while p z (z) is the specified probability density function that we wish the output image to have.

17
Histogram Matching (Specification) Let s be a random variable with the property s = T(r) = integration p r (w) dw where w is the dummy variable. This expression is the continuous version of histogram equalization. Let us define a random variable z with the property G(z) = integration p z (t) dt = s where t is the dummy variable. From these 2 equations, we see G(z) = T(r) and z satisfy the condition z = G -1 (s) = G -1 [T(r)]. The transformation T(r) can be obtained once p r (r) has been estimated from the input image. Similarly the transformation function G(z) can be obtained once p z (z) is given.

18
Histogram Matching (Specification) In a nutshell, the procedure to be followed is as follows: Obtain the transformation function T(r) from input image Obtain the transformation function G(z) from specified image Obtain the inverse transformation function G -1 Obtain the output image z by applying the last equation for all the pixels in the input image. This results in an image whose gray levels z, have the specified probability density function p z (z).

19

20

21

22

23
% Histogram Matching % Read a gray Scale Image and look at its histogram % Generate the bimodel Gaussian function with appropriate parameters % match the given image histogram with the bimodal gaussian function and % verify the resultand image histogram aganist bimodal gaussian clear all; close all; clc; f = imread('moon.tif'); figure,imhist(f); f1 = histeq(f,256); p = twomodegauss(0.15,0.05,0.15,0.15,0.4,0.8,0.002); f2 = histeq(f,p); figure,imshow(f); figure,plot(p); figure,imshow(f2); figure,imhist(f2);

24
Local Enhancement The Histogram Equalization and Matching methods are global in nature. The pixels are modified by a transformation function based on the gray-level content of an entire image. There are cases where we need to enhance details over small areas in an image. Now we need to devise transformation functions which are based on the neighborhood of every pixel in the image.

25
Local Enhancement The procedure is to define a square or rectangular neighborhood and move the centre of this area from pixel to pixel. At each location, the histogram of the points in the neighborhood is computed and either a histogram equalization or histogram specification transformation function is obtained. This function is used to map the gray level of the pixel centered in the neighborhood. The centre of the neighborhood region is then moved to an adjacent pixel location and the procedure is repeated. To reduce computation, we can use non-overlapping regions, but this method produces an undesirable check board effect. Local histogram equalization reveals the presence of small details.

26

27
Histogram statistics for Image Enhancement We can also use some statistical parameters obtainable from the histogram also for enhancement. Let r denote a discrete random variable representing discrete gray-levels in the range [0, L-1] and let p(r i ) (probability of occurrence of gray level r i ) denote the normalized histogram component corresponding to the i th value of r. The n th moment of r about its mean is defined as μ n (r) = Σ (r i – m) n p(r i ) where i varies from 0 to L-1. Here m is the mean value of r: m = Σ r i p(r i ) for i = 0 to L-1 We notice that μ 0 = 1 and μ 1 = 0. The second moment is given by Μ 2 (r) = Σ (r i – m) 2 p(r i ) for i=0 to L-1. This expression is the variance of r, denoted as σ 2 (r). The standard deviation is the square root of the variance.

28
Histogram statistics for Image Enhancement As far as enhancement is concerned, we are interested in the mean, which is a measure of average gray level in an image and the variance which is a measure of average contrast. Global mean and variance are measured over an entire image and are useful for gross adjustments of overall intensity and contrast. In the case of local enhancement, the local mean and variance are used as the basis for making changes that depend on image characteristics in a predefined region about each pixel in the image.

29
Histogram statistics for Image Enhancement Let (x,y) be the coordinates of a pixel in an image and let S xy denote a neighborhood (subimage) of specified size, centered at (x,y). The mean m Sxy of the pixels in S xy is calculated as m Sxy = Σ r s,t p(r s,t ) where r s,t is the gray level at coordinates (s,t) in the neighborhood, and p(r s,t ) is the neighborhood normalized histogram component corresponding to that value of gray level. Similarly the gray-level variance of the pixels in region S xy is given by σ 2 Sxy = Σ [r s,t - m Sxy ] 2 p(r s,t ) The local mean is a measure of average gray level in neighborhood S xy and the variance is a measure of contrast in that neighborhood.

30
Histogram statistics for Image Enhancement If one part of the image is quite clear and other part of the image is darker and contain hidden features of interest, then we can apply local approaches. A measure of whether an area is relatively light or dark at a point (x,y) is to compare the local average gray level m Sxy to the average image gray level, called the global mean, M G. We can process a pixel at the (x,y) if m Sxy k 0 M G where k 0 is a positive constant with value less than 1.0

31
Histogram statistics for Image Enhancement If we are interested in enhancing areas that have low contrast, we need a measure to determine whether the contrast of an area makes it a candidate for enhancement. Thus we enhance a pixel at (x,y) if σ Sxy k 2 D G where D G is the global standard deviation and k 2 is a positive constant. The value is greater than 1.0 for enhancing light areas and less than 1.0 for dark areas. We need to set the lowest values of contrast to accept, otherwise the procedure would attempt to enhance even constant areas, whose standard deviation is zero. Thus we set a lower limit on the local standard deviation by setting k 1 D G σ Sxy, with k 1 < k 2. A pixel at (x,y) that meets all the conditions for local enhancement is processed by multiplying it by a specified constant E, to increase (or decrease) the value of its gray level relative to the rest of the image. Values of pixels not meeting the enhancement conditions are left unchanged.

32
Histogram statistics for Image Enhancement In a nutshell, let f(x,y) is the value of an image pixel at (x,y) and g(x,y) is its corresponding enhanced pixel at (x,y). Then g(x,y) = E.f(x,y)if m Sxy k 0 M G AND k 1 D G σ Sxy k 2 D G = f(x,y)otherwise Here E, k 0, k 1 and k 2 are specified parameters and M G and D G are the global mean and global standard deviation.

33

34
Enhancement using Arithmetic/Logic Operations Arithmetic operations involving images are done on a pixel-by-pixel basis between 2 or more images (except NOT operation which is done on a single image). Any logical operations can be implemented using only AND, OR and NOT logic operators. When dealing with gray-scale images, pixel values are processed as strings of binary numbers. The NOT logic operator does the same function as the negative transformation does. The AND and OR operations are used for masking; that is, for selecting subimages in an image. Masking is also called as region of interest (ROI) processing.

35
Enhancement using Arithmetic/Logic Operations Of the four arithmetic operations, subtraction, and addition are useful for image enhancement. Division of 2 images is considered as multiplication of one image by the reciprocal of the other. Multiplying an image by a constant increases its average gray level

36

37
Image Subtraction The difference between 2 images f(x,y) and h(x,y) is given as: g(x,y) = f(x,y) – h(x,y) The difference image is very useful for evaluating the effect of setting to zero the lower-order planes. Image subtraction for segmentation is used when the criterion is changes. In tracking moving vehicles in a sequence of images, subtraction is used to remove all stationary components in an image. What is left is the moving elements in the image plus noise.

38
(a) Original fractal Image. (b) Result of four lower-order bit plains to zero. (c) Difference image.

39
Image Averaging Consider a noisy image g(x,y) formed by addition of noise η(x,y) to an original image. g(x,y) = f(x,y) + η(x,y) Here we assume that at every pair of coordinates (x,y) the noise is uncorrelated and has zero average value. We try to reduce the noise content by adding a set of noisy images, g i (x,y). It can be shown that as the number of noisy images used in the averaging process increases, the noisy image resembles the original image f(x,y).

40
Image Averaging Let ğ(x,y) is obtained by averaging K different noisy images. ğ(x,y) = (1/K) Σ g i (x,y) where i varies from 1 to K. Then E{ ğ(x,y)} = f(x,y)and σ 2 ğ(x,y) = (1/K) σ 2 η(x,y) Here E{ ğ(x,y)} is the expected value of ğ and σ 2 ğ(x,y) and σ 2 η(x,y) are the variances of ğ and η, all at coordinates (x,y). The standard deviation at any point in the average image is σ ğ(x,y) = (1/sqrt(K)) σ η(x,y) Now we realize that as K increases, the variability (noise) of the pixel values at each location (x,y) decreases.

41

42

43
% Read a gray scale image and analyze the effect of averave filter(linear) % for various mask sizes. prove that higher the maks size is leading to % more blurring clear all; close all; clc; f = imread('moon.tif'); f = im2double(f); %f1 = imnoise(f,'gaussian',0,0.4); [m n]=size(f); f2 = zeros(m,n); % e=input('Enter size of the mask: '); e = [3,5,9,17]; M_size=(e(1)-1)/2; A_imge1=Iaver(f,M_size); M_size=(e(2)-1)/2; A_imge2=Iaver(f,M_size); M_size=(e(3)-1)/2; A_imge3=Iaver(f,M_size); M_size=(e(4)-1)/2; A_imge4=Iaver(f,M_size); figure(1); subplot(3,2,1),imshow(f); subplot(3,2,2),imshow(f); subplot(3,2,3),imshow(A_imge1); subplot(3,2,4),imshow(A_imge2); subplot(3,2,5),imshow(A_imge3); subplot(3,2,6),imshow(A_imge4);

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google