how to place the rectangle for all the blob

6 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 10 月 11 日
コメント済み: Star Strider 2021 年 10 月 12 日
Hi all,
I have 7 binary images.
anyone know how to place the rectangle for all the blob in the subplot binary images?
I used below coding, but only one binary image (the last images) have the rectangle
%% TEST IMAGES
DATASetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
IMAGEDir = fullfile(DATASetDir,'Test');
IMDS = imageDatastore(IMAGEDir);
%% TO GET THE VOLUME SEGMENTATION AFTER DEEP LEARNING PERFORM
alldice=[]
acc=[]
Ts = [];
Ts2 = [];
for ii=1:7
subplot(3,3,ii)
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
outt2=C=="foreground";
st2=strel('disk',5);
outt22 = imopen(outt2,st2);
figure
title('output')
imshow(outt22)
fprintf('\nprocess %d image\n', ii);
T = regionprops('table', outt22,'Area','Centroid');
info = regionprops(outt22,'Boundingbox') ;
Ts{ii} = T;
Ts2 = [Ts2; T];
end
allbb=[]
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',1) ;
allbb=[allbb; BB]
end

採用された回答

DGM
DGM 2021 年 10 月 11 日
The second loop needs to be inside the first one, otherwise it's only going to plot the bounding boxes for the blobs in the last subplot.
  7 件のコメント
Star Strider
Star Strider 2021 年 10 月 12 日
‘T’ is a table, and the ‘T.Area’ reference returns the values in the ‘Area’ variable as a column vector.
.

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

その他の回答 (1 件)

yanqi liu
yanqi liu 2021 年 10 月 12 日
%% TEST IMAGES
DATASetDir = fullfile('C:\Users\Akmal\Desktop\I-131 256 28.02.2020\I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang');
IMAGEDir = fullfile(DATASetDir,'Test');
IMDS = imageDatastore(IMAGEDir);
%% TO GET THE VOLUME SEGMENTATION AFTER DEEP LEARNING PERFORM
alldice=[]
acc=[]
Ts = [];
Ts2 = [];
for ii=1:7
I = readimage(IMDS,ii);
[C,scores] = semanticseg(I,net1);
outt2=C=="foreground";
st2=strel('disk',5);
outt22 = imopen(outt2,st2);
figure(ii)
title('output')
imshow(outt22)
fprintf('\nprocess %d image\n', ii);
T = regionprops('table', outt22,'Area','Centroid');
info = regionprops(outt22,'Boundingbox') ;
Ts{ii} = T;
Ts2 = [Ts2; T];
end
allbb=[]
for ii=1:7
figure(ii);
hold on;
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',1) ;
allbb=[allbb; BB]
end
end
  1 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 10 月 12 日
Error using info
Too many output arguments.

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

Community Treasure Hunt

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

Start Hunting!

Translated by