Biomedical Statistics and Informatics
Volume 2, Issue 1, March 2017, Pages: 22-26

Automatic Detection and Segmentation of Kidneys in Magnetic Resonance Images Using Image Processing Techniques

Mariam Saii, Zaid Kraitem

Department of Computer Engineering, Faculty of Electronic and Electrical Engineering, Tishreen University, Latakia, Syria

Email address:

(M. Saii)
(Z. Kraitem)

To cite this article:

Mariam Saii, Zaid Kraitem. Automatic Detection and Segmentation of Kidneys in Magnetic Resonance Images Using Image Processing Techniques. Biomedical Statistics and Informatics. Vol. 2, No. 1, 2017, pp. 22-26. doi: 10.11648/j.bsi.20170201.15

Received: December 27, 2016; Accepted: January 12, 2017; Published: February 4, 2017

Abstract: Kidney Detection and Segmentation in MR images allows extracting meaningful information for nephrologists, also for practical use in clinical routine, thus we should apply an fast, automatic and robust algorithm. We demonstrate the possibility of construct an algorithm that achieve these requirements. Therefore, a novel kidney segmentation algorithm was created depending on multiple stages. The Region of Interest (ROI) is extracted after we convert the input image to binary one via specific thresholding level yields from K Mean Clustering algorithm. The resulted binary image contain both of kidneys as the biggest regions, so we can isolate them after we calculate the objects areas in labeled image. Finally we can use some morphological operation to remove small objects surrounding the kidney region. The effectiveness of this method is demonstrated through experimental results on complex MR slices. Kidneys were accurately detected and segmented in a few seconds.

Keywords: Automatic Kidney Segmentation, K Mean Clustering, Magnetic Resonance Images MRI

1. Introduction

Image segmentation is one of the most important issues in computer aided medical imaging. It is used in the analysis and diagnosis of numerous applications such as the study of anatomical structure, localization of pathology, treatment planning, and computer-integrated surgery [1]. Nowadays, medical image processing plays an essential tool in diagnosis therapy, surgical planning, preventing the diseases and complications of various body organs such as brain, heart, kidney, liver and so on [2]. In most cases, tissue segmentation in medical images is the beginning stage in analyzing those images. Segmentation of medical images is a valuable step to gathering anatomical information for diagnosis or interventional planning. Automatic and fast segmentation algorithm are thus needed for practical usage. It is yet still challenging to construct an algorithm robust enough to noise, acquisition artifacts or leakages in neighboring organs [3-4]. Systems have been developed to assist in the making of precise and objective diagnoses for lung cancer, liver tumor, and breast diseases [5-8]. However, relatively little research has been focused on kidney segmentation. A typical kidney MR image is very complicated. It usually contains kidney, liver, spleen, vertebral column, fat, and pathologies. Therefore the proposed method must be created to extracting the desired area accurately and efficiently.

2. Research Objectives and Its Methods

Kidney image segmentation is a key role for diagnosis and treatment of kidney diseases using medical image technologies. However, accurate kidney image segmentation is a challenge due to the difficulties in finding the object boundaries in MR images. This paper proposes an effective segmentation method for 2D Magnetic Resonance Images (MRI) of the human kidneys. Kidney image segmentation is not an easy task. It is one of the most difficult tasks in the visualization processes. The most Important algorithm which used to determine the thresholding level is K Mean Clustering algorithm.

2.1. K Means Clustering Algorithm

K-means clustering (k-means for short), also known as Forgy's algorithm, is one of the most well-known tool for data clustering. The goal of k-means is to find k points of a dataset that can best represent the dataset in a certain mathematical sense. These k points are also known as cluster centers, prototypes, centroids, or codewords, and so on [9-10]. K-means is also a method of partitioned clustering in which we need to specify the number of clusters before starting the clustering process. Suppose that the number of clusters is m, then we can define an objective function as the sum of square distances between a data point and its nearest cluster centers. We can follow a procedure to minimize the objective function iteratively by finding a new set of cluster centers that can lower the value of the objective function at each iteration. The data points in cluster p are represented by a set Gp with a cluster center cp. Then the square error of cluster p can be defined as [11]:


Where xi belongs to Gp. We can then define the objective function as the square error of all the m clusters, as follows:


