Im looking to implement a feature in Java which reads an image and is able to detect where there are shades of red, blue, green, yellow, etc. as part of a satellite image analysis program. So for example in a standard satellite image, blue would be water so I would like the program to read how many pixels are blue and then it could say x% of the image is water.
I know it would be possible using a whole load of logic statements by reading the RGB value of each pixel but is there an easier way to do this? Otherwise there will be hundreds of if statements which is going to take a long time to write but also a long time to perform. Ideally id like something like this:
if (pixelValue = red) {
redCounter++;
}
Which is obviously very simple but it would save having to go through every single possible RGB combination for red, blue, green, yellow, purple, etc. which are all colours present in some of the coloured images.
Thanks in advance.