A Method for Improving Renogram Production and Detection of Renal Pelvis using Mathematical Morphology on Scintigraphic Images

Dynamic renal scintigraphy is a well-established imaging technique in nuclear medicine, used to detail both the organ's anatomy and function. However, the quality of the produced scintigrams provides an often unreliable diagnostic tool because of a rather bad signal-to-noise ratio and the fact that in certain occasions the regions of interest are too concentrated making it difficult for physician evaluation. The goal of this paper is to achieve a more accurate production of the renal activity graph, by avoiding the inclusion of image artifacts in the detection process. This is achieved by treating pixels as points in a two-dimensional Euclidean space, and exploiting set-theoretic properties and morphological operators. The evaluation of the method in a number of real patient’s scintigrams obtained in a depth of 5 years, showed that, in the majority of the cases, it is feasible to produce a more accurate renogram, for both kidneys and the renal pelvis region, that was helpful for the interpretation


INTRODUCTION
Renal scintigraphy is a sensitive mean for detection, evaluation and quantification of numerous renal conditions. Scintigraphy is a diagnostic test in which a two-dimensional picture of a body radiation source is obtained through the use of radioisotopes. Radioisotopes are taken internally, and the emitted radiation is captured by gamma cameras equipped with a parallel-hole collimator to form two-dimensional images, called scintigrams, that detail both the organ's anatomy and function. Periodic capturing and post-processing of these images produces a sequence of kidney instances throughout time, along with a renogram -a graphic record that depicts the brightness variation throughout time in the image. These may help in the quantification of certain parameters of the renal function, such as the effective renal plasma flow (ERPF), the excretory index, the glomerular filtration rate (GFR), and the differential renal function.
Through the assessment of the abovementioned metrics, the physician can detect anatomic or functional abnormalities of the kidneys or the urinary tract by interpreting images and/or digital data of diagnostic quality. Such abnormalities include, but are not limited to, the detection, evaluation and quantification of possible urinary tract obstruction, the detection and evaluation of renovascular disease, the detection of pyelonephritis and parenchymal scarring, the detection and evaluation of functional and anatomic abnormalities of transplanted kidneys, the qualitative measurement of renal function and the detection of congenital and acquired anatomic renal abnormalities [1] There are various quantitative renal function protocols followed by physicians in order to detect different renal abnormalities such as those mentioned above. A protocol suitable for routine clinical use includes the injection to the patient of some kind of renal tracer such as 99mTc-MAG3 and the monitoring of its flow in the kidneys using a gamma camera in order to evaluate three distinct phases: perfusion, concentration and excretion [2]. These are depicted in the resulted images and in the renogram which help the physician to conduct visually two types of diagnoses: • Quantitative analysis, in which the physician identifies the existence of one or both kidneys, kidney deformities, and abnormalities in the renal parenchyma and finally • Renogram analysis, in which the physician examines the renal behavior throughout time, i.e. if the absorption and excretion of the radiopharmaceutical is normal.
The accurate diagnosis from the physician is subject to the physician's experience and ability to identify patterns. The physician interprets the potential findings visually, examining dynamic images, and through the washout curve shape (concave vs. convex) of the renogram. Further, the diagnosis is usually obscured by low image quality due to naturally inserted noise [3]. It should be noted that a Crucial Region of Interest

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
(ROI) in the scintigraphic images (scintigram) is restricted to a small area of the kidney, called renal pelvis, which acts as the main output funnel of the kidney. By examining the renal pelvis area, the physician can evaluate the flow of the radioisotope of the kidney.
In this paper we advocate that the above mentioned practice can become more accurate if we deploy an image processing technique that will process the renal images and isolate the ROI (renal pelvis), filter the picture from unwanted artifacts inserted by noise and finally estimate the flow of the renal tracer through the production of the renogram (renal activity graph) and of the activity graph of the renal pelvis. This is achieved by a series of algorithms applied on the scintigram with the purpose to measure the absorption and excretion of the radioisotope. We argue that the application of the overall algorithm is efficient in terms of performance and quality and we compare our results with those produced by applying a regular scintigraphy protocol without post-processing.
The paper is structured as such: Section 2 presents the related work. Section 3 analyzes the proposed algorithm. Section 4 presents details about the system implementation and the evaluation dataset. Finally, Section 5 details the conclusions reached through this endeavor.

