Hi I would like to write a program that can tell me the color of a pixel base on the RGB values. Currently I am using the following code to read pixels from a buffered image. However, this program can only identify 7 colors and is very inaccurate. If possible, I want the program to be able to identify whether the color is light or dark. ie. "light red" "dark red"
Public static void main(String args[]){
boolean isRed=false;
boolean isGreen=false;
boolean isBlue=false;
String color="";
//read color from a color array
blue = color[i][j].getBlue();
red = color[i][j].getRed();
green = color[i][j].getGreen();
if(blue>(255-blue)) {
isBlue=true;
}
if(red>(255-red)) {
isRed=true;
}
if(green>(255-green)) {
isGreen=true;
}
if(isRed==false&&isGreen==false&&isBlue==false) {
color="black";
}else if(isRed==true&&isGreen==true&&isBlue==true) {
color="white";
}else if(isRed==true&&isGreen==false&&isBlue==false) {
color="red";
}else if(isRed==false&&isGreen==true&&isBlue==false) {
color="green";
}else if(isRed==false&&isGreen==false&&isBlue==true) {
color="blue";
}else if(isRed==true&&isGreen==true&&isBlue==false) {
color="yellow";
}else if(isRed==false&&isGreen==true&&isBlue==true) {
color="cyan";
}else if(isRed==true&&isGreen==false&&isBlue==true) {
color="magenta";
}
System.out.println(color);
}