Hi,
I'm trying to identify the banana from the other fruits in an binary Image so that the result only show the banana, I used se=strel('disk',25) but the area of orange was larger so the result show the orange not banana. can you help me with the problem.
Thank you in advance.

6 件のコメント

Image Analyst
Image Analyst 2019 年 12 月 29 日
Not without the image we can't. You forgot to attach it. I also have no idea why you're even using strel(). That's used for doing morphological operations, which I'm not convinced you need.
Sadeq Ebrahimi
Sadeq Ebrahimi 2019 年 12 月 29 日
yes strel() didnt work, then I used regionprops and all I could do is to draw a line around the fruit, I want to only show the banana, here is the code:
I=imread('B.jpg');
bw=im2bw(I,0.7);
bw1=~bw;
Ifilled=imfill(bw1,'holes');
I2=bwareaopen(Ifilled,1000);
[B,L] = bwboundaries(I2,'noholes');
numregion = max(L(:));
imshow(label2rgb(L));
I1=regionprops(I2,'MajorAxisLength');
stats = [I1.MajorAxisLength];
keepers = find(stats > 225);
imshow(I2);
for index=1:length(keepers)
outline = B{keepers(index)};
line(outline(:,2),outline(:,1),'color','r','LineWidth',2);
end
Sorry I forgot the picture, here you are:
Capture1.PNG
And Thank you for your help!
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 29 日
Can you attach the original picture?
Sadeq Ebrahimi
Sadeq Ebrahimi 2019 年 12 月 29 日
Ok
B.jpg
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 29 日
As you already located the roi (red boundary), is there any issue now?
Sadeq Ebrahimi
Sadeq Ebrahimi 2019 年 12 月 29 日
yes, delete all the other fruits and only show banana in binary

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

 採用された回答

Image Analyst
Image Analyst 2019 年 12 月 29 日

0 投票

This looks like homework, not a real world problem. So I'll give you hints. Use the color thresholder app on the Apps tab to create a mask for yellow. Then use regionprops() to find out which blobs have a major axis some factor longer than the minor axis:
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'MajorAxisLength', 'MinorAxisLength');
aspectRatios = [props.MajorAxisLength] ./ [props.MinorAxisLength]
bananas = aspectRatios > 2; % Or whatever.
% Extract binary image of just the banana blobs
bananasImage = ismember(bananas, find(bananas));

その他の回答 (0 件)

質問済み:

2019 年 12 月 28 日

回答済み:

2019 年 12 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by