我如何测量图像的距离

8视图(30天)
Warisa Theerathamtada
Warisa Theerathamtada 2023年2月4日
评论道: 图像分析 2023年2月5日
我想测量的最大距离ROI图像沿x和y轴通过写代码。
这是我的ROI图像
我想知道沿着x轴和y轴的最大距离为例
谢谢你!

答案(2)

图像分析
图像分析 2023年2月4日
使用 bwferet 。让我知道如果你不能自己找出答案。
帮助bwferet
BWFERET Feret直径测量和角度的图像区域。= BWFERET(我)措施的最大Feret每个组件的属性(对象)的形象。我可以是一个二进制图像,连接组件或标记矩阵。= BWFERET (BW,属性)措施一组Feret每个连接组件的属性二进制映像BW(对象),这是一个逻辑数组。= BWFERET (CC、属性)措施一组Feret每个连接组件的属性在CC(对象),这是一个由BWCONNCOMP返回结构体。= BWFERET (L,属性)措施一组Feret属性标签矩阵中的每个标签组件(对象)L L的正整数元素对应于不同地区。例如,L等于1的元素的集合对应区域1;L等于2的元素的集合对应地区2;等等。[,L] = BWFERET(…)措施一组Feret每个组件的属性(对象)在二进制图像,连接组件或标记矩阵。 This also returns the corresponding label matrix L such that the first value in the table OUT corresponds to the labeled region 1, the second value with the labeled region 2 and so on. PROPERTIES can be an array of strings, a single character vector, a cell array of character vectors, or 'all'. If PROPERTIES is set to 'all' it returns all the Feret properties mentioned below. If no argument is provided, all maximum Feret properties are given as outputs. The set of valid measurement strings or character vectors includes 'MaxFeretProperties', 'MinFeretProperties' and 'all'. 'MaxFeretProperties' - Outputs all the properties related to maximum Feret Diameter. These properties are: MaxDiameter - Maximum Feret diameter length. MaxAngle - Angle of maximum Feret diameter with respect to X axis in degrees. The value lies between 180 to -180 degrees. MaxCoordinates - Endpoint coordinates of maximum Feret diameter. 'MinFeretProperties' - Outputs all the properties related to minimum Feret Diameter. These properties are: MinDiameter - Minimum Feret diameter length. MinAngle - Angle of minimum Feret diameter with respect to X axis in degrees. The value lies between 180 to -180 degrees. MinCoordinates - Endpoint coordinates of minimum Feret diameter. Class Support ------------- If the first input is BW, BW must be a logical array and it should be 2D. If the first input is CC, CC must be a structure returned by BWCONNCOMP. If the first input is L, L must be real, nonsparse and 2D. L can have any numeric class. The output OUT is returned as a table. Example 1 --------- % Calculate the minimum Feret diameter for objects in image I = imread('toyobjects.png'); bw = imbinarize(I, 'adaptive'); % Retain the two biggest objects in the image bw = bwareafilt(bw, 2); bw = imfill(bw, 'holes'); % Calculate the Feret properties of the objects in the image along with % the label matrix [out, L] = bwferet(bw, 'MinFeretProperties'); Example 2 --------- % Plot the maximum Feret diameter for objects in the image % Read an image I = imread('toyobjects.png'); % Binarize the image B = imbinarize(I, 'adaptive'); % Fill in the holes in the binary image B = imfill(B, 'holes'); % Show the image h = imshow(B) ax = h.Parent; % Convert to connected component struct using bwconncomp C = bwconncomp(B); % Calculate Feret Properties F = bwferet(C, 'MaxFeretProperties'); hold on % Display maximum Feret Diameters with their values for each object imdistline(ax, F.MaxCoordinates{1}(:,1), F.MaxCoordinates{1}(:,2)); imdistline(ax, F.MaxCoordinates{2}(:,1), F.MaxCoordinates{2}(:,2)); imdistline(ax, F.MaxCoordinates{3}(:,1), F.MaxCoordinates{3}(:,2)); imdistline(ax, F.MaxCoordinates{4}(:,1), F.MaxCoordinates{4}(:,2)); See also BWCONNCOMP, BWLABEL, BWLABELN, LABELMATRIX, REGIONPROPS. Documentation for bwferet doc bwferet
或者你可以使用 bwboundaries 紧随其后的是 pdist2 马克斯
1评论
Warisa Theerathamtada
Warisa Theerathamtada 2023年2月5日
谢谢你先生,我刚刚发现功能。我将试着为你告诉我结果。谢谢你!

登录置评。


为副总经理
为副总经理 2023年2月4日
编辑:为副总经理 2023年2月5日
你说你想要沿着x和y轴的最大距离,但是你画的是别的东西。所以你想要哪一个?
您可以使用regionprops()来获得主要/次要等效椭圆的直径。否则,根据你的解释,你可以得到边界框几何或feret属性使用regionprops ()。
从截图%裁剪
inpict = imread (“image.png”)> 128;
%得到属性
S = regionprops (inpict“MajoraxisLength”,“MinoraxisLength”,“定位”,
“MinFeretProperties”,“MaxFeretProperties”,的边界框(“大小));
%整齐边界框的宽度和高度
S.BoundingBox (3:4)
ans = 1×2
47 70
%的直径相当于椭圆和角度
%这些直径在90度
[S。MinorAxisLength S.MajorAxisLength]
ans = 1×2
42.8568 - 74.9145
年代。定位+ (90 0)
ans = 1×2
164.8426 - 74.8426
%最小/最大Feret直径和角度
%这些不一定发生在90度
[S。MinFeretDiameter S.MaxFeretDiameter]
ans = 1×2
42.2930 - 73.6817
180 - [S。MinFeretAngle S.MaxFeretAngle]
ans = 1×2
167.7995 - 71.8110
Feret属性也可以获得使用bwferet () @Image分析师 提到。
4评论
图像分析
图像分析 2023年2月5日
好,一个坏形象!你可以得到mm每像素的图像,因为你可以看看硬币的宽度。但是你的相机不是出于某种原因直接开销。这意味着空间在垂直方向的变化取决于校准线。,很不幸的是你有药丸被垂直对齐。所以你可以口服避孕药的宽度,但它只将近似的长度。你可以使用相同的毫米每像素(错误地)认为是一样的不管你行什么,当然避孕药的垂直长度将只有近似。如果你想要更准确的测量你应该相机直接开销。

登录置评。

类别

找到更多的在图像处理和计算机视觉帮助中心文件交换

下载188bet金宝搏


释放

R2022a

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!