A small warning for the perfectionists

Started by garry23, November 27, 2018, 07:58:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

The current depth of field (DoF) calculations in ML do a reasonable job of estimating the near and far DoFs, with or without diffraction.

However, some of you may have noted a strange result if you focus at infinity: have a look in the Focus menu in LV and you will see that the near DoF is different to the hyperfocal distance.

As you know, if you focus at the hyperfocal (H), the near DoF will be H/2 and the far DoF will be inifinity.

If you focus between H and short of infinity, the far DoF will, of course, remain at infinity, and the near DoF will move further away from H/2, until, at infinity it will be H.

The current ML C code estimates the near DoF as follows:

    lens_info.dof_near = fl + (fd*H-fl2)/(H+fd-2*fl); // in mm relative to the sensor plane

But, because we are using approximations and infinity is not infinity in ML, it's just a large number, you end up with the 'infinity anomaly' for the near DoF.

The ML code in focus.c should read:

if (fd>=655000)
   { lens_info.dof_near = H/2; // in mm relative to the sensor plane }
else
   { lens_info.dof_near = fl + (fdH-fl2)/(H+fd-2fl); // in


Using the fact that ML reports infinity as the distance 655350mm.

BTW my latest DoF Bar correctly reports things, so, at ML-reported infinity, DoF Bar and ML will report different near DoFs. DoF Bar can be downloaded from: https://gist.github.com/pigeonhill/fdbc6e2fbeed1206afcc47d69cee9591/revisions

The ML anomaly will not ruin anyone's day: I'm flagging this up for the perfectionists out there ;-)

I have flagged this in a bug report: https://bitbucket.org/hudson/magic-lantern/issues/2912/focusc-needs-updating-with-one-line-of which I hope will result in it being 'fixed' the next time @a1ex has a chance to refresh the core code.