Ask Your Question
1

Registering images

asked 2015-05-15 07:53:05 -0500

lock042 gravatar image

updated 2015-05-15 08:41:21 -0500

Hello everybody, I'm posting here a question I have. Indeed, I'm working on a project using OpenCV and I would like to know some tips. I want to register a set of images with regard to a reference one. Each image already has a set of points I've computed (I used a homemade algorithm to find out these points. In fact, these points are the stars in astronomical images) and I take an image as reference. The different sets don't necessary have the same number of points between each others and the number of outliers can be important

Now, I need to match these dataset in order to compute for each image :

  • the (x,y) shift

  • the rotation angle

Could you give me some advices ? I think that OpenCV must have some good functions but I'm not sure about it.

Best regards,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-05-15 08:48:23 -0500

Potato gravatar image

updated 2015-05-15 08:49:15 -0500

There are two ways that I know you can register images with openCV. Feature based registration, and pixel based registration. I can see that you already have reference points to work with to register your image, so you could use techniques used in feature based registration.

Like you say, you have a reference image and a image to register. With the points that you have computed with the homemade algorithm, you could use the "findHomography( )" function. --> Mat H = findHomography(ImageToRegister_pts, ReferenceImage_pts, CV_RANSAC); where ImageToRegister_pts and ReferenceImage_pts are vector<Point2f>of your points This will give you the homography matrix between the two images which you can use to warp/align the given image to the reference image. (Reference: http://docs.opencv.org/modules/calib3...)

Then use the "warpPerspective function( )" to effectively warp the image. --> warpPerspective(imageToWarp, OutputImage, Hinv, ImageToWarp.size()); where ImageToWarp is the Mat image, OutputImage is a Mat to store the final output and Hinv is the inverse of the Homography Matrix (Hinv = H.inv()). There are alternatives to the warPerspective function like "perspectiveTransform( )" as used in this example --> http://docs.opencv.org/doc/tutorials/...

Another registration technique can be found in OpenCV 3 under the opencv_contrib functionality. It uses pixel based registration methods. Follow this link for more information --> https://github.com/Itseez/opencv_cont...

As per my experience, I used feature based registration as it was simpler, however pixel based registration is more accurate. You will have to look into the source code to really understand what is happening. Your choice all depends on your application.

Hope this helps!

edit flag offensive delete link more

Comments

Hi, Thank you for your answer !! I believe that findHomography needs to have 2 datasets with the same number of points. Isn't it ? I can't check it now because I'm at work, but this function could solve my problem. So thanks !!

lock042 gravatar imagelock042 ( 2015-05-15 08:59:42 -0500 )edit

Yes, you would need the same number of corresponding points and the number of points have to be greate than 4. No problem. If you get stuck just come back and ask. Take a look into the pixel reg as well. You might find something there.

Potato gravatar imagePotato ( 2015-05-15 09:05:19 -0500 )edit

Ok, Thanks. You said "you would need the same number of corresponding points" I would say "you would need the same number of points" because as I said, I'll probably have some outliers. To handle this I will take for example, the 20 brightest stars in each image. But As you can imagine, it's possible that the 20 selected stars are not always the same in each image.

Anyway, Thank you :).

lock042 gravatar imagelock042 ( 2015-05-15 09:12:15 -0500 )edit

You're absolutely right. When I said it, I meant in an ideal case. As a matter of fact I also worked on registering images of a starfield, and I had a hard time detecting corresponding points as there is only so much information that you can pull out from a starfield. I found that the pixel based registration worked well for me.

Potato gravatar imagePotato ( 2015-05-15 10:18:18 -0500 )edit

Hum I'm sad. It looks like calib3d is using GTk2 while my project use GTK3. As a consequence I have :

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

Any idea ?

lock042 gravatar imagelock042 ( 2015-05-16 07:01:13 -0500 )edit

What is your compile command?

Potato gravatar imagePotato ( 2015-05-19 09:23:18 -0500 )edit

the classic : -lopencv_core -lopencv_imgproc -lopencv_calib3d

I have no problem with -lopencv_core -lopencv_imgproc. I found a workaround, but I'm not happy: I compiled the 2.4.10 version. I would like to use opencv from repositories because it's easier for the users of my project.

So now I can use findHomography, but I have another problem. But more algorithmic this one ;)

If you want to take a look : http://answers.opencv.org/question/62...

Thank you

lock042 gravatar imagelock042 ( 2015-05-19 11:38:20 -0500 )edit

Hello, I am using opencv 2.4.13, does pixel based registration method work with this version? Please send/add codes if so.

Kabali gravatar imageKabali ( 2016-12-23 02:04:18 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2015-05-15 07:53:05 -0500

Seen: 902 times

Last updated: May 15 '15