Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Basic Intensity Transformation Functions – Part 1

Basic Intensity Transformation Functions – Part 1

Three basic types of functions used for image Enhancement are:
1.       Linear transformation
2.       Logarithmic transformation
3.       Power Law transformation
Consider an Image r with intensity levels in the range [0 L-1]
1.       Image Negatives

Equation : s = L – 1 – r
Consider  L  = 256 and r be the intensity of the image(Range 0 to 255)


MATLAB CODE:

A=imread('rice.png');
figure,imshow(A);title('Original Image');


%Image Negative
L=256;
s= (L-1)-A;
figure,imshow(s);title('Image negative -> S = L - 1 - r')

EXPLANATION:
Consider array r = [ 1 10 255 100]
  S = 256 – 1 – r gives [ 254 245 0 155]




2.       Log Transformation

Equation:  s = c log(1 + r) where c is a constant

Consider  c = 1 and r be the intensity of the image(Range 0 to 255)

%Log Transformation

%Input Image in type double
r=double(A);
C=1;
S=C*log(1+r);
Temp=255/(C*log(256));
%Display image range [0 255]
B=uint8(Temp*S);
figure,imshow(B);title('Log Transformation -> S = clog(1+r)');



EXPLANATION:
a.       Convert the image to type double
b.      Apply the log transformation
c.       Map the obtained values to the range [0 255]

3.       Power –Law (Gamma) corrections

Equation :


Where c and gamma are positive constants

Consider c = 1, gamma =0.04 and r be the intensity of the image (Range 0 to 255)


G=0.40;%Gamma =0.40
S=C*(r.^G);
Temp=255/(C*(255.^G));
%display image range [0 255]
S1=uint8(Temp*S);
figure,imshow(S1);title('Gamma corrected Image -> S = cr^\gamma  \gamma = 0.40 c = 1');





Plots of the Equation:

%Power Law(Gamma) Transformation
GRng=[0.04; 0.10; 0.20; 0.40; 0.67; 1; 1.5; 2.5; 5.0; 10.0; 25.0];
R=0:255;
figure,
for i = 1 : 11
X=C*(R.^GRng(i));
Temp=256/X(256);
s=Temp*X;
plot(R,s);
title('Plot Equation S = Cr^\gamma');
xlabel('Input Intensity Level,r');
ylabel('Output Intensity Level,s');
text(R(175),s(175),['\gamma = ',num2str(GRng(i))],'HorizontalAlignment','left');
hold all
axis([0 255 0 255]);
end


EXPLANATION:
The transformation is plotted for different values of gamma for the intensity levels [ 0 255].
The output image intensity values are mapped to the range [0 255]










like button Like "IMAGE PROCESSING" page
Previous Post Next Post Home
Google ping Hypersmash.com