Page 1 of 1
Montage not maintaining 16 bit depth
Posted: 2015-11-16T17:16:13-07:00
by digitalis99
I'm a 3D animator that creates large still image renders using a tile rendering process. The tiles created by my application are 16bits per channel EXR's. I'm trying to use montage to stitch the tiles together into the final image. For some reason, the bit depth seems to be down-converting to 8bits per channel, no matter what options I feed to montage. I'm using montage from ImageMagick-6.9.2-Q16-HDRI. An example of the command I feed to montage is:
montage.exe cropped_spherical-lighting-test1.*000001.exr -geometry "100x200+0+0<" -tile 20x5 output.exr
I've put together a .zip of the correct output, a set of tiles, and an incorrect output as generated by montage. You may download it here:
http://www.mastermindpro.com/montage_problem.zip
If you open both of the output EXR's in Photoshop and drop the exposure to -5, you'll see the correct output has dynamic range whereas the output from montage...doesn't.
I should note that I have to do an additional step (convert.exe) to crop the output tiles prior to using montage to stitch them together. I think convert is maintaining the bit depth detail correctly (which you can see from examining the cropped tiles), so I'm focusing my troubleshooting on montage. Let me know if that is mistaken.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-16T18:00:25-07:00
by fmw42
It might be a restriction of exr output and/or using Windows or your version of OpenEXR? Does the following work for you?
The following works fine for me under IM 6.9.2.6 Q16 Mac OSX. I get a 16-bit output.
Code: Select all
montage cropped_spherical-lighting-test1.+AA+000001.exr cropped_spherical-lighting-test1.+AA+000001.exr cropped_spherical-lighting-test1.+AA+000001.exr -geometry "100x200+0+0<" -tile 3x1 tmp.png
identify -verbose tmp.png
Image: tmp.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 300x200+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 16-bit
Channel depth:
red: 15-bit
green: 15-bit
blue: 16-bit
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-16T19:05:43-07:00
by digitalis99
I should clarify, the output image from montage is 16bits per channel. At least Photoshop and identify both claim that. The problem is that it doesn't look like it. It looks exactly like it's been truncated to 8bits per channel and then saved as 16bits per channel.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-16T19:55:15-07:00
by fmw42
Does this look OK to you? It displays fine in Mac PREVIEW but is darker in IM display.
Code: Select all
montage cropped_spherical-lighting-test1.+AA+000001.exr cropped_spherical-lighting-test1.+AA+000001.exr -geometry +0+0 -tile 2x1 tmp3.exr
identify -verbose tmp3.exr
Image: tmp3.exr
Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 200x200+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 15-bit
green: 15-bit
blue: 16-bit
alpha: 1-bit
I think the issue is that EXR is a linear format. Some viewers will honor the linear space (such as IM display), but others will assume sRGB. So convert the result to sRGB. This works for me.
Code: Select all
convert tmp3.exr -colorspace sRGB tmp4.exr
display tmp4.exr
See
http://www.imagemagick.org/script/formats.php
"A majority of the image formats assume an sRGB colorspace (e.g. JPEG, PNG, etc.). A few support only linear RGB (e.g. EXR, DPX, CIN, HDR) "
P.S. Seems like montage does honor -colorspace sRGB, so just try
Code: Select all
montage cropped_spherical-lighting-test1.+AA+000001.exr cropped_spherical-lighting-test1.+AA+000001.exr -geometry +0+0 -tile 2x1 -colorspace sRGB tmp5.exr
display tmp5.exr
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-17T11:39:42-07:00
by digitalis99
I've tinkered with a few options for montage, per your prompting. I've tried "-colorspace RGB", "-colorspace sRGB", "-define exr:color-type=RGB", "-define exr:color-type=sRGB"...none of which made any difference. If you look at an "identify -verbose" pass on the cropped tile with CD in the name, you get this:
Code: Select all
Channel statistics:
Pixels: 20000
Red:
min: 3901.94 (0.0595398)
max: 1.#INF (1.#INF)
mean: 1.#INF (1.#INF)
standard deviation: -1.#IND (-1.#IND)
kurtosis: -1.#IND
skewness: -1.#IND
entropy: 0.607496
Green:
min: 5423.92 (0.0827637)
max: 1.#INF (1.#INF)
mean: 1.#INF (1.#INF)
standard deviation: -1.#IND (-1.#IND)
kurtosis: -1.#IND
skewness: -1.#IND
entropy: 0.604619
Notice the Max value is, I assume, clipped in both cases. If you run an "identify -verbose" on the correct output file, you'll see the same thing as regards the max value for both the red and green channels, with a minimum value on the red channel being 768.488 and minimum for green at 451.493.
To the contrary, if you run "identify -verbose" on the stitched result from montage, you get this:
Code: Select all
Channel statistics:
Pixels: 2000000
Red:
min: 593.991 (0.00906372)
max: 65535 (1)
mean: 25044.3 (0.382152)
standard deviation: 16765.5 (0.255825)
kurtosis: -0.241287
skewness: 0.865055
entropy: 0.921521
Green:
min: 384.494 (0.005867)
max: 65535 (1)
mean: 26097.7 (0.398226)
standard deviation: 14740.1 (0.22492)
kurtosis: 1.25858
skewness: 1.34038
entropy: 0.883645
Notice the minimum value for both the red and green channels went down, and the maximum dropped to be not clipped at the 16bit highest possible value of 65,535.
So, it appears montage is shifting the dynamic range of the image to avoid clipping. I can understand its desire to do so, but it causes unexpected results in this case. Is there a way to tell montage not to adjust the dynamic range to avoid clipping? I see -clamp, but it doesn't appear to have a "no" option.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-17T12:29:03-07:00
by fmw42
On IM 6.9.2.6 Q16
(non-HDRI) Mac OSX for your image with CD in the name (cropped_spherical-lighting-test1.+CD+000001.exr), I do not get your odd results. (probably due to not using HDRI) I get
Code: Select all
Image: cropped_spherical-lighting-test1.+CD+000001.exr
Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 100x200+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 1-bit
Channel statistics:
Pixels: 20000
Red:
min: 4372 (0.0667124)
max: 65535 (1)
mean: 36465.7 (0.556431)
standard deviation: 27618 (0.421424)
kurtosis: -1.93906
skewness: 0.0623597
entropy: 0.606209
Green:
min: 6316 (0.096376)
max: 65535 (1)
mean: 39127.5 (0.597047)
standard deviation: 25249.5 (0.385283)
kurtosis: -1.91287
skewness: 0.0353391
entropy: 0.604285
Blue:
min: 90 (0.00137331)
max: 1806 (0.0275578)
mean: 717.733 (0.0109519)
standard deviation: 507.952 (0.00775085)
kurtosis: -0.858382
skewness: 0.641439
entropy: 0.956238
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: 65535 (1)
mean: 19077.7 (0.291108)
standard deviation: 18712 (0.285526)
kurtosis: 6.41528
skewness: 3.05981
entropy: 0.541683
Rendering intent: Undefined
Gamma: 1
Background color: rgba(255,255,255,1)
Border color: rgba(223,223,223,1)
Matte color: rgba(189,189,189,1)
Transparent color: rgba(0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 100x200+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2015-11-17T11:30:56-08:00
date:modify: 2015-11-16T12:58:12-08:00
signature: 94d34c29143d9c7f10b46e7736065bffc16521067fb21a3b748f52ee7aa19ad0
Artifacts:
filename: cropped_spherical-lighting-test1.+CD+000001.exr
verbose: true
Tainted: False
Filesize: 164KB
Number pixels: 20K
Pixels per second: 2.5GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-6 Q16 x86_64 2015-11-14 http://www.imagemagick.org
With IM 6.9.1.10 HDRI, I do get your bad results
Code: Select all
im69110hdri identify -verbose cropped_spherical-lighting-test1.+CD+000001.exr
Image: cropped_spherical-lighting-test1.+CD+000001.exr
Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 100x200+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 1-bit
Channel statistics:
Pixels: 20000
Red:
min: 4371.93 (0.0667114)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.606209
Green:
min: 6315.9 (0.0963745)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.604285
Blue:
min: 89.6861 (0.00136852)
max: 1805.97 (0.0275574)
mean: 717.827 (0.0109533)
standard deviation: 507.917 (0.00775031)
kurtosis: -0.858658
skewness: 0.641152
entropy: 0.956238
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.541683
Rendering intent: Undefined
Gamma: 1
Background color: rgba(255,255,255,1)
Border color: rgba(223,223,223,1)
Matte color: rgba(189,189,189,1)
Transparent color: rgba(0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 100x200+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2015-11-17T11:43:56-08:00
date:modify: 2015-11-16T12:58:12-08:00
signature: 94d34c29143d9c7f10b46e7736065bffc16521067fb21a3b748f52ee7aa19ad0
Artifacts:
filename: cropped_spherical-lighting-test1.+CD+000001.exr
verbose: true
Tainted: False
Filesize: 164KB
Number pixels: 20K
Pixels per second: 4GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-07-25 http://www.imagemagick.org
Likewise, when using IM 6.9.2.6 Q16 HDRI, I get your same odd results with inf and nan showing in the channel stats.
Code: Select all
im6926hdri identify -verbose cropped_spherical-lighting-test1.+CD+000001.exr
Image: cropped_spherical-lighting-test1.+CD+000001.exr
Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 100x200+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 1-bit
Channel statistics:
Pixels: 20000
Red:
min: 4371.93 (0.0667114)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.606209
Green:
min: 6315.9 (0.0963745)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.604285
Blue:
min: 89.6861 (0.00136852)
max: 1805.97 (0.0275574)
mean: 717.827 (0.0109533)
standard deviation: 507.917 (0.00775031)
kurtosis: -0.858658
skewness: 0.641152
entropy: 0.956238
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: inf (inf)
mean: inf (inf)
standard deviation: nan (nan)
kurtosis: nan
skewness: nan
entropy: 0.541683
Rendering intent: Undefined
Gamma: 1
Background color: rgba(255,255,255,1)
Border color: rgba(223,223,223,1)
Matte color: rgba(189,189,189,1)
Transparent color: rgba(0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 100x200+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2015-11-17T11:43:56-08:00
date:modify: 2015-11-16T12:58:12-08:00
signature: 94d34c29143d9c7f10b46e7736065bffc16521067fb21a3b748f52ee7aa19ad0
Artifacts:
filename: cropped_spherical-lighting-test1.+CD+000001.exr
verbose: true
Tainted: False
Filesize: 164KB
Number pixels: 20K
Pixels per second: 2.5GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-6 Q16 x86_64 2015-11-17 http://www.imagemagick.org
You might post a note to the Bugs forum and reference back here. I do not know if this is an IM issue or one with your EXR files, but the IM developers should take a look. I believe that IM only permits the use of EXR "Half" format. Are your images Half or Full format EXR?
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-17T13:09:56-07:00
by fmw42
I think you have at least one bad image. I do not get the same inf and nan for other of your images. For example:
Code: Select all
im6926hdri idv cropped_spherical-lighting-test1.+AA+000001.exr
Image: cropped_spherical-lighting-test1.+AA+000001.exr
Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 100x200+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: RGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 1-bit
Channel statistics:
Pixels: 20000
Red:
min: 4751.93 (0.0725098)
max: 13423.8 (0.204834)
mean: 11070.8 (0.16893)
standard deviation: 926.577 (0.0141387)
kurtosis: -0.143403
skewness: 0.460611
entropy: 0.933098
Green:
min: 7699.88 (0.117493)
max: 20751.7 (0.31665)
mean: 17627.7 (0.268981)
standard deviation: 1283.47 (0.0195846)
kurtosis: 0.229231
skewness: 0.414506
entropy: 0.914077
Blue:
min: 128.748 (0.00196457)
max: 328.995 (0.00502014)
mean: 288.123 (0.00439647)
standard deviation: 17.0209 (0.000259723)
kurtosis: 1.29967
skewness: 0.303937
entropy: 0.819898
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: 20751.7 (0.31665)
mean: 7246.65 (0.110577)
standard deviation: 791.54 (0.0120781)
kurtosis: 11539
skewness: 261.905
entropy: 0.666768
Rendering intent: Undefined
Gamma: 1
Background color: rgba(255,255,255,1)
Border color: rgba(223,223,223,1)
Matte color: rgba(189,189,189,1)
Transparent color: rgba(0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 100x200+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2015-11-17T11:44:01-08:00
date:modify: 2015-11-16T12:58:08-08:00
signature: 9d45958318007b66bfda02cf6efb37e932cdcff1214ea4145794ccddef0ac0bc
Artifacts:
filename: cropped_spherical-lighting-test1.+AA+000001.exr
verbose: true
Tainted: False
Filesize: 164KB
Number pixels: 20K
Pixels per second: 10GB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.9.2-6 Q16 x86_64 2015-11-17 http://www.imagemagick.org
Fred-Weinhauss-Mac-mini:desktop fred$
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-17T18:53:10-07:00
by digitalis99
fmw42 wrote:I think you have at least one bad image. I do not get the same inf and nan for other of your images. For example:
The image was created by the render app that way. There is a "sun" present on that tile that shows exactly where the clipping is. There is no sun elsewhere on the image, so there shouldn't be clipping on any of the other tiles.
I'll post over on bugs and see where we go.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-25T09:11:57-07:00
by digitalis99
The post on the bugs forum has gone all of nowhere so far. I would have thought it would be taken at least somewhat seriously due to it being easily reproducible with the files I provided. The nature of the flaw is objectively obvious. Anyone?
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-25T11:08:34-07:00
by fmw42
Just a suggestion. Try using convert ... +-append to combine your images to see if convert has the same issue as montage. See
http://www.imagemagick.org/Usage/layers/#append.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-26T08:57:45-07:00
by digitalis99
Convert doesn't have the same issue as montage, since I use convert to crop each output tile to only the portion of the image with information prior to using montage. I may have to resort to using convert, though, if none of the devs care about making montage work correctly.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-26T11:14:04-07:00
by magick
Montage places its image tiles on a canvas with a compositing operation, the default is 'over'. Compositing is governed by the SVG standard for alpha compositing which requires clamping for the 'over' operator. Try instead, the 'copy' op with '-compose copy' on your command-line. You may also need to use an HDRI-enabled version of ImageMagick to get the expected results.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-26T11:25:42-07:00
by fmw42
Magick:
Would montage accept the -define compose:clamp=on|off (available as of 6.9.1-3)?
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-26T11:32:12-07:00
by magick
Yes.
Re: Montage not maintaining 16 bit depth
Posted: 2015-11-26T12:17:16-07:00
by digitalis99
Yea! That works as expected. I'm not so sure the default of that should be "over", but I'm happy to have that solved. Too bad it took so long to find. :^)