Remove single pixel width connecting lines between objects

1 Ansicht (letzte 30 Tage)
Haider Ali
Haider Ali am 21 Okt. 2019
Kommentiert: darova am 23 Okt. 2019
Hi all,
How can I remove/disconnect the connecting lines between objects while keeping the boundaries of my objects intact?
  6 Kommentare
Matt J
Matt J am 21 Okt. 2019
An intriguing problem.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

darova
darova am 22 Okt. 2019
Here is an idea: find large areas and merge them to remove walls
I = imread('image.png');
I1 = im2bw(I);
% I2 = bwmorph(~I1,'thin',3);
[I3,n] = bwlabel(I1,8); % label image
p = regionprops(I3,'Area'); % find area of each region
ar = cat(1,p.Area);
ind = find( 400 < ar & ar < 5000); % find interested areas
I4 = I3*0;
for i = 1:length(ind)
ix = find( I3==ind(i) ); % find pixels of interested areas
I4(ix) = 1;
end
I5 = imdilate(I4,ones(3)); % merge neigbouring areas
I6 = imdilate(~I5,ones(3)); % return original size of areas
II = cat(3,I1,~I6,I1*0);
imshow(II)
figure
imshow(I1 | ~I6)
The result: Green lines/walls removed, Yellow areas detected
  2 Kommentare
Haider Ali
Haider Ali am 22 Okt. 2019
@darova, interesting sloution.
But I am afraid it does not solve my actual problem.
The image that I have provided is actaully obtained after applying watershed on binarized cell image. My goal is to segment the cells and calculate their properties.
The probelm I am facing is that after binarization (imbinarize), some of the cells' boundaries are not closed> Therefore, I applied the waterhsed transform. This improves the cell segmentation but also introduces extra ridges (connecting lines) and these extra ridges create false positives.
So there are couple of things that I can do:
  1. Improve my binarization/thresholding algorithm to create strong edged cell boundaries.
  2. Perform some pre-processing before watershedding to join broken cells' boundaries (please see this question too Edge linking and hole filling in binarized cell image).
  3. Remove the newly created connecting lines introduced by watershed transform.
What would the best approach in your opinion?
I am attaching some figures too.
In watershedimage.fig, I have circled 2 false positives which were introduced only because of watwershed transform.
Please let me know if any pther explanation of the problem is required.
Thanks.
darova
darova am 23 Okt. 2019
I'm afraid that i can't help. All i can advise is binarizing image and manipulating with graythersh

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by