matlab 如何对齐模型,如何对齐图像 – Matlab

该解决方案首先在

@AruniRC的评论中被暗示,然后在

@belisarius在数学中实现.以下是我在MATLAB中的解释.

想法基本相同:使用Canny方法检测边缘,使用霍夫变换找到突出线,计算线角度,最后执行剪切变换以对齐图像.

%# read and crop image

I = imread('http://i.stack.imgur.com/CJHaA.png');

I = I(:,1:end-3,:); %# remove small white band on the side

%# egde detection

BW = edge(rgb2gray(I), 'canny');

%# hough transform

[H T R] = hough(BW);

P = houghpeaks(H, 4, 'threshold',ceil(0.75*max(H(:))));

lines = houghlines(BW, T, R, P);

%# shearing transforma

slopes = vertcat(lines.point2) - vertcat(lines.point1);

slopes = slopes(:,2) ./ slopes(:,1);

TFORM = maketform('affine', [1 -slopes(1) 0 ; 0 1 0 ; 0 0 1]);

II = imtransform(I, TFORM);

现在让我们看看结果

%# show edges

figure, imshow(BW)

%# show a

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值