Gimp-Forum.net
Selecting Large Amount of Small Specks - 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: Selecting Large Amount of Small Specks (/Thread-Selecting-Large-Amount-of-Small-Specks)



Selecting Large Amount of Small Specks - Gimpy222 - 02-22-2020

I have several hundred scanned pages I received as 1-bit images. The person that scanned them left a LOT of specks 1 to 10 pixels in diameter. To manually remove them will take weeks. Is there a script that will select all the specks and change them to background color and then save them as the same file name?

The text is rather bumpy, but I doubt there is anything that can be done with that.

Thanks Sandy


[attachment=3973]


RE: Selecting Large Amount of Small Specks - Ofnuts - 02-22-2020

  • Select the background color
  • Select>Grow by one pixel
  • Select>Shrink by one pixel
  • [Delete]



RE: Selecting Large Amount of Small Specks - rich2005 - 02-22-2020

Are you really using Gimp 2.8 ?

Quote:I have several hundred scanned pages I received as 1-bit images. The person that scanned them left a LOT of specks 1 to 10 pixels in diameter.

More than just a remove-speckle problem. Several hundred scans and 1 bit (black / white) images.

Several hundred, and the usual advice from the clever guys is "write a script" and apply in a batch file.

I am not that clever so I will use two Gimp plug-ins gimp-gmic to improve the scan  http://www.gmic.eu and BIMP  https://alessandrofrancesconi.it/projects/bimp/ for "several hundred" Both come with Windows installers.

Individually the workflow is 
convert the image to grayscale (for gmic)
apply the gmic repair scanned document filter.

I have gone a little step further and used a script to quickly apply the gmic filter. Attached gmic_shell.zip Unzip put gmic_shell.scm in C:\Users\"yourname"\.gimp-2.8\scripts

Then for several hundred apply that procedure using the plugin BIMP. 

The whole thing in 3 minutes https://youtu.be/hVE6pJXjF74





edit: add a pre-despeckle to the script for large speckles.


RE: Selecting Large Amount of Small Specks - denzjos - 02-22-2020

Rich2005, in your workflow you can also use (just a suggestion) :

- Filters / Blur / Gaussian Blur (value 4 - I dont know if one can change that in a batch ?)
- Filters / GMic-Qt / Black & White / Stamp

Result :

 [attachment=3977]


RE: Selecting Large Amount of Small Specks - Ofnuts - 02-22-2020

On Gimp 2.10, Filter>Blur>Median blur (with a small radius: 1 or 2px) is worth a try.


RE: Selecting Large Amount of Small Specks - Gimpy222 - 02-22-2020

Thanks All. I'm doing other things to each page, some color highlighting, underlining, etc., so batch editing won't be a big help.

Ofnuts, your Grow 1 pixel, Shrink 1 pixel, Delete works fine for my purpose. Looks good printed on my printer. Thanks

I'm using Gimp 2.8

How would I create a script or plugin in to do all of the following after I make background selection?


Select>Grow by one pixel
Select>Shrink by one pixel
[Delete]
Select>None
Image>Flatten Image
Image>Center Guides
Image>Mode>RGB


RE: Selecting Large Amount of Small Specks - Ofnuts - 02-24-2020

A small script. Adds a Gimpy222 menu to your image menubar. Several entries, for 1 to 5 pixels of grow-shrink.

I suggest you try a few values on the a first couple of images, then either you use Ctrl-F to replay the same filter all along, or you set a keyboard shortcut for the one you use often (seach for "gimpy222").

Have a look at my  ofn-file-next script to go from one image to the next if mass-editing.


RE: Selecting Large Amount of Small Specks - CtrlAltDel - 02-25-2020

[quote pid='16976' dateline='1582375566']
denzjos Wrote:Rich2005, in your workflow you can also use (just a suggestion) :

- Filters / Blur / Gaussian Blur (value 4 - I dont know if one can change that in a batch ?)
- Filters / GMic-Qt / Black & White / Stamp

Result :

These two steps worked great.  Thanks, denzjos.  I couldn't do anything with grow1, shrink1, delete, it just didn't seem to have any effect for me.  
 
[/quote]


RE: Selecting Large Amount of Small Specks - Gimpy222 - 02-25-2020

(02-24-2020, 04:06 PM)Ofnuts Wrote: A small script. Adds a Gimpy222 menu to your image menubar. Several entries, for 1 to 5 pixels of grow-shrink.

I suggest you try a few values on the a first couple of images, then either you use Ctrl-F to replay the same filter all along, or you set a keyboard shortcut for the one you use often (seach for "gimpy222").

Have a look at my  ofn-file-next script to go from one image to the next if mass-editing.

Perfect! Excellent! Thank you very much!