You are getting copy of the array of pixels from the pixel block corresponding to the plane (== 0) with a copy of the pixel data (second argument is set to true).
Array array = block.GetPixelData(0, true);
But you are not using the array in your analysis, maybe try:
Array array = block.GetPixelData(0, true);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int pixelValue = array[x, y];
}
}
I don't have a raster handy, so i am not sure which array dimension corresponds to x (width) and y (height). I assume that the dimension arguments correspond to sourcePixels.GetValue (x, y), but you should double check this in your code to make sure that's the case.