I have and array of 80 integers
int[800] px;
From this array I create an image of 80x100 points (h: 80, w:100)
For finding centered pixel in array I use:
px[(w >> 1) * (h + 1)]
But now I need to find 4x4 (16centered pixels and average them. Can you please help me do this?
So you have a one-dimention array (p
), whitch contains an image (im[x][y] = p[im.width*x+y]
) an you want to know which is the middle 4x4 of that image and compute the average of those 16 pixels.
The middle of the 80x100 pixels image is at (40,50); (I would use a 3x3 window instead of 4x4) so you need the pixels (40+i,50+i), where i in {-1,0,1}. Now you can use a variable to compute the average of 3x3=9 pixels value
There is a library, OpenCV that can do alot of stuffs and can be integrated with Java.