Aim:- Image Enhancement Frequency Domain
MSc Computer Science Image Processing Practical No. 9
Index of all Practicals ~ Click Here
Code:- Image_seg.m
Output:-
MSc Computer Science Image Processing Practical No. 9
Index of all Practicals ~ Click Here
Code:- Image_seg.m
clc;clear all;close all;
im=imread('car.jpg');
im1=rgb2gray(im); % RGB2GRAY --> Convert RGB image or colormap to grayscale.
im2=medfilt2(im1,[3 3]); % MEDFILT2 --> Perform 2-D median filtering. Median filtering the image to remove noise
BW = edge(im2,'sobel'); % EDGE --> Find edges in intensity image.
[imx,imy]=size(BW); % Dimensions
msk=[0 0 0 0 0; % Mask
0 1 1 1 0;
0 1 1 1 0;
0 1 1 1 0;
0 0 0 0 0;];
B=conv2(BW,msk); % CONV2 Two dimensional convolution. Smoothing image
% to reduce the number of connected components
L = bwlabel(B,8); % BWLABEL-> Calculating connected components
mx=max(max(L));
[r,c] = find(L==15); % FIND-> Find indices of nonzero elements.
rc = [r c];
[sx sy]=size(rc);
n1=zeros(imx,imy); % zeros --> Zeros array
for i=1:sx
x1=rc(i,1);
y1=rc(i,2);
n1(x1,y1)=255; % Storing the extracted image in an array
end
figure('Name','Input Image'),imshow(im);
figure('Name','Gray Image'),imshow(im1);
figure('Name','Median Filtered Image (Noise Removal)'),imshow(im2);
figure('Name','Smoothing Image'),imshow(B);
figure('Name','Extracted Image'),imshow(n1,[]);
I = imread('canoe.tif');
BW1 = edge(I,'sobel');
BW2 = edge(I,'canny');
figure, imshow(I)
figure, imshow(BW1)
figure, imshow(BW2)
im=imread('car.jpg');
im1=rgb2gray(im); % RGB2GRAY --> Convert RGB image or colormap to grayscale.
im2=medfilt2(im1,[3 3]); % MEDFILT2 --> Perform 2-D median filtering. Median filtering the image to remove noise
BW = edge(im2,'sobel'); % EDGE --> Find edges in intensity image.
[imx,imy]=size(BW); % Dimensions
msk=[0 0 0 0 0; % Mask
0 1 1 1 0;
0 1 1 1 0;
0 1 1 1 0;
0 0 0 0 0;];
B=conv2(BW,msk); % CONV2 Two dimensional convolution. Smoothing image
% to reduce the number of connected components
L = bwlabel(B,8); % BWLABEL-> Calculating connected components
mx=max(max(L));
[r,c] = find(L==15); % FIND-> Find indices of nonzero elements.
rc = [r c];
[sx sy]=size(rc);
n1=zeros(imx,imy); % zeros --> Zeros array
for i=1:sx
x1=rc(i,1);
y1=rc(i,2);
n1(x1,y1)=255; % Storing the extracted image in an array
end
figure('Name','Input Image'),imshow(im);
figure('Name','Gray Image'),imshow(im1);
figure('Name','Median Filtered Image (Noise Removal)'),imshow(im2);
figure('Name','Smoothing Image'),imshow(B);
figure('Name','Extracted Image'),imshow(n1,[]);
I = imread('canoe.tif');
BW1 = edge(I,'sobel');
BW2 = edge(I,'canny');
figure, imshow(I)
figure, imshow(BW1)
figure, imshow(BW2)
Output:-
0 comments:
Confused? Feel free to ask
Post a Comment