Incorrect color(whitespace) converting RAW images through LibRaw

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Locked
qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

Hey, I am converting some dng images to jpgs, and noticed the color of jpgs are not correct. I'm using the newest version and delegating to LibRaw.
I'm able to get the correct color by using dcraw -W option, which reads the camera whitespace. LibRaw is based on dcraw, and it seems also has a similar option named "use_camera_wb". Is this parameter disabled by default in ImageMagick? Is there any way I can enable it? Or are there some other options? Thanks

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by snibgo »

qliu wrote:I'm able to get the correct color by using dcraw -W option, which reads the camera whitespace.
I think you mean "-w" (lowercase). Uppercase "-W" disables auto-brighten.

No, IM doesn't enable camera white balance with LibRaw. This is a pain.

There are many options that you might want when processing raw images, that IM doesn't allow. Personally, I always process raw images externally, eg with dcraw to create a TIFF, then process that with ImageMagick.
snibgo's IM pages: im.snibgo.com

qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

Thanks snibgo! I'll just file a ticket to imageMagick, it would be nice to add this option

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by snibgo »

Feel free to file any tickets you want. Personally, I think IM should default to using the camera white balance. However, also remember that IM is a general-purpose system. Sometimes we need more specialist programs, and we can't add zillions of options to IM.

If you want, you can add entries to your delegates.xml. For example, I have:

Code: Select all

  <delegate decode="linrawv" command="dcraw.exe -v -4 -w -o 0 -T -O &quot;%o&quot; &quot;%i&quot;"/>
Then I can run:

Code: Select all

magick linrawv:AGA_3443.NEF -auto-level -set colorspace RGB -colorspace sRGB out.tiff
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by magick »

Set -define dng:use-camera-wb=true to use the RAW-embedded color profile for Sony cameras. This option requires ImageMagick release 7.0.9-6 or 6.9.10-75. We can add defines for other dcraw options as well. Just let us know which ones you would find useful.

qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

magick wrote:
2019-11-26T05:05:19-07:00
Set -define dng:use-camera-wb=true to use the RAW-embedded color profile for Sony cameras. This option requires ImageMagick release 7.0.9-6 or 6.9.10-75. We can add defines for other dcraw options as well. Just let us know which ones you would find useful.
This option didn't work for me. I'm using this version:
Version: ImageMagick 7.0.9-14 Q16 x86_64 2020-02-06 https://imagemagick.org

I tried these commands on my linux machine:
convert test.dng out2.jpg
convert test.dng -define dng:use-camera-wb=true out1.jpg

However, the out jpgs look the same. The color is different with the original dng image.
Here are the links to the output jpg and original dng:
https://drive.google.com/file/d/1RIAPYU ... sp=sharing
https://drive.google.com/file/d/1iEThhL ... sp=sharing

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by fmw42 »

For IM 7, use magick, not convert.

qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

fmw42 wrote:
2020-04-29T18:15:34-07:00
For IM 7, use magick, not convert.
I just verified that magick gives the same output.
Is there any difference of using magick and convert?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by fmw42 »

Yes, when using IM 7 using convert will invoke IM 6 behavior, which has difference from IM 7

qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

fmw42 wrote:
2020-04-29T19:28:32-07:00
Yes, when using IM 7 using convert will invoke IM 6 behavior, which has difference from IM 7
Thanks for pointing that out. Is this documented somewhere? Are the command-line options and usages remain the same for magick? What are the major differences between convert and magick?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by fmw42 »

There are minor differences. See https://imagemagick.org/script/porting.php#cli

qliu
Posts: 6
Joined: 2019-11-25T17:09:37-07:00
Authentication code: 1152

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by qliu »

Do we support -define dng:use-camera-wb=true as a command-line option? I'm using 7.0.9-14 version. I tried but the color is still not correct.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by fmw42 »


User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Incorrect color(whitespace) converting RAW images through LibRaw

Post by dlemstra »

Its use_camera_wb not use-camera-wb.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Locked