浅谈压缩感知(二十九):压缩感知算法之迭代硬阈值(IHT)
主要内容:
1、IHT的算法流程
2、IHT的MATLAB实现
3、二维信号的实验与结果
4、加速的IHT算法实验与结果
一、IHT的算法流程
文献:T. Blumensath and M. Davies, "Iterative Hard Thresholding for Compressed Sensing," 2008.
基本思想:给定一个初始的X0,然后通过以下的阈值公式不断地迭代。
二、IHT的MATLAB实现
function hat_x=cs_iht(y,T_Mat,s_ratio,m)
% y=T_Mat*x, T_Mat is n-by-m
% y - measurements
% T_Mat - combination of random matrix and sparse representation basis
% s_ratio - sparsity percentage of original signal
% m - size of the original signal
% the sparsity is length(y)/ hat_x_tp=zeros(m,); % initialization with the size of original
s=floor(length(y)*s_ratio); % sparsity
u=0.5; % impact factor % T_Mat=T_Mat/sqrt(sum(sum(T_Mat.^))); % normalizae the whole matrix for times=:s x_increase=T_Mat'*(y-T_Mat*hat_x_tp); hat_x=hat_x_tp+u*x_increase; [val,pos]=sort(abs(hat_x),'descend'); hat_x(pos(s+:end))=; % thresholding, keeping the larges s elements hat_x_tp=hat_x; % update end
三、二维信号的实验与结果
function Demo_CS_IHT()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the DCT basis is selected as the sparse representation dictionary
% instead of seting the whole image as a vector, I process the image in the
% fashion of column-by-column, so as to reduce the complexity. % Author: Chengfu Huo, roy@mail.ustc.edu.cn, http://home.ustc.edu.cn/~roy
% Reference: T. Blumensath and M. Davies, “Iterative Hard Thresholding for
% Compressed Sensing,” 2008.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %------------ read in the image --------------
img=imread('lena.bmp'); % testing image
img=double(img);
[height,width]=size(img); %------------ form the measurement matrix and base matrix ---------------
Phi=randn(floor(height/3),width); % only keep one third of the original data
Phi = Phi./repmat(sqrt(sum(Phi.^2,1)),[floor(height/3),1]); % normalize each column mat_dct_1d=zeros(256,256); % building the DCT basis (corresponding to each column)
for k=0:1:255
dct_1d=cos([0:1:255]'*k*pi/256);
if k>0
dct_1d=dct_1d-mean(dct_1d);
end;
mat_dct_1d(:,k+1)=dct_1d/norm(dct_1d);
end %--------- projection ---------
img_cs_1d=Phi*img; % treat each column as a independent signal %-------- recover using iht ------------
sparse_rec_1d=zeros(height,width);
Theta_1d=Phi*mat_dct_1d;
s_ratio = 0.2;
for i=1:width
column_rec=cs_iht(img_cs_1d(:,i),Theta_1d,s_ratio,height);
sparse_rec_1d(:,i)=column_rec'; % sparse representation
end
img_rec_1d=mat_dct_1d*sparse_rec_1d; % inverse transform %------------ show the results --------------------
figure(1)
% subplot(2,2,1),imagesc(img),title('original image')
subplot(2,2,1),imshow(img,[]),title('original image')
subplot(2,2,2),imagesc(Phi),title('measurement mat')
subplot(2,2,3),imagesc(mat_dct_1d),title('1d dct mat')
psnr = 20*log10(255/sqrt(mean((img(:)-img_rec_1d(:)).^2)));
% subplot(2,2,4),imagesc(img_rec_1d),title(strcat('1d rec img ',num2str(psnr),'dB'))
subplot(2,2,4),imshow(img_rec_1d,[]),title(strcat('1d rec img ',num2str(psnr),'dB')) disp('over') %************************************************************************%
function hat_x=cs_iht(y,T_Mat,s_ratio,m)
% y=T_Mat*x, T_Mat is n-by-m
% y - measurements
% T_Mat - combination of random matrix and sparse representation basis
% s_ratio - sparsity percentage of original signal
% m - size of the original signal
% the sparsity is length(y)/4 hat_x_tp=zeros(m,1); % initialization with the size of original
s=floor(length(y)*s_ratio); % sparsity
u=0.5; % impact factor % T_Mat=T_Mat/sqrt(sum(sum(T_Mat.^2))); % normalizae the whole matrix for times=1:s x_increase=T_Mat'*(y-T_Mat*hat_x_tp); hat_x=hat_x_tp+u*x_increase; [val,pos]=sort(abs(hat_x),'descend'); hat_x(pos(s+1:end))=0; % thresholding, keeping the larges s elements hat_x_tp=hat_x; % update end
结论:实验针对的是图像信号,但算法中运用的是1维的算法,因此实验结果不太理想。(后面提供一个链接,有更好的代码 hard_l0_Mterm.m)
四、加速的IHT算法实验与结果
文献:Blumensath T. Accelerated iterative hard thresholding[J]. Signal Processing, 2012, 92(3): 752-756.
五、相关代码
http://www.personal.soton.ac.uk/tb1m08/sparsify/sparsify.html
浅谈压缩感知(二十九):压缩感知算法之迭代硬阈值(IHT)的更多相关文章
- Bootstrap <基础二十九>面板(Panels)
Bootstrap 面板(Panels).面板组件用于把 DOM 组件插入到一个盒子中.创建一个基本的面板,只需要向 <div> 元素添加 class .panel 和 class .pa ...
- Web 开发人员和设计师必读文章推荐【系列二十九】
<Web 前端开发精华文章推荐>2014年第8期(总第29期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载]
原文:WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载] 我们有两种典型的WCF调用方式:通过SvcUtil.exe(或者添加Web引用)导入发布的服务元数据生成服务代理相关的代码 ...
- VMwarevSphere 服务器虚拟化之二十九 桌面虚拟化之安装View副本服务器
VMwarevSphere 服务器虚拟化之二十九 桌面虚拟化之安装View副本服务器 VMware View中高可用性可是一个必须要考虑的问题.在整个虚拟桌面环境中View Connection S ...
- Bootstrap入门(二十九)JS插件6:弹出框
Bootstrap入门(二十九)JS插件6:弹出框 加入小覆盖的内容,像在iPad上,用于存放非主要信息 弹出框是依赖于工具提示插件的,那它也和工具提示是一样的,是需要初始化才能够使用的 首先我们引入 ...
- mysql进阶(二十九)常用函数
mysql进阶(二十九)常用函数 一.数学函数 ABS(x) 返回x的绝对值 BIN(x) 返回x的二进制(OCT返回八进制,HEX返回十六进制) CEILING(x) 返回大于x的最小整数值 EXP ...
- JAVA之旅(二十九)——文件递归,File结束练习,Properties,Properties存取配置文件,load,Properties的小练习
JAVA之旅(二十九)--文件递归,File结束练习,Properties,Properties存取配置文件,load,Properties的小练习 我们继续学习File 一.文件递归 我们可以来实现 ...
- 浅谈Kotlin(二):基本类型、基本语法、代码风格
浅谈Kotlin(一):简介及Android Studio中配置 浅谈Kotlin(二):基本类型.基本语法.代码风格 浅谈Kotlin(三):类 浅谈Kotlin(四):控制流 通过上面的文章,在A ...
- 【黑金原创教程】【FPGA那些事儿-驱动篇I 】原创教程连载导读【连载完成,共二十九章】
前言: 无数昼夜的来回轮替以后,这本<驱动篇I>终于编辑完毕了,笔者真的感动到连鼻涕也流下来.所谓驱动就是认识硬件,还有前期建模.虽然<驱动篇I>的硬件都是我们熟悉的老友记,例 ...
随机推荐
- table奇偶行设置颜色代码
- jquery中append跟prepend的用法
jquery中append和prepend的用法 append 是插入到元素中,并放到元素内的最后面prepend 是插入到元素中,并放到元素内的最前面例$("body"). ...
- Convert HTML Entities
function convert(str) { // :) //return str; var HTML_Entities = { '&':'&', '<':'<', '& ...
- Java核心知识点学习----线程中如何创建锁和使用锁 Lock,设计一个缓存系统
理论知识很枯燥,但这些都是基本功,学完可能会忘,但等用的时候,会发觉之前的学习是非常有意义的,学习线程就是这样子的. 1.如何创建锁? Lock lock = new ReentrantLock(); ...
- linux中压缩与解压缩命令
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压 ...
- 解决 label 多行间距
使用. 一个是间距,一个是行高,但是鉴于多行,都写的话,就相当于双倍行高了.我就用行高代替间距. self.textLabel.attributedText = [self getAttributed ...
- NSDate--日期格式
日期格式: 年: y 将年份 (0-9) 显示为不带前导零的数字 yy 以带前导零的两位数字格式显示年份 yyy 以四位数字格式显示年份 yyyy 以四位数字格式显示年份 月: M 将月份显示为不带前 ...
- unity --项目总结
最近做的unity的项目涉及到的问题如下: 1.绘制折线图问题: 起初利用的unity自带的linerender组件,这种方法绘制的线不均匀,效果不好.然后又利用画线插件Ves……开头的那个,结果那个 ...
- document.write()
以前一直以为document.write()就一定会清空文档里面的所有内容,一直没有去尝试,最近才知道原来是要在特定的情况下document.write才会清空文档里面所有内容的,在这里,觉得应该告诉 ...
- Servlet中使用Log4j2
因为Servlet常用的版本有两个,即2.5与3.0.要在web application中使用Log4j2,还需要加入log4j-web的jar包.log4j通过web.xml中的context参数l ...