Preprint
Article

This version is not peer-reviewed.

A Hybrid Template-Guided Deep Learning Framework for OCR-Oriented Restoration of Degraded Tax Documents

Submitted:

17 July 2026

Posted:

20 July 2026

You are already at the latest version

Abstract
Degraded tax forms and other legal-administrative documents require restoration methods that impose strict constraints on content fidelity. This paper presents a structure-aware restoration framework for degraded tax documents that combines geometric normalization, canonical template guidance, and supervised image restoration within a common alignment space. Documents are first mapped to a canonical layout through homography estimation based on Scale-Invariant Feature Transform (SIFT) and Random Sample Consensus (RANSAC), using a master template as a reference. Restoration is then performed using template priors and masked constraints designed to preserve the fixed document structure while recovering variable content. Under a fixed-budget comparative protocol, U-Net with template priors achieved the highest visual and structural quality, whereas the proposed hybrid model obtained the best functional OCR performance on synthetic data, reaching a Character Error Rate (CER) of 0.1091 and a Word Error Rate (WER) of 0.3495. As a complementary evaluation on 37 real-world documents with human-generated textual ground truth, restoration increased full-page word coverage across all three OCR engines evaluated, yielding absolute improvements ranging from 4.15 to 18.05 percentage points.
Keywords: 
;  ;  ;  

1. Introduction

The restoration and binarization of degraded documents constitute critical problems in computer vision and image processing. However, for legal and tax documents, the requirements are particularly stringent: restoration must preserve content fidelity, as the loss or alteration of a single digit may invalidate a record and produce unacceptable errors in Optical Character Recognition (OCR). Consequently, purely visual restoration is insufficient, and both structural integrity and functional readability must be preserved with high precision.
In the Colombian context, the legal requirement to retain original supporting documents for extended periods increases the prevalence of physically deteriorated documents affected by mixed degradations. More generally, a significant proportion of historical and administrative documents exhibit degradation, limiting accessibility, analysis, and information preservation [1]. Unlike handwritten manuscripts or general-purpose administrative records, tax forms exhibit highly rigid layouts containing predefined fields (totals, Tax Identification Number (NIT), dates), tables, signatures, and encoded elements. As a result, any geometric distortion or local alteration may propagate and ultimately lead to systematic OCR failures.
Traditional methods, such as adaptive thresholding, have been widely adopted because of their simplicity and computational efficiency. However, their performance tends to deteriorate under complex noise, shadows, stains, and severe information loss [2]. Deep learning methods—particularly generative models—have demonstrated significant advances in document restoration. For example, EHDI employs Generative Adversarial Networks (GANs) to enhance the quality of degraded documents [1], while recent approaches such as DocDiff address deblurring, denoising, and artifact removal within a unified diffusion-based framework [3]. Similarly, Doc-Attentive-GAN incorporates attention mechanisms to guide the denoising process [4].
Nevertheless, these approaches present limitations when applied to structured tax documents. Generative models optimized primarily for perceptual quality may introduce spurious strokes or modify critical details such as characters, separators, and table boundaries, thereby affecting semantic consistency and OCR performance. Consequently, a gap remains between visually appealing restoration and restoration that is valid for automatic reading under strict layout constraints.
In this work, we propose a hybrid structure-guided restoration method for degraded tax documents. The approach begins with geometric normalization based on SIFT and RANSAC to map each form into a common canonical space defined by a master template. Within this aligned space, restoration is performed using a supervised model that incorporates explicit structural information through template priors, template fusion, and masked constraints focused on variable-content regions. By reducing restoration uncertainty in rigid-layout documents, the proposed framework aims to preserve form consistency and improve OCR utility without introducing severe computational overhead. To validate the proposed method, we compare it against both classical and learning-based baselines using visual, structural, textual, and practical efficiency metrics.
The remainder of this paper is organized as follows. Section 2 reviews related work. Section 3 describes the materials and methods, including synthetic dataset generation, the geometric normalization stage, and the proposed hybrid framework. Section 4 presents the experimental results, covering dataset validation, baseline comparisons, computational cost analysis, and ablation studies. Section 5 discusses the implications of the findings, the limitations of the proposed approach, and its applicability to sensitive document-processing scenarios. Finally, Section 6 summarizes the main conclusions of the study.

3. Materials and Methods

The methodology is composed of two components that combine Digital Image Pro-cessing (DIP) and Deep Learning (DL). The first component is a synthetic data generation pipeline that produces supervised pairs (degraded document and its corresponding ground truth) under controlled degradations. The second component is a hybrid restora-tion method that explicitly separates geometric normalization from content restoration, first projecting the document into a canonical space and then applying structure-conditioned inpainting. Figure 1 summarizes the training, inference, and evaluation pipeline.

3.1. Synthetic Data Generation

The objective of the synthetic generator is to construct a supervised dataset with controlled degradations, enabling reproducible training and evaluation using a fixed seed and explicit per-sample parameter logging. To achieve this, the pipeline initializes from a base PDF template, from which a reference template image ( I t e m p l a t e ) and a master mask ( M m a s t e r ) are generated to isolate and focus on specific document regions. For each document i , the pipeline generates: (i) a clean/ground-truth/canonical image I gt ( i ) , (ii) a degraded image I noisy ( i ) and (iii) a JSON file containing the full parameterization of the document ( θ fill ( i ) ) and applied degradations ( θ deg ( i ) ) (see Figure 2).

3.1.1. Form Rendering and Document Content

Starting from a PDF template of the selected form type, a filled PDF is generated using a document filling module that produces coherent field values (e.g., identifiers, dates, and amounts), returning a parameter dictionary θ fill ( i ) for auditing and reproducibility. This PDF is rasterized into an image via PDF-to-image conversion, producing the canonical grayscale representation:
I gt ( i ) = g r a y ( p d f 2 i m g ( P D F filled ( i ) ) )
The canonical image is stored as a reference “without degradations”.

3.1.2. Degradation Operator: Transformation Chain

The degradation process is implemented as an ordered composition of operators, sampled from uniform or discrete distributions and activated according to configurable probabilities. Let T g denote geometric transformations (translation/rotation/scale), T dpi denote resampling simulating DPI variation, and T n , T b c , T b , T t h r denote noise, brightness/contrast adjustment, blur, and thresholding operators, respectively:
I n o i s y ( i ) = T t h r ( T b ( T b c ( T n ( T d p i ( T g ( I gt ( i ) ) ) ) ) ) )
The image I noisy includes the full degradation pipeline. The complete sampling and activation parameters for each transformation are detailed in Table 1.

3.1.3. Data Persistence and Sample Traceability

For each document i , the pipeline stores: I gt ( i ) (clean/GT/canonical), I noisy ( i ) (degraded), and a JSON file containing θ fill ( i ) and θ deg ( i ) (degradation parameter set). This ensures full reproducibility and auditability, as each sample can be regenerated from its JSON configuration and the seed.

3.1.4. Reproducibility and Parallelization

The generator supports a global seed s . In parallel execution, a per-document seed is defined as s i = s + i , ensuring deterministic generation regardless of process scheduling order.

3.2. Hybrid Restoration Method

3.2.1. Canonical Space Formulation and Structural Guidance

