Live data from Hacker News

Page Dewarping

mzucker.github.io

31–40 of 75 posts

Re: Page Dewarping

#31
post #8

This is great! My wife is a music teacher and often scans sheet music so that it's more portable. She has been asking me for a while for something exactly like this. I'll have to tweak it to work on sheet music, since I imagine his methods to identify lines of text won't work for the music staff out of the box.

If she literally scans it with a scanner, why would it need dewarping? This is for when you use a digital camera on pages not lying flat.

If you have the option go for scanning.

Scans still benefit from cleanup, such as rotation and adjusting the levels (making everything near white perfectly white) and possibly manual cleanup (removal of specks of dust or the odd hair that was on the scanner).

Re: Page Dewarping

#32
post #8

This is great! My wife is a music teacher and often scans sheet music so that it's more portable. She has been asking me for a while for something exactly like this. I'll have to tweak it to work on sheet music, since I imagine his methods to identify lines of text won't work for the music staff out of the box.

If she literally scans it with a scanner, why would it need dewarping? This is for when you use a digital camera on pages not lying flat. If you have the option go for scanning. Scans still benefit from cleanup, such as rotation and adjusting the levels (making everything near white perfectly white) and possibly manual cleanup (removal of specks of dust or the odd hair that was on the scanner).

She scans it in a scanner, but the music is often in large books that don't lay completely flat, so you still see the warping near the binding.

Re: Page Dewarping

#33
post #23

Is using a curve whose end points are fixed to zero to model the warping accurate? I can't see a rationale for why the end points should both be 0.

The main rationale is removing redundant degrees of freedom -- since the page is allowed to rotate freely, the edges of the page can still move around plenty.

I see, so basically assume the two end points are at zero and there is some rotation accounting for the endpoint offset in real space.

It still doesn't seem fully accurate as I can imagine a non-rotated cubic curve with endpoints at an offset, but I assume your simplification works well enough.

Re: Page Dewarping

#34
it came in handy whenever a student emailed me their homework as a pile of JPEGs.

Gotta admire this guy's resourcefulness—and patience. If I were a professor, I'd probably just reject the assignment outright if a student sent me a bunch of photos from their smartphone in lieu of a PDF or a "proper" scan. :)

Re: Page Dewarping

#35
post #19
post #8

This is great! My wife is a music teacher and often scans sheet music so that it's more portable. She has been asking me for a while for something exactly like this. I'll have to tweak it to work on sheet music, since I imagine his methods to identify lines of text won't work for the music staff out of the box.

ScanTailor [1] also implements automatic dewarping and is overall great for scan postprocessing. [1] http://scantailor.org/

I used it for about 1000 pages I photographed with a DSLR. The automatic dewarping rarely worked for me, so I ended up doing it manually.

It likely didn't help that many of the pages were typed carbon copies or hand-written. For the former I had to put another piece of paper behind the page to prevent the next page from bleeding through.

That said, I managed to get the job done, though it took a couple of weeks. Next is to capture the metadata (author, date written, ...). There were a lot of one page letters in the documents I copied.

Would love to try out another tool that could read from the ScanTailor project file to get the page segmentation or even the warping I did manually to improve on the result.

Re: Page Dewarping

#36

This strikes close to home for me, because I've done this "by hand" quite a number of times, using some interactive Gimp filters, with very good results. I've been able to take a perspective photo of a curved page lying on a desk, get it almost perfectly straight, and threshold it to clean black and white or sharp gray scale. Here is my very quick and dirty manual job of the same example page: http://www.kylheku.com/…

Divide by blur is very crafty. Will have to give that a shot next time I have a similar need in Photoshop.

Re: Page Dewarping

#37
This is solid. I'm an engineer at Algorithmia, and this caught our attention as the sort of project we love to host as a service on our algorithm marketplace. We've already made note of it for our team to consider adding (thanks to the generous MIT license), but I wanted to reach out in case you'd rather add, own, and optionally monetize it on our platform yourself. Either way, this was a great read with impressive results.

Re: Page Dewarping

#38
post #10

Thanks for the feedback, everyone -- happy to answer questions here or in the Disqus comments on my blog.

I really enjoyed the article!

By the way, you mentioned using word boundaries in regexes to replace variable names. GNU Emacs regexes can actually include "symbol boundaries" (which are a little better for variable names than word boundaries), represented as "\_". Personally, I like using the "highlight-symbol" package, which provides the "highlight-symbol-query-replace" command to basically execute M-% for the symbol at point.

Re: Page Dewarping

#40
post #37

This is solid. I'm an engineer at Algorithmia, and this caught our attention as the sort of project we love to host as a service on our algorithm marketplace. We've already made note of it for our team to consider adding (thanks to the generous MIT license), but I wanted to reach out in case you'd rather add, own, and optionally monetize it on our platform yourself. Either way, this was a great read with impressive r…

[deleted]
Post reply on HN