Selections and Gaussian blur

Started Aug 27, 2018 | Discussions
Eliot Kramer Contributing Member • Posts: 998
Selections and Gaussian blur

Hello.

I am noticing a behavior that is not consistent and I would like to be able to control it.

Here is the setup.

Sometimes, when I make a selection and use a Gaussian blur or similar filter on that selection it will take the pixels outside the selection and average/blur them in, so that the selection is contaminated, when in fact the reason I made a selection is to apply the filter only "inside".

Same happens in reverse, sometimes it will take pixels from inside the selection and smudge them out.

Then finally, and this is what I am trying to do, I would like the effect to be confined entirely inside the selection and not involve outside pixels. This has happened to me occasionally but I don't know why or how, it just worked "perfectly" the way I wanted to.

As of right now I make a selection, blur it out, it gets contaminated, then I erase it back carefully to get rid of the contaminating effects, then repeat on a smaller area if there is still clean up necessary. This is super slow and tedious.

BTW, my PS is possessed so it does things on its own sometimes so it has behaved differently at times without me knowing exactly what I did.

Thank you

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
JohnWheeler Regular Member • Posts: 403
Re: Selections and Gaussian blur
5

Hi Eliot

Here is one way to get the blur as if only applied to the pixels inside the selection

1) Duplicate the original image to the Layer above

2) In this new Layer select the area you wish to blur

3) Invert this selection (Shift+Cmd+I or Shift+Ctrl+I on PCs) and do a content aware fill of the area outside the original selection  (Edit>Fill.......)

4) Invert the selection again so it goes back to the original selection

5) Apply Gaussian Blur directly to pixels or convert to Smart Object first before blur so you can go back and adjust as desired easily

6) Convert selection to Layer Mask so the blur only applies to selection area in the Layer below.

7) Optionally merge down to have it revert to a single Layer (yet this makes it harder to go back and fine tune your edits)

This may not work perfectly for all conditions yet I believe it should improve your success rate.  Hope it helps some.

-- hide signature --

John Wheeler

Sailor Blue
Sailor Blue Forum Pro • Posts: 14,909
Re: Selections and Gaussian blur
4

If you are using the Rectangular, etc. tools or the Lasso, etc. tools then make sure the Feather control is set to 0 (zero).

If you are using the Quick Selection Tool, etc. then make sure the Brush Hardness is set to 100%.

-- hide signature --

Living and loving it in Pattaya, Thailand. Canon 7D - See the gear list for the rest.

 Sailor Blue's gear list:Sailor Blue's gear list
Fujifilm FinePix Real 3D W3 Canon EOS 7D Canon EOS 5DS R Tamron SP AF 90mm F/2.8 Di Macro Canon EF 70-200mm F4L IS USM +9 more
richardplondon
richardplondon Forum Pro • Posts: 10,894
Re: Selections and Gaussian blur

I assume your goal is to take a hard-edged selection, and then soften the boundary of the selection? Ensuring only pixels fully inside the first selection, are going to be affected, leaving out an "edge" of part selected pixels?

(assuming Photoshop) one way to take off just the hard edges of this selection - without straying outside of that - would be to use Selection / Modify / Contract by (say) 2 pixels. Then use Selection / Modify / Feather by (say) 2 pixels.

Another approach could be to copy the selection onto a fresh layer / layer mask / alpha channel, select contents of this, and then feather that selection, invert selection and delete to black.

Personally, I tend to find that varying levels of softness are required for different parts of a selection's boundary, if it is to "sit in" naturally.

So I find myself using a combination of high or low tech methods, not being too proud to simply paint onto a layer mask in one or another blending mode. For example: when compositing layers one may make a "maximal" extraction first, which is often hard edged, onto a different layer. Then one can nondestructively soften and tighten the boundary of this layer's contents using a layer mask, painting in black with a feathered brush - or developing the edge further using Overlay blending mode in either black or white - according to the nuances of the real world edge transitions (rounded or sharp, translucent or opaque, more or less in focus) that are seen within the subject.

 richardplondon's gear list:richardplondon's gear list
