Separating Connected Objects Effectively in Image

조회 수: 10 (최근 30일)
Serg Zhelezniak
Serg Zhelezniak 2017년 11월 12일
댓글: Image Analyst 2017년 11월 12일
Hello, I am attempting to separate several connected objects that are often only connected by one pixel (see image). I want to have all connected objects be separate from each other i.e. remove the particular pixel that's causing the issue. I have been trying to use imerode function but I keep on removing more pixels than I would like. Any advice would be greatly beneficial.

채택된 답변

Image Analyst
Image Analyst 2017년 11월 12일
They are separated if you use 4-connectedness. For subsequent operations, like bwconncomp() or bwlabel(), just specify 4-connectedness instead of the default 8-connectedness.

추가 답변 (1개)

Jose Marques
Jose Marques 2017년 11월 12일
Hello. Have you tried "imopen"?
Please, post your code and figures so we can help you.
  댓글 수: 2
Serg Zhelezniak
Serg Zhelezniak 2017년 11월 12일
im0 = image;
thresh = 190;
%Threshold Procedure
im_1a = im0 > thresh;
im_1b = bwareaopen(im_1a,5); %remove less than 5 connected components
im_1c = imerode(im_1b,strel('disk',1)); %erode with disk of radius 1
im_1d = imdilate(im_1c,strel('disk',1)); %dilate with disk of radius 1
figure
subplot(2,1,1) imshow(im_1a) title('im_1a')
subplot(2,1,2) imshow(im_1d) title('im_2d')
Performing erosion and dilation helps a little, but there are still components being connected by single pixel that should be separate (red arrow). My question is whether it is possible just to remove that particular one pixel in a manner preserves the quantity of pixel data present in im_1a.
Image Analyst
Image Analyst 2017년 11월 12일
Again, just use 4-connected like I said in my answer and you won't have the problem!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by