[PYTHON] Adjust OpenCV contrast

I tried to create a python version by referring to the following site. http://gori-naru.blogspot.jp/2012/11/blog-post_8647.html

#image must be GRAYSCALE
def contrast(image, a):
  lut = [ np.uint8(255.0 / (1 + math.exp(-a * (i - 128.) / 255.))) for i in range(256)] 
  result_image = np.array( [ lut[value] for value in image.flat], dtype=np.uint8 )
  result_image = result_image.reshape(image.shape)
  return result_image

Recommended Posts

Adjust OpenCV contrast
About Opencv ②
About Opencv ③
How to adjust image contrast in Python
About Opencv ①