# Autonomous Prostate Segmentation in 2D B-Mode Ultrasound Images
## 5 Graph-Cut Segmentation
For this, the probability from the prostate shape model, given in (19), will be discretized to give a pixel-based probability score which will be stored in an image, \(\prescript{U}{P}_{i}\), of the same size as the TRUS images (with a height \(\prescript{U}{T}_{\mathit{height}}\) and width \(\prescript{U}{T}_{\mathit{width}}\)). For mapping between the ultrasound image set and prostate, a centre point, \(\prescript{P}{c}=[\prescript{P}{x}_{c},\prescript{P}{y}_{c},\prescript{\phi}_{c}]\)\(\top\), will be used. Only a single contour point is used for the entire image set and, in a similar manner to the contour fitting procedure, this centre point will be optimized during the graph-cut procedure. Using a given centre point, the location of a pixel in the TRUS image, \((\prescript{U}{px},\prescript{U}{py})\), is converted to the contour coordinate system through the transform  
\[\prescript{P}{px} =\frac{\prescript{U}{px}-\prescript{P}{yx}}{\prescript{P}{yx}} \tag{50}\] \[\prescript{P}{py} =\frac{\prescript{U}{py}-\prescript{P}{py}}{\prescript{P}{yx}}\] \[\theta_{px} =\text{atan2}(\prescript{P}{py}-\prescript{P}{y}_{c},\prescript{P }{px}-\prescript{P}{x}_{c})-\prescript{P}{y}_{c}\] \[r_{px} =\sqrt{(\prescript{P}{py}-\prescript{P}{y}_{c})^{2}+(\prescript{ P}{px}-\prescript{P}{x}_{c})^{2}}\]  
Figure 9: Output of superpixel algorithm in TRUS image frame \(\{U\}\) with region borders shown in green and region centroids indicated with red dots. where \(\prescript{p}{px}\) and \(\prescript{p}{py}\) are the pixel coordinates in the patient attached frame, using the constants in the transform (A1), giving the output values \(\theta_{px}\) and \(r_{px}\) in the contour coordinate system. Using this transform, the probability image, \(\prescript{U}{\mathcal{P}}\), is created by evaluating the CDF of the prostate shape, given in (20), for every pixel within the ROI of in the input image, such that  
\[\prescript{U}{\mathcal{P}}(\prescript{U}{px},\prescript{U}{py})_{i}= \begin{cases}P(R \leq r_{px}|\theta_{px},i)&\text{for}\ (\prescript{U}{px},\prescript{U}{py})\in\ \prescript{U}{\mathcal{I}}_{ROI}\\ 1&\text{for}\ (\prescript{U}{px},\prescript{U}{py})\
otin\ \prescript{U}{\mathcal{I}}_{ROI} \end{cases}  \tag{51}\]  
where \(P(R\leq r_{px}|\theta_{px},i)\) is the probability that the prostate contour is smaller than the pixel's radial distance \(r_{px}\), relative to the centre point, and the value of 1 will prevent the prostate contour from being outside the ROI. With the probability image defined, the data term components \(\psi_{k}(\mathbf{L}_{k})\) for the cost function (47) are given as  
\[\psi_{k}(R_{k}\in\mathbf{L}_{In})=\lambda_{DP}\left(\sum_{(\prescript{U}{ px},\prescript{U}{py})\in k}\frac{\upupupupupupupupupupupupupupupupupupupupup  
cutting are inside of the prostate, which could be represented in a binary image where all of the pixels inside of the regions \(R_{k}\in\mathbf{L}_{In}\) have a value of one and all other pixels are zero. To smooth out the segmented prostate contour, the contour model is fit to the pixels on the perimeter of the binary region \(R_{k}\in\mathbf{L}_{In}\). The perimeter pixels are transformed to the contour model coordinate system using (50), and then the model is fit to these pixel points from the least-squares fitting given in (6), thus creating a 3D contour model for the segmented prostate; see Figure 11. The results of the segmentation on a number of patient image sets is given in Section 6. Figure 11: _Cont._  
Figure 10: Superpixel regions after graph-cut procedure. The centroids of regions labelled as being inside of the prostate, \(R_{k}\in\mathbf{L}_{In}\), are displayed with green dots, and the centroids of the superpixel regions outside of the prostate, \(R_{k}\in\mathbf{L}_{Out}\), are displayed with red dots.