필터 지우기
필터 지우기

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

조회 수: 11 (최근 30일)
Sahik Ha.adi
Sahik Ha.adi 2024년 3월 7일
답변: Sanju 2024년 3월 11일
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?

답변 (1개)

Sanju
Sanju 2024년 3월 11일
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!

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by