klauspost / rawspeed

Raw Image Decoder Library
GNU Lesser General Public License v2.1
72 stars 20 forks source link

Add thumbnail and whitebalance extraction #42

Open pedrocr opened 10 years ago

pedrocr commented 10 years ago

For rawspeed to be able to completely replace libraw in apps at least two things seem to be needed:

Comments?

LibRaw commented 10 years ago

Also, you need color data extraction from files which provides color data (DNG, digital backs, several other formats).

BTW, LibRaw may use RawSpeed as (faster) decoder for about two years. We use this way to use RawSpeed in our apps (RawDigger, FastRawViewer) without problems (although, sometimes RawSpeed's output differs from LibRaw's, in this case I file a bug to Klaus).

pedrocr commented 10 years ago

you need color data extraction from files which provides color data

Isn't that already done? At least darktable doesn't seem to use libraw to get that.

LibRaw commented 10 years ago

As I can see, darktable uses own built-in color data (src/external/adobe_coeff.c) copypasted from dcraw

pedrocr commented 10 years ago

That's one source, originally from dcraw now generated from the Adobe DNG converter directly. It also has custom colors for some cameras.

Do you mean that besides fixed values for some formats you also need to extract them from the file itself? And that rawspeed isn't doing that already?

LibRaw commented 10 years ago

yes, for some cameras it is better to extract it from file. I do not see some generic interface for it in RawSpeed.

LibRaw commented 10 years ago

BTW, you say 'generated from the Adobe DNG converter directly'. Is there any script or something? I'm interested to extract Adobe's BaselineExposure values for all cameras....

pedrocr commented 10 years ago

https://github.com/darktable-org/darktable/blob/master/tools/dngmeta.sh

I'm afraid that probably doesn't do what you want. It extracts the values from a .DNG file but you'd probably want to extract them from the app data itself.

LibRaw commented 10 years ago

Thanks, but this script extracts data from DNG file, not from DNG convertor. I use Exiftool, not exiv2 for it, but it is nearly the same.

The problem is there is no enough samples to extract BaselineExposure from, because this parameter may vary with ISO change (and, worse, with other camera settings, such as 'highlight preservation')

pedrocr commented 10 years ago

After looking at this in more detail my plan would be to extend rawspeed to extract both whitebalance and color data but not thumbnails. For thumbnails something like exiv2 should work instead. For the color data my plan would be to take the matrices currently in darktable's adobe_coeff and migrate them to rawspeed's cameras.xml. That way we would have a complete sensor definition with black/white points and color matrix all in one place.

Klaus, does this make sense to you, or would you rather keep this info out of cameras.xml?

klauspost commented 10 years ago

I think all color convertion should be separate.

I have however thought about adding the "UniqueCameraModelRestriction" camera name from Adobes DCP to cameras.xml - that way it would be trivial to match a DCP profile with data from RawSpeed. I think these could be added automatically with a little coding efford.

If time had been more on my side, I have thought about making a simple, but separate converter frontend for RawSpeed, that used (Adobe) DCP profiles for conversion. These contain, at very least the same matrix as D.C. has extracted and included. However, there can be two matrices with different illuminants, and based on the whitebalance an intermediate can be calculated.

Here you can see the "simple" profiles, which only contain matrices:

http://rawstudio.org/svn/rawstudio/trunk/profiles/simple-src/

These xml files are "compiled" into DCP files (using a tool called dcptool), which are basically slightly modified DNG/TIFF files that only contain profile information:

http://rawstudio.org/svn/rawstudio/trunk/profiles/

More advanced profiles can contain 3d HSV-lookup tables to correct color casts and imperfections in the matrix.

LibRaw commented 10 years ago

Color conversion, surely, should be separate. But raw decoding library should unpack color data from raw files (it these raw data contains color data) and pass it to calling application. This is very useful for a) generic DNG support (from unknown camera) b) generic format support (from new camera from known manufacturer; for example, Sony or Olympus raws contains matrix color profile) c) cameras with per-camera calibration (digital backs)