# A Prostate MRI Segmentation Tool Based on Active Contour Models Using a Gradient Vector Flow
## 2 Materials and Methods
### Implementation of the Proposed Active Contour Model
#### 2.3.4 Contour Smoothing--Term \(J_{4}(\phi)\)  
Finally, it is desirable that the generated contour is smooth. This can be achieved if the Euclidean arc length of the contour \(C\) is minimized. It follows that the contribution function for this prior is the one represented in Equation (13).  
\[J_{4}(C)=\int_{C}ds \tag{13}\]  
It is worth mentioning that if only this term is included in the functional, the shape of the contour will become a circle, and then it will start shrinking until it eventually disappears. Nonetheless, when all the terms are put together, this situation is avoided, and the effect is to smooth the curve. Again, adding the level set function where the contour is embedded, the final function for \(J_{4}\) is defined in Equation (14).  
\[J_{4}(\phi)=\int_{\Omega}\delta(\phi(x,y))|\
abla\phi(x,y)|dxdy \tag{14}\]  
The following step is to combine all the functional together, and expand the minimization problem, in such a way the function \(\phi(x,y)\), which contains the contour \(C\) as its level zero, evolves towards the edge of the object. The entire procedure is well explained in [12], and it consists of three tasks:  
1. Define the statistical model constants, in such a way that they comply with the prior that the pixel distribution follows a Gaussian distribution.
2. Estimate the ellipse parameters to obtain the distance functional contribution.
3. Define the contour evolution equation. This can be done by applying the Euler-Lagrange (EL) equation to the functional of the four priors. Then, considering that \(\phi\) is a function of time, the \(EL\) equation is equal to the derivative of \(\phi\) with respect to the time. The resulting function is given in Equation (15). \[\frac{\partial\phi}{\partial t}=\left[\lambda_{1}(M_{2}-M_{1})-\
abla P\frac{ \
abla\phi}{||\
abla\phi||}-P\kappa\right]\delta(\phi(x,y))\] (15)where \(M_{1}\), \(M_{2}\) are the stochastic models of the object and the background, respectively, \(\kappa=div\left(\frac{\
abla\phi}{\|\
abla\phi\|}\right)\) is the curvature of the contour, \(\phi(x,y)\) is our level set function, and \(P(x,y)=\lambda_{2}\gamma(x,y)+\lambda_{3}D^{2}(x,y)+\lambda_{4}\) is the potential function.  
The different values of \(\lambda_{1}\), \(\lambda_{2}\), \(\lambda_{3}\) and \(\lambda_{4}\) will define the contribution of the corresponding energy term, from \(J_{1}\) to \(J_{4}\), and the one with the biggest value will enforce its properties over the others. In practice, the parameters setting is done empirically, and there is no rule that defines how to chose them. It depends on the quality and the properties of the input image. One solution is to make the weights to evolve at each iteration to obtain the best results. The general idea of this evolution is that at the beginning, the algorithm should minimize the energy functional trying to cover all the object, pushing the boundaries towards the edges (effect produced by \(\lambda_{1}\) and \(\lambda_{2}\)), and when the algorithm is close to the end, the curve must enforce the shape of the contour and its smoothness (\(\lambda_{3}\) and \(\lambda_{4}\)).  
For the particular case of prostate segmentation, several objects with different shapes have to be considered. Therefore, the shape prior cannot be only an ellipse, as it happens in the case of the left ventricle of the heart. Thus for this implementation, the value of \(\lambda_{3}\) has been set to zero.  
Additionally, through several experiments, we concluded that the contribution produced by the smoothness prior is not noticeable. In fact, it produces small variations in the contour, and the result is that the algorithm takes more time to converge. This is the reason why the value of \(\lambda_{4}\) has been set to zero too. Finally, the suggested evolution of the weights is shown in Figure 5.