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!