Separate the R, G, B channels of RGB images into grayscale images. How should I operate?

I want to separate the R, G, B channels of RGB images into three grayscale images. How should I operate?

You could do it like this:

var planeImages = image.Planes
                       .Select(plane => plane.Map())
                       .ToArray();

This doesn’t actually create new Images, but views on the existing image (we call these views MappedImages). Thus this operation is very fast and doesn’t occupy a lot of space. If you want actual copies you can add

                       .Select(image => image.Clone())

before the .ToArray() call.

3 Likes