Copy alpha channel
Posted: 2016-10-06T08:35:41-07:00
I'm attempting to copy a grayscale file into the alpha channel of a Radiance RGBE file using perl magic. The Radiance file has values which exceed the quantum depth (Q16 HDR) and the grayscale file has values either 0 or quantum depth (Q16)
In command line the following was successful:
The compose:clamp=off instruction appeared to be necessary for this to work correctly.
I have not been able to identify the equivalent clamp=off command in perl magic, and the following code does not work (i.e. produces a fully transparent alpha channel, in the same way as omitting the clamp=off instruction in the command line example).
Running $image_x->Identify(); on $image_a (before composite) gives
.... and the $image_b file
...... with the post Composite result file being
Am I missing something, or is there an alternative way to do this?
Mike
In command line the following was successful:
Code: Select all
convert -define compose:clamp=off \
IMAGE_A.hdr IMAGE_B.ppm \
-alpha Off -compose copy-opacity -composite \
IMAGE_OUT.hdr
The compose:clamp=off instruction appeared to be necessary for this to work correctly.
I have not been able to identify the equivalent clamp=off command in perl magic, and the following code does not work (i.e. produces a fully transparent alpha channel, in the same way as omitting the clamp=off instruction in the command line example).
Code: Select all
$image_b->Set(Alpha=>"Off");
$image_a->Set(Alpha=>'Set');
$image_a->Composite(file=>$image_b, compose=>"CopyOpacity");
Running $image_x->Identify(); on $image_a (before composite) gives
Code: Select all
Image: /media/sf_Linux_Share/Process/2/2_3_Test.hdr
Format: HDR (Radiance RGBE image format)
Class: DirectClass
Geometry: 4460x2976+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: 13272960
Red:
min: 0 (0)
max: 6.4552e+06 (98.5)
mean: 160894 (2.45509)
standard deviation: 280578 (4.28135)
kurtosis: 220.499
skewness: 12.0161
entropy: 0.394997
Green:
min: 0 (0)
max: 6.3569e+06 (97)
mean: 164157 (2.50488)
standard deviation: 253904 (3.87432)
kurtosis: 188.494
skewness: 10.295
entropy: 0.40226
Blue:
min: 0 (0)
max: 6.38966e+06 (97.5)
mean: 167421 (2.55468)
standard deviation: 211620 (3.22911)
kurtosis: 236.99
skewness: 11.2159
entropy: 0.271946
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: -nan (-nan)
kurtosis: -5.00137e+69
skewness: 1.03552e+50
entropy: 0.392506
Image statistics:
Overall:
min: 0 (0)
max: 6.4552e+06 (98.5)
mean: 139502 (2.12866)
standard deviation: 216780 (3.30785)
kurtosis: 304.257
skewness: 13.5816
entropy: 0.365427
Rendering intent: Undefined
Gamma: 1
Alpha color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 4460x2976+0+0
Dispose: Undefined
Iterations: 0
Compression: RLE
Orientation: Undefined
Properties:
date:create: 2016-10-06T16:07:51+01:00
date:modify: 2016-10-06T16:07:51+01:00
signature: f660e94e6f56fcc5a4e4b2ed7b591e27509ee420a848713ae3f76664ed9cd12b
Tainted: True
Filesize: 42.62MB
Number pixels: 13.27M
Pixels per second: 642KB
User time: 21.180u
Elapsed time: 0:21.660
Version: ImageMagick 7.0.2-4 Q16 x86_64 2016-09-15 http://www.imagemagick.org
Code: Select all
Image: /tmp/magick-16155MFWS9Z8ZGoU5
Format: PPM (Portable pixmap format (color))
Mime type: image/x-portable-pixmap
Class: DirectClass
Geometry: 4460x2976+0+0
Base geometry: 5248x3502
Units: Undefined
Type: Bilevel
Base type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 16/1-bit
Channel depth:
Gray: 1-bit
Channel statistics:
Pixels: 13272960
Gray:
min: 0 (0)
max: 65535 (1)
mean: 65439.3 (0.99854)
standard deviation: 2502.42 (0.0381845)
kurtosis: 679.845
skewness: -26.1122
entropy: 0.0158595
Colors: 2
Histogram:
19381: ( 0, 0, 0) #000000000000 black
13253579: (65535,65535,65535) #FFFFFFFFFFFF white
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Alpha color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2016-10-06T16:06:43+01:00
date:modify: 2016-10-06T16:06:43+01:00
signature: fdab5316fe8c640cccbb47967da3defa2e75559ce5b52a08fb2f70f56acb9728
Artifacts:
modulate:colorspace: HSB
Tainted: False
Filesize: 0B
Number pixels: 13.27M
Pixels per second: 272KB
User time: 15.060u
Elapsed time: 0:49.849
Version: ImageMagick 7.0.2-4 Q16 x86_64 2016-09-15 http://www.imagemagick.org
Code: Select all
Image: /media/sf_Linux_Share/Process/2/2_3_Test.hdr
Format: HDR (Radiance RGBE image format)
Class: DirectClass
Geometry: 4460x2976+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: 13272960
Red:
min: 0 (0)
max: 6.4552e+06 (98.5)
mean: 160894 (2.45509)
standard deviation: 280578 (4.28135)
kurtosis: 220.499
skewness: 12.0161
entropy: 0.394997
Green:
min: 0 (0)
max: 6.3569e+06 (97)
mean: 164157 (2.50488)
standard deviation: 253904 (3.87432)
kurtosis: 188.494
skewness: 10.295
entropy: 0.40226
Blue:
min: 0 (0)
max: 6.38966e+06 (97.5)
mean: 167421 (2.55468)
standard deviation: 211620 (3.22911)
kurtosis: 236.99
skewness: 11.2159
entropy: 0.271946
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: -nan (-nan)
kurtosis: -5.00137e+69
skewness: 1.03552e+50
entropy: 0.392506
Image statistics:
Overall:
min: 0 (0)
max: 6.4552e+06 (98.5)
mean: 139502 (2.12866)
standard deviation: 216780 (3.30785)
kurtosis: 304.257
skewness: 13.5816
entropy: 0.365427
Rendering intent: Undefined
Gamma: 1
Alpha color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 4460x2976+0+0
Dispose: Undefined
Iterations: 0
Compression: RLE
Orientation: Undefined
Properties:
date:create: 2016-10-06T16:07:51+01:00
date:modify: 2016-10-06T16:07:51+01:00
signature: f660e94e6f56fcc5a4e4b2ed7b591e27509ee420a848713ae3f76664ed9cd12b
Tainted: True
Filesize: 42.62MB
Number pixels: 13.27M
Pixels per second: 2.208MB
User time: 6.020u
Elapsed time: 0:07.009
Version: ImageMagick 7.0.2-4 Q16 x86_64 2016-09-15 http://www.imagemagick.org
Am I missing something, or is there an alternative way to do this?
Mike