LarsBT wrote:Your guess is right. The row is the output for the channel. Top row is red channel.
That makes things easier to understand.
LarsBT wrote:It's not a "true" matrix multiplication as the result from each row carries on to the next while multiplying. Thus the red channel is dealt with first, then the green with the any changes to the red carried on. (The problem you spotted with my initial suggestion using the -fx operator.)
Then you have found a bug.. This is a matrix operator, as as such should
be performed as a whole. Not one by one. Send in a bug report.
Hmmm quick test.... The clasical 'swap red and blue channels' problem. This is typically regarded as difficult to do, and the result on the built-in rose image is a blue rose.
Code: Select all
convert rose: -recolor ' 0 0 1
0 1 0
1 0 0 ' rose_blue.png
Well the result definatally isn't blue, as it is more like a 'black' rose!
So I can verify -recolor is broken.
Note that I only use a 3x3 matrix. That is quite acceptable when transparency is not being modified. A 4x4 is for RGBA or CMYK images
while a 5x5 is needed for CMYKA images.
This brings use to a extra idea with the -recolor matrix (when it is working).
matrix operations on a HSL image. Could produce interesting effects.
Another example of (when working) -recolor matrix would be...
Grey scale image in a 2/5/3 ration rather than the IM default of 3/4/3
Code: Select all
convert rose: -recolor ' .2 .5 .3
.2 .5 .3
.2 .5 .3 ' rose_grey_253.png
I did say I have not tested it and added examples in IM Examples yet.
The act of creating examples generally performs a secondary function of testing and debugging IM operators, as well as providing regression tests tha locates detrimental effects from other changes in the code.
Thanks for your efforts. I have made notes for IM examples. BUt no examples yet. The 'Color Modification' Page of IM examples, will in the next couple of months undergo a ''
cellular division'' so to speak. It will divide in direct color modifications, and histogram modifications.
The former includes color selection, replacement, fuzz factors, brightening, gray-scaling, recoloring, tinting, Color Lookup tables, etc etc.
The later will include things like normalization, auto-leveling, linear and gussian equalization, contrast adjustments, and so on.
Lot of work to do.