View Full Version : simulating DOF in AE but


Steven Andrus
April 6th, 2006, 09:07 PM
ok, so you can simulate DOF in post with after effects if you roto the subject and defocus the foreground. This is obviously no ideal, but I have some footage where this is the only choice. I'm wondering if anyone knows of an easier way than frame by frame changing the mask, maybe by using motion tracker or something...

Carl Jakobsson
April 6th, 2006, 09:25 PM
Very hard to tell wit´hout seeing the footage...

I have used several methods, sometimes in combination
1) Keying several colours, especially around contoures and then exporting to a filmstrip and clean up in photoshop. For example, I keyed the sky to green and then manually airbrushed out a skyscraper that had the same colour as the skin of the subject
2) Selective focus in the plugin '55mm' by DFT
3) Extract all the moving pixels from footage (VERY HARD - requires static footage)
4) Clip certain areas dynamically with keyframes

I found this tutorial useful, even though it doesn't deal with this particular issue. Some nice tips in it.
http://www.creativecow.net/articles/kramer_andrew/sky_replacement/sky.html

Steven Andrus
April 9th, 2006, 05:57 AM
Very hard to tell wit´hout seeing the footage...

3) Extract all the moving pixels from footage (VERY HARD - requires static
http://www.creativecow.net/articles/kramer_andrew/sky_replacement/sky.html

How is this done? I have a few of the shots that are static, like a medium close up of a guy with a cowboy hat bobbin around talking, might work perfect for that, but how is it done? I'll check out that tutorial also...

Conor Ryan
April 9th, 2006, 07:27 AM
I have to admit not trying this yet, but have been planning to. Anyway, if you have PFTrack, you can actually get a grayscale depth matte from your footage, you could then use that as the depth matte for the lens blur filter in AE7.

that's the theory anyway.

Etienne Caron
April 9th, 2006, 08:17 AM
Check this application who is used for creating DOF in animation... may it help you.

Dof generator pro:
http://www.dofpro.com

Giroud Francois
April 9th, 2006, 09:37 AM
mokey is very good at generating mask of moving object on relatively static background. it is not its primarily purpose, but i do not think you can find better tool.

Carl Jakobsson
April 9th, 2006, 05:57 PM
This thread got me interested in giving fake DOF a second chance. I've uploaded a clip to show the difference. The first half is directly from the camera with only deinterlace added. The second half is after the fake-dof. I've also added some denoising and the WarpSharp-filter in Virtualdub (this doesn't effect the DOF effect though) to clean up the noise. The clip is hosted on my private server, so it won't be online for too long.

http://www.nattvard.com/upload/aedof.mpg
MPEG2 PAL VBR 4000 2pass

The scene is from an upcoming short called "Lomma Vice 2" - The Return of Calzone. Carlito Calzone (me), the boss on the right, has just picked up an old partner in crime at the hospital. However, we couldn't record this embarassing coke-sniffing scene outside the hospital, so we recorded it at a parking lot. This makes the fake-dof necessary because without it, it was quite obvious that the scene was recorded elsewhere, since the hospital couldn't be seen in the background.

About a month ago I tried to key out the background but without sucess. It was too detailed and colorful. The solution I present here is quite manual and tidious, but I guess I've spent a lot more time on trying different keying solutions than I did masking it the way I describe below.

Here's the recipe:
First, the footage was deinterlaced. After that it was imported in After Effects. By using the motiontracker I could easily stabilize the footage using a street lamp (that is no longer visible in the "after"-footage) as a reference.

Having a steadier shot I then duplicated the footage to a track below. On the lower track blur was added. On the upper track I started drawing masks with the pen tool. I drew two different masks, one per person. I then keyed the vertices of the mask every 5th to 10th frame, depending on the motion.

So what I did was to mask and keep the stuff that should be in focus on the upper track, and let everything else be out of focus on the lower track. This process isn't particularly fast, but it isn't hard either, as long as you know how to do. It's all about patience and moving vertices. I fixed more than 20 seconds (500 frames) of footage in two hours. Boring, but it paid of.

Here's some tips;
1) Apply some feather to the mask
2) Don't use too much blur. That will make it look fake (or more fake :)).
3) Take a break every now and then
4) Fix a dof-adapter and film in 24p! (less keyframing... :))

