problem with active contour - image segmentation

Hello, I'm trying to use active contour to create segmentation. my flow is as follow:
  1. load slide(image) - is a matrix where 1 represent the boundaries of the object otherwise 0.
  2. creating a mask for the object.
  3. "put" the mask on the slide and set all the areas outside the mask to 0 - we can call it cleanup.
  4. enable active contour on 3 result.
I have problem with number 4. as you can see in the picture below, the active contour dosent calculate the boundaries of the object. it calculate the inner area for some reason. my goal is to create boundaries to the object from 3 using active contour. Anyone have idea/hint how to fix it ?
%open the next slide
nextSlide = segMat(:,:,ii);
subplot(2,2,1)
imshow(nextSlide)
title('Original slide')
% create the mask
mask = imdilate(slide ,strel('disk' , 10));
subplot(2,2,2)
imshow(mask)
title('The mask');
%outside the mask countor set 0.
nextSlide(mask == 0 ) = 0;
subplot(2,2,3)
imshow(nextSlide)
title('clenup outside the mask');
% Active contur
bw = activecontour(nextSlide,mask,300,'edge');
subplot(2,2,4)
imshow(bw)
title('Active countour to clean slide using mask');

Answers (1)

I don't know why you're using activecontour() on the mask. Why not simply use the mask as it is? If you, for some reason, want the boundaries of it use bwperim() (to get an image), or bwboundaries() (to get a list of x,y coordinates).

1 Comment

The mask is created from the previous slide, and it is not the boundaries of the current slide.
The idea behind that is that the mask helps to "clean" the next slide in order to let the active contour to focus in the main object of the slide.
The active contour result with imdilate should be the mask for the next next slide. it just as it named a mask. that's why i need active contour.
i did some manually changes this is what i'm looking for using active contour with the above code.
:

Sign in to comment.

Asked:

on 4 Jun 2017

Edited:

on 5 Jun 2017

Community Treasure Hunt

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

Start Hunting!