How to Fill a segmented image

4 views (last 30 days)
Juan  Garay
Juan Garay on 11 May 2014
Commented: Juan Garay on 20 May 2014
Im trying to segment a photo and the program only segmentates a part of it, what do i have to add to segment the whole photo. Im trying to fill the segmented image but it fills a part, not the complete photo, this is the code that im using:
clear all clc
IO=imread('FotoJuan.jpg'); IOG=rgb2gray(IO);
[~, threshold] = edge(IOG, 'sobel'); fudgeFactor = .5; BWs = edge(IOG,'sobel', threshold * fudgeFactor);
se90 = strel('line', 2, 90); se0 = strel('line', 3, 0); BWsdil = imdilate(BWs, [se90 se0]);
BWdfill = imfill(BWsdil, 'holes');
% BWnobord = imclearborder(BWdfill, 4); % % seD = strel('line', 1, 90); % BWfinal = imerode(BWnobord,seD); % BWfinal = imerode(BWfinal,seD);
etiqueta = bwlabel(BWdfill, 4); numObjetos = max(max(etiqueta)); numObjetos
subplot(2,2,1); imshow(IO); title('Imagen Original');
subplot(2,2,2); imshow(IOG); title('Imagen en escala de grises');
subplot(2,2,3); imshow(BWdfill); title('Dilated Gradient Mask');
Im going to attach the original photo and the one who shows how is segmented, Hope you can help me :)

Accepted Answer

Image Analyst
Image Analyst on 11 May 2014
Tell it to read in your image and trace out some part of the blue background. The demo will give you the blue background as a mask. Your person mask is simply the inverse of the blue background mask. You might call imfill() to get rid of any little holes in the mask.
  1 Comment
Juan  Garay
Juan Garay on 20 May 2014
Thank you very much for your help, was very useful!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!