Kwstas Tranos
Kwstas Tranos

Reputation: 11

Active contour initialization

I am trying to segment an image

http://i58.tinypic.com/wu33pl.jpg

I want to take the two contours with blue

Wanted contours image

Anyone with an idea which technique can i use for this kind of segmentation?

The problem is that i want to use Active contours for segmentation and i want automatic initialization of active contours in this kind of images .For this purpose i have to find a way to put inside the contours i draw an initial contour.Any idea of how can make this ,any charactiristic that you can see and i can take(texture,etc)? Thanks

Upvotes: 0

Views: 652

Answers (2)

Dima
Dima

Reputation: 39419

If you have a recent version of MATLAB, try the Image Segmenter app.

Upvotes: 0

LowPolyCorgi
LowPolyCorgi

Reputation: 5188

A simple way of doing it would be to threshold the image, locate the objects with regionprops, keep only those of interest (here, with an area criteria) and find the contour with bwboundaries.

In practice, this gives:

% Define threshold
th_BW = 100;

% Read image
img = imread('myimage.jpg');

% Get objects and filter them
R = regionprops(img>th_BW, 'Area', 'PixelIdxList');
I = find([R.Area]>1000 & [R.Area]<10000);

% Get contours
C = cell(numel(I),1);
for i = 1:numel(I)   
    BW = img*0;
    BW(R(I(i)).PixelIdxList) = 1;
    tmp = bwboundaries(BW);
    C{i} = tmp{1};
end

% Display
imshow(img)
hold on
plot(C{1}(:,2), C{1}(:,1), 'Linewidth', 2);
plot(C{2}(:,2), C{2}(:,1), 'Linewidth', 2);

And here is the result:

Result image

Upvotes: 1

Related Questions