Anderson
Anderson

Reputation: 3

What is the equivalent of ImageJ Merge channels in Python?

ImageJ has the option of merging the channels, even if there is no color for some of the channels (you can keep the value as None). This means you can pick red channel from one image and blue from another, and merge them together to get a new image. However, i could not find such a thing in Python, more specifically in OpenCV. There is the method cv2.merge(), but it requires three different parts (blue, red and green) which should be provided from cv2.split(). Is it possible to merge two different channels, for example blue from an image and green from another, in Python?

Thanks

Upvotes: 0

Views: 688

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207778

You can use cv2.merge() as you suggest. Or, since most Python image processing packages represent images with Numpy arrays, you can use Numpy's dstack().

Example here and here.

Upvotes: 1

Related Questions