bootchk / resynthesizer

Suite of gimp plugins for texture synthesis
GNU General Public License v3.0
1.47k stars 163 forks source link

Additional choices for heal selection #39

Open kwokyinc opened 7 years ago

kwokyinc commented 7 years ago

Hi

First of all, thanks for maintaining this useful plugin.

Can I make an request for a simple additional feature? It would be great if "filling order" can allow 4 additional choices, namely "from left to right", from right to left", "from top to bottom" and "from bottom to top".

The reason is that when I apply "heal selection" to a selection which touches, say, the right border of the image, and under the "sample from = sides" and "filling order = inward towards center" options, the plugin would produce great result on the left half of the selection but bad result on the right half of the selection (i.e. the half close to the border). I figure if it had a "from left to right" filling order option, it would probably produce good result throughout the selection. Hopefully this feature can be implemented. Thanks a lot.

Cheers, Jim

bootchk commented 7 years ago

Thanks. I think I understand what you want. But I am not sure it will work. I might get a chance to try it, but it requires changes to the C code (a little more involved than if it were only to the Python wrapper.) Those are my initial thoughts, but it certainly is interesting, and I could be wrong.

The reason I think it might not work is: that would be like a wavefront algorithm. In my experience, the farther you get from where the wavefront starts, the less chance that the results will be good. I.E. the pixels in the center of the resynthesized border might not be good. It might work better if it was a three-sided wavefront from all the non-border edges.

Also, a better algorithm might be to copy/paste a section of the border from somewhere else onto the image outside the border (in a temporary image) and then heal from the sides, harvesting the copied sections of the border. That idea too might not always work. Possibly that could be done all in the Python wrapper. Any user can already do something similar by using the full control panel "Filter>Resynthesizer" which lets you choose a separate corpus, where in this case you would fabricate a separate corpus image from nearby sections of the border. Yes, it is tedious and your idea would save time.

Again, interesting, but I can't promise I will do it.

kwokyinc commented 7 years ago

Thanks for the tips! How come I never thought of expanding the canvas and fill it with a temporary image!! I just did that and filled the expanded area with something (anything would do coz it will be cropped eventually). Then I select an area covering both the area I want to patch and the expanded image such that the "original image border" falls roughly in the central line of the area of selection. Then I apply resynthesizer. Now it's magic. I get what I want. Then all I need to do it just to crop back the image to the original size.

It would still be nice to have the "from left to right" etc options. But if it's really a hassle to code such thing in C, then I guess the above workaround is good enough to do the trick. Thanks.

bootchk commented 7 years ago

Cool. I never thought of those details either, that it doesn't really matter what you fill the expanse with. That could be automated in a Python plugin. Called something like "Heal Selection On Border."

But I was wondering why, on the right edge, Heal "from top and bottom" doesn't work. I suppose your case is that top and bottom are sufficiently different from what is to the left that the result is not what you expect. I need to experiment more with various cases.

kwokyinc commented 7 years ago

I suppose your case is that top and bottom are sufficiently different from what is to the left that the result is not what you expect.

Yes. That is exactly my case.