This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Process single channels of image

I am trying to process only single channels of my image. How would you go about that?

Let's say I want to increase the brightness of only the red channel.

Can I do that directly or do I have to split and then combine?
Hi,

Unfortunately, there are no planar pixel formats in GraphicsMill. So, the only way is to split and combine the image.

This is a sample with Bitmaps:
using (var bitmap = new Bitmap("MyImage.JPG"))
using (var brightness = new Brightness(0.1f))
using (var red = bitmap.Channels[Channel.Red])
{
    red.ApplyTransform(brightness);
    bitmap.Channels[Channel.Red] = red;
    bitmap.Save("output.jpg");
}


And this is with Pipeline API:
using (var reader = ImageReader.Create("MyImage.jpg"))
using (var splitter = new RgbChannelSplitter())
using (var combiner = new RgbChannelCombiner())
using (var writer = ImageWriter.Create("output.jpg"))
using (var brightness = new Brightness(0.1f))
{
    reader.Receivers.Add(splitter);

    combiner.R = splitter.R + brightness;
    combiner.G = splitter.G;
    combiner.B = splitter.B;

    Pipeline.Run(combiner + writer);
}