Skip to content

Morphological Operations on Image

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 printdip speechimages5.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 printdip speechimages5.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 printdip speechimages6.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

7 thoughts on “Morphological Operations on Image”

  1. Good day! This is my first comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading your posts. Can you suggest any other blogs/websites/forums that deal with the same subjects? Thanks a ton!|

  2. We are a gaggle of volunteers and starting a brand new scheme in our community. Your site provided us with helpful info to work on. You have performed an impressive activity and our entire group can be thankful to you.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!