# PSDFH: A Phase-Space-Based Depth from Hologram Extraction Method
## 3 Proposed Methodology
### Step 4: Regions of Interest Iterative Refinement  
To better control the depth extent of the extracted regions of interest, a proposed iterative refinement algorithm is introduced in the next section and is applied to the extracted ROI in order to calculate the optimal representation line. Then, a new ROI of fixed size centered on the predicted line is defined and used as the final ROI. The initially extracted ROI is a subset of the minimal set of points that produce the same binarized phase space representation as \(\hat{M}_{b}\). As a result, the ROI can be further refined to produce the smallest set of points that when mapped into phase space produce the same representation as \(\hat{M}_{b}\). To reduce combinatorial complexity, primitives larger than the points, namely lines, are chosen as the set of candidates to be combined in order to produce the same representation as \(\hat{M}_{b}\), as shown in Figure 3.  
The decomposition into a minimal set of lines is described in Algorithm 1. First, the set of candidate points \(\hat{P}\) is decomposed into a set of disjoint regions \(ROIs(\hat{P})\) using the **findContours** from the Opencv Library [15]. Then, all lines that are completely embedded in each subregion are extracted. Each line is mapped into phase space, and its contribution to the estimated phase space representation \(\hat{M}_{b}\) is evaluated. The line that contributes the most is selected. Finally, all candidate points that are in the same interval along the \(X\)-axis as the selected line are removed. As shown in Figure 4, the contribution of the selected line is not removed from the matrix \(\hat{M}_{b}\) because other candidate lines may share the same points as the selected line in phase space. Therefore, removing the line contribution would remove candidate lines that may actually belong to the scene. To prevent this from happening, a buffer \(M_{pred}\) is used and is incremented with the phase space representation of the selected line at each iteration. The iteration stops when the contribution of the newly selected line is less than 5% overlap of the input phase space representation. An example of phase space decomposition is given in Figure 5.  
Figure 2: Illustration of the two different cases that can be observed during the ROI extraction. The first case, shown at the top of the figure with a scene composed of 3 segments, is a perfect mapping that produces diamond shapes that encapsulate the scene points. The second case, shown at the bottom of the figure, is a more common mapping case of larger scene segments where diamonds are hidden due to lack of space between scene points. In both of these cases, the iterative method produces relevant results. **Algorithm 1** Iterative decomposition into a set of lines  
```
1:Set of candidate points \(\hat{P}\), and the estimated phase space representation \(\hat{M}_{b}\). 2:\(M_{pred}\gets zeros(size(\hat{M}_{b}))\);
3:\(S_{last}\gets 0\);
4:\(\Omega_{\hat{M}_{b}}(P)=\{(x[n_{1}],\xi[m_{1}])\ |\ \mathbb{1}_{\hat{M}_{b}[n_{1},m_{1}]=1}\}\)
5:repeat
6:\(ROIs(\hat{P})=findContours(\hat{P})\);
7:\(lines_{scores}\leftarrow[]\);
8:for\(R\in ROIs(\hat{P})\)do
9: Extract the set \(\Theta(R)\) of horizontal lines that are completely included in \(R\);
10:\(\gamma=\frac{|\Omega(l)\cap\hat{\Omega}_{\hat{M}_{b}}(P)|}{|\Omega(l)|}\)
11:\(lines_{scores}.append(\gamma)\)
12:endfor
13:endfor
14: Select the optimal line \(l=\arg\max lines_{scores}\)
15:\(S_{current}\leftarrow\max lines_{scores}\)
16:if\((S_{current}-S_{last})\geq 0.05\)then
17:\(S_{last}\gets S_{current}\)
18:else
19: Break
20:endif
21:\(M_{pred}\leftarrow(\Omega(l)\cup M_{pred})\)
22: Remove contribution of line l in set \(\hat{P}\), \[\hat{P}\leftarrow\{(x,z):x\
otin[min_{x}(l),max_{x}(l)]\quad\forall(x,z)\in \hat{P}\}\]
23:
24:until\((S_{current}-S_{last})<0.05\). ```  
**Algorithm 1** Iterative decomposition into a set of lines  
Figure 3: Illustration of the ROI refinement method.