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!

