Page 1 of 1

Swap color channels

Posted: 2019-06-30T09:56:23-07:00
by dlinaresg
I´m trying to use 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?

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();
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 ... channel-fx in some form to the API. Not sure how and when this will happen yet.