Restoration of deteriorated text sections in ancient document images using a tri-level semi-adaptive thresholding technique

The proposed research aims to restore deteriorated text sections that are affected by stain markings, ink seepages and document ageing in ancient document photographs, as these challenges confront document enhancement. A tri-level semi-adaptive thresholding technique is developed in this paper to overcome the issues. The primary focus, however, is on removing deteriorations that obscure text sections. The proposed algorithm includes three levels of degradation removal as well as pre- and post-enhancement processes. In level-wise degradation removal, a global thresholding approach is used, whereas, pseudo-colouring uses local thresholding procedures. Experiments on palm leaf and DIBCO document photos reveal a decent performance in removing ink/oil stains whilst retaining obscured text sections. In DIBCO and palm leaf datasets, our system also showed its efficacy in removing common deteriorations such as uneven illumination, show throughs, discolouration and writing marks. The proposed technique directly correlates to other thresholding-based benchmark techniques producing average F-measure and precision of 65.73 and 93% towards DIBCO datasets and 55.24 and 94% towards palm leaf datasets. Subjective analysis shows the robustness of proposed model towards the removal of stains degradations with a qualitative score of 3 towards 45% of samples indicating degradation removal with fairly readable text. Highlights This work presents a semi-adaptive binarization technique for ancient image enhancement. Main focus of this work is to restore obscured text sections. Multi-level thresholding approach is used for the removal of degradations. Gradient of the original image is used in the computation of reference image to detect deteriorated text sections. Pseudo-colouring and post-enhancement process finally transform to the enhanced image. DIBCO and palm leaf document samples are used for experimentations.


Introduction
In the context of documents, digitization is the process of transforming the physical documents into a format that can be processed by a computer. The primary objective of digitization is to preserve and often disseminate the valuable information of these documents [1]. There exists a wide variety of document types, such as old books, medical reports or even handwritten music scores and ancient manuscripts, such as degraded printed, handwritten and palm leaf manuscripts. Though there exist various successful works on the digitization of ancient manuscripts, it is significant to ensure that digitized documents are readable and of good resolution which requires enhancement. The task of enhancement is very complex and would usually vary from one type of document to other types due to variety of document built-up methods. Therefore, it is necessary to carryout enhancement so that the documents are degradation free and digitally good enough to identify the relevant information and useful for extraction of data from documents. The primary purpose of this study is to enhance the digitized documents by restoring deteriorated and obscured textual contents using multi-level thresholding techniques without the knowledge of labelled data. Several research attempts on ancient document digitalization initiatives have been documented since 2004 [2]. An attempt has been made in this work to solve the issues that arise during the enhancement process of digitized ancient manuscripts. Whilst acquiring, storing, processing and disseminating ancient manuscripts are all key objectives of the digitization process, restoring severely deteriorated manuscripts into visually appealing digitized forms is a necessary step in the document enhancement process.
Degradation challenges such as brittleness/cracks, contrast difficulties owing to old age and ink seepage, environmental influence, ink quality, overlapping of text with analogous textured background noise and de-acidification damages have a significant impact on ancient manuscripts. All of these factors are major challenges in the digitization of ancient manuscripts, and if they are not addressed properly, they will result in poor text quality retention after digitization. Improved text readability of ancient manuscripts, promotes accessibility, natural language processing operations and makes information retrieval faster.
To deal with various challenges that arise in the process of enhancement of deteriorated ancient documents, there is no universal binarization approach. As documents are created with their own layout and made of different material types, the degradations specific to a document would vary in terms of minute inter-grey level changes between textual and deteriorated regions. The interpretation of minute inter-grey level changes to classify textual to non-textual pixels demands a simple and effective document-specific binarization technique. On the other hand, restoration of text sections obscured by degradations from digitized ancient manuscripts is also crucial because high-precision Optical Character Recognition Systems (OCRS) demand enhanced documents to boost recognition rates [1].
Enhancement of ancient DIBCO documents is a well-researched problem in the literature and various degradations such as uneven illumination, foxing effect, ink bleed throughs on two-sided printed documents are often researched. Methods such as global or local thresholding strategies are widely employed for binarization to determine if a pixel is labelled as 0 or 1 [3][4][5][6][7][8][9][10]. Global thresholding applies a unified predicate to all the pixels in an image and whereas multiple predicates are dynamically employed in local thresholding based on the local neighbourhoods of grey level distributions [11]. It is observed that the use of a unified threshold throughout the document will not produce better results for degraded documents and on the other hand use of adaptive thresholding at the block or pixel level based on local neighbourhoods would also be time consuming and computationally intensive tasks. The idea of this investigation is to combine the efficiencies of global and local thresholding approaches and use multiple thresholds based on the degradation type to be addressed. A methodology has been developed in our research to address essential issues such as restoring text sections obscured by stains, show throughs and uneven illumination in ancient manuscripts such as DIBCO datasets and palm leaf manuscripts. In this regard, Section 2 discusses a couple of noteworthy contributions for binarization of deteriorated document images.

