how to place the rectangle for all the blob
1 次查看(过去 30 天)
显示 更早的评论
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

0 个评论
采纳的回答
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
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!