II. RELATED WORK
Dynamic renal scintigraphy is a well-established imaging technique in nuclear medicine [4]. The intervention of the computer in the identification of important artifacts is usually reaching to the point of the depiction of the brightness of the images throughout time in the production of the renogram. The resulting graph can provide information to the physician about the flow of the radioisotope in the kidneys. However, several approaches have been proposed in the literature for postprocessing of the results in order to assist the physician to better interpret the results. Specifically, several studies ([4] [8] have shown that the automatic definition of renal ROIs that helps in minimizing user interaction in the evaluation of dynamic renal scintigraphy is generally required in the practice of nuclear medicine.
Authors in [9] state that it is a common practice to apply post-processing tools to improve the quality of the images for viewing, such as altering the display window levels and the use of filters such as smoothing or Metz. ROIs can be used to mask out areas of high uptake not related to the back such as the kidneys and bladder as well as areas of physiological high uptake within the back and pelvis such as tuber coxae, to allow better visualization of other areas within the image. ROIs can also be drawn around anatomical structures to give uptake ratios.
Moreover, authors in [10] applied fuzzy methods in order to extract time-activity curves corresponding to renal parenchyma, renal pelvis, vascular and spatially homogeneous background. Their method is applied to factor images of the renal parenchyma and identifies fuzzy regions of interest in contrast to those obtained manually in order to produce a more accurate graph for physician evaluation. Similarly to what the current paper proposes, the authors of [10] achieve the exclusion of artifacts that do not add value to the creation of the time-activity curve. However, their method is applied on a different examination protocol and they aim into isolating the activity ROIs rather than the ROIs that present the clinical interest as the current paper suggests, based on well-established practices.
In [11], the singular value decomposition method is presented as a potential tool for analysis and semiquantification of scintigrams. The results conclude that it is possible to "objectify" the interpretation of clinically relevant information contained in the images. They reduce the signal-tonoise ratio by forming the image with those singular vectors that have the greatest impact in the decomposition they use.
Other approaches are focusing on filtering out noise from the nuclear images. The most representative is [12] where the authors used signal processing methods to obtain a representation of the image in a domain where salient information could be separated from noise. The information that is contained in the noisy scintigrams is then transformed into a small number of coefficients. In turn, the coefficients are analyzed so as to derive their statistical significance. This way, the authors managed to decompose the image to its signal and noise components and to restore it once the noise components were eliminated.

RENAL ACTIVITY AND RENAL PELVIS ACTIVITY
The isolation of the kidney ROI is the result of a workflow that includes a sequence of small procedures and the execution of a number of algorithms. This process is depicted in Figure 1.

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
In the following subsections we analyze the steps of the algorithm in detail.

A. Detection of Kidney and Renal Pelvis
In this Section the main algorithm for the isolation of the area in the image that depicts the kidney and the renal pelvis is described. In brief, the developed algorithm analyzes the scintigraphic image in order to identify the ROI and produces the renogram and radiograph of the isolated renal pelvis. These radiographs are then used for the measurements.

1) Isolating the Kidney Region
The boundary tracing algorithm is taking advantage of the brighter regions of the original radiograph in order to detect the contours that delineate the boundaries of the kidney. The algorithm is performed on a binary image where nonzero valued pixels belong to an object and zero value pixels constitute the background.
Regions with high brightness that are out of the ROI, and appearing in scintigraphic images in the extreme upper and lower parts of the image (namely the heart and the bladder) were isolated by cropping the extremities of the image. After cropping the out-of-interest regions, a stretching function is applied on the image, in order to enhance the overall brightness of the image. Stretching is a procedure where we multiply the brightness of all the pixels in the image by a factor α, where 1, with Max_b=The maximum brightness value in the image.
So, after stretching, for every pixel in the image we have:

