[RESOLVED] Applying Lut difference between photoshop and imagemagick

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
g3nd0
Posts: 5
Joined: 2018-06-28T10:33:43-07:00
Authentication code: 1152

[RESOLVED] Applying Lut difference between photoshop and imagemagick

Post by g3nd0 »

Version: ImageMagick 7.0.8-2. Tested on both osx and linux.

I recently upgraded from Imagemagick 6.7 to 7.0 and am noticing a change when applying a hald file within photoshop and one with imagemagick.

Imagemagick command I am using: magick -verbose sphere_render.exr hald_CC.exr -channel RGB -hald-clut -depth 32 sphere_render_hald.png.

https://imgur.com/gallery/E6TtYaP The link includes render outputs to illustrate the issue. Best way I can describe it is the hot white parts seems to be blown out to blue.

The hald file I am using has been generated from version 7.0.8 and then the .cube file applied. I have tried changing the depth variable as well as removing it and the channel variable. Tried staying with all pngs, all exrs, still get the blown out blue result.

If anyone has come across this and knows of a fix I would really appreciate it. Hoping I can keep using imagemagick and not have to find another solution for mass image editing.
Thanks!
Last edited by g3nd0 on 2018-07-03T16:39:59-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Applying Lut difference between photoshop and imagemagick

Post by snibgo »

You don't seem to have a link to the hald-clut file "hald_CC.exr".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

Since you did not provide your HALD image, it is hard to say. We need your actually input image, HALD image and the output from Imagemagick and Photoshop. But I would point out that your HALD image must have dimension large enough to span all the colors in your image. EXR image can have a large depth and thus lots of colors. The HALD size must be compatible. Perhaps you understand that and have made an appropriate HALD image. I just wanted to be sure you took care of that.
g3nd0
Posts: 5
Joined: 2018-06-28T10:33:43-07:00
Authentication code: 1152

Re: Applying Lut difference between photoshop and imagemagick

Post by g3nd0 »

Does the Hald file have to be the exact size of the image it is being applied to? The hald file I have is 4096x4096, and my original image is smaller in both dimensions. https://imgur.com/gallery/Lh28lbi Hald file is here, however converted to png for hosting. Unless someone knows how to host exrs free somewhere to include a link?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

Zip the EXR HALD image and then post to some free hosting service and put the URL here.

The size of the HALD image must be large enough to cover the color depth of the image to which it needs to be applied. See http://www.imagemagick.org/Usage/color_mods/#hald-clut. A 4096x4096 HALD image, HALD:16, only covers 8-bit color depth , i.e. 16^2=256 colors. If your EXR image is larger than 8-bit depth (>256 colors) you will need a much larger HALD image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

CORRECTION. The number of colors for 4096x4096 HALD image is 256*256*256 = 16,777,216 colors. That is the equivalent of 24-bit color. If your EXR file is 48-bit color or even larger, then you will need a larger HALD image dimension.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Applying Lut difference between photoshop and imagemagick

Post by snibgo »

If 4096*4096 is too small, I would expect as that to show as a minor problem, not the severe problems shown here.

The uploaded hald file seems available only as a JPG, which makes it larger than a PNG.

It is very different to a "hald:16" image, especially in the red channel. You will see that your q3nd00 link has the IM conversion as cyan instead of almost white, ie the green and blue channels are ok there, but the red channel is wrong.
q3nd0 wrote:The hald file I am using has been generated from version 7.0.8 and then the .cube file applied.
I suspect that process has gone wrong. How did you do this?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

Why did you save your HALD image as EXR. If you only need 24-bit color, then any non-compressed format such as PNG would do.

There is always the possibility that IM 7 has a bug vs IM 6. Have you tried comparing the results of the -hald-clut in both IM 6 and IM 7? Have you tried creating the HALD image from both IM 6 and IM 7 to make sure the created HALD image is the same?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

Doing a quick test using both IM 7 and IM 6, I find that the HALD images are identical and application of the -hald-clut produces the same results. So you have some other issue. I used IM 6.9.10.2 Q16 and IM 7.0.8.2 Q16 HDRI.
g3nd0
Posts: 5
Joined: 2018-06-28T10:33:43-07:00
Authentication code: 1152

Re: Applying Lut difference between photoshop and imagemagick

Post by g3nd0 »

@ snibgo The cube file was applied outside of imagemagick with nuke.

@ fmw42 The hald is an exr because we saw a difference when it was a png vs exr, and liked the result from exr more. I also have generated a hald file from IM6 and IM7 and get the same issue when applying the convert command in IM7.

Upon further investigation it looks like the blue highlight effect is only in the pixels that have a value higher than 1. Does anyone here know to account for that? Is there a clamp function on luts?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

IM 7 is HDRI enabled by default. I assume that you are using that. If the hald-clut result is being clamped, that is conceivable. I do not know if that command was created expecting colors out of range 0 to quantum range. EXR does support out of this range values. But the hald-clut may not. This should be a question for the developers as a potential improvement.

Are you comparing results using the same HALD clut between Imagemagick and Nuke? Or does Nuke use a different 3D LUT?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Applying Lut difference between photoshop and imagemagick

Post by snibgo »

Code: Select all

Is there a clamp function on luts?
No. If you want to clamp, use "-clamp".
snibgo's IM pages: im.snibgo.com
g3nd0
Posts: 5
Joined: 2018-06-28T10:33:43-07:00
Authentication code: 1152

Re: Applying Lut difference between photoshop and imagemagick

Post by g3nd0 »

@ fmw42 Thank you so much for mentioning IM7 has HDRI on by default. I rebuilt the install disabling that and got the correct render!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Applying Lut difference between photoshop and imagemagick

Post by fmw42 »

Why did you disable HDRI? I thought your EXR file might have values outside the normal range and you would need HDRI enabled. If you really want values clamped, then you can still use HDRI but add -clamp to your command as snigbo has said.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Applying Lut difference between photoshop and imagemagick

Post by snibgo »

Remember that "-hald-clut" involves two input images and an output. So there are three possible places where "-clamp" could be applied, for three different effects. I suppose as a general rule we would want to clamp the main input image, and we might assume the hald itself is already clamped, so the output doesn't then need clamping.
snibgo's IM pages: im.snibgo.com
Post Reply