Calculating the number of pixels inside a freehand region.
古いコメントを表示
I have a binary image, what I want to do is select a freehand region and then find out the total number of white and black pixels inside that region.
採用された回答
その他の回答 (1 件)
Image Analyst
2014 年 7 月 1 日
0 投票
This is exactly what my freehand drawing demo does. See attached.
4 件のコメント
Image Analyst
2014 年 7 月 1 日
Post your image and tell me what you're tracing around. If you have a pure black and pure white image rather than gray scale, you'll have to multiply the mask by your image before summing so that you'll get only the few pure black and pure white pixels in the freehand mask area rather than counting the total number of pixels in the area.
Image Analyst
2022 年 4 月 25 日
See my demo to get the coordinates of the hand-drawn shape. Let's call them x, y, so first create a mask with poly2mask, then use nnz()
[imageRows, imageColumns = size(originalBinaryImage);
insideShape = poly2mask(x, y, imageRows, imageColumns);
newMask = originalBinaryImage & insideShape;
pixelCount = nnz(newMask)
カテゴリ
ヘルプ センター および File Exchange で Build Interactive Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

