Log in

View Full Version : How can I blur the edges of images only?


travolter
17th March 2012, 22:48
I want to blur the edges of images only. (The opposite of some sharpen techniques that sharp the edges).

How can I do it? I need code (Im not expert)

Bloax
17th March 2012, 23:04
Blurring the edges?
Sounds unpractical, but here goes.
msk=RAverageW(last,16,RemoveGrain(19,-1),-16,u=0,v=0,bias=-96).Mt_Inflate()
RMerge(last,RemoveGrain(19),msk)
Needs RedAverage, RemoveGrain (you ought to have this, if not - get it!) and MaskTools2.

Didée
17th March 2012, 23:51
This blurs the edges themselves:
a = last # source vid
b = a.removegrain(11) # blur
e = a.mt_edge("prewitt",0,255) # edge mask

mt_merge(a,b,e)

If you don't want to blur the very edges, but rather the areas beneath the edges: (e.g. halo/gibbs removal)
a = last # source vid
b = a.removegrain(11) # blur
e1 = a.mt_edge("prewitt",0,255) # edge mask
e2 = e1.mt_expand().mt_expand()
ee = mt_lutxy(e2,e1,"x y -").mt_inflate().removegrain(11)

mt_merge(a,b,ee)

Those are just basic examples. There's a myriad of "variants", especially about creating the edge mask. It really depends on the characteristics of the source - natural film, anime, clean, or noisy/grainy, etc.pp.

travolter
18th March 2012, 11:15
Thanks for the help Bloax and Dideé!! I was playing with the scripts posted here.. and the last one from dideé was the one that convinced me more. (not needed to blur the very edges).
a = last # source vid
b = a.removegrain(11) # blur
e1 = a.mt_edge("prewitt",0,255) # edge mask
e2 = e1.mt_expand().mt_expand()
ee = mt_lutxy(e2,e1,"x y -").mt_inflate().removegrain(11)

mt_merge(a,b,ee)
I also preferred the look of a gaussianblur arround edges so I replaced removegrain(11) by gaussianblur(3), but it consumes much
more cpu

My idea with this request was to blur the edges of images and then sharp the inside using this great script (Dideé code)

str =1.49
o = last
b = o.removegrain(11).removegrain(4)
mt_lutxy(o,b,"x x y - abs 4 / 1 1.4 / ^ 4 * "+string(str)+" * x y - x y - abs 0.9 + / * +",U=2,V=2)



Finally I noticed that if I apply swcaler gaussian blur (ffdshow) before the above script the result is similar and I
consume less cpu realtime.


There is any other way to do the same task more efficiently? or other alternative to blur edges, and sharp the inside of images?

pandy
20th March 2012, 12:16
Overlay?