| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2132 人关注过本帖
标题:提取中心线后用hough拟合直线程序有问题,希望大家给指点一下
只看楼主 加入收藏
k18247171258
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-5-18
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
提取中心线后用hough拟合直线程序有问题,希望大家给指点一下
clc;
clear all;
close all;
I=imread('tu1.jpg');%由于图像本身为灰度图像,所以不需要灰度化
% I2=rgb2gray(I);
figure(1),imshow(I);

%%%%提取中心线start%%%%%%%%%%
a=I;
[max_a index]=max(a);              %找出a的格式
b=repmat(max_a,size(a,1),1);     %按矩阵a格式复制b矩阵,b矩阵全是最大值
a(a<b)=0;                                %矩阵a中小于最大值的元素全变为0
figure(2),imshow(a);
%%%%%%%提取中心线end%%%%%%%%%%%%
%%%%%%%%%%%hough变换检测直线start%%%%%%%%%%%%
BW=a;
[H,T,R] = hough(BW,'RhoResolution',0.5,'ThetaResolution',0.5);
% display the original image显示原始图像
figure(3),imshow(imadjust(mat2gray(H)),'XData',T,'YData',R,'InitialMagnification','fit');
title('Hough transform of tu1.jpg ');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot);
peaks = houghpeaks(H, 50,'threshold',ceil(0.3*max(H(:))));
lines = houghlines(BW, T, R,peaks);
figure(4),imshow(a);
lines(1).point2(1)=lines(1).point2(1)+315;
hold on
max_len = 0;
for k = 1:length(lines)
    % 绘制各条线
    xy = [lines(k).point1; lines(k).point2];
    plot(xy(:,1),xy(:,2),'LineWidth',1,'Color','red');

end
hold off
%%%%%%%%%%%%%%hough变换检测直线end%%%%%%%%%%%%%%%%
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: figure 中心线 最大值 close 
2015-05-30 14:08
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:10 
不懂哎
2015-05-30 16:51
boooeee
Rank: 2
等 级:论坛游民
帖 子:4
专家分:30
注 册:2015-6-2
收藏
得分:10 
看到代码头疼,@包多仔网项目外包平台
www.
2015-06-02 23:12
快速回复:提取中心线后用hough拟合直线程序有问题,希望大家给指点一下
数据加载中...
 
   



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

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