Change color for parts of an image

I am trying to find a solution that will allow me to change the color for parts of an image.

For example, let's say a picture of a chair. The chair can have different frame or cushion colors. I intend to allow users to select a frame or pillow and update the image. We can only upload one chair image.

Any idea is greatly appreciated!

+3


source to share


1 answer


Detecting parts of an image to be modified

Detecting objects in images programmatically is probably not easy;). I believe that one of the good solutions to this problem was suggested by Collin O'Dell in his comment on the question. He suggested using multiple images with manually separated parts of the image you want to recolor. Then you can compose the final image from several different layers.

However, you can also save the main image with all the objects and manually take a few additional images, but only to preserve the object masks (that is, the white pixels where the object is located). Then you can easily check which pixels should be repainted. This will allow you to paint directly on one image and avoid compositing.

Calculation of color



If you want to recolor a photo, you probably want to keep the shading effect, etc., rather than cover it with the same solid color. To achieve this, you can use HSV color space instead of RGB . To use this method, you must:

  • read pixel color (in RGB )
  • convert it to HSV
  • change the hue value of the color to get the desired hue of the color
  • recaluclate the changed color back to RGB
  • set new pixel color

For more information on the HSV color space you can look here: http://en.wikipedia.org/wiki/HSL_and_HSV .

+1


source







All Articles