马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
跪求各路大神,如何用matlab检测出图中最上面亮条纹的上边界,和最下面亮条纹的上下两边界(每张图共三条边界)?诚心跪求
clear all;
close all;
I = imread('PIC.jpg');
I = rgb2gray(I); % convert to intensity;
figure, imshow(I);
I = imcrop(I,[15,15,480,210]);
figure, imshow(I);
H = fspecial('gaussian',6,0.55);
%用图像滤波函数imfilter处理
I = imfilter(I,H,'replicate');
I=imadjust(I,[0.3 0.7],[0 1],1);
I = imfilter(I,H,'replicate');
I=imadjust(I,[0.3 0.7],[0 1],1);
figure, imshow(I);
figure;
BW = edge(I,'canny');
[H,T,R] = 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 = [lines(k).point1; lines(k).point2];
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');
这是编的代码,结果不行,不知道怎么操作好,求大神们指教
|