How to Fill a segmented image
4 views (last 30 days)
Show older comments
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 :)
0 Comments
Accepted Answer
Image Analyst
on 11 May 2014
This is very easy with my delta E color difference demo : http://www.mathworks.com/matlabcentral/fileexchange/31118-color-segmentation-by-delta-e-color-difference
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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!