How to extract an object from an image

48 ビュー (過去 30 日間)
Nikhil Hegde
Nikhil Hegde 2015 年 12 月 13 日
回答済み: Arnab Banerjee 2019 年 9 月 13 日
I've got this code to extract a single cashew from a image containing multiple cashews. I need the extracted image to be RGB as well.
cashew_RGB = imread('White Wholes 180.jpg');
cashew_BW = img_BW(cashew_RGB);
cashew_stats = regionprops(bwlabel(cashew_BW),'BoundingBox');
cashew_single = imcrop(cashew_RGB,cashew_stats(i).BoundingBox);
I have attached the image and the user-defined function 'img_BW' which converts RGB image to black and white If you execute the code you'll find that the extracted cashew image has an invasion from the neighboring cashew. Is there any way to extract the cashew without such invasions? Thanks for your help!

採用された回答

Image Analyst
Image Analyst 2015 年 12 月 13 日
You can't use the bounding box or else you may have incursions from another blob that juts into the bounding box. You have to use either PixelList from regionprops, or (easier) use ismember() with the blob you want to extract:
thisBlob = ismember(labeledImage, blobIndexToExtract) > 0;
  6 件のコメント
nour n
nour n 2017 年 1 月 10 日
how to extract the object without the black background?
Jan
Jan 2017 年 1 月 10 日
@nour: Please use flags for pointing out inproper use of the forum. Instead of attaching a new question as a comment, open a new thread. Thanks.

サインインしてコメントする。

その他の回答 (2 件)

r r
r r 2018 年 8 月 8 日
I have an image I want to extract the small areas of black color within the blue How so؟؟؟
  1 件のコメント
Image Analyst
Image Analyst 2018 年 8 月 8 日
Start your own new, separate question and I'll show you how.

サインインしてコメントする。


Arnab Banerjee
Arnab Banerjee 2019 年 9 月 13 日
first, convert to gray, by rgb2gray(), then find the perfect threshold of the region from the image matrix. it can be aslo done in RGB image if you knew the R:G:B ration of the threshold.
lastly, past the bounded area in a mask, or extract the partcular threshold

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by