ew Brightness Value= ⋅ a Old Brightness Value
This resulted in a first approach of the isolating the ROI as seen in Figure 2. Results after cropping extremes and stretching image brightness The next step in the preparation of the image for the application of the boundary tracing algorithm is the adaptive equalization of the image, in order to enhance contrast. With this procedure, we aim in further improvement of the clarity in the image, and better brightness separation between the ROIs and the rest of the image.
The result of adaptive equalization improves the contrast in regions of the image, so that the resulting histogram follows as much as possible, the normal distribution. Neighboring regions are combined with bilinear interpolation to remove artificial boundaries created by the equalization. We can see the results of adaptive equalization in Figure 3. In order to better facilitate the application of the boundary tracing algorithm, we have to split the image in two halves, each containing one kidney. In a sample of more than eight hundred (800) renal scintigrams taken in a clinic, the result was that the image can be split in the exact center without affecting the ROIs. So, from the initial matrix of 128x128 pixels, we produce two 128x64 pixels matrices, each containing one kidney.
The next step in the workflow is to estimate the imagespecific statistical properties, in order to further adjust the image contrast, and then re-calculate them after the image adjustment. The statistical measures used are: the mean value, the median and the maximum of brightness for each of the two matrices containing the kidneys. By applying image adjustment we further improve the image contrast by transforming the brightness values so that 1% of the image data is saturated in high and low brightness.
After these preparatory procedures our image is now ready for the detection of the ROIs. Our purpose here is to make the kidney contours in the two matrices as "clear" as possible, and remove isolated bright pixels in the images, in order to feed the data to the Boundary Tracing Algorithm. By exploiting the statistical properties of the images, i.e. the mean, the median and the maximum brightness values, we compute a threshold (specific and different for different scintigraphic images), under which a pixel in the image is considered to be outside the ROI. This method was applied to a database of a private doctor's clinic, on about 850 different scintigrams and procured expected results in more than 90% of the sample. Another method that was tried on these samples was the a priori definition of a brightness threshold, only depending on maximum brightness value and ranging from 120 to 130, was found to be inadequate, producing good results in less than 60% of the sample.
The issue that rises, after the aforementioned procedures, is that of -not only possible, but almost always present-isolated

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
pixels that were bright enough to be included in the image.
Another issue that has to be tackled is also that of pixels inside the ROIs that were not included because of their low brightness (which is crucial for the final diagnosis, since low brightness pixels inside the ROIs are indicative of a pathology).Thus, in order to erase small or larger brightness regions, outside our main ROIs and re-include regions that were removed but are inside the ROIs, we apply binary mathematical morphology operators on the images. In binary morphology the image is considered to be a subset of an Euclidean space The morphology operators used are the clearing operator, the majority detection operator and the erosion operator. The clearing operator [13] removes isolated pixels that may still exist in the image, as shown in Figure 4. Example of an Isolated Pixel The "Majority detection" [13] operator is responsible for refilling "holes" inside the kidney regions, which were created by false-positive extractions due to low brightness. The Majority detection operator checks if a pixel has value 1 and at least 5 neighbouring pixels have non-zero values. If not, the pixel's value is then set to zero, as shown in Figure 5. Finally, we perform the Erosion morphological operator [13], with the unitary structural element, in order to cover regions at the edges of the kidneys, that may have been omitted from the ROI. Erosion of a binary image A in the Euclidean space E with a structural element B is defined by: where B z is the translation of B by the vector z, i.e With the erosion procedure we conclude all preparatory steps concerning our ROIs and we are now ready to isolate them from the background and apply the boundary tracing algorithm. Thus, we set the brightness value of all pixels outside the kidneys to zero. The result can be seen in Figure 6. The next step in our process is the application of the boundary tracing algorithm. Since we have "filled" all the probable gaps inside the ROI's, there is no chance that "holes" will appear in the kidney regions and thus we will later take into account every pixel belonging to them, using its brightness value to produce the Renal Activity Graph. The boundary tracing algorithm [14] returns the coordinates of the edges of and area, beginning from a pixel on its boundary, as shown in Figure 7. Now that the boundaries of the ROI's have been traced, and we have their coordinates, we proceed with the creation of two masks, one for each kidney. The masks will be used as a

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
blueprint for the kidneys in all 26 images of the scitintigraphy test, applied to each one of them, in order to calculate the sum of the brightness value of all pixels in them, and thus produce the renal activity graph. So, we create the two masks, in the form of logical arrays of size 128x64. In these masks, points inside the kidney regions have a value of 1, and points outside of these regions have a value of 0. Next, the algorithm counts how many images are included in the exam folder (usual number is 26 -one image taken per minute in the course of the exam, but, depending on the needs of the doctor and the patient, this number could vary), and then it splits each image in the two parts already explained. The algorithm then superimposes the masks on the actual images of the exam, one by one, and records for each image -separately for right and left kidney-in a new array the sum of brightness values of pixels inside the areas marked with 1 in the masks. Now, we have two 1xn arrays (n being the number of individual images in the exam). Let L(1,n) and R(1,N) be the two arrays, indicating the Left and Right kidney respectively. Now L(1,i) is the sum of the brightness values of the i-th image of the Left kidney. The remaining step is to plot these two brightness arrays in a graph that shows brightness vs. time for each kidney. In Figure 8 we can see an example result of the application of the algorithm.

