Hello Mat

 找回密码
 立即注册
查看: 5027|回复: 0

压缩采样匹配追踪(CoSaMP)

[复制链接]

1323

主题

1551

帖子

0

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22647
发表于 2017-2-12 22:24:17 | 显示全部楼层 |阅读模式
压缩感知重构算法之压缩采样匹配追踪(CoSaMP)
具体可参考:
游客,如果您要查看本帖隐藏内容请回复


具体的MATLAB函数代码见附件:
  1. clc,clear
  2. % -- Measurement matrix "A"
  3. N   = 2^10;
  4. M   = round(N/2);
  5. randn('state',239234);
  6. rand( 'state',239234);
  7. A   = randn(M,N)/sqrt(M);

  8. % -- Sparse signal "x"
  9. K   = round(M/5);
  10. T   = randperm(N);
  11. T   = T(1:K);
  12. x   = zeros(N,1);
  13. x(T)= randn(K,1);

  14. %% Add some noise:

  15. NOISE_LEVEL = 3;  % choose

  16. b   = A*x;
  17. randn('state',94350);
  18. switch NOISE_LEVEL
  19.     case 1
  20.         sigma   = 0;              % noiseless
  21.         disp('-------- Noiseless setting ----------');
  22.     case 2
  23.         sigma   = .3*norm(b)/sqrt(M); % noisy
  24.         disp('-------- Noisy setting --------------');
  25.     case 3
  26.         sigma   = .9*norm(b)/sqrt(M); % extremely noisy
  27.         disp('-------- Very noisy setting ---------');
  28. end
  29. z   = sigma*randn(M,1);
  30. b   = b + z;


  31. opts            = [];
  32. opts.maxiter    = 50;
  33. opts.tol        = 1e-8;
  34. opts.HSS        = true;
  35. opts.two_solves = true; % this can help, but no longer always works "perfectly" on noiseless data
  36. opts.printEvery = 10;
  37. % K_target    = round(length(b)/3)-1; opts.normTol = 2.0;
  38. K_target        = 50;   % When extremely noisy, this is best; when no noise, this is sub-optimal
  39. if sigma == 0
  40. %     K_target        = 100;  % This doesn't work "perfectly" but is OK
  41. %     K_target        = 102;  % This works "perfectly" with noiseless data
  42.     K_target        = 150;  % Slower, but works "perfectly" with noiseless data
  43. end

  44. % opts.addK       = 2*K_target; % default
  45. opts.addK       = K_target; % this seems to work a bit better
  46. % opts.addK       = 5;    % make this smaller and CoSaMP behaves more like OMP
  47.                         % (and does better for the correlated measurement matrix)

  48. % opts.support_tol    = 1e-2;
  49. fprintf('CoSaMP, -------------------------------\n\n');
  50. [xk] = CoSaMP( A, b, K_target, [], opts);
  51. fprintf('Error is %.2e\t\n\n', norm(xk-x)/norm(x));
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-11-26 08:04 , Processed in 0.227953 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表