Page 1 of 1
Swap color channels
Posted: 2019-06-30T09:56:23-07:00
by dlinaresg
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
Re: Swap color channels
Posted: 2019-06-30T19:10:09-07:00
by 246246
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
Posted: 2019-07-01T10:03:02-07:00
by dlinaresg
Thank you so much. Nice solution.
Re: Swap color channels
Posted: 2019-07-02T22:22:13-07:00
by dlemstra
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.