# A Prostate MRI Segmentation Tool Based on Active Contour Models Using a Gradient Vector Flow
## 2 Materials and Methods
### Gradient Vector Flow Approach (GVF)
\[\varepsilon=\iint\mu(u_{x}^{2}+u_{y}^{2}+v_{x}^{2}+v_{y}^{2})+|\
abla Y|^{2}\,| \mathbf{v}-\
abla Y|^{2}\,dxdy \tag{17}\]  
where \(u_{x}\) and \(v_{x}\) are the partial derivatives of \(u\) and \(v\) with respect to the variable \(x\), respectively, \(u_{y}\) and \(v_{y}\) are the partial derivatives of \(u\) and \(v\) with respect to the variable \(y\), respectively, and \(\gamma(x,y)\) is the edge map of the original image. The parameter \(\mu\) is a constant that serves as regularization: it adjusts the balance between the first and the second term of the integral, and it should be adjusted based on the noise. The higher the noise, the higher the value of \(\mu\). Interpreting the energy term presented in (17), it is possible to see that if the gradient of the edge map is too small, the energy term depends only on the partial derivatives of \(u\) and \(v\). On the other hand, if this gradient is large, the integral is dominated by it, and the value of the GVF that minimizes the energy is \(\mathbf{v}=\gamma\), i.e., the gradient vector flow is equal to the gradient of the edge map on those cases. It can be demonstrated that the vector field \(\mathbf{v}=(u,v)\) that minimizes (17) is the result of the decoupled pair of differential Equations (18) and (19). \[\mu\
abla^{2}u-(u-Y_{x})(Y_{x}^{2}+Y_{y}^{2}) =0 \tag{18}\] \[\mu\
abla^{2}v-(v-Y_{y})(Y_{x}^{2}+Y_{y}^{2}) =0 \tag{19}\]  
where \(\
abla^{2}\) is the Laplacian operator. Similarly as in Equation (17), it is possible to see that in the regions where the gradient of the edge map is small, the solution of the differential equations for the GVF are the solution of Laplace's equations. Furthermore, this solution is interpolated from the boundaries of the object, and that's the reason why the resulting field, even far away from the object, points to the edges of it. The gradient vector flow of the same image as in Figure 6, is shown in Figure 7. Now, the solution to the Equations (18) and (19) provides vectors in the areas where the gradient is zero, and the vectors in the concavity contains downwards components too. Once the GVF has been computed, it is fixed for the entire the image, and what remains is the optimization equation that will guide the deformation of the active contour to the edges of the object, based on this new force. Several researchers have been working on adding gradient vector flow to the traditional snake equations. For the implementation made in Section 2.3, only GACs algorithms can be adapted to be added as an external force to the energy functional defined in the Equation (15),  
Figure 7: Example of normalized Gradient Vector Flow. (**Left**) GVF vector field for the same image used before. (**Right**) Zoom in the concavity. as it has been done in [18; 19]. A simplified version of the GVF optimization equation from [19] is used, and defined as:  
\[\gamma\frac{\partial\phi}{\partial t}=\left[\alpha\kappa-v.\frac{\
abla\phi}{ \left|\
abla\phi\right|}\right]\left|\
abla\phi\right| \tag{20}\]  
The parameter \(\gamma\) regularizes the step size, \(\phi\) is the level-set function, \(\kappa=div\left(\frac{\
abla\phi}{\left|\
abla\phi\right|}\right)\) is the curvature, \(\mathbf{v}\) is the Gradient Vector Flow vector field, and the parameter \(\alpha\) regulates the balance between the two forces. The right hand factor of (20) is added directly to Equation (15), giving Equation (21):  
Figure 5:0  
This new segmentation algorithm has been included in the list of options to segment the different prostate zones. After having implemented the _Basic ACS_ in Python, the extension with a GVF component is trivial: all the components of this new force are already available in the code except for the vector field \(\mathbf{v}\). Since this vector field is fixed for a given image, a new class has been created that solves the optimization problem for the GVF. This new piece of code is executed before the main loop of the segmentation algorithm. Since there are no rule for setting both \(\alpha\) and \(\gamma\), we arbitrarily decided to set them to 1.