2) Renal Pelvis Detection
In this section we will analyze the code for the detection of the ROIs belonging to the kidney's renal pelvis. The renal pelvis is a funnel-shaped part that connects the ureter to the kidney. Its function is to funnel urine flowing from the kidney to the ureter. The algorithm for the isolation of the renal pelvis is quite similar to the algorithm described for the isolation of the whole kidneys, in the previous section. The problem of detecting the renal pelvis is quite complex and it is a very difficult part of the organ to detect due to its uneven shape, as depicted in Figure 9. Since the images produced by renal scintigraphy are "grainy" and of low definition, the renal pelvis detection is an arduous task, performed only by the doctor at the time of the exam. Although it is very hard to discern in such small images, we have two basic "guidelines" stemming from the actual practice of isolating it visually, which we will try to exploit, in order to detect it automatically: The most prominent one is its position, at the inner edge of the kidney, and the secondary one is a very mild fluctuation of brightness at the inner edge of the pelvis, in the areas where the calyxes border with the papillae. This approach combines mathematical morphology and a "game of life"-type of approach, centered around the expected time of its maximum brightness during the exam.
After examining the physician's archives of true patients' renal scintigrams and following the physicians' guidelines, the result was that the renal pelvis was more discernible to the human eye, between the 12th and 15th minute of the examination. At this point of the scintigram, the radionucleoid is mainly concentrated on the renal pelvis, since it has began flowing from the kidney to the ureter, as depicted in Figure 10. In this figure -converted to RGB color for better discernibility-we can see the bright red spot that marks the renal pelvis in the left kidney of the patient, and the somewhat darker blue region in the right kidney (reversed image). Apparently, the specific patient's right kidney is dysfunctional, while the left may be over-active. This algorithm follows the same steps with the previous one, concerning the steps up to the boundary tracing of the kidneys. a) Creating a wide bounding box around the ROI Our task after that, is to create a wide ROI around the renal pelvises, and shrink it incrementally until we have obtained a more-or-less satisfactory boundary for the pelvis itself. Thus our first concern is to build a Bounding Box around the wider area of the pelvis, based on the data of the boundary tracing algorithm and the spatial properties of the pelvis (inner part of the kidney).

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
The first rough outline of the pelvis region is now calculated, as depicted in Figure 11.

b) Detect Pelvis exploiting statistical measures
Since we have roughly defined our initial ROI's for the renal pelvis, we can now begin tightening our knot around the area, exploiting brightness and its statistical measures. Our aim here is to produce two new images (one for each kidney) each of which will have its maximum brightness value inside the Renal Pelvis, and which will be used to "build" an as-close-aswe-can approximate outline of it.
More specifically we exploit the mean, median and maximum value of the brightness inside the Bounding Box, "evicting" from it pixels with brightness less than a certain threshold, specific for each exam, but greater than the 75% of the maximum brightness value. In this case too, it has been experimentally observed that a good rule of thumb is to initially exclude pixels with brightness less than 120-130, but this posed inaccuracies in exams with low overall brightness, so the use of the mean and maximum value was necessary to adapt the algorithm to each individual exam.

c) Applying Mathematical Morphology to ROI's
This is the most crucial part in the procedure of Renal Pelvis Detection. As we previously discussed, the shape of the renal pelvis is quite irregular and could not be described by the usual elementary structural elements, used in mathematical morphology. Nevertheless, beginning from a small core of pixels with adequate brightness and at the right position, we can create a shape which will be an adequate -although not perfect-approximation of the Renal Pelvis.
Before performing our structural transformations, we have to clear the area of any possible isolated pixels outside the Bounding Box we have created, so one more time we perform mathematical cleaning operations in both images.
After our image is cleared from isolated pixels, we now calculate the dimensions of the Bounding Box, and following, we create the structural elements of "line" and "rectangle": • The "line" structural element is defined by its length and its angle to the horizontal axis. If our Bounding Box is larger than 10 pixels in length, then the length of the "line" structural element is defined as : where [ ] denotes the integral part.
• If the Bounding Box is smaller than 10 pixels in length, then the "line" structural element has length equal to it.
• The angle of the structural element was experimentally calculated, to be 55 O for the right kidney and 125 O for the left kidney, so the structural element approximates the angle of the kidneys in the scintigram (relevant to the horizontal axis).
• The "rectangle" structural element has always dimensions of 2x1 pixels. It is adequately small to create an initial centre of reference for the mask to be extracted later.
• Having created the structural elements in the brightest spot of our bounding box, we recursively perform the procedure of mathematical erosion already described, in order to acquire an area approximating the area of the Renal Pelvis. d) Completing the procedure After having procured an approximation of the Renal Pelvis ROI, we follow the steps for mask creation described in previously, with the addition of a step of conversion of the image to RGB colour for a better visual clarity of the final image. In Figure 13 the results of the application of the algorithm in two separate patient files are shown. The algorithm produced adequate results in more than 80% of the tested samples of the physician's patients' archives. Although the algorithm is not perfect and there are imperfections in the final results of the produced activity graphs, this first implementation shows promising results and will be further exploited to produce a first Computer Aided Diagnosis tool, to help physicians in their initial evaluation of the patients' health.

