I would like to improve the layer mask that I am creating in Python. Although my mask pretty much hits the targeted color, my main problem with it, is it is doing so in binary, the pixel is either pure white or pure black. I’m unable to extrapolate the intensity of the color. I want to achieve something like how Photoshop does it wherein there are mid-tones of grey on the mask. Just like these photos:
![Image]()
![Image]()
Can anyone please show how to recreate (or similar) to the mask that photoshop can create? It doesnt have to be strictly done in openCV, if you know of a module that does this please do share it,
Here is the photo i used above :
![Image]()

Code:
image = cv2.imread('sample.jpg')lower = np.array([0,0,0]) upper = np.array([12,255,255])mask = cv2.inRange(cv2.cvtColor(image, cv2.COLOR_BGR2HSV), lower, upper)mask = 255 - maskmask = cv2.bitwise_not(mask) #inverting black and whiteoutput = cv2.bitwise_and(image, image, mask = mask)cv2.imshow("output", output) cv2.imshow("mask", mask) cv2.waitKey()

Can anyone please show how to recreate (or similar) to the mask that photoshop can create? It doesnt have to be strictly done in openCV, if you know of a module that does this please do share it,
Here is the photo i used above :

Statistics: Posted by drakejest — Sat Mar 23, 2024 8:00 pm