0% found this document useful (0 votes)
25 views

Homework 01 Example

This document summarizes a student homework assignment on image enhancement using point processing techniques in MATLAB. The homework involves choosing one image enhancement method, writing code to implement it, and creating a GUI to display the input and output images. The document provides code samples for four point processing methods - negative image, thresholding, power law transformation, and logarithmic transformation. It also describes implementing a GUI with buttons to input images, apply the different techniques, and reset to the original image. Results of applying each method to an example image are displayed.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Homework 01 Example

This document summarizes a student homework assignment on image enhancement using point processing techniques in MATLAB. The homework involves choosing one image enhancement method, writing code to implement it, and creating a GUI to display the input and output images. The document provides code samples for four point processing methods - negative image, thresholding, power law transformation, and logarithmic transformation. It also describes implementing a GUI with buttons to input images, apply the different techniques, and reset to the original image. Results of applying each method to an example image are displayed.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

VIETNAM NATIONAL UNIVERSITY HCMC

INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING
--------------------------

IMAGE PROCESSING

HOMEWORK 01
IMAGE ENHANCEMENT-POINT PROCESSING

Students : Nguyễn Hữu Minh Hoàng – EEEEIU13005


Nguyễn Lập Phương Uyên – EEEEIU13115

HCM City. Feb. 28, 2017

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

2.2. Thresholding transformation


Thresholding transformation is useful for defining the boundary in which we
want to isolate an object of interest from a background.
The algorithm of thresholding transformation:
s= 1 , r >threshold
{
0 , r <threshold
Matlab code:
Th=input('Enter desired Thresholding value: ');
s2=r>Th;
imshow(s2); %output the image

3
Fig 2. Output image with threshold value 0.5

2.3. Power law transformations


Power law transformations map a narrow range of dark input values into a
wider range of output values, with the opposite being true for the higher
values.
Algorithm:
s=c × r γ
For simplicity, we set c = 1
Matlab code:
p=input('Enter desired Power value: ');
[m,n]=size(I);
for i=1:m
for j=1:n
J(i,j)=I(i,j)^p;%Power Law with power of p
end

end

(original image) (power value=2)

(power value = 0.3)

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

(original image) (const = 1)

(const = 2) (const = 3)

5
3. Implementation by GUI
- Create a file GUI as figure below:

- Definition of buttons used in GUI:


+Input image: input a picture from computer
+reset: reset the output picture to the original picture
+ Negative image: apply Negative transformation method for image
enhancement.
+Thresholding: apply Thresholding transformation method for image
enhancement. Noted that there is a textbox below this button for entering the
desired threshold value.
+Power Law: apply Power Law transformation method for image
enhancement. Noted that there is a textbox below this button for entering the
desired power value.

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:

+ Result of thresholding transformation method (threshold value = 125):

8
+ Result of Power Law transformation method (power value = 0.3):

+ Result of logarithmic transformation (coefficient value = 3):

9
Once finishing the process, you can input a new picture, or reset to the original
picture

10

You might also like