Literature review
Lipiński et al. [12] evaluate the performance of 15 different global thresholding methods for binarization of water-sensitive document images. According to the results of an experimental investigation, the Otsu approach is the best of the three top-rated techniques. To overcome non-uniform illuminations, Gupta et al. [13] use a combination of local and global thresholding approaches for binarization of DIBCO documents. The method uniformizes grey level distributions successfully and has been tested on DIBCO datasets. Later, Michalik and Okarma [14] adopted both adaptive and global thresholding techniques to binarize non-uniformly illuminated documents captured by mobile sensors. Non-stain degradations were the focus of the experiment, and testing was done on non-uniformly illuminated manuscripts. Uneven illumination difficulties in DIBCO document collections are examined in the following paper Michalik and Okarma [15]. In the analytical study, problems with uneven illumination are a major concern. Following this, Michalik and Okarma [16] used a multilayered thresholding technique to address the problem of uneven illumination in Bickley diary datasets.
According to Alexander and Kumar [17], sometimes parameter tuning in adaptive thresholding algorithms delivers the best results for deteriorated palm leaf documents. In addition, the two-step binarization strategy proposed by Krupiński et al. [18] is used to handle uneven illuminations in DIBCO and Bickley diary datasets. Gaussian Mixture Models and the Monte Carlo method for binarization are used to calculate a threshold. Specific strategies for addressing the deteriorations, such as restoring obscured text sections, are not covered in this paper.
In another work, a binarization strategy using local patches of DIBCO images is used for training neural networks called U-net by Huang et al. [19]. Later, deteriorated document image binarization method is devised by Yang and Yibing [20] for the removal of signal-dependent noise, variable illuminations, shadows, smears/smudges and low contrast regions. A nonlinear reaction-diffusion model is proposed by Zhang et al. [21] for bleed-through removal using Perona Malik equation. A parallel series splitting algorithm is devised and evaluated on DIBCO datasets for bleedthrough removal.
Further, binarization of damaged paper photos is performed via the modified Sauvola approach by Kaur et al. [22] using stroke width transform to decide the label of each pixel as 0 or 1. A set of synthetic images are employed for testing and it is observed that documents tested are non-ancient document images. In a subsequent work by Guo et al. [23], a non-linear edge conserving diffusion model is used for the binarization of text photos. The algorithm is evaluated on DIBCO datasets proving that adaptive thresholding techniques perform better compared to probabilistic model-based binarization models.
Calvo and Gallego [24] used auto-encoders for binarization of DIBCO dataset images, using thresholded documents for training. Though deep learning methods perform well, a major limitation with the model is training with ground truth images of the similar category of images. In a later work by Calvo et al. [25], pixel-wise binarization of musical documents is carried out using deep convolutional neural networks. Experiments are conducted on DIBCO, musical score documents, Persian heritage and Balinese script palm documents. Though it is a successful attempt towards DIBCO, musical score and Persian heritage documents, the performance is lagging below a correlation of less than 60% towards palm leaf manuscripts. Binarization technique for ancient document images is implemented by Saddami et al. [26] using adaptive thresholding and auto-encoders. In a different work by Feng et al. [27], a model for noise removal in degraded images uses energy function to address degradations such as smudges and uneven illumination. Consecutive attempts for enhancement of degraded document images are investigated by Zhao et al. [28] using conditional generative adversarial network using generator functions. In a work by Sehad et al. [29] for document binarization, Gabor filters are used to address the challenges in degradation removal. Later, in a work by Hangarge et al. [30], local binary patterns and cosine distance are employed as parameters for logo detection in documents and also tested for binarization.
An optimal block-based adaptive thresholding technique is propped by Xiong et al. [31] for DIBCO document binarization. Datasets experimented include printed and handwritten degraded images. Though the method produces successful outcomes, specific trials addressing restoration of under text sections in images are not addressed. In a subsequent investigation by Vo et al. [32], a deep supervised network is trained to predict the text sections in DIBCO document images. The method is dependent on reference images of datasets for training. Further, in a work by Chen and Wang [33], broken and degraded text sections are enhanced using non-local means technique and Wellner's adaptive thresholding.
Preservation of stroke connections in degraded textual sections, on the other hand, has ramifications. Mitianoudis and Papamarkos [34] propose a method for damaged handwritten and printed document binarization using Gaussian Mixture models and local cooccurrence maps. Ntirogiannis et al. [35] devise a method for binarization of degraded document images using a combination of local and global thresholding techniques. In DIBCO datasets, the approach removes non-uniform illuminations, smudges and fainted letters. The difficulties of recovering blurred text strokes are not addressed.
By studying a series of attempts made in 2013 and 2012, Wen et al. [36], Su et al. [37], Chiu et al. [38] apply thresholding methods to enhance DIBCO datasets. Otsu, Sauvola, Niblack and Kittler are examples of approaches that have been demonstrated to be effective in removing uneven illumination, smudges and smearing. Hedjam et al. [39] and Bataineh et al. [40] investigate spatial pixel relationship-based techniques for binarization of DIBCO documents using a combination of thresholding and soft computing techniques. Non-uniform illuminations and ink bleeds are successfully removed in both works. Farrahi and Cheriet [41] use a multi-scale binarization technique with adaptive thresholding on damaged historical documents. The effectiveness of this method for correcting poor connections between text strokes has been demonstrated. Also, employing a low-pass Wiener filter and a background surface approximation [42] resolves degradations such as non-uniform lighting and smearing.
The following points are noted, to the best of our knowledge, after carefully analyzing the literature. Some significant works that closely align with our proposed method are summarized in Table 1. The rest of this paper is laid out as follows: Section 3 explains how the semi-adaptive document binarization technique works. Section 4 gives the experimental  [14] 2020 Adaptive thresholding Mobile captured images Non-uniform illumination Michalik and Okarma [15] 2020 Optimized adaptive thresholding DIBCO Non-uniform illumination Michalik and Okarma [16] 2020 Global and local thresholding procedures

