New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Straighten Function #236

Closed
kscottz opened this Issue Oct 30, 2012 · 10 comments

Comments

Projects
None yet
4 participants
@kscottz
Contributor

kscottz commented Oct 30, 2012

Create a function that looks at the longest and strongest lines and sets them to be horizontal and vertical images. A good example would be scanning a business card at an arbitrary angle and the function would rotate it so the edges are horizontal and vertical.

@ghost ghost assigned kscottz Oct 30, 2012

@mfkaptan

This comment has been minimized.

Show comment
Hide comment
@mfkaptan

mfkaptan Apr 14, 2013

Contributor

Hi, is this issue still open?

Contributor

mfkaptan commented Apr 14, 2013

Hi, is this issue still open?

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 23, 2013

Contributor

@kscottz
So i tried it with around 50 images.
My original idea was to get the best possible rotation to get all the lines as straight as possible. But is there are lines at many orientations it will find a compromise. I think that's why you suggested using bins.

So I gave the bins idea a shot. The problem was if there are many small ( insignificant ) lines at an orientaion they will fill the bin more.

Instead of incrementing the bin by 1 for each line at that angle, I am incrementing by the length of the line, so that I can get length into consideration . I then pick the biggest bin and rotate to the average of angles of the lines in that bin. The problem still persists. Too many smaller lines tend to influence the rotation.

See the results here. I am drawing all the lines in the seected bins.

http://imgur.com/a/zRjSN

I am thinking of setting a threshold, like consider only the 'k' longest lines(taken from user).

Contributor

vighneshbirodkar commented Apr 23, 2013

@kscottz
So i tried it with around 50 images.
My original idea was to get the best possible rotation to get all the lines as straight as possible. But is there are lines at many orientations it will find a compromise. I think that's why you suggested using bins.

So I gave the bins idea a shot. The problem was if there are many small ( insignificant ) lines at an orientaion they will fill the bin more.

Instead of incrementing the bin by 1 for each line at that angle, I am incrementing by the length of the line, so that I can get length into consideration . I then pick the biggest bin and rotate to the average of angles of the lines in that bin. The problem still persists. Too many smaller lines tend to influence the rotation.

See the results here. I am drawing all the lines in the seected bins.

http://imgur.com/a/zRjSN

I am thinking of setting a threshold, like consider only the 'k' longest lines(taken from user).

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 23, 2013

Contributor

Side by Side album

http://imgur.com/a/R01vV

Contributor

vighneshbirodkar commented Apr 23, 2013

Side by Side album

http://imgur.com/a/R01vV

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 27, 2013

Contributor

@kscottz I added the feature you said, the code now tries to decide how to rotate ( vertical or horizontal ). I couldn't find any literature/projects that do exactly the same thing. I found some work on rotating documents and rotating knowing the original object. Also a few regarding rotating at right angles ( 90,180,270 ).

Let me know how you find this.
http://imgur.com/a/fap0V

Best of the lot
http://imgur.com/a/fap0V#32

It couldn't rotate all, it threw warnings on the images in which both sides are identical, since it couldn't find lines.

Contributor

vighneshbirodkar commented Apr 27, 2013

@kscottz I added the feature you said, the code now tries to decide how to rotate ( vertical or horizontal ). I couldn't find any literature/projects that do exactly the same thing. I found some work on rotating documents and rotating knowing the original object. Also a few regarding rotating at right angles ( 90,180,270 ).

Let me know how you find this.
http://imgur.com/a/fap0V

Best of the lot
http://imgur.com/a/fap0V#32

It couldn't rotate all, it threw warnings on the images in which both sides are identical, since it couldn't find lines.

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 29, 2013

Contributor

@kscottz Canny thresholds do the trick. Here are the results , no funny business going on . Have a look and tell me if I should send a pull .

http://imgur.com/a/aI4XQ

Contributor

vighneshbirodkar commented Apr 29, 2013

@kscottz Canny thresholds do the trick. Here are the results , no funny business going on . Have a look and tell me if I should send a pull .

http://imgur.com/a/aI4XQ

@kscottz

This comment has been minimized.

Show comment
Hide comment
@kscottz

kscottz Apr 29, 2013

Contributor

@vighneshbirodkar Send me the pull request so I can see the code. Looks good to me. See simple works :). Learn your zen of python.

Contributor

kscottz commented Apr 29, 2013

@vighneshbirodkar Send me the pull request so I can see the code. Looks good to me. See simple works :). Learn your zen of python.

@jayrambhia

This comment has been minimized.

Show comment
Hide comment
@jayrambhia

jayrambhia Apr 29, 2013

Contributor

Try this on titanic! :D

Contributor

jayrambhia commented Apr 29, 2013

Try this on titanic! :D

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 29, 2013

Contributor

For god's sake , it straightened the Leaning Tower, what more do you want ?

res

Got this with default parameters :D

Contributor

vighneshbirodkar commented Apr 29, 2013

For god's sake , it straightened the Leaning Tower, what more do you want ?

res

Got this with default parameters :D

@kscottz

This comment has been minimized.

Show comment
Hide comment
@kscottz

kscottz Apr 29, 2013

Contributor

pisa

COMPUTER VISION WILL SAVE THE WORLD!!!

Contributor

kscottz commented Apr 29, 2013

pisa

COMPUTER VISION WILL SAVE THE WORLD!!!

@vighneshbirodkar

This comment has been minimized.

Show comment
Hide comment
@vighneshbirodkar

vighneshbirodkar Apr 29, 2013

Contributor

I'll send the pull after sometime, complete with unit tests and use case example

Contributor

vighneshbirodkar commented Apr 29, 2013

I'll send the pull after sometime, complete with unit tests and use case example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment