How to draw bounding boxes around the ROI obtained by thresholding.

9 Ansichten (letzte 30 Tage)
Sidra Aleem
Sidra Aleem am 4 Apr. 2018
Kommentiert: Image Analyst am 6 Apr. 2018
I want to highlight the region of interest using rectangular bounding box on the original image.
Can anyone here help me with this?

Antworten (1)

Image Analyst
Image Analyst am 4 Apr. 2018
props = regionprops(binaryImage, 'BoundingBox');
for k = 1 : length(props)
thisBB = props(k).BoundingBox;
hold on;
rectangle('Position', thisBB);
end
  2 Kommentare
Sidra Aleem
Sidra Aleem am 5 Apr. 2018
Bearbeitet: Sidra Aleem am 6 Apr. 2018
@Image Analyst I tried the same code from the link ( https://de.mathworks.com/matlabcentral/answers/87597-rectangle-around-the-object-bounding-box ). but its gives bounding boxes in the thresholded image.
However, I donot want this. I want these bouding boxes at the same position, but on the segmented image as shown in figure1 in my questionj. I want the bounding box around the thresholded image to be in the same position, but on Blood vessel subplot.
I tried to do the following, but its not working.
st = regionprops(Thresholded_image,'BoundingBox'); % Thresholded image in subplot 2
figure,imshow(bloodVessels); %Blood Vessel Image in subplot 3
for k = 1 : length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor','r','LineWidth',2 )
end
As shown the third subplot doesnot have any bounding box.
Image Analyst
Image Analyst am 6 Apr. 2018
You have to switch the current axes to the one you want to put the boxes onto. For example call subplot() or axes() before you call rectangle().

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by