Bickley diary datasets Uneven illumination
Alexander and Kumar [17] 2020 Local/adaptive optimization Palm leaf Restoration of text Krupiński et al. [18] 2020 Gaussian mixture models and Monte Carlo simulation DIBCO+ Bickley diary datasets Non-uniform illumination Huang et al. [19] 2020 Global, local UNET technique DIBCO Non-uniform illumination Kaur et al. [22] 2020 Modified Sauvola approach Damaged paper photograph Non-uniform illumination Guo et al. [23] 2019 Adaptive thresholding Mobile captured text photos Non-uniform illumination Saddami et al. [26] 2019 Adaptive thresholding and auto-encoders Ancient document images Smudges-uneven illumination Calvo et al. [24] 2017 Auto-encoder approach DIBCO Broken text sections Bradley et al. [36] 2007 Adaptive binarization and soft decision method DIBCO document images Non-uniform illumination and noise Bartolo et al [7] 2004 Bernsen's thresholding adaptation DIBCO document images Variable illumination Kittler et al. [8] 1986 Adaptive thresholding DIBCO document images Spatial variation in illumination Sauvola et al. [9] 1997 Minimum error thresholding Sketched line drawing images Pixel classification error Point Grey camera captured images inferences of the proposed approach utilizing palm leaf document images and DIBCO document images, as well as a comparative research with other benchmark techniques using local and global thresholding techniques.  to apply the necessary brightness adjustments. In the next step, the image is filtered using two different workflows. In one workflow, the image is converted to grey scale, whilst in another, the image is subjected to gradient image extraction via red, green and blue channel analysis. Gradient image is used for the extraction of binary mask marking the text sections obscured by stain degradations. On the other hand, the grey-scale image obtained from the input image is subjected to mid-level processing, which includes a tri-level degradation removal process that uses statistical thresholds estimated based on the image's global grey-scale features, resulting in a tri-level noise filtered image. From that, the tri-level noise filtered image is subjected to a pseudo-colouring procedure, in which stain degradation is removed from the tri-level noise filtered image using a binary mask, resulting in a pseudo-coloured image. Finally, in post-enhancement, morphological operations are applied to the pseudo-coloured image to generate the enhanced binarized image.

