An Implementation of Diabetic Retinopathy Grading System on Android Device Using Fully Automated Algorithm Duc Ngoc Tran Computer Engineer Faculty University of Information Technology Ho Chi Minh, Vietnam ductn@uit.edu.vn Abstract— Diabetic retinopathy (DR) is a diabetic eye disease which causes damage to the blood vessels in the retina. Most of studies are applied in MATLAB environment that is designed for research only. For solving these problems above, a new prototype of Android based DR grading system will be introduced in this study. The proposed design architecture emphasizes and enhances the computing power usage efficiency of DR grading system in ARM platform running Android. The novelty lies in the idea of creating MATLAB-like environment using IT++ library to ease the conversion from MATLAB source code to C++. Another contribution is applying the multithreading technique to image processing module to decrease the execution time in Android OS. This approach have improved the system in terms of execution time with 14.5 seconds. Keywords—Diabetic retinopathy, Android, multithreading I. INTRODUCTION (HEADING 1) Diabetic retinopathy (DR) is the common diabetic eye disease that eventually develops to some degree in almost all long-standing diabetic patients. DR severity is divided into five levels including no DR, mild non-proliferative diabetic retinopathy (NPDR), moderate NPDR, severe NPDR and proliferative diabetic retinopathy (PDR) [1]. In previous research, CISIR in UTP has developed successfully the automatic computerized DR Grading system running in MATLAB [2]. This current system has achieved many advantages such as high accuracy, quick diagnosis, low cost and suitable for diabetic patient. However, the previous computerized DR system requires a personal computer to operate, so it is cumbrous machine, which is less mobility than other portable machine like popular modern tablet or smartphone. Another disadvantage is the requirement of the environment to use this system that is MATLAB. This environment is only designed to use in a laboratory in which the researchers can easily develop and modify the algorithm in research and development stage (R&D stage). Thus, this system is not suitable for mass screening of a large number of diabetic patients nationwide. Based on several reasons above, a portable, mobile and standalone DR system is very necessary. In this study, a new XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE prototype of standalone and portable computerized DR grading system using fully-automated DR algorithm will be introduced. II. LITERATURE REVIEW A. Diabetic Retinopathy Diagnosis System Over the last decade, there was a rapid development of automated DR pathology detection systems. These automated diagnostic systems are based on several types of lesions of the eye to detect certain pathologies such as microaneurysms, hemorrhages, exudates, cotton wool spots and distances between the exudates and foveas [3]. Another approach for automated grading system is the analysis of Foveal Avascular Zone (FAZ). Foveal avascular zone is a circular area of retina which is responsible for central and color vision and devoid of capillaries in the macular region [4]. In diabetic retinopathy, the loss of capillaries in the perifoveal capillary network make an enlargement of the FAZ [5]–[7]. A group of researcher at the Centre for Intelligent Signal and Imaging Research (CISIR) in Universiti Teknologi Petronas studied a method for measurement of FAZ based on digital color fundus images. In these studies, the increase of FAZ is strongly correlated to the progression of DR from normal, mild NPDR, moderate NPDR, and severe NPDR. This promising approach will be widely used in the future due to its advantages such as ease of operation, low cost and quick diagnosis. This approach of automated DR grading system includes three main processes, i.e. contrast enhancement of retinal vessels, segmentation of retinal vessels and DR grading based on analysis of FAZ [2] as shown in Figure . In the first process, Retinex and Independence Component Analysis (ICA) are used to conduct the contrast enhancement. The output of this process is fundus image, which has high contrast retinal blood vessels. The second process is used to segment the retinal blood vessels in the fundus image. First, the blood vessel detection algorithm named Chaudhuri is utilized by applying a series of digital filters. The segmentation of retinal blood vessel is generated by automatic region growing method. In the last process, the blood vessel endpoints at perifoveal capillary are detected using segmentation result in previous process. The foveal avascular zone area is determined by detecting all nearest points to the center of macula. The size of FAZ is the size of a specific area, which is formed by connecting these detected points encircling the perimeter of macula. Radius of FAZ, which is defined as half of the longest line that connecting to detected points of FAZ, is also calculated to give another parameter for DR diagnosis. Fig. 1. Flowchart of fully automated DR algorithm B. Development Platform To implement a mobile system for the DR Grading system, the market include many available embedded high performance platforms including ARM-based MCU, MIPSbased MCU, Power Architecture-based MCU or x64/x86based MCU. On these platforms, ARM has a fast growth speed and combine many good characteristics for an effective embedded system such as low power consumption, low cost and high performance. ARM architecture is chosen to develop the portable DR grading system in this project. To build a good system, the DR grading system need a potential OS to make a good interaction with the user. Using Linux kernel with many libraries and APIs written in C, Android provides an open-source and convenient platform for implementation and maintain. As a Google’s product, Android has a major role in the direction of the embedded industry. By using Android OS in this project, a vast of benefits as above can be achieved for this product and continuous improvement ability for the next version of portable DR grading system. C. Project Library Implementation The DR algorithm requires many subroutines for most basic algorithms in numerical linear algebra such as matrix factorization, systems of linear equations, matrix multiplication. Blount used JLAPACK, a subset of the LAPACK library in Java, library to implement high performance numerical software in Java [8]. When used with the native BLAS library, JLAPACK performs comparably with the Fortran version of LAPACK using the native BLAS library. They found that the Java version is about two or three times worse than the Fortran version on the larger problem sizes for both the factorization and the triangular solve. The interpreted Java implementation was unusably slow. In addition, the performance when the native BLAS library was used increased significantly. This demonstrates that the native library provides better performance. Mouton made a study of the existing linear algebra libraries that can be used from C++ [9]. This study showed that LAPACK library is essential library for linear algebra libraries. It provides high performance linear algebra computation for many scientific computing softwares. To implement the algorithm in MATLAB to Android OS efficiently, a library of mathematical and signal processing is very necessary. IT++ is a C++ library of mathematical, signal processing and communication classes and functions. Its main use is in simulation of communication systems and for performing research in the area of communications. The kernel of the library consists of generic vector and matrix classes, and a set of accompanying routines. Such a kernel makes IT++ similar to MATLAB [10]. Cristea has presented an extension of the IT++ library useful for the study of turbo receivers [11]. In this research, the advantage of using a compiled language (C++) for complex algorithms implementation was clearly demonstrated. The IT++ library, with its MATLAB-like kernel, is in their opinion a good replacement for MATLAB and other interpreted languages used by scientists and engineers as simulations tools. III. IMPLEMENTATION The Figure 2 shows the design of portable DR grading system. In this design, the computing component comprises a mathematical library module and an IT++ library module. The mathematical library module implementing LAPACK (Linear Algebra PACKage) and BLAS (Basic Linear Algebra Subroutine) algorithms are placed at the lowest layer in the design as essential libraries for other modules in the upper layers. Since it is a standard mathematical library, the results provided by the lower layer are reliable. The mathematical library module provides a set of routines such as matrix multiplication, solving linear equations and matrix decomposition for modules placed at the upper layers which are actual application modules such as Retinex, Independent component analysis (ICA), Region growing and Chaudhuri’s algorithm of the grading component. It will use all the essential classes and functionalities, which are provided by lower layers, to implement the algorithm. Thus, if there is any change in design or upgrading, only the upper layer modules need to be modified, the lower layer module remains stable. This will save a lot of time for debugging the lower layer. Based on LAPACK and BLAS, IT++ library module is capable of providing many useful signal processing functions. IT++ library module is an open source C++ library of mathematical, signal processing and communication classes and functions. Its main use is in simulation of communication systems and for performing research in the area of communications. The IT++ library component implements a Fast ICA package and a Kurtosis algorithm. The kernel of the IT++ library component consists of generic vector and matrix classes, and a set of accompanying routines. Such a kernel makes IT++ library component similar to MATLAB. Thus, a MATLAB-like environment with IT++ is created to ease the conversion from MATLAB source code to C++. The IT++ library component of the present design, which employs the native C code, achieves much better performance than using the same algorithm running on Java code. Although IT++ is not designed for Android platform, it can run in Android with modification in source code related to Android.mk file and IT++ source code. Fast ICA and Chaudhuri modules are time critical function, which accounts total 86% of execution time in DR grading system. Thus, these modules will be investigated to give appropriate solutions for optimization. Fig. 3. Android based DR grading system profile B. Retinex Optimization In DR Grading system algorithm, three channels of the image is undergone the Retinex processing sequentially. Three results after this processing are used as inputs to ICA module. Because the processing of each channel is independent with each other’s, the multithreading technique can be applied in this case to improve performance by utilize multi-core architecture in modern ARM processor as Figure 4 below. Fig. 2. Android based DR grading system design This template, modified in MS Word 2007 and saved as a “Word 97-2003 Document” for the PC, provides authors with most of the formatting specifications needed for preparing electronic versions of their papers. All standard paper components have been specified for three reasons: (1) ease of use when formatting individual papers, (2) automatic compliance to electronic requirements that facilitate the concurrent or later production of electronic products, and (3) conformity of style throughout a conference proceedings. Margins, column widths, line spacing, and type styles are builtin; examples of the type styles are provided throughout this document and are identified in italic type, within parentheses, following the example. Some components, such as multileveled equations, graphics, and tables are not prescribed, although the various table text styles are provided. The formatter will need to create these components, incorporating the applicable criteria that follow. IV. SYSTEM OPTIMIZATION A. Android based DR Grading System Analysis Figure 3 shows the profile of Android based DR Grading system for ARM architecture. It demonstrated that Retinex, Fig. 4. Multithreading optimization in Retinex Ten images from FINDeRS database are chosen randomly to evaluate the performance of Retinex module. Xiaomi Mi 5 with Snapdragon 820 quadcore 1.8GHz is used to as the experiment platform. In general, multithreading technique can improve performance in Retinex with speedup factor 1.91x C. Blood Vessel Detection (Chaudhuri’s Filter) Optimization In the previous study, an optimization of blood vessel detection in retina images has been studied [12]. This algorithm is integrated to DR Grading system to gain more performance. The performance of native code achieves about 92.77% faster Java code after applying multithreading method. The multithreading technique can bring 1.9x performance gain for native code. be further analyzed using relationship plots of DR-Android against DR-MATLAB data as shown in Figure 5. V. RESULT & DISCUSSION The experiments have been performed to validate the design and optimization of Android based DR Grading System. Firstly, resource consumption of the system is benchmarked in Xiaomi Mi5 which is configured to run on Android 6.0 and Snapdragon 820 quadcore 1.8Ghz. A. Resource Consumption A total of 100 images samples in FINDeRS database have been undergone to the Android based DR Application to obtain the CPU and Memory usage of each image. The mean CPU and Memory usage of 100 images is the average CPU and Memory usage of the DR Application on the Mi5 phone. Fig. 5. FAZ radius obtained by the DR-Android against DR-MATLAB C. Execution time comparison TABLE I. CPU Usage Memory Usage AVERAGE CPU AND MEMORY USAGE OF THE DR APPLICATION ON THE MI5 Resource Consumption 67.52 % 148479 KB The Table I shows the average CPU and memory consumption of Android based DR Grading running on PandaBoard. During the experiment to measure the CPU and memory usage, the application can use 99% CPU resource in Chaudhuri’s filters module and the memory usage is always below 150 MB. This result proved that the multithreading technique, which has been applied in Chaudhuri’s filter, Retinex module and Fast ICA module module, utilized all available resource and increase the efficiency of CPU utilization. B. Diagnosis Accuracy Comparison From the FINDeRS database, 100 fundus images are chosen to undergo to the DR Grading system in MATLAB (DR-MATLAB) and Android (DR-Android) to collect results in both system STATISTICS OF ERROR OF FAZ RADIUS FOR THE ACCURACY ANALYSIS OF THE FULLY AUTOMATED DR SYSTEM IN MI5 In the following experiment, several test cases are conducted to measure execution time in three devices including Xiaomi Mi5 and PC (MATLAB). The PC, which is used in this experiment, has Core i7 3.0 GHz with 8 cores, 8 GB RAM. TABLE III. EXECUTION TIME COMPARISON BETWEEN TWO DEVICES Android Xiaomi Mi5 No. of Fundus images Average execution time (second) PC (MATLAB) 100 100 14.5 11.2 Although PC with MATLAB still can complete the algorithm in 28.35 seconds which is faster than Mi5, it is not a significant difference with the performance gap between PC and Mi5. The regression analysis of Figure 5.2 shows strong linear relationship of DR-Android system with DR-MATLAB. It is indicated by their most perfectly linear regression line. TABLE II. DR-MATLAB – DR-Android No. of fundus image samples Mean absolute error (pixels) Std. deviation (pixels) Lower bound (pixels) Upper bound (pixels) 100 2.63 2.29 0.32 7.91 From 100 observations, the maximum error produced by the DR system in Android when using FAZ radius is less than 8 pixels with a significantly small standard deviation (less than 3 pixels). It indicates that the DR system in Android has very limited difference with the DR system in MATLAB. This can VI. CONCLUSION Android based DR Grading System, a portable standalone diagnosis devices for DR, has been development successfully. The evaluation is confirmed that DR Grading in Android is very similar with the DR in MATLAB with significant small the mean absolute error (FAZ radius: 2.63). The design and optimized techniques has been utilized the hardware resources effectively to reduce the execution time. The techniques includes native code, multithreading. Thus, the final version of Android based DR grading system had a lot of improvement in terms of execution time with 14.5 seconds. ACKNOWLEDGMENT The research is funded by Computer Engineering Faculty in project D2016-03, University of Information Technology – Vietnam National University. [7] [8] REFERENCES [1] [2] [3] [4] [5] [6] “American Academy of Ophthalmology. Preferred Practice Patterns : Diabetic Retinopathy PPP - September 2008,” Am. Acad. Ophthalmol., 2008. A. F. M. Hani et al., “Toward a Fully Automated DR Grading System,” vol. 37, Springer Berlin Heidelberg, 2012, pp. 663–666. O. Faust, “Algorithms for the Automated Detection of Diabetic Retinopathy Using Digital Fundus Images: A Revi,” J. Med. Syst., 2010. G. Richard, G. Soubrane, and L. Yanuzzi, Fluorescein and ICG Angiography. New York: Thieme Medical Publisher Inc, 1998. J. Conrath et al., “Semi-automated detection of the foveal avascular zone in fluorescein angiograms in diabetes mellitus,” Clin. Experiment. Ophthalmol., vol. 34, no. 2, pp. 119–123, 2006. G. H. Bresnick, R. Condit, S. Syrjala, M. Palta, A. Groo, and K. Korth, “Abnormalities of the Foveal Avascular Zone in Diabetic [9] [10] [11] [12] Retinopathy,” Arch. Ophthalmol., vol. 102, no. 9, pp. 1286–1293, Sep. 1984. J. Conrath, R. Giorgi, D. Raccah, and B. Ridings, “Foveal avascular zone in diabetic retinopathy: quantitative vs qualitative assessment,” Eye, vol. 19, no. 3, pp. 322–326, Jul. 2004. B. Blount and S. Chatterjee, “An Evaluation of Java for Numerical Computing,” in Computing in Object-Oriented Parallel Environments, vol. 1505, D. Caromel, R. Oldehoeft, and M. Tholburn, Eds. Springer Berlin / Heidelberg, 1998, pp. 501–502. C. Mouton, “A study of the existing linear algebra libraries that you can use from C++ (Une ’etude des biblioth\`eques d’alg\`ebre lin’eaire utilisables en C++),” Comput. Res. Repos., vol. abs/1103.3021, Mar. 2011. Free Software Foundation, “IT++ - Scientific Library.” [Online]. Available: http://itpp.sourceforge.net/current/index.html. [Accessed: 09-Sep-2012]. B. Cristea, “Turbo receivers with IT++,” in Proceedings of the 2nd International Conference on Simulation Tools and Techniques, ICST, Brussels, Belgium, Belgium, 2009, p. 17:1–17:7. D. N. Tran, F. A. Hussin, and M. Z. Yusoff, “Optimization of blood vessel detection in retina images using multithreading and native code for portable devices,” in 2013 IEEE 9th International Colloquium on Signal Processing and its Applications, 2013, pp. 194–198.