def rgb2dklCart(picture, conversionMatrix=None):
 picture = numpy.array(picture)
 origShape = picture.shape
 if (conversionMatrix is None):
  conversionMatrix = numpy.asarray([[0.25145542, 0.64933633, 0.09920825], [0.78737943, (-0.55586618), (-0.23151325)], [0.26562825, 0.63933074, (-0.90495899)]])
  logging.warning('This monitor has not been color-calibrated. Using default DKL conversion matrix.')
 else:
  conversionMatrix = numpy.linalg.inv(conversionMatrix)
 red = picture[:, :, 0]
 green = picture[:, :, 1]
 blue = picture[:, :, 2]
 dkl = numpy.asarray([red.reshape([(-1)]), green.reshape([(-1)]), blue.reshape([(-1)])])
 dkl = numpy.dot(conversionMatrix, dkl)
 dklPicture = numpy.reshape(numpy.transpose(dkl), origShape)
 return dklPicture

def rgb2dklCart ( picture , conversionMatrix = None ) : picture = numpy . array ( picture ) origShape = picture . shape if ( conversionMatrix is None ) : conversionMatrix = numpy . asarray ( [ [ 0.25145542 , 0.64933633 , 0.09920825 ] , [ 0.78737943 , ( - 0.55586618 ) , ( - 0.23151325 ) ] , [ 0.26562825 , 0.63933074 , ( - 0.90495899 ) ] ] ) logging . warning ( 'This monitor has not been color-calibrated. Using default DKL conversion matrix.' ) else : conversionMatrix = numpy . linalg . inv ( conversionMatrix ) red = picture [ : , : , 0 ] green = picture [ : , : , 1 ] blue = picture [ : , : , 2 ] dkl = numpy . asarray ( [ red . reshape ( [ ( - 1 ) ] ) , green . reshape ( [ ( - 1 ) ] ) , blue . reshape ( [ ( - 1 ) ] ) ] ) dkl = numpy . dot ( conversionMatrix , dkl ) dklPicture = numpy . reshape ( numpy . transpose ( dkl ) , origShape ) return dklPicture
convert an rgb image into cartesian dkl space .