2

I have a bunch of images that have different exposures and I want to stitch them together:

Grayscale Images Converted to JET colormapping for Illustration Purposes

OpenCV has a Stitcher example but it relies on matching features between the images and they should overlap with each other.

My images are not overlapping BUT they are connected to each other contiguously (as if I partitioned a Panorama into multiple splits) and I want to connect them together and fix their exposures.

How can I do this in OpenCV Python? At the very least the Compensator class needs:

compensator.feed(corners=corners, images=images_warped, masks=masks_warped)

images_warped could just be normal input images and masks_warped could be a 2D array of Ones but I don't know how the corners value should be given manually?

a simple example would suffice, Thanks.

Individual images

enter image description here enter image description here enter image description here

nathancy
  • 42,661
  • 14
  • 115
  • 137
Cypher
  • 2,374
  • 4
  • 24
  • 36
  • It would help if you would provide separate images without the buffers between them. Try np.hstack(). See https://docs.scipy.org/doc/numpy/reference/generated/numpy.hstack.html – fmw42 Jan 31 '20 at 18:50
  • @fmw42 Oh... The buffers are just for demonstration purposes and the image is an screenshot from the image thumbnails in Windows File Explorer. The real images don't have any buffer between them: just raw separate images. – Cypher Jan 31 '20 at 19:04
  • I am asking you to provide the original images so we can demonstrate the code with your images. – fmw42 Jan 31 '20 at 20:10
  • @fmw42 I added them to the end of the question. Thanks. and also please know that the answer from `nathancy` is not what I had in mind. – Cypher Feb 01 '20 at 07:16
  • What do these images represent? Looks like depth map with colormap applied. For sure you could use multi-band blending. But if you have the raw depth map, I would stitch first and then applied the colormap on the panorama. – Catree Feb 01 '20 at 13:08
  • @Catree It's as you said: Raw Depthmaps with the JET colormap applied (only for Illustration purposes). How can i use Multiband blending? can you provide some guidance or sample code please? Thanks. – Cypher Feb 02 '20 at 07:02
  • @Cypher I meant for a panorama, the different images are captured with different exposure. Here I think that the colormap takes the maximum and minimum raw depth values and convert it to the colormap. Since the max and min values differ for the three depth maps, you see these discontinuities. But if you applied the colormap afterward, you should not see discontinuities. Else it means the three depth maps have discontinuities and indeed you can use blending techniques from the panorama processing field. – Catree Feb 02 '20 at 19:33

2 Answers2

0

With the assumption that each of your images have the same dimensions and since OpenCV images are Numpy arrays, we can use np.concatenate, np.hstack, or cv2.hconcat.

import cv2
import numpy as np

# Load images
image1 = cv2.imread('1.png')
image2 = cv2.imread('2.png')
image3 = cv2.imread('3.png')

# Method #1
hstack = np.hstack((image1, image2, image3))

# Method #2
concatenate = np.concatenate((image1, image2, image3), axis=1)

# Method #3
hconcat = cv2.hconcat([image1, image2, image3])

cv2.imshow('hstack', hstack)
cv2.imshow('concatenate', concatenate)
cv2.imshow('hconcat', hconcat)
cv2.waitKey()

The result should be the same

enter image description here

nathancy
  • 42,661
  • 14
  • 115
  • 137
  • As you can see there are vertical lines connecting each section to the other one and these vertical lines are unwanted. The OpenCV Exposure Compensator Class fixes these continuity problems and my question is about how to use that class with images like these (which have no overlapping sections). – Cypher Feb 01 '20 at 07:15
0

I would create an overlapping section by duplicating on each picture a small part of the adjacent picture. Then there is a bit of work to process that as a normal stitching process.

Pilip38
  • 1
  • 1