Ask Your Question
1

Simple image stitching (C++)

asked 2016-06-14 17:07:25 -0500

Elessar gravatar image

I'm having a hard time finding a tutorial that explains how to do image stitching. I've read https://ramsrigoutham.com/2012/11/22/..., but it's only a code example, and not an actual tutorial.

Are there any good tutorials in C++ that would explain how image stitching?


What I'm trying to do is stitch images that are created on a computer (eg. screenshots), which will be consistently the same orientation, resolution, angle, etc. The only thing that differs is the offset, which isn't consistent.

How do I go about stitching these images so that they are matched pixel-perfect?

edit retag flag offensive close merge delete

Comments

Do you know the offset exactly, or do you need to find it?

Tetragramm gravatar imageTetragramm ( 2016-06-14 20:12:22 -0500 )edit

My program would know the general direction of the offset, but not the amount. It could also be offset by both x and y. Each image might be at a different x/y offset.

Elessar gravatar imageElessar ( 2016-06-14 22:12:15 -0500 )edit

Do the screenshots overlap?

strann gravatar imagestrann ( 2016-06-15 02:55:48 -0500 )edit

Yes, they always do.

Elessar gravatar imageElessar ( 2016-06-15 12:23:19 -0500 )edit
1

Ok, if there's no depth involved, it's a flat image that you're seeing different parts of, then you should probably use Phase Correlation to find the shift between images. Then just copy to the appropriate location, perhaps with getRectSubPixel if you have subpixel shifts.

Alternatively, use feature descriptors like ORB, use the matches to find an affine transform and only use the translation.

Phase Correlate is probably faster, but there's more tutorials for feature points.

Tetragramm gravatar imageTetragramm ( 2016-06-15 17:14:50 -0500 )edit

I thing than need delete warping part code.

VladimirKhludenkov gravatar imageVladimirKhludenkov ( 2016-06-20 02:16:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-06-24 15:10:31 -0500

Elessar gravatar image

Using Phase Correlation I was able to find the correct x/y offset. I used the Phase Correlation tutorial found here: http://web.archive.org/web/2012101411...

The only hiccup I have come across is when the images are aligned top-right / bottom-left. The phase correlation only returns the correct x coordinate OR y coordinate at a time, so I have to calculate twice. (Once for X, once for Y.) And the Y coordinate generated for this positioning is consistently 1 pixel off. (Not desirable, but manageable.)

The other arrangements all work out fine (directly above / below, side-by-side, and top-left / bottom-right).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2016-06-14 17:07:25 -0500

Seen: 326 times

Last updated: Jun 24 '16