Scanning intensity level of pixel image
Hi,
I want to scan intensity value of pixel for binary image. Here is the code that I build.
byte* p = (byte*)imgData.Scan0.ToPointer();
int i = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
{
if (*p != 0)// white
{
i++;
}
else
{
i = 0;
}
}
++p;
}
p += srcOffset;
}
if (i >= 10)
resultScan = "PASS";
else
resultScan = "FAIL";
Here, I want to make it;
If there are any intensity values of pixel other than zero, and the total of that pixel is more or similar to 10, it will return âPASSâ. Otherwise it will return âFAILâ. Means, it will return âPASSâ if I put object in the field of view and returns âFAILâ if no object in the field of view.
However, it not gives right answer. It just give âFAILâ statement for both condition. Iâm sure this is not the mistake from type of image input but something wrong with the condition of âif elseâ. Could any body help me please to check where the mistakes are? Thanks.
|