Pre-enhancement
Consider an input image I for which pre-enhancement is carried out by applying contrast stretching linear function that stretches the grey level of an image I to its full dynamic range. The result of pre-enhancement is shown in Figure 2. The enhanced image I E is the outcome of brightness modification of image I and it is used to compute the gradient image G d , as stated subsequently.
The intensity values are modified as a result of applying the contrast stretching transformation to the input image in order to increase the discrimination between the textual pixels and the background, resulting in the restoration of slightly faded text sections as seen in Figure 2(e). Preprocessing basically turns brighter pixels into much brighter pixels, which may result in a marginal increase in noise, but it is necessary for the preservation of slightly faded text in both DIBCO and palm leaf documents. The proposed method's noise removal is effective in removing additional noise that occurs as a result of this change.

Gradient image computation
The enhanced image I E is divided into colour channel images I R , I G and I B of RGB colour space images. To compute the RGB sliced image I d , the channel images are subjected to arithmetic processing. The computation of a gradient image is depicted in Figure 3. The average of red and blue channel images is combined with a green channel image to create an RGB sliced image I d . The RGB sliced image is also subjected to Otsu thresholding, resulting in a binary image that serves as the reference image I ref . Finally, the original image I is mapped to the reference image I ref .
1. Given I R, I G and I B as colour channel images of RGB image I E 2. Arithmetic processing -RGB sliced image: Initially, the enhanced image I E is required as input, which is separated into red I R , green I G and blue I B  channel images. The red and blue channel images are combined as I R +I B , divided by the number of channels used to combine, which is 2, and the result is subtracted from the green channel image I G to generate an RGB sliced image I d .
The overall effect of merging and dividing three channels would reduce noise, which could then be subtracted from the green channel image to aid in the detection of changes between images. In addition, deducting the combine and divide result from the green channel image contributes to the normalization of uneven text parts and the removal of shadows, yielding an RGB sliced image I d . Following that, the RGB sliced image is subjected to Otsu's thresholding, which divides the pixels into intensity levels 0 and 1, yielding a reference image I ref .
Each This technique is performed for all pixels in I d , an M-row, n-column grid. Finally, the original image is subjected to RGB sliced image I d mapping before being assigned as a gradient image G d . The gradient image is vital in emphasizing the text sections that have been deteriorated and concealed.

