Homework 01 Example
Homework 01 Example
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING
--------------------------
IMAGE PROCESSING
HOMEWORK 01
IMAGE ENHANCEMENT-POINT PROCESSING
1
Homework 01:
- Choose at least one method of image enhancement using point processing in
lectrure 02.
- Write a Matlab program to perform the point processing method which you
have choose.
- Use GUI in Matlab to write the inteface to display the input image and output
image.
- Present and explain your Matlab code, discuss the results
Solution 01:
1. Input image
Step 1: Using the command “imread” to input the picture
f=imread('pic2.jpg'); %read data from picture 1
the picture now is in uint8 class and rbg value
Fig.
1: Original Image
Step 2: Converting the picture data to gray value and double class
r=rgb2gray(f); %convert rbg value to gray value
r=im2double(r); %convert picture data into double class
Convention for next part:
s: the gray value of output image
r: the normalize gray value of input image (0 < r < 1)
2
2. Image enhancement using point processing
The aim of this report is to enhance the image by using 4 methods:
Negative images
Thresholding
Power law
Logarithmic transformation
2.1. Negative image
Negative image is method that converts white to black and viceversa.
It is usually used for enhancing white or gray details in dark regions.
The algorithm of negative image:
s=1−r
Matlab code:
l=ones(size(r)); %create a matrix 1 with size of input image
s1=l-r;
imshow(s1); %output the image
3
Fig 2. Output image with threshold value 0.5
end
4
2.4. Logarithmic transformations
The log transformation maps a narrow range of low grey level values in the
input image into a wider range of output values. The opposite is true of
higher values of the input levels.
The log transform is usually used to extend the lower values while
compressing the higher value levels.
The algorithm of log transform:
s=c × log (1+ r )
where c is a constant
Matlab code:
c=input('Enter desired coefficient value: ');
[m,n]=size(I);
for i=1:m
for j=1:n
G(i,j)=c*log(I(i,j)+1);%Logarithmic transformation
end
end
(const = 2) (const = 3)
5
3. Implementation by GUI
- Create a file GUI as figure below:
6
+Logarithmic: apply Logarithmic transformation method for image
enhancement. Noted that there is a textbox below this button for entering the
desired coefficient.
- Operation: the figure below shows the output of the GUI file:
7
+ Result of negative transformation method:
8
+ Result of Power Law transformation method (power value = 0.3):
9
Once finishing the process, you can input a new picture, or reset to the original
picture
10