首页 > 其他 > 详细

数字信号处理Day2-小波基与规范正交化

时间:2014-06-26 18:26:27      阅读:432      评论:0      收藏:0      [点我收藏+]

我们有这么一张灰度图64*64

bubuko.com,布布扣


我们能够定义出4096个基,各自是某一位是0其它是1,在这样的情况下,假设我们传输图片,那么就相当于传输原始数据

如果传到一半,网络坏了。

于是,我们得到bubuko.com,布布扣

我们能够计算原图像和这图像的差距

error = I - I_approx; 
distance = sqrt(sum(sum(error.*error))) 
distance = 
713.5559

如果我们使用Haar基

bubuko.com,布布扣


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

然后,我们看一下仅仅接受一半的图片能够恢复成什么样子,这个东西能够用到图片压缩(PCA降维)

clear all
close all
clc

% Load image
I = double(imread(‘camera.jpg‘));

% Arrange image in column vector
I = I(:);

% Generate Haar basis vector (rows of H)
H = haar(4096);

% Project image on the new basis
I_haar = H*I;

% Remove the second half of the coefficient
I_haar(2049:4096) = 0;

% Recover the image by inverting change of basis
I_haar = H‘*I_haar;

% Rearrange pixels of the image
I_haar = reshape(I_haar, 64, 64);

% Display image
figure
imshow(I_haar,[]);

bubuko.com,布布扣

效果还能够

error = I - I_haar; 
distance = sqrt(sum(sum(error.*error))) 
distance = 
350.6765


Haar基是正交基

怎样将普通基变成正交基呢

线性代数中的拉格慕-施密特正交化即可

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);

end

E=U;

return 


数字信号处理Day2-小波基与规范正交化,布布扣,bubuko.com

数字信号处理Day2-小波基与规范正交化

原文:http://www.cnblogs.com/mfrbuaa/p/3808526.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!