Page 1 of 1
Applying channel multipliers to RGB channels
Posted: 2017-07-22T02:12:09-07:00
by geoland
Hi.
Given the channel multiplier values
Code: Select all
R sRGB G sRGB B sRGB
R raw 1.91 -1 0.09
G raw -0.19 1.65 -0.46
B raw 0.07 -0.7 1.64
Color matrix as defined in ISO standard 17321
Is there an IM method for applying multipliers to each channel, as follows?
Code: Select all
R = 1.91 * r - 1 * g + 0.09 * b
G = -0.19* r + 1.65 * g - 0.46 * b
B = 0.07 * r - 0.7 * g + 1.64 * b
R G B would then be combined to create an sRGB image.
There is likely no need to separate the channels - this just illustrates the process.
Re: Applying channel multipliers to RGB channels
Posted: 2017-07-22T05:00:28-07:00
by snibgo
Re: Applying channel multipliers to RGB channels
Posted: 2017-07-22T16:44:35-07:00
by geoland
Thanks. This is what I came up with. Works quite well.
Code: Select all
#! /bin/bash
# Apply DSLR channel multipliers, obtained from
# https://www.dxomark.com/Cameras/Canon/EOS-450D---Measurements
# ImageMagick -color-matrix
# To run script from command line in Windows OS replace \ with ^ AFAIK...
# Canon 450D
# R sRGB G sRGB B sRGB
# R raw 1.91 -1 0.09
# G raw -0.19 1.65 -0.46
# B raw 0.07 -0.7 1.64
# Color matrix as defined in ISO standard 17321
# Play around with multipliers for Ha modded cameras
convert in.jpg -depth 16 -color-matrix \
"1.81 -0.8 0.07 0.0, 0.0, 0.0 \
-0.16 1.51 -0.4 0.0, 0.0, 0.0 \
0.05 -0.5 1.5 0.0, 0.0, 0.0 \
0.0 0.0 0.0 0.0, 0.0, 0.0 \
0.0 0.0 0.0 0.0, 0.0, 0.0 \
0.0 0.0 0.0 0.0, 0.0, 0.0" -alpha off out.jpg
animate -delay 100 -loop 0 -resize 800x600 -page 800x600 in.jpg out.jpg
exit
Re: Applying channel multipliers to RGB channels
Posted: 2017-07-22T17:47:56-07:00
by fmw42
If you only need the RGB channels, you can reduce the matrix to the top left 3x3 values
Code: Select all
convert in.jpg -depth 16 -color-matrix \
"1.81 -0.8 0.07 \
-0.16 1.51 -0.4 \
0.05 -0.5 1.5" -alpha off out.jpg
Re: Applying channel multipliers to RGB channels
Posted: 2017-07-22T19:50:23-07:00
by snibgo
The data behind the matrix may assume pixels values are linear, not sRGB (or AdobeRGB or whatever). If so, put "-colorspace RGB" before the matrix and "-colorspace sRGB" after it.
Re: Applying channel multipliers to RGB channels
Posted: 2017-07-23T12:29:17-07:00
by geoland
snibgo wrote: ↑2017-07-22T19:50:23-07:00
The data behind the matrix may assume pixels values are linear, not sRGB (or AdobeRGB or whatever). If so, put "-colorspace RGB" before the matrix and "-colorspace sRGB" after it.
That fits in with the workflow. Plan is to apply this to linear images.
The 4th and 5th column seem redundant and likely unnecessary in that case.