Intensify or increase Saturation of an image

Viewed 12754

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)?enter image description here

Goal is this: enter image description here

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)
1 Answers

I convert it to HSV colorspace, and increment the S channel value to the max for the values that are "green".

enter image description here

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:

enter image description here

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.

Related