Largest rectangle inscribed inside multiple blobs

Hi,
I have few blobs where I need to fit the largest area rectangle inside. I used the matlab function LargestRectangle to find the rectangle and it works well for a single blob.
a = imread('blob.png');
LRout=LargestRectangle(a);
But how to get rectangles for multiple blobs in the same image?
I have gone through regionprops. What I understood is, I need to seperate each blob and then calculate the highest rectangle for each one as I can't use LargestRectangle with regionprops. Now my question is how to separate each blob so that I can get the largest rectangle for each one?

 採用された回答

Simon Chan
Simon Chan 2021 年 7 月 15 日
編集済み: Simon Chan 2021 年 7 月 15 日

0 投票

How about separate them into 6 different images and put into the function?
The images are stored in BW(:,:,1) to BW(:,:,6).
A = imread('Matlab output of blob seq.png');
[L,n]=bwlabel(A);
tiledlayout(2,3)
for k=1:n
nexttile
BW(:,:,k)=(L==k);
imshow(BW(:,:,k));
end

3 件のコメント

Sunetra Banerjee
Sunetra Banerjee 2021 年 7 月 15 日
Hi,
Thanks a lot. That's a great idea. But 'tiledlayout' is not working in my R2019a. If I want to use subplot instead of 'tiledlayout', how to use this?
Simon Chan
Simon Chan 2021 年 7 月 15 日
編集済み: Simon Chan 2021 年 7 月 15 日
Use this:
A = imread('Matlab output of blob seq.png');
[L,n]=bwlabel(A);
for k=1:n
BW(:,:,k)=(L==k);
subplot(2,3,k)
imshow(BW(:,:,k));
end
Sunetra Banerjee
Sunetra Banerjee 2021 年 7 月 15 日
Hi,
Now it's working fine. Thanks a lot for your help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by