We have such a grayscale image 64*64
We can define 4096 bases, each of which is 0 and the other is 1. In this case, if we transmit an image, it is equivalent to transmitting the original data.
If the transfer is half done, the network is broken.
So we get
We can calculate the gap between the original image and the image.
Error = I-I _approx;
Distance = SQRT (sum (error. * error )))
Distance =
713.5559
If we use Haar
function h = haar(N) % Assume N is power of 2 h = zeros(N,N); h(1,1:N) = ones(1,N)/sqrt(N); for k = 1:N-1 p = fix(log(k)/log(2)); q = k-(2^p); k1 = 2^p; t1 = N/k1; k2 = 2^(p+1); t2 = N/k2; for i=1:t2 h(k+1,i+q*t1) = (2^(p/2))/sqrt(N); h(k+1,i+q*t1+t2) = -(2^(p/2))/sqrt(N); end end
Then, let's take a look at what we can restore with only half of the images, which can use image compression (PCA dimensionality reduction)
clear allclose allclc% Load imageI = double(imread(‘camera.jpg‘));% Arrange image in column vectorI = I(:);% Generate Haar basis vector (rows of H)H = haar(4096);% Project image on the new basisI_haar = H*I;% Remove the second half of the coefficientI_haar(2049:4096) = 0;% Recover the image by inverting change of basisI_haar = H‘*I_haar;% Rearrange pixels of the imageI_haar = reshape(I_haar, 64, 64);% Display imagefigureimshow(I_haar,[]);
The effect can also be
Error = I-I _haar;
Distance = SQRT (sum (error. * error )))
Distance =
350.6765
The Haar base is an orthogonal basis.
How can we change a normal base into an orthogonal basis?
Lagermu-Schmidt in linear algebra can be orthogonal.
function E=gs_orthonormalization(V)% V is a matrix where each column contains the vectors spanning the space of which we want to compute the orthonormal base% E is a matrix where each column contains an ortho-normal vector of the base of the space[numberLines,numberColumns]=size(V);% U is a matrix containing the orthogonal vectors (non normalized)U=zeros(numberLines,numberColumns);for indexColumn=1:numberColumns U(:,indexColumn)=V(:,indexColumn); for index=1:(indexColumn-1) R(index,indexColumn) =U(:,index)‘*V(:,indexColumn); U(:,indexColumn)=U(:,indexColumn)-R(index,indexColumn)*U(:,index); end R(indexColumn,indexColumn)=norm(U(:,indexColumn)); U(:,indexColumn)=U(:,indexColumn)./R(indexColumn,indexColumn);endE=U;return