フィルターのクリア

change the color of line inside the boundaries and measure length of this part of line?

2 ビュー (過去 30 日間)
Walaa
Walaa 2022 年 12 月 1 日
コメント済み: Rik 2022 年 12 月 1 日
Could you kindly help me in changing the colour of the line inside the red borders to green and measuring the length of this part of  line? I attached the code for plotting the cyan line.
% Plot the boundary over the original image
% Display the image.
subplot(1,2, 2);
imshow(originalImage2, []);
hold on;
caption = sprintf('original image with plotted disc diameter');
title(caption, 'FontSize', 10);
hold on
plot(smoothX1, smoothY1, 'r-', 'LineWidth', 4);
plot(smoothX2, smoothY2, 'r-', 'LineWidth',4);
hold on
%-------------------------------------------------------------------------------------------------------------------------------------
xLine = [smoothx1(index1), smoothX2(index2)];
yLine = [smoothy1(index1), smoothY2(index2)];
hold on
numLines = 1;
lineColors = jet(numLines);
x = randi(columns, numLines, 2);
y = randi(rows, numLines, 2);
% Now extend these lines in the overlay until the image edge.
for k = 1 : numLines
coefficients = polyfit( xLine (k, :), yLine(k, :), 1);
% Define x values to be the whole width of the image.
xFit = 1 : columns;
% Get y values. Note: some may be less than 1 or more than rows but we will adjust.
yFit = polyval(coefficients, xFit);
goodIndexes = yFit >= 1 & yFit <= rows;
xFit = xFit(goodIndexes);
yFit = yFit(goodIndexes);
% Display in overlay above the image.
line([xFit(1), xFit(end)], [yFit(1), yFit(end)], 'Color', lineColors(k, :), 'LineWidth', 3);
end
  2 件のコメント
KSSV
KSSV 2022 年 12 月 1 日
You have to attch the image.
Rik
Rik 2022 年 12 月 1 日
If you have the coordinates of the red line, you should be able to find the intersection. Once you have those, finding the length is trivial, as is plotting a new line with a different color.
You can even use my point_to_line_distance function to find the boundary elements closest to the line.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by