Sorry for being slow with this, it took me a while to dig up my reference.

coc = abs(focalDist - objectZ) * focalLen * focalLen / (fStop * objectZ * 
(focalDist - focalLen))
pixelBlur = coc * imageWidth

this formula assumes a perfectly thin lens

make sure all your units are the same

you might want to clamp your max blur to avoid insane blur values

focalDist must always be greater than focalLen to avoid badness


Brett


From: Robin Graham 
<[email protected]<mailto:[email protected]>>
Reply-To: Nuke Python discussion 
<[email protected]<mailto:[email protected]>>
Date: Thu, 12 Jan 2012 09:26:38 -0800
To: Nuke Python discussion 
<[email protected]<mailto:[email protected]>>
Subject: [Nuke-python] Script to get depth of field size?

Has anyone seen a python script that calculates the depth of field circle based 
on info about the camera and focus distances? For instance you can find many 
calculators online that take the film size, lens length, and focus distance and 
give you a graph that shows where the depth of field is. Would it be possible 
to convert this information into a defocus size and a certain distance from the 
focal point?

I think this would be incredibly useful.

-=Robin

This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed.
_______________________________________________ Nuke-python mailing list 
[email protected]<mailto:[email protected]>,
 http://forums.thefoundry.co.uk/ 
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to