Coded in Python. I have the following image that I classified with making so only what was found to have its original colour. Is there a way I can intensify the pixels colour (mage the green...greener)?
Goal is this:
img = cv2.imread("/Volumes/EXTERNAL/ClassifierImageSets/Origional_2.png",1)
mask = cv2.imread("/Users/chrisradford/Documents/School/Masters/RA/Classifier/Python/mask.png",0)
result = cv2.bitwise_and(img,img,mask=mask)
Saturation refers to the intensity of a color. The higher the saturation of a color, the more vivid it is. The lower the saturation of a color, the closer it is to gray. Lowering the saturation of a photo can have a “muting” or calming effect, while increasing it can increase the feel of the vividness of the scene.
The Hue/Saturation command adjusts the hue (color), saturation (purity), and lightness of the entire image or of individual color components in an image. Use the Hue slider to add special effects, to color a black and white image (like a sepia effect), or to change the range of colors in a portion of an image.
Color saturation refers to the intensity of color in an image. As the saturation increases, the colors appear to be more pure. As the saturation decreases, the colors appear to be more washed-out or pale.
I convert it to HSV colorspace, and increment the S channel value to the max for the values that are "green".
with this code:
import cv2
img = cv2.imread("D:\\testing\\test.png",1)
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
greenMask = cv2.inRange(hsv, (26, 10, 30), (97, 100, 255))
hsv[:,:,1] = greenMask
back = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
cv2.imshow('test', back)
cv2.waitKey(0)
cv2.destroyAllWindows()
If you want, you can put pure green to it like this:
with this code:
import cv2
img = cv2.imread("D:\\testing\\test.png",1)
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
greenMask = cv2.inRange(hsv, (26, 10, 30), (97, 100, 255))
img[greenMask == 255] = (0, 255, 0)
cv2.imshow('test', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
It seems that a part of the small thing in the south is also green (or green enough).
I hope this helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With