Jump to content

Request: Selection Blur


Recommended Posts

Hello everyone.

Recently I had massive problems with the Gaussian Blur when I used it on selections. The point is that it blurs only the selection, of course, but uses the entire (not selected) picture as source for the image modification.

Here are some simple examples as demonstration:

baseabyd3.png

The selection:

abselectionqi1.png

And now the problem:

erroruw0.png

See the red color of our B coming in? That's the point! In this case it looks rather harmless, but when used with complex pictures it creates rather nasty things.

invaderb7.png

As you can see, darkness is invading the selection, created by the not selected part of the picture. :cry:

I tried to copy the selection and to paste it in a new layer and then running the blur on it, but in every case the surrounding alpha was now the problem. The funny thing was that the blur got weaker when I increased the blur value (because of he alpha).

What I want is just a "Gaussian Blur +", which, as you can imagine, uses only the current selection as base. I think this is possible, as MadJik did such a thing for his Twistz effect on request (viewtopic.php?f=16&t=20508&start=0; thanks again MadJik). Also I think it would not be that complicated as you can build the effect using the normal Gaussian Blur source.

For me, code usable with codelab is fine enough. I would really be glad to get this thing working. Thanks in advance. :)

Link to comment
Share on other sites

Effect selection is only meant to define a clipping area for output, nothing else. Like BoltBait said, just move it to another layer as a better way to control what is used for input.

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

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

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Can't you just copy your selection to a new layer and blur that?

Then I get trouble with the alpha around the selection in the new layer...

@Blooper: I'll give it a try.

Thank you all for your replies. I thought it would be easy to code such a think. To be precise, I don't need Gaussian blur I only need blur. Code that blurs the selection is enough, as long it is bound to the selected part.

Well, I don't think I'll get something ( :cry: ) and if I would be able to do it myself I would do it. If anybody is so kind and has the time to write some code at least for testing, you can PM me or publish it here.

Link to comment
Share on other sites

Can't you just copy your selection to a new layer and blur that?

Then I get trouble with the alpha around the selection in the new layer...

But you'd have the same problem if Paint.NET only used the input from the selection area; it'd have to treat the other pixels as something. Besides, if you just copy it to the next layer (instead of cutting), the alpha pixels will show the color from below anyway.

Paint.NET can't just decide what you want to blur, eliminate what you don't, and "make up" the rest.

Well, not yet. Although, the way things are going, I wouldn't be surprised if it were in 5.0....:-)

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

The antialias plugin recreates the pixels in contact with fully transparent as an outline. That works just as well as selection blur. Making a plugin that combines both of these wouldn't be such a pain, I bet. Anti-alias may also be a good start for bevels *has started on the Iron Browse icon for MSC entry*

Link to comment
Share on other sites

Here's what I do if I just was a certain part of an image blurred without the colors bleeding...(This would work with your second example, not your first)

First I duplicate my layer. Then on the top layer I Lasso an area slightly smaller than area I actually want to blur. Invert the selection. Use the Transparency adjustment to make the area around my original selection, um...transparent :). Deselect. Use BB's Chanel Blur to blend my the top layer's alpha values; 5-10px should be ok. Now I can blur to my hearts content.

Sans the last blurring step, this method works great for face mutations/replacements (e.g., moving facial features around, or face swapping)...

(I was going to post an example of something I've done, but the subject is someone I work with who hasn't seen it yet...and I still need this job :()

 

Take responsibility for your own intelligence. ;) -Rick Brewster

Link to comment
Share on other sites

I'm not a programmer, but I can tell you this much: Doing an effect strictly within the selection would take quite a while to code, it would be hard to implement, and such a feature would take up loads of RAM (I'm pretty sure).

@BB: Yeah, this reminds me of the time I came across the Gaussian theorem on Wiki... ouch.

2-dimensional Gaussian function:

a6a6a2035bffacfcd7c27214c00b2f22.png

[matrix]

53f022c87448b5afdf1062ec965f4db7.png

"The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound

twtr | dA | tmblr | yt | fb

Link to comment
Share on other sites

@ Fishermans Friend.

If you select what you want blurred then decrease the selection you should end up with satisfactory results. :)

dA

Son, someday you will make a girl happy for a short period of time. Then she'll leave you & be with men that are ten times

better than you can imagine. These men are called musicians. :D

Link to comment
Share on other sites

@ Fishermans Friend.

If you select what you want blurred then decrease the selection you should end up with satisfactory results. :)

Sure? I think the other image parts will still "disturb" the selected areas (?).

At the moment I'm tired and had a lot of work today. As soon as possible I'll try to make a workaround, based on all suggestions (thank you all very much). Maybe scriptlab will be useful, it would allow to save the steps so that you haven't to repeat them all every time. I'll see what the next days will bring.

Link to comment
Share on other sites

But this can't be done, can it? Paint.NET has to have some pixels from somewhere to do the blur; if it's not the pixels on the outside of the selection, it's the transparent pixels you want to replace it with. I don't understand how you would like this to work.

See, if it only blurs using what is in the selection area, it takes the transparent pixels to make the blur work.

whatyouget.png

It's just like if you had selected it, Ctrl+X, Ctrl+Shift+V, and then run the blur. Notice the transparency that has appeared? Since Paint.NET can't distinguish between the selected object and the background, it has to assume that you want transparent pixels in lieu of others to run the Gaussian blur algorithm on. (Open this image in PdN to see the transparency a little better)

This is what you'll get if you Ctrl+C, Ctrl+Shift+V, and then run the blur.

whatyouwant.png

I think this is more like what you want.

Or maybe I'm not understanding at all.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

I think this is more like what you want.