Panasonic LX10 Pentax K-5 Pentax smc DA 21mm F3.2 AL Limited Pentax smc DA 35mm F2.8 Macro Limited Pentax smc DA 70mm F2.4 AL Limited +7 more
OP Eliot Kramer Contributing Member • Posts: 998
Re: Selections and Gaussian blur

Seems I wasn't fully clear with what I want and am getting a bit of a mixed bag of responses.

Here is what I am after.

1. Make a selection.

2. Blur INSIDE the selection.

3. Have ONLY the pixels inside the selection contribute to the blur and NOT the pixels from outside the selection.

Here is an example.

I have a dark skin model standing next to a white wall and the wall has a smudge that is close to them. I select the wall part all the way UP to the model's skin. Now the smudge and wall are inside the selection, the model and the rest are outside.

When I apply blur to the selection the pixels from the model get pulled in and blurred together with the pixels inside the selection and so now you have another smudge, but now coming from the model so I am back to the situation of having a smudge next to the person and not a clean wall.

However, a few times it happened as I was hoping it would, only pixels inside the selection were blurred but I don't know why or how since I didn't do anything different.

I can still do what I want to do but it is tedious and I have to repeat the clean up a few separate times so I was hoping for a well controlled way of doing it.

I am mostly doing free hand selections with a lasso tool or using PS select options, everything is set to 0 pixels as far as softness. I do not want to soften the edge of the selection at all, that would smudge up the edge of the model and would look unnatural.

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
Skip
Skip Senior Member • Posts: 1,971
Re: Selections and Gaussian blur
1

What I often do is Duplicate the layer, Invert the selection, Delete, and Deselect. The selection is then by its lonesome and whatever I do to it doesn't (usually) affect the rest of the image.

 Skip's gear list:Skip's gear list
Panasonic Lumix DMC-FZ150 Panasonic Lumix DC-ZS70 Panasonic Lumix DMC-G5 Sony a77 II
JohnWheeler Regular Member • Posts: 403
Re: Selections and Gaussian blur

Hi Eliot

I totally understand your issue as I have experienced the same thing.  So here is a second easier solution then next a better explanation of why I was using a content aware fill on my first suggestion in my prior post

Note that most of the blur functions do reach out underneath the selection in their calculations so a bit difficult to get around that issue.

1) An easier way to get around this yet not perfect is the Lens Blur option instead of Guassian.  I do believe that blur option totally respects the selection boundary as you desire

2) My first option that I gave you in the prior post allows one to use a Gaussian blur yet is more complex.

To make sure that only the pixels inside the selection are used for the Gaussian Blur one has to have that blur filter only see the inside pixels, outside the selection.  If you select everthing outside your original selection (using inverse selection) and then do a Content Aware Fill, the source of the pixels with which it will do the fill are all pixels outside that selection (which are the pixels inside your original selection area.

Give it a try and you wilil see.

-- hide signature --

John Wheeler

JohnWheeler Regular Member • Posts: 403
Re: Selections and Gaussian blur

Skip wrote:

What I often do is Duplicate the layer, Invert the selection, Delete, and Deselect. The selection is then by its lonesome and whatever I do to it doesn't (usually) affect the rest of the image.

I like your approach.  What you have to watch out for is that the the blur still reaches outside the selection and pulls in transparency into the areas just inside the selection so when combined with the original image in the Layer below, reduces the blur effect in those edge areas.

Nice quick way to eliminate the contamination.  Thanks!

-- hide signature --

John Wheeler

sabrina81
sabrina81 Senior Member • Posts: 5,673
Re: Selections and Gaussian blur

JohnWheeler wrote:

the blur still reaches outside the selection and pulls in transparency into the areas just inside the selection

Lock the transparent pixels. The lock icon is at the top of the layers panel.

sabrina81
sabrina81 Senior Member • Posts: 5,673
Re: Selections and Gaussian blur
1

Eliot Kramer wrote:

Sometimes, when I make a selection and use a Gaussian blur or similar filter on that selection it will take the pixels outside the selection and average/blur them in, so that the selection is contaminated, when in fact the reason I made a selection is to apply the filter only "inside".

It shouldn't do that. Try deleting your prefs file and launch PS so it can create a new prefs file. (Save a copy of the prefs file in case this doesn't fix the problem.)

EDIT: This is what should happen when you blur inside a selection:

