ScanTailor-Advanced / scantailor-advanced

ScanTailor Advanced is the version that merges the features of the ScanTailor Featured and ScanTailor Enhanced versions, brings new ones and fixes.
GNU General Public License v3.0
194 stars 8 forks source link

Perspective correction tool #28

Open ghost opened 1 year ago

ghost commented 1 year ago

sometimes when you want to scan something, the pictures are not square, and that causes lots of issues with detect content. i suggest that we have a tool similar to GIMP's perspective tool to correct for it.

is this still maintained @vigri ?

(Same as https://github.com/4lex4/scantailor-advanced/issues/4 and https://github.com/trufanov-nok/scantailor-universal/issues/67)

darnn commented 1 year ago

I suspect this may be beyond the scope of ScanTailor in general, especially since, as you've pointed out, there are other programs that already do this. Also, this is not dissimilar to what dewarping does at the output stage.

ghost commented 1 year ago

@darnn I don't think that it's beyond the scope of ScanTailor because, as I already said, non-square images and detect content get along badly, mainly because the detect content tool does not allow free-from selection, only square.

While it is true that you may use other tools like GIMP but perspective issues usually apply to every page and I don't think GIMP perspective tool has batch processing, besides, as you already said, it's basically moving the dewarping to the preprocessing phase.

darnn commented 1 year ago

Maybe I'm not quite understanding you, then. What do you mean when you say that you scan something and pictures aren't square? Is there a specific example of a scan you can link (or upload)?

ghost commented 1 year ago

@darnn No, I do not have any examples that I can upload albeit, it's very easy to see the effect by taking a document, capturing a picture at an odd angle and give the picture to scan tailor.

darnn commented 1 year ago

Okay, I think that makes it a bit clearer at least: You're talking about using a camera, rather than a scanner? Because I do believe that in most situations where people use cameras, they have some kind of line-straightening process (or what have you) that they apply before they start things like binarization. But I admit I have limited experience with that. Anyway, this is all mostly academic, since as far as I understand, this repository mostly exists to have a functional build of the latest version of STA, and there aren't many additions planned, much as I would like some myself. But hey, shoot your shot.

ghost commented 1 year ago

Yes, I'm talking about using a camera, using a scanner with ScanTailor doesn't seem to have much sense to me because the scanner already does processing and Scan Tailor is usually not needed.

darnn commented 1 year ago

None of the scanners I've had have done processing nearly as well as ScanTailor... right now I have a copier, which is great for speed but not in any other regard, so I at least definitely do need it for scans, but I see what you mean. Are you using CHDK or anything like that, or just taking photos by hand?

ghost commented 1 year ago

I take pictures by hand, with a tripod and with manual trigger. It's not perfect but my camera doesn't have support for CHDK. If the perspective is not perfect, it's very hard or sometimes impossible to crop and select the content.

darnn commented 1 year ago

Ah. Well, the only thing I can suggest is, you can try to replicate the flattening of the page by the scanner by pressing the book down using a large glass pane. I've used my phone to "scan" a few books this way, and it was much easier with the glass pane than trying to hold them open (and straight) by hand. Though of course then you get issues like glare, but I find that it's mostly okay if you figure out the proper angles. For instance, here's a not-quite-straight image from when I was holding the book open myself (taken by vFlat, which does some processing and straightening of its own): 20210202_203600000_ - Copy

And here's one (also taken using vFlat) with a glass pane: 20210310_150540000_ - Copy

As you can see, still not totally straight, but much better. And there's no glare since I worked out the angle ahead of time.

In any case, if you're planning on digitizing many books over time, I really recommend looking into a cheap second-hand copier with scanning capabilities. I cannot overstate what a huge difference it makes in terms of effort and speed.

ghost commented 1 year ago

@darnn This is the scanner i use: https://www.instructables.com/Bargain-Price-Book-Scanner-From-A-Cardboard-Box/

As you can see it's just made from cardboard, but getting the camera aligned properly is very hard, unfortunately, better DIY scanners cost around 200$ which is expensive. This is why a perspective correction tool would be very very helpful for this cases.

darnn commented 1 year ago

Ah, well, if that's your price range, then yes, I think this might be a good compromise. Anyway, if I had to do this to a large number of images, I would find some way of obtaining Photoshop, since it does have a batch mode. And GIMP does have a batch plugin of some sort (BIMP or something), though I admit I haven't tried it. The quick and dirty thing I use for this is YASW: https://sourceforge.net/projects/yascanw/ But as you can see, it's both old and fairly rudimentary. It does seem like it was created for your exact purpose, though, so that's something.