求助matlab边缘检测
跪求各路大神,如何用matlab检测出图中最上面亮条纹的上边界,和最下面亮条纹的上下两边界(每张图共三条边界)?诚心跪求clear all;
close all;
I= imread('PIC.jpg');
I= rgb2gray(I); % convert to intensity;
figure, imshow(I);
I = imcrop(I,);
figure, imshow(I);
H = fspecial('gaussian',6,0.55);
%用图像滤波函数imfilter处理
I = imfilter(I,H,'replicate');
I=imadjust(I,,,1);
I = imfilter(I,H,'replicate');
I=imadjust(I,,,1);
figure, imshow(I);
figure;
BW = edge(I,'canny');
= hough(BW);
imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P= houghpeaks(H,4,'threshold',ceil(0.4*max(H(:))));
x = T(P(:,2));
y = R(P(:,1));
plot(x,y,'s','color','white');
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',70,'MinLength',27);
figure, imshow(I), hold on
max_len = 0;
for k = 1:length(lines)
xy = ;
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
end
% highlight the longest line segment
plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','cyan');
这是编的代码,结果不行,不知道怎么操作好,求大神们指教
有无报错? ChaChing 发表于 2013-5-26 00:15 static/image/common/back.gif
有无报错?
没有报错,但是分界效果不好,应该是方法思路不对,不知道还能怎么做,有没有更好的方法 我爱编程 发表于 2013-5-26 13:01 static/image/common/back.gif
没有报错,但是分界效果不好,应该是方法思路不对,不知道还能怎么做,有没有更好的方法
所以非编程问题! 图像处理没玩过, 无法协助
同待高人路过
页:
[1]