X-Git-Url: http://git.kpe.io/?p=cl-photo.git;a=blobdiff_plain;f=dof.lisp;h=8dfdf1478ac32981d9472a92fc1bb7d1d6e70e33;hp=ee9250a745c0d613716cdc405e798f8a8e191019;hb=431903301170bffaea3a481813a210dc407d0455;hpb=4860883d5bf05e9e7c83d4f16a001e4edd1d1cb2 diff --git a/dof.lisp b/dof.lisp index ee9250a..8dfdf14 100644 --- a/dof.lisp +++ b/dof.lisp @@ -19,19 +19,29 @@ (in-package #:photo) +(defun sort-size (size) + "Returns a cons pair with the smaller size first." + (if (>= (car size) (cdr size)) + (cons (cdr size) (car size)) + (cons (car size) (cdr size)))) + +(defun print-magnification (imager-size print-size) + "Returns the magnification required between an imager and print sizes +while taking crop into consideration." + (setf imager-size (sort-size imager-size)) + (setf print-size (sort-size print-size)) + (float (max (/ (car print-size) (car imager-size)) + (/ (cdr print-size) (cdr print-size))))) + (defun coc (imager-size &key (lpm 5) (minimum-distance 250) (viewing-distance 250) (print-size (output-dimensions :8x10in))) "Returns circle of confusion in mm and print magnification for a format. Default resolving power is 5 lpm at 25cm." - - (let* ((imager-diagonal (diagonal (car imager-size) (cdr imager-size))) - (print-diagonal (diagonal (car print-size) (cdr print-size))) - (resolution-factor (/ (* lpm print-diagonal minimum-distance) - (* imager-diagonal viewing-distance))) - (coc (/ 1.0d0 resolution-factor)) - (print-magnification (/ print-diagonal imager-diagonal))) - (values coc print-magnification))) + (let* ((magnification (print-magnification imager-size print-size)) + (resolution-factor (/ (* magnification lpm minimum-distance) viewing-distance)) + (coc (/ 1.0d0 resolution-factor))) + (values coc magnification))) (defun coc-format (format &key (lpm 5) (minimum-distance 250) (viewing-distance 250) @@ -133,5 +143,3 @@ Output: NEAR-POINT, FAR-POINT, TOTAL-DOF, MAGNIFICATION, BLUR-SIZE-OF-INFINITY-P (defun mtf-scanner (freq dscan-freq &optional (order 3)) (abs (expt (kmrcl:sinc (* pi (/ freq dscan-freq))) order))) -(defun freq-mtf-scanner (dscan-freq mtf &optional (order 3)) - (* dscan-freq (/ (asin (* x (exp (/ (log mtf) order)))) pi)))