gray scale imageの白い点を検出するために次のコードを使用しています。画像に特定の距離にマーカーを配置する
Gimg=imread('hi.tif','tif');
BW=Gimg>150;
rp=regionprops(BW,Gimg,'WeightedCentroid');
disp('Centroiding is done.');
figure(1); image(Gimg); axis image; hold on;
n=numel(rp);
pos = rp.WeightedCentroid; %all positions
for ct = size(pos,1):-1:1 %check them backwards
d = sum((pos-pos(ct,:)).^2); %distance to all other points (kd-trees could be used for speedup)
if min(d)<1^2,pos(ct,:)=[];end %remove if any point is too close
end
for i=1:pos
plot(rp(i).WeightedCentroid(1), rp(i).WeightedCentroid(2), 'wX', 'markers',15)
end
しかし、私は私は赤で概説した画像の一部に白い斑点を保持する:従って
、全てprev_*
変数。
これを行うにはどうすればよいですか?
したがって、場所のコレクションがあり、前の2つのポイントから少なくとも50離れているすべてのポイントを検索する必要があります。現在のメソッドで何が問題になっていますか?その領域にスポットを入れたい場合は、 'inpolygon'を使うことができます。 – Gelliant
現在の方法(上記の画像を生成した)では、非常に近いところに多くのマーカーがあります。 – nini