How to create a silhouette
이전 댓글 표시
Hi all,
I've been trying to create a silhouette with the following code;
function S = getsilhouette( im )
%GETSILHOUETTE - find the silhouette of an object centered in the image
[h,w,d] = size(im);
% Initial segmentation based on more red than blue
S = im(:,:,1) > (im(:,:,3)-2);
% Remove regions touching the border or smaller than 10% of image area
S = bwareaopen(S, ceil(h*w/10));
squeeze(S);
% % Now remove holes < 1% image area
S = ~bwareaopen(~S, ceil(h*w/100));
And this is what I get as an output;

I was wondering if anyone had any ideas to remove the base?
Many thanks and cheers for reading
Adam
댓글 수: 5
Cedric
2013년 4월 13일
Could you grab an image without the object (but with the support)? This could be a basis for extracting whatever object you place on the support..
Ian
2013년 4월 13일
Yes, that's the idea. Any pixel of the image including the object that is not "close enough" to the corresponding pixel of the image with no object, defines the object.
Now I have little experience in image processing; I would be able to do it my way, but I am unable to tell you how to do it using proper techniques, so I would be interested as well in having Image Analyst's take on this matter.
PS: "my way" would be to set thresholds on the norm of differences between corresponding channels associated with both the image without and the image with the object.
Image Analyst
2013년 4월 14일
편집: Image Analyst
2013년 4월 14일
If you can get a "blank shot" - an image without the object of interest in it - then that is certainly the way to go. Then just subtract and threshold.
diffImage = abs(double(grayImage) - double(backgroundImage));
binaryImage = diffImage > 4; % or whatever value you want.
You might want to fill holes too:
binaryImage = imfill(binaryImage, 'holes');
Cedric
2013년 4월 14일
Thank you for the update!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!