Jump to content

Content Aware Fill (2020-09-10)

Recommended Posts

OMG!  ? This is AWESOME!! I couldn't believe how good this is.


To try it out, I cut a circle out of a reasonably complex scene. The two different replacements were created with different settings. Both are very believable!




Thanks so much @null54. This definitely goes into my "essentials" toolbox.

Link to post
Share on other sites

I managed to get an error that crashes PDN. Seems to occur for selections that include pixels along the bottom of the image; I didn't test other sides. It's an index out-of-range error. Details:


File: C:\Program Files\paint.net\Effects\ContentAwareFill.dll
      Name: ContentAwareFill.ContentAwareFillEffect
      Author: null54
      Copyright: Copyright © 2018 Nicholas Hayes (aka null54)
      Website: https://www.getpaint.net/redirect/plugins.html
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ContentAwareFill.Resynthesizer.PrepareNeighbors(Point position)
   at ContentAwareFill.Resynthesizer.Synthesize(Int32 pass, Func`1 abortCallback)
   at ContentAwareFill.Resynthesizer.ContentAwareFill(Func`1 abortCallback)
   at ContentAwareFill.ContentAwareFillEffect.OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs)
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 227
   --- End of inner exception stack trace ---
   at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 418
   at PaintDotNet.Menus.EffectMenuBase.DoEffect(Effect effect, EffectConfigToken token, PdnRegion selectedRegion, PdnRegion regionToRender, IRenderer`1 clipMaskRenderer, Surface originalSurface, Exception& exception) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 1556


Edited by Joshua Lamusga
Link to post
Share on other sites
2 hours ago, Joshua Lamusga said:

I managed to get an error that crashes PDN. Seems to occur for selections that include pixels along the bottom of the image; I didn't test other sides. It's an index out-of-range error.


That crash and the dialog tab order have been fixed in version 1.1.



  • Upvote 1
Link to post
Share on other sites
40 minutes ago, Zevel said:

Can you move the menu entry from "Photo" to "Selection"?




Changed the submenu from "Photo" to "Selection" and updated the PluginSupportInfo to point to the forum thread.

File version updated to



  • Like 4
  • Upvote 1
Link to post
Share on other sites
5 hours ago, Zevel said:

Can you move the menu entry from "Photo" to "Selection"?



I don't actually think this is a good idea.


All plugins work on selections.  But, the plugins in the selection submenu change their behavior based on the shape of the selection.*


This plugin doesn't do that.


I'd put it back in the photo menu as I think it is really designed for repairing photos.




*For example, outline selection draws an outline in the shape of the selection.

Link to post
Share on other sites

I think either Photo or Selection makes sense. This plugin depends on the selection in a way most plugins don't. In most plugins, the same thing occurs in the selected area as would occur if there were no selections at all. The selection merely restricts the region that's affected. In this plugin, the results are determined by the pixels on the selection boundary.

  • Upvote 1
Link to post
Share on other sites

I originally placed the plugin on the Photo menu because that was the location of BoltBait's Seam Carving plugin, which was the closest existing "content aware" plugin.

The purpose of this plugin is to replace the contents of a selection based on the pixels outside the selection.

Which as @Ego Eram Reputo's example above illustrates is useful for more than just photographs.


13 hours ago, BoltBait said:

All plugins work on selections. 


But as @MJW has noted most plugins do not require a selection to operate, and there are not many other categories to make that requirement clear to users.

Link to post
Share on other sites
  • 1 month later...

I recently switched over from PS to Paint.Net and I've been trying to get this content aware plugin to work. I'm not expecting the exact same results as PS, but I can't even come close...


I've been trying to remove the woman in the attached image as a test for the plugin and it's been horrendous results. Any tips? I'm using default plugin settings when when the selection > content aware window pops up.


Link to post
Share on other sites

1. Don't trust the defaults. The tiniest change in the sample size can have a big effect on the outcome, as does the selection itself.


The first try I had with your image used a sample size of 15. Redoing the selection + 15 looked awful. I had better results with 67.


2. Don't remove the object first. Take our time and select around it with care. Then run the plugin directly on the selected lady.


Your object in the image is taller than it is wide, so I'd select the refill from the sides. This will take the refill pixels from more horizontal offsets than vertical.


I tend to use Inwards fill. It just seems to be better at object removal.


So, try something like these settings:





In saying that, I don't think you're going to get a seamless result out of the box. You're going to have to do some manual fixing.

  • Like 2
Link to post
Share on other sites

Hi @Syn

Welcome to the Forum.

A fairly new plugin - but I believe I am getting the hang of it.

THe first step is to remove the area you need filled.

Then work with small areas to fill with the content you are looking for.

Just 15 minutes and I managed to provide this quick example.



More time spent will produce a better result. I should mention a directional blur was added to blend the colors better after the content aware fill.

I am sure this will get you pointed in the right direction. Any questions just ask.

@Ego Eram Reputo is much faster than I ?



  • Like 2
Link to post
Share on other sites
  • null54 changed the title to Content Aware Fill (2020-09-10)

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