November 22, 2007
Using the Gimp to automate "cleaning" of scanned B&W images
Sometimes I play around with translating manga for fun. It doesn't really seem to get me much of anything except for lots of requests from punks to translate their favorite naruto doujinshi, but it is fun and relaxing with the bonus that I learn some cool casual Japanese.I like to translate with a program I wrote for manga translation that puts all the text in the bubbles and whatnot, so I need to have scans of the manga to work from. So sometimes I'll scan manga.
The problem is that the scanner I have now doesn't do a great job of getting nice clean images. I often use (when I'm not feeling too lazy) pnyxtr's scan cropping program and his great scan rotation program, but if you have nasty scans that doesn't help much.
Since I'm both poor and lazy, and have a small amount of moral fiber, I use The Gimp for my image-editing needs. The Gimp has a nice scripting interface using a kind of baby scheme, so I wrote a script that will take a grayscale image, run the despeckle filter on it, re-level the image so that whites are whiter and blacks are blacker, then resizes the image to a reasonable size and converts it to a fixed number of colors. That makes the straight scanner output look just dandy, if you choose proper values for the high and low thresholds, and also automates a lot of clicking that I would have to do otherwise.
So in the off chance that anyone is interested, here is a Gimp script that will do all of that. If you place it in your proper gimp script location - on Linux or Mac OSX that would be ~/.gimp-2.2/scripts/ (or possible ~/.gimp-2.0/scripts/), and on Windows if you use the version of Gimp that I am using you can look in its application folder for something like a share/scripts folder and drop it there. On your next start-up of the Gimp you should see a new Script entry "Manga->DarkenResize" that will pop up a dialog and ask you for some values, with reasonable defaults specified.
You can get the script here: mangaDarkenResize.scm
One thing that annoys me is that I still have to manually set each picture to "Greyscale" mode. I should be able to do this automatically, but I don't know much about the Gimp, so I'm punting on that for now. It is also possible to use the Gimp in a batch processing mode, which would be totally awesome, but I haven't had time to make that work with this script. If someone makes any headway on that area, please let me know.
Comments
Provide your email address when commenting and Gravatar will provide general portable avatars, and if you haven't signed up with them, a cute procedural avatar with their implementation of Shamus Young's Wavatars.Re: Using the Gimp to automate
Now I feel guilty for not finishing "Shouts of Nothingness" that I started a year and a half ago!
Posted 14 years, 3 months ago by Douglas • @ • • Reply
Re: Using the Gimp to automate
Posted 11 years, 11 months ago by egonist • • • Reply
Re: Using the Gimp to automate
Posted 11 years, 11 months ago by fugu • @ • www • Reply
Re: Using the Gimp to automate
Posted 11 years, 10 months ago by L • • • Reply
Re: Using the Gimp to automate
;; threshold values
(low_cutoff 65)
(high_cutoff 165)
and that works well for scans when I use my scanner default settings. Basically the higher you make low_cutoff the more white pixels you will have. The lower you make high_cutoff, the more black pixels you will have.
Since I have changed how I scan, I've written a few more versions of the script. Also:
For things that have lots of black that you might want to touch up by hand, try the Despeckle filter. Create a copy of the entire image, and despeckle with
Adaptive: off
Recursive: on
Radius: 3
Black Level: -1
White Level: 256
Put that layer on top. Layer modes that look good:
- Burn (Darkens stuff up, you can lose some lights that you might want)
- Overlay (Not as dark as burn)
- Darken only (Darkens a lot, but not as much as multiply.)
- Multiply (Really darkens things up a lot. More than Burn.)
- Soft light (makes lights lighter and darks darker, but leaves some annoying specks still)
It looks like this could be automated, but it really does darken up the image a lot. So maybe I will stick with just doing it by hand for some images for now. In general though, this would automate well.
Posted 11 years, 10 months ago by FuguTabetai • @ • www • Reply
Re: Using the Gimp to automate
Im an extremely newbie with this GIMP. Had it downloaded and installed yesterday only ('coz its FREE! ).
Im interested in learning on how to Clean Manga. And i want to try your automated script. But being i noob, i dont know how to install the script. Do i just copy your script and save it in *.ini format using a NotePad? If i had this done, how to i run it?
Please give me some advice.
Thanks.
- Jack -
:)
Posted 11 years, 2 months ago by Jack • @ • www • Reply
Re: Using the Gimp to automate
Hello again.
What i newbie i am. I had it figured it out!
He-he-he!
Im using windows. I had just right-clicked on your script link and saved it as it is (*.scm) under the following directory:
C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts
When i rebooted GIMP, i found the script under "Script-Fu".
I really runs very smoothly. So I'll just be cleaning the dialogs and sounds then. Thanks a lot.
- Jack -
Posted 11 years, 2 months ago by Jack • @ • www • Reply
Re: Using the Gimp to automate
I am having difficulty in getting your script to run on gimp 2.6.11 (i think that is there version I'm using). It appears with this message
Error: eval: unbound variable:
Any thoughts on how to fix this?
Thanks
Posted 10 years, 8 months ago by Tom • • • Reply
Re: Using the Gimp to automate
Posted 10 years, 8 months ago by fugu • @ • www • Reply
Re: Using the Gimp to automate
experience.first,open the scan,then go to color,choose brightness and
contrast and then move the contrast upward.that's it! and if u find out
anything just erase it.im new in using gimp so i dont know anything
Posted 10 years, 2 months ago by anon • • • Reply
Re: Using the Gimp to automate
Posted 10 years, 2 months ago by Anonymous • • • Reply
Re: Using the Gimp to automate
Posted 9 years, 9 months ago by stargood • • • Reply
Re: Using the Gimp to automate
Posted 9 years, 9 months ago by FuguTabetai • @ • www • Reply
Re: Using the Gimp to automate
Posted 9 years, 9 months ago by stargood • • • Reply
Comments have now been turned off for this post