If the blur strays outside the selection, something is buggy. As I suggested above, try getting rid of the preferences file and see if that kills the bug.

Ronny Harris Veteran Member • Posts: 7,158
Experiment with Levels.

After you blur the mask, apply Levels (Control L) to the mask in order to expand, contract, or sharpen/blur the edges of the mask. You can also use the lasso tool to select different parts of the mask before you run Levels. This is the old way of tweaking masks in Photoshop and is still a useful method for me.

Ronny

Chaplain Mark
Chaplain Mark Senior Member • Posts: 5,587
Re: Selections and Gaussian blur
3

True, when making selections for the purpose of applying filters or effects selectively, one encounters the problem of how to include/exclude areas near edges for blending treatment.

I have been faced with the problem you state, and have found a much simpler workaround, which does not involve selections at all.

Keeping in mind, the software I use is Affinity Photo, you will need to extrapolate the below into equivalent functions in PS.....

Keeping in mind also, I've been editing images for less than one year, so take this with a grain or two of salt...  This newbie says, sometimes simpler is better.

1. Make a duplicate layer of the entire image, don't bother with making any selections.

2. Apply a new adjustment layer to the duplicate layer you just created, in this case, a
Gaussian Blur, setting the Blur to the level you wish, for the area to be blurred, disregarding the blurring of the rest of the image layer.

3. Invert the adjustment layer you just created, so that the blur disappears entirely.

4. Paint a layer mask back onto the area you wish to blur, experimenting with your paintbrush's size, flow, opacity and hardness until you have the blur you like in the areas in which you want to have blur.

5. If you wish, change the opacity and/or blend mode and/or blend range of the adjustment layer you modified in step 4, to suit.

I find this to be a lot quicker, simpler, more predictable and more controllable than attempting to deal with all the choices and conditions induced by making a selection to begin with.

Hope this helps...!!!

-- hide signature --

Thank You,
Chaplain Mark
-----
'Tis better to have a camera and not need one than to need a camera and not have one.
--------------
In pursuit of photographic excellence.

 Chaplain Mark's gear list:Chaplain Mark's gear list
Canon G3 X Canon PowerShot G5 X Sony a7R III +3 more
OP Eliot Kramer Contributing Member • Posts: 998
Re: Selections and Gaussian blur

sabrina81 wrote:

JohnWheeler wrote:

the blur still reaches outside the selection and pulls in transparency into the areas just inside the selection

Lock the transparent pixels. The lock icon is at the top of the layers panel.

Sabrina81, Always great knowledge and answers but assumes we know what we are doing.

Can you please spell it out "for an idiot". The more granular the steps the better.

And if you feel kind an explanation of when to use "lock transparent" and what it does would be great.

Yes, the other problem that I encountered is transparent pixels getting "pulled in", I didn't even mention it in the original post for fear of making it incomprehensible.

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
OP Eliot Kramer Contributing Member • Posts: 998
Re: Selections and Gaussian blur

sabrina81 wrote:

Eliot Kramer wrote:

Sometimes, when I make a selection and use a Gaussian blur or similar filter on that selection it will take the pixels outside the selection and average/blur them in, so that the selection is contaminated, when in fact the reason I made a selection is to apply the filter only "inside".

It shouldn't do that. Try deleting your prefs file and launch PS so it can create a new prefs file. (Save a copy of the prefs file in case this doesn't fix the problem.)

EDIT: This is what should happen when you blur inside a selection:

If the blur strays outside the selection, something is buggy. As I suggested above, try getting rid of the preferences file and see if that kills the bug.

Something is not right.

Look at the bottom part of the rectangle. Things got blurs and the boundaries are respected.

Look at the top of the rectangle. The boundaries are NOT respected, the pixels got mixed in with a transparency I guess and now you can see THROUGH it to the underlying layer.

I don't understand how you can have non-transparent pixels in the bottom part and transparent in the top.

At the bottom it is  doing what I want it to. The top it is doing what I am trying to avoid, that is, make them semi-transparent or pull things in from the outside.

Now I am even more confused.

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
OP Eliot Kramer Contributing Member • Posts: 998
Re: Experiment with Levels.

Ronny Harris wrote:

After you blur the mask, apply Levels (Control L) to the mask in order to expand, contract, or sharpen/blur the edges of the mask. You can also use the lasso tool to select different parts of the mask before you run Levels. This is the old way of tweaking masks in Photoshop and is still a useful method for me.

Ronny

This is a question about selections and blur.

There is NO masking involved anywhere.

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
GCam Veteran Member • Posts: 8,667
Re: Experiment with Levels.

Eliot Kramer wrote:

Ronny Harris wrote:

After you blur the mask, apply Levels (Control L) to the mask in order to expand, contract, or sharpen/blur the edges of the mask. You can also use the lasso tool to select different parts of the mask before you run Levels. This is the old way of tweaking masks in Photoshop and is still a useful method for me.

Ronny

This is a question about selections and blur.

There is NO masking involved anywhere.

That might be one of your problems, not masking as suggested.  I have never experienced that problem that I know of.  gc

sabrina81
sabrina81 Senior Member • Posts: 5,673
Re: Selections and Gaussian blur

Eliot Kramer wrote:

Look at the bottom part of the rectangle. Things got blurs and the boundaries are respected.

Look at the top of the rectangle. The boundaries are NOT respected, the pixels got mixed in with a transparency I guess and now you can see THROUGH it to the underlying layer.

No, the top part of the rectangular selection is outside the radial circle, in the gray area, so it's blurring gray. You can't see the top edge of the rectangle.

Here is the same image with a second rectangle selected and blurred. G/blur should not bleed outside a selection. If it does, there's something buggy in your PS. Again: Delete the preferences file and see if that solves the problem. (Save your current copy of that file in case it doesn't solve it. Then you can restore all your custom settings.)

sabrina81
sabrina81 Senior Member • Posts: 5,673
Re: Selections and Gaussian blur

Eliot Kramer wrote:

Sabrina81, Always great knowledge and answers but assumes we know what we are doing.

Can you please spell it out "for an idiot". The more granular the steps the better.

Granular  steps.

OP Eliot Kramer Contributing Member • Posts: 998
Re: Selections and Gaussian blur

sabrina81 wrote:

Eliot Kramer wrote:

Look at the bottom part of the rectangle. Things got blurs and the boundaries are respected.

Look at the top of the rectangle. The boundaries are NOT respected, the pixels got mixed in with a transparency I guess and now you can see THROUGH it to the underlying layer.

No, the top part of the rectangular selection is outside the radial circle, in the gray area, so it's blurring gray. You can't see the top edge of the rectangle.

Here is the same image with a second rectangle selected and blurred. G/blur should not bleed outside a selection. If it does, there's something buggy in your PS. Again: Delete the preferences file and see if that solves the problem. (Save your current copy of that file in case it doesn't solve it. Then you can restore all your custom settings.)

Ok, I will do that and report back soon.

 Eliot Kramer's gear list:Eliot Kramer's gear list
Nikon D850 Nikon D500 Nikon AF-S 105mm F1.4E ED Nikon AF-S Nikkor 58mm f/1.4G Sigma 135mm F1.8 Art +3 more
gscotten
gscotten Senior Member • Posts: 1,658
Re: Selections and Gaussian blur

Eliot Kramer wrote:

Sometimes, when I make a selection and use a Gaussian blur or similar filter on that selection it will take the pixels outside the selection and average/blur them in, so that the selection is contaminated

Is this what you mean?

The box on the right was the selection and I gaussian blurred it. It picked up the red from outside the selection and contaminated the selection.

If that is your issue, the best way to deal with it is to use the Lens Blur instead of Gaussian Blur. In the old days you had to use the Layer Mask mode, but now all the Lens Blur modes honor the selection.

This tip was presented here long ago by a great retoucher and teacher, Peano. I wish he were still here, as I still have a VERY great deal to learn.

-- hide signature --

George

 gscotten's gear list:gscotten's gear list
Canon EOS 80D Canon EF-S 10-18mm F4.5–5.6 IS STM Canon EF-S 15-85mm f/3.5-5.6 IS USM Canon EF 70-300mm f/4-5.6L IS USM Canon EF 400mm f/5.6L USM +1 more
Keyboard shortcuts:
FForum MMy threads