• 大小: 12KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: Matlab
  • 标签: Matlab  压缩感知  

资源简介

Code demo for single-pixel imaging (SPI) with different reconstruction methods including [1] differential ghost imaging (DGI) [2] gradient descent (GD) [3] conjugate gradient descent (CGD) [4] Poisson maximum likelihood (Poisson) [5] alternating projection (AP) [6] sparse representation compressive sensing (Sparse) [7] total variation compressive sensing (TV)

资源截图

代码片段和文件信息

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% By Liheng Bian June 22 2017. Contact me: lihengbian@gmail.com.
% This demo does the simulation of single-pixel imaging with different reconstruction methods.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear; 
clc;
close all;
addpath(genpath(pwd));

%% Parameters
num_pixel = 64; % number of image pixels in each dimension
samplingRatio = 0.5;

para.tol = 1e-2;
para.min_iter = 30;
para.x0flag = 0; % initialization flag of the reconstructed image 0: all one; 1: pinv(A)*b.

%% Measurements
im = im2double(imread(‘cameraman.tif‘));
im = imresize(im[num_pixelnum_pixel]);
figureimshow(im[]‘InitialMagnification‘1000); title(‘Scene image‘);

num_pattern = round(samplingRatio * num_pixel * num_pixel); % number of illumination patterns
patterns =  rand(num_pixelnum_pixelnum_pattern);
measurements = sum(sum(repmat(im[11num_pattern]) .* patterns));
measurements = reshape(measurements[]1);

%% initialization
[row col m] = size(patterns);
P = reshape(patterns [row*col m]);
P = P‘; % each row represents a pattern

if para.x0flag == 1
    para.x0 = pinv(P)*measurements;
else
    para.x0 = ones(row * col1);
end

%% 1. SPI differential ghost imaging (DGI) reconstruction
ind = 1;
fprintf(‘Begin reconstruction of DGI. \n‘);
tic
[im_r_DGI] = fun_SPI_R_DGI(patterns measurements);
runTime(ind2) = toc;
figureimshow(im_r_DGI[]‘InitialMagnification‘1000); title(‘Recovered im using DGI method‘);
im_r(::ind) = im_r_DGI;

%% 2. SPI gradient descent (GD) reconstruction
ind = 2;
fprintf(‘Begin reconstruction of GD. \n‘);
tic
[im_r_GD totaliter] = fun_SPI_R_GD(patterns measurements para);
runTime(ind2) = toc;
runTime(ind1) = totaliter;
figureimshow(im_r_GD[]‘InitialMagnification‘1000); title(‘Recovered im using GD method‘);
im_r(::ind) = im_r_GD;

%% 3. SPI conjugate gradient descent (CGD) reconstruction
ind = 3;
fprintf(‘Begin reconstruction of CGD. \n‘);
tic
[im_r_CGD totaliter] = fun_SPI_R_CGD(patterns measurements para);
runTime(ind2) = toc;
runTime(ind1) = totaliter;
figureimshow(im_r_CGD[]‘InitialMagnification‘1000); title(‘Recovered im using CGD method‘);
im_r(::ind) = im_r_CGD;

%% 4. SPI Poisson maximum likelihood reconstruction
ind = 4;
fprintf(‘Begin reconstruction of Poisson. \n‘);
tic
[im_r_Poisson totaliter] = fun_SPI_R_Poisson(patterns measurements para);
runTime(ind2) = toc;
runTime(ind1) = totaliter;
figureimshow(im_r_Poisson[]‘InitialMagnification‘1000); title(‘Recovered im using Poisson method‘);
im_r(::ind) = im_r_Poisson;

%% 5. SPI alternating projection (AP) reconstruction
ind = 5;
fprintf(‘Begin reconstruction of AP. \n‘);
tic
[im_r_AP totaliter] = fun_SPI_R_AP(patterns measurements para);
runTime(ind2) = toc;
runTime(ind1) = totaliter;
figureimshow(im_r_AP[]‘InitialMagnification‘1000); title(‘Recovered im using AP method‘);
im_r(::ind) = im_r_AP;

%% 6. SPI Sparse representa

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4714  2017-06-22 17:46  Demo.m
     文件         806  2017-10-24 15:52  fun_error.m
     文件        2042  2017-11-21 16:05  fun_SPI_R_AP.m
     文件        1949  2017-11-21 16:11  fun_SPI_R_CGD.m
     文件        1414  2016-06-29 06:22  fun_SPI_R_DGI.m
     文件        2045  2017-06-22 10:10  fun_SPI_R_GD.m
     文件        2648  2017-06-22 10:10  fun_SPI_R_Poisson.m
     文件        4674  2017-10-21 17:30  fun_SPI_R_Sparse.m
     文件        5691  2017-10-24 15:54  fun_SPI_R_TV.m
     文件        4655  2017-10-24 15:54  README.txt

评论

共有 条评论