I not found any solution for my problem so i ask, how ?
and :
operators works when i have multiple statemants?
What i want to do, i have pixel on the middle pixel[pos]
and pixels around, its look like:
0 0 0
0 x 0
0 0 0
x
is a center pixel.
Im checking, if i have any white (zero
) pixel around it. If is anyone, i marked pixel as two
. If not, so pattern looks like:
1 1 1
1 x 1
1 1 1
1
is an black pixel, i set it to one
.
Now, the code:
if(pixels[positionOfPixel] == one && x > 0 && x < width
&& y > 0 && y < height)
{
pixels[positionOfPixel] = pixels[positionOfPixel - 1] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel + 1] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel - offset] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel + offset] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel - offset + 1] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel + offset - 1] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel - offset - 1] == zero ? two :
pixels[positionOfPixel] = pixels[positionOfPixel - offset + 1] == zero ? two : zero;
}
My question is, why every one
pixel is marked as two
? Why it didnt recognize pixel, where every pixel arond is one
(like in second pattern)?
Thanks for any advices!