## 5 Object Depth Modelling
As far as even sharp images contain edges of objects from different distances to the lens, i.e., the objects distances are in the range of DOF, different depths for the edges are obtained. To obtain a maximum range of depth, by varying \(d_{\rm v}\) a certain generated blurred image is found where e.g., \(\sigma_{\rm v}^{2}=\sigma_{\rm t}^{2}\) and \(T_{d\rm v}=T\); i.e., a maximum value among the computed \(T_{d\rm v}\) values. Then, from Equation (14), we have:  
Figure 5:1In the same way, a blurred image from the database can be compared to the generated blurred image as:  
Figure 5:2  
Here as well, different depths are detected using a maximum depth range by varying \(d_{v}\), where a certain generated blurred image is found, e.g., \(\sigma_{\text{v}}^{2}=\sigma_{\text{p}}^{2}\) and \(\text{P}_{\text{dv}}=\text{P}\), i.e., a maximum value among the computed \(\text{P}_{\text{dv}}\) values. Then, from Equation (16), we obtain:  
Figure 5:3  
By having \(\sigma_{1}^{2}\) from Equation (15), Equation (17) is used to obtain the standard deviation of a burring kernel which causes the most blurring effect from the unintentional motion or defocused blur. The pseudocode of the presented algorithm that summarizes the main computational steps is shown in Algorithm 1. ```
Input: color image, I, sharp or blurred (either 0 or a value), ImSigma, \(\sigma_{\text{v}}\) values changes (rang of blurring), [bIMin, blMax], blurring step, bIStep Output: pseudo color image (depth image), Id, max depth (related to \(\mathbf{T_{dw}}\) or \(\mathbf{P_{dv}}\)), maxDepthOut, Gaussian sigma of sharp (Equation (15)) or blurred image (Equation (17)), ImSigmaOut  Preprocessing: Ic \(>\) Icp %mapping the intensity values of each of three color channel of Ic to new values in Icp  Color to grey conversion, Icp \(>\) Icg  Edge detection, Ig \(>\) Ice % where the Ic is a binary image  Generate Gaussian filter kernels, \(\sigma_{\text{v}}\) (bIMin, blMax, blStep) \(>\) G1, G2, \(\ldots\),GN  Calculate Gaussian gradient magnitude image for each Gaussian kernel, Ic, G1 \(>\) mgIm1  Ice, G2 \(>\) mgIm2...  Ic, Gn \(>\) mgImN  Calculate amplitude ratio (Equation (14)), Le, mgIm1, mgIm2, \(\ldots\), mgImN \(>\) TP\({}_{\text{dv1}}\), TP\({}_{\text{dv2}}\)... TP\({}_{\text{dvN}}\) If ImSigma = 0  max (TP\({}_{\text{dv1}}\), TP\({}_{\text{dv2}}\)... TP\({}_{\text{dvN}}\)) \(>\) T\({}_{\text{dv}}\)  If TP\({}_{\text{dvk}}\) = T\({}_{\text{dv}}\) find Gk related to TP\({}_{\text{dvk}}\) \(>\)\(\sigma_{\text{t}}\) in Equation (15), calculate \(\sigma_{\text{t}}\) in Equation (15), \(\sigma_{\text{t}}\), T\({}_{\text{dv}}\)\(>\)\(\sigma_{\text{t}}\) ImSigmaOut = \(\sigma_{\text{1}}\) maxDepthOut = T\({}_{\text{dv}}\) else % ImSigma has a value, \(\sigma_{\text{t}}\), from sharp related image max (TP\({}_{\text{dv1}}\), TP\({}_{\text{dv2}}\)... TP\({}_{\text{dvN}}\)) \(>\) P\({}_{\text{dv}}\)  If TP\({}_{\text{dvk}}\) = P\({}_{\text{dv}}\) find Gk related to TP\({}_{\text{dvk}}\) \(>\)\(\sigma_{\text{v}}\) in Equation (16), calculate \(\sigma_{\text{m}}\) in Equation (17), ImSigma (or \(\sigma_{\text{1}}\)), \(\sigma_{\text{v}}\), P\({}_{\text{dv}}\)\(>\)\(\sigma_{\text{m}}\) ImSigmaOut = \(\sigma_{\text{1}}\) maxDepthOut = P\({}_{\text{dv}}\) end  Generate a sparse depth map using quantization of depth range, mgIm1, mgImK (related to found T\({}_{\text{dv}}\) or P\({}_{\text{dv}}\)) \(>\) blsparseDk  Apply joint bilateral filtering, blsparseDk \(>\) blsparseDk  Calculate sparse depth propagation using network of edges, blsparseDkF \(>\) blsparseD  Clean the current sparse depth of outliers and noise, blsparseD \(>\) blsparseD  Full sparse depth propagation, blsparseD \(>\) Id
```  
**Algorithm 1** Full depth map estimation.