Automated Computer Vision System for Urine Color Detection

Abstract


Introduction
Urine color is an indicator of health status.Urine color can indicate infections or disorders, such as urinary tract infections, kidney trauma, dehydration, or injury.Foods, metabolic products, and medications can cause changes in urine color.Normal urine color is pale yellow [1], and abnormal urine colors are pink, red, brown, orange, white, blue, and greenish.Table 1. is a list of the common causes of urine color: Table 1.Urine color and it is causing

Color
The Reasons Yellow Normal urine color ranges from pale yellow to deep amber.
In the healthcare domain, many diseases can be diagnosed by observing urine color, changes in the urine color can be a sign of an underlying serious disease, especially for patients undergoing treatment.Diagnosis of the potential causes of urine coloration can assist clinicians in developing the treatment strategy and it will assist in determining which test should be ordered and in eliciting any relevant history of medication or food use, as well as any other condition that may be contributing to abnormal urine color, this is the primary motivation for developing the proposed system which aims to design and implement a safe, low-cost, real-time and reliable urine color detection system based on urine color analysis and a machine learning algorithm to find related pathological conditions for early warning.Additionally, it improves the ability of the proposed system to process samples under different light conditions.Moreover, it presents an effective remote communication system based on (GSM) module for communicating results to the care provider or patient.The proposed system provides a solution to reduce impaired color discrimination by the naked eye by using an (RF) algorithm to provide a higher classification, accuracy, and faster to predict urine color under different light conditions in real-time detecting urine color and then sending the status over (GSM) to the care provider.

