Jump to content

Any good plugins from removing antialiasing artifacts from images?


Recommended Posts

To clarify what I mean: let's say I have an image like this, with a gray background:

G08j84r.png

 

I want to replace the gray background with a transparent one. However, because the original image was drawn with an antialiased brush, the edge of the image and the background blend together, so the magic wand tool isn't quite up to the task:

50sobyx.png

 

Now, with enough manual effort it's possible to hide these kinds of artifacts. (My current process is to create a silhouette of the image in the same color as the original edge, then use a plugin to antialias that silhouette, delete the areas overlapping with the original image, antialias it again, and delete the areas overlapping with the background.) But this is slow, and it tends to look ugly and blocky on close inspection. Ideally, I'd like some kind of plugin that I can run to easily replace the background color with transparency; I figure that, if the background is a single static color, there's some kind of algorithm you could run to just convert pixels of that color to transparency (and pixels somewhat-that-color to somewhat-transparent), right? Does a plugin along these lines exist?

Link to comment
Share on other sites

1 hour ago, BoltBait said:

Step 1: Install my plugin pack at https://forums.getpaint.net/BoltBaitPluginPack

 

Step 2: Magic wand the background (gray in your case) and delete it.

 

Step 3: Use my Effects > Object > Feather

I actually did install this plugin pack earlier today (good work on it, by the way, I appreciate the sheer diversity of tools here) but this specific tool isn't quite what I'm looking for. It directly erases pixels from the outside of the image, which is good for quick-fixes but runs into the problem of erasing thinner lines entirely or missing some sharp concave corners.

The Switch Grey to Alpha tool from the same plugin pack is *almost* what I'm after here, but the two problems there are that it it only fully works on pure white/black backgrounds (rather than other colors like blue or whatever) and that it affects the entire selected area indiscriminately (so, if it's a blue outline on a white background, the blue becomes partially transparent even at its bluest).

 

I guess the best way to phrase what I'm looking for is, like, a plugin that lets me designate one color as the "background" and a second color as "not the background", and then have the background color erased, the non-background color untouched, and colors between the two colors gradually get more or less transparent depending on which of the two they're closer to.

Link to comment
Share on other sites

Welcome onboard @Hitlinemoss :)

 

You try this too:

 

Go to this site to remove the background.

Load up the image and use AA's Assistant.

On your bottom layer add a color.

 

remove-background.png

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

32 minutes ago, Pixey said:

Welcome onboard @Hitlinemoss :)

 

You try this too:

 

Go to this site to remove the background.

Load up the image and use AA's Assistant.

On your bottom layer add a color.

This site seems to be doing roughly the same thing as the aforementioned Feather plugin (i.e, just erasing the pixels at the edge of the image). Which is still good for a quick fix, but with this thread I'm mostly just wondering if there's a more specialized plugin for this kind of thing that preserves the non-background pixels as accurately as possible.

Link to comment
Share on other sites

Not sure you are happy with this result, but this CodeLab script makes the pixel more transparent when pixel color is more closer to the primary color.
 

#region UICode
DoubleSliderControl threshold = 0.32; // [0,1] Threshold
#endregion

protected override void OnInitializeRenderInfo(IGpuImageEffectRenderInfo renderInfo) {
    renderInfo.ColorContext = GpuEffectColorContext.WorkingSpace;
    base.OnInitializeRenderInfo(renderInfo);
}

protected override IDeviceImage OnCreateOutput(IDeviceContext DC) {
    using var source = Environment.SourceImage.CreateRef();
    using var color  = new FloodEffect2(DC, (ColorRgba128Float)Environment.PrimaryColor);
    using var vector = new HlslBinaryOperatorEffect(DC, source, HlslBinaryOperator.Subtract, color);
    using var length = new HlslUnaryFunctionEffect(DC, HlslUnaryFunction.Length, vector);
    using var alpha  = new HlslBinaryOperatorEffect(DC, length, HlslBinaryOperator.Multiply, new Vector4Float((float)(1 / threshold)));
    using var clamp  = new HlslUnaryFunctionEffect(DC, HlslUnaryFunction.Saturate, alpha);
    using var output = new HlslBinaryOperatorEffect(DC, source, HlslBinaryOperator.Multiply, clamp);
    return output.CreateRef();
}

 

image.thumb.png.f6b67f7a0dc9d95a5b3a62e75e707ee4.png

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

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

Guest
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...