I'm trying to do this code just with NumPy
I have used skimage but it is not perfect like tfio rgb_to_xyz
so
def rgb_to_xyz(input, name=None):
"""
Convert a RGB image to CIE XYZ.
Args:
input: A 3-D (`[H, W, 3]`) or 4-D (`[N, H, W, 3]`) Tensor.
name: A name for the operation (optional).
Returns:
A 3-D (`[H, W, 3]`) or 4-D (`[N, H, W, 3]`) Tensor.
"""
input = tf.convert_to_tensor(input)
assert input.dtype in (tf.float16, tf.float32, tf.float64)
kernel = tf.constant(
[
[0.412453, 0.357580, 0.180423],
[0.212671, 0.715160, 0.072169],
[0.019334, 0.119193, 0.950227],
],
input.dtype,
)
value = tf.where(
tf.math.greater(input, 0.04045),
tf.math.pow((input + 0.055) / 1.055, 2.4),
input / 12.92,
)
return tf.tensordot(value, tf.transpose(kernel), axes=((-1,), (0,)))