Interpreting the output of regionprops function

2 ビュー (過去 30 日間)
Roohollah
Roohollah 2023 年 10 月 3 日
コメント済み: Image Analyst 2023 年 10 月 3 日
I have some ellipse in an image and I used regionprops function to find the length of their major and minor axes.
The output of function is in pixels and I need to convert it to millimeters. Consder the following as output of regionprops function and please help me to figure the conversion out:
MajorAxisLength: 320 pixels
MinorAxisLength: 180 pixels
Orientation: 25 degrees
pixel-to-mm conversion factor: 0.1 mm/pixel
Now the question is what are the length of major and minor axes in mm?
Many thanks

採用された回答

Image Analyst
Image Analyst 2023 年 10 月 3 日
Try this:
% Measure properties of all the individual blobs in the image.
props = regionprops(mask, 'MajorAxisLength', 'MinorAxisLength', 'Orientation');
% Define spatial calibration factor to convert pixels to millimeters.
scaleFactor = 0.1 % mm/pixel
% Get all the major axis lengths of all the blobs into one vector.
allMajorAxisLengths = [props.MajorAxisLength] * scaleFactor; % Will have units of mm.
% Get all the minor axis lengths of all the blobs into one vector.
allMinorAxisLengths = [props.MinorAxisLength] * scaleFactor; % Will have units of mm.
% Get all the orientations of all the blobs into one vector.
allOrientations = [props.Orientation]; % Has units of degrees
  2 件のコメント
Roohollah
Roohollah 2023 年 10 月 3 日
I think this cannot be the case. Maybe I am wrong. But what if the major axis has an angle of 25 degrees with respect to x-axis? I am asking this questions since for an image, the number of pixels are given just along x and y axes. When there is an angle between major axis and x-axis, I orientation must be taken into account for converting the length of major and minor axis of ellipse to mm.
Please correct me if I am wrong.
Image Analyst
Image Analyst 2023 年 10 月 3 日
The blob is somehow fitted to an ellipse, perhaps using something like this:
The major axis length is along the main axis of the blob, which will be tilted at some angle usually. It is not the bounding box, which goes parallel with the axes, which is maybe where your confusion comes in. The ellipse fitted to the blob will NOT usually fit into the bounding box of the irregularly-shaped blob (for obvious reasons if you just think about it). The minor axis is the smaller of the axes of the fitted ellipse and will be perpendicular to the main axis, and of course 90 degrees rotated from the "Orientation" angle.
If for some reason you want the projected distances along x and y of the ellipse, you can approximate that by multiplying by 2*MajorAxidLength*sind(Orientation). I have never ever needed this and don't know why you would either.
I suggest you take a look at bwferet since it might be more like what you want perhaps.

サインインしてコメントする。

その他の回答 (1 件)

Abderrahim. B
Abderrahim. B 2023 年 10 月 3 日
Hi!
It s a simple conversion:
MajorAxisLength = 320 ; % in pixels
MinorAxisLength = 180 ; % in pixels
MinorAxisLength = 0.1*MinorAxisLength % in mm
MinorAxisLength = 18
MajorAxisLength = 0.1*MajorAxisLength % in mm
MajorAxisLength = 32
Hope this helps
-Abderrahim

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by