IV. TEST AND EVALUATION
The algorithm was implemented exclusively in MATLAB 7.3. Our sample consisted of more than eight hundred (800) scintigrams, taken in a private clinic in a span of 5 years. The scintigrams were taken from adult patients of various ages and both sexes, both healthy and suffering from various conditions. The scintigrams were produced with GE's 3000 γ camera attached to a STARCAM computer, each exam consisting of 26 images, one per minute. The patients were injected with weight adjusted doses of 99MTc-MAG3 before the exam and LASIX during it, to evaluate excretion rate. The inputs of the algorithm consisted solely of the kidney images produced by the STARCAM and no other evaluative input was used. The images were in PNG format.
We evaluated the results of our algorithm in comparison to the results from the STARCAM computer. The main advantage of our algorithm was the removal of irrelevant to the kidneys areas outside of them. In most cases, the STARCAM computer did successfully trace the boundaries of the kidneys, but included in this trace bright areas outside the kidneys, owed to artifacts and image noise. With the present algorithm we had a success rate of more than 90% in successfully detecting the correct areas of the kidneys and more than 95% success at removing artifacts, thus resulting in a better production of the renal activity graph and aiding the doctor in a better diagnosis. In Figure 14 we can see a comparison between the detection of the kidneys by the STARCAM, on the left, and our algorithm, on the right. On the left there are inclusions of areas outside the kidneys, but on the right, after processing of the image, the algorithm outputs clear outlines of the kidneys and no other irrelevant area is included. This results in a more accurate production of the renal activity graph. Nevertheless, the differences in the end result of the produced renal activity graph are either way not huge. Since, even in the case of other areas inclusion, their total area and brightness sum are not adequate enough to influence the original activity graph in a way that would produce extreme misleading results in the doctor's evaluation. Doctors were also always taking into account in their diagnosis this fact and thus eliminated intuitively the small error factor imposed by such imperfections in the original algorithm. The bigger innovation of this algorithm though, lies in the detection and production of the activity graph for the renal pelvis area. The renal pelvis is a very difficult area to detect and trace, but our algorithm showed good results in more than 70% of the sampled images. Being an area that lies on the inner-edge of the kidney, but also with an "inconsistent" shape, and due to the numerous conditions that can be affecting it, it is deemed extremely hard to automatically detect it with extreme accuracy. Thus, the initial idea of the doctors' requirements was to produce an algorithm that would let them manually pick the area and then produce the activity graph. But since the initial algorithm performed extremely well with the whole kidneys, the idea of auto-detecting the renal pelvis with a promising success ratio was not deemed to be impossible. The production of the activity graph for the renal pelvis was judged by the evaluating physicians to be of big help in their diagnostic procedure, although of course, since the accuracy of the algorithm results varies, it was used with prudence, depending on the judgement of the doctor.

V. CONCLUSIONS
The application of the algorithm in numerous cases produced satisfactory results. The main algorithm showed great promise in accurate detection of the kidneys and production of

www.etasr.com Xefteris et al: A Method for Improving Renogram Production and Detection of Renal Pelvis…
the renal activity graph. The renal pelvis detection algorithm provided us with satisfactory first results in many cases, but showed weaknesses in some cases, by either over-covering the area of the pelvis or detecting smaller parts of it. These weaknesses were owed to brightness fluctuations in the area, exceeding the limits posed by the algorithm, which leads us to the conclusion that the algorithm needs improvement in its adaptive part, to cope for extreme conditions. Thus, both algorithms can be improved, aiming at two distinct goals. The first one being to further improve the renal pelvis detection function in order to have more accurate trace of it and thus facilitate the production of better activity graphs for it. The second goal is to evaluate modified applications of the algorithm in different kinds of medical imaging data, sourcing not only from radio-nuclear-generated imagery but from other sources as well.
It is very important to note that the purpose of the abovementioned study is not to provide a diagnosis replacing the physician but rather to provide more accurate results so as to assist him in the interpretation of findings.