Jump to content

Stray pixel remover

Recommended Posts

This plugin deletes small islands of pixels.

When I use the magic wand, some pixels aren't deleted. The plugin deletes them, if they are surrounded by transparent pixels. : sMSe2t0.png


It has two parameters :

- radius threshold : Delete island up to this size.

- alpha threshold : A pixel will be considered transparent up to this value. 


@toe_head2001 has recompiled this plugin to make it compatible with PDN 4.0+.







Original PDN 3.5.11 version: StrayPixelRemover.zip   <--- Incompatible with Paint.NET 4.x



  • Upvote 1
Link to comment
Share on other sites

PS: I can't upload DLL files so you have to rename the "StrayPixelRemover.txt" to "StrayPixelRemover.dll".

Zip them. A lot more people understand ZIP files than changing extensions, especially since Windows hides extensions by default.
  • Upvote 1


ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

It will auto remove if it finds a pixel to be surrounded by transparent pixels.  Making a selection will constrain the effect within the selection bounds.


@archip:  I'm going to take issue with the menu placement.  Misc?  To me, that's less than helpful.  Why not place it in the Object menu?  (as this operates on tiny pixel objects).

Link to comment
Share on other sites

  • 2 months later...
  • 3 years later...
On 11/30/2016 at 6:30 AM, Allan said:

I have tried installing this on Windows 10 and Windows 7 and in both in crashes paint.


I've updated the effect using the original source code provided by @archip in the first post.



- No longer crashes

- Faster and more efficient

- Works properly on non-rectangular selections


  • Upvote 5
Link to comment
Share on other sites

Thanks for the update toe_head. I've added your zip file to the first post.

Link to comment
Share on other sites

  • 3 months later...

As you wish - the new one you just updated.


Application version: paint.net 4.0.15 (Final 4.15.6309.42632)

Time of crash: 2017-04-13 2:41:49 PM

Application uptime: 00:01:23.0193871

Application state: Running

Working set: 206,276 KiB

Handles and threads: 1796 handles, 34 threads, 218 gdi, 248 user

Install directory: C:\Program Files\paint.net

Current directory: C:\Program Files\paint.net

OS Version: 10.0.14393.0 Workstation x64

.NET version: CLR 4.0.30319.42000 x64, FX 4.6

Processor: "Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz" @ ~3193MHz (4C/4T, DEP, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, XSAVE)

Physical memory: 8143 MB

Video card: NVIDIA GeForce GT 720 (v:10DE, d:1286, r:161), Microsoft Basic Render Driver (v:1414, d:8C, r:0)

Hardware acceleration: True (default: True)

UI animations: True

UI DPI: 96.00 dpi (1.00x scale)

UI theme: Aero/Aero + DWM (Aero.msstyles)

Updates: True, 2017-04-13

Locale: pdnr.c: en-US, hklm: en-US, hkcu: en-US, cc: en-CA, cuic: en-US




Exception details:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)

   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()

   at ExamplePropertyBased.StrayPixelsEffect.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length)

   at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98

   at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer`1 clipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 170

   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 150

   at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 142

   at PaintDotNet.Effects.EffectRendererWorkItemQueue.OnExecuteNextWorkItem() in D:\src\pdn\src\PaintDotNet\Effects\EffectRendererWorkItemQueue.cs:line 131

   at PaintDotNet.Threading.MultithreadedWorkItemDispatcher.WorkThreadProc(Object context) in D:\src\pdn\src\Core\Threading\MultithreadedWorkItemDispatcher.cs:line 512

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Threading.ThreadHelper.ThreadStart(Object obj)



Managed assemblies:

    mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 @ C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll

    PaintDotNet, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.exe

    PaintDotNet.Base, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.Base.dll

    WindowsBase, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll

    System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll

    System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll

    System.Drawing, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll

    PresentationFramework, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll

    PresentationCore, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll

    System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll

    PaintDotNet.Core, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.Core.dll

    PaintDotNet.SystemLayer, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.SystemLayer.dll

    PaintDotNet.Framework, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.Framework.dll

    PaintDotNet.Resources, Version=4.15.6309.42632, Culture=neutral, PublicKeyToken=null @ C:\Program Files\paint.net\PaintDotNet.Resources.dll



Link to comment
Share on other sites

That's an exception you'll see if your `List<T>` is modified (e.g. via `Add()` or `Remove()` etc.) at the same time as enumeration (like with a `foreach`).


So, basically, the use of this `List<T>` is being done without synchronization (locks).


This can be fixed in many ways. One hacky approach is to use `EffectFlags.SingleThreaded`.


Edit: darn, I forgot that this forum doesn't support Markup. Pretend all of my `things in ticks` are using a "code" font :) 

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html


Link to comment
Share on other sites

Nice. Thank you Toe-Head. I've updated the first post.

Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...