# Autonomous Prostate Segmentation in 2D B-Mode Ultrasound Images
## 3 Active Shape Prostate Contour Model
### 3D Prostate Contour Model Fitting
The least-squares optimization, under the constraint given in (7), is then  
\[\underset{\beta_{c}}{\text{argmin}}\sum_{i=0}^{nImg}\underset{\beta_{i}}{ \text{argmin}}\left\|\{\vec{r}_{i}|\beta_{c}\}-R_{i}(\left\{\vec{\theta}_{i}| \beta_{c}\right\}|\beta_{i})\right\| \tag{8}\]  
where, \(\{\vec{r}_{i}|\beta_{c}\}\) and \(\left\{\vec{\theta}_{i}|\beta_{c}\right\}\) are the transformed points calculated from (4). Thus, the optimal augmented centre point is found, which minimizes the slice contour model error across all slices, \(i\), in the image set (\(i=[0,1,...,nImg]\)). This fitted contour model, incorporating the prostate contour information from all 2D slices, thus describes the 3D contour of the prostate. The resulting 3D contour model, after fitting to all of the patient contour slices, is shown in Figure 3, where input contour points are the red dots and the blue curves are the resulting prostate contour model. To evaluate the accuracy of the prostate contour model, the mean-squared difference and maximum absolute error between the output model and the input contour points will be used. The mean-squared error is given as  
\[\vec{\theta}_{i} =\text{atan2}(\,^{P}\vec{y}_{i}-\,^{P}y_{c},\,^{P}\vec{x}_{i}-\,^{P}x _{c})-\,^{P}\phi_{c}\]0where \(n_{pt}\) is the total number of clinician-segmented contour points that the model was fit to. The maximum absolute error is given as  
\[\vec{\theta}_{i} =\text{atan2}(\,^{P}\vec{y}_{i}-\,^{P}y_{c},\,^{P}\vec{x}_{i}-\,^{P}x _{c})-\,^{P}\phi_{c}\]1  
with \(v\) being the index of a vertex point within the input slice contour points; hence the MAE is the maximum absolute error between the model and all of the input contour points. These two metrics were evaluated for a set of 100 3D clinician-segmented contours (consisting of 7 to 13 2D slice contours each) based on a TRUS images of the prostate and a set of 100 3D clinician-segmented contours (consisting of 7 to 16 2D contours each) based on MR images of the prostate. While this work is focused on US prostate segmentation, the second MR dataset was evaluated to see if the model had any bias with respect to input imaging modality. In these results, and for the prostate contour after graph cutting segmentation, only four modes were used in the model (\(n_{\omega}=4\)), and the constant phase offset values, \(\phi_{j}\), were chosen to be \(\phi_{1}=0,\phi_{2}=\pi/2,\phi_{3}=0\), and \(\phi_{4}=\pi/2\). Therefore, for each contour slice, this four mode model is given by  
\[\vec{\theta}_{i} =\text{atan2}(\,^{P}\vec{y}_{i}-\,^{P}y_{c},\,^{P}\vec{x}_{i}-\,^{P}x _{c})-\,^{P}\phi_{c}\]2  
where the parameters to be fit for slice \(i\) are \(\beta_{i}=[\alpha_{0},\alpha_{1},\alpha_{2},\alpha_{3},\alpha_{4}]\). The mean value and standard deviation of the MSE and MAE across the 100 contours and the range (minimum-to-maximum) of the MAE for the two datasets is presented in \[\vec{\theta}_{i} =\text{atan2}(\,^{P}\vec{y}_{i}-\,^{P}y_{c},\,^{P}\vec{x}_{i}-\,^{P}x _{c})-\,^{P}\phi_{c}\]3 The results show that the contour model has an average sub-millimetre mean-square error accuracy and a mean maximum absolute error less than 1.6 mm, regardless of imaging modality. The results also indicate that, by using only four modes, the clinician-segmented contours are modelled with acceptable accuracy, where the largest discrepancy (maximum absolute error) between the input clinician contour point and the contour model across the two datasets was under 2.2 mm.