You are on page 1of 6

Islamic University Of Gaza Digital Image Processing

Faculty of Engineering Discussion


Computer Department Chapter 3
Eng. Ahmed M. Ayash Date: 03/03/2013

Chapter 3
Image Enhancement in the Spatial Domain
Part 1

1. Theoretical

 Enhancement
 The principal objective of enhancement is to process an image so that the result is
more suitable than the original image for a specific application.

 Image enhancement approaches fall into two broad categories:


o Spatial domain methods: Techniques are based on direct manipulation of pixels in
an image.
o Frequency domain methods: Techniques are based on modifying the Fourier
transform of an image

 The general form of the enhancement approach is:

S = T(r)

where T is a transformation that maps a pixel value (intensity) r into a pixel value s.

 Gray Level Transformations


 Three basic types of functions used frequently for image enhancement
o Linear (negative and identity transformation)
o Logarithmic (log and inverse-log transformation)
o Power-law (nth power and nth root transformation)

1
Linear
 Identity: s = r, no transformation

 Image Negatives: assume the gray level range is [0, L-1]:

S = L-1-r
L=0,1,2,3,4 =total 5
L=5

r=value of exact row

2
Logarithmic
 Log Transformations

S = c log(1+r)

- Where c is a constant and it is assumed that r≥0.


- Stretch low gray levels and compress high gray level.
- maps a narrow range of dark input values into a wider range of output values.

 The opposite of this applies for inverse-log transform.

Power-law
 Power-Law Transformations:

S = c rγ

 where c and γ are positive constants

 γ < 1  T plays as log transformation.


 γ > 1  T plays as inverse log transformation.
 c = γ = 1  Identity function
 This transformation function is also called as gamma correction.

3
2. Practical
Example1: Image Negatives
%img_neg.m
close all;
clear all;
I=imread('ch3.jpg');
I=im2double(I);

for i=1:size(I,1)
for j=1:size(I,2)
I1(i,j)=1-I(i,j);
end
end
subplot(121),imshow(I),title('original image')
subplot(122),imshow(I1),title('enhanced image (image negative)')

Output:

Example2: Power-Law Transformations


%power_tr.m
close all;
clear all;
clc;
I=imread('ch3.tif');
I=im2double(I);
c=input('Enter the value of the constant c=');
g=input('Enter the value of gamma g=');
for i=1:size(I,1)
for j=1:size(I,2)
I3(i,j)=c*I(i,j)^g;
end
end
subplot(121), imshow(I),title('original image')
subplot(122), imshow(I3),title('power-low transformation')

4
Output:

Enter the value of the constant c=1


Enter the value of gamma g=0.2 % for gamma value less than 1 u gets Bright image

Enter the value of the constant c=1


Enter the value of gamma g=1 % for gamma value equals to 1 the result will be the same image

5
Enter the value of the constant c=1
Enter the value of gamma g=5 % for gamma value greater than 1 u gets dark image

3. Homework:
1. Repeat Example1 (Image Negatives) without converting the image to double, your output should
be the same as example1 output.

2. Write a Matlab code to apply Log Transformations function.