A list,

Principle of wavelet transform

Wavelet transform is a time-scale (time-frequency) signal analysis method, a time-frequency localization analysis method in which the size of the window is fixed and the shape of the window can be changed, and the time window and frequency window can be changed. It is characterized by multi-resolution Analysis and has the ability to characterize local signal characteristics in both time and frequency domains.

Wavelet analysis method has high frequency resolution and low time resolution in the low frequency part, and high time partition rate and low frequency partition rate in the high frequency part, so it is known as “mathematical microscope”. It is this characteristic that makes the wavelet transform adaptive to the signal.

Wavelet analysis is as a harmonic analysis for half a century in the field of the mathematical crystallization, has been widely used in signal processing, image processing, quantum field theory, seismic exploration, speech recognition and synthesis, music, radar, CT imaging, color copies, fluid turbulence, object recognition, machine vision, mechanical fault diagnosis and monitoring, fractal and digital TV and other areas of science and technology.

In principle, wherever Fourier analysis has traditionally been used, wavelet analysis can be replaced. The advantage of wavelet analysis over Fourier transform is that it has good localization properties both in time domain and frequency domain.



In this way, the wavelet transform is regulative to the sampling step size of different frequencies in time domain: at low frequency, the wavelet transform has lower time resolution and higher frequency split rate; At high frequency, the temporal resolution of wavelet transform is high, but the rate-like resolution is low. This is consistent with the low frequency signal changes slowly and high frequency signal changes rapidly.

That’s where it’s superior to the classical Fourier transform and the STFT.

Ii. Source code

clear  all
close all
clc;
%%
I = imread('1.png');
% I = double(rgb2gray(I));
% I = im2double(I);
[WS,map,alpha] = imread('the watermark 01. PNG'); % Read watermark image W=double(255-alpha); %alpha is opacity. This graph is opaque alpha=0
[mw,nw]=size(W);
W=logical(W);
figure,subplot(121),imshow(I); title('Carrier image')
subplot(122),imshow(W); title('Watermarked image')
%%
ntimes=20; rngseed=59433; Iw = (setdwtwatermark(I,W,ntimes,rngseed)); % The peak signal-to-noise ratio of watermark image mn= Numel (I); Imax=max(I(:)); % psnr=10*log10(mn*double(Imax)^2/sum((im2double(I(:))-im2double(Iw(:))).^2)); peaksnr=psnr(im2uint8(Iw),I); Wg= getDWtwaterMark (Iw,W,ntimes, rNGSeed); nc=sum(Wg(:).*W(:))/sqrt(sum(Wg(:).^2)) /sqrt(sum(W(:).^2));
figure,subplot(121),imshow(Iw); title('Carrier image embedded with watermark')
subplot(122),imshow(Wg),title(['Watermark extracted from carrier image, NC=',num2str(nc)]); %% watermark attack experimentfunction dwtwatermarkattack(action,Iw,W,ntimes,rngseed)
%action; Watermark attack type %Iw: embedded watermark image %W: original watermark, used to calculate correlation %ntimes, rNGseed: watermark algorithm secret key % simulated watermark attackswitch lower(action)
    case 'filter'
        Ia=imfilter(Iw,ones(3) /9);
    case 'gaussian noise'
        Ia=imnoise(Iw,'gaussian');
    case 'resize'
        Ia=imresize(Iw,0.5);
        Ia=imresize(Ia,2);
    case 'noise'
        Ia=imnoise(Iw,'salt & pepper'.0.01);
    case 'crop'
        Ia=Iw;
        Ia(50:400.50:400,:)=randn();
    case 'rotate'
        Ia=imrotate(Iw,45.'nearest'.'crop');
        Ia=imrotate(Ia,- 45.'nearest'.'crop');
    case 'motion filter'% Motion blur PSF = fSpecial ('motion'.20.15);
        Ia = imfilter(Iw,PSF,'conv'.'circular');
    case 'gaussian filter'% Gaussian blur G = fSpecial ('gaussian'[5 5].2);
        Ia = imfilter(Iw,G,'same'); End unction Iw =setdwtwatermark(I,W,ntimes,rngseed) %W watermark image, and length and width of the same %ntimes: secret key1, Arnold scramble times %rngseed: secret key2, random number seed %Iw: add watermark after the image type=class(I); % I=double(I);
% IR = I(:,:,1);  IG = I(:,:,2);  IB =( I(:,:,3));
% I=IB;
IHSV=rgb2hsv(I);
IH=IHSV(:,:,1); IS=IHSV(:,:,2); IV=IHSV(:,:,3);
I=IV*255;
[mI,nI]=size(I);
[mW,nW]=size(W);
if mW~=nW
    error('SETDWTWATERMARK:ARNOLD'.'ARNOLD scrambling requires that the length and width of the watermark image must be equal! '(ca1, CH1, CV1, CD1) = DWT2 (I,'haar');
[ca2,ch2,cv2,cd2]=dwt2(ca1,'haar'); %% % Scramble the watermark Wa=W; H=[1.1;1.2]^ntimes; 
for i=1:nW
    for j=1:nW
        idx=mod(H*[i- 1; j- 1],nW)+1;
        Wa(idx(1),idx(2))=W(i,j); Cd2w = CD2; rng(rngseed); idx=randperm(numel(cd2),numel(Wa)); % randomly shuffles a sequence of numbersfor i=1:numel(Wa)
    c=cd2(idx(i));
    z=mod(c,nW);
    if Wa(i)
        if z<nW/4
            f=c-nW/4-z;
        else
            f=c+nW*3/4-z;
        end
    else 
        if z<nW*3/4
            f=c+nW/4-z;
        else
            f=c+nW*5/4-z;
        end
    end
    cd2w(idx(i))=f;
end
Copy the code

3. Operation results



















Fourth, note

Version: 2014 a