Back Forum Reply New

DOF plugin...

I think it would be really cool if someone created a DOF plugin.  This DOF plugin would shallow the depth of field (similarly to a 35mm film camera).  This would involve some calculations on how near or far objects are in the video and to blur or keep the focus on a certain subject.

I doubt that it is possible, but it sure would be a nice plugin to get that quot;film-lookquot;.

Something like this plugin for Adobe Photoshop.

One way someone could do this is to create an alpha-channel black and white and use that information to blur (black) and to keep in focus (white or vise-versa).

If possible, it would be nice if there was a way to automatically create such an alpha-channel matte.

Regards,
Josh

hmm... it could be done if you generated your source with 3dsmax or something like that... just set z-buffer depth as alpha channel, render to corePNG or something like that (that codec was MADE for 3ds renders ), and then all we need is a really good and fast blur plugin.  you could use nested blur(1)'s depending on alpha luminance.

but it wouldn't be as pretty or accurate as a proper quot;fuzzyquot; renderer.  i haven't used Max for ages, but i believe the new version of it (max 7?) comes with mental-ray, which is about as good as renderers get.  Brazil R/S or FinalRender will do it too.  not sure what else is floating round the market atm.

as for using it on natural video, well i think that'd only work for video shot in stereo, otherwise there's no way of determining depth via indirect means - there's too much there to confuse even a very clever algorithm (offhand i can think of some method of quot;blur detectionquot;, where the edge-sharpness is used to determine the focal plane of the camera.)

Even if it was that quot;very clever algorithmquot;, or something like blur(1) depending on alpha luminance, I think it would still come in handy (especially the latter).

Is there any way of automatically creating such a alpha luminance matte?  I was reading the Photoshop plugin Lenscare again and it says it quot;uses a depth buffer for its calculationsquot;-- what exactly is this and could it be implemented?

Regards,
Josh

Mug Funky (oops, sorry ) posted a gauss function a while back...  It has a nice blur effect:

Code:
function gauss (clip c,int quot;radiusquot;,bool quot;convquot;,int quot;precisionquot;) {

radius=default(radius,4)
conv=default(conv,false)
precision=default(precision,8)
mul=int(pow(2,precision))

Function siney(string s,int stop,int len,int mul)
{
eqn = string(round(mul*pow(sin(pi*stop/len),2)))
return (stop == 0) ? s : siney(s,stop-1,len,mul) + quot; quot; + eqn
}

matrix=siney(quot;quot;,radius*2,radius*2,mul)
matrix=matrix.midstr(2,(matrix.strlen()-3))

(conv==false)?c.bilinearresize(4*(c.width/(radius*2)),4*(c.height/(radius*2)))
\.bicubicresize(c.width,c.height,1,0):
\c.yv12convolution(horizontal=matrix,vertical=matrix,Y=3,U=3,V=3,usemmx=true)

}
Now all we need is to somehow detect depth, or to create an alpha-channel to indicate what the focused subject is.

Regards,
Josh

This function was created by Mug Funky, not by me.

Digging 3D-information out of one single 2D picture is ... well, difficult at least.
Detecting 'depth' is the stumbling stone. While it were possible to detect image features that are in focus (e.g. by edge frequency or 'sharpness'), it is practically impossible to decide if something with low frequency actually belongs to the background, or if it is a gradient feature in the foreground.

hehe... forgot about that one.  funny thing is i got a million scripts that call it.

that photoshop plugin gets it's z-buffer from your 3d app.  it doesn't pull it out of the RGB channels (alas).  take a look at the quot;snail-on-a-leafquot; picture - do you see anything in the depth map you could obviously get out of the picture beside it?

for sure, if we had panning motion to grab hold of and unlimited CPU cycles, we could grab very accurate depth data out of normal pictures.  Icarus does just that, but even it isn't nearly as advanced (it's more like DeShaker) unless you spend hours in a 3d app filling in the gaps (essentially modelling your scene down to a high level of detail).

btw, i'd like to see a plugin for avs that did variable radius blurring, per pixel.  that would give some nice possibilities. gauss is a slow script, and not suited to being used several times at different radii (it can do it, of course, but i don't like slow stuff).

Originally posted by Mug Funky
btw, i'd like to see a plugin for avs that did variable radius blurring, per pixel.

Am I correct in understanding quot;radius varies per-pixelquot;?

If so, you're probably thinking of quot;blur each pixel with the max. radius that just doesn't cross any edgequot;, or something similar?

Same suggestion as in the quot;selective gaussquot; thread: Have a look at TBilateral ...
Taken simple, its spatial domain part is a gaussian blur, that gets additionally modulated by the range part (similarity of pixel value). This can be seen either as adaptive behaviour (for the other thread), or - in a sense - as variable radius, since even big radii won't blur across edges.

i suppose so, but i meant a more general purpose filter where, for instance a max radius is set, and the filter is fed a greyscale mask, where 0 = radius*0 and 255 = radius.  i'm not sure if this would be able to run too fast, but couldn't a convo filter have a window size that varied per pixel? (just running through this in my head i can see it'd be a programming nightmare, but i don't think it's impossible.  i don't know enough maths to say conclusively).

i'll take a look at Tbilateral.  i think i shied away because of speed when that thread came up.
¥
Back Forum Reply New