The above objective function is also referred to as the distortion when using these cluster centers to represent the whole dataset. It is obvious that the objective function depends on the cluster centers. Therefore we need to find a systematic method for identifying these clusters and their corresponding centers for minimizing E [11-12].

Figure 1. 1- The data points, 2- After Clustering (m=3).

2.2. Region Properties Function

It is a tool used to measure the characteristics of Regions areas in the labeled binary image. Common formula for this within the MATLAB program are as follows [13]:

From the previous version, we find that Regionprops function measures the properties of Labeled Regions in the labeled matrix L. Correct positive elements corresponding to different areas of the binary image, for example: if the group elements in the matrix L is equal to one, this means that they match the region 1. The value STATS refers to the return value, it is a structure array of length equals to the greatest region length in the L matrix i.e. max (L (:)), the fields in the resulting structure matrix refer to the different measurements for each region, as they defined within the second entrance to the regionprops function. Many of the properties offered by a this function, and they are Strings series separated by a comma. If we put the string ' all ' as an entry to function, this means that all measurements of the region will be calculated, but in case it is not explained any string or were placed 'basic', the function will be calculate only the following measurements, which is: 'Area', 'centroid', and 'Bounding Box' [13]. In this research we use the 'Area' property to calculate the area of resulting foreground elements in binary labeled image, and choose the biggest ones to detect the kidney regions.

2.3. Small Objects Removing

After getting the biggest two areas, we should improve the resulted binary image, This is accomplished through morphological operations and remove small items [6]. MATLAB program offers function to do this task known as 'bwareaopen', represented as follows:

BW2 = bwareaopen (BW1, P, conn)

BW1 symbol represents binary input image, while BW2 represents the resulting binary image, and conn symbol defines the communication between the elements, or the neighborhood. It is a method to remove related items to the binary image, which is an area of less than P, where P represents an area of pixels that pre-defined by the user. Removing small objects is done by following algorithm:

1.  defines the connected objects in the image.

2.  calculate the area of each object.

3.  removes objects that area quite smaller than the P area [6].

3. Discussion

Kidney tissue is very similar to the neighboring organs tissues, so we have to create an innovative way to isolate the Kidney component, particularly the presence of two Kidneys in the single image. First, we identified a number of clusters (m=4), and apply the K Means algorithm, Figure 2 shows the clusters resulting from the input image.

Figure 2. 1-Input Image, 2-The four resulting clusters with centers.

We reshape the image to the raw matrix, and then we apply the clustering algorithm, after that we arrange ascending order of clusters centers, and calculate the level of thresholding relying on third and fourth clusters according to the following equation:


Then we convert binary image to an labeled image, and calculate the areas of all resulting labeled regions, after that we choose the biggest two areas which represent the regions of the kidney in the image. We Enhance the ROI Boundaries, and remove small objects from binary image through some morphological operation (i.e. BW-Area-Open). Finally we color the binary image and overlapping it on the original image to indicate the resulting of detection and segmentation processes. Figure 3 shows the stages of proposed method.

Figure 3. Box chart for proposed method.

4. Results

We apply the series of pervious steps on MR image, and we can notice that the proposed method can detect the kidney region, and isolate it from the neighboring regions. Figure 4 illustrates the output of each stage.

Figure 4. 1-Original Image, 2-Result of K Means, 3-The biggest two areas in labeled image, 4- Difference between the labeled image (3) and (3 minus 2 image), 5- Removing the small objects, 6- Kidneys Detection.

We can overlap the result of segmentation on original image, to see the kidney regions clearly, as the figure 5 shows.

Figure 5. 1- Original Image, 2- Overlapping the result on Input Image.

The proposed method proved its effectiveness in extracting the kidney's area in several MR images, as we notice in figure 6.

Figure 6. 1, 2, 3- Another MR Kidney Images (image 2, Image 3, Image 4), 4, 5, 6- The result of Kidney Detection.

Get a satisfactory result segmentation comes from several factors, the most important factor is the pre-choice of the optimal number of clusters, figure 7 shows that the choice of four clusters gives the best result. Table 1 shows the most important parameters of the K Means algorithm for each image, where we note the different number of iterations needed to reduce the Objective Function E, with the updating of the clusters centers with each iteration.

Figure 7. Changing number of clusters: 1-) m=2, 2-) m=3, 3-) m=4, 4-) m=5.

Table 1. Objective Function E for each image (m=4).

  Objective Function Value Iteration Num