Level 1 degradation removal
The principal objective of level 1 degradation removal is to remove the greyscale image variance caused by the uneven lighting and shadow corrections in the source image. A transformation is applied to a greyscale that separates the grey levels over a threshold to the maximum grey level whilst keeping the grey levels below the threshold constant. The process for removing level 1 degradation is as follows.
The histogram of a gradient image is used to examine the distribution and dispersion of grey levels relating to textual and non-textual sections. To eliminate level 1 degradations, a gradient image-based threshold is applied. For categorizing grey level variations in greyscale image G s , the threshold is employed as a reference parameter.
Let r 1 , r 2 , r 3 . . . r L−1 be the grey levels corresponding to the gradient image G d and ϑ is the vector holding the value p(r k ) of G d , where k = 1, 2, 3 . . . L − 1 and p(r k ) is the probability of occurrence of a specific grey level r k . A mean threshold T (1) μ for level 1 degradation removal is computed from trimmed vector ϑ obtained by truncating the grey level r k whose p(r k ) is zero as given by (1).
In the proposed datasets for experimentation, grey levels of degradation-obscured text sections appear less dominating in brightness than the mean threshold T (1) μ . Also, non-obscured background sections appear to be less prominent in brightness when it descends below the mean threshold T (1) μ . Besides that, several visual perception-based implications from the proposed datasets are stated.
(1) In most of the cross-domain documents, noise constituted of grey levels below the mean threshold T (1) μ affects more than 90% of deteriorated document images.
(2) It is clear that a grey level l(d) relevant to degradations such as degradation of obscured text sections, discolour-age, non-uniform lighting and ink bleed through exists between the grey levels l(t) and l(b) spectrum of grey levels, as illustrated in (2).
(3) Mean threshold T (1) μ employed for level 1 degradation removal indicates the spread of grey level constant ±k of a specific grey level l(d) of grey-scale image as given by (3).
The empirical relation (3) can be represented subsequently in the simplified form given by (4). where Thus, mean threshold T (1) μ is a crucial parameter in level 1 degradation removal process resulting in level 1 filtered image g 1 given by (5).
In the next step, level 1 filtered image g 1 is sent to level 2 degradation removal process. Figure 2 highlights the mean threshold T (1) μ obtained with the help of histograms for few instances of gradient images.
In Figure 4, mean threshold T μ of I 1 , I 2 and I 3 lies in the range of 110-150 indicating the degradations above the range are non-uniform illuminations, smears, smudges and foxing effect.

Level 2 degradation removal
The intention of level 2 degradation removal is to eliminate impulse and periodic noise from the level 1 filtered image g 1 's output. To do so, a global threshold is calculated based on the median of the level 1 filtered image g 1 . The median of the image's different grey levels is used as the filtering threshold.
For an image g 1 , initially distinct grey levels l 1 , l 2 , l 3 . . . l k are computed and sorted from which a median g 1 is computed from sorted grey levels, where k is number of grey levels. The median threshold is in responsible for removing moderate and sensitive stains or blemishes on textual contents that are close to the grey levels. Let (x, y) represents an arbitrary pixel in level 1 filtered image g 1 with number of rows m and columns n, where, x = 1, 2, 3 . . . m, y = 1, 2, 3 . . . n, the median threshold g 1 is applied on g 1 producing an outcome of level 2 filtered image g 2 as given by (6).
Level 2 filtered image g 2 is sent to level 3 degradation removal for the elimination of stain marks crossing text strokes.

Level 3 degradation removal
Level 3 degradation removal attempts to remove noise from degradation-obscured text sections, and uses an intensity level slicing technique to detect the range of grey levels associated with degradations. The input of level 3 degradation removal is supposed to be a level 2 filtered image g 2 . Filtering is used to slice the grey levels corresponding to degradation-obscured text sections into a defined range of grey levels. The following is a description of how to identify a specific range using distinct grey levels produced from a level 2 filtered image g 2 . Let l 1 , l 2 , l 3 . . . l k are sorted distinct grey levels of image g 2 partitioned into equal sized groups p 1 , p 2 , p 3 , p 4 , respectively. l 1 , l 2 . . . l p 1 , l p 1 +1, l p 1 +2 . . . l p 2 , l p 2 +1, l p 2 +2 . . . l p 3 , l p 3 +1, l p 3 +2 . . . l p 4 , and l p 4 +1, l p 4 +2 . . . l k represent p 1 , p 2 , p 3 , p 4 , respectively.
For each partition p i , where i = 1, 2, 3, 4 are analyzed for interpretation of grey level range of degradationobscured text sections. Figure 4 depicts the brightest grey levels (white) as the background and the textual sections as foreground darker grey levels (black) in the document image. In a grey-scale image, the darker grey levels designate the lower range, brighter grey levels designate the higher range and the midrange as degradation. Therefore, the partitions p 2 and p 3 are comprised of grey levels of degraded regions closer to textual regions. Thus, mean of grey levels of partition p 2 is employed for stain marks type degradation removal in level 3 as given by (7).
In (7), μ(p 2 ) represents the mean of grey levels in partition p 2 which is computed as given by (8).
where n is the number of grey levels in partition p 2 ranging from l p 1 +1 , l p 1 +2 . . . l p 2 to i = p 1 + 1, p 1 + 2, . . . p 2 . Figure 5 indicates the relationship between the mean grey level of gradient image G d in level 1 and the mean grey level of partition 3 of image g 2 for all the document samples of DIBCO.  The distribution of mean quantities applied in level 1 to level 2 shows a clear distinction, allowing for multiple degradations to be addressed at separate levels.

Pseudo-colouring and post-enhancement
The pseudo-colouring process aims to increase the grey level discriminating range between text sections and stain type degradations. This technique is also important for restoring text strokes that have been obscured by stain degradation. This entails mapping grey levels from darker to somewhat lighter tones. In the level 3 filtered image g 3 , the partial prevalence of stain mark degradations that are close to textual grey levels remains. The algorithm below depicts the process of applying pseudo-colouring.
To adjust grey levels related to stain degradations, the pseudo-colouring algorithm assumes an input of level 3 filtered image g 3 and gradient image G d . The next step is to obtain the binary mask B d , which contains degradation-obscured text sections. The binary mask B d is then used for the pseudo-colouring process. The threshold that is applied to level 3 filtered picture g 3 with reference to on pixels in binary mask B d determines the outcome of this process. According to our findings, a threshold of is determined using the 50% of the mean of grey level as provided in step 3 of the method. The threshold's implications paint a grey level at pixel g 3 (x, y) that is above the threshold to maximum grey level 255 and below the threshold to minimum grey level 0, as shown in step 4.
Initially, Otsu's thresholding operator T is applied to gradient image G d , resulting in the formation of binary image B d by assigning a pixel G d (x i , y i ) lying above the threshold T to 1 and below T to 0. This operation will be carried out for all pixels with i = 1, 2, 3 . . . m rows and j = 1, 2, 3 . . . n columns. Further, the related components of binary image B d are interpreted, which are a combination of text sections and degradation-obscured text sections.
If κ 1 , κ 2 , κ 3 . . . κ p are the connected components, in the binary image B d , then each connected component is subject to analysis based on its area of pixels and each κ c with c = 1, 2, 3 . . . p is subject to predicate area of component A(κ c ) > = S pixels. The detection of text sections obscured by degradations is based on the fact that the majority of the obscured text sections have an area greater than 500 pixels. Thus, repeating the process with respect to connected components from κ 1 , κ 2 , κ 3 . . . κ p would result into creation of a binary mask B d . The mask is critical in ensuring that subsequent operations are applied only to text sections hidden by stain degradation in level 3 filtered image g 3 , which correspond to pixels in binary mask B d . This is accomplished via a threshold which is mean of level 3 filtered image g 3 and multiplied by 1 2 . As described in step 4 of the technique, threshold is applied to those pixels in g 3 (x, y) that satisfy B d (x, y) = 1 in binary mask B d , which is used as a reference image for removing stain degradations that are obscuring the text sections. Each g 3 (x,y) > is quantized  with g 3 (x, y) = 255 and the below threshold to 0 resulting in level 4 filtered image g 4 . Additionally, level 4 filtered image g 4 is subject to morphological operations for enhancement of retained textual sections with the help of morphological bridging operators followed by dilation to obtain the final binarized image.    Table 2.

Experimental analysis
For up to 10 documents of Malayalam palm leaf manuscripts to be evaluated, ground truth images are created using imtool in MATLAB. The document images for experimentation are chosen with a higher degree of degradation in consideration. Validation of the remaining documents is done with the help of 25 observers using observer testing procedures. Poorly readable (P), fairly readable-partial degradations (FP-Y), fairly readable-no degradations (FP-N) and clearly readable (C) are the four levels of observer results. Figure 6 depicts the observer grading scores, with 1 being the lowest and 4 being the greatest.
The proposed model is thoroughly evaluated utilizing DIBCO competition dataset evaluation metrics such as FM (F-measure), pFM (pseudo-F-measure), PSNR (peak signal noise ratio), NRM (negative rate metrics), DRD (distance reciprocal distortion) and MPM (misclassification penalty metrics) [43]. Table 3 shows the context of each metric type implying the performance of the proposed model.
The following assessment measures are used to evaluate DIBCO competition datasets, with a primary focus on images with obscured text sections, as shown in Table 4. Figure 7 displays the sample images considered in the evaluation as well as the results.
Ink bleed-through reflections from the opposite side of the paper is one sort of degradation, and as shown in Figures 7-(1b) 2009-1, (7b) 2012-1 and (12b) 2016-1, degradations that obscured text sections are successfully erased, and the qualitative grade is provided as C with a score of 4. Other degradation types, such as the stains shown in Figures 7-(2b) 2009-2, (8a) 2013-1 and (9b) 2013-2, are rated as FP-N with a qualitative score of 3, whereas degradation-obscured text in Figures 7-(9b) 2013-2, (11b) 2013-4 and (16b) 2017-3 are rated as fairly readable-partial degradations (FP-Y)    Table 5 shows the results of sample observer assessment for 22 document samples, which are text sections obscured by degradations. Table 5 shows the percentage of observers who awarded each sample 1, 2, 3 or 4 rating. The percentage of observers graded as a percentage of the total number of observers is derived sample wise based on the number of observers graded as a percentage of the total number of observers. The samples are then graded using the final grade based on the highest percentage of votes. Figure 8 depicts the sample-by-sample grades based on maximum votes.
As per the subjective analysis conducted on stained degraded samples for 22 samples, 18% of observers graded the samples with the highest grade of 4, 45% of observers with a rating of 3, 18% with 2 and remaining 18% with 1 of low rating. It is inferred that the highest number of samples are binarized where the text restoration is fairly readable and partial degradations remained and only 18% are rated high indicating better visibility of obscured text sections after stain removal. Ten samples of stain degradations that are obscuring text sections are graded 3 in Table 5, indicating that the text sections have been restored by successfully removing the degradations that are obscuring text sections.
Four more examples received a four rating, indicating excellent noise removal and great text retention. Four samples are scored as 2, and four samples are graded as 1, indicating a low text retention rate with partial stain degradation removal. Figures 9-11 show how the proposed technique performs on DIBCO samples that have been specially damaged by stains at different phases of the algorithm. Figure 12 also shows the experimental results of the proposed approach with several state-of-the-art adaptive thresholding strategies. Adaptive thresholding methods which are compared include Niblack 1986 [3], Gatos [27] are considered for evaluating comparative results. The results show that the proposed method, when compared to state-of-the-art   techniques, is capable of removing noise and retaining text that has been obscured by degradations. In addition, the proposed method outperforms state-ofthe-art techniques in terms of stain removal, as shown in Figure 12. Figure 12 shows the average F-measure of stain removal of 22 samples from DIBCO datasets and its comparative results. According to our findings, whilst the proposed technique for noise removal achieves satisfactory results for palm leaf enhancement, it causes text breakages in palm leaf documents. Furthermore, all existing methods for noise removal in palm leaf manuscripts have failed, with the exception of the Niblack method, which performs similarly to the proposed method. Furthermore, when applied to stained degradation samples of DIBCO datasets, the results of state-of-the-art methods for eliminating degradations obscuring text sections are unsuccessful since text sections are corroded together with stain removal.
The visual results of Figure 12 and the quantitative evaluation of the same in Figure 13 Tables 6 and  7. The greatest F-measure will be close to 1, indicating that the binarization technique is effective, and the NRM and MPM values will be close to zero, indicating that the algorithm is reliable in classifying pixels into background and foreground. Figures 14 and 15 show the quantification of results produced in terms of MPM for all DIBCO and palm leaf datasets using the proposed method vs state-of-theart techniques. Figure 13 depicts the tradeoff between the DIBCO 2009-2014 datasets and MPM, revealing that the proposed method and Sauvola have the lowest MPM of all known methods. Figure 15 shows the MPM of the proposed technique and state-of-the-art Regardless of the type of degradation, we can conclude from our quantitative investigation, which used dataset-wise averaged measures that the proposed methodology performs nearly as well as state-of-theart techniques such as Gatos, Niblack and Wolf in varied circumstances. Other algorithms' failures can be attributed to a variety of issues, such as Otsu's technique's use of a unified threshold, which may fail to interpret the margin of difference between minute grey level changes in degraded sections of the document. Other adaptive thresholding approaches, such as Feng, Bernson, Bradley, Kittler and Local Otsu, rely on specified parameters, resulting in the higher text to non-text misclassification penalties and vice versa.
These methods are more effective in dealing with larger grey level variations in cases of uneven illuminations, show throughs and other ageing changes, but they are less effective in removing stained degradations by maintaining text sections. Gatos, Niblack, Wolf and Sauvola outperform the proposed technique in a few F-measure and PSNR cases. However, the Fmeasure and pFM results for the 22 samples of stained degradations that are obscuring the text sections, viz. Figure 13, show that the proposed approach is adequate. In the instances of Sauvola, Niblack, Bernson   and Gatos, we could see in Figure 11 that there were times when characters would fade along with the noise.
The removal of stained degradation by state-of-theart also results in an unacceptably sharp transition from stained to the text section. When it comes to noise reduction from DIBCO and palm leaf documents, Otsu, Local Otsu and Kittler's are the examples where inadequate efficiency is perceived.
Following that, it is discovered that the proposed approach and Niblack perform similarly well in terms of noise removal in palm leaf documents, whereas Sauvola, Wolf and Gatos perform well in terms of DIBCO datasets. However, they fail to eliminate text breakages and noise in Balinese and Malayalam palm leaf writings. Furthermore, the suggested method fails to binarize papers with thin pen strokes, despite the fact that it reduces noise regardless of DIBCO or palm leaf documents, as shown in Figure 16. The difficulty of improving text legibility in palm leaf manuscripts, on the other hand, deserves more research.
However, as demonstrated in Figure 16, the proposed technique's efficiency for palm leaf document enhancement is not as promising as it is for DIBCO document images. Text strokes of varying lengths and show throughs with grey levels equal to the original text result in poor text stroke preservation in documents, as seen in Figure 16.
The average F-measure for the DIBCO dataset is 65.73, whilst the average F-measure for palm leaf document samples is 55.24, according to Table 5. The results show that the proposed technique is capable of removing stains, non-uniform illuminations, foxing, ageing marks and pen scribbles. For DIBCO document images, the proposed method has produced encouraging results, with an F-measure of more than 65 percent for 4 out of 10 documents and 2 out of 10 for palm leaf document images.

Conclusion and future work
With the application of adaptive thresholding methods, binarization of ancient degraded document images is becoming more common. Complex degradation, on the other hand, is still a mystery, despite the fact that a model based on a combination of global and local thresholding procedures generates outstanding results. To solve the degrading obscured text sections, we use a tri-level semi-adaptive binarization technique in this research. Gradient images made with RGB channels of scanned documents are significantly used in the identification of binary mask highlighting stains. Adapting the usage of thresholds to binarize deteriorating hidden text sections of the original image introduces the nature of applying local thresholds. The proposed study uses global thresholding approaches to remove level-wise degradation, whereas the post-enhancement procedure uses local thresholding techniques. Though the evaluation demonstrates that noise removal and text retention are effective for DIBCO samples, future study will be hampered by the low text retention rate for palm leaf document samples. Furthermore, the topic of the recommended algorithm's speed in comparison to other ways could be studied as a separate research challenge in the future.

Disclosure statement
No potential conflict of interest was reported by the author(s).

Funding
This research did not receive any specific grant from funding agencies in the public, commercial or not-for-profit sectors.