types of image enhancements in spatial domain the objective of enhancement is to process the image...
TRANSCRIPT
![Page 1: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/1.jpg)
Types of Image Enhancements in spatial domain
• The objective of enhancement is to process the image so that the resultant image is better than the original image for a particular application.
• It is classified into 2 types: Spatial domain methods and frequency domain methods.
• In spatial domain methods, we directly manipulate the pixels of an image.
• In frequency domain methods, we modify the Fourier transform of an image.
![Page 2: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/2.jpg)
Spatial Domain
• Spatial domain refers to the aggregate of pixels composing an image. It is expressed as:
• g(x,y) = T[f(x,y)]• where f(x,y) is the input image, g(x,y) is the
processed image and T is an operator on f, defined over some neighborhood of (x,y).
• When we say neighborhood about a point (x,y) means use a square or rectangular subimage area centered at (x,y) as shown in figure.
![Page 3: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/3.jpg)
A 3 x 3 neighborhood about a point (x, y) in an image
![Page 4: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/4.jpg)
Gray Level Transformation
• The centre of this subimage is moved from pixel to pixel starting from top left corner.
• The operator T is applied at each location (x,y) to get the output, g, at that location.
• For neighborhood, shapes such as circle are used. • But square and rectangular arrays are very common.
When T is a 1 X 1 neighborhood, g depends only on the value of f at (x,y), and T becomes a gray-level (called intensity or mapping) transformation function of the form:
• s = T(r)• Here r and s are variables denoting the gray level of
f(x,y) and g(x,y) at any point (x,y).
![Page 5: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/5.jpg)
Contrast Stretching• The effect of this transformation is to produce an image
of higher contrast than the original by darkening the levels below m and brightening the levels above m in the original image.
• This is called as contrast stretching. • Here the values of r below m are compressed by the
transformation function into a narrow range of s, toward black.
• For values of r above m, the opposite happens. • This produces a 2 level image called binary image. • A mapping of this form is called a thresholding function.
• Here the enhnaement at any point in an image depends
only on the gray level at that point, we call it as point processing.
![Page 6: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/6.jpg)
Gray Scale Image
-50 0 50 100 150 200 250 3000
100
200
300
400
500
600
700
800
Thresholded Image
0 50 100 150 200 250 3000
0.5
1
1.5
2
2.5
3
3.5
4x 10
4
![Page 7: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/7.jpg)
clear all; close all; clc;f = imread('bird.gif');f = im2double(f);figure,imshow(f),title('Gray Scale Image');h = imhist(f);h1 = h(1:10:256);horz=1:10:256;figure,bar(horz, h1)%figure,imhist(f);[m n]=size(f);b = zeros(m,n);for i=1:m for j=1:n if f(i,j) >= 0.5 b(i,j)=1; else b(i,j)=0; end endendfigure,imshow(b),title('Thresholded Image');h = imhist(b);
horz=1:256;figure,bar(horz, h)%figure,imhist(b),title('Histogram of Thresholded image');
![Page 8: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/8.jpg)
Gray level transformation function for contrast enhancement
![Page 9: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/9.jpg)
Mask Processing
• One can also use larger neighborhoods called masks.
• It is also called as filters, kernels, templates or windows.
• Mask is a small (say, 3 X 3) 2-D array, in which the values of the mask coefficients determine the nature of the process such as image sharpening.
• Enhancement techniques based on masks are called as mask processing or filtering.
![Page 10: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/10.jpg)
Additive Image Offset
• An additive Image offset has the form• g(x,y) = f(x,y) + L• Here L is an integer. • We assume that image is quantized into integers
in the range {0,1,…,K-1}. I• f L >0, then g(x,y) will be a brightened image. • If L <0, then g(x,y) will be a dimmed image. • If |g(x,y)| becomes < 0 due to additive image
offset operation, then we set |g(x,y)| = 0. • Similarly if |g(x,y)| > K-1, then we set |g(x,y)| =
K-1. • This operation only improves the overall visibility
of the image but it will not improve the contrast.
![Page 11: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/11.jpg)
Gray Scale Imageoffset image
F = F+L(0.3)
offset image
F = F-L(0.3)
![Page 12: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/12.jpg)
clear all; close all; clc;f = imread('bird.gif');f = im2double(f);figure,imshow(f),title('Gray Scale Image');L = 0.3;f1 = f+L;figure,imshow(f1),title(‘Additive image ');f2 = f-L;figure,imshow(f2),title(‘Additive image');
![Page 13: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/13.jpg)
Multiplicative Image Scaling• A multiplicative image scaling by a factor P is given by:• g(x,y) = Pf(x,y)• Here P is assumed to be positive as g(x,y) must be
positive. • But P need not be an integer. • The practical definition for the output is to round the
result as13• g(x,y) = INT[Pf(x,y) + 0.5].• If P > 1, then the gray levels of g will cover a broader
range than those of f. • If P < 1, then g will have a narrower gray-level
distribution than f. • Thus multiplicative scaling either stretches or
compresses the image.
![Page 14: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/14.jpg)
Gray Scale Image
MultiplicativeimageMultiplicative image
F1 = P*FF1 = P*F P=2P=0.5
![Page 15: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/15.jpg)
clear all; close all; clc;f = imread('bird.gif');f = im2double(f);figure,imshow(f),title('Gray Scale Image');L = 2;f1 = f.*L;figure,imshow(f1),title('Multiplicativeimage');L1 = 0.5;f2 = f.*L1;figure,imshow(f2),title('Multiplicative image');
![Page 16: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/16.jpg)
Image Negative
• The linear point operation that uses both scaling and offset is called the image negative and it is given by P = -1 and L = K-1. Hence
• g(x,y) = -f(x,y) + (K-1)• The scaling by P = -1 reverses (flips) the
histogram. • The additive offset L = K-1 is needed so that all
values of the result are positive and fall in the allowable gray-scale range.
• This operation creates a digital negative image. • If the image is already a negative, then it
produces a positive image.
![Page 17: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/17.jpg)
Negative of an imageOriginal Image Negative Image
![Page 18: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/18.jpg)
• % Read a gray scale image and generate the negative of it
• % Read the negative image and by taking its negative get the original image
• % Extend the same technique for color image• clear all; close all; clc;• a=imread('Cameraman.tif');• b=im2double(a);• [m n]=size(b);• for i=1:m• for j=1:n• c(i,j)= 1-b(i,j);• end• end• figure,imshow(a);• figure,imshow(c);
![Page 19: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/19.jpg)
Nonlinear Transformations• Log Transformations• The general form of log transformation is:• s = c log( 1 + r)• Here c is a constant and r ≥ 0. • The shape of the log curve implies that this
transformation maps a narrow range of low gray-level values in the input image into a wider range of output levels.
• The opposite is true for higher values of input levels. • This transformation can be used to expand the values of
dark pixels in an image while compressing the higher level values.
• The opposite is true of the inverse log transformation. Log transformations are mainly used in Fourier spectrum.
![Page 20: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/20.jpg)
Fourier spectrum and Result of applying the log transformation
![Page 21: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/21.jpg)
![Page 22: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/22.jpg)
Power Law Transformations• This transformation has the form:• Here c and γ are positive constants. Like log
transformations, power law curves with fractional values of γ map a narrow range of dark input values into a wider range of output values.
• A variety of devices used for image capture, printing and display respond according to a power law. (eg) Cathode Ray Tube devices have an intensity-to-voltage response that is a power function, with exponents varying from 1.8 to 2.5.
• The display systems tend to produce image that are darker than intended.
• This transformation is also useful for contrast manipulation.
crs
![Page 23: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/23.jpg)
Power law transforms for various gamma values
![Page 24: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/24.jpg)
Gamma = 0.2Original Image After Power-Law Transformation
![Page 25: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/25.jpg)
Power-Law Transformations • % Read a gray scale image and apply the power-law transform for
gamma• % =0.05,0.2,0.67,1.5,2.5,5 and comment your results• clear all;• close all; clc;• f = imread('pout.tif');• f = im2double(f);• [m n]=size(f);• c = 1;• y=input('Gamma value:');• for i=1:m• for j=1:n• s(i,j)=c*(f(i,j)^y);• end• end• figure,imshow(f);• figure,imshow(s);
![Page 26: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/26.jpg)
Contrast stretching• Here low-contrast images can result from poor
illumination, lack of dynamic range in the imaging sensor, or wrong setting of lens aperture during image acquisition.
• The idea of contrast stretching is to increase the dynamic range of gray levels in the image.
• Let us consider a transformation function used for contrast stretching.
• If r1 = s1 and r2 = s2, the transformation is a linear function that produces no changes in gray levels.
• If r1 = r2, s1 =0 and s2 = L-1, the transformation becomes a thresholding function that creates a binary image.
![Page 27: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/27.jpg)
Contrast stretchingOriginal Image Contrast stretched Image
![Page 28: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/28.jpg)
Contrast Stretching
• clear all; close all; clc;• f = imread('cameraman.tif');• f = im2double(f);• m=0.75; %contrast• E=0.55; %slope of the function• g = 1./(1+(m./(f+eps)).^E);• figure,imshow(f);• figure,imshow(g);
![Page 29: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/29.jpg)
Gray level slicing
• Highlighting a specific range of gray levels in an image is often useful.
• To achieve this there are 2 approaches. • One approach is to display a high value for all
gray levels in the range of interest and a low value for all other gray levels.
• This also produces a binary image. • The other kind of transformation is used to
brighten the desired range of gray levels but preserves background and gray-level tonalities in the image
![Page 30: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/30.jpg)
Gray level slicingOriginal Image
Highlights range a & b of gray levels
![Page 31: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/31.jpg)
Gray level slicingOriginal Image Highlights range a & b of gray levels others unchanged
![Page 32: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/32.jpg)
% Gray scale slicingclear all; close all; clc;
f = imread('cameraman.tif');a = 100;b = 200;T1 = 25;
T2 = 250;[m n]=size(f);
for i=1:m for j=1:n
if (f(i,j)< a || f(i,j) > b) f1(i,j)= T1;
else f1(i,j)=T2;
end end
end
![Page 33: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/33.jpg)
f1 = uint8(f1);figure,imshow(f);figure,imshow(f1);T3= 200;for i=1:m for j=1:n if (f(i,j) > a && f(i,j) < b) f2(i,j)= T3; else f2(i,j)=f(i,j); end endendf2 = uint8(f2);figure,imshow(f);figure,imshow(f2);
![Page 34: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/34.jpg)
Bit plane slicing• Sometimes instead of highlighting the gray-level
ranges, highlighting the contribution made to total image by specific bits is desirable.
• Imagine that the image is composed of eight 1-bit planes, ranging from bit-plane 0 for the least significant bit to bit plane 7 for the most significant bit.
• The plane 0 contains all lowest order or bits and plane 7 contains all the high order bits.
• The higher order bits contain the majority of the visually significant data.
• Other planes contain only subtle details. • This process can aid in determining the number
of bits needed to quantize each pixel.
![Page 35: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/35.jpg)
Bit plane slicing
• To get the bit plane 7 one can threshold the image with a thresholding gray-level transformation function that maps all levels in the image between 0 and 127 (eg 0).
• Map the levels between 129 and 255 to another (eg 255).
• Similarly we can obtain the gray-level transformation function for other bit planes.
![Page 36: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/36.jpg)
Original Image Bit-Plane 0
Bit-Plane 1 Bit-Plane 2
![Page 37: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/37.jpg)
Bit-Plane 3 Bit-Plane 4 Bit-Plane 5
Bit-Plane 6Bit-Plane 7
![Page 38: Types of Image Enhancements in spatial domain The objective of enhancement is to process the image so that the resultant image is better than the original](https://reader035.vdocuments.net/reader035/viewer/2022062511/5514358e550346d8488b61b6/html5/thumbnails/38.jpg)
% bit plane slicingclear all; close all; clc;f = imread('onion.png');f = rgb2gray(f);[m n] = size(f);f1(1:m,1:n)=0;s = input('Enter bit levels:');b = [128,64,32,16,8,4,2,1];b1 = [255,128,64,32,16,8,4,2,1];for i = 1:m for j = 1:n for k=1:s if f(i,j)> b(k) f1(i,j)=f1(i,j)+b1(k); % break; else f1(i,j)=f1(i,j); end end endendf1=uint8(f1);figure,imshow(f);figure,imshow(f1);