I am doing a LAB to RGB conversion.
If my LAB matrix is float64, the bounds for the axes must be -100, 100. Upon analysis of the output RGB image, the results look correct.
However, if the LAB matrix is float32 the bounds are checked and forced to -1 1 which yields an RGB image that is incorrect.
Upon further inspect, the problem looks like it comes from the convert function in dtype.py.
image = np.asarray(image)
dtypeobj = np.dtype(dtype)
dtypeobj_in = image.dtype
dtype = dtypeobj.type
dtype_in = dtypeobj_in.type
if dtype_in == dtype:
if force_copy:
image = image.copy()
return image
at the "if dtype_in == dtype:" the types are float32 and float64 causing the if to be skipped. Eventually the code reaches the point:
if kind_in == 'f':
if np.min(image) < -1.0 or np.max(image) > 1.0:
raise ValueError("Images of type float must be between -1 and 1.")
if kind == 'f':
# floating point -> floating point
if itemsize_in > itemsize:
prec_loss()
return dtype(image)
and the bounds are checked, outside of [-1 1] and an error is thrown.
Isaac