So, here's what I want to do.
Let's say I have a normal image with RGB color channels. I want to either generate or use a random noise image for this. Basically, what I want to do is switch the red and green color channels based off the noise image's pixels. If the pixel is black the colors aren't switched, if it's white the colors are completely swapped, and if it's half/gray the colors are averaged. How can I do this?
Swap image color channels based off noise image.
-
- Posts: 27
- Joined: 2016-03-11T07:27:11-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Swap image color channels based off noise image.
With a "compose over". The basic idea is:
Where the mask is black, the output is from source. Where it is white, it is from switched. Where it is gray, the output is a blend.
Instead of "switched.png", you could start a new list, clone the source, separate the channels, swap them, and combine:
(Windows syntax, but untested.)
Code: Select all
convert ^
source.png ^
switched.png ^
mask.png ^
-compose Over -composite ^
out.png
Instead of "switched.png", you could start a new list, clone the source, separate the channels, swap them, and combine:
Code: Select all
convert ^
source.png ^
( +clone ^
-separate ^
-swap 0,1 ^
-combine ^
) ^
mask.png ^
-compose Over -composite ^
out.png
snibgo's IM pages: im.snibgo.com