Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heic image decode color incorrect #1189

Open
lam2003 opened this issue Jun 14, 2024 · 11 comments
Open

heic image decode color incorrect #1189

lam2003 opened this issue Jun 14, 2024 · 11 comments

Comments

@lam2003
Copy link

lam2003 commented Jun 14, 2024

Hi, I use heif_convert command(from libheif example) to convert below heif image to jpg/png. The output image color incorrect which seems too green

1040g008313u8g0qp1m4g5nkalku094d2qla98k0 2.heic.zip

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

output image:
1.jpg.zip

@farindk
Copy link
Contributor

farindk commented Jun 14, 2024

I had a look at the file structure. It seems that there is no color-space information in that file (no nclx, no ICC). Also the file structure is different than what I have seen before. The EXIF data says that it was captured by a Xiaomi camera. Is that correct, or was it post-processed in some other software?

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

The original image can play on MacOS(Version 13.4.1) correctly.
I use mediainfo to parse file structure and found something difference.

1

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

Is there something wrong on the color conversion?

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

I have confirm the rgb matrix take from decoder already has color incorrection

@farindk
Copy link
Contributor

farindk commented Jun 14, 2024

It's strange that your tool says RGB colorspace, but Chroma 4:2:0.
I'll need to have a closer look into the h265 stream.

@kmilos
Copy link
Contributor

kmilos commented Jun 14, 2024

It's strange that your tool says RGB colorspace, but Chroma 4:2:0.

... and matrix coeffs identity? exiftool indeed does not see any nclx or ICC either, but only chroma 4:2:0 as well - no matrix coeffs, no transfer curve...

The white comes out as (128, 255, 128) in RGB, which looks to me like some (U, Y, V) values?

FWIW, Windows 11 photo app shows it correctly as well.

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

Attach file is h265 stream

320540aab5d8da77982dc2e9cfb88d01.mov

1040g008313u8g0qp1m4g5nkalku094d2qla98k0.h265.zip

@lam2003
Copy link
Author

lam2003 commented Jun 14, 2024

It's strange that your tool says RGB colorspace, but Chroma 4:2:0.

... and matrix coeffs identity? exiftool indeed does not see any nclx or ICC either, but only chroma 4:2:0 as well - no matrix coeffs, no transfer curve...

The white comes out as (128, 255, 128) in RGB, which looks to me like some (U, Y, V) values?

FWIW, Windows 11 photo app shows it correctly as well.

The matrix coeffs value is 0;
image

@silverbacknet
Copy link

My assumption is that these other libraries have sanity checks to change RGB 4:2:0 to Unspecified (and just treat that as 709), because shoddy developers assuming 0 is default or just not caring is definitely A Thing. This isn't an illegal configuration, if someone decided to subsample red & blue, it's just a weird and slightly crazy one.

I haven't checked whether flipping that bit to 1 will fix it, I can try when I get home tonight, but I suspect it will.

@lam2003
Copy link
Author

lam2003 commented Jun 15, 2024

My assumption is that these other libraries have sanity checks to change RGB 4:2:0 to Unspecified (and just treat that as 709), because shoddy developers assuming 0 is default or just not caring is definitely A Thing. This isn't an illegal configuration, if someone decided to subsample red & blue, it's just a weird and slightly crazy one.

I haven't checked whether flipping that bit to 1 will fix it, I can try when I get home tonight, but I suspect it will.

image

I set matrix_coefficients to heif_matrix_coefficients_unspecified and output image can show correctly. Thank you!

2.png.zip

@lam2003 lam2003 closed this as completed Jun 18, 2024
@farindk farindk reopened this Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants