A new method for detecting the outer corneal contour in images from an ultra-fast Scheimpflug camera

Background The Corvis® ST tonometer is an innovative device which, by combining a classic non-contact tonometer with an ultra-fast Scheimpflug camera, provides a number of parameters allowing for the assessment of corneal biomechanics. The acquired biomechanical parameters improve medical diagnosis of selected eye diseases. One of the key elements in biomechanical measurements is the correct corneal contour detection, which is the basis for further calculations. The presented study deals with the problem of outer corneal edge detection based on a series of images from the afore-mentioned device. Corneal contour detection is the first and extremely important stage in the acquisition and analysis of corneal dynamic parameters. Result A total of 15,400 images from the Corvis® ST tonometer acquired from 110 patients undergoing routine ophthalmologic examinations were analysed. A method of outer corneal edge detection on the basis of a series of images from the Corvis® ST was proposed. The method was compared with known and commonly used edge detectors: Sobel, Roberts, and Canny operators, as well as others, known from the literature. The analysis was carried out in MATLAB® version 9.0.0.341360 (R2016a) with the Image Processing Toolbox (version 9.4) and the Neural Network Toolbox (version 9.0). The method presented in this paper provided the smallest values of the mean error (0.16%), stability (standard deviation 0.19%) and resistance to noise, characteristic for Corvis® ST tonometry tests, compared to the methods known from the literature. The errors were 5.78 ± 9.19%, 3.43 ± 6.21%, and 1.26 ± 3.11% for the Roberts, Sobel, and Canny methods, respectively. Conclusions The proposed new method for detecting the outer corneal contour increases the accuracy of intraocular pressure measurements. It can be used to analyse dynamic parameters of the cornea.

dynamic corneal deformation. On their basis, a special indicator, the so-called corneal biomechanical index (CBI), was developed, which intuitively indicates the probability of corneal ectasia in the examined patient.
Analysis of medical images, which include images from the Corvis ® ST, is often based on the use of modern algorithms and transformations. Today, various methods dedicated to image analysis are used in this field. Unfortunately, when confronted with real medical images, they turn out to be insufficient in most cases and eventually fail. Therefore, in each case, the algorithm must be individually adapted to the data. This is due to the individual character of each case, i.e. high individual variability of analysed patients, as well as artefacts created in the registration process, characteristic of a given imaging method. Such problems also appear in the analysis of images from the Corvis ® ST.
The impact of individual characteristics and the difficulty in the analysis of images from the ultra-fast Scheimpflug camera can often be seen in problematic images that commercial software provided with the device cannot handle (examples of images are shown in Fig. 1).
The main problem is the erroneously detected outer corneal edge, the determination of which is essential to acquire the characteristic parameters of corneal deformation. Special attention should be paid to the correctness of corneal contour detection, because the detection of its outer edge is the first and necessary step in determining parameters such as: • Central corneal thickness (CCT). Evaluation of this parameter is particularly important when diagnosing corneal diseases, e.g. keratoconus. Patients with this disorder are characterised by smaller CCT [39]. • Parameters describing corneal vibrations, applicable, among others, in the classification of corneal diseases [40]. • Whole eye movement, which allows for the separation of the entire eyeball displacement from the dislocation of the cornea itself. On this basis, the parameters are divided into those that take into account the displacement of the eyeball, which are  18:115 described in the literature as deformation parameters, and those that contain only the "raw" corneal displacement, which are described as deflection parameters. • Other parameters described in the literature, for example, deflection amplitude ratio, highest concavity delta arc length and integrated inverse concave radius [38,41].
It should be emphasised that the accuracy of the obtained parameters depends on the method of outer corneal contour detection. These results are already used in practice by ophthalmologists in disease diagnostics. In particular, they are used in the early detection of keratoconus [36] and in the assessment of refractive surgery [42]. The mentioned keratoconus is a rare degeneration that makes the corneal centre thinner. Under the influence of intraocular pressure, the cornea becomes cone shaped. The development of this disease causes even more significant bulging of the cornea, it gets thinner and its shape becomes more irregular. Such degenerations are a challenge for scientists, since the corneas of patients suffering from, for example, keratoconus are unique; therefore, the algorithms working properly for healthy patients may fail in those with diseased corneas.
A common problem is the use of polynomial approximation in determining the corneal edge [13,43,44]. The use of approximations in a process as dynamic as corneal deformation can result in false edges by marking an area that is not the cornea itself. Therefore, classic edge detection methods often prove to be unsuitable for problems that use real data with high variability.
The above problems also appear in the studies of other authors. In the paper by Ji et al. [13], the method used is resistant to small image noise (Fig. 2), but limited by the lack of contour detection at the corneal edges. This solution takes into account the adjustment of the 5th degree polynomial to the corneal edges, which in turn significantly simplifies the described problem and does not allow for accurate consideration of individual corneal variability, especially in the case of patients with, for example, keratoconus. It is also worth paying attention to the study by Kasprzak et al. [43], where the authors use repetitive Gaussian smoothing of the detected, raw outer corneal edge. This approach introduces limitations Fig. 2 Examples of problems with corneal edge detection described by other authors [13,43]. a An image showing the result of outer corneal edge detection (green line) in the image from the Corvis ® ST tonometer using the method presented in [13]. b A corneal image before deformation, from the Corvis ® ST tonometer, along with the detected outer corneal curvature (upper edge of the green area) based on the algorithm presented in paper [43] Page 5 of 22 Jędzierowska et al. BioMed Eng OnLine (2019) 18:115 into the analysis of corneal deformation, especially at the time of the so-called oscillatory phase of corneal deformation. The problem with corneal contour detection is related not only to Scheimpflug camera images, but also to images from other devices, e.g. OCT (optical coherence tomography). The obtained contour allows ophthalmologists to measure corneal thickness or its curvature radius. These measurements are useful in the diagnosis of patients and refractive surgery. Segmentation and isolation of the cornea profile from many cross sections also allow for the creation of corneal models useful from the point of view of numerical simulations [45].
Given the above, this paper presents the original method of outer corneal edge detection on the basis of a series of images from the Corvis ® ST tonometer. In its assumption, the proposed algorithm does not use approximation methods for the detected contour so that the outer corneal edge retains its individually variable shape. Therefore, special emphasis was put in the presented method on the most precise binarisation of the corneal profile. The method was compared with the known and used edge detectors: Sobel, Roberts and Canny operators.

Results
The first step in assessing the correctness of the authors' method for detecting the outer corneal edge in images from the Corvis ® ST tonometer was to check whether the detected contours contained any discontinuity points. Next, the contours detected by the new algorithm and those determined using the tested Sobel, Roberts and Canny operators were compared with outer corneal contours marked by the expert.
The correctly determined outer corneal contour L SP k (n) was an edge that did not contain any discontinuity points, and the difference in position between the contour points for subsequent images in the series was not greater than 5% of the number of image rows. In the case of the method proposed by the authors, the contour was detected correctly for approx. 90% of the 15,400 analysed 2D images. Figure 3 shows an image from the Corvis ® ST tonometer for the moment of the first applanation together with the contours of the outer corneal edge detected by means of the tested methods, i.e. the Sobel L S k (n) , Roberts L R k (n) , Canny L C k (n) methods as well as the proposed new method L SP k (n) and the external corneal contour marked by the expert L E k (n) . The accuracy of the described outer corneal edge detection algorithms was determined based on the measurement error value δ k (Eq. 1), calculated on the basis of the difference, obtained by a given method, in the position of the corneal edge and the position of the outer corneal contour designated by the expert. The expert's work was computer-assisted, so it was possible to mark the edges for all 15,400 images.
where L k (n)-corneal contour determined by one of the analysed methods: Sobel operator, where: L k (n) = L S k (n) , Roberts operator, where: L k (n) = L R k (n) , Canny operator, where: L k (n) = L C k (n) or the authors' method, where: L k (n) = L SP k (n) , L E k (n)-corneal contour determined by the expert, M-number of image rows, N-number of image columns. (1) 100%, The measurement error was calculated for each of the four analysed methods separately and for all 15,400 images. The mean error values together with their minimum and maximum values as well as standard deviations obtained for each method are presented in Table 1.
The mean value of the measurement error ( δ k ) for the proposed method was the smallest and amounted to 0.16 ± 0.19% . For individual patients (Table 2), this error did not exceed 1.25% and its minimum value was 0.11%.
Taking into account the total of 15,400 images analysed, this error was not greater than 3.62%. The proposed method also provided the smallest minimum and  maximum values of the error δ k (the minimum value of δ k = 0.09% and the maximum-δ k = 3.62% ). On the other hand, the highest mean error value and standard deviation were recorded for the Roberts method: 5.78 ± 9.19% . What is more, the largest error for all the analysed data of 61.67% and for individual patients equal to 47.45% was also in the case of Roberts edge detection. The highest error values result from the method used, which shows less resistance to local noise than the other edge operators. The most popular method is the Canny method, which has been modified many times for various applications in medical imaging. The disadvantage of the aforementioned method, in the analysed problem of detecting only the outer corneal border, is the detection of too many edges, including the edges of emerging artefacts-mainly light flares resulting from poor lighting. For the analysis of images from the Corvis ® ST tonometer, the mean value of the error δ k for the Canny method is only 1.1% higher than the error for the proposed method. However, a large maximum error of 50.70% excludes the use of this method (in the presented version) in practice.
Graphs of values of the error δ k for individual methods, i.e. Sobel, Roberts, Canny and the proposed method of outer corneal edge detection, for each of the 15,400 analysed images are shown in Fig. 4. A three-dimensional error graph for the proposed method for one of the patients is shown in Fig. 5. It presents the distribution of errors in the analysed images (repeated for all patients)-larger errors usually appear at the ends of the detected cornea and in its central area. The best results, i.e. the smallest distance between the curve detected by the authors' method and the edge marked by the expert, can be observed in approx. 1 6 and 5 6 length of the cornea (mm). Such distribution of errors results from the dynamic corneal deformation, when the cornea changes its shape the least at the mentioned points.
In the literature, other methods for detecting the outer corneal edge in images from the Scheimpflug camera are also suggested. Due to the various purposes of the studies quoted, the methods of testing and validating the suitability of the algorithms proposed by other authors [13,32,43] are also different (Table 3).
It is also worth noting that in the practical analysis of the errors presented, it is important to determine the purpose of the Corvis ® ST tonometry tests. If it is to show the total dynamic corneal deformation and its speed, analyse its vibrations etc., the outer corneal border in each of the 140 images (constituting the full examination of 1 patient) must be detected correctly. Especially, in such cases, the value of the presented error is significant. It is worth noting that despite obtaining small errors of outer edge detection (for individual patients δ k = 0.11 ± 0.13% ), the possibility of enhancing outer contour detection (obtaining smaller values of the error δ k ) would improve the accuracy of ophthalmologic diagnosis. This is due to the fact that the cornea (especially the diseased one) subjected to dynamic changes behaves in an unconventional way. That is why there is no standardised biomechanical model of the cornea (for dynamic conditions). Therefore, the more precise the detection of the outer corneal edge, the more accurate and  reliable the assessment of corneal biomechanics, and thus the ophthalmologic diagnosis. A different situation is the analysis of corneal phenomena such as: the length of the first and second applanation, the measurement of the maximum corneal deformation (highest concavity HC), when the upper corneal edge must be correct for a specific image corresponding to a given event.

