Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intensify or increase Saturation of an image

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)
like image 772
C.Radford Avatar asked Aug 31 '18 01:08

C.Radford


People also ask

What does increasing saturation do to an image?

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.

What does increasing saturation in an image do in Photoshop?

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.

What does it mean to increase color saturation?

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.


Video Answer


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.

like image 63
api55 Avatar answered Sep 18 '22 02:09

api55