Filters in Matlab (Filter Codes)
Filters in Matlab (Filter Codes)
Filters in Matlab (Filter Codes)
FILTERS IN MATLAB
Submitted to:
Miss Bushra Sikander
Submitted by:
Nousheen hashmi
Date:
6/7/2012
Department:
BS(CS)-VIII
Laplacian Filter:
lap_mask=[0 -1 0;-1 4 -1;0 -1 0]; H1 = fspecial('laplacian'); L_img=imfilter(img,H1); figure; imshow(L_img); title('Edge Detected(Laplacian) Image');
Gradient Filter:
%Horizontal G_H_mask=[-1 1]; G_H_img=imfilter(img,G_H_mask); %Vertical G_V_mask=[-1;1]; G_V_img=imfilter(img,G_V_mask); figure; title('Gradient image'); subplot(1,2,1);imshow(G_H_img); title('Gradient Horizontal image'); subplot(1,2,2);imshow(G_V_img); title('Gradient Vertical Image');
Robert Filter:
R_H_mask=[-1 0;0 1]; R_H_img=edge(img,'roberts'); figure; imshow(R_H_img); title('Robert Filtered Image');
Sobel Filter:
S_H_mask=[-1 -2 -1;0 0 0;1 2 1]; S_H_img=edge(img,'sobel'); figure; imshow(S_H_img); title('Sobel Filtered Image');
My Masks Filter:
%Mask1 mask1=[-1 -2 -1;-2 12 -2;-1 -2 -1]; mask1_img=imfilter(img,mask1); %Mask2 mask2=[-1 -2 -1;-2 -12 -2;-1 -2 -1]; mask2_img=imfilter(img,mask2); figure; subplot(1,2,1);imshow(mask1_img); title('Mask1 Filtered Image'); subplot(1,2,2);imshow(mask2_img); title('Mask2 Filtered Image')