archip

Stray pixel remover

Recommended Posts

UPDATED 08-06-13 : Now effect is applied only to the selection. The plugin is now in the Object Menu.

 

 

This plugin delete small island of pixel
 

 

When I use the magic wand, some pixels aren't deleted. The plugin delete them if they are surrounded by transparent pixel. : 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. 


 

Original PDN 3.5.11 version: StrayPixelRemover.zip

 

@toe_head2001 has recompiled this plugin to make it compatible with PDN 4.0+. Use this version in prefrence to the one above: StrayPixelRemover.zip

  • Upvote 2

Share this post


Link to post
Share on other sites

I would like to try this out, but for some reason my browser (both IE10 & Chrome) and my Avast internet security won't permit me to download the file ?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

This is looking interesting. Do you need to make a - selection - surrounding the stray pixel(s) or will this auto remove them for you?

Share this post


Link to post
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).

Share this post


Link to post
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.

Thank you EER. 

Share this post


Link to post
Share on other sites

For now, the effect is applied to the entire image, I'll change this when I find how. I'll also change the menu placement.

 

If you have suggestion post them and I'll see what I can do.

Share this post


Link to post
Share on other sites
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.

 

Fixes:

- No longer crashes

- Faster and more efficient

- Works properly on non-rectangular selections

 

  • Upvote 5

Share this post


Link to post
Share on other sites

I came back to this thread to confirm the crash and probable incompatibility with PDN 4.

Thank you toe_head. You fixed it in the time it took me to test it!

Share this post


Link to post
Share on other sites
16 minutes ago, AndrewDavid said:

First try and it crashed my paint. Crashlog sent to the usual email.

You used the updated release I made, or the original one for paint.net v3?

 

Post the crashlog here in this forum thread.

Share this post


Link to post
Share on other sites

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

Flags:

 

 

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=4.0.0.0, 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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll

    System.Core, Version=4.0.0.0, 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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll

    System.Drawing, Version=4.0.0.0, 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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 @ C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll

    PresentationCore, Version=4.0.0.0, 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=4.0.0.0, 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

Share this post


Link to post
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 :) 

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