You are on page 1of 27

FACULTY OF ELECTRICAL ENGINEERING

UNIVERSITI TEKNOLOGI MARA

ELECTRICAL ENGINEERING LABORATORY [ECE645]


LAB REPORT

DIGITAL IMAGE PROCESSING LAB

NAME NO MATRIC GROUP


MUHAMAD AMIRUL AIZAD BIN ZUKRI 2014623502 EE2007D1/D2
List of Experiments

1. Display of Grayscale Images.


2. Histogram Equalization.
3. Edge detection
4. Image enhancement.
5. Image segmentation.

REFERENCE:

1. Rafael C. Gonzalez, Richard E. Woods, Steven Eddins,' Digital Image Processing


using MATLAB', Pearson Education, Inc., 2004.

LIST OF EQUIPMENTS:

Computer, Software MATLAB


Lab Experiment 1 : Display of Gray scale Images.
Aim:
To display the Gray scale images.

Result:
Histogram Equalization

Aim: to enhance contrast using Histogram Equalization.

I = imread('tire.tif');

J = histeq(I);

imshow(I)

Results:

figure,imshow(J)

Results:
figure,imhist(I,64)

Results:

figure,imhist(J,64)

Results:
Edge Detection using Function

Aim: to detect the edge of the Grayscale images.

I = imread('circuit.tif');

IEr = edge(I,'roberts');

IEp = edge(I,'prewitt');

IEs = edge(I,'sobel');

To demonstrate edge detection.

subplot(2,2,1),imshow(I);

subplot(2,2,2),imshow(IEr);

subplot(2,2,3),imshow(IEp);

subplot(2,2,4),imshow(IEs);

Results:
Image Enhancement

Aim: to detect the result of enhancing image using filtering.

To demonstrate image filtering.

(a) Average filter.

fspecial('average',3)

ans =
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111

fspecial('average',11)

ans =
Columns 1 through 6
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
Columns 7 through 11
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083

C = imread('cameraman.tif');
F1 = fspecial('average');
CF1 = filter2(F1,C);
imshow(C);

Results:
figure,imshow(uint8(CF1));

Results:
(b) Laplacian

clear all;
close all;
F = imread('moon.tif');
W = fspecial('laplacian',0); W = [0 1 0; 1 -4 1; 0 1 0];
G1 = imfilter(F,W,'replicate');
figure(1),imshow(G1,[]);

Results:
F2 = im2double(F);
G2 = imfilter(F2,W,'replicate');

figure(2),imshow(G2,[]);

Results:
G = F2-G2;
figure(3),imshow(G);

Results:
(c) Laplacian 2

clear all;
close all;
F = imread('moon.tif');
W4 = fspecial('laplacian',0);
W8 = [1 1 1; 1 -8 1; 1 1 1];
F = im2double(F);
G4 = F-imfilter(F,W4,'replicate');
G8 = F-imfilter(F,W8,'replicate');

Results:

figure(4),imshow(F);
figure(5),imshow(G4);
figure(6),imshow(G8);

(d) Laplacian 3

clear all;
close all;
F = imread('moon.tif');
W = [0 -1 0; -1 9 -1; 0 -1 0];
G1 = imfilter(F,-W,'replicate');
Results:

figure(1),imshow(G1,[]);

F2 = im2double(F);
G2 = imfilter(F2,-W,'replicate');
figure(2),imshow(G2,[]);
Results:

G = F2-G2;
figure(3),imshow(G);

Results:
(e) High Boost Filtering

clear all;
close all;
F = imread('moon.tif');
A = 2;
W4 = [0 -1 0; -1 A+8 -1; 0 -1 0];
W8 = [-1 -1 -1; -1 A+8 -1; -1 -1 -1];
F = im2double(F);
G4 = F-imfilter(F,-W4,'replicate');
G8 = F-imfilter(F,-W8,'replicate');

Results:

figure(1),imshow(F);
figure(2),imshow(G4);

figure(3),imshow(G8);
Segmentation

Aim: to detect the edge of border using images segmentation.

To demonstrate image segmentation.

(a) Segment by point processing Threshold.

>> close all;


>> I = imread('cell.tif');
>> figure,imshow(I);
>> figure,imhist(I);
>> T = 110;
>> Z = im2bw(I,T/255);
>> figure,imshow(Z);

Results:
(b) Otsu Method

>> close all;


>> A = imread('cell.tif');
>> figure,imshow(A);
>> figure,imhist(A);
>> B = graythresh(A);
>> C = im2bw(A,B);
>> figure,imshow(C);

Results:
(C)

>> close all;


>> I = imread('cell.tif');
>> figure,imhist(I);
>> figure,subplot(221),imshow(I);
>> subplot(222),im2bw(I,0.6);
>> [counts,X] = imhist(I);
>> P = polyfit(X,counts,6);
>> Y = polyval(P,X);
>> [V,ind] = sort(abs(diff(Y)));
>> secondd = diff(V);
>> [valuem,i] = min(secondd);
>> thresh = ind(i)/255;
>> subplot(223),im2bw(I,thresh);
>> level = graythresh(I);
>> subplot(224),im2bw(I,level);
>> figure,plot(X,counts);
>> hold on;plot(X,Y,'r');
Results:
(d) Watershed Segmentation

>> close all;


>> I = imread('cell.tif');
>> S = imtophat(I,strel('disk',10));
>> figure,imshow(I);
>> figure,imshow(S);
>> level = graythresh(S);
>> BW = im2bw(S,level);
>> figure,imshow(level);
>> figure,imshow(BW);
>> C = ~BW;
>> figure,imshow(C);
>> D = -bwdist(C);
>> D(C) = -Inf;
>> L = watershed(D);
>> W = label2rgb(L,'hot','w');
>> figure,imshow(W);
>> im = I;
>> im(L==0)=0;
>> figure,imshow(im);

Results:

You might also like