この質問をしてからしばらくしています。答えが遅すぎることはないと思います。私は同様の質問で流域セグメンテーションを使用するという一般的な問題を抱えています。オブジェクトが離れていて、互いに触れ合わない場合もあります。like in this exampleそのような場合、画像をぼかすだけで、流域セグメンテーションを使用することができます。オブジェクトが密接に接してお互いに接触することがあるため、オブジェクトの境界は明確ではありませんlike in this example。そのような場合、distance transform - > blur - > watershedを使用すると便利です。この質問では、論理的アプローチは距離変換を使用する必要があります。しかし、今度は、樹木の上や近くの影によって境界がはっきりしない。このような場合、オブジェクトas in hereを分離するのに役立つ情報を使用するか、オブジェクト自体を強調することをお勧めします。
この質問では、色情報を使用してツリーピクセルを強調することをお勧めします。
ここにMATLABのコードと結果を示します。
im=imread('https://i.stack.imgur.com/aBHUL.jpg');
im=im(58:500,86:585,:);
imOrig=im;
%% Emphasize trees
im=double(im);
r=im(:,:,1);
g=im(:,:,2);
b=im(:,:,3);
tmp=((g-r)./(r-b));
figure
subplot(121);imagesc(tmp),axis image;colorbar
subplot(122);imagesc(tmp>0),axis image;colorbar
%% Transforms
% Distance transform
im_dist=bwdist(tmp<0);
% Blur
sigma=10;
kernel = fspecial('gaussian',4*sigma+1,sigma);
im_blured=imfilter(im_dist,kernel,'symmetric');
figure
subplot(121);imagesc(im_dist),axis image;colorbar
subplot(122);imagesc(im_blured),axis image;colorbar
% Watershed
L = watershed(max(im_blured(:))-im_blured);
[x,y]=find(L==0);
figure
subplot(121);
imagesc(imOrig),axis image
hold on, plot(y,x,'r.','MarkerSize',3)
%% Local thresholding
trees=zeros(size(im_dist));
centers= [];
for i=1:max(L(:))
ind=find(L==i & im_blured>1);
mask=L==i;
[thr,metric] =multithresh(g(ind),1);
trees(ind)=g(ind)>thr*1;
trees_individual=trees*0;
trees_individual(ind)=g(ind)>thr*1;
s=regionprops(trees_individual,'Centroid');
centers=[centers; cat(1,[],s.Centroid)];
end
subplot(122);
imagesc(trees),axis image
hold on, plot(y,x,'r.','MarkerSize',3)
subplot(121);
hold on, plot(centers(:,1),centers(:,2),'k^','MarkerFaceColor','r','MarkerSize',8)
**あなたは**どのように多くの木があります伝えることはできますか?もしそうなら、どうやってやったのですか。 – Shai
確かに、手動でカウントすることもやりにくいので、画像に何本の木があるのか分かりません。しかし、地方自治体の機能によって、私はその地域の面積を知ることができます。そして、多くの場合、樹木は3000ピクセルの面積を持ち、研究対象地域は112,000ピクセルの面積を持つため、この地域には約37本の樹木があります。 –