How to fade color

后端 未结 8 1289
我寻月下人不归
我寻月下人不归 2021-02-06 05:56

I would like to fade the color of a pixel out toward white, but obviously maintain the same color. If I have a pixel (200,120,40), will adding 10 to each value to m

8条回答
  •  我在风中等你
    2021-02-06 06:22

    It's not that simple because in your monitor each color channel is weighted differently. I'd say the best bet is to do this in scikit image by converting to gray, dimming or brightening, and then back-converting to color. Scikit-image will take care of keeping the colors straight.

    from skimage.color import gray2rgb, rgb2gray
    scale_factor = 0.9 #90 percent
    img_new = gray2rgb(rgb2gray(img) * scale_factor)
    

    If you want to work directly with hue, saturation and value, check out this example:

    http://scikit-image.org/docs/dev/auto_examples/plot_tinting_grayscale_images.html

提交回复
热议问题