- You have obtained the bounding boxes and scores of the detected objects.
- You have selected the bounding box with the highest score.
- You have cropped the image using the selected bounding box to isolate the selected object.
- You have counted the number of white pixels in the selected object.
- You have calculated the size of the object in millimetres by dividing the number of white pixels by the square of the pixels per millimetre.
- You have obtained the size of the object in terms of its dimensions using the size function.
- You have obtained the area of the object by counting the number of elements in the selected object.
How to find size of an object inside the bounding box?
4 views (last 30 days)
Show older comments
From the above image I want to find the size of that particular white region? How can we achive that?
i have used the below code
bounding_boxes = bboxes;
s=scores;
% Read the image
image = I;
pixels_per_mm=5;
[max_s,max_idx] =max(s);
selected_box= bounding_boxes(max_idx,:);
selected_object= imcrop(image,selected_box);
num_white_pixels=sum(selected_object(:) ==255);
object_size_mm = num_white_pixels / pixels_per_mm^2;
object_size = size(selected_object);
object_are= numel(selected_object);
i got output. But i dont know wheather it is correct approach or not?
0 Comments
Answers (1)
Sanju
on 11 Mar 2024
I understand that you have developed a code to find the size of the white region in the selected object, the approach you have taken seems to be correct.
Here's a breakdown of the steps you have followed,
Overall, your approach seems reasonable for finding the size of the white region in the selected object.
Note: it's important to validate it based on the specific requirements of your application and the characteristics of your images.
Hope this Helps!
0 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!