How do I count the number of pixels from top white to bottom white pixel?
5 ビュー (過去 30 日間)
表示 古いコメント
Stelios Fanourakis
2019 年 9 月 15 日
編集済み: Stelios Fanourakis
2019 年 9 月 20 日
Hello
I attach the image I want to work with.
I define with red vertical lines the width or the space of the area I want to measure the total number of pixels for every column (e.g. cumsum command). The columns will contain the total number of pixels of only the distance between the top white pixel of the curve and the last bottom white pixel. No beyond the two margins. Only this distance. From top white pixel to bottom white pixel, all pixels included in this black area, and only for the space between those two red vertical lines that denote the first and last white pixels of the white little curve line bottom structure.
I am sure it is not hard. Just a bit fuzzy and complicated but other than that I know it can be done.
Thanks for the time spending reading my query.
0 件のコメント
採用された回答
Image Analyst
2019 年 9 月 15 日
Try this:
[rows, columns] = size(binaryImage);
heights = zeros(1, columns);
for col = 1 : columns
thisColumn = binaryImage(:, col);
topRow = find(thisColumn, 1, 'first');
if ~isempty(topRow)
bottomRow = find(thisColumn, 1, 'last');
heights(col) = bottomRow - topRow; % Add 1 if you want.
end
end
5 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!