Light Field Refocusing Shift
Compute the pixel shift for refocusing in a light field.
Light fields enable digital refocusing - changing the focal plane after capture. To focus at depth instead of the original , we shift each subaperture image by:
where:
- is the subaperture position
- is the central subaperture
- is the original focal distance
- is the target focal distance
Objects at depth will be in focus (zero parallax), while objects at other depths are blurred.
If the target focal distance is 0, return 0.0 instead of dividing by zero. Round the result to 4 decimal places.
Example
refocus_shift(2, 0, 10, 5)
2.0
- Inputs:
s= 2 is the subaperture's position,s_center= 0 is the central subaperture,d_original= 10 is the depth the capture was focused at, andd_target= 5 is the new, closer depth we want sharp. - Baseline offset: . This view's distance from the centre sets how strongly it must move; the centre view itself never moves.
- Depth factor: . Halving the focal distance makes the factor exactly 1.
- Shift: , already exact at 4 decimal places, so the result is
2.0pixels. - Notice: the sign carries meaning. Refocusing farther (say ) gives and a shift of , the opposite direction. When the factor is 0 and nothing moves, since the focal plane is unchanged.
Constraints
- s: subaperture position
- s_center: center subaperture position
- d_original: original focal distance
- d_target: target focal distance
- Return shift in pixels, rounded to 4 decimal places