You can do this for the purpose of creating an HDR (high Dynamic Range) image, or for "focus stacking" where you increase the DOF by merging images with different focal planes.
Other than tonal differences or focal plane the scene must be exactly the same in all the frames, with an allowance for slight "incidental" movement like leaves fluttering or clouds blowing a little in landscape-type shots. |