Morphological Image Processing: Object Identification and Separation
33 次查看(过去 30 天)
显示 更早的评论
Hi, all --
As a graduate student I learned that the way to make image procesing easy was to start with good images. Sometimes, however, you have the images that you have, and that is where I am now (attached). It's not that the image is "bad" per se, it's that I am finding it difficult to do what I want with it.
What I would like: to transform the attached image (and many, many more like it) into a binary image containing only whole particles not in contact with one another.
Other information: particle orientation is unimportant and it is OK to delete any necessary particles to achieve the stated goal. (My working assumption -- for now -- is that over the span of many images these removals will average out.)
I have tried various combinations of binarization, erosion, dilation, etc., but I am pretty amateur at this. I am hoping someone with a bit of expertise could perhaps point me in the right direction.
Thanks in advance.
2 个评论
Matt J
about 10 hours 前
编辑:Matt J
about 10 hours 前
I think there must be other criteria you've neglected to mention. As it is now, your criterion can be met just by binarizing one particle or two particles far apart from each other in the image. Is there no requirement on the density or coverage of the not-deleted particles?
回答(2 个)
Image Analyst
about 2 hours 前
There are MATLAB demos that separate particles. See blogs:
and
3 个评论
Image Analyst
about 1 hour 前
Sorry, no it doesn't make sense to me. Please describe precisely your definitions of isolate and separate and how they are different from each other.
You will not be able to get precise measurements for several reasons. One is that the particles overlap so if some of a particle is occluded by another particle, you won't have accurate silouhette of that particle since some of it will be missing. Secondly it depends on how the particles are laid down (what surface they lie on). If you drop the same particles down a second time, you'll get different area, perimeter, and feret diameter distributions. So you'll have to take many, many samples and even then you'll get distributions for partially occluded particles rather than particles as if they were all nicely separated. Nonetheless, that may be good enough to do whatever you eventually want to do with these measurements, like differentiate one batch of raw material from another batch.
Matt J
about 4 hours 前
编辑:Matt J
about 3 hours 前
This might be along the lines of what you're looking for. It's semi-empirical though in the way it discards particles. Maximum density is not guaranteed.
load Image
contactDistance=20; %distance in pixels for blobs to be considered in contact
se=@(r) strel('disk',r);
I0=I;
I=imerode(I0,se(7));
%Initial blob identification
BW= imfill( imbinarize(I,"adaptive")|imbinarize(I),"holes");
BW=bwpropfilt(BW,I,'MaxIntensity',[50,inf]);
%Segment blobs using watershed method
BW=separateBlobs(BW);
D=interDists(BW); %Get adjacency matrix of blob separation distances
%Extract a "non-touching" subset of blobs
S = subsetExtract(D, contactDistance);
CC=bwconncomp(BW);
CC.NumObjects=numel(S);
CC.PixelIdxList=CC.PixelIdxList(S);
BW=cc2bw( CC );
imshow(labeloverlay(I0,BW));
function A=interDists(BW)
%Compute blob separation distances. Return adjacency matrix, A
arguments
BW logical
end
B={regionprops(bwmorph(BW,'remove'),'PixelList').PixelList};
N=numel(B);
A=zeros(N);
for i=1:N
A(i,i)=inf;
for j=i+1:N
A(i,j) = min(pdist2(B{i},B{j}),[],'all');
end
end
A=A+A';
end
function S=subsetExtract(D,d)
%Get a nontouching subset where "touching" is defined by
%threshold distance, d, and D is the separation distance adjacency matrix
while min(D(:))<d
idx=find(min(D,[],2)<d);
if isempty(idx), break;end
n=numel(idx); m=ceil(n/4);
cut=idx(randperm(n,m));
D(cut,:)=inf; D(:,cut)=inf;
end
S= find(~all(isinf(D),2));
end
function bw3=separateBlobs(bw)
%Watershed method for blob separation
D = -bwdist(~bw);
mask = imextendedmin(D,5);
D2 = imimposemin(D,mask);
Ld2 = watershed(D2);
bw3 = bw;
bw3(Ld2 == 0) = 0;
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

