Ask Your Question

SmokedCheese's profile - activity

2019-07-03 08:41:39 -0600 received badge  Notable Question (source)
2018-12-08 03:55:19 -0600 received badge  Popular Question (source)
2013-12-08 04:53:44 -0600 received badge  Editor (source)
2013-12-08 04:39:47 -0600 asked a question OpenCV and HLS

Why when i'm open first image, then convert to HLS, extract hue and set saturation and lightness to 127, then convert to RGB and save (second image). Why colors is wrong? image description image description

import cv2, numpy
img = cv2.imread('image.png')
img = cv2.cvtColor(img, cv2.COLOR_RGB2HLS)
hue = img.T[0]
sl = numpy.repeat(numpy.uint8(127), hue.shape[0] * hue.shape[1])
sl  = sl.reshape(hue.shape)
img = numpy.array((hue, sl, sl)).T
img = cv2.cvtColor(img, cv2.COLOR_HLS2RGB)
Image.fromarray(img).save('pew.png')

But when i do

img = cv2.cvtColor(img, cv2.COLOR_HLS2BGR)

all is right
image description