A. MRI Databases (Data Acquisition)
In our study, Signa HDxt 1.5 T scanner of General Electric Company was used, this unit is equipped with an 8-channel coil for knee examination. Axial T2 (fat saturation), Coronal Proton Density (fat saturation), Coronal T1, Sagittal T2 (fat saturation), and Sagittal Merg were performed on a patient's knees using the standard procedure in five sequences. Axial T2 and sagittal T2 images were used in our research. In this paper, we have suggested using the Marker-Controlled Watershed Transform Technique to remove baker's cyst in MRI images using MATLAB (r2018b) software.
Image preprocessing was one of the primary steps in advanced algorithm. The aim of preprocessing operation for input images was edge detection and image noise reduction. At the beginning of this process, images are converted to grayscale; in the next step, Sobel code is used for edge detection and noise reducing, and low-pass filtering is utilized by using Gaussian kernel. Sobel is a mask that detects points on the edge of an image. Based on the mask’s coefficients, it gives more value to the neighboring edges whereupon better edges are gained [9]. Gaussian kernel is a two-dimensional low pass filter, the formula of which is presented below:

Where D0 and D(u,v) are the cut-off frequency and distance from the center of rectangular frequency, respectively [9].
C. Segmentation
C.1. Gradient Magnitude Calculation
Before using the watershed transform for segmentation, it's common to use gradient magnitude to pre-process a gray-scale image. High pixel values along object edges and low pixel values everywhere else characterize the gradient magnitude image [9]. Therefore, using the linear filtering technique in this method, the gradient magnitude of the gray-scale image is computed. The gradient vector magnitude and the angle at which the maximum rate of change of intensity level occurs at the specified coordinates (x, y) can be computed for any gray-scale image (x, y) at coordinates (x, y) using Eq. (2) and (3).

The gradients in the x and y directions are g1(x, y) and g2(x, y). The Sobel masks H1 and H2 - used to calculate the magnitude of these gradients- are described by Eq.(4)[9].
C.2 Watershed Transformation
The watershed transformation is a popular image segmentation technique based on analytical morphology. It's a gradient-based segmentation system with catchment basins as the segmented areas. By treating a picture as a surface with high light pixels and low dark pixels, the watershed transform detects catchment basins and watershed ridge lines. [9,10].
As previously mentioned, the key issue with the watershed transform is over-segmentation, which results in a large number of segmented regions in each image's local minimum. This technique has made a change in image intensity that constructs extra-regional minima due to the over-segmentation difficulty. To control over-segmentation, markers of the gradient image beginning from these markers instead of regional minima are recommended [11]. Marker-controlled watershed segmentation is a systematic procedure that reduces the over-segmentation difficulty [12].
C.3 Marker-Controlled Watershed Transform algorithm
Dividing touching objects in an image is one of the most difficult image processing steps. For this issue, watershed transforms are commonly used. Marker-controlled watershed segmentation has proven to be a reliable and versatile method for segmenting artifacts with closed outlines, with ridges indicating the boundaries. Foreground and backdrop markers are aligned with internal and external markers, respectively. Following segmentation, the watershed sections' boundaries are drawn on desired ridges; hence, using the watershed transform to separate any object from its neighbors' segmentation works best if you can distinguish or "mark" foreground and background objects and locations. In these procedures, marker-controlled watershed segmentation is used; compute a segmentation function for the items we were trying to segment in this section. The second phase involved calculating foreground markers to link blobs of pixels within each of the objects. Because of the presence of pixels that were not part of an entity, the next step was to compute background markers. The segmentation feature was then modified to provide minima only at the foreground and background marker positions. Finally, the watershed transform of the modified segmentation function was computed [9,10].