Digital ImageProcessing 5
Digital ImageProcessing 5
University of Diyala
Computer Science Department
Image Processing
3rd Class
Lecturer: Dr. Jumana Waleed Salih
Image Processing
معالجة صور
5 th lecture
1
Introduction to Image Enhancement
For the enhancement in the spatial domain, we use the transform function:
g(x,y) = T [f(x,y)]
f(x,y) --- input image,
g(x,y) --- output image,
T --- a transform
The object transformed may be a sub-image with 2x2, 3x3 or 1x1. For simplicity, 1x1,
so we have s = T (r)
r --- gray-level value for an inputting pixel
s --- gray-level value for an outputting pixel
Grey-level value transform graph
We use a graph to denote the transform function s = T (r).
2
Some Simple Enhancement Methods
1- Image negatives
Example:
>> f=imread('E:\rose.jpg');
>> size (f)
ans =
252 237
>> imshow(f);
>> c=imcomplement(f);
>> figure; imshow(c);
>> imwrite ( c, 'E:\rosecomplement.jpg');
3
2- Contrast stretching
For a low-contrast image, we feel it uncomfortable and sometimes cannot see any
details clearly.
Histogram Processing
What is the histogram of an image?
The distribution of the pixel gray level is very important for an image display. For a
limited gray-level domain [0, L-1] we hope there is a uniform distribution of the pixel
gray level instead of non-uniform distribution. Based on the distribution of the pixel
gray level we define the image histogram.
For a digital image with gray levels in the range [0, L-1], we define a discrete
function:
Where:
nk is the number of the pixels with the gray level rk
n is the total number of pixels in the image.
We call p(rk) the histogram of a digital image.
Four special histograms are as follows.
4
Histogram equalization
Sometimes we need to convert a low-contrast image into a high-contrast image for
displaying it better. We can do it by extending its histogram.
5
Example:
>> f=imread('E:\rose.jpg');
>> imshow(h);
>> figure; imhist(f);
>> h=histeq(f, 256);
>> figure; imhist(h);
>> figure; imshow(h);
Image Subtraction
The result is that the different parts between two images are kept but the same parts
between them are removed (become dark). A typical application is the medical X-ray
image test for a specific body area of the patient.
>> sub=f-g;
>> imshow(sub);
6