1. A method for generating a focused image of an object, comprising: obtaining a plurality of images of the object; estimating an initial depth profile of the object; estimating a parallax parameter and a blur parameter for each pixel in each of the plurality of images; and generating a focused image and a corrected depth profile of the object using a posterior energy function, wherein the posterior energy function is based on the estimated parallax parameter and blur parameter for each pixel in the plurality of images.