Version 7 Channel FX

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Alan Hadley
Posts: 48
Joined: 2010-03-31T12:17:55-07:00
Authentication code: 8675308

Version 7 Channel FX

Post by Alan Hadley »

I have been trying out some Channel FX operations and have a few comments. I know that you are going to expand this functions capabilities, but still had to have a p[lay.

Extracting individual channels, e.g. R G and B, to greyscale images works fine with this string "1;2;3" but when using the equivalent "1=>1;2=>1;3=>1" it fails because the right hand numbers in expressions like this need to be reduced by one i.e. "1=>0;2=>0;3=>0" works as expected.

It is not easy to do the reverse of the above, i.e. combine three grey images to make one 3 channel image. I have come up with a solution which involves adding an extra image at the start of the input image list. That is having a dummy 3 channel image and then three single channel images, then using "|1=>0|1>1|1>2". The first "|" skips over the dummy image which is however cloned to make the output image. Without this first image the output would be a clone of a one channel image and thus could not hold the three channel result.

In the above using "|1=>0" as the FX string will replace the red channel and leave the original channels. Note that you still have to reduce the channel number of the RHSs by one.

It is not possible to use three single channel images and produce three three channel images, using something like "|1=>0|;1=>1|;1=>2" even if there is a three channel image at the start of the list. I would expect the above to produce a red, a green and a blue image as output. This is because each new output image is a clone of the current input image not of the first image.

A possible way to resolve these problems is to have two input lists, one the source images and the other the images to be modified. The "|" operator would then advance the modifiable lists pointer and the ";" would modify the input lists pointer. It should then be possible to have both input lists be the same list thus "<=>" channel swapping would still work to reorder the input channels in place.

I like the last solution but there is another, to supply an input list and a specification which is used whenever a new image is called for at the start and when "|" is used. This has the disadvantage that you would have to supply all of the channels of the new image, whereas in the first solution you could, for instance, supply say a batch of RGBA images and apply the same grey image to each as an alpha channel without creating any new images with something like ChannelFX(outlist,inlist,"1=>4|1=>4|1=>4...).

Alan Hadley
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Version 7 Channel FX

Post by magick »

We're just getting back to channel-fx because we are going to use this option to populate the read and write masks. We intend to expand the current capabilities and will look toward incorporating your suggestions. Thanks.
Post Reply