I´m trying to use Magick.net to interchange red and green channels in a RGB image, but cannot find swap method. I have found MagickImageCollection Reverse method which 'reverses the order of the images in the collection' but it´s not clear if rotates the channels (1 to 0, 2 to 1, 0 to 2) or, when there are three channels, swaps red channel (0) with green channel (2). Is Reverse the only way to swap two channels? How can I specify which channels to interchange?
Thanks
Swap color channels
Re: Swap color channels
Get IMagickCollection by Separate(), reorder to the state whatever you want, then Combine();
Code: Select all
var x = image.Separate().ToList();
var y = new MagickImageCollection();
y.Add(x[2]);
y.Add(x[1]);
y.Add(x[0]);
var swapped = y.Combine();
Re: Swap color channels
Thank you so much. Nice solution.
Re: Swap color channels
I am also considering to add parts of https://imagemagick.org/script/command- ... channel-fx in some form to the API. Not sure how and when this will happen yet.