13.2 Image Enhancement and Compensation for Nonlinear Changes——DWT-Based Image Adaptive Enhancement (matlab program)

1. Brief description

      

In practical applications, image enhancement is sometimes required to improve the visual effect of the image. In the treatment of this problem, according to the color, it can be divided into grayscale image enhancement and color image enhancement. According to the scope classification, it can be divided into air domain processing and frequency domain processing.

Image spatial domain processing methods usually include grayscale transformation, histogram equalization, image smoothing and sharpening. Frequency domain processing has DFT transform, and image enhancement is carried out by filtering method. The existing methods have poor adaptive effects. Here we propose a fuzzy adaptive method——image adaptive enhancement based on DWT.

2. Code

 

clear all;
B = double(imread('lena.bmp'));            
A = B(:,:,1);
s = size(A); s1 = s(1,1); s2 = s(1,2);
figure,imshow(A/256);

%% Perform wavelet transform on image A
h = sqrt(2)*[-1/8,1/4,3/4,1/4,-1/8]; 
g = sqrt(2)*[0,0 ,-1/4,1/2,-1/4];

DEPTH = 4; % The number of layers of wavelet decomposition
b = 0.2; c = 5; 
a = 1/(1/(1+exp(c*(b-1)))-1/(1+exp(c*( 1+b))));
k = 1; ALL = A;
while (k <= DEPTH)
    [ALL,ALH,AHL,AHH] = MyDWT2(ALL,h,g);

    M = max(max(ALH)); ALH = ALH/M;
    ALH = a*(1./(1+exp(c*(b-ALH)))-1./(1+exp(c*(b+ALH))));
    ALH = M*ALH;
    
    M = max(max(AHL)); AHL = AHL/M;
    AHL = a*(1./(1+exp(c*(b-AHL)))-1./(1+exp(c*(b+AHL))));
    AHL = M*AHL;   
    
    M = max(max(AHH)); AHH = AHH/M;
    AHH = a*(1./(1+exp(c*(b-AHH)))-1./(1+exp(c*(b+AHH))));
    AHH = M*AHH;
    
    s1 = s1/2; s2 = s2/2;
    B(1:s1,1:s2) = ALL; 
    B(1:s1,s2+1:2*s2) = ALH;
    B(s1+1:2*s1,1:s2) = AHL; B(s1+1:2*s1,s2+1:2*s2) = AHH;
    
    ALH = zeros(s1,s2);
    AHL = zeros(s1,s2);AHH = zeros(s1,s2);
    
    k = k+1;
end

h1 = sqrt(2)*[1/4,1/2,1/4];
g1 = sqrt(2)*[-1/8,-1/4,3/4,-1/4,-1/8,0,0];
k = k-1;
while (k >= 1)
    if ( k==DEPTH )
        ALL = B(1:s1,1:s2);
    end
    ALH = B(1:s1,s2+1:2*s2); AHL = B(s1+1:2*s1,1:s2); AHH = B(s1+1:2*s1,s2+1:2*s2);
    ALL = MyDWT2(ALL,ALH,AHL,AHH,h1,g1);
    s1 = s1*2; s2 = s2*2;
    k = k-1;
end

A0=ALL;
figure,imshow(A0/256);
 

 

 

 

Guess you like

Origin blog.csdn.net/m0_57943157/article/details/131524411