So I am running a bit of code that is supposed to allow me to desaturate and then saturate an image. I have a function that is supposed to allow me to do this, but no matter how I change the code, it always shifts the color so it doesn't desaturate.
My Function:
def desaturation(img,percent=.5):
imgGreen=img[:,:,1]
desatGreen=imgGreen*percent
desatImg=img[:,:,:]
desatImg[:,:,1]=desatGreen
return desatImg
Each time I run it, it shifts the color to a magenta rather than a desaturated look that I would expect. I would prefer to have the color range still remain in BGR rather than any of the other color ranges. Is there any bit of code that can help me with this, doing it raw rather than relying on another builtin function?
Edit: I have the percent variable set so that it can never go above 1 and never below 0.
Edit: I would like to desaturate the entire image. The way my code is written is a bit misleading.