The proposed method operates in a canonical document space to first reduce geometric variability and subsequently perform restoration under a normalized spatial layout. This formulation is particularly suitable for structured tax documents, where the relative positioning of fields, separators, tables, and encoded regions follows a rigid pattern. Restoration is not performed as a free-form transformation of the original degraded image but as a reconstruction conditioned on a template within a previously aligned geometry. This alignment stage constitutes the Digital Image Processing (DIP) component of the method and is performed prior to deep restoration.
Let I n o i s y [ 0,1 ] H 0 × W 0 be the observed degraded image and M m a s t e r [ 0,1 ] H × W the master template in canonical space. To map I n o i s y into this space, a homography H R 3 × 3 is estimated between the degraded document and the template. In the original formulation, this estimation is performed using SIFT keypoint detection on the degraded image, descriptor matching via BFMatcher with L 2 distance, correspondence filtering using Lowe’s ratio test, and robust transformation estimation via RANSAC. Once the homography is estimated, the degraded image is warped as:
I a l i g n e d = ω ( H , I n o i s y )
This operation projects the degraded image into the canonical coordinate system via a warp operator ω , yielding the aligned representation that is used as input to the restoration block.
In the supervised setting, the clean reference I g t [ 0,1 ] H × W is expressed in the same canonical space as I a l i g n e d , enabling learning under explicit geometric correspondence between input and target. Additionally, the method uses M m a s t e r , defined in canonical space with values in { 0 ,   127 ,   255 } . From this mask, three auxiliary maps are derived:
α = M m a s t e r 255 ,   M c = 1 [ M m a s t e r = 255 ] ,   M v = 1 [ M m a s t e r 127 ] .
From this mask, the alpha map α , a content mask M c , defined on pixels with value 255, and a validity mask M v , defined on pixels different from 127 are obtained. These maps are not direct inputs to the backbone but serve as guidance signals that control structural fusion and the loss function.
The effective model input is constructed by concatenating the aligned degraded image and the canonical template I t e m p l a t e , forming a two-channel tensor:
X = concat ( I a l i g n e d , I t e m p l a t e ) R 2 × H × W
In this way, the network learns to restore degraded content explicitly conditioned on the expected document structure. The template acts as the primary structural prior, while the mask is reserved for guiding permissible edits and region-specific optimization. This design combines observed visual information with structural prior knowledge consistent with the rigid nature of tax form layouts.

3.2.2. Model and Structure-Constrained Optimization

The restoration core is implemented using an encoder–decoder architecture based on a U-Net design, tailored for grayscale document restoration under template guidance. The encoder begins with a double-convolution block and proceeds through four stages of spatial downsampling. Each convolutional block consists of two 3 × 3 convolutions, GroupNorm normalization, and ReLU activation, while spatial downsampling is performed using MaxPool2d. The decoder mirrors this structure using transposed convolutions for upsampling, skip connections from the encoder, and additional double-convolution blocks to refine reconstruction. The output layer consists of a 1 × 1 convolution followed by a sigmoid activation, producing a single-channel prediction I ^ r a w [ 0 , 1 ] H × W . Both during training and inference, the model is instantiated with i n _ c h a n n e l s = 2 .
The raw network prediction is not directly used as the final output. Instead, the method applies a template-constrained fusion mechanism defined as:
I ^ f u s e d = α I ^ r a w + ( 1 α ) I t e m p l a t e
where denotes element-wise multiplication. This operation enforces that the network is allowed greater freedom only in regions enabled by the structural guide, while preserving the template in regions where modification is not desired. The alpha map α is used as a per-pixel blending weight between the network prediction and the canonical template. Specifically, background, fixed structure, and editable content regions are encoded in the master mask with values 0, 127, and 255, respectively. Consequently, α induces a differentiated constraint: background regions are primarily taken from the template, editable regions are primarily taken from the network prediction, and structural regions receive an intermediate blending value. This intermediate value implements a soft constraint rather than a hard copy of the template. Thus, structural pixels are biased toward the canonical template while still allowing smooth transitions with neighboring editable regions, avoiding abrupt visual discontinuities at field boundaries.
Model optimization is based on a composite loss function that integrates global fidelity, structural similarity, and content-specific reconstruction. First, a global L 1 term restricted to valid regions is computed on the fused output:
L g l o b a l = masked L 1 ( I ^ f u s e d , I g t , M v ) .
Second, a structural loss based on SSIM is incorporated:
L s s i m = 1 SSIM ( I ^ f u s e d , I g t ) .
Finally, an L 1 term focused exclusively on editable regions is computed on the raw prediction:
L c o n t e n t = masked L 1 ( I ^ r a w , I g t , M c ) .
The total objective function is defined as:
L = λ 1 L g l o b a l + λ s L s s i m + λ c L c o n t e n t
where the weights λ 1 , λ s and λ c control the contribution of each component. This formulation enables simultaneous enforcement of global document coherence, perceptual similarity of the final output, and localized reconstruction accuracy in regions where the model is expected to intervene. In general terms, L g l o b a l enforces similarity between the fused output and the clean reference, but only over valid regions defined by M v . Since M v , this term supervises background and editable content, but excludes fixed structural regions marked with value 127. Consequently, it does not directly penalize pixel-wise errors in structural zones. L ssim is computed over the full I ^ fused image and encourages local structural consistency using Gaussian windows of size 11 with σ = 1.5 . This term acts as a global constraint, preserving visual coherence and layout consistency even in regions not directly supervised by the L 1 term. The L content term plays a critical role. It is computed not on the fused output but on the raw prediction I ^ raw , and only over editable regions defined by M c . This enforces that the network learns to accurately reconstruct variable content in regions where modification is explicitly required. Figure 3 illustrates the complete pipeline.

3.2.3. Training and Inference Procedure

The DL component is trained in canonical space using supervised pairs of aligned degraded and clean images, together with the canonical template and the three guidance maps derived from the mask. To this end, two dataset construction strategies are implemented. During training, random patches are extracted from the aligned images, increasing the spatial variability observed by the model. During validation, deterministic coordinates are generated for each image in order to maintain a stable evaluation across epochs. In both cases, cropping is performed consistently over the degraded image, the clean image, the template, the alpha map, the content mask, and the validity mask, ensuring that all signals preserve exact spatial correspondence. The model input is formed by concatenating the degraded patch and the template patch, while the remaining maps are subsequently used in fusion and loss computation.
Training optimizes the model parameters using AdamW. At each iteration, the model produces a raw prediction from the input patch; this prediction is then fused with the template using the alpha map, the three loss terms described above are computed, and the parameters are updated through backpropagation. Validation follows exactly the same scheme. This procedure ensures that the network not only generates a reconstruction compatible with the clean reference but also does so under the structural constraints defined by the template and the mask.
During inference, full resolution aligned images are not processed in a single pass, but through an overlapping tiling strategy. For each document, the two-channel input tensor is first constructed from the degraded image and the template. This tensor is then divided into tiles of size t i l e _ s i z e , with overlap controlled by t i l e _ o v e r l a p . Each tile is processed independently by the trained network, and the resulting predictions are recombined using a weight map based on a Hann window, with the aim of attenuating border artifacts between adjacent tiles. The aggregated prediction Î r a w is finally fused with the template using the same α -guided rule employed during training, producing the final restored output in canonical space (see Table 2).

3.3. Baselines and Evaluation Protocol

