Re: [Gdcm2] YBR_PARTIAL_422 and JPEG Baseline support
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mihail I. <mih...@go...> - 2022-01-13 04:10:11
|
OK, i think i know now. The artifact on the right image was my mistake, there was a bug in my test, sorry. But the above post is correct, in fact, according to standard, the conversion is little different, but the difference is hardly visible, not sure it make sense to spend time with it. I have derived with the help of Matlab function (uses correct coefficients from the DICOM standard) in previous post and octave (for 8 bits): YBR_PARTIAL_422 to RGB: R = 1.164415463*(Y-16) + (-0.000095036)*(Cb-128) + 1.596001878*(Cr-128) G = 1.164415463*(Y-16) + (-0.391724564)*(Cb-128) + (-0.813013368)*(Cr-128) B = 1.164415463*(Y-16) + 2.017290682*(Cb-128) + (-0.000135273)*(Cr-128) YBR_FULL, YBR_FULL_422 to RGB: R = Y + (-0.000036820)*(Cb-128) + 1.401987577*(Cr-128) G = Y + (-0.344113281)*(Cb-128) + (-0.714103821)*(Cr-128) B = Y + 1.771978117*(Cb-128) + (-0.000134583)*(Cr-128) The last equation is very very close to YBR2RGB in GDCM (0.000.. multiplication can be skipped). const int halffullscale = 1 << (storedbits - 1); const int R = Round(Y + 1.402 * (Cr-halffullscale)); const int G = Round(Y - (0.114 * 1.772 * (Cb-halffullscale) + 0.299 * 1.402 * (Cr-halffullscale))/0.587); const int B = Round(Y + 1.772 * (Cb-halffullscale)); Sorry for noise and thank you again! Kind regards, Mikhail |