Discussion
The paper presents a fully automatic method for outer corneal edge detection in images from the Corvis ® ST tonometer. The method was compared with commonly known edge detectors: Roberts, Sobel and Canny operators. The selected operators are classic edge detection methods, the most popular and widespread in the literature. The proposed methodology is characterised by repeatability and accuracy ( δ k = 0.16 ± 0.19% ). Outer corneal edge detection is an indispensable step to acquire numerical parameters, calculated on the basis of data from the Corvis ® ST tonometer, relevant in terms of their practical use in ophthalmology. Therefore, the accuracy of the algorithm responsible for this process is an extremely important issue. It should be noted that the proposed method is not the only possible approach to solving the analysed problem. For this purpose, it is also possible to apply other methods used in medical image processing. However, each of the new methods must be adapted to individual processing needs-in this case, corneal edge detection. The problem of outer corneal contour detection was mentioned in the paper [32], where the authors Koprowski et al. presented two approaches to corneal edge detection. The first proposed method was based on Otsu segmentation. The correctness of the method was about 80% for 13,400 analysed images. The next presented algorithm was based on the well-known Canny edge detection method and morphological image   [13] with the manual method (expert). The correlation was determined for the Peak Distance parameter describing the distance between two corneal peaks at the moment of the largest corneal concavity A time (ms)-The difference between corneal applanation times determined using the built-in method (available in the Corvis ® ST tonometer software) and the method proposed by Kasprzak et al. [43] Outer edge detection method

