从 Java 读取 RAW 图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1222324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:41:48  来源:igfitidea点击:

Reading RAW images from Java

javaimage-processing

提问by Marcin

Canon/Nikon/other cameras save raw output of their sensor in some of their proprietary formats (.CR2, whatever). Is there any Java library designed to read them and convert into manageable BufferedImages?

佳能/尼康/其他相机以某些专有格式(.CR2 等)保存传感器的原始输出。是否有任何 Java 库旨在读取它们并将其转换为可管理的 BufferedImages?

I don't reqlly care here about fully customizable conversion similar to ufraw or imagemagick, rather something simple that "just works" for rendering simple previews of such images.

我在这里并不关心类似于 ufraw 或 imagemagick 的完全可定制的转换,而是一些简单的“只适用于”渲染此类图像的简单预览的东西。

采纳答案by BobMcGee

I've been where you are, and I feel for you. Your best bet is to use an Adobe or dcraw-based program to create thumbnails automatically. Temporary DNG files using Adobe's converter may be easier to use.

我去过你所在的地方,我对你有感觉。最好的办法是使用 Adob​​e 或基于 dcraw 的程序自动创建缩略图。使用 Adob​​e 转换器的临时 DNG 文件可能更易于使用。

IF you insist on doing it in Java, you're about to run into a mountain of pain.RAW formats change often, have all sorts of crazy nuances and are intentionally hard to work with. Camera makers want you to use THEIR RAW conversion software, to show the camera's abilities at its best and screw Adobe. The guy behind dcraw found that some are camera manufacturers even use encryption now!

如果您坚持使用 Java 来做这件事,那么您将陷入巨大的痛苦之中。RAW 格式经常变化,有各种疯狂的细微差别,并且故意难以使用。相机制造商希望您使用他们的 RAW 转换软件,以最好地展示相机的功能并拧紧 Adob​​e。dcraw背后的家伙发现有些相机制造商现在甚至使用加密!

The existing Java libraries are poor -- JRawIO has improved since I last looked at it, but it supports only a fraction of the formats that dcraw does. In addition to the listed libraries, the imagerolibrary mayprovide the ability to display a thumbnail for your image.

现有的 Java 库很差——自从我上次查看 JRawIO 以来,它有所改进,但它只支持 dcraw 支持的一小部分格式。除了列出的库之外,imagero还可以提供显示图像缩略图的功能。

From personal experience, don't even think about writing your own RAW file reader.I tried to do this with a very simple RAW format once (just a solid array of sensor data, 12 bits per pixel). The dcraw source translates badly to Java. You haven't seen such a nightmare of bit-fiddling ever. Took me days to debug problems with byte alignment and endian-ness.

根据个人经验,甚至不要考虑编写自己的 RAW 文件阅读器。我曾尝试使用一种非常简单的 RAW 格式(只是一个固定的传感器数据阵列,每像素 12 位)来做到这一点。dcraw 源代码很难转换为 Java。你从来没有见过这样的摆弄的噩梦。我花了几天时间调试字节对齐和字节序问题。

回答by D. Wroblewski

jrawiois a plugin for Java Image I/O. With it you can read the raster data, the thumbnails and the metadata from the raw image file.

jrawio是 Java Image I/O 的插件。有了它,您可以从原始图像文件中读取光栅数据、缩略图和元数据。

回答by D. Wroblewski

nef and cr2 already contains preview images in jpeg. just find the right offset and the right length to extract it... Laurent Clevy @ lclevy.free.fr/raw

nef 和 cr2 已经包含 jpeg 格式的预览图像。只需找到正确的偏移量和正确的长度来提取它...... Laurent Clevy @ lclevy.free.fr/raw

Laurent

洛朗

回答by basszero

Unless you want to write you own file parser/loader(sounds fun imho ;) ), perhaps JMagickwill help you. I haven't tried it and it might not work given your target platform since JMagick uses JNI.

除非你想编写你自己的文件解析器/加载器(听起来很有趣,恕我直言;)),也许JMagick会帮助你。我还没有尝试过,鉴于 JMagick 使用 JNI,它可能无法在您的目标平台上工作。

UPDATE: dcrawlooks like a good resource/reference

更新:dcraw看起来是一个很好的资源/参考