1. A method for focus error processing, the method comprising: receiving image data of an object onto a sensor array of an optical system; calculating a filter response value of a defocus filter to a patch of the received image data for each defocus filter in a set of one or more defocus filters for the optical system, such that the calculated filter response values for the set of defocus filters produces a filter response vector of the received image data; calculating a probability for each of multiple defocus levels within a predetermined set of defocus levels from the filter response vector of the received image data; and determining an estimate of focus error from the received image data based on the calculated probabilities of the multiple defocus levels; wherein calculating the probability of each of the multiple defocus levels comprises using a parametric function of a training set of images comprising image patches having defocus levels corresponding to the predetermined set of defocus levels to determine a probability for each defocus level of the predetermined set of defocus levels; wherein determining an estimate of focus error comprises selecting a defocus level from the predetermined set of defocus levels that is most similar to training filter response vectors associated with a defocus level.