- Example 1: (a,b) = (0,b). Answer = b+1.
- Example 2: (a,b) = (1,2). Answer = 4. The line passes through (0,0), (0,1), (1,1), and (1,2).
- Example 3: (a,b) = (2,2). Answer = 3. The line passes through (0,0), (1,1), and (2,2).
how to find number of pixels in a region of a hand?
1 次查看(过去 30 天)
显示 更早的评论
We are doing a project on detection of asl. We have extracted hand from the background. Now we need to do feature extraction for which we are using radial length signature. We need to find the number of pixels from the centroid to the edge of the hand. We are successful in drawing the radial lines but now we are stuck with counting the number of pixels from centroid to the edge. Can somebody pls help us.
0 个评论
回答(1 个)
Jonathan
2011-2-19
I am making some assumptions, here, about how you count pixels. Hopefully, these assumptions will be clear via the following examples.
I assume your radial lines go from the center of pixel (0,0) to the center of pixel (a,b).
To summarize this counting method into a formula, we need to characterize the conditions under which the line passes through a pixel vertex (as in example 3) and not a pixel edge (as in examples 1 and 2). I can give you the reasoning behind my answer if you like. For now I give you the formula below.
function numPts = numPoints(a,b)
diagPixels = gcd(a+1,b+1) - 1;
numPts = a + b + 1 - diagPixels;
end
~Jonathan
2 个评论
Jonathan
2011-2-20
If you want to count all four pixels at a vertex crossing, use the following for numPts.
numPts = a + b + 1 + 2*diagPixels;
~Jonathan
Hassan Javaid
2014-3-11
I am also doing the same project can you tell me how the function works? And also the reasoning?
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!