交换Jpeg RGB通道(RGB-> BGR)

时间:2022-10-25 21:15:48

I have a Jpeg RGB single-scan clip (with Adobe App14 marker, and R, G, B components all interleaved in the same scan). I am wondering if there is way to edit the Jpeg clip header (or append other headers like EXIF) so that decoders can interpret the R channel as B and vice versa without changing the rest of the bitstream?

我有一个Jpeg RGB单扫描剪辑(使用Adobe App14标记,并且R,G,B组件都在同一扫描中交错)。我想知道是否有办法编辑Jpeg剪辑标题(或附加其他标题,如EXIF),以便解码器可以将R通道解释为B,反之亦然,而不更改其余的比特流?

I had tried swapping the ordering of "Scan component selectors" in the scan header, and the decoder (Windows Photo Viewer in this case) successfully displayed Red as Blue and Blue as Red afterwards. However, the ITU-T.81 Jpeg specification specifically said that "Csj:Scan component selector: Each Csj shall match one of the Ci values specified in the frame header, and the ordering in the scan header shall follow the ordering in the frame header." So I guess changing the Scan component selector ordering is not a valid option unless there is any updated specification saying that this is no longer the restriction.

我曾尝试在扫描头中交换“扫描组件选择器”的顺序,然后解码器(在这种情况下为Windows照片查看器)成功显示红色为蓝色,蓝色为红色。但是,ITU-T.81 Jpeg规范明确指出“Csj:扫描组件选择器:每个Csj必须匹配帧头中指定的Ci值之一,并且扫描头中的排序应遵循帧头中的排序“。所以我想改变扫描组件选择器顺序不是一个有效的选项,除非有任何更新的规范说这不再是限制。

Does anyone know other ways to swap the RGB channels by either appending some sort of app data or modifying Jpeg frame or scan headers without touching the scan data at all?

有没有人知道通过附加某种应用数据或修改Jpeg帧或扫描头而不触及扫描数据来交换RGB通道的其他方法?

Thank you for your inputs.

感谢您的投入。

1 个解决方案

#1


If you have the image in raw format you can modify the exif CFA using exiftool. The array may vary depending on the sensor and format. For swapping dng files, you can use the following

如果你有原始格式的图像,你可以使用exiftool修改exif CFA。阵列可能因传感器和格式而异。对于交换dng文件,您可以使用以下内容

exiftool.exe -subifd:cfapattern2="2 1 1 0" file.dng

Where

0 = Red,
1 = Green,
2 = Blue,

If your desperate you could always consider converting your Jpg to Raw and then back again

如果你绝望,你可以考虑将你的Jpg转换为Raw然后再回来

#1


If you have the image in raw format you can modify the exif CFA using exiftool. The array may vary depending on the sensor and format. For swapping dng files, you can use the following

如果你有原始格式的图像,你可以使用exiftool修改exif CFA。阵列可能因传感器和格式而异。对于交换dng文件,您可以使用以下内容

exiftool.exe -subifd:cfapattern2="2 1 1 0" file.dng

Where

0 = Red,
1 = Green,
2 = Blue,

If your desperate you could always consider converting your Jpg to Raw and then back again

如果你绝望,你可以考虑将你的Jpg转换为Raw然后再回来