Gimp-Forum.net
Flattening a scanned book - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Flattening a scanned book (/Thread-Flattening-a-scanned-book)

Pages: 1 2 3 4


Flattening a scanned book - antoni gual - 12-13-2023

Hello, this is my first post here.
Gimp 2.10.36 in windows 10 here
I'm trying to flatten some warped pages of a hastily scanned book. I have found the filter>distortion > bend along lines (sorry, translated from spanish menus) 
The problem is the book has a funny size of 1300 pixel wide x 3500 pixel tall. With this format, the preview is 1 cm wide in my screen, making the tool unusable. The image does'nt even cover the checkered box, and does'nt change when the dialog is resized.
Is there a way to increase the preview size? Or perhaps is there a tool in gimp more adapted to the job?
Cheers
Antoni

[attachment=10832]


RE: Flattening a scanned book - denzjos - 12-13-2023

Some solutions using gimp : https://graphicdesign.stackexchange.com/questions/136140/is-it-possible-to-uncurl-an-image-of-a-handwritten-book-page
Also : https://www.gimp-forum.net/Thread-How-to-flatten-a-curved-paper-photo?highlight=interactive+warp


RE: Flattening a scanned book - antoni gual - 12-13-2023

Hello denzjos.
Thanks for your prompt answer. It opens me to other options. It's sad to know that a smart phone can scan and unwarp in the same operation...
I have already tried the grid transform in the Gimp but it has the bad habit to warp the image laterally when i just want to stretch vertically. Perhaps i have not played enough with it.
It's a pity the filter that seems to me the best fit to the job is perhaps the only one that does'nt do a full scren preview!

I have found the G'MIC plugin at this thread https://www.gimp-forum.net/Thread-Distortion-along-a-curve
It has a Warp transform that looks promising...


RE: Flattening a scanned book - PixLab - 12-13-2023

For a not so distorted, and want to bring the curves inside, you might want to try Filters > Distorts > Lens Distortion...
The thing is we don't see your image, thus we can only speculate, post a sample of your image or a reduction, and you will have real solutions


RE: Flattening a scanned book - antoni gual - 12-13-2023

(12-13-2023, 02:18 PM)PixLab Wrote: For a not so distorted, and want to bring the curves inside, you might want to try Filters > Distorts >  Lens Distortion...
The thing is we don't see your image, thus we can only speculate, post a sample of your image or a reduction, and you will have real solutions
Hi PixLab
I attach a sample of the worst warped pages. What would you do? I get lost at teh number of options thr Gimp offers...

[attachment=10841]


RE: Flattening a scanned book - PixLab - 12-14-2023

(12-13-2023, 09:27 PM)antoni gual Wrote: Hi PixLab
I attach a sample of the worst warped pages. What would you do? I get lost at teh number of options thr Gimp offers...

Oh... OK, now I see, big deformation here...

Did you tried with the Cage Transform tool, little block by little block at a time? It's a bit cumbersome -> takes some time, but you get to have the full view on the canvas, there is also an advantage to this method is to add Guides, thus you can refer to the guides to straighten your text.
La documentacion (en español Wink ) --> https://docs.gimp.org/es/gimp-tool-cage.html

[attachment=10849]

Or the G'MIC, Filters > G'MIC_Qt > Deformations > Warp [Interactive]? It's quite nice and faster than the Cage Transform as you can add points/nodes live anywhere on the whole image (best directly on the text or surrounding to affect those parts) ->  with a live preview (you can increase the window size)

[attachment=10848]

Or I would use Krita with its Mesh transform tool, because the "Mesh transform" is very user friendly.

[attachment=10847]

Or you can try the Ofnuts plugin flatten cylinder on the right side of the scan and manually do the left side, or ask Ofnuts if he does not have something similar for this case, that would take NO TIME to do it

@ Ofnuts that would be a great idea to have an "ofn flatten book" plugin  Big Grin


RE: Flattening a scanned book - rich2005 - 12-14-2023

(12-13-2023, 10:38 AM)antoni gual Wrote: The problem is the book has a funny size of 1300 pixel wide x 3500 pixel tall. With this format, the preview is 1 cm wide in my screen, making the tool unusable. The image does'nt even cover the checkered box, and does'nt change when the dialog is resized.
Is there a way to increase the preview size? Or perhaps is there a tool in gimp more adapted to the job?

There is an old script by RobA that uses two paths and the Gimp curve-bend plugin.
The RobA site is gone, you can find via the Internet Archive. To save the hassle the script ra_curve-bend-between-paths.scm is attached.  Unzip and put in your Gimp users scripts folder C:\Users\"yourname"\AppData\Roaming\GIMP\2.10\scripts

Needs a top and a bottom path following the curve. There is a maximum of 17 path nodes.  Never going to be great with the example.

[attachment=10852]

And as a 3 minute video: https://youtu.be/fOX5p5tMt6c






RE: Flattening a scanned book - antoni gual - 12-14-2023

Thanks PixLab. I will need several hours to check all the options you suggested !!


RE: Flattening a scanned book - denzjos - 12-14-2023

Just as information : the only plugin I know that actually does the job well is a plugin for Photoshop and I never found a similar program like this one: Altostorm Panorama Corrector 2.2. It's an old one and I can't find a link to the original site. I found this but I don't think it's a legal site (so excuse me if it is): https://altostorm-panorama-corrector.software.informer.com/2.2/
Here's the corrected page as an example what is possible :
[attachment=10858]


RE: Flattening a scanned book - Krikor - 12-14-2023

Hello rich2005,

Just yesterday I had coincidentally downloaded this same plugin and tried to use it with no luck.

I downloaded it from https://www.gimpscripts.net/ inside a package with several other zipped plugins.

After several unsuccessful attempts, I uninstalled the plugin and deleted it from the PC.
But now seeing how you used it, making several nodes instead of the just two that I made for each path, I'm going to download, install and test this plugin again.

If it works, it's definitely a very useful feature for Gimp.

Thanks for the explanatory video!

==================================================

PS:

I installed and tried to use the script.
On the first run, it generates an error window and does nothing.
When clicking CTRL+F (Repeat Last), on the second attempt, error messages are repeated again in the Error Console window.
But the third time, again just clicking CTRL+F, the script does not generate any error and correctly performs the image distortion.

I repeated the steps above a few times, and without understanding why the script was executed only after the third attempt via ctrl+F.

But I couldn't continue the experiments because my Gimp simply closed out of nowhere, displaying the Gimp Crash Debug window.

Something a little paranormal. Perhaps this script needs to be exorcised, blessed or left in the care of a shaman.  Dodgy

[attachment=10860]