Image Alignement issue in Opencv [closed]

asked 2014-07-28 05:04:38 -0600

rahulvg gravatar image

If I have two images

Image 1: Aligned properly http://i.imgur.com/ui6wTiJ.jpg Aligned properly

Image 2: Not aligned properly http://i.imgur.com/Z05ZfwR.jpg Not aligned properly

My algorithm compares two images but it needs both the images aligned properly. I was thinking of putting some unique marker at top-left corner but is there another way to align the images properly?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 01:13:32.415038

Comments

1

If your images will always be that clear there are some simple steps

 1. Binarize your image
 2. Apply Hough Line transform
 3. Look for the orientation of the longest lines, which are the sides of the page
 4. Rotate accordingly
StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-28 05:12:43 -0600 )edit

Please see picture http://i.imgur.com/ptGGTrB.png Hough Line returns me 28 lines and really its very hard to judge the longest line i.e it can be vertical or horizontal.

rahulvg gravatar imagerahulvg ( 2014-07-28 05:23:15 -0600 )edit

Did you use HoughLinesP? It has a better accuracy. Also you should apply a thinning algorithm to the detected edges. You want 1 pixel to remain!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-28 05:55:33 -0600 )edit

Yeah I used HoughLinesP.Maybe something wrong with the parameters?? cv::HoughLinesP(copiedImg, lines, 1, CV_PI / 180, 70, 30, 10);

rahulvg gravatar imagerahulvg ( 2014-07-28 06:02:35 -0600 )edit
1

Seems good to me, guess you will need a line thinning algorithm. Quick google should give you some hints.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-28 06:15:09 -0600 )edit
1

thinning algorithm is not working properly input :http://i.imgur.com/ui6wTiJ.jpg Output :http://i.imgur.com/BijtKNF.png

rahulvg gravatar imagerahulvg ( 2014-07-31 02:05:40 -0600 )edit

That is because you are running the thinning algorithm on your original input image! You should apply it in combination with my previous steps ofcourse. Apply the thinning algorithm on the output you supplied after my first suggestion.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-31 02:11:49 -0600 )edit