Ask Your Question
2

How to adjust a image as the empty image

asked 2017-08-13 22:32:36 -0600

yode gravatar image

updated 2017-08-16 14:07:01 -0600

Suppose I have a empty paper like this image

Then I write some text on the paper,but the result paper have been distorted,rotated and translated.like this image

How to adjust the result papper according the original empty paper? As you see,some empty transverse line can align this two images. The result(I get it by Photoshop) like this image is expected.

I want to use OpenCV to do this.Can anybody give a better solution for this?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-08-13 23:16:55 -0600

Ziri gravatar image

If you have 4 points as reference. You can use getPerspectiveTransform function to obtain transformation matrix , then apply this matrix using warpPerspective function .

edit flag offensive delete link more

Comments

I don't want to use manual participation.It show be automatically totaly.Because I should correct many many image by that empty paper

yode gravatar imageyode ( 2017-08-13 23:19:46 -0600 )edit

4 points are the corners of that page. you'll have to detect them automatically in image you want to adjust.

If not maybe you can use another reference ( maybe that MAXLEAF in the bottom of page).

Ziri gravatar imageZiri ( 2017-08-13 23:27:47 -0600 )edit
0

answered 2017-08-14 05:29:44 -0600

updated 2017-08-14 07:54:41 -0600

for a perfect solution take a look at this (have python source)

by the way i tried to improve the code used in my other answer and get the image below ( it is not perfect but maybe helpful )

you can find my trial C++ source code on github

image description

edit flag offensive delete link more

Comments

I am curious, What points you're using ?

Ziri gravatar imageZiri ( 2017-08-14 06:45:49 -0600 )edit
1

Thanks I will learn it,If I have confused about your code.I will ask you still

yode gravatar imageyode ( 2017-08-14 06:51:43 -0600 )edit

i edited the source a bit to show some steps to be easier to understand but i have no time to explain all the things. but i will try to answer some specific questions if needed.

sturkmen gravatar imagesturkmen ( 2017-08-14 07:20:00 -0600 )edit

Thank very much...

yode gravatar imageyode ( 2017-08-14 08:03:44 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-13 22:32:36 -0600

Seen: 534 times

Last updated: Aug 16 '17