1

I have 1000 1-bit images that feature lines of ~20 pixels width. However, there are sometimes small 1-pixel holes and frayed bits which create an issue when I vectorize the lines in a Geographic Information system. I attach 2 screenshots to show how this creates a problem in the vectorization.

So, I'd need to blur the image or smooth it some way that these 1-pixel gaps are filled without changing the image size. And I'm looking for a batch process because doing this by hand over 1000 times is not in my plans. I do have Photoshop and IrfanView installed.

I tried to blur and compress the images, but it was no good.

1-pixel hole frayed border

As per request, the result should look like this:

image 1 without hole. frayed borders - "landfilled"

3
  • Could you also please show the exact final result you're after? – Sergey Kritskiy Sep 7 '20 at 11:10
  • I've updated my original post accordingly. – Wernazuma Sep 7 '20 at 11:52
  • Salta n peppar noise plus tunnel cavities. The salt and peppar is easy just recursively delete picels that have a pixel on 3 sides. – joojaa Sep 7 '20 at 12:35
0

I assume that your 1-bit images are not scaled like the ones you post where each block is 10 pixels wide. I've taken one of your screenshots, scaled it down so every pixel is 1:1 and added a little more noise to remove.

I propose the following method in Photoshop:

  1. Convert the image from Bitmap mode to either Grayscale or RGB (to enable the use of filters).
  2. Choose Filter > Noise > Dust & Scratches.
  3. Set Radius to the wanted amount of smoothing.
  4. Press OK.
  5. Optionally convert the image back to Bitmap mode.

0

I thought it could be fun to make a Photoshop action for that. You can probably achieve this in different ways, here's what I did:

  • action first increases height of the canvas by 200px: this will be required for cases when red pixels touch top or bottom because I'm going to manipulate selections;
  • then it uses Magic Wand with 0 tolerance to select whites; inverts the selection; fills it with red and creates a new layer from selection: now I have all the red parts as a separate layer:

enter image description here

  • now action copies this base layer 4 times, each time moving it 5px down. The idea here is that top part of my duplicates now should overlap top part of the original layer. Here I made it black to undertsand it easier:

enter image description here

  • I obviously don't need the bottom part, so I load selection from the original layer, move it 40 pixels to bottom and clear selection:

enter image description here

  • now the action does the same for bottom part: several copies, load selection from original layer and move it, clear. The last part is to change the canvas back to original -200px size.

Result:

enter image description here

Action: https://www.dropbox.com/s/rmy4ug80xyh9u71/Set%202.atn?dl=1

Add a Save step to the action and it could be used in Batch (File > Automate > Batch)

3
  • You can do this with filter custom instead of copying – joojaa Sep 7 '20 at 13:44
  • @joojaa oh really? How? It's a bit like a dark magic to me – Sergey Kritskiy Sep 7 '20 at 18:04
  • Its just a array that says copy pixel value times x in pixel row so and so for every pixel. – joojaa Sep 7 '20 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.