Remove Background from image and select the region of interest

조회 수: 2 (최근 30일)
Animesh
Animesh 2014년 2월 14일
댓글: Image Analyst 2014년 4월 15일
I have a image
and I want to remove the background and select the region of interest and my output should be
How can I do it ? thanks in advance.

채택된 답변

Image Analyst
Image Analyst 2014년 2월 14일
For this image, the background is neutral and the subject is not. So I'd probably convert to hsv with rgb2hsv() and then threshold on saturation to get highly saturated pixels. The background won't get selected. Then get rid of any small regions with bwareaopen, call regionprops, get the bounding box, and call imcrop(). The essential lines are few:
hsv=rgb2hsv(rgbImage);
s = hsv(:,:,2);
foreground = s > 0.2; % Or whatever.
foreground = bwareaopen(foreground, 1000); % or whatever.
labeledImage = bwlabel(foreground);
measurements = regionprops(labeledImage, 'BoundingBox');
bb = measurements.BoundingBox;
croppedImage = imcrop(rgbImage, bb);
or something like that. I didn't test it - that's just off the top of my head.
  댓글 수: 9
Animesh
Animesh 2014년 2월 18일
편집: Animesh 2014년 2월 18일
I am trying to find the denomination of the note by using two features
1)Dominant color
2)Ratio of length/width.
And for the above I would take the dominant color as there are more of them.
Image Analyst
Image Analyst 2014년 2월 18일
편집: Image Analyst 2014년 2월 18일
Sounds like just taking the mean color would be good enough to tell which note it is. I don't see any need to do anything fancier or more difficult.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Anagha
Anagha 2014년 4월 15일
Hello,
I'm also facing similar problem. I want to crop the egg image from black background for further image processing. I'm attaching the image. Please help me in this regard. Really urgent!!
  댓글 수: 1
Image Analyst
Image Analyst 2014년 4월 15일
Please start your own thread. Post your image there and explain why you want to crop. Cropping is not necessary for analysis, so why do you want to crop? Answer in your own, new thread, not here.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by