how to place the rectangle for all the blob

조회 수: 2(최근 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