Point Processing When doing so you actually perform a special type of image processing known as point processing.
Point processing Point processing is now defined as an operation which calculates the new value of a pixel in g(x, y) based on the value of the pixel in the same position in f (x, y) and some operation. When doing so you actually perform a special type of image processing known as point processing.
Point Processing linear Non-linear (Logarithm, Exponential, Gamma, etc.)
Gray-Level Mapping g(x, y) = f (x, y)+b NOTE: If b >0 the image becomes brighter and if b < 0 the image becomes darker.
exercise
Gray-Level Mapping
The contrast of an image g(x, y) = a * f (x, y) g(x, y) = a * f (x, y)+b The contrast of an image is changed by changing the slope of the graph If a >1 the contrast is increased and if a <1 the contrast is decreased.
Arithmetic operations on an image: multiplication and division
Complements Input imageoutput image MATLAB function
Non-linear Gray-Level Mapping Gamma Mapping Humans have a non-linear perception of contrast. A commonly used non-linear mapping is gamma mapping
Gamma Mapping Gamma-mapping curves for different gammas g(x, y) = f (x, y) γ Adjust the gamma L1 = imadjust(I,[ ], [ ],2); figure, imshow(L1) L2 = imadjust(I,[ ], [ ],.3); figure, imshow(L2)
Gamma Mapping If Vin = 120 is gamma mapped with γ = Initially, the pixel value is transformed into the interval [0, 1] by dividing with 255, g’(x,y) = 20/255 = The gamma mapping is performed v2 = = Finally, it is mapped back to the interval [0, 255] giving the result v out = / 255 = 47.
Logarithmic Mapping An alternative non-linear mapping is based on the logarithm operator. Each pixel is replaced by the logarithm of the pixel value.
Logarithmic Mapping the mapping is defined as g(x, y) = c * log(1+f (x, y)) where c is a scaling constant that ensures that the maximum output value is 255 It is calculated as c = 255 / log(1 +v max ) where v max is the maximum pixel value in the input image.
Logarithmic Mapping I = imread('pout.tif'); g=c*log(1+double(I)) gs=im2uint8(mat2gray(g)); Input imageOutput image Output Input
Exponential Mapping The exponential mapping uses a part of the exponential curve. It can be expressed as where k is a parameter that can be used to change of shape of the transformation curve and c is a scaling constant that ensures that the maximum output value is 255. where v max is the maximum pixel value in the input image. k is normally chosen as a number just above 1. g(x, y) = c *(k f (x,y) − 1)
MATLAB function > Im2 = imadjust(I,[],[],0.5); //adjusts gamma: exponential map of grays J = imadjust(I, [low_in; high_in], [low_out; high_out],gamma); Exponential Mapping
The Image Histogram “how can we tell if an image is too dark or too bright? “ Histogram equalization is based on non-linear gray- level mapping using a cumulative histogram.
The Image Histogram
Histogram stretching ini h = imhist(im, b): h: histogram, b: number of histogram bins
The Image Histogram Histogram stretching (Contrast stretching) Histogram Equalization
The Image Histogram (con’t) Given a grayscale image, its histogram consists of the histogram of its grey levels
Histogram stretching
The Image Histogram (con’t) MATLAB function
Histogram stretching 5 9
This function has the effect of stretching the grey levels 5-9 to grey levels 2-14 by following: i56789 j
Perform histogram stretching in Matlab Format imadjust(im,[a,b],[c,d]) NOTE: images of type double, uint8 or uint16 the values of a, b, c, and d must be between 0 and 1 J = imadjust(I) J = imadjust(I,[low_in; high_in],[low_out; high_out]) J = imadjust(I,[low_in; high_in],[low_out; high_out],gamma)
Perform histogram stretching in Matlab >> t=imread('tire.tif'); >> th=imadjust(t,[],[],0.5); >> imshow(t),figure,imshow(th)
Example RGB1 = imread('football.jpg'); RGB2 = imadjust(RGB1,[.2.3 0;.6.7 1],[]); imshow(RGB1), figure, imshow(RGB2) Input imageOutput image
A piecewise linear stretching function pix=find(im >= a(i) & im < a(i+1)); out(pix)=(im(pix)-a(i))*(b(i+1)-b(i))/(a(i+1)- a(i))+b(i);
Histogram equalization The user input is required for histogram starching, and a better approach is provided by histogram equalization, which is an entirely automatic procedure.
Histogram equalization ini h = imhist(im, b): h: histogram, b: number of histogram bins
Histogram equalization /360
exercise 1.I = imread('tire.tif'); 2.[J,T] = histeq(I); 3.figure;imshow(I); 4.figure; imhist(I,64) 5.figure;imshow(J); 6.figure; imhist(J,64) 7.Plot(T);