title: How to convert from sRGB to linear sRGB for computing the color correction matrix in opencv? (CCM)
body: <p>I have referred to the following <a href="https://stackoverflow.com/questions/49221892/color-correction-matrix-in-lab-color-space-opencv">stackoverflow thread</a> for computing the color correction matrix. </p>
  
  <p>As referred in the thread mentioned above, I want to convert from the sRGB color space to linear sRGB space, I'm trying to use the <a href="http://pydoc.net/pwkit/0.8.15/pwkit.colormaps/" rel="nofollow noreferrer">pwkit colorspace mapper</a> code for the conversion. </p>
  
  <p>However, i'm unsure about the resulting linear sRGB values, since the function requires sRGB in range [0-1], is dividing the sRGB values by 255.0, the correct approach? How to verify that the linear sRGB values returned by the function are correct? </p>
  
  <pre><code>import os
  import numpy as np
  import cv2 
  import matplotlib.pyplot as plt
  
  def srgb_to_linsrgb (srgb):
      """Convert sRGB values to physically linear ones. The transformation is
         uniform in RGB, so *srgb* can be of any shape.
  
         *srgb* values should range between 0 and 1, inclusively.
  
      """
      gamma = ((srgb + 0.055) / 1.055)**2.4
      scale = srgb / 12.92
      return np.where (srgb &gt; 0.04045, gamma, scale)
  
  
  if __name__ == "__main__":
  
      colorChecker = cv2.imread('C:/Users/Ai/Documents/Urine Sample Analysis/Assets/colorchecker_1.jpg')
      cc = cv2.cvtColor(colorChecker,cv2.COLOR_BGR2RGB)
      plt.imshow(cc)
  
      #Convert srgb to linear rgb
      cc = cc / 255.0
      cc1 = srgb_to_linsrgb(cc)
      print("Conversion from sRGB to linear RGB:\n")
      print(cc1[1,1,:])
  </code></pre>
  
  <p>The result of conversion is: [0.30946892 0.23455058 0.19806932]</p>
  
  <p>The input sRGB should be between 0-1, how to scale the value of sRGB channels from [0-255] to [0-1], would simple division by 255.0 result in correct linear sRGB values? How to verify that the conversion has resulted in correct linear sRGB values?</p>