Related Works
To automatically increase the accuracy of measurement and obtain reliable results of urine color identification, a computer vision system has been developed in recent times.It is largely acquired attention from the researchers of various analyses.For instance, a study by Hortinela et al. [26] suggested an image-processing technique for identifying the presence of urine crystals in the patient's urine sample.A Raspberry Pi camera was put on the microscope's ocular to take an image of the urine sediment under a microscope.The method detected the edges of the crystals using the Harr feature, with used AdaBoost and support vector machine (SVM) to classify the crystals detected in the urine sediment.
The researchers took photographs of thirty urine samples.Compared to a standard urinalysis, the test achieved a 90% accuracy rate this method cannot detect false negatives.Another study by Mathaweesansurn et al. [27] introduced a new patterning of the microfluidic-based analytical device (μPAD) technique for the assay of creatinine in urine utilizing a contact stamping method.A center zone coupled with eight surrounding thin channels makes up the PAD's design.On this channel, conventional solutions have been added.A circular area that was loaded with reagents was connected to each channel.The other end of this reagent zone is connected to the last circular detecting zone by a second thin tube.Once a urine sample has been introduced, the Jaffé reaction's orange-colored end product forms in the eight detection zones.The amount of creatinine was then measured using the ratio of (R/G) intensity that was acquired from a digital image of the PAD taken using a tablet camera.This method's linearity was excellent but it is affected by the volume of the urine sample.A new magnetic lateral flow strip that can both qualitatively and quantitatively detect cocaine in urine was introduced by Wu et al [28].It makes use of image processing technology and a cell phone.Eight urine samples were used in this process.Using software for image capturing on a cellphone, the color of a magnetic bead (MB) was used as a visual signal, and the color density of (MB) was translated into a digital signal (gray value), which was used as a quantitative signal.Cocaine has a prorated standard deviation of less than 10%.The analysis took less than 10 minutes, and the limit of visual detection was 5 ng/mL.MB is perfect for recording drug addiction histories because it is remarkably consistent at room temperature.Another study by Jalal et al. [29] proposed a brand-new, low-cost hybrid microfluidic device for the colorimetric detection of urine indicators, such as PH, protein, glucose, and red blood cells (RBC), using a smartphone-based optical platform.To maintain a consistent colorimetric reaction time, the hybrid device successfully demonstrated the precise control of sample solution volume inside the device microchannel, reducing measurement inaccuracy caused by time-dependent factors.A smartphone APP and image processor were used to simplify the colorimetric urinalysis and decrease observer and measurement variability in the standard colorimetric POC.A study by Ravazzi et al. [30] presented a digital imaging method for captopril determination based on the spot test reaction between captopril and palladium (II) chloride, which generates a yellow, water-soluble complex.A smartphone camera and portable equipment designed for internal illumination control were used to take digital pictures of reaction mixtures.Digital image processing employing the RGB technique was used to create a quantitative relationship between color intensity and captopril concentration.The percentage of recovered samples of synthetic urine varied from 97.1 to 102.9 percent.When the outcomes were compared to the reference method, there were no appreciable differences at the 95 percent confidence level the limitation of this method is the need to control the light from portable apparatus.Another study by Budianto et al. [31] presented a method for using image processing to help with the interpretation of the findings of strip tests by taking pictures of the strip using a smartphone.According to the findings of 30 experiments, the system can identify and distinguish strip discolouration, split the reagent, and categorize blood with 93.4 percent accuracy (to identify kidney stones) and glucose with 90 percent accuracy (to identify diabetes).To count the white blood cells (WBCs) and red blood cells (RBCs) in a urine sample, Cruz et al. [32] employed Canny edge detection and circular hough transform methods.The cameracaptured images were rescaled into grayscale using the Canny Edge Detection technology, which also created the image's edges.The algorithm for determining whether there was blood in the urine was the circular Hough transform.This method's accuracy, measured against actual RBC and WBC counts, was 93.229%.The limitation of this method was it did not include the data storage feature.Another study by Wang et al. [33] suggested using colorimetric detection and a smart camera to measure the glucose levels in urine.They noticed the color fading caused by the oxidation of glucose using the (HRP-H2O2-TMB) technique (GOD).96 microplates are set on a white background, and an image is taken using a smartphone camera held horizontally 20 cm directly above the microplates.The digital value of the image is then examined in RGB.
The color of the solution faded as the glucose concentration increased.Linearity and great repeatability made this approach stand out.This method's drawback was that as H2O2 levels rose, HRP formation may be inhibited.Two colorimetric detection techniques have been developed for paper-based creatinine sensors Lewińska et al. [34].Utilizing a smartphone that has been modified with 3D-printed components, the signal is read and processed.The Jaffe method-based approach and the 3,5-dinitro benzoic acid-based approach were the two colorimetric methods that were evaluated and contrasted.The hue channel intensity in the Hue Saturation Value (HSV) color space and the green channel in the RGB color space was employed as analytical signals in the Jaffe and 3,5-dinitrobenzene procedures.The approach used synthetic urine samples, and the recoveries ranged from 70 to 129 percent.This technique was limited in that it required a colorful area on a uniform background for the photo to be taken.
In this paper, a detection system for urine color is proposed that relies on finding the changes in the color of urine.This involves the use of a Webcam to take images of urine samples.The taken digital images are then analyzed by a computer program, and the color components are extracted, classified by using a random forest (RF) algorithm, and then determined the urine color.The proposed system developed a powerful tool to detect abnormal urine color and related pathological conditions in real-time, with low cost, short time, and different light conditions.

Data Collection
In the proposed system, two different groups of data were used.The first set of data was used to design and implement the RF algorithm, which consisted of 710 pictures of samples of urine in different colors that were fed as input for the proposed RF algorithm.These images will be processed, used as features, saved in a CSV file, and used as trained data the resolution of images was 1920*1080, the type of images (png), and the number of images for class 1= 98, class 2= 88, class 3= 90, class 4= 95, class 5= 83, class 6= 82, class7= 90, class 8= 81.This process involves two stages, training of data and testing of data.At first, 80% of the dataset was trained to design an RF algorithm, and 20% of the remaining dataset was used to test the system.The output is a trained classifier model.The second type of data was used to operate the system and detect the color of urine.It was obtained using colored solutions to cover different colors of urine with one sample of urine from a healthy volunteer in the color yellow in real-time.The sample was placed in front of a webcam (Logitech C615) at a distance of roughly 15 cm, with a white background, and numerous images were taken under varying lighting conditions at various times.

System Framework
The schematic diagram of the proposed urine color detection system is presented in Fig. 1.The system framework relies on analyzing urine color, including image processing techniques, RF algorithm, and the practical circuit.

