So, what I'm trying to do is run through a picture that is 1024x768 (Or, popMap.getWidth x popMap.getHeight), grab the blue color of it, compare it to the highest blue so far, and if it's more, that blue becomes the new 'newBlue'. Basically, find the highest blue value in an image, closest to 255 blue.
Also, I'm attempting to store the blue value of the entire thing into an array popMapArray, which is a 2d array with 3 columns, storing [blueValue][x][y]. Which I will then sort, to get a list from high to low of the bluest values.
My problem, is that with the code below, it's only storing into the array when column=767.
I get 1024 [blue,row,767], and then the rest are all [0,0,0]
Any clue why? Java, by the way.
for (int row = 0; row < popMap.getWidth(); row++)
{
for (int column = 0; column < popMap.getHeight(); column++)
{
System.out.println(column);
//Find a Pixel
int c = popMap.getRGB(row, column);
int red = (c & 0x00ff0000) >> 16;
//int green = (c & 0x0000ff00) >> 8;
//int blue = c & 0x000000ff;
// and the Java Color is ...
Color color = new Color(red);
int newBlue = color.getBlue();
int oldBlue = lastColor.getBlue();
switch(popArrayRow)
{
case 0:
{
arrayVar = newBlue;
popArrayRow = 1;
break;
}
case 1:
{
arrayVar = row;
popArrayRow = 2;
break;
}
case 2:
{
arrayVar = column;
popArrayRow = 0;
break;
}
}
popArray[row][popArrayColumn] = arrayVar;
//System.out.println(popArray[row][popArrayColumn]);
switch(popArrayColumn)
{
case 0:
{
popArrayColumn = 1;
break;
}
case 1:
{
popArrayColumn = 2;
break;
}
case 2:
{
popArrayColumn = 0;
break;
}
}
if(newBlue > oldBlue)
{
startX = row;
startY = column;
//System.out.print(row);
//System.out.print(",");
//System.out.println(column);
System.out.print("The oldBlue is ");
System.out.println(oldBlue);
lastColor = color;
}
}
}