这个还是可以找出来的,简单做了一下,下面的代码还不完善,如果要做到通用还需要大量的修改,另外代码也需要进行优化,不过还是基本能实现你这个问题的
- clc;
- clear;
- a=imread('a.jpg');
- a(a<150)=0;
- a(a>150)=255;
- [L,M,N]=size(a);
- blkx=[];
- blky=[];
- for i=1:L;
- if sum(a(i,fix(M/3):fix(2*M/3),2))<10;
- blky=[blky,i];
- end
- end
- for j=1:M;
- if sum(a(fix(L/3):fix(2*L/3),j,2))<10;
- blkx=[blkx,j];
- end
- for i=1:L
- if a(i,j,1)~=255 | a(i,j,2)~=0 | a(i,j,3)~=0
- a(i,j,:)=255;
- end
- end
- end
- b=rgb2gray(a);
- b(b~=255)=0;
- imshow(b)
- for i=1:40
- dx=(max(blkx)-min(blkx))/40;
- xi(i)=fix(dx*i+min(blkx));
- yi(i)=mean(find(b(:,xi(i))==0));
- y(i)=1.5-1.5*(yi(i)-min(blky))/(max(blky)-min(blky));
- end
复制代码
其中y就是你需要输出的结果
y =
Columns 1 through 7
0.7440 0.6720 0.5160 0.6460 0.9240 1.0680 1.0740
Columns 8 through 14
1.0560 1.1760 1.1400 1.2840 1.3080 1.0260 0.9120
Columns 15 through 21
0.9480 0.6600 0.6840 0.7920 0.6180 0.7575 1.0380
Columns 22 through 28
0.9780 0.8820 1.0380 1.1280 1.2000 1.2420 1.1520
Columns 29 through 35
NaN 1.1467 0.8860 0.8760 0.7152 0.6480 0.3915
Columns 36 through 40
0.9660 0.9024 0.8400 NaN 1.1880
说明一点这里有两个结果出现了NAN,这是由于在你的图片中那个标签挡住了两个点的原因! |