Friday, 21 September 2012


Morphological Operations on Image

A) Opening
B) Closing
C) Morphological Gradient
D) Top-hat Transformation

(A) Opening

Code
Clc;
clear all;
close all;

a=imread('D:\final print\dip speech\images5.jpg');
         se=[1 1 1 1 1];
         b=imerode(a,se);
c=imdilate(b,se);
        
subplot(1,2,1);
imshow(a);
title('Original Image');

subplot(1,2,2);
imshow(c);
title('Opening of Image');

Output Of An Opening Image



(B) Closing

Code
clc;
clear all;
close all;
a=imread('D:\final print\dip speech\images5.jpg');
se =[1 1 1 1 1 1 1 1 1];
e=imdilate(a,se);
f=imerode(e,se);

subplot(1,2,1);
imshow(a);
title('Original Image');

subplot(1,2,2);
imshow(f);
title('Closing of Image');

Output Of An Closing Image




(C) Morphological gradient

Code
clc;
clear all;
close all;

a=imread('D:\final print\dip speech\images6.jpg');
se=strel('square',5);
b=imdilate(a,se);
c=imerode(a,se);
d=imsubtract(b,c);
subplot(2,2,1);
imshow(a);
title('original');
subplot(2,2,2);
imshow(d);
title('Morphological Gradient image');

Output Of An Morphological gradient




(D)Top Hat transformation CODING

Code
clc;
close all;
clear all;
a=imread('Jesus.jpg');
d=a;
         se=[1 1 1 1];
         b=imdilate(a,se);
c=imerode(a,se);
[row col]=size(c);
for i=1:row
                 for j=1:col
                    d(i,j)=b(i,j)-c(i,j);
                 end
end
         subplot(1,2,1);
imshow(a);
title('Original Image');
         subplot(1,2,2);
imshow(d);
title('Top Hat Trasnformed Image');

Output Of An Top Hat transformation


Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment