| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 787 人关注过本帖
标题:求助matlab边缘检测
只看楼主 加入收藏
gxtwztx
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-5-24
收藏
 问题点数:0 回复次数:0 
求助matlab边缘检测
跪求各路大神,如何用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');

 
这是编的代码,结果不行,不知道怎么操作好,求大神们指教




图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 检测 all convert matlab figure 
2013-05-24 22:18
快速回复:求助matlab边缘检测
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014931 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved