Demo entry 6356844

1

   

Submitted by 1 on Apr 20, 2017 at 14:52
Language: Matlab. Code size: 666 Bytes.

%特征块中心坐标提取
%提取特定颜色
rgb=im2double(imread('12.png'));
ycbcr=rgb2ycbcr(rgb);
cr=ycbcr(:,:,3);
mask1_r=cr>.65;  %阈值
%缺省拟合部分
%寻找二值图等于0的像素坐标(等于0即为白色,等于1即为黑色)
[x,y]=find(mask1_r==1);
imshow(mask1_r);
B=[x,y];
[y1,I] = max(B(:,2));
x1=B(I,1)
hold on,plot(y1,x1,'x','LineWidth',2,'Color','red');
[y2,S] = min(B(:,2));
x2=B(S,1);
hold on,plot(y2,x2,'x','LineWidth',2,'Color','red');
[x3,M] = min(B(:,1));
y3=B(M,2);
hold on,plot(y3,x3,'x','LineWidth',2,'Color','red');
[x4,M] = max(B(:,1));
y4=B(M,2);
hold on,plot(y4,x4,'x','LineWidth',2,'Color','red');
x0=((x1+x2+x3+x4)/4);
y0=((y1+y2+y3+y4)/4);
hold on,plot(y0,x0,'x','LineWidth',2,'Color','red');

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).