Combine EXR images

1.2k views Asked by At

I encountered some issues to combine EXR. With PNG or anything else, no problem (with ImageMagick).

I have 4 images at same size, which should be combined to get a bigger image. Each image represents a part of the bigger image (top left, top right, bottom left and bottom right). Each image contains N layers with information (colors, depth, etc). Theses layers must be combined in the final image.

Each image has this signature :

$ identify imput_tile_0001.exr
imput_tile_0001.exr EXR 400x225 400x225+0+0 16-bit DirectClass 2.501MB 0.000u 0:00.000

I try ImageMagick simple commands like

$ convert +append *.exr out.exr
$ montage *.exr -tile 2x2 -geometry +0+0 out.exr

Theses commands returns a totally black image, with the correct size, and with only 1 layer.

I am open to any solution with any language or any software, working on Debian.

Edit : The 4 EXR tiles can be found here : https://www.dropbox.com/sh/p6h8kh5wlroy5bb/AACMuR8WieZ-SqB3qXHFwk_ea?dl=0 (These are the "imput_tile...exr").

Any idea?

1

There are 1 answers

4
Mark Setchell On

I am no expert on (ok, I have never even seen any) EXR format images but I know that vips is able to process them. I can't even tell what your images look like but I think/hope this might be doing what you want.

First, I inspect your images and see they are 4 bands of 400x225 pixels like this

vips im_printdesc input_tile_0000.exr
400x225 float, 4 bands, srgb, setbuf VipsImage (0x7fda0984f000) count=1 9600 bytes
width: 400
height: 225
bands: 4
format: 6 - float
coding: 0 - none
interpretation: 22 - srgb
xoffset: 0
yoffset: 0
xres: 1.000000
yres: 1.000000
filename: "input_tile_0000.exr"

Then I do a left-right join to get the top row of your desired result:

vips im_lrjoin *0.exr *1.exr top.v

Then I do another left-right join to get the bottom row of your desired result:

vips im_lrjoin *2.exr *3.exr bot.v

Then I do a top-bottom join to join the top and bottom to get the final result:

vips im_tbjoin top.v bot.v result.v

And if I look at it, it appears to have the correct dimensions and the same number of bands and coding as your originals:

vips im_printdesc result.v
800x450 float, 4 bands, srgb, openin VipsImage (0x7f975b84d010) count=1
width: 800
height: 450
bands: 4
format: 6 - float
coding: 0 - none
interpretation: 22 - srgb
xoffset: 0
yoffset: 0
xres: 1.000000
yres: 1.000000
filename: "result.v"

Notes

  1. The xyz.v format is vips's internal, efficient image format

  2. vips is available with bindings to many languages - see the vips website here.

  3. It may be able to cache the intermediate files I create (top.v and bot.v), but I have no idea how

  4. The vips maintainer is on SO as @user894763 and he may be able to throw more light on my musings - hopefully!