If both of us aren't totally misunderstanding, this is very close to what I want. I will try to test this until tomorrow.

Yeah, I was wondering if useful Scriptlabs could be posted into a topic in Plug-ins.

There should be something like this. Also for Shape3D, Curves+ and Gradient Mapping. I think we really need this.

Link to comment
Share on other sites

OK, I tried everything. "Back to the roots" for the start.

This is the picure, the X should be blurred.

baseev2.png

This is the selection:

selectionob3.png

This is Gaussian Blur (as example) used with value 27:

blurls8.png

The red part of the picture which is outside the selection interferes and makes it impossible to blur the selection in the way I want and need (note that this is only an example to show the problem!).

With 200 % saturation to make it clear. I want to get rid of the red (the red that is now in the blurred area):

saturationcz9.png

Now again with David's workaround (Crtl+C, Crtl+Shift+V):

davidsworkaroundyo9.png

Now I don' get red parts, I get alpha coming ins my selection and destroying the blur. The alpha (=transparency) around the selection in the new layer is the reason why the blur gets weaker. Maybe the problem can be solved by increasing the selection before you copy and paste it, and then running a blur with a massive amount.

@Blooper: In all the was I tried your suggestion, I didn't get the desired results. And fast blur is still not intended for selections, as far as I know. I haven't made pics for these cases, as they don't differ that much or too much from the pictures above.

@barkbark00: Using your solution, you get the thing the other way around, meaning you get the black inside the red.

barkbarkyq0.png

And the blur isn't a blur anymore, almost.

The point is that I want to get rid of certain, ugly spots inside a picture. I tried to select the area and to blur it, but as long as other image parts are comming inside the selection when you blur, I can`t remove these spots. I'll get the parst around the selection inside, making the selected areas uglier than before the blur.

At the moment I'm looking for workaround myself which may include to prepare the image part before and then paste it the original pic, or blending it with gradients. If any of these ways will succeed, it will be a lot of work every time and it'll be impossible to do a scriptlab, as the steps will be different each time. Still code or a plugin are highly appreciated.

To try to explain this issue further, an example: You get a picture of the Tokyo Tower from the internet, but it was to high compressed and now has errors (I don't want to hear "surface blur", this is an example for such ugly spots, and please believe me I tried surface blur often enough in various settings; also please tell me not to use clone stamp, it might work in this case, but in the cases I had problems, at the moment they can't be reproduced).

ttey3.png

Back again, you want to erase the errors wth Gaussian Blur (or any other blur).

Note: With certain values it works. This time. I say again that this is an example and you can imagine that in 90 % of the cases it is not that easy like here with the blue sky on the one site and the antenna on the other. And it is rather unusual that I fix pictures of the antenna of the Tokyo Tower.

tt2le7.png

BRRRRR!

Again, I would normally never use a blur in such a case, this is a demo to show the effect. Of course the antenna was not selected (but you'll get the red).

Please excuse me for mistakes in the text, but it is rather long and I don't want to read it again and again. I think you understand what's meant. Also I'm sorry for large pngs, but I had to make sure that jpeg doesn't "blur" the images itself. Thanks for reading.

Link to comment
Share on other sites

Try this,

Select area, use Gaussian Blur at a very low value, then repeat many time.

Keep in mind different case calls for different method.

Like what BB said use use Median Blur in that case.

I some times use motion blur when in cases that Gaussian blur doesn't work well.

The_next_thousand_words_by_0_ASH_0.png

All creations Ash + Paint.NET [ Googlepage | deviantArt | Club PDN | PDN Fan ]

Link to comment
Share on other sites

Try this,

Select area, use Gaussian Blur at a very low value, then repeat many time.

This is excellent advice.

I had forgotten, but according to Wiki, "Applying multiple, successive gaussian blurs to an image has the same effect as applying a single, larger gaussian blur, whose radius is the square root of the sum of the squares of the blur radii that were actually applied."

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

Try this,

Select area, use Gaussian Blur at a very low value, then repeat many time.

This is excellent advice.

I had forgotten, but according to Wiki, "Applying multiple, successive gaussian blurs to an image has the same effect as applying a single, larger gaussian blur, whose radius is the square root of the sum of the squares of the blur radii that were actually applied."

You have yourself to thank.

I tested and gave the answer because I remember one post you answered from a while back. :wink:

"Applying multiple, successive gaussian blurs to an image has the same effect as applying a single, larger gaussian blur"

The_next_thousand_words_by_0_ASH_0.png

All creations Ash + Paint.NET [ Googlepage | deviantArt | Club PDN | PDN Fan ]

Link to comment
Share on other sites

FF- I just don't understand where you want Paint.NET to come up with the pixels. They flat don't exist in the source image; how can it blur with them? I'm really confused. :-/

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

BB, I tried to emphasize that the antenna was only a bad example to show the system. However, thanks. Ash, your idea makes sense. I'll check it. To both of you, many thanks and continue your good work.

David, what do you mean? Which pixels? I don't want to use the pixels which aren't selected, that's the reason I made the thread. I want that only the selection is blurred but without influence of anything around it.

Link to comment
Share on other sites

But the way Gaussian Blur's algorithm works, it needs those pixels. That's why it calls them from outside the selection.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

But the way Gaussian Blur's algorithm works, it needs those pixels. That's why it calls them from outside the selection.

Of course. And this seduced me to request a plugin that works not so. But as usual you get rather tutorials than plugins for requests, and know I think Ash's idea could be really helpful, and you could save the low value steps with sciptlab...

Link to comment
Share on other sites

Ah! I think I understand now. :-) My apologies.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

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.

 Share

×
×
  • Create New...