A Multi-Stage Image Restoration Pipeline through Illumination Enhancement, Environmental Degradation Removal, and Exemplar-Based Inpainting ()
1. Introduction
With the proliferation of autonomous camera systems and edge vision devices, digital image processing techniques have become foundational assets in video monitoring [1], smart factory automation [2], traffic control tracking [3], and earth observatory remote sensing [4]. Despite these technical expansions, hardware sensors are highly vulnerable to challenging, field-deployed conditions. Images recorded inside dim structures, at night, or under adverse weather elements are consistently marred by low visibility, heavy grain, severe color cast, and loss of structural definition [5]. If left uncorrected, these primary fidelity losses accumulate during subsequent image compression, server storage, and channel transmission routines [6], making accurate pattern recognition or forensic interpretation highly difficult.
Defining a precise threshold for low-light degradation remains an open problem due to varying lighting geometries and device responses [7]. Industrial vendors often classify low visibility into practical operation layers such as moonlight, starlight, or deep shadow [8], which reflect varying combinations of narrow grayscale dynamic range, sensor noise spikes, and prominent color deviations [9]. Over the years, image fusion strategies have emerged to combat low-light constraints by blending features across distinct exposures or color planes [10]. Relevant methodologies include multi-exposure structural decomposition [11], non-subsampled shearlet transform distributions [12], and complementary gamma function blends [13], all targeting regional details hidden in heavy shadows. Alongside these, histogram manipulation remains a classic standard for contrast adjustment [14], evolving from simple Histogram Equalization (HE) to more stable variants like Brightness Preserving Bi-Histogram Equalization (BBHE) [15] and Adaptive Histogram Equalization (AHE) [16], which aim to manage overexposure artifacts. Furthermore, physical light modeling via the Retinex theory or the Absorption Light Scattering Model (ALSM) [17] preserves realistic scene illumination by tracking natural transmittance vectors across varying medium depth planes. However, adjusting illumination is only a partial solution when real-world scenes also display noise and weather interference. Statistical and partial differential equation (PDE) filters traditionally suppress image noise based on spatial priors [18], alongside transform-domain paradigms like sparse 3D collaborative filtering [19]. Modern architectures, such as the Real Image Denoising Network (RIDNet) [20], utilize residual channel-attention mechanisms to isolate noise envelopes without smoothing underlying textures. Similarly, removing atmospheric haze and rain streaks is a core requirement for clean visual feature tracking [21], [22]. While standard scattering equations frequently fail under dense fog conditions [23], the Deep Residual Haze Network (DRHNet) [24] addresses extreme cases by tracking negative residual maps to unmask background radiance layers.
One of the major issues of image enhancement in real-field applications is resolving structural occlusions, object clutter, or localized pixel dropouts. Image inpainting serves to reconstruct these missing geographic layers using peripheral pattern distributions [25]-[27], providing useful utility in old photo archiving, asset preservation, and media editing. Classic exemplar methods copy patch textures from clear zones [28], though they frequently cause blurry boundaries when facing complex edges. To alleviate these structural artifacts, the Adaptive Two-Round Search (ATRS) framework [29] applies secondary matching evaluations using patch differences to reduce structural drift and improve restoration layout consistency.
While the individual image processing components referenced above have proven useful within their targeted tasks, real-world scenes rarely present single, isolated defects. Applying these algorithms independently or in an uncontrolled sequence frequently introduces compounding errors, for instance, amplifying hidden camera noise during a contrast-stretching step or washing out structural textures during aggressive weather filtering. In this work, we propose a unified, decision-driven restoration architecture that connects illumination modeling, conditional deep-learning cleanup, and exemplar inpainting into a self-correcting system. By analyzing the degradation traits before processing, our system avoids redundant operations and ensures each layer enhances the structural fidelity of the next.
The core contributions of this study are structured as follows:
We present an integrated, multi-stage restoration architecture that resolves contrast deficiencies, multi-weather noise, and pixel loss within a single pipeline.
We establish a balanced contrast correction module, combining complementary gamma functions, adaptive histogram manipulation, and physics-based light scattering models to uncover shadow details while preserving natural color limits.
We integrate a conditional network activation strategy using statistical variance metrics to selectively deploy denoising, dehazing, or deraining modules, thereby avoiding performance loss on clean channels.
We demonstrate an asset repair framework using advanced exemplar search logic to smoothly eliminate unwanted objects and correct localized color drift.
The remainder of this paper is organized as follows: Section 2 presents the structural methodology and workflow of the proposed framework, along with the corresponding algorithm. Section 3 discusses the results using both qualitative and quantitative benchmark metrics, and Section 4 summarizes our conclusions and future avenues of research.
2. Materials and Methodology
Our proposed method is a multi-stage pipeline designed to sequentially address different types of image degradation. The initial step involves preparing the image for processing. This includes normalizing pixel values to a standard range (e.g., [0, 1]) and converting the image to a suitable color space if necessary. Following this, a degradation detection module analyzes the image to determine which specific restoration steps are required.
Noise Detection: The presence of noise is determined by analyzing the statistical variance across small, flat image patches. If the average variance exceeds a predefined threshold, the denoising module is activated.
Haze/Rain Detection: A lightweight rule-based classifier is employed to identify the presence of haze or rain degradations. The classifier analyzes image characteristics such as contrast attenuation, color distortion, and oriented linear structures that are commonly associated with atmospheric haze and rain streaks. Based on these features, empirically determined thresholds are used to activate the corresponding restoration module. Images exhibiting haze-related characteristics are processed using the DRHNet dehazing model, while images containing rain artifacts are directed to the deraining branch. This conditional strategy helps avoid unnecessary processing and preserves image quality when such degradations are absent.
This conditional approach prevents the application of unnecessary and potentially harmful processing to clean images. Figure 1 presents the overall framework of the proposed methodology.
Figure 1. The proposed integrated image enhancement framework, showing the sequential and conditional processing stages.
2.1. Contrast Enhancement and Illumination Correction
This stage begins with contrast enhancement, where image visibility and color fidelity are improved through a three-step sequential process. The output of each step serves as the input for the next, creating a cumulative enhancement effect. The sequence of PCGF, AHE, ALSM, RIDNet/DRHNet, and ATRS was selected to progressively improve image visibility before restoration and repair. Early illumination enhancement exposes hidden structural details and improves scene visibility, while the subsequent restoration modules suppress degradation artifacts such as noise, haze, and rain. Finally, the inpainting stage is applied after restoration to ensure that missing regions are reconstructed using enhanced and artifact-reduced contextual information.
2.1.1. Gamma Correction
The process begins with Gamma Correction, which non-linearly adjusts the global luminance of the image [29]. For dehazing, it is defined as
(1)
The technique involves inverting the input picture
to the value
, applying gamma correction, then reversing the result back to get the final image
. One may get inhomogeneous results by applying gamma correction to hazy images, or one can get consistent results by applying a gamma correction previously. Dong et al. [30] initially suggest the inverse technique, which is subsequently applied for low-light image enhancement [7]. Following the idea presented in Equation (1), Li et al. [13] define two new functions:
(2)
(3)
Then combine (1) and (3) to form an inherent whole, resulting in the following pair of complementary gamma functions [13]:
(4)
A simple blending technique allows us to obtain the optimal enhanced image using the Pair of Complementary Gamma Functions (PCGF).
(5)
where
is the mapped image from the original low-light picture as defined by (4), and the weighting factor is derived as follows:
(6)
where,
is the mean value of the HSV transformation of the image
. Figure 2 shows the visual effect after applying the PCGF.
Figure 2. (a) Original low-light images; (b) After applying PCGF.
It is clear that PCGF is a powerful tool for enhancing images with limited lighting. It increases the overall visibility of dark images and improves the finer details by compressing the light areas and expanding the dark ones. Unfortunately, the local contrast and particulars still need to be further improved. Li et al. [13] provide a straightforward fusion technique to enhance quality further. Image fusion is often used for multi-focus image processing [12], low-light image enhancement [10], and underwater image enhancement [31].
The quality of an image is greatly affected by the amount of light it receives. So, using (5) and (6), we choose an exposedness weight map to generate the areas that will be used to assess the degree of exposure, which is represented as a Gaussian-modeled distance from the average normalized value of 0.5, as shown below [10], [32]:
(7)
where,
stands for the
image in the input and the coordinates of the
pixel
. Pixels that are closer to 0.5 are given higher values. Underexposed and overexposed pixels receive low values from this weight map, while properly exposed pixels receive high values. As a result, it produces an unbiased assignment. Finally, the following provides the normalized weight maps for fusion:
(8)
Using the pyramid fusing technique suggested by Burt and Adelson [33], we can eliminate the halos and artifacts that emerge from using a straightforward blending strategy for fusion. The enhanced image is finally provided by:
(9)
where the number of pyramid layers is denoted by
,
is the up-sampling operator with
,
and
stand for Gaussian and Laplace operators. With little computational load, it may provide excellent performance [13], as shown in Figure 3.
Figure 3. (a) Original low-light images; (b) After applying PCGF by Fusion.
2.1.2. Histogram Equalization
Following gamma correction, we apply an Adaptive Histogram Equalization (AHE) method [16] to improve local contrast without amplifying noise significantly. To improve visual contrast, the Adaptive Histogram Equalization (AHE) method begins by extending a color channel in the RGB color space and then converting the input RGB color space into the HSI color space. The intensity channel is then given a nonlinear adaptive gamma correction using a weighted histogram distribution method to improve the image’s details. The enhanced image is then returned to RGB for optimal display, as shown in Figure 4.
Figure 4. Framework for the histogram equalization method [16].
Consider the following input color image:
, where
,
, and
are the red, green, and blue color spaces, and
are the pixel coordinates. In order to correct color distortion from an unfavorable capturing situation, the input images are first stretched on each color channel. To provide the observer with the optimal set of color information, a magnitude or channel stretching mechanism expands the input color channels into their respective tolerated maximum ranges [16]. The color value for stretched red is stated as,
(10)
The same distortion is applied to the green and blue channels. Stretching enhances the image’s color richness and acts as a pre-processing step for contrast improvement. After magnitude stretching, all color signals are transformed into the hue-saturation-intensity (HSI) space. The system processes the I-signal, which represents the intensity or brightness. The H-channel and S-channel components are not altered since they have no direct effect on an image’s human-perceived contrast [16]. The transformed RGB input image is converted into HSI color space according to Equation (11).
(11)
where,
stands for the RGB-to-HSI color conversion procedure. The picture can be improved by keeping the H and S channel components but enhancing the intensity channel. The intensity channel in the HSI space is denoted as [16],
(12)
The main goal of this step of enhancement is to improve visual contrast while retaining as much information content as possible near the original image. The converted pixel intensity is determined as follows [16]:
(13a)
For integer-valued output in [0, 255], Equation 13(a) is applied as:
(13b)
Figure 5. Contrast Enhancement results and their histograms. (a) Original image; (b) HE-ed image; (c) Gamma-corrected image; and (d) AHE-ed image.
Figure 6. Histogram equalization results, (a) Original images and (b) AHE-processed images.
Figure 5 shows the result after contrast enhancement with its histogram. To produce the improved image, combine the processed intensity image
with the hue space and then convert the image back to the RGB color space [16] as shown in Figure 6. It is stated as,
13(c)
2.1.3. Physical Illumination Modeling
The final step in this module is the application of the Absorption Light Scattering Model (ALSM) [17]. This model, an extension of the atmospheric scattering model, realistically illuminates shadowed regions by modeling light absorption. It recovers the scene radiance for each pixel, revealing hidden details in low-light areas that may not have been fully corrected by the previous steps.
McCartney, Narasimhan, and Nayar suggested a monochromatic ASM [34] that adequately describes the effects of particle scattering on visible light imaging based on the attenuation and ambient light model. Because sunlight may pass through the atmosphere and illuminate objects, atmospheric light is seldom the primary source of lighting [23]. Assuming a uniform spatial distribution of light, we may write ASM as follows:
(14)
where,
is the observed image’s 3D matrix, and
is the scene’s reflection. A pixel’s location
is represented by the 2D vector
. A 3D RGB vector at pixel
is denoted as
. The color channel
’s 2D matrix is denoted by the symbol
. The color channel
at pixel
is represented by the scalar
. The coordinates
denote a 3D vector at the given pixel
. The scalar representation of the color channel
at pixel
is denoted by
. Each point
has a medium transmittance, denoted by the scalar
, which is in the interval [0, 1].
and
stand for the overall ambient light of the scene, provided by the sun. It is often believed that
and
, both 3D matrices, are spatially constant; that is, they are identical matrices for every channel
in
.
Following Equation (14), after completing monotonic analysis and utilizing the minimal channel constraint, ALSM obtains the enhancement result for each pixel. Finally, the scene radiance at pixel
of the original low-light image is given by:
(15)
where,
is the color channel
’s 2D matrix, a scalar of the color channel
at a pixel
is represented by
and
, the medium transmittance of any point
is given by
, and
is the lowest limit of
for presenting this term as indivisible. A common fixed value for
is 0.1.
A physical finding of the imaging process of the absorption light scattering image is just one of the benefits of ALSM; the method also reproduces the hidden details of low-light images and provides new characteristics for analysis [17]. Figure 7 depicts the result of using this information to determine the brightest pixel value.
2.2. Environmental Cleanup
Tasks such as denoising, dehazing, and deraining provide important benchmarks for assessing image priors and evaluating visual quality.
Figure 7. Physical Illumination Modeling (a) Original Images and (b) ALSM results with T = 6, where T denotes the number of pyramid decomposition levels used in the multi-scale fusion step.
2.2.1. Denoising with RIDNet
If noise is detected in the preprocessing stage, we employ the Real Image Denoising Network (RIDNet) [20], a robust CNN-based model. Its residual-on-residual architecture with Enhancement Attention Modules (EAMs) allows it to effectively remove complex, real-world noise while preserving fine textures and edges.
The RIDNet model comprises three main modules: feature extraction, residual-on-residual feature learning, and image reconstruction, as illustrated in Figure 8.
Figure 8. Architecture of the CNN-based RIDNet model [20].
In this architecture, the convolutional layers with a kernel size of 1×1 are represented, while the varying green shades indicate different dilation rates in the convolutional layers. The second column provides a detailed view of the structure of each Enhancement Attention Module (EAM), as illustrated in Figure 9.
Figure 9. Feature attention mechanism [20].
Figure 9 illustrates the feature attention mechanism that focuses on the most relevant characteristics. In this process,
denotes the global pooling layer,
and
represent the channel reduction and upsampling operators, respectively, and α is the sigmoid activation function. The approach incorporates four Enhancement Attention Modules (EAMs). Except for the last convolutional layer in the improved residual block, which uses a 1 × 1 kernel, all convolutional layers utilize a 3 × 3 kernel size, with zero padding applied to maintain feature map dimensions. Each convolutional layer, except during feature attention downsampling, contains 64 channels. These channels are reduced by a factor of 16, resulting in four feature maps. Depending on the input, the final convolutional layer outputs either one or three feature maps. The model executes in approximately 0.2 seconds for a 512 × 512 pixel image. The results are demonstrated in Figure 10.
![]()
Figure 10. Image denoising (a) Noisy images; (b) RIDNet images.
2.2.2. Dehazing & Deraining with DRHNet
If haze or rain is detected, we utilize the Deep Residual Haze Network (DRHNet) [35]. This end-to-end framework learns to predict a negative residual map (the haze or rain layer), which is then subtracted from the input image to restore a clear version. Its design ensures strong performance on both tasks and prevents quality degradation when applied to clear images.
Figure 11 illustrates the three components of the Deep Residual Haze Network (DRHNet): the context-aware encoder (left), the transformation module (center), and the haze decoder (right). By reformulating its layers to learn residual functions, DRHNet effectively captures the differences between clear and hazy images, which also helps to reduce computational complexity [36].
Figure 11. The framework of the DRHNet model [35].
The dehazed result that is produced by DRHNet can be obtained in the following manner:
(16)
where J denotes the dehazed image, DRHNet(I) is the output of the DRHNet model given the hazy input image I. The model employs a context-aware feature extraction module to encode contextual information into feature maps. These maps are then decoded by the haze decoder to estimate the residual map. Since the residual between hazy and haze-free images is mostly negative, DRHNet generates a negative residual map by inverting each pixel value in the residual map. The clear image is recovered by subtracting the hazy input from this negative residual. Similarly, DRHNet directly estimates the residual between clear and rainy images using the same formulation. Sample dehazing and deraining results are shown in Figure 12. Wang et al. [35] demonstrated that DRHNet achieves strong deraining performance on benchmark datasets. Moreover, applying DRHNet to haze-free images has minimal adverse effects and does not degrade image quality.
![]()
Figure 12. Image dehazing and deraining (a) Hazy image; (b) DRHNet result of Hazy image; (c) Rainy image; and (d) DRHNet result of rainy image.
2.3. Image Inpainting
The final stage addresses object removal or the repair of damaged regions. We use the Adaptive Two-Round Search (ATRS) strategy [29], an exemplar-based method. It improves upon traditional techniques by first finding a best-match patch using the Sum of Squared Differences (SSD), and then, if a potential mismatch is detected, initiating a second search round that also considers the color difference (DBP), ensuring better structural and textural consistency.
2.3.1. Priority Computation
Here we follow [28] to calculate the patch priority and decide on the filling order. For each patch
centered at the point
that has a patch priority
, it is denoted as:
(17)
where,
and
represent the confidence term and the data term, respectively. After determining the most crucial target patch, it searches the source area for the exemplar patch that is most similar to the target patch based on the matching rule.
2.3.2. Definition of DBP
The Sum of Squared Differences (SSD) is used to determine how similar a target patch is to an exemplar patch in the standard exemplar-based inpainting process. According to the definition [28],
(18)
where
is the exemplar patch, and
is the target patch.
is the binary mask, and it utilizes one to designate which pixels must be filled. Differences between Patches (DBP) are defined as follows, using Equation (18).
(19)
where the first item determines the average value of pixels in the target patch, the second determines the average value of pixels utilized to fill the exemplar patch.
2.3.3. Adaptive Two-Round Search (ATRS)
To find the mismatch error, two adaptive thresholds,
and
, are given to compare it with SSD and DBP. It uses a straightforward and effective way to calculate the thresholds. SSD and DBP are first calculated for all matching patches, yielding ssd_data and dbp_data, respectively, as two arrays. Next, we’ll apply an ascending sort to each array, and then we’ll have ssd_data_sort and dbp_data_sort. After doing that, we can get the values for B and Y by doing the following [29]:
(20)
where,
and
are the coefficients of proportionality, the number of similar patches is denoted by
. The two-round search approach is executed adaptively if there is a discrepancy between the exemplar and target patches. It uses a two-round research approach to rediscover the exemplar patch that resembles the original. The new matching rule that incorporates SSD and DBP is denoted as follows [29]:
(21)
where,
is a multiplier that makes the SSD and DBP the same order of magnitude apart, it is defined as
.
2.4. Proposed Framework Algorithm
In Algorithm 1, the complete workflow of our proposed framework is summarized in the pseudocode. The restoration modules are conditionally activated based on the degradation analysis performed during preprocessing. When multiple degradations are detected simultaneously, the denoising stage (RIDNet) is executed before the dehazing/deraining stage (DRHNet). This ordering is intended to suppress noise prior to atmospheric restoration, thereby reducing the possibility of noise amplification and improving the stability of the subsequent restoration process.
Algorithm 1. Proposed image enhancement pipeline.
Input: Degraded Image I in, optional Inpainting Mask M Output: Enhanced Image Iout 1: // Preprocessing 2: Inorm = Normalize(Iin) 3: // Degradation Detection 4: has_noise = DetectNoise(Inorm) 5: has_haze_rain = DetectHazeRain(Inorm) 6: // Stage 1: Contrast Enhancement 7: Igamma = GammaCorrection_Fusion(Inorm) 8: Iahe = AHE(Igamma) 9: Icontrast = ALSM(Iahe) 10: // Stage 2: Conditional Restoration 11: Irestored = Icontrast 12: if has_noise then 13: Irestored = RIDNet(Irestored) 14: end if 15: if has_haze_rain then 16: Irestored = DRHNet(Irestored) 17: end if 18: // Stage 3: Inpainting 19: if InpaintingMask M is provided then 20: Iout = ATRS(Irestored, M) 21: else 22: Iout = Irestored 23: end if 24: return Iout |
3. Result Analysis
To validate our integrated framework, we conducted both qualitative and quantitative evaluations. We demonstrate the step-by-step enhancement process on a single, complex image and compare our final results with several well-known, state-of-the-art methods using standard Image Quality Assessment (IQA) metrics.
3.1. Qualitative Analysis: Integrated Enhancement Process
Figure 13 illustrates the effectiveness of our connected pipeline on a single input image suffering from low light, noise, and containing an object for removal. The original image (a) is dark and lacks detail. After applying our contrast enhancement module (b), the brightness and local contrast are significantly improved, revealing details in the shadows. The subsequent conditional restoration step (c) effectively removes noise and atmospheric haze, resulting in a much cleaner image. Finally, the inpainting stage (d) seamlessly removes the marked object, producing a visually coherent and high-quality final image. This step-by-step visualization confirms that the components work synergistically, with each stage building upon the previous one to achieve a comprehensive restoration.
![]()
Figure 13. Demonstration of the integrated pipeline. (a) Original degraded image; (b) After Stage 1: Contrast Enhancement; (c) After Stage 2: Conditional Denoising & Dehazing; (d) Final result after Stage 3: Inpainting.
3.2. Quantitative Comparison
We compared our proposed method against several leading individual algorithms: LIME [7] for low-light enhancement, FFA-Net [37] for dehazing, and Restormer [38] for general restoration. We used the Peak Signal-to-Noise Ratio (PSNR) and Structural Similarity Index (SSIM) as our quantitative metrics, where higher values indicate better performance. The results, averaged over a test set of 50 benchmark images from the LOL dataset [7] (low-light), RESIDE-β (haze), and Rain100H (rain) with synthetic degradations applied to clean reference images to enable full-reference PSNR/SSIM evaluation, are presented in Table 1. Our proposed approach demonstrates competitive performance compared with the selected baseline methods and the individual methods, demonstrating the benefit of a holistic pipeline that addresses multiple degradations simultaneously.
Table 1. Quantitative comparison with state-of-the-art methods.
Method |
PSNR (dB) |
SSIM |
Primary Function |
LIME [7] |
18.73 |
0.79 |
Low-Light Enhancement |
FFA-Net [37] |
21.05 |
0.84 |
Dehazing |
Restormer [38] |
24.51 |
0.89 |
Denoising/Restoration |
Proposed Framework Algorithm |
26.84 |
0.93 |
Holistic Enhancement |
3.3. Inpainting Comparison
For the inpainting task, we compared our ATRS-based module with a modern deep learning approach. In Figure 14, we show the original image (a) with a region marked for removal (b). The result from a Contextual Attention GAN [26] (c), based on two discrimination networks, provides a plausible restoration but introduces some textural artifacts. Our proposed Integrated Algorithm (d) demonstrates visually improved restoration quality in the presented example in this case, producing a more natural and structurally consistent result by effectively leveraging information from the surrounding pixels.
Figure 14. Inpainting comparison. (a) Original image; (b) Target removal region (marked in gray); (c) Result using contextual attention GAN [26] based on two-discrimination networks; and (d) Result using our proposed Integrated Algorithm.
4. Conclusions
This study has presented a unified and decision-driven restoration architecture designed to resolve complex, overlapping image degradations. By connecting complementary illumination models, deep network weather filters, and structural exemplar inpainting, the framework handles low contrast, sensor noise, atmospheric haze, and foreground blockages within a single pipeline. Both empirical and numerical benchmarks confirm that this unified approach yields cleaner edges, more authentic color retention, and better artifact containment than specialized, single-purpose algorithms applied in isolation.
Future investigations will explore expanding this processing pipeline into temporal video processing fields. This transition requires optimizing execution times for streaming frames and establishing inter-frame constraints to avoid temporal flicker. Furthermore, we plan to replace the rule-based threshold filters in our detection module with an end-to-end learnable network, further improving the system’s adaptability across varied real-world scenarios.
Code Availability
The implementation used in this study was developed for research purposes. Source code and supplementary materials are available from the corresponding author upon reasonable request.
Data Availability
The datasets used in this study were obtained from publicly available benchmark image datasets and synthetically generated degraded samples. Additional information regarding the data used and the evaluation protocol is available from the corresponding author upon reasonable request.