Image 1 288.726 40
Image 2 1298.479 100
Image 3 545.485 34
Image 4 406.059 38

Compared with the most famous thresholding methods (Otsu Thresholding), we note that the result of thresholding by relying on the K Means algorithm is the best, as the Table 2 shows the quotient difference between the levels which resulting from applying the Global Thresholding way, and the second one which resulting from clustering stage.

Table 2. Thresholding Levels of two methods.

  Otsu's Level K Means Level
Image 1 0.266 0.374
Image 2 0.231 0.357
Image 3 0.152 0.401
Image 4 0.317 0.536

Figure 8. 1, 2, 3- Otsu method result, 4, 5, 6- Thresholding result depending on K Mean Clustering.

5. Conclusion

Our automatic segmentation system is expected to assist physicians in both clinical diagnosis and educational training, thus the paper presented a fully automatic method to detect and segment both kidneys in any MR Images without preprocessing step, we apply thresholding after getting four clusters from K Means algorithm, after that we enhance the output binary image via morphological (BW-Area-Open) operation which removes the small foreground elements. This method implements on different images with several sizes and comes from multiple sources.


We acknowledge the help extended by Dr. Hussam Hassoun, Al- Basel Hospital, for providing various MR images to conduct this study.


  1. D. L. Pham, C. Xu, and J. L. Prince, "Current methods in medical image segmentation" Annu. Rev. Biomed. Eng., vol. 2, pp. 315–338, 2000.
  2. Daw-Tung Lin, "Computer-Aided Kidney Segmentation on Abdominal CT Images", IEEE TRANSACTIONS ON INFORMATION TECHNOLOGY IN BIOMEDICINE, VOL. 10, NO. 1, 2006.
  3. Moe Myint, Theingi Myint, "Effective Kidney Segmentation Using Gradient Based Approach in Abdominal CT Images", International Conference on Future Computational Technologies, ISBN 978-93-84468-20-0, pp. 130-135, 2015.
  4. A. Reeves and W. Kostis, "Computer-aided diagnosis for lung cancer" Radiologic Clinics of North America, vol. 38, no. 3, pp. 497–509, 2000.
  5. E. L. Chen, P. C. Chung, C. L. Chen, H. M. Tsai, and C. I. Chang, "An automatic diagnostic system for CT liver image classification," IEEE Trans. Biomed. Eng., vol. 45, no. 6, pp. 783–794, 1998.
  6. Zaid Kraitem and Dr. Mariam Saii, "Automatic Detection and Measurement of Abdominal Circumference in Fetal Ultrasound Images" International Journal of Information Research and Review. Vol. 03, Issue, 03, pp. 1997-2000 March, 2016.
  7. D. Trevathan-Ramirez, "Innovations in breast disease diagnosis," Radiology Technol., vol. 70, no. 2, pp. 197–203, 1998.
  8. D. T. Lin, C. C. Lei and S. W. Hung, "Computer-aided kidney segmentation on abdominal CT images," IEEE Transactions on Information Technology in Biomedicine, vol. 10, no. 1, January 2006.
  9. Nir Ailon, Ragesh Jaiswal, and Claire Monteleoni. "Streaming k-means approximation". In NIPS, pages 10-18, 2009.
  10. Stuart P. Lloyd. "Least squares quantization in pcm". IEEE Transactions on Information Theory, Vol. 28, No.2, PP: 129-137, 1982.
  11. Chris H. Q. Ding and Xiaofeng He. "K-means clustering via principal component analysis". In ICML, 2004.
  12. Hongyuan Zha, Xiaofeng He, Chris H. Q. Ding, Ming Gu, and Horst D. Simon. "Spectral relaxation for k-means clustering". In NIPS, pages 1057-1064, 2001.
  13. Dr. Mariam Saii, Dr. Issa Ibraheem, and Zaid Kraitem. "Auto Measurement and Segmentation of Head Region in Fetal Ultrasound Images". Tishreen University Journal, Syria. ISSN: 2079-3081, Vol. 38, No. 3, 2016.
  14. J. S. Hong, T. Kaneko, S. Sekiguchi, and K. H. Park, "Automatic liver tumor detection from CT," IEICE Trans. Inf. Syst., vol. E84-D, pp. 741–748, 2001.

Article Tools
Follow on us
Science Publishing Group
NEW YORK, NY 10018
Tel: (001)347-688-8931