To use your own neural network to determine which type of object it is,
you could convert the RGB values to grayscale values using the formula
Gray = Ylinear = 0.2126Red + 0.7152Green + 0.0722*Blue. You would do that because it is already trained to recognize objects that are grayscale.
See Converting RGB to grayscale/intensity.
To get the color name of the object you need to mask off the non-object background. Then average the object RGB values.
Perhaps the image has white background pixels. Where there are white pixels don't count them in the RGB average.
If there is a sharp contrast between the image and the background, take the derivative (calculus) of the pixel(x,y). This will give you an outline. Zero low values. Then integrate the derivative function to get a black and white mask of the object. Then find the RGB average.
Once you have an average RGB value, you need a list of color names with RGB values.
Black 0 0 0
White 255 255 255
Red 255 0 0
Green 0 255 0
Blue 0 0 255
Violet 255 0 255
Yellow 255 255 0
etc
Choose the color closest to the average.
- If you can't easily remove the background pixels, but the object is mostly one color you still might be able to find its color. Make a histogram to find the major colors groups. Then one by one, remove all colors except the one. When the neural network object type choice is the same as for the gray scale, you probably know the color. Suppose the object is a red square and the background has blue, cyan, green, and yellow.
Keeping only red would show a square.