how do i find out the perfect edge

1 次查看(过去 30 天)
Iam writing the code to detect the edge of a leaf in matlab code,but Iam unable to find out the clearcut edge formation my code is
clc
close all;
clear all;
a=imread('t.jpg');
figure(1);
subplot(3,3,1);
imshow(a);
title('Actual image');
g=rgb2gray(a);
subplot(3,3,2);
imshow(g);
title('Gray image');
[r c l]=size(a);
o(:,:)=a(:,:,1);
x=0;y=0;
bw=im2bw(a,0.4);
subplot(3,3,3)
imshow(bw)
title('binarized image');
s=imcomplement(bw);
subplot(3,3,4)
imshow(s)
title('complement for binarized image')
for i=1:r
for j=1:c
for k=1:3
if g(i,j)<=80
o(i,j)=0;
elseif g(i,j)>80
o(i,j)=255;
end
if(s(i,j)==255)
x=x+1;
w=x*0.00147;
elseif(s(i,j)==0)
y=y+1;
b=y*0.00147;
end
end
end
end
c=edge(s,'canny');
subplot(3,3,5);
imshow(c);
title('canny');
p=edge(s,'log');
subplot(3,3,6);
imshow(p);
title('log filter');
p=edge(s,'roberts');
subplot(3,3,7);
imshow(p);
title('roberts filter');
p=edge(s,'sobel');
subplot(3,3,8);
imshow(p);
title('sobel filter');

回答(1 个)

Walter Roberson
Walter Roberson 2017-2-13
You cannot get perfect edge detection from a JPEG image, unless it is one of the rare lossless JPEG images. JPEG blurs edges in strange ways.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by