What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Remove white dust/pixels from black area (1bit-BMP)


Phanto

New Member
Messages
2
Likes
0
Dear All,

I have a 1-bit black and white BMP image and want to remove white dust on every black zone.
I need a plugin/script because I have to batch process several files.

Tried "Filter / Noise / Dust&Scratches", but the algorithm affects also black dust on white areas, which I don't want.
(For those interested: the D&S functions like “the nail that stands out gets hammered”. It parses the image, NxN-pixels square at a time, searching some pixel that stands out, and hammer it down (or up) to align it to the crowd (actually, to the median value of the crowd)).

What I am searching for is a "seek and destroy" method: search every black zone for single white pixels, or say 3x3-pixels-white-zones or smaller, and fill it with black.

1bit-BW.gif
 
Last edited:

thebestcpu

Guru
Messages
2,994
Likes
2,760
Hi @Phanto
Your specificaitons are not 100% clear. In fact, I get the impression that it does not need to be 100% accurate.
I think it would help if you provided an image example and pointed out exactly what type of shapes you want to delete vs keep,
I lieu of that, I will describe a technique that may (or may not meet your needs). I demonstrate the before and after results for you to consider via a GIF annimation.
I wanted to point out that you image came across as an indexed color image and not a 1 bit B&W image. That is OK yet wanted to point out that my technique requires the image to be in grayscale and afterwards covereted to 1 bit mode if that is the end desired result.
To test the approach I duplicated the black field with white "stars/dirt" and inverted to verify that only the white small dust would be removed and not the small black dust in the large white field.
Here are the steps

- Select all white of the image with magic wand (other approaches would work as well) with contiguous and anti alias both turned off
- Shrink the selection by 2 pixels using Select > Modify > Contract and set to two pixels
- Expand the selection by 4 pixels using Select > Modify > Expand set to 4 pixels
- Invert the selection
- Fill the selection with solid black

The above approach can be put into a Photoshop Action for automation

It is not 100% perfect approach yet for images very similar to what you presented it may work well enough.

The end result is shown if the GIF below
Hope this gives you something to consider
John Wheeler

(NOTE - the image needs to be viewed at 100% for accurate viewing of what is removed since we are working at the pixel level

1bit-BW-animation.gif
 

Phanto

New Member
Messages
2
Likes
0
Thanks for your time John Wheeler.
I guess the "seek and destroy" method is a deadend, at least for this project:
Actually the treatment I was searching for is the last step for scanning and cleaning pen & ink drawings. And the drawings are pretty intricate: fine lines, cross-hatchings, bright and dark halftones.

Here's the result of your method, for two zones:

Zone1: very good result.
zone-1+.gif

Zone 2: we lose detail / it becomes dirtier
zone-2+.gif

The little white spots that spoils fine black zones, are the same that constitutes the normal "voids" of dark halftones.

Maybe there's a solution in the upstream treatments. I would appreciate if someone knows of a good method for scanning and cleaning pen & ink drawings.
Here's what I used:
Scanning in grayscale
Unsharp-Mask (500%, 1 pix, 2 levels)
Threshold(128)
Dust&Scratch(1 pix, 6 levels)

What actually introduces the undesirable white spots, is the Unsharp-Mask. What is meant to be plain black zones, are in fact in the paper dark gray, with litle brighter spots that the UnsharpMask will intensify.

I tried several combinations, but it amounted basically to two directions:
- Less white spots, but dark halftones that goes dirtier
- Very clean dark halftones (*), but a lot more white spots


(*) with the following:
Unsharp-Mask (145%, 4 pix, 3 levels)
Threshold(105)
Dust&Scratch(1 pix, 6 levels)
 

Top