Image Processing: Recovery and restoration of information: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „= Image Recovery and Restoration = '''Image Restoration''' is a field of image processing that deals with recovering an original, sharp image from a degraded version. Unlike ''Image Enhancement'', which seeks to improve the visual appearance of an image subjectively (e.g., brightening a dark photo), Restoration is an '''objective''' approach. It attempts to reconstruct the original image by mathematically modeling the degradation and reversing it. __TOC…“ |
|||
| Zeile 133: | Zeile 133: | ||
fprintf('Restoration Quality (PSNR): %.2f dB\n', score); | fprintf('Restoration Quality (PSNR): %.2f dB\n', score); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Result == | |||
[[Datei:Restoration.png|center|800px|thumb|Image restoration result]] | |||
Aktuelle Version vom 3. Februar 2026, 11:53 Uhr
Image Recovery and Restoration
Image Restoration is a field of image processing that deals with recovering an original, sharp image from a degraded version. Unlike Image Enhancement, which seeks to improve the visual appearance of an image subjectively (e.g., brightening a dark photo), Restoration is an objective approach. It attempts to reconstruct the original image by mathematically modeling the degradation and reversing it.
The Mathematical Model of Degradation
To restore an image, we must first understand how it was damaged. In classic image processing, degradation is modeled as a linear process.
Let be the original image. The observed (degraded) image is produced by convolving the original image with a degradation function (often called the Point Spread Function or PSF), followed by the addition of noise .
Where:
- : The degraded image we have.
- : The original image we want to recover.
- : The Point Spread Function (PSF). This represents the blur (e.g., motion blur, lens defocus, atmospheric turbulence).
- : Additive noise (e.g., sensor noise, Gaussian noise).
The Solution: Deconvolution
Since the degradation involves convolution, the restoration process is often called Deconvolution.
Why is this difficult?
If there were no noise, we could theoretically convert the image to the frequency domain (using Fourier Transform), divide by the blur function, and convert back. This is called Inverse Filtering.
However, in the real world, images contain noise. At frequencies where the blur function has low values (near zero), simple division amplifies the noise term mathematically, resulting in a restoration typically unusable due to extreme noise artifacts.
The Classic Algorithm: The Wiener Filter
The Wiener Filter (Minimum Mean Square Error Filter) is the standard algorithm for restoration. It acknowledges the presence of noise. Instead of simply dividing by the blur, it performs a trade-off between deblurring and noise smoothing.
It minimizes the overall mean square error between the estimated image and the original image.
MATLAB Implementation Strategy
When solving this in MATLAB (specifically for Grader tasks), the workflow follows a strict logic: Model the Blur → Preprocess Edges → Deconvolve.
Key MATLAB Functions
fspecial: Creates the PSF (the model of the blur).edgetaper: Pre-processes the image to reduce "ringing" artifacts at the borders.deconvwnr: Applies the Wiener filter.deconvreg/deconvlucy: Alternative constrained least squares or iterative methods.
Detailed Code Logic
Below is a step-by-step breakdown of how to implement Image Restoration to solve a motion-blur problem.
Step 1: Define the Degradation (PSF)
First, you must determine (or be given) the nature of the blur.
- Motion Blur: Defined by length (pixels) and angle (degrees).
- Gaussian Blur: Defined by the standard deviation (sigma) and window size.
% Create a Point Spread Function (PSF)
% Example: A camera moved 21 pixels in a 11-degree direction
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
Step 2: Handle Boundary Effects (Edge Tapering)
Deconvolution uses Fourier transforms, which assume images are periodic (repeatable tiles). The edges of a photo usually do not match the opposite edges, causing "ringing" (ripples) in the restored image. edgetaper blurs the edges of the input image to minimize this.
% 'blurredImage' is the input image
taperedImage = edgetaper(blurredImage, PSF);
Step 3: Estimate Noise-to-Signal Ratio (NSR)
The Wiener filter requires an estimation of the Noise-to-Signal Power Ratio.
- If , the Wiener filter becomes an ideal Inverse Filter (works only if zero noise).
- In Grader tasks, this is often a tunable parameter. If the variance of noise is known, .
% Estimation of noise power (often estimated experimentally)
estimated_nsr = 0.001;
Step 4: Apply Deconvolution
Pass the tapered image, the modeled PSF, and the NSR into the function.
restoredImage = deconvwnr(taperedImage, PSF, estimated_nsr);
Full Algorithm Example (Script)
Here is a complete, standardized script suitable for a MATLAB Grader problem.
% --- IMAGE RESTORATION TASK ---
% 1. Read the input image (Ground Truth)
original = imread('cameraman.tif');
% 2. Simulate Degradation
PSF_real = fspecial('motion', 21, 11);
blurred = imfilter(original, PSF_real, 'conv', 'circular');
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', noise_mean, noise_var);
% A. Model the PSF
estimated_len = 21;
estimated_theta = 11;
est_PSF = fspecial('motion', estimated_len, estimated_theta);
% B. Estimate Noise to Signal Ratio
% A lower value assumes less noise (sharper but grainier)
% A higher value assumes more noise (smoother but blurrier)
estimated_nsr = noise_var / var(im2double(blurred_noisy(:)));
% C. Taper Edges
% This reduces the Gibbs phenomenon (ringing) at image borders
input_ready = edgetaper(blurred_noisy, est_PSF);
% D. Restore Image using Wiener Deconvolution
restored_img = deconvwnr(input_ready, est_PSF, estimated_nsr);
% ---------------------------------------------------------
% VISUALIZATION & METRICS
% ---------------------------------------------------------
figure;
subplot(1,3,1); imshow(original); title('Original');
subplot(1,3,2); imshow(blurred_noisy); title('Blurred & Noisy');
subplot(1,3,3); imshow(restored_img); title('Restored (Wiener)');
% Metric: Peak Signal-to-Noise Ratio (Higher is better)
score = psnr(restored_img, original);
fprintf('Restoration Quality (PSNR): %.2f dB\n', score);
Result
