使用霍夫变换定位手指边缘

图片大小为1024*1280,这里先定位上边缘,再定位到下边缘

上边缘(行数1:512)

 

img = imread('./G_A01_L1_2_R.bmp');
% Convert to intensity.
I =imbinarize(img);
figure;
subplot(2,2,1);
imshow(I);

title('binary image');

% Extract edges.
BW1 = edge(I,'Prewitt');
subplot(2,2,2);
imshow(BW1);
title('edge');

[H1,T1,R1] = hough(BW1);
%显示变换域
subplot(2,2,3);
imshow(imadjust(rescale(H1)),'XData',T1,'YData',R1,'InitialMagnification','fit');
xlabel('\theta');
ylabel('\rho');
title('change domain');
axis on,axis normal,hold on

%计算变换域峰值
P1 = houghpeaks(H1,'threshold',ceil(0.3*max(H1(:))));
x=T1(P1(:,2));
y=R1(P1(:,1));
plot(x,y,'s','color','red');

%标记直线
L1 = houghlines(BW1,T1,R1,P1,'FillGap',200,'MinLength',100);
subplot(2,2,4);
imshow(RGB);
title('result')
hold on
max_len=0;
for k=1:length(L1)
    xy=[L1(k).point1;L1(k).point2];
    plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
    %Plot beginning and ends of lines
    plot(xy(1,1),xy(1,2),'xw','LineWidth',2);
    plot(xy(2,1),xy(2,2),'xw','LineWidth',2);
    %Determine the endpoints of the longest line segment
    len=norm(L1(k).point1-L1(k).point2);
    if(len>max_len)
        max_len=len;
        xy_long=xy;
    end
end




 

下边缘(513:1024)只需要改行数

 

效果图:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值