How to Fill a segmented image

1 次查看(过去 30 天)
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 :)

采纳的回答

Image Analyst
Image Analyst 2014-5-11
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.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by