Hope this "tutorial" was helpful to anyone.

Carl Jakobsson
April 9th, 2006, 06:02 PM
I have to admit not trying this yet, but have been planning to. Anyway, if you have PFTrack, you can actually get a grayscale depth matte from your footage, you could then use that as the depth matte for the lens blur filter in AE7.

that's the theory anyway.

The DFT 55MM filters work this way. The problem is that there's always something that you want in focus that has the same luminance or chroma in the generated matte as the things you want to blur.

Steven Andrus
April 10th, 2006, 12:38 AM
Yeah, i can't get DFT to only go after my subject... ...i've been doing it frame by fram, although i hadn't thought about 24p giving me less work... ...i guess i just thought that by now someone would have made a magnetic lasso tool that would also track. That way you could easilly trace out someone and and then have a tracker keep the up with the movement of the outline

Steven Andrus
April 10th, 2006, 09:07 PM
Mokey is good but will only export mask shapes to Shake and not to after effects (which, not having a mac, i am using) i think you can export the mask as a targa sequence and then play with chokers in ae after you import the sequence but this is not as cool as the option offered to shake users... ..another thing I noticed is sillouette roto, which can export mask shapes to after effects but is not as powerful of a tracker as mokey

Conor Ryan
April 11th, 2006, 04:30 AM
The DFT 55MM filters work this way. The problem is that there's always something that you want in focus that has the same luminance or chroma in the generated matte as the things you want to blur.

ah, not the case using the pftrack technique. you generate a depth matte from a 3d motion track of the footage - not from the luma or chroma - it calculates the luma of the matte based on the distance of an object from the camera. then use plug that matte into the depth matte section of the lens blur filter in ae7.

Steven Andrus
April 12th, 2006, 01:10 AM
ah, not the case using the pftrack technique. you generate a depth matte from a 3d motion track of the footage - not from the luma or chroma - it calculates the luma of the matte based on the distance of an object from the camera. then use plug that matte into the depth matte section of the lens blur filter in ae7.


This sounds interesting, so am i understanding you right that pftrack, based on the motion in the clip, calculates the depth of objects so that you can isolate them and then mask them out that way? This would be even better than mokey

Conor Ryan
April 12th, 2006, 04:33 AM
yeah, that's pretty much it. you don't have to mask anything out though, just use it as a depth matte for a defocus effect.

problems: pftrack is very expensive, GBP3000, zdepth generation is very slow (unless you have a supercomputer, in which case it's quite slow).

it's made by pixelfarm, http://www.thepixelfarm.co.uk/

Jeff Tyler
April 12th, 2006, 09:30 PM
Carl I watched your clip and I think it would look better if you didn't denoise it. The way it is it looks to smoothed out and fake, I think the original noise will help mask the fake dof and make it look better.

Steven Andrus
April 13th, 2006, 12:25 AM
yeah, that's pretty much it. you don't have to mask anything out though, just use it as a depth matte for a defocus effect.

problems: pftrack is very expensive, GBP3000, zdepth generation is very slow (unless you have a supercomputer, in which case it's quite slow).

it's made by pixelfarm, http://www.thepixelfarm.co.uk/


I think I can get the producer of this project to front the cash if this really works, even if it takes forever for it to calculate.... ..so it's called z depth generation? Do you know of any tutorials on how to do this or any examples so I can check it out before trying to sell him on the idea?

Jef Bryant
April 13th, 2006, 01:48 AM
I'd love to see some examples of the z-depth approach. Finally, a new method fo manipulating dof! (potentially).

Too bad it is so expensive...

Riley Harmon
June 11th, 2006, 06:10 AM
http://www.rileyharmon.com/temp/DOF_test.mov

used ae to create animated depth maps using masks, opacity, and alpha channels, then used DOF Generator to batch. will do a longer clip when i have more time. stock vx2000, 24p using my own recipe