What is Image Processing?
Image processing is the study of any algorithm that
Takes an image as input and returns an image as output .
Includes:
Image display and printing
Image editing and manipulation
Image enhancement
Feature detection
Image compression
Project requirements
Image Enhancement Using Intensity Transformations:
1- Linear Contrast Stretching technique
is a simple image enhancement technique that improves the
contrast in an image by stretching the range of intensity values
it contains to span a desired range of values.
Code
1. Fig3=imread('Fig3.10(b).jpg');
2. maxPix=max(Fig3(:));
3. minPix=min(Fig3(:));
4. NewImg=zeros(500,'uint8');%creat new zeros matrix & Convert
to 8-bit unsigned intege
5. for i=1:500
6. for j=1:500
7. NewImg(i,j)=((255/(maxPix-minPix))*(Fig3(i,j)-
minPix));
8. End end
9. figure,
10. subplot(2,2,1);
11. imshow(Fig3);title('Original Image with low
contrast');
12. subplot(2,2,2);
13. imhist(Fig3);title('Original image with low
contrast');
14. subplot(2,2,3);
15. imshow(NewImg);title('Contrast stretching');
16. subplot(2,2,4);
17. imhist(NewImg);title('Enhancement image with Linear
Contrast Stretching ');
(Before Contrast)
(After contrast)
(Before Contrast) (After contrast)
Image become better as histogram covered
Histogram is narrow and centered toward Broad range of the gray scale and distribution of
The middle of gray level pixels is not too far from uniform with very few
vertical lines being much higher than other
(image with higher contrast)
the mean and Standard Deviation of the original and the enhanced images
origin= mean2(Fig3) enhanced= mean2(NewImg)
origin =
109.0753 enhanced =
95.3764
origin=std2(Fig3) enhanced=std2(NewImg)
origin= enhanced =
11.4980 57.4898
2- a power-law transformation:
There are further two transformation is power law transformations, that include
nth power and nth root transformation.
These transformations can be given by the expression: s=cr^
Variation in the value of varies the enhancement of the images.
Different display devices / monitors have their own gamma correction, thats why
they display their image at different intensity.
Code
1. oldimag=imread('Fig3.10(b).jpg');
2. OldImag=im2double(oldimag); %Convert image to double precision
3. C=1;
4. gamma=3;
5. Newimag=C*OldImag.^(gamma);
6. subplot(2,2,1);imshow(OldImag);title('Original Image with low
contrast')
7. subplot(2,2,2)
8. imhist(OldImag);title('Original Image with low contrast')
9. subplot(2,2,3);imshow(Newimag);title('Enhancement image ')
10. subplot(2,2,4);
11. imhist(Newimag);title('Enhancement image with power-law
transformation ')
(before)
(After at gamma=3)
(After at gamma<1)
Before Enhancement After Enhancement
When the is reduced too much, the image
begins to reduce contrast to the point
where the image started to have very slight
Histogram is narrow and centered toward look, especially in the background
The middle of gray level As gamma = 3 we observe that the
contrast concentrated near dark side some
detail is lost)
As gamma <1 we can observe that the
contrast concentrated near light side
After this operation, we can conclude that: A method which is quite
useful for enhancing an image may not necessarily be the best approach
for enhancing another image. (best technique for enhancement of X-ray
image may not be the best for enhancement of microscopic images)
the mean and Standard Deviation of the original and the enhanced images
origin= mean2(oldimag) With gamma=3
origin = enhanced= mean2(Newimag)
109.0753 enhanced=
0.0809
With gamma=0.5
enhanced= mean2(Newimag)
enhanced=
0.6531
origin=std2(oldimag) With gamma=3
origin = enhanced=std2(Newimag)
11.4980 enhanced =
0.0255
With gamma=0.5
enhanced =std2(Newimag)
enhanced =
0.0344