声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1484|回复: 3

[图像处理] 求助matlab边缘检测

[复制链接]
发表于 2013-5-24 22:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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');



这是编的代码,结果不行,不知道怎么操作好,求大神们指教
2.jpg
1.jpg
回复
分享到:

使用道具 举报

发表于 2013-5-26 00:15 | 显示全部楼层
有无报错?
 楼主| 发表于 2013-5-26 13:01 | 显示全部楼层
发表于 2013-5-26 22:25 | 显示全部楼层
我爱编程 发表于 2013-5-26 13:01
没有报错,但是分界效果不好,应该是方法思路不对,不知道还能怎么做,有没有更好的方法

所以非编程问题! 图像处理没玩过, 无法协助
同待高人路过
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-20 22:51 , Processed in 0.062880 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表