Edge Strength Calculation considering the boundary(Zero Padding) | MATLAB | Digital Image Processing

preview_player
Показать описание
Code:

clc
clear all
close all
warning off
subplot(2,2,1);
imshow(a);
title('Original Input Image');
a=double(a);
w1=[-1 -2 -1;0 0 0;1 2 1];
w2=[-1 0 1;-2 0 2;-1 0 1];
[row col]=size(a);
newA = zeros(size(a)+2);
newA(2:end-1,2:end-1)=a;
row=row+2;
col=col+2;
a=newA;
a1=zeros(row,col);
a2=zeros(row,col);
for x=2:1:row-1
for y=2:1:col-1
a1(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)+w1(3)*...
a(x-1,y+1)+w1(4)*a(x,y-1)+w1(5)*a(x,y)+w1(6)*...
a(x,y+1)+w1(7)*a(x+1,y-1)+w1(8)*a(x+1,y)+w1(9)*...
a(x+1,y+1);
a2(x,y)=w2(1)*a(x-1,y-1)+w2(2)*a(x-1,y)+w2(3)*...
a(x-1,y+1)+w2(4)*a(x,y-1)+w2(5)*a(x,y)+w2(6)*...
a(x,y+1)+w2(7)*a(x+1,y-1)+w2(8)*a(x+1,y)+w2(9)*...
a(x+1,y+1);
end
end
aa1=a1(2:end-1,2:end-1);
subplot(2,2,2);
imshow(uint8(aa1));
title('Edge Detection in y direction');
aa2=a2(2:end-1,2:end-1);
subplot(2,2,3);
imshow(uint8(aa2));
title('Edge Detection in x direction');
output=sqrt((aa1.^2)+(aa2.^2));
subplot(2,2,4);
imshow(uint8(output));
title('Edge Strength');
output=aa1+aa2;
figure;
imshow(uint8(output));
title('Edge Detection');

Prerequisite:
Sobel Edge Detection without built-in function (MATLAB)
VVI point to be remembered if using own code for Edge Detection
Рекомендации по теме
Комментарии
Автор

Hi, i was watching the MatLab dominant color video. Is there a way I can automate the process and select multiple images at the same time? Thank you!

cristianvintu
welcome to shbcf.ru