-1

I have the RGB values from image and i want to make the neural network to recognize which object is and to get the color of the object.

Note: I already have my own neural network but is based on gray color.

How can i make an algorithm for my neural network to understand which object is in different color like(black, white, yellow, violet...and so on) and what color has?

Eamrle
  • 3
  • 1

1 Answers1

0

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.

  1. Perhaps the image has white background pixels. Where there are white pixels don't count them in the RGB average.

  2. 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.

  1. 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.
gary
  • 26
  • 3