Digital Image Processing, Study notes of Digital Image Processing

The detailed and over viewed assignment about the dip

Typology: Study notes

2019/2020

Uploaded on 02/25/2020

mian-saad
mian-saad 🇵🇰

1 document

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Source Code:
A=imread('mango.jpg');
C=rgb2gray(A);
C(C<225)=0;
s=strel('disk',4,0);%Structuring element
D=~im2bw(C);%binary Image
F=imerode(D,s);%Erode the image by structuring element
figure,imshow(A);
title('Original Image');
figure,imshow(D);
title('Binary Image');
%Difference between binary image and Eroded image
figure,imshow(D-F);title('Boundary extracted Image');
Output Images:
:
pf3
pf4
pf5
pf8

Partial preview of the text

Download Digital Image Processing and more Study notes Digital Image Processing in PDF only on Docsity!

Source Code: A=imread('mango.jpg'); C=rgb2gray(A); C(C<225)=0; s=strel('disk',4,0);%Structuring element D=~im2bw(C);%binary Image F=imerode(D,s);%Erode the image by structuring element figure,imshow(A); title('Original Image'); figure,imshow(D); title('Binary Image'); %Difference between binary image and Eroded image figure,imshow(D-F);title('Boundary extracted Image'); Output Images: :

Region Filling:

Source Code: I = imread('coins2.png.gif'); figure imshow(I) title('Original Image') %Convert image to binary image. BW = imbinarize(I); figure imshow(BW) title('Original Image Converted to Binary Image') %Fill holes in the binary image and display the result. BW2 = imfill(BW,'holes'); figure imshow(BW2) title('Filled Image')

Output Images:

Closing:

Source Code: %Read a binary image into the workspace and display it. originalBW = imread('pearlite.png'); imshow(originalBW); se = strel('disk',10); %Perform a morphological close operation on the image. closeBW = imclose(originalBW,se); figure, imshow(closeBW) Output Images:

Dilation:

Source Code: A=imread( 'flower.png' ); figure

imshow(A); title('Original Image') A=im2bw(A); %Structuring element B=[1 1 1 1 1 1 1;]; C=padarray(A,[0 3]); D=false(size(A)); for i=1:size(C,1) for j=1:size(C,2)- D(i,j)=sum(B&C(i,j:j+6)); end end figure,imshow(D); title('Dilation') Output Images:

D=false(size(A)); for i=1:size(C,1) for j=1:size(C,2)- L=C(i,j:j+2); %Find the position of ones in the structuring element K=find(B==1); if(L(K)==1) D(i,j)=1; end end end figure,imshow(D); title('Erosion') Output Images: