Version 7 Channel FX
Posted: 2013-05-15T11:33:20-07:00
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
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