BoltBait

Remove Dust from Scanned Photos

Recommended Posts

So, I was scanning a ton of photographs today and kept having to do the same steps to remove dust from the images.

I automated it into a plugin.

Enjoy.

RemoveDustUI.png

 

 

// Name: Remove Dust
// Submenu: Photo
// Title: BoltBait's Remove Dust v4.0
// Author: BoltBait
// URL: http://BoltBait.com/pdn
// Desc: Remove dust from scanned photographs
// KeyWords: dust|stamp|scan|clone
#region UICode
byte Amount1 = 0; // [1] Dust Color|White|Black
#endregion

// Setup for using Lighten blend op
private BinaryPixelOp lightenOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Lighten);
// Setup for using Darken blend op
private BinaryPixelOp darkenOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Darken);

// Here is the main render loop function
unsafe void Render(Surface dst, Surface src, Rectangle rect)
{
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        ColorBgra* prevPtr = src.GetPointAddressUnchecked(rect.Left, y);
        ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y);
        ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y);
        for (int x = rect.Left; x < rect.Right; x++)
        {
            ColorBgra CurrentPixel;

            if (Amount1 == 0)
            {
                // Remove white dust
                CurrentPixel = darkenOp.Apply(*prevPtr, *srcPtr);
            }
            else
            {
                // Remove black dust
                CurrentPixel = lightenOp.Apply(*prevPtr, *srcPtr);
            }

            *dstPtr = CurrentPixel;
            
            prevPtr = srcPtr;
            srcPtr++;
            dstPtr++;
        }
    }
}
There is no UI. Just run it and the white dust specks are gone.

There is now a simple UI. Select White or Black and those color specks are gone!

It's not perfect. It only works on very small specks. Basically what it does is Clone Stamp them out.

Install the dll in the normal way. Then, restart Paint.NET and look in Effects > Photo > Remove Dust for the effect.

Download Here

For Paint.NET 3.5.11:

RemoveDust.zip

For Paint.NET 4.0:

http://forums.getpaint.net/index.php?/topic/28488-

I'm thinking "Plugin of the Year". Yes?

  • Upvote 4

Share this post


Link to post
Share on other sites

Must feel good to have a problem like that and just be able to knock out a plugin :(

Yeah, CodeLab is the best plugin ever.

Now, I can't speak for those who write canvas plugins, but I find that actually coding a plugin is the easy part. Coming up with the idea is the hard part.

In this case, I wrote it to save myself a ton of time.

Any time you find yourself doing the same steps multiple times, make a note of it. If you don't have the ability to code a plugin yourself, I'm sure someone would be able to automate those steps for you.*

And, thanks for the vote. :D

*Keeping in mind the limitations of the plugin system. ;)

Share this post


Link to post
Share on other sites
It makes me fatter?

Actually, I think its the pizza that does that. ;)

Share this post


Link to post
Share on other sites

For those of us interested in the development, but without asking anyone to reveal any "trade secrets" may I ask what toolkit was used to take the code above to compiled .dll?

 

Either way, one of the best, most useful plug-ins to any image management software I've seen anywhere.  THANK YOU !!!

Share this post


Link to post
Share on other sites

For those of us interested in the development, but without asking anyone to reveal any "trade secrets" may I ask what toolkit was used to take the code above to compiled .dll?

That would be CodeLab.

Share this post


Link to post
Share on other sites

^^ He's too modest. CodeLab is developed and maintained by @BoltBait (free to download, donations welcomed). Damned fine piece of kit it is too!

You'll find numerous excellent tutorials on BoltBait's website (link in his signature).

Share this post


Link to post
Share on other sites

This plug-in is great. I'm a total noob, but would it be hard for me to duplicate this to eliminate black dots?

Thanks. Here ya go...

// Name: Remove Black Dust
// Submenu: Photo
// Author: BoltBait
// URL: http://BoltBait.com/pdn
private UserBlendOps.LightenBlendOp lightenOp = new UserBlendOps.LightenBlendOp();
void Render(Surface dst, Surface src, Rectangle rect)
{
   for (int y = rect.Top; y < rect.Bottom; y++)
   {
      for (int x = rect.Left; x < rect.Right; x++)
      {
         ColorBgra CurrentPixel = src[x,y];
         if (x>0) CurrentPixel = src[x-1,y];
         CurrentPixel = lightenOp.Apply(src[x,y], CurrentPixel);
         dst[x,y] = CurrentPixel;
      }
   }
}

Share this post


Link to post
Share on other sites

I am a total novice with codeLab, I have read about it on your website BB, but I am at a loss with this code, when I open codeLab  how much of the script (code?) that is already there  do I remove before I insert the above code you have provided? I tried to copy / paste this but ended up with errors at different lines. The removal of black dots is a useful tool to have with some of my scans too. 

You may have a virtual hug (or a rep point) if you can help me please :D

Share this post


Link to post
Share on other sites

How to use a codelab script (including the one above)

1) Highlight the above code block and press Ctrl-C.

2) Run Paint.NET and open the graphic you want to modify.

3) Effects > Advanced > Codelab

4) In codelab, Edit > Select All

5) Edit > Paste

After a second the effect will compile and run. If you like the effect, click OK to keep the changes.

  • Upvote 1

Share this post


Link to post
Share on other sites

Hello. I am really interested in downloading BoltBaits "Remove Dust" plugin for Paint.net version 4.0.16 but cannot find the direct link for it. I clicked on the second link below (copied from top of this page), but I'm not able to find the actual zip file. Would somebody please point me to it?
Thank You so much.


Download Here

For Paint.NET 3.5.11:

RemoveDust.zip

For Paint.NET 4.0:

http://forums.getpaint.net/index.php?/topic/28488-

I'm thinking "Plugin of the Year". Yes?

Share this post


Link to post
Share on other sites
3 minutes ago, Major said:

Hello. I am really interested in downloading BoltBaits "Remove Dust" plugin for Paint.net version 4.0.16 but cannot find the direct link for it.

 

It's now part of his plugin pack:

 

Share this post


Link to post
Share on other sites
Just now, Major said:

Can I just select that particular plug in from the rest of the pack?

Yes, you can just select what you want. It won't force you to install everything contained in the pack.

Share this post


Link to post
Share on other sites
11 minutes ago, Major said:

If so, I'm still having trouble finding the actual download that is appropriate for my version 4.0.16

 

I gave you the correct link. It says "v4.0.6+". Notice the plus sign... meaning version 4.0.6 and later versions.

  • Upvote 1

Share this post


Link to post
Share on other sites

Well this kind of stinks. I went and downloaded BoltBaitPack46.zip and it was stopped in it's tracks by my Norton 360 Antivirus suite. The zipped executable no longer works. I highly doubt that this is malware of any kind, but even turning auto protect off, Norton still caught it while trying to download it again. If anybody is interested, I attached a print screen. :(

Boltbait.JPG

Share this post


Link to post
Share on other sites

Norton is well known for crying wolf. Disable Norton then download and install the plugin. Better yet, delete Norton entirely - your world will be better for it.

Share this post


Link to post
Share on other sites

You can restore the file if Norton deletes it. In the lower-right corner of the Norton file-warning window (in rather small letters), there's a Restore link. Click on it to restore the file Norton quarantined.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now