For the comparative evaluation, the proposed method was contrasted with representative baselines under a common experimental protocol in canonical space. The comparison included: (i) Noisy input, used as a no-restoration reference; (ii) CRP (classic restoration pipeline), a classical DIP-based restoration pipeline evaluated only at inference time; (iii) U-Net baseline [35], which performs supervised restoration from the aligned degraded image without incorporating a structural prior; (iv) U-Net + prior, which incorporates the canonical template as an additional input but does not apply the structurally constrained fusion or the full loss formulation of the proposed method; (v) DE-GAN [36] baseline; and (vi) an attention-based baseline inspired by Restormer [37]. For all learned baselines, the restoration stage was evaluated after geometric normalization, so that the comparison was performed under the same document geometry and with paired samples ( n o i s y a l i g n e d , c l e a n a l i g n e d ). This protocol constitutes a conservative evaluation of the proposed framework, since all learned baselines receive previously aligned inputs. Consequently, the comparison isolates the restoration component and prevents possible failures in geometric normalization from dominating the results.
All restoration models were evaluated on a curated and aligned subset of 2000 synthetic tax documents, divided into 1600 images for training, 200 for validation, and 200 for testing. A common training budget was imposed for all learned methods, consisting of 50 epochs and 500 steps per epoch, without early stopping, for a total of 25,000 optimizer updates per model. Training was performed through random patch sampling. U-Net, U-Net + prior, and the proposed model were trained with 256 × 256 patches and a batch size of 8; DE-GAN used 128 × 128 patches with a batch size of 16; and the attention-based baseline used 128 × 128 patches with a batch size of 4. All experiments were run on a workstation equipped with an Intel Xeon Gold 6230R processor, 250 GB of RAM, and two NVIDIA RTX A6000 GPUs with 48 GB of memory each. Under this protocol, geometric normalization was treated as a fixed preprocessing stage and was evaluated separately before analyzing restoration performance.
The evaluation combined image-level fidelity metrics, binary quality metrics in the filled-in regions, and OCR-based functional metrics. Let I g t be the clean reference image and Î the restored image, both in grayscale and in canonical space. Radiometric fidelity was quantified using the mean squared error and was computed as follows:
M S E = 1 H W u = 1 H v = 1 W ( I ^ ( u , v ) I g t ( u , v ) ) 2
from which the Peak Signal-to-Noise Ratio (PSNR) was computed as:
P S N R = 10 log 10 ( 255 2 M S E ) .
Structural similarity was evaluated using the Structural Similarity Index (SSIM),
S S I M ( I ^ , I g t ) = ( 2 μ I ^ μ I g t + c 1 ) ( 2 σ I ^ I g t + c 2 ) ( μ I ^ 2 + μ I g t 2 + c 1 ) ( σ I ^ 2 + σ I g t 2 + c 2 )
where μ , σ 2 and σ I ^ I g t represent local means, variances, and covariance, respectively.
For the binarization metrics, both I g t and Î were converted into binary foreground masks using either an adaptive or global threshold, depending on the selected method. In general terms, the binary mask B was defined as:
B ( u , v ) = { 1 , I ( u , v ) < τ ( u , v ) , 0 , otherwise ,
where τ ( u ,   v ) represents the binarization threshold. The binary metrics were computed over a region of interest Ω corresponding to the filled-in fields of the document, that is, for pixels ( u ,   v )     Ω . Over this region, the following quantities were defined:
T P =   | { B I ^ ( u , v ) = 1   and   B c ( u , v ) = 1 } | F P =   | { B I ^ ( u , v ) = 1   and   B c ( u , v ) = 0 } | F N =   | { B I ^ ( u , v ) = 0   and   B c ( u , v ) = 1 } |
where | . | denotes the cardinality of the set, that is, the number of pixels satisfying the condition. From these quantities, Precision, Recall, and F-measure were computed as:
P =   T P T P + F P ,             R = T P T P + F N ,                 F - measure = 2 P R P + R  
Binary distortion was also evaluated using the Distance Reciprocal Distortion (DRD). Let E = { ( u , v ) Ω :   B I ^ ( u , v ) B c ( u , v ) } , be the set of erroneous pixels. The implementation used computes:
D R D = 1 N U B N ( u , v ) E   D R D ( u , v ) ,
where N U B N is the number of non-uniform 8 × 8 blocks in the binary reference within the evaluated region. For each erroneous pixel ( u ,   v ) , DRD is computed as follows:
D R D ( u , v ) = i = 2 2 j = 2 2 | B c ( u + i , v + j ) B I ^ ( u , v ) | W ( i , j ) ,
with a normalized weight mask:
W = 1 16 [ 0 0 1 0 0 0 1 2 1 0 1 2 0 2 1 0 1 2 1 0 0 0 1 0 0 ] .
Finally, functional utility was measured using OCR applied to the identification fields delimited by the PDF template. Text recognition was performed with the Tesseract OCR engine version 5.5.1, compiled with Leptonica 1.82.0. It was configured with page segmentation mode (PSM) 6, corresponding to a uniform text block, and the Spanish language model (spa), without additional preprocessing of the restored image. For each sample n , the seven fields of the identification section were automatically extracted (tipo_doc, primer_apellido, segundo_apellido, primer_nombre, segundo_nombre, razon_social, nombre_comercial). The ground-truth texts were then concatenated into a string t n , and the OCR-recognized texts into a string t ^ n . Before computation, both strings were normalized by converting them to uppercase, removing accents, and collapsing multiple spaces. With this normalization, the character and word error rates for each sample were defined as follows:
C E R n = E D c h a r ( t ^ n , t n ) max ( 1 ,   | t n | c h a r ) ,   W E R n = E D w o r d ( t ^ n , t n ) max ( 1 ,   | t n | w o r d ) ,
where E D c h a r and E D w o r d correspond to the Levenshtein distance at the character and word levels, respectively. Micro-averages were used for reporting the results:
C E R m i c r o = n = 1 N E D c h a r ( t ^ n , t n ) n = 1 N | t n | c h a r , W E R m i c r o = n = 1 N E D w o r d ( t ^ n , t n ) n = 1 N | t n | w o r d .

4. Results

4.1. Validation of the Synthetic Dataset

4.1.1. Partition Homogeneity

The synthetic dataset was split into 80%/10%/10% for training, validation, and testing, respectively. To rule out partitioning biases in the degradation variables, homogeneity across partitions was evaluated.
Table 3 presents the homogeneity verification across dataset partitions for the degradation variables: contrast α , brightness β , angle θ , and translations t x and t y . The Kullback-Leibler (KL) divergence is reported as a descriptive measure of discrepancy, and the p-value of the energy distance test is used as an inferential contrast of the null hypothesis H 0 : both partitions come from the same distribution. In all comparisons (train-validation and train-test), the p-values were greater than 0.05 ; therefore, there is no statistical evidence to reject H 0 . Consequently, the partitions maintain similar degradation distributions, reducing the risk of experimental bias due to partitioning and supporting the attribution of observed performance differences to the model rather than to systematic imbalances in the degradation parameters.

4.1.2. Validity Against Real Data Using a Coverage Criterion

Due to privacy restrictions, the available real dataset does not correspond to a designed probabilistic sample. In addition, with approximately 37 real documents, the power of two-sample tests is limited, and several image metrics do not follow normal distributions, reducing the usefulness of parametric tests in this setting. Consequently, a coverage-based compatibility validation was adopted. The objective was to verify that the real documents were not atypical with respect to a high-density region induced by a large synthetic sample, using PCA fitted on the synthetic data and an elliptical region defined by the threshold χ k 2   ( 0.95 ) .
Using 1000 synthetic samples and 37 real documents, a coverage of 35/37 (94.6%) was obtained, with a minimum 95% confidence bound of 81.8 % , using k   =   4 principal components and a threshold of χ 2   =   9.488 with Ledoit-Wolf covariance. This result supports that the generator produces samples consistent with the available real set under the defined compatibility criterion (see Figure 4).

4.2. Validation of the Restoration Method

4.2.1. Performance of Geometric Normalization

The geometric normalization stage was evaluated on the test partition using robust statistics, specifically the median and interquartile range (IQR), in order to characterize variability across samples. First, the alignment success rate reached 100% (200/200 test documents), defined as the proportion of samples for which a valid homography was estimated and an aligned output was correctly generated. In addition, considering the full aligned and curated dataset, all 2000 / 2000 selected samples were successfully normalized, with no failures recorded during dataset construction.
Second, the inlier ratio was quantified, defined as n u m _ i n l i e r s / g o o d _ m a t c h e s , which directly reflects the geometric consistency of the correspondences retained by RANSAC. In the test set, this ratio had a median of 0.7958 and an IQR from 0.7499 to 0.8213. Complementarily, the number of inliers showed a median of 410.5 (IQR: 317.0–518.25), while the number of retained valid matches reached a median of 524.5 (IQR: 411.0–631.0) (see Table 4). Figure 5 shows an example of the result on a test-set case.

4.2.2. Restoration Results and OCR Utility

Figure 6 and Table 5 summarize the qualitative and quantitative comparison between the proposed method and the considered baselines, including a no-restoration reference (Noisy input) and a classical restoration pipeline (CRP). The results in Table 5 correspond to the fixed-budget scenario, in which all learned models were trained for 50 epochs and 500 steps per epoch, ensuring a controlled comparison across architectures. The evaluation was performed on the test set aligned in canonical space, allowing all methods to be compared under the same geometry. Therefore, the results in Table 5 should be interpreted as a comparison focused on the restoration stage, under favorable and homogeneous conditions for all learned models. In this scenario, PSNR and SSIM quantify radiometric and structural fidelity with respect to the clean reference, while F-measure and DRD evaluate the preservation of the document foreground after binarization. To measure functional utility, CER and WER were computed from OCR on the identification region of the form, comparing the recognized text with the synthetic reference content available in the dataset JSON files. In particular, these metrics were aggregated as micro-averages, in order to reflect the total character and word error over the full evaluated set.
First, the results show that both Noisy input and CRP remain clearly below the learned models. Although CRP slightly improves over the degraded input image (PSNR: 15.4991 vs. 14.5045; CER: 0.1455 vs. 0.1538), its performance remains limited across all metrics, confirming that a classical pipeline is insufficient under complex degradations in structured tax documents. In contrast, all deep learning-based methods produce a substantial improvement in visual fidelity, structural consistency, and OCR legibility.
Among the learned baselines, U-Net + prior achieved the best performance in the visual and structural metrics, reaching the highest PSNR (28.3218 ± 2.3118), the highest SSIM (0.9841 ± 0.0079), the best F-measure (0.9243 ± 0.0261), and the lowest DRD (183.1854 ± 97.3021). This result indicates that, once the geometry is fixed through prealignment, explicitly incorporating the canonical format as a prior provides a clear advantage over purely end-to-end restoration. Indeed, U-Net + prior outperforms both the U-Net baseline and the Attention baseline, suggesting that, in this problem, explicit document structure is more beneficial than only increasing architectural complexity or introducing attention mechanisms without geometric constraints.
However, when the comparison shifts to the functional level, the most relevant behavior corresponds to the proposed hybrid method. Although it does not achieve the best PSNR or SSIM, it obtains the best OCR utility results, with the lowest CER (0.1091) and the lowest WER (0.3495) in the entire comparison. This is particularly important because the objective of the problem is not only to restore the global appearance of the form, but also to correctly preserve and recover the variable content inserted into a rigid template. In this sense, the hybrid method shows a better balance between visual restoration and semantic text recovery, which is consistent with its design: the canonical template resolves the fixed structure, while the network focuses on reconstructing useful content within the informative regions.
On the other hand, the DE-GAN baseline showed the worst performance among the learned models (CER: 0.3928; WER: 0.9353), even with structural results below several non-adversarial baselines. This behavior suggests that, for this type of form, adversarial optimization does not offer a clear advantage and may even affect the stability of the restoration. Similarly, the Attention baseline improves over Noisy input and CRP, but remains below the prior-guided variants, reinforcing the central hypothesis of this work: in documents with a rigid layout, learned attention alone does not replace the explicit incorporation of structural information.
This allows two main conclusions to be drawn. First, canonical prealignment followed by supervised restoration constitutes an effective strategy for this problem. Second, the best visual quality does not necessarily coincide with the best OCR utility: while U-Net + prior dominates in fidelity and structural preservation, the proposed hybrid method provides the best textual recovery, which is ultimately the most relevant property in automatic reading and document-processing scenarios.
As a complementary analysis, Table 6 reports a convergence-oriented scenario based on early stopping. Table 5 should be interpreted as the main comparison under a fixed and homogeneous training budget, whereas Table 6 presents a convergence-based scenario in which each learned model is evaluated at the best checkpoint determined by the evolution of the validation criterion. In this configuration, early stopping was applied with a patience of 5 epochs and a maximum of 120 epochs, while keeping the same dataset, validation split, and 500 steps per epoch used in the fixed-budget setting. The results show that this configuration preserves the general ranking trends: U-Net + prior remains the strongest method in terms of visual and structural fidelity, whereas the proposed hybrid model achieves the best OCR-oriented performance (CER = 0.1072, WER = 0.3175). This result suggests that, when training is allowed to adapt to convergence, the hybrid formulation better supports the objective of improving the functional legibility of the document, rather than optimizing only global image similarity.
Figure 7. Improvement in validation metric (from epoch 1) over training epochs under early stopping.
Figure 7. Improvement in validation metric (from epoch 1) over training epochs under early stopping.
Preprints 223800 g007

4.2.3. Computational Cost and Practical Efficiency

Table 7 compares the computational cost of the evaluated methods in terms of number of parameters, arithmetic complexity, peak GPU memory, training time, and inference latency. This analysis complements the restoration and OCR results, since in real document-processing applications, not only output quality matters, but also the practical feasibility of the method under time and resource constraints.
First, the U-Net-based models show a very similar computational profile. The U-Net baseline, U-Net + prior, and the proposed hybrid model have around 7.76 M parameters and 27.3 G FLOPs, with memory requirements close to 1.5 GB and training times per epoch between 74 and 77 s. This indicates that incorporating the canonical prior and the hybrid scheme does not introduce a severe computational penalty compared with the base model. In particular, using the 1600 training images, the proposed method requires 77.02 ± 0.69 s per epoch and 64.18 ± 0.57 min to complete 50 epochs, representing only a moderate increase compared with the U-Net baseline (61.82 ± 0.40 min) and U-Net + prior (62.97 ± 1.12 min).
The DE-GAN baseline has the lowest number of parameters (1.810 M) and the lowest theoretical complexity (0.428/0.214 G FLOPs/MACs), as well as the lowest inference latency among the learned models (2.67 ± 0.12 ms). However, this cost advantage does not translate into better restoration quality, since it was one of the worst-performing methods in the previously reported metrics. This suggests that low arithmetic complexity alone is not sufficient to adequately restore degraded rigid forms.
In contrast, the Attention baseline represents the least favorable case in terms of practical efficiency. Although its number of parameters (3.293 M) is lower than that of the U-Net variants, its peak memory reaches 3.188 ± 0.019 GB, more than twice that of the other learned models, and its inference latency reaches 20.61 ± 0.73 ms, well above the rest. It also records the highest training time per epoch (91.14 ± 0.33 s). Consequently, this model does not offer an attractive cost-benefit ratio for real deployment scenarios.
Finally, CRP does not require training, but its inference latency (132.17 ± 9.21 ms) is the highest among all evaluated methods. This indicates that avoiding training cost does not necessarily imply greater operational efficiency when large volumes of documents must be processed.
The proposed hybrid method offers a favorable trade-off between performance and computational cost. Although it is not the lightest method, it maintains memory requirements, training time, and latency very close to U-Net + prior, while improving the final utility for OCR. From a practical perspective, this suggests that the functional gain of the hybrid approach is achieved without introducing prohibitive computational overhead.

4.2.4. Component Ablation

Table 8 presents the results of the ablation study of the proposed method on the test set, with the aim of isolating the effect of three key components: the content-oriented masked loss, the structural fusion with the canonical template, and the explicit visual template prior. In all cases, the variants were retrained under the same experimental protocol as the full model, so that the observed differences could be attributed primarily to the removed component.
The most consistent result corresponds to the w/o template prior variant, which produces the largest overall degradation in the visual and structural metrics. Compared with Hybrid full, this ablation reduces PSNR from 26.4961 to 24.2217, SSIM from 0.9607 to 0.9438, and F-measure from 0.9113 to 0.8701, while increasing DRD from 297.3505 to 325.9923. This behavior indicates that the explicit canonical prior is a central component of the method, since it provides a stable structural reference that improves restoration in documents with a fixed layout. In other words, when the model loses access to the visual template of the form, its ability to preserve the global organization of the document is clearly reduced.
The other two ablations show a more subtle behavior. Both w/o masked content loss and w/o template fusion obtain higher values than the full model in PSNR, SSIM, F-measure, and DRD. In particular, w/o template fusion achieves the best visual results in the table, with PSNR = 28.3505 ± 2.3779, SSIM = 0.9827 ± 0.0082, and DRD = 146.0933 ± 90.4275. However, this improvement does not translate into better textual utility: its OCR metrics (CER = 0.1124, WER = 0.3588) remain below those of the full model. A similar pattern is observed for w/o masked content loss, which improves the visual restoration metrics but worsens text recovery (CER = 0.1142, WER = 0.3627).
This result is particularly relevant for interpreting the behavior of the proposed method. The full variant is not optimized solely to maximize global image similarity, but rather to correctly recover the variable content of the form. The masked loss and template fusion appear to act as functional regularization mechanisms, sacrificing part of the global visual fidelity to favor the preservation and legibility of useful content. Therefore, although the simplified variants may produce images closer to the GT in terms of PSNR/SSIM, the full model remains the one with the best OCR performance, achieving the lowest CER (0.1091) and WER (0.3495) in the ablation study.
Therefore, first, the template prior is the most critical component for maintaining the structural quality of the method. Second, the combination of content-oriented loss and template fusion does not necessarily maximize classical visual metrics, but it does improve the final utility of the restored document for automatic reading.

4.3. Functional Evaluation on Real Documents

To complement the controlled evaluation on synthetic data, a functional test was conducted on the 37 available real documents. Unlike the synthetic set, these documents do not have a clean reference image that would allow pixel-level metrics such as PSNR or SSIM to be computed. For this reason, the evaluation on real data was not designed as a direct measurement of visual fidelity, but rather as a test of textual recoverability after restoration.
For each real document, two versions were considered: the original degraded image and the image restored with the proposed hybrid method. In addition, a textual ground truth was manually constructed from the full form page, including both fixed template text and the information filled into the document fields.
The evaluation was performed using three independent OCR engines: GLM OCR [38], Amazon Textract [39], and Tesseract [40]. For each engine, text was extracted from the full page in both image versions. The percentage of ground-truth words recovered by the OCR output was then measured. This metric is interpreted as lexical coverage of the document, not as full OCR accuracy, since it does not explicitly penalize insertions, false positives, or semantic field-level errors. Formally, for each OCR engine, coverage was computed as:
C o v e r a g e =   | W g t W o c r | | W g t |
where W g t represents the list of normalized ground-truth words and W o c r the list of normalized words detected by the OCR engine. Coverage was computed as lexical recovery, counting each ground-truth word as recovered if it appeared at least once in the OCR output.
Table 9 presents the results obtained. For the three OCR engines evaluated, restoration increased the coverage of ground-truth words compared with the degraded real image.
Because coverage is computed over the full page, the metric combines fixed template text and filled-in content; therefore, this test evaluates the document’s overall textual recoverability. The results show that the proposed restoration improves textual recoverability in real documents across the three OCR engines considered. The gain is moderate for GLM OCR, which already achieves high coverage on the original degraded image, and more pronounced for Amazon Textract and Tesseract. In particular, Tesseract shows the largest absolute improvement, increasing from 11.84% to 29.89%, suggesting that OCR engines more sensitive to noise, misalignment, and visual degradation may benefit more clearly from structure-guided restoration.
This test does not replace the main quantitative evaluation performed on synthetic data, where a clean reference and experimental control are available. However, it provides complementary evidence on real documents, showing that the proposed method not only improves visual and structural metrics on synthetic data, but also increases full-page textual recovery in real scenarios.

5. Discussion

The results suggest that, for structured tax documents, restoration evaluation should not focus solely on the generative capacity of increasingly large image models, but also on their ability to recover the document without introducing uncertainty into legally sensitive content. In this type of document, a spurious stroke, an altered digit, or a displaced field boundary can compromise the functional validity of the record. This is compounded by an equally relevant practical constraint: such documents often contain confidential information, so their processing with large-scale models, especially when they rely on external infrastructure or remote services, introduces additional requirements for security, traceability, and data governance. Therefore, constraining restoration through canonical alignment, templates, and masks is not only a design decision, but also a way to reduce the degrees of freedom in a problem where structural fidelity, process control, and information protection are more important than isolated perceptual quality.
In this direction, the findings reinforce a broader idea: end-to-end deep learning is not always the most suitable option when the domain imposes strong geometric and semantic constraints. In the proposed approach, the classical DIP component does not compete with the network; instead, it simplifies the problem by first fixing the geometry and providing an explicit layout prior. This helps explain why template-guided variants showed advantages over adversarial alternatives or attention-only models. In particular, the hybrid method obtained the lowest CER and WER values in the evaluated protocol, supporting the usefulness of combining geometric normalization, structural priors, and supervised restoration when the final objective is to improve automatic reading. At the same time, recovering small letters, fine separators, and few-pixel-wide lines remains difficult for any method, because these are precisely the structures most vulnerable to degradation and local ambiguity.
Regarding the scope of the study, the quantitative comparison was conducted under a homogeneous and controlled protocol, in order to isolate the effect of the restoration stage and compare the methods under the same document geometry. For this reason, the main results should be understood as a specific evaluation of restoration in canonical space, with previously aligned inputs. The evaluation on real data, in turn, measures textual recoverability rather than pixel-level restoration fidelity, since no clean visual reference is available for those documents. Consequently, the results on real documents serve as complementary functional evidence: they show that the proposed restoration increases OCR coverage under real conditions, but they are not intended to replace the controlled evaluation performed on synthetic data. Likewise, the objective was not to propose an OCR system, but to improve the functionality of the OCR engine used after restoration. Therefore, CER, WER, and word coverage should be interpreted as OCR-dependent functional metrics, useful for characterizing the practical utility of the restored document.
Finally, the use of synthetic data remains the main factor requiring caution in the interpretation of the results. Although the coverage-based validation showed compatibility between the generator and the available real sample, with 35 out of 37 real documents falling within the confidence region induced by the synthetic data, this does not rule out the existence of extreme cases that are not yet represented. This consideration is especially important in the tax and legal context, where the problem is not only to recover content, but also to avoid introducing plausible but false content. In this scenario, structural control of the restoration process and the explicit reduction of degrees of freedom are central elements of the proposed approach. As a natural continuation of this work, it is pertinent to extend the validation with more diverse real documents, study out-of-distribution failures, and incorporate uncertainty estimation mechanisms before considering operational use in sensitive environments.

6. Conclusions

This work addressed the restoration of degraded tax forms as a recovery problem under structural constraints, rather than as an unconstrained generation task. The combination of geometric normalization, a canonical template, structural masks, and supervised restoration reduced the model’s degrees of freedom and guided the restoration process toward functionally relevant regions of the document.
The results show that, under a controlled synthetic protocol and in canonical space, template-guided methods provide advantages over baselines without structural information. U-Net + prior achieved the best visual and structural fidelity, whereas the proposed hybrid method obtained the lowest CER and WER values in the OCR evaluation. This discrepancy between visual and functional metrics reinforces the need to evaluate document restoration not only in terms of image similarity, but also in terms of usefulness for automatic reading.
As a complementary evaluation, real documents showed improvements in OCR coverage after restoration. However, these results should be interpreted with caution, since no clean visual reference is available and the coverage metric includes both fixed template text and filled-in content. A priority direction for future work is to extend the evaluation to a larger set of real documents, separate fixed and variable fields, evaluate the full end-to-end pipeline, and incorporate uncertainty estimation before operational use in tax or legal contexts.

Author Contributions

Conceptualization, O.P. and G.S.; methodology, O.P. and G.S.; software, O.P.; validation, O.P., G.S. and J.W.; formal analysis, G.S.; investigation, O.P.; resources, J.W.; data curation, O.P.; writing—original draft preparation, O.P. and G.S.; writing—review and editing, O.P., G.S. and J.W.; visualization, O.P. and G.S.; supervision, G.S. and J.W.; project administration, G.S. and J.W.; funding acquisition, J.W. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The synthetic data generation procedure and experimental configuration are described in the manuscript. The real-world document images used for complementary evaluation are not publicly available due to privacy and confidentiality restrictions. Open resources used in this study are available at https://github.com/oswaldoapr/hybrid-tax-document-restorer.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Fathallah, A.; El-Yacoubi, M.A.; Essoukri Ben Amara, N. EHDI: Enhancement of historical document images via generative adversarial network. In Proceedings of the 18th International Conference on Computer Vision Theory and Applications (VISAPP), Lisbon, Portugal, 19–21 February 2023; Volume 4, pp. 238–245. [Google Scholar] [CrossRef]
  2. Han, S.; Ji, S.; Rhee, J. Diffusion-denoising process with gated u-net for high-quality document binarization. Appl. Sci. 2023, 13, 11141. [Google Scholar] [CrossRef]
  3. Yang, Z.; Liu, B.; Xiong, Y.; Yi, L.; Wu, G.; Tang, X.; Liu, Z.; Zhou, J.; Zhang, X. DocDiff: Document enhancement via residual diffusion models. In Proceedings of the 31st ACM International Conference on Multimedia, Ottawa, ON, Canada, 29 October–3 November 2023; pp. 2795–2806. [Google Scholar] [CrossRef]
  4. Neji, H.; Ben Halima, M.; Nogueras-Iso, J.; Hamdani, T.M.; Lacasta, J.; Chabchoub, H.; Alimi, A.M. Doc-Attentive-GAN: Attentive GAN for historical document denoising. Multimed. Tools Appl. 2024, 83, 55509–55525. [Google Scholar] [CrossRef]
  5. Lugo-Torres, G.; Peralta-Rodriguez, D.A.; Valdez-Rodriguez, J.E.; Calvo, H. Enhancing document digitization: Image denoising with a cycle generative adversarial network. In Proceedings of the 2023 IEEE Symposium Series on Computational Intelligence (SSCI), Mexico City, Mexico, 5–8 December 2023; pp. 1461–1466. [Google Scholar] [CrossRef]
  6. Neji, H.; Nogueras-Iso, J.; Lacasta, J.; Halima, M.B.; Alimi, A.M. Adversarial autoencoders for denoising digitized historical documents: The use case of incunabula. In Proceedings of the 2019 International Conference on Document Analysis and Recognition Workshops (ICDARW), Sydney, NSW, Australia, 22–25 September 2019; Volume 6, pp. 31–34. [Google Scholar] [CrossRef]
  7. Wang, X.; E, N.; Yang, J. Image clearness processing for image restoration based on generative adversarial networks. Int. J. Cogn. Comput. Eng. 2025, 6, 360–369. [Google Scholar] [CrossRef]
  8. Du, Z.; He, C. Nonlinear diffusion system for simultaneous restoration and binarization of degraded document images. Comput. Math. With Appl. 2024, 153, 237–248. [Google Scholar] [CrossRef]
  9. Guo, J.; He, C. Adaptive shock-diffusion model for restoration of degraded document images. Appl. Math. Model. 2020, 79, 555–565. [Google Scholar] [CrossRef]
  10. Jung, S.; Hasan, M.A.; Kim, C. Water-filling: An efficient algorithm for digitized document shadow removal. In Computer Vision—ACCV 2018; Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Cham, Switzerland, 2019; Volume 11361, pp. 398–414. [Google Scholar] [CrossRef]
  11. Nnolim, U.A. Enhancement of degraded document images via augmented fourth order partial differential equation and Total Variation-based illumination estimation. Optik 2022, 249, 168262. [Google Scholar] [CrossRef]
  12. Wang, Y.; Zhou, L.; Zhang, X. Spatio-temporal regularized shock-diffusion filtering with local entropy for restoration of degraded document images. Appl. Math. Comput. 2023, 436, 127618. [Google Scholar] [CrossRef]
  13. Zahra, A.B.F.; Moad, H.; Idriss, E.M.; Said, R. A p-Laplacian model for uneven illumination enhancement of document images. J. Math. Model. 2023, 11, 157–169. [Google Scholar] [CrossRef]
  14. Khan, S.U.; Ullah, I.; Khan, F.; Lee, Y.; Ullah, S. Historical text image enhancement using image scaling and generative adversarial networks. Sensors 2023, 23, 4003. [Google Scholar] [CrossRef] [PubMed]
  15. Kim, J.; Choe, Y. Document image restore via SPADE-based super-resolution network. Electronics 2023, 12, 748. [Google Scholar] [CrossRef]
  16. Hoque, O.B.; Rashid, M.B.; Jawad, K.M.T. Autonomous deblurring images and information extraction from documents using CycleGAN and mask RCNN. In Proceedings of the 2020 23rd International Conference on Computer and Information Technology (ICCIT), DHAKA, Bangladesh, 19–21 December 2020. [Google Scholar] [CrossRef]
  17. Kodym, O.; Hradiš, M. TG2: Text-guided transformer GAN for restoring document readability and perceived quality. Int. J. Doc. Anal. Recognit. (IJDAR) 2022, 25, 15–28. [Google Scholar] [CrossRef]
  18. Rahman, M.M.; Ahmed, A.; Hasan Mahin, M.R.; Bin Kibria, F.; Moonwar, W.; Rhythm, E.R.; Alim Rasel, A. ReSkipNet: Skip connected convolutional autoencoder for original document denoising. In Proceedings of the 2023 26th International Conference on Computer and Information Technology (ICCIT), Cox’s Bazar, Bangladesh, 13–15 December 2023. [Google Scholar] [CrossRef]
  19. Bella, F.Z.A.; Rhabi, M.E.; Hakim, A.; Laghrib, A. An innovative document image binarization approach driven by the non-local p-Laplacian. EURASIP J. Adv. Signal Process. 2022, 50. [Google Scholar] [CrossRef]
  20. De, R.; Chakraborty, A.; Sarkar, R. Document image binarization using dual discriminator generative adversarial networks. IEEE Signal Process. Lett. 2020, 27, 1090–1094. [Google Scholar] [CrossRef]
  21. Ju, R.-Y.; Lin, Y.-S.; Jin, Y.; Chen, C.-C.; Chien, C.-T.; Chiang, J.-S. Three-stage binarization of color document images based on discrete wavelet transform and generative adversarial networks. Knowl.-Based Syst. 2024, 304, 112542. [Google Scholar] [CrossRef]
  22. Ju, R.-Y.; Lin, Y.-S.; Chiang, J.-S.; Chen, C.-C.; Chen, W.-H.; Chien, C.-T. CCDWT-GAN: Generative adversarial networks based on color channel using discrete wavelet transform for document image binarization. In PRICAI 2023: Trends in Artificial Intelligence; Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Singapore, 2024; Volume 14325, pp. 186–198. [Google Scholar] [CrossRef]
  23. Lin, Y.-S.; Lin, T.-Y.; Chiang, J.-S.; Chen, C.-C. Binarization of color document image based on adversarial generative network and discrete wavelet transform. In Proceedings of the 2022 IET International Conference on Engineering Technologies and Applications (IET-ICETA), Changhua, Taiwan, 14–16 October 2022. [Google Scholar] [CrossRef]
  24. Jemni, S.K.; Souibgui, M.A.; Kessentini, Y.; Fornés, A. Enhance to read better: A multi-task adversarial network for handwritten document image enhancement. Pattern Recognit. 2022, 123, 108370. [Google Scholar] [CrossRef]
  25. Sfikas, G.; Retsinas, G.; Gatos, B. Document binarization with quaternionic double discriminator generative adversarial network. In Document Analysis and Recognition—ICDAR 2023 Workshops; Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Cham, Switzerland, 2023; Volume 14194, pp. 272–284. [Google Scholar] [CrossRef]
  26. Suh, S.; Kim, J.; Lukowicz, P.; Lee, Y.O. Two-stage generative adversarial networks for binarization of color document images. Pattern Recognit. 2022, 130, 108810. [Google Scholar] [CrossRef]
  27. Sukesh, R.; Seuret, M.; Nicolaou, A.; Mayr, M.; Christlein, V. A fair evaluation of various deep learning-based document image binarization approaches. In Document Analysis Systems; Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Cham, Switzerland, 2022; Volume 13237, pp. 771–785. [Google Scholar] [CrossRef]
  28. Zhao, J.; Shi, C.; Jia, F.; Wang, Y.; Xiao, B. Document image binarization with cascaded generators of conditional generative adversarial networks. Pattern Recognit. 2019, 96, 106968. [Google Scholar] [CrossRef]
  29. Guo, J.; He, C.; Zhang, X. Nonlinear edge-preserving diffusion with adaptive source for document images binarization. Appl. Math. Comput. 2019, 351, 8–22. [Google Scholar] [CrossRef]
  30. Guo, J.; He, C.; Wang, Y. Fourth order indirect diffusion coupled with shock filter and source for text binarization. Signal Process. 2020, 171, 107478. [Google Scholar] [CrossRef]
  31. Saifullah, S.; Agne, S.; Dengel, A.; Ahmed, S. ColDBin: Cold diffusion for document image binarization. In Document Analysis and Recognition—ICDAR 2023; Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Springer: Cham, Switzerland, 2023; Volume 14191, pp. 207–226. [Google Scholar] [CrossRef]
  32. Zhang, X.; He, C.; Guo, J. Selective diffusion involving reaction for binarization of bleed-through document images. Appl. Math. Model. 2020, 81, 844–854. [Google Scholar] [CrossRef]
  33. Dey, A.; Das, N.; Nasipuri, M. Variational augmentation for enhancing historical document image binarization. In Proceedings of the 13th Indian Conference on Computer Vision, Graphics and Image Processing (ICVGIP), Gujarat, India, 8–10 December 2022. [Google Scholar]
  34. Yang, Z.; Liu, B.; Xiong, Y.; Wu, G. GDB: Gated convolutions-based document binarization. Pattern Recognit. 2024, 146, 109989. [Google Scholar] [CrossRef]
  35. Ronneberger, O.; Fischer, P.; Brox, T. U-Net: Convolutional Networks for Biomedical Image Segmentation. arXiv 2015. [Google Scholar] [CrossRef]
  36. DE-GAN: A Conditional Generative Adversarial Network for Document Enhancement. Available online: https://www.computer.org/csdl/journal/tp/2022/03/09187695/1mVFmWt3gGs (accessed on 10 March 2026).
  37. Zamir, S.W.; Arora, A.; Khan, S.; Hayat, M.; Khan, F.S.; Yang, M.-H. Restormer: Efficient Transformer for High-Resolution Image Restoration. arXiv 2022. [Google Scholar] [CrossRef]
  38. Duan, S.; Xue, Y.; Wang, W.; Su, Z.; Liu, H.; Yang, S.; Gan, G.; Wang, G.; Wang, Z.; Yan, S.; et al. GLM-OCR Technical Report. Available online: https://arxiv.org/abs/2603.10910v2 (accessed on 4 June 2026).
  39. Amazon Textract Documentation. Available online: https://docs.aws.amazon.com/textract/ (accessed on 4 June 2026).
  40. Smith, R. An Overview of the Tesseract OCR Engine. In Proceedings of the Ninth International Conference on Document Analysis and Recognition (ICDAR 2007), Curitiba, Brazil, 23–26 September 2007; Volume 2, pp. 629–633. [Google Scholar]
Figure 1. General flow of the proposed methodology for documentary restoration with controlled synthetic degradations.
Figure 1. General flow of the proposed methodology for documentary restoration with controlled synthetic degradations.
Preprints 223800 g001
Figure 2. Generation flow of the synthetic dataset and its associated outputs.
Figure 2. Generation flow of the synthetic dataset and its associated outputs.
Preprints 223800 g002
Figure 3. Template-guided hybrid restoration pipeline with geometric normalization and mask-based fusion.
Figure 3. Template-guided hybrid restoration pipeline with geometric normalization and mask-based fusion.
Preprints 223800 g003
Figure 4. Synthetic-real validation using PCA and an elliptical confidence region (χ2, 95%). (a) PC1–PC2 projection of synthetic and real samples with a confidence ellipse fitted on the synthetic samples; (b) cumulative explained variance (dashed line: 90%); and (c) explained variance per principal component.
Figure 4. Synthetic-real validation using PCA and an elliptical confidence region (χ2, 95%). (a) PC1–PC2 projection of synthetic and real samples with a confidence ellipse fitted on the synthetic samples; (b) cumulative explained variance (dashed line: 90%); and (c) explained variance per principal component.
Preprints 223800 g004
Figure 5. Examples of geometric normalization. The document was aligned to the canonical template, obtained from 321 good matches, of which 244 were retained as inliers (inlier ratio = 0.7601). Panels show: (a) noisy input, (b) aligned noisy image and (c) aligned clean image.
Figure 5. Examples of geometric normalization. The document was aligned to the canonical template, obtained from 321 good matches, of which 244 were retained as inliers (inlier ratio = 0.7601). Panels show: (a) noisy input, (b) aligned noisy image and (c) aligned clean image.
Preprints 223800 g005
Figure 6. Visual example of restoration results in the canonical space obtained with different methods: (a) Noisy input, (b) Noisy aligned, (c) CRP, (d) U-Net baseline, (e) U-Net + prior, (f) DE-GAN baseline, (g) Attention baseline, and (h) Proposed hybrid model.
Figure 6. Visual example of restoration results in the canonical space obtained with different methods: (a) Noisy input, (b) Noisy aligned, (c) CRP, (d) U-Net baseline, (e) U-Net + prior, (f) DE-GAN baseline, (g) Attention baseline, and (h) Proposed hybrid model.
Preprints 223800 g006
Table 1. Synthetic degradation model and parameter sampling ranges.
Table 1. Synthetic degradation model and parameter sampling ranges.
Parameter Operation Sampling Rule Range/Values Prob Default
alpha Contrast scaling U [1.0, 1.4] 0.5 1.0
beta Brightness shift U [0.0, 15.0] 0.5 0.0
mean Gaussian noise mean U [−10.0, 10.0] 0.6 0.0
stddev Gaussian noise standard deviation U [0.0, 12.0] 0.6 0.0
min_pixel_value Noise support lower bound DU [50, 140] 0.6 0
max_pixel_value Noise support upper bound DU [min_pixel_value, 200] 0.6 255
blur_size Gaussian blur kernel size RC {1, 3} (both axes) 0.5 (1, 1)
dpi Resolution resampling DU [120, 240] 0.5 186
tx Horizontal translation DU [−50, 50] px 0.7 0
ty Vertical translation DU [−70, 70] px 0.7 0
angle Rotation U [−5, 5] degrees 0.7 0
scale Isotropic scaling U [0.7, 1.0] 0.7 1.0
method Thresholding mode RC {adaptive_mean, adaptive_gaussian} 0.3 none
U = Uniform; DU = Discrete uniform; RC = Random choice.
Table 2. Main training and inference hyperparameters of the proposed hybrid method.
Table 2. Main training and inference hyperparameters of the proposed hybrid method.
Component Parameter Value Parameter Value
Training patch_size 256 steps_per_epoch 500
batch_size 8 epochs 50
Optimization lr 1 × 10−3 weight_decay 1 × 10−5
Loss l1_weight 1.0 content_weight 3.0
ssim_weight 0.2
Architecture base_ch 32 tile_overlap 64
Inference tile_size 512
Structural mask values {0, 127, 255}
SSIM window_size 11 sigma 1.5
Table 3. Statistical comparison of degradation variables across dataset partitions.
Table 3. Statistical comparison of degradation variables across dataset partitions.
Train vs. Validation Train vs. Test
Variable KL p-Value KL p-Value
alpha 6.04 0.17 3.72 0.51
beta 5.07 0.72 3.16 0.48
mean 3.86 0.29 5.36 0.71
stddev 7.71 0.16 5.67 0.47
min_pixel_value 4.19 0.75 6.26 0.08
max_pixel_value 5.44 0.42 6.21 0.53
dpi 4.21 0.83 6.38 0.39
tx 3.88 0.68 2.05 0.15
ty 5.25 0.08 3.01 0.39
angle 4.50 0.95 2.33 0.74
Table 4. Performance of the geometric normalization stage on the test set.
Table 4. Performance of the geometric normalization stage on the test set.
Metric Test Set
Alignment success rate 100% (200/200)
Inlier ratio, median (IQR) 0.7958 (0.7499–0.8213)
Number of inliers, median (IQR) 410.5 (317.0–518.25)
Good matches, median (IQR) 524.5 (411.0–631.0)
Table 5. Quantitative comparison of the proposed method against reference methods.
Table 5. Quantitative comparison of the proposed method against reference methods.
Method PSNR ↑ SSIM ↑ F-Measure ↑ DRD ↓ CER ↓ WER ↓
Noisy input (aligned) 14.5045 ± 1.7828 0.8257 ± 0.0292 0.8118 ± 0.0592 1023.4413 ± 740.1513 0.1547 0.4454
CRP 15.4991 ± 1.3609 0.8414 ± 0.0239 0.8165 ± 0.0572 946.4848 ± 695.6484 0.1513 0.4329
U-Net baseline 25.0740 ± 1.8799 0.9436 ± 0.0290 0.8873 ± 0.0428 254.1193 ± 165.0406 0.1122 0.3814
U-Net + prior 28.3218 ± 2.3118 0.9841 ± 0.0079 0.9243 ± 0.0261 183.1854 ± 97.3021 0.1102 0.3557
DE-GAN baseline 20.2169 ± 0.7506 0.8587 ± 0.0260 0.7375 ± 0.0413 622.5367 ± 258.8305 0.3928 0.9353
Attention baseline 24.3767 ± 2.0705 0.9349 ± 0.0297 0.8747 ± 0.0448 314.5643 ± 221.4223 0.1391 0.4399
Hybrid proposed 26.4961 ± 1.7856 0.9607 ± 0.0138 0.9113 ± 0.0289 297.3505 ± 132.0764 0.1091 0.3495
Table 6. Comparison with baselines under a convergence-based criterion.
Table 6. Comparison with baselines under a convergence-based criterion.
Methods Epochs PSNR ↑ SSIM ↑ F-measure ↑ DRD ↓ CER ↓ WER ↓
Noisy input (aligned) - 14.5045 ± 1.782 0.8257 ± 0.029 0.8118 ± 0.059 1023.44 ± 740.151 0.1547 0.4454
CRP - 15.4991 ± 1.360 0.8414 ± 0.023 0.8165 ± 0.057 946.48 ± 695.648 0.1513 0.4329
U-Net baseline (ES) 66 25.2375 ± 1.947 0.9489 ± 0.026 0.8885 ± 0.041 195.80 ± 110.465 0.1123 0.3714
U-Net + prior (ES) 22 27.5052 ± 2.095 0.9802 ± 0.007 0.9054 ± 0.025 153.23 ± 93.556 0.1122 0.3424
DE-GAN baseline (ES) 120 21.6964 ± 1.011 0.8858 ± 0.027 0.7942 ± 0.032 508.59 ± 186.396 0.2746 0.7090
Attention baseline (ES) 43 23.0897 ± 2.172 0.9250 ± 0.030 0.8691 ± 0.043 307.32 ± 225.476 0.1466 0.4462
Hybrid proposed (ES) 58 26.5764 ± 1.822 0.9609 ± 0.013 0.9122 ± 0.028 256.46 ± 118.890 0.1072 0.3175
Table 7. Computational cost comparison between the different approaches.
Table 7. Computational cost comparison between the different approaches.
Model Params (M) ↓ FLOPs/MACs (G) ↓ Peak GPU Mem (GB) ↓ Train Time/Epoch (s) ↓ Total Train Time (min, 50 ep) ↓ Inference Latency/Slice (ms) ↓
CRP - - - - - 132.17 ± 9.21
U-Net baseline 7.762 27.288/13.644 1.465 ± 0.001 74.18 ± 0.48 61.82 ± 0.40 3.19 ± 0.29
U-Net + prior 7.763 27.326/13.663 1.469 ± 0.000 75.56 ± 1.34 62.97 ± 1.12 3.05 ± 0.07
DE-GAN baseline 1.810 0.428/0.214 1.341 ± 0.008 80.38 ± 1.62 66.99 ± 1.35 2.67 ± 0.12
Attention baseline 3.293 9.172/4.586 3.188 ± 0.019 91.14 ± 0.33 75.95 ± 0.28 20.61 ± 0.73
Hybrid proposed 7.763 27.326/13.663 1.494 ± 0.000 77.02 ± 0.69 64.18 ± 0.57 3.27 ± 0.11
Table 8. Ablation study of the proposed method on the test set.
Table 8. Ablation study of the proposed method on the test set.
Variante PSNR ↑ SSIM ↑ F-Measure ↑ DRD ↓ CER ↓ WER ↓
Hybrid full 26.4961 ± 1.7856 0.9607 ± 0.0138 0.9113 ± 0.0289 297.3505 ± 132.0764 0.1091 0.3495
w/o masked content loss 26.4931 ± 1.7564 0.9605 ± 0.0130 0.9171 ± 0.0280 292.4290 ± 111.9934 0.1142 0.3627
w/o template fusion 26.3505 ± 2.3779 0.9627 ± 0.0082 0.9107 ± 0.0266 261.0933 ± 90.4275 0.1124 0.3588
w/o template prior 24.2217 ± 1.5083 0.9438 ± 0.0162 0.8701 ± 0.0429 325.9923 ± 209.9575 0.1109 0.3705
Table 9. Ground-truth word coverage in real documents using different OCR engines.
Table 9. Ground-truth word coverage in real documents using different OCR engines.
OCR Engine Raw Data (%) Hybrid Data (%) Absolute Improvement (p.p.)
GLM OCR 73.22 77.37 +4.15
Amazon Textract 64.84 74.69 +9.85
Tesseract 11.84 29.89 +18.05
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

© 2026 MDPI (Basel, Switzerland) unless otherwise stated

Accessibility

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings