Code covered by the BSD License  

Highlights from
Study of various Digital Image Processing concepts using MATLAB

image thumbnail

Study of various Digital Image Processing concepts using MATLAB

by

 

Study of various Digital Image Processing concepts using MATLAB. .txt files for C are also included

Prewitt.m
clc;
clear;
close all;

F=double(imread('bwduck.bmp'));
H=F;
I=F;
J=F;
[rows cols]=size(F);
Px=[-1,-1,-1;0,0,0;1,1,1];%prewitt horz
Py=[-1,0,1;-1,0,1;-1,0,1];%prewitt vert
Pxy=[-2,-1,0;-1,0,1;0,1,2];%prewitt combined

G1=zeros(3,3);
G2=zeros(3,3);
G3=zeros(3,3);
for i = 2:1:rows-1
    for j = 2:1:cols-1
        
    for k=-1:1
        for l=-1:1
        G1(k+2,l+2)=F(i+k,j+l)*Px(k+2,l+2);
        G2(k+2,l+2)=F(i+k,j+l)*Py(k+2,l+2);
        G3(k+2,l+2)=F(i+k,j+l)*Pxy(k+2,l+2);
        end
    end
    H(i,j)=sum(sum(G1));
     I(i,j)=sum(sum(G2));
      J(i,j)=sum(sum(G3));
    end
end
H = uint8(round(H - 1));
I = uint8(round(I - 1));
J = uint8(round(J - 1));
figure()
subplot(2,2,1);
imshow(uint8(F));
title('Original Image');
subplot(2,2,2);
imshow(H);
title('Prewitt Horizontal');
subplot(2,2,3);
imshow(I);
title('Prewitt Vertical');
subplot(2,2,4);
imshow(J);
title('Prewitt Combined');

Contact us