0
votes

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

1
just to extend Mark's answer, if you don't have a third channel for the opencv merge operation, just generate an empty black(0) Mat for the nonexistent red channel to merge with the Green and Blue channels.Jason Pitt

1 Answers

1
votes

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.