Hey the technique is called bit shifting.
int alpha = (pixels[ctr] >> 24) & 0xff;
you are getting 24th to the 32nd bits of the int.
Check out
http://www.javage.net/cgi-bin/showArt.cgi?index=7Finding all the red pixels is pretty easy.
int width = img.getWidth(null);
int height = img.getHeight(null);
int[] imageData = new int[width * height];
PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, imageData, 0, width);
try
{
pg.grabPixels();
} catch (InterruptedException e) {
}
for(int i=0; i<width; i++)
{
for(int j=0; j<height; j++)
{
int pixel = imageData[i + (j * width)];
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
if(red==255 && green == 0 && blue == 0){
// Found full red pixel.
}
}
}