How to find size of an object inside the bounding box?

5 Ansichten (letzte 30 Tage)
Sahik Ha.adi
Sahik Ha.adi am 7 Mär. 2024
Beantwortet: Sanju am 11 Mär. 2024
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?

Antworten (1)

Sanju
Sanju am 11 Mär. 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,
  1. You have obtained the bounding boxes and scores of the detected objects.
  2. You have selected the bounding box with the highest score.
  3. You have cropped the image using the selected bounding box to isolate the selected object.
  4. You have counted the number of white pixels in the selected object.
  5. 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.
  6. You have obtained the size of the object in terms of its dimensions using the size function.
  7. You have obtained the area of the object by counting the number of elements in the selected object.
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!

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by