# Negative value in XYZ space by using inverse adobe-coeff

Thanks for reading this post.

I am working on converting camera-RGB to sRGB space. What I did is to first multiply the inverse of the adobe-coeff matrix with camera-RGB image (normalized to : [0,1]) (convert from camera-rgb to XYZ), then convert it to sRGB space. However, what I found is that the XYZ space has negative values. And after conversion, the minimum value of sRGB space can be lower than 0, and the maximum value can be higher than 1.

My script:

raw_rgb = np.float32(raw_rgb/255)

# using Sony A7R3

color_matrix = np.array([[ 6640, -1847, -503],

[-5238, 13010, 2474],

[ -993, 1673, 6527]])

color_matrix = color_matrix/10000

# Reshape the image data for matrix multiplication

pixels = raw_rgb.reshape(-1, 3)

# Apply the color transformation matrix

xyz_pixels = np.dot(pixels, np.linalg.inv(color_matrix).T)

xyz_pixels = xyz_pixels.reshape(raw_rgb.shape)

print(np.min(xyz_pixels[:,:,0]),np.max(xyz_pixels[:,:,0]))

print(np.min(xyz_pixels[:,:,1]),np.max(xyz_pixels[:,:1]))

print(np.min(xyz_pixels[:,:,2]),np.max(xyz_pixels[:,:,2]))

# converting to srgb space

srgb_pixels = xyz_to_rgb(xyz_pixels)

srgb_pixels[:, [0, 1]] = rgb_pixels[:, [0, 1]]

print(np.min(rgb_pixels),np.max(rgb_pixels))

--------------output (a sample from Sony A7R3)-------------------

0.16259616344985683 1.9754706878475143

-0.0276043322748736 0.4712576608113939

-0.1171506515602409 1.7001050929819055

-0.9080825167745925 4.433969834566348

I am new to this forum and color topic. Really appreciate it if anyone can provide me any clue.

## Recent comments

3 weeks 5 daysago3 weeks 5 daysago1 month 1 weekago1 month 1 weekago1 month 1 weekago