Odd behavior when compositing OpenEXR

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nate101
Posts: 9
Joined: 2017-05-24T04:29:54-07:00
Authentication code: 1151

Odd behavior when compositing OpenEXR

Post by nate101 »

Hi All,

Apologies in advance if this is a noobish question. I'm using IM 7.0.5-Q16-HDRI for Windows for whatever it's worth. I'm trying to composite two EXR files using the linear dodge method but so far have been unable to replicate the output I get from Photoshop. I've added links to the following items for reference:
  • A. "Shading" base layer EXR LINK
  • B. "Reflection" layer EXR (to be layered on top w/ linear dodge) LINK
  • C. "Composite Reference" EXR (how A + B should look when properly composited) LINK
  • D. Photoshop file for reference showing proper compositing behavior (Shading + Reflection = Composite Reference) LINK
I've tried to composite A and B in IM using the following command:

Code: Select all

magick Sphere-Shading.exr Sphere-Reflection.exr -compose linear-dodge -composite Sphere-IMComposite.exr
You'll see if you compare the IM output from this command with item C above (the reference exr) that there are noticeable differences around the edge of the sphere and also in the sphere's specular highlight. I've tried a bunch of things but still haven't been able to figure out what I'm doing wrong. Not sure if its a syntax issue or some setting in IM I'm missing.

Appreciate any help anyone can give.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Odd behavior when compositing OpenEXR

Post by fmw42 »

This command works fine for me in IM 7.0.7.11 Q16 HDRI Mac OSX. I get the same result as your reference EXR image.

Code: Select all

magick Sphere-Shading.exr Sphere-Reflection.exr -compose linear-dodge -composite Sphere-IMComposite.exr
But if I save to PNG, I get a darker green. PNG does not keep the wide range of color values as EXR does. EXR can have values outside the 16-bit range that only get saved properly using a format that allows such values in HDRI, such as EXR, HDRI, PFM and MPC (and TIFF with the right define).
nate101
Posts: 9
Joined: 2017-05-24T04:29:54-07:00
Authentication code: 1151

Re: Odd behavior when compositing OpenEXR

Post by nate101 »

Thanks Fred maybe just a boneheaded mistake on my part. Will retest and see if I can duplicate.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Odd behavior when compositing OpenEXR

Post by fmw42 »

It is possible EXR was fixed after IM 7.0.5. So if it fails for you, try upgrading IM.

I checked 7.0.5.4 and still get the correct result.

P.S. I am viewing using Mac Preview and all seems fine colorwise. There is a slight difference in the antialiasing at the border of the sphere and background, which may be the cause of the 7% difference I get when doing

Code: Select all

magick compare -metric rmse Sphere-CompositeReference.exr Sphere-IMComposite_im705.exr null:
4682.02 (0.071443)

I also see slight color difference between your reference exr and the one from Photoshop.
nate101
Posts: 9
Joined: 2017-05-24T04:29:54-07:00
Authentication code: 1151

Re: Odd behavior when compositing OpenEXR

Post by nate101 »

Yes the anti-aliasing around the edge of the sphere was one of the things bugging me. PS doesn't seem to have this antialiasing issue from what I could tell. Even more concerning, I was seeing a difference in the white highlight on the sphere (not sure if you saw that too), which made me wonder if the brightness values in those pixels were being clamped somewhere along the line.

Going to upgrade to 7.0.7 and retest and will let you know if I notice any difference.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Odd behavior when compositing OpenEXR

Post by fmw42 »

I see little color change if at all between my IM version and your Reference. There is an antialiasing difference. But I see more color change between the PS versions and your Reference, but less aliasing difference.

There is no difference between my using IM 7.0.5.4 and 7.0.7.11.

Code: Select all

magick compare -metric rmse Sphere-IMComposite_im705.exr Sphere-IMComposite_im70711.exr null:
0 (0)
Post Reply