Verification parameter
Number of analysed patients A completely different approach to the problem of determining the corneal edge was presented by Ji et al. [13]. The edge detection methodology was based on a three-step algorithm: removing artefacts, creating phase-based images and marking the corneal edge. The correctness of this method was compared with the results of segmentation of the built-in method, provided with the Corvis ® ST device, as well as manual segmentation (expert). In the analysed research group, 40 healthy eyes and 30 eyes with keratoconus were tested, which together gave 9800 2D images. The reference parameters for all the algorithms analysed in paper [13] were the values of the central corneal thickness (CCT) and the distance between the two peak points at the time of maximum corneal concavity (peak distance, PD). Correlation analysis (Bland-Altman test and Pearson's correlation coefficient) showed a strong correlation between the presented method and manual segmentation ( p ≤ 0.01 , two-sided T test). However, there was no strong correlation with the built-in method (during the corneal deformation stage: p = 0.389 for healthy patients, p = 0.222 for patients with keratoconus). Nevertheless, the method of Ji et al. turned out to be more robust in the case of images with noise and artefacts (characteristic and numerous in images from the Corvis ® ST tonometer) compared to the built-in method, which could not handle such cases.
The determination of corneal contours was also an indispensable stage in the study by Rogowska et al. [44], where the influence of age on changes in corneal deformation was investigated. For the segmentation of both the outer and inner edges, the Otsu thresholding method was used, followed by approximation of the contours using the sixth grade Chebyshev polynomial. Due to the increase in noise and small stabilisation of the polynomial fit on the edges of the designated corneal profiles, ultimately 10% of the data was cut off from each side of the image. As in the above-mentioned studies [13,32], edge detection was only a step leading to the proper analysis being the subject of this paper. However, it is worth noting, that it was a necessary stage without which it would be impossible to examine the dynamic corneal parameters. Rogowska et al. also pointed out that 10% data trimming resulted in different results than in the case of analysis for profiles with a 5% cut-off. The above may indicate that the analysis of the incomplete corneal contour may introduce an error in the conducted tests, and the spherical shape of the cornea also affects the obtained results.
As shown in the above comparisons, the method presented in this paper indicates the highest accuracy of edge detection; the measurement error for the 15,400 analysed 2D images was: δ k = 0.16 ± 0.19% . It should be emphasised that the results obtained are influenced by the adopted exclusion criteria, which eliminated all unusual cases. In addition, it is worth considering other factors affecting the repeatability and reproducibility of the results obtained, among others, test conditions (temperature, lighting), changes in the position of the patient's head, various technological parameters of Corvis ® ST tonometers.
Owing to the proposed method, it was possible to obtain small error values, and thus increase the accuracy of measurements, which will allow for precise diagnosis. Obtaining the smallest possible measurement error is particularly important in this case because the corneal deformation process is dynamic, covering not only the cornea itself but also the entire eyeball. Therefore, even relatively small changes in acquired parameters (whose determination requires the localization of the outer edge) may affect the accuracy of diagnosis. The proposed method can be used as the first procedure in determining the dynamic parameters of the cornea available in the Corvis ST tonometer software. Thus, it can improve the commercially available tool. In subsequent research, on the basis of acquired corneal contours, the authors want to analyse the dynamic corneal deformation process and related phenomena. Ultimately, owing to the information obtained, it is planned to perform automatic classification (verification) of patients who have been diagnosed with keratoconus. The possibility of testing the proposed solution for data from different devices and for patients coming from outside Europe would also be interesting and valuable. It would enable to check the repeatability and stability of the method.
The applied image processing techniques used as well as other currently used methods [46][47][48] invariably require individual profiling and adjustment of acquired parameters depending on the analysed biomedical data set.

Conclusions
The use of an ultra-fast Scheimpflug camera in the modern Corvis ® ST tonometer has opened new possibilities in the field of analysis of biomechanical parameters of the eye and the dynamic deformation process occurring during tonometry tests. In this study, the authors addressed the basic problem being one of the first, and at the same time, key stage in the analysis of corneal images-the detection of the outer corneal edge in the full sequence of 140 images from the Corvis ® ST tonometer.
Over 15,400 two-dimensional images acquired from 110 patients using the Corvis ® ST tonometer were analysed. A new, fully automatic method for detecting the outer corneal contour was proposed. Its operation was compared with three edge detectors, commonly used in the analysis of medical images, i.e. Roberts, Sobel and Canny operators. The authors obtained an error of the proposed method at the level of 0.16% and its high repeatability (standard deviation 0.19%). For the other methods, the errors were 5.78 ± 9.19% , 3.43 ± 6.21% , and 1.26 ± 3.11% for the Roberts, Sobel and Canny operators, respectively. The above indicates, among others, that the presented algorithm is more resistant to noise characteristic of Corvis ® ST tonometry tests. The analysis was carried out in MATLAB ® 9.0.0.341360 (R2016a).
The proposed method for detecting the outer corneal edge can be used in the analysis of dynamic parameters of the cornea. It increases the accuracy of measurements and, thus, can be the basis for creating another precise diagnostic tool for patients with eye surface diseases.

Methods of outer corneal edge detection
The well-known edge detectors commonly used in medical images analysis were used: Roberts, Sobel and Canny operators. The above operators were selected for comparative analysis because they are one of the most popular methods among those cited in the literature. Moreover, the tested algorithms (Canny, Sobel, Roberts), due to their versatility and simplicity of operation, are repeatedly used as methods of fast and effective edge detection in images. In addition, the proposed method of edge detection is described.

Image preparation for analysis (pre-processing)
Images were obtained directly from the Corvis ® ST tonometer as a sequence of 140 2D images L(m, n), where m-number of rows m ∈ (1, 200) , n-number of columns n ∈ (1, 576) . The algorithm was written in MATLAB ® version 9.0.0.341360 (R2016a) using the Image Processing Toolbox (version 9.4) and the Neural Network Toolbox (version 9.0). The first stage of analysis was median filtration. The size of the filter mask was selected based on the measurements and the mean value of the measurement noise. The observed noise was mainly caused by the noise of the CCD converter in the form of white pixels with brightness exceeding 80%. Considering the above, it was found that the largest noise had an area of no more than 24 pixels. Thus, a 7 × 7 pixel mask h was adopted. Then, the whole image was normalised so that the brightness values in the resulting image L F (m, n) ranged from 0 to 1.

Image processing
The filtered and normalised image L F (m, n) formed the basis for main transformations aimed at determining the outer corneal edge.

Known edge detection methods
Edge detection was carried out successively using the three most popular operators for edge detection: Roberts, Sobel [49,50] and Canny [51]. The edge detection methods selected for analysis belong to the category of gradient operators. Gradient methods detect edges by searching for the maximum and minimum in the first derivative of the image. The Sobel method [52] locates edges using the Sobel approximation to the derivative. It precedes the edges at the points with the highest gradient. In the Sobel technique, a 2D spatial gradient quantity is performed in an image and, as a result, regions of high spatial frequency that correspond to edges are highlighted. It is generally used to find the estimated absolute gradient magnitude at each point in an input grayscale image. The operator is conjectured to consist of a pair of 3 × 3 complication kernels. One kernel is simply the other one rotated by 90°.
The Roberts method [52] performs simple, quick to compute, 2D spatial gradient measurements in an image. The method highlights regions of high spatial frequency that often correspond to edges. Pixel values at every point in the output represent the estimated complete magnitude of the spatial gradient of the input image at that point. It is very similar to the Sobel operator.
The Canny edge detection algorithm [53] is known as the optimal edge detector. The algorithmic steps are as follows: • Image convolution with a Gaussian function to obtain a smooth image. • Application of the first difference gradient operator to compute edge strength, then edge magnitude and direction. • Application of non-maximal or critical suppression to the gradient magnitude. • Application of the threshold to the non-maximal suppression image.
For the Roberts method, a threshold of 0.03 was used; for the Canny method, the applied threshold value was 0.1, and the standard deviation of the Gauss filter was set at 0.99. In the case of the Sobel method, the best results were obtained for the automatic threshold, determined in a heuristic manner based on the estimated RMS value of the measurement noise. Automatic selection of threshold values for this method is described in detail in paper [54]. The images resulting from the edge detection operation are as follows: L R (m, n) , L S (m, n) , L C (m, n). Figure 6 shows the selected image L S (m, n) for the characteristic moment of the deformation process: maximum corneal deformation (HC) along with the corneal edge marked by the expert (the expert's work was computer-assisted).
In addition, an analysis was also carried out for the method presented in the paper by Koprowski et al. [32], based on edge detection by Canny operator, as well as for the active contour method [45]. Apart from applying the classic Canny operator (as in this paper), the solution presented in [32] also uses morphological image operations, which provided 80% efficiency. Another tested method (active contour method) [45] implements segmentation by gradually transforming a closed contour in such a way that it finally adheres closely to the borders of the selected object. The contour is transformed based on the function values of the contour energy, which consists of regulatory constraints, associated with the need to maintain contour continuity and find the shortest contour, image appearance parameters and additional restrictions. Among the image parameters, both local features, e.g. related to the image gradient, and global features, e.g. texture, calculated inside and outside the contour are used. An important issue of this method is the initialization of the contour. For both solutions based on the image gradient and methods using global features, prior knowledge about the location of objects in the analysed image is required. The use of this approach has proved problematic in the case of outer corneal contour detection in images from the Corvis ® ST tonometer, because this method requires the assumption of a fixed position of the cornea in the image, which is impossible for the examined images. This is due to the specifics of tonometric examinations, in which the cornea deforms dynamically. Furthermore, during the examination the patient can move, which additionally changes the position of the cornea in the analysed images. Given the above, this method was not used in further research. Edge detection methods based on Otsu segmentation are also popular in the literature [55]. This method assumes that the histogram of the segmented image consists of two normal distributions, each of which represents one of the pixel classes in the image, i.e. the object pixel class and the background pixel class. The purpose of segmentation in the Otsu method is to allocate image pixels to one of these classes; so, this is an example of segmentation by binarisation. This task is accomplished by finding an optimal threshold that maximises the segmentation quality assessment indicator in the form of inter-class variance. This method, however, was not used by the authors in the present study due to the expected unsatisfactory results supported by the results obtained in another study [32].
For the applied edge operators and other tested methods proposed in papers [13,43,56,57], the following problems appear in the analysed problem: • Each of the applied edge detection operators marked more than one edge. • Without the expert's assessment, it is impossible to select the edge that corresponds to the outer corneal contour. • There are numerous discontinuities in the detected edges.
• Edges of objects not belonging to the outer corneal contour are detected, e.g. iris, light flares that are artefacts resulting from bad lighting, and others.
Due to the fact that, as shown in Fig. 6, edge detectors provide images containing not only the outer corneal edge, only the first pixels with the value '1' (for each column) were taken for further analysis, thus obtaining-for the Sobel operator, the edge: L S k (n) , for the Roberts operator-L R k (n) , and for the Canny operator-L C k (n) . This criterion is based on the assumption that the outer corneal edge should be the first edge detected by the applied operators.

Proposed algorithm
The proposed new method for detecting the outer corneal edge is based on local thresholding using Sauvola and Pietkainen's method [58] and the authors' algorithm. The individual stages of data processing for the proposed new method as well as for known methods are shown in the block diagram (Fig. 7).
According to the methodology described in paper [58], the value of the binarisation threshold t(m, n) was determined on the basis of the mean µ(m, n) and standard deviation σ (m, n) of the pixels in a window sized w × w: where t(m, n)-the value of the set threshold, for the pixel with coordinates (m, n) , m ∈ (1, 200) , n ∈ (1, 576) , µ(m, n)-mean brightness for a given window, σ (m, n)standard deviation for a given window, k-constant k > 0 , selected in an experimental way (k = 0.25 ), R-maximum standard deviation.
The window size w × w was chosen directly for the data and is 75 × 75 pixels for each of the analysed images. The k parameter enables to control the binarisation threshold  18:115 value in the local window. There is no consistency in the literature as to the best value for this parameter. In the study by Sauvola et al. [58], k = 0.5 was used; in the study by Rangoni et al. [59], the k parameter was 0.4; whereas, Badekas et al. [60] chose k = 0.34 as the most optimal value. The selection of the k parameter value is, therefore, strictly dependent on the data. In addition, as already pointed out by other authors [58], the algorithm itself is not very sensitive to changes in the values of k. For the case presented in this paper, the conducted experiments showed that the best results were obtained for k = 0.25.
To optimize the calculation time of the mean values of brightness and standard deviation in a given window, integral images were used [61,62]. For the original image L(m, n) , an image L i (m, n), being the integral image representation of L(m, n), was introduced. The value of the integral image at any point (m, n) of the image is the sum of the pixel values above and to the left of the pixel with the coordinates (m, n) of the original image L(m, n): The values of coordinates outside the image frame are 0: Using an integral image, it is possible to determine, in an efficient and quick way, the sum of pixel brightness in a given window sized w × w , and then the desired local mean µ i (m, n). For the example shown in Fig. 8, the mean in a window sized 3 × 3 (in the figure the window is marked in blue) can be determined based on the following formula: The integral image can be used in a similar way to determine standard deviations. Sauvola and Pietikainen's binarisation with the local threshold t(m, n) provided the image L SP (m, n) , which required further correction. For this purpose, a morphological opening operation with a disc-shaped structural element SE with a 3-pixel radius was used. For monochrome images and symmetric structural elements, this operation can be written as: To extract only the corneal image, all the objects present in the binary image L O (m, n) were labelled.
Then, on the basis of a comparative analysis of the characteristic features of the labelled objects, one feature was selected, i.e. major axis length, allowing for automatic and unambiguous classification of the object being a binary image of the cornea. For this purpose, the areas and major axis lengths of the previously determined objects were compared. Major axis length was defined as the length (in pixels) of the major axis of the ellipse that had the same normalised second central moments as the region. For all of the images analysed, the object with the largest major axis length (as opposed to the object with the largest area) always corresponded to the binary corneal image (Fig. 9).
Based on the image L maxAL (m, n) (representing the cornea) obtained after applying the above-described criterion, the outer corneal edge L SP k (n) was determined, defining it in the same way as for the methods described in "Known edge detection methods" subsection, as the first pixels having the value '1' for each column. The comparison of (4) µ i (m, n) = the outer corneal contour detection method using the major axis length parameter with known edge detection methods is presented in "Results" section. Characteristics that allow for corneal image detection in a binary image can be searched for with the use of deep learning methods that provide much greater accuracy of the analysed task and efficiency in making decisions based on data analysis. For the case under study, a database of 150,000 2D images with a resolution of 200 × 576 pixels was created containing a binary corneal image of the entire deformation process and individual areas constituting noise, visible in the image L O (m, n) . To recognise corneal images, a convolutional neural network (CNN) was used, which allowed for both the detection of features and the classification itself (recognition of the corneal image). For the given problem, 9000 images from each of the two categories were randomly selected, i.e. 9000 images of the cornea and 9000 images containing other non-corneal objects. Training and test sets were created (2/3 of the data formed a training set and 1/3-test set). All images were allocated to each set at random and were not duplicated. It is, therefore, possible that images from the same patient will be in both the test and training set. The corneal images for a given patient and among other patients are quite similar; therefore, no additional rigour was introduced to prevent the presence of images from one patient in both sets. On the other Fig. 9 A comparison of characteristic features of the labelled objects in a selected corneal deformation image. a The image L O (m, n) after labelling objects. Elements described by particular labels were assigned colours from the artificial colour map. The index of 1 corresponds to the area of the cornea. b A graph showing major axis lengths of the labelled objects. The largest parameter value belongs to the object with the label 1 (this area corresponds to the cornea). c A graph showing surface areas of the labelled objects. The highest parameter value belongs to the object with the label 8 (this area does not represent the cornea)