Urine Color Analysis
When the Webcam captures the image, a MATLAB algorithm is used to detect the urine color from the captured images in real-time by using image processing techniques, including analyzing the image into color space by conversion from RGB color space to YCbCr (Luminance, Chrominance) color space, and then converted it to binary scale to simplifies the operation of the recognition.Then morphology operations were used to remove image noise and enhancement the image.Finally, the ROI will be selected and analyzed into (R, G, B, Y, Cb, and Cr) components and then classified using the RF model, as shown in Fig. 2.
Fig. 2. Flowchart of the used image processing techniques The color of urine will be classified, the reasons are diagnosed, and the outcome is shown in the GUI panel, as shown in Fig. 3.
Fig. 3.The GUI main panel of the proposed urine color detection system

The Practical Circuit
The main components of the practical circuit in the proposed system are shown in Fig. 4. A Logitech C615 portable HD Webcam was employed in the proposed system, which provides high-quality image capture.At First, a Webcam is used to take pictures.The taken images are analyzed by a Matlab program.The color components were extracted and then classified the color of the urine was by using the RF algorithm.Second, an Arduino microcontroller was used to send a message via the GSM module to care providers or patients.

Experimental Results
The efficiency of the proposed system was tested by using a urine sample from a healthy volunteer in the color yellow, and the remaining colors (green, red, orange, brown, pink, and white) were produced using colored solutions to replace and cover other abnormal urine colors in realtime.With a white background, numerous photos were taken using a webcam with various lighting conditions at a distance of 15 cm from the sample.The suggested approach correctly identified all of the sample colors under various lighting conditions.Table 2 shows the summary obtained after applying the proposed detection algorithm to samples in real-time.
Table 2.The results were obtained using the proposed system in real time

Discussion
To evaluate an accurate RF algorithm and accurate urine color detection, this study used recall, accuracy, precision, and F-measure as evaluation metrics.These metrics of the proposed system can be shown in Table 3. From the confusion matrix of the proposed system, it can be noticed from Fig. 5 that the precision of the proposed system was 97%.  4.  5 show the comparison between the proposed RF, SVM, and K-Nearest Neighbors (KNN) algorithms currently used by the existing works in terms of precision, accuracy, recall, F-measure.As the comparison shows, the proposed RF algorithm has maximum accuracy and minimum error rate with outperforms the existing approaches in all cases.Its ability to cover missing information without sacrificing accuracy allowed the proposed model to extract the features more accurately.In addition, it allows the estimation of the important variables in the classification and selects only the features that highlight the intrinsic characteristics to predict the correct class and detect the color of urine.Moreover, the ability of deals with a large number of input variables without deleting any variables allowed the model to detect more than one color in the proposed system.The proposed system resolved the difficulties by utilizing the RF algorithm, which quickly and accurately identified the colors under various lighting situations and without the need to change the lighting.This allowed the system to diagnose urine colors with a high degree of accuracy.The findings demonstrated that the suggested system has a high level of urine color detection accuracy (about 97%).There is a limitation on choosing the ROI, though, if the urine color and the picture background are the same and if the distance between the samples and the camera is greater than 50 cm.

Conclusions
The abnormal color of urine can be distressing for physicians and patients alike.A change in urine color could be an indication of health status or an underlying medical disease, or it could be brought on by drugs, dyes, or toxins that give urine an odd color.In the proposed system, a powerful tool was developed to detect the color of urine and related pathological diseases in real-time, at low cost, in a short amount of time, with high accuracy, approximately about 97%, and under various lighting circumstances.An accurate computer vision for urine color detection was presented in the proposed system depending on the RF algorithm and image processing.Additionally, the ability to send the result to the mobile phone of the patient or care provider by using the GSM module.In future work, the detection accuracy will be enhanced by utilizing a smartphone instead of a camera, with adding the capability to test many urine samples at once and display the results for each sample separately.This might produce better outcomes in terms of movement flexibility and detection speed.

Fig. 1 .
Fig. 1.The schematic diagram of the proposed system

Fig. 4 .
Fig. 4. The main components of the practical circuit of the proposed system

Fig. 5 .
Fig. 5.The confusion matrix of the proposed model The correct and incorrect classification of instances for each class of the proposed model is shown in Table4.

Table 3 .
The precision, accuracy, recall, and F-measure of the proposed model

Table 4 .
TP, TN, FP, and FN of the proposed model

Table 5 .
Comparison of prediction performance Measures between the proposed RF, SVM, and KNN approaches