Stitch images with exact match (pixel-to-pixel)

I have a bunch of images in a folder that actually are only parts of a single image that have been split into overlapping parts. How to quickly and programmatically recombine these images to create the original image?

I would prefer a solution that uses python or mathematica (or an existing application), but I'm open to other ideas as well (I'm pretty good at Java).

+4
source share
5 answers

Well, I don’t have to do this anymore to do what I want to do, but I will tell you how to do it if I wrote it in python (a combination of psuedocode and python). Here, I assume that the upper left corner of subsequent images is always the overlap point (which was true in my case). If you want to detect overlap for any angle, you will need to determine which β€œcorner” case (pun intended: D) you are in, and add processing for each case.

images = list of images to be stitched, loaded from directory stitched_image = images[0] for (image in images): if first image then skip it (continue) else combine_images(stitched_image, image) def combine_images (stitched_image, image_to_add): top_left_corner = top left corner of image_to_add // top_left_corner dimensions need to be big enough that you don't have a false positive, // but not so big that the overlap doesn't exist coordinates = find_coordinates(stitched_image,top_left_corner) new_width = max(stitched_image.width,image_to_add.width + coordinates.x) new_height = max(stitched_image.height,image_to_add.width + coordinates.y) new_image = new Image(new_width,new_height) // See note 1 new_image.paste(stitched_image,(0,0)) new_image.paste(image_to_add,(coordinates.x,coordinates.y)) stitched_image = new_image def find_coordinates (image,sub_image): // See note 2 for how to implement 

Notes:

  • Image creation and insertion into it can be done using PIL: http://29a.ch/2009/5/14/concatenating-images-using-python

  • Take a look at this question on how to find sub_image in an image (you may need to convert the image to a different view): Finding a subimage inside a Numpy image.In addition, for any experienced programmer it would not be easy to manually check the pixels in the pixel matrix to find the overlap. You can add additional optimization if you know roughly where the match is likely to happen, just first in more likely areas.

0
source

You can use Autopano or something similar; if you want to flip it yourself, you may find the SIFT algorithms useful http://www.janeriksolem.net/2009/02/sift-python-implementation.html?m=1

0
source

What you want is a panorama tool. For this, various tools with various functions are used. What you need to think about:

  • matching position both vertically and horizontally
  • different brightness between images
  • correction of rotation and angle of rotation of the camera
0
source

Do you intend to use a custom Java solution? If you are open to something else, I am doing something similar for a project and came up with a bash script suite for Linux.

To do this, I used

  • Hugin and hugin tools from Ubuntu repositories
  • Panotools perl shell scripts
  • This is a guide to get command-line generation functionality. In the example, pto_gen does not exist after setting hugin, but it replaces my match-n-shift in Panotools scripts.

If you want to process several panoramas sequentially, you will have to come up with a way to sort, execute and move files. It was fun with my scripting process. Stitching images was easy, making sure they went to the right place after that was a bit complicated.

Right now, using the 4-core Xeon system with 4 GB of RAM, stitching a panorama of 50 shots at 360 degrees takes ~ 30-45 minutes.

0
source

In Mathematica, you can use ImageCorrespondingPoints in the overlap area, and then FindGeometricTransform to calculate an affine transform that transfers one image to another. Note that the size of images and areas of overlap affects the accuracy of the conversion. If you are doing something complicated (for example, combining satellite images), you will need a common geometric model for the result, and then map each image to it. In such cases, the affinity transformation may be insufficient.

0
source

All Articles