how to find number of pixels in a region of a hand?

조회 수: 1 (최근 30일)
neha
neha 2011년 2월 18일
댓글: Hassan Javaid 2014년 3월 11일
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.

답변 (1개)

Jonathan
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).
  • 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).
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
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
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!

Translated by