フィルターのクリア

How to find the broadest width of contour and calculate it.

2 ビュー (過去 30 日間)
AliAlemana
AliAlemana 2018 年 12 月 19 日
コメント済み: Image Analyst 2018 年 12 月 27 日
Hello everybody,
I would like to know, where my contour(1440 in the picture) is broadest (considering the y-direction for the width) and calculate it.
I read a lot but I am not sure which suggestion would be the best for my case (interp2, In2bw,...).
Thank you very much for your help,
Alina

採用された回答

Image Analyst
Image Analyst 2018 年 12 月 19 日
Try this (untested)
binaryImage = grayImage >= 1440
binaryImage = bwareafilt(binaryImage, 1); % Extract only the largest blob.
[rows, columns] = size(binaryImage);
for col = 1 : columns
thisColumn = binaryImage(:, col);
topRow(col) = find(thisColumn, 1, 'first');
bottomRow(col)= find(thisColumn, 1, 'last');
heights(col) = bottomRow(col) - topRow(col);
end
maxHeight = max(heights);
columnsOfMaxHeight = find(heights == maxHeight); % Might be more than one column with max height!
% Draw it
hold on;
for k = 1 : length(columnsOfMaxHeight)
thisCol = columnsOfMaxHeight(k);
line([thisCol, thisCol], [topRow(thisCol), bottomRow(thisCol)], 'Color', 'r', 'LineWidth', 2)
end
Let me know of any problems.
  2 件のコメント
AliAlemana
AliAlemana 2018 年 12 月 27 日
Dear Image Analyst,
I am very sorry I reply so late, I found an easier solution than yours but still, thank you very very much for the fast and helpful answer!
Image Analyst
Image Analyst 2018 年 12 月 27 日
What was your easier solution?

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by