Log in

View Full Version : Blur an image while retaining its edges


travolter
9th August 2012, 00:04
Exist already any script for this effect?

before
http://www.complang.tuwien.ac.at/schani/sharpblur/before.jpg
after
http://www.complang.tuwien.ac.at/schani/sharpblur/after.jpg
http://www.complang.tuwien.ac.at/schani/sharpblur/index.html

Blur an image while retaining its edges. Sharp edges get preserved while soft edges are discarded.

In photoshop you can create the effect mixing two layers one sharp, one gaussianblurred with blend="multiply". Then you need to fix levels and sat.

Anyone can help me with a script example to do that?
I did initial tests with avisynth-overlay-multiply and using gaussianblur.. but consumes high cpu for realtime and Im not sure if this the most efficient way to create the effect into avisynth
http://creativetechs.com/tipsblog/how-to-smooth-skin-in-photoshop/
This PS turial speak about Surface Blur filter and how it uses a “smart” smoothing effect that protects areas of contrast or detail when applied

librarian
9th August 2012, 00:18
msmooth(threshold=12,strength=4)

travolter
9th August 2012, 00:27
msmooth(threshold=12,strength=4)

oh thanks pal!!!. Ill test it!!!

travolter
9th August 2012, 11:32
I tested msmooth but its very slow..

Currently Im testing with this one (the blur line comes from a Dideé script). The speed is pretty good for realtime usage and I get some cloud effect that I want to see.


ylevels(0,2,255,0,255)
v=last
rad=6
v2=bicubicresize(round(v.width()/rad/4)*4,round(v.height()/rad/4)*4).bicubicresize(v.width(),v.height(),1,0)
overlay(v2,v,mode="multiply")


I wonder if code can be improved in any way.. .. and how to make the edges more noticeable over the near "clouds"

Didée
9th August 2012, 12:31
Easy.

#--------------------------------------------------------
function LimBlur(clip c, float "radius", int "limit")
{
radius = default(radius, 3)
limit = default(limit, 5)
THR = string(limit)

b = c.bicubicresize(round(c.width()/radius /4)*4,round(c.height/radius /4)*4).bicubicresize(c.width(),c.height(),1,0)
c.mt_lutxy(b,"x "+THR+" + y < x "+THR+" + x "+THR+" - y > x "+THR+" - y ? ?",U=2,V=2)
}
#--------------------------------------------------------

( /code/ not possible right now.)

travolter
9th August 2012, 16:08
Wow Didée!! the results of limblur() are simply amazing.

http://thumbnails59.imagebam.com/20513/20e578205124178.jpg (http://www.imagebam.com/image/20e578205124178)

It works fantastic with HD content and its extremely fast!!!
Im testing with Swscaler -ffdshow as sharpener and works pretty well.
I applied very few amount in the example to be noticeable (Im not sure if its the 2nd or 3rd pic the one with sharp).

Really big thanks for the help pal! Ill use the function a lot :)

2Bdecided
10th August 2012, 11:36
imagebam? That's one dodgy image host!