Crack Detection Annotation Issue

10 ビュー (過去 30 日間)
文辉 沈
文辉 沈 2022 年 6 月 2 日
編集済み: Chunru 2022 年 6 月 3 日
How do I label it after the crack size is calculated?
I am currently using text()
1、The length of the crack I marked at the midpoint of the line segment
plot([coord1(1), coord2(1)],[coord1(2), coord2(2)],'b','LineWidth',2);
text((coord1(1)+coord2(1))/2,(coord1(2)+coord2(2))/2,[' ','Length = ',num2str(length)],'Color','b');
2、I just mark the angle in the upper left corner, is there any function that can draw the angle arc, and then mark the angle next to the angle arc
text(20,20,['Angle = ',num2str(angle),'°'],'Color','b');
3、Width, I can only know which line to take the maximum value, but I can't return the coordinates of the two ends where the maximum value is located. Is there any solution?
for i = 1:c
width = find(bw(i,:),1,'last')-find(bw(i,:),1,'first');
K(i)=width;
end
Width = max(K);
  1 件のコメント
文辉 沈
文辉 沈 2022 年 6 月 2 日
When the length is marked, the characters exceed the image frame when saving, how to solve this?

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

回答 (1 件)

Chunru
Chunru 2022 年 6 月 2 日
編集済み: Chunru 2022 年 6 月 3 日
1、The length of the crack I marked at the midpoint of the line segment: Use horizontal alignment
plot([coord1(1), coord2(1)],[coord1(2), coord2(2)],'b','LineWidth',2);
text((coord1(1)+coord2(1))/2,(coord1(2)+coord2(2))/2,[' ','Length = ',num2str(length)],'Color','b', ...
'HorizontalAlignment','center'); % center or right
2、I just mark the angle in the upper left corner, is there any function that can draw the angle arc, and then mark the angle next to the angle arc
text(20,20,['Angle = ',num2str(angle),'°'],'Color','b');
% Assume (x0, y0) be the coordinates or the angle vertex
theta = linspace(0, angle, 50);
r = 10; % radius of the arc
plot(x0+r*sind(theta), y0+r*cosd(theta), 'b-');
3、Width, I can only know which line to take the maximum value, but I can't return the coordinates of the two ends where the maximum value is located. Is there any solution?
maxw = 0; % max width
for i = 1:c
wr = find(bw(i,:),1,'last');
wl = find(bw(i,:),1,'first')
width = wr-wl;
if width > maxw
maxw = width;
maxwl = wl;
maxwr = wr;
end
%K(i)=width;
end
maxw, maxwl, maxwr
  2 件のコメント
文辉 沈
文辉 沈 2022 年 6 月 2 日
theta = linspace(0, angle, 50);
How to modify the sentence, divide the two points into 50 paragraphs, what is the use?
Chunru
Chunru 2022 年 6 月 3 日
編集済み: Chunru 2022 年 6 月 3 日
You want to plot an arc. The arc is a curve consiting of 50 points from theta=0 to theta=angle deg.

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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by