Giter Club home page Giter Club logo

d-amp_toolbox's People

Contributors

schniter avatar strikemetz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

d-amp_toolbox's Issues

Issue with Complex-Valued Image Reconstruction using function `DprGAMP.m`

Hi there,

I am working on a phase retrieval project and have been trying to use the DprGAMP.m function from the D-AMP_Toolbox for reconstructing complex-valued images from their magnitude measurements. According to my understanding of phase retrieval, the goal is to recover the original complex signal, but the function seems to return only real-valued images.

I have prepared a complex test signal as x_0 = img2 .* exp(1i * pi * img1), using test images img1 and img2. The reconstruction should retrieve the phase information from this signal. However, when I pass the magnitude measurements abs(M(x_0)) into the DprGAMP.m function, the result is an array of NaN values, which suggests that something is not working as expected.

Here's the MATLAB code I'm using, which is a modified version of the demo provided in the toolbox:

clear all;
clc;
close all;

addpath(genpath('..'));

%Parameters
denoiser='BM3D';%Available options are NLM, Gauss, Bilateral, BLS-GSM, BM3D, fast-BM3D, and BM3D-SAPCA 
filename='barbara.png';
SamplingRate=.6;
iters=100;
imsize=128;
Beta_damp=.1;
wvar=.1;

ImIn1=im2double(imread("Set12/02.png"));
ImIn2=double(imread("Set12/01.png"));
img1=abs(imresize(ImIn1,imsize/size(ImIn1,1)));
img2=abs(imresize(ImIn2,imsize/size(ImIn2,1)));
x_0 = img2 .* exp(1i*pi*img1);
[height, width]=size(x_0);
n=length(x_0(:));
m=round(n*SamplingRate);
x_init=255*rand(n,1);

%Generate Coded Diffraction Pattern Handle
signvec = exp(1i*2*pi*rand(n,1));
inds=[1;randsample(n-1,m-1)+1];
I=speye(n);
SubsampM=I(inds,:);
M=@(x) SubsampM*reshape(fft2(reshape(bsxfun(@times,signvec,x(:)),[height,width])),[n,1])*(1/sqrt(n))*sqrt(n/m);
Mt=@(x) bsxfun(@times,conj(signvec),reshape(ifft2(reshape(SubsampM'*x(:),[height,width])),[n,1]))*sqrt(n)*sqrt(n/m);
M_norm2=n;

%Compute magnitudes of compressive samples of the signal
% w=sqrt(wvar)*(randn(m,1)+1i*randn(m,1));
y=abs(M(x_0(:)));

%Recover Signal using D-prGAMP algorithm
PNSR_func=@(x) PSNR(x_0(:),abs(x(:)));
[x_hat, PSNR_hist] = DprGAMP(y,iters,width,height,denoiser,M,Mt,M_norm2,Beta_damp,wvar,x_init,PNSR_func);

%D-prGAMP Recovery Performance
display([num2str(SamplingRate*100),'% Sampling ', denoiser, '-prGAMP Coded Diffraction Pattern Reconstruction PSNR=',num2str(PSNR_hist(end))])

%Plot Recovered Signals
subplot(1,3,1);
imshow(abs(x_0),[]);title('True Amplification');colorbar;
subplot(1,3,2);
imshow(angle(x_0),[]);title('True Phase');colorbar;
subplot(1,3,3);
imshow(x_hat,[]);title('Output');colorbar;

When I run this code, here's what I get as the output:

NaN Output with Complex Input:

For comparison, when I use a real-valued image as input, like in the toolbox demo (x_0 = img2;), the function works fine, and I get a reasonable reconstruction:

Is the DprGAMP.m function designed to work with complex signals for phase retrieval, and if so, could you provide any guidance on why it might be failing with a complex input? If the function is not intended for complex-valued signals, I'd appreciate any pointers on how to modify it or if there's an alternative approach within the toolbox for handling complex signals.

Your guidance would be greatly appreciated, as it would significantly aid my understanding and application of phase retrieval techniques.

Thank you for developing such a comprehensive toolbox and for your support in resolving this query.

A question about calculating DIV

Dear author,

I want to ask a question about calculation of DIV.
In your code, you set a Gaussian vector $eta$

x_tplus1=denoi(pseudo_data,sigma_hat);
eta=randn(1,n); 
epsilon=max(pseudo_data)/1000+eps;  
div=eta*((denoi(pseudo_data+epsilon*eta',sigma_hat)-x_tplus1)/epsilon);

and I want to know why it works

VampSlmEst file missing

It seems to me that VampSlmEst file required for the VAMP algorithm is missing. If I am wrong, could you please write where to find it.

DnCNN missing as a denoiser

When I was trying to use the D-AMP_Toolbox, I followed the instruction and had GAMPmatlab installed and the NLM and RWT compiled.

The issue is that when I was trying to run Demos/CS_Imaging_Demo_LDAMP.m, I found that the DnCNN denoiser was missing in Algorithms/denoise, as shown in the following code snippets.

switch denoiser
case 'NLM'
if min(height,width)==1
%Scale signal from 0 to 1 for NLM denoiser
max_in=max(noisy(:));
min_in=min(noisy(:));
range_in=max_in-min_in+eps;
noisy=(noisy-min_in)/range_in;
Options.filterstrength=sigma_hat/range_in*1.5;
Options.kernelratio=5;
Options.windowratio=10;
output=range_in*NLMF(noisy,Options)+min_in;
else
if sigma_hat>200
Options.kernelratio=5;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.9;
elseif sigma_hat>150
Options.kernelratio=5;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.8;
elseif sigma_hat>100
Options.kernelratio=5;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.6;
elseif sigma_hat>=75
Options.kernelratio=5;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.5;
elseif sigma_hat>=45
Options.kernelratio=4;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.6;
elseif sigma_hat>=30
Options.kernelratio=3;
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*.9;
elseif sigma_hat>=15
Options.kernelratio=2;
Options.windowratio=10;
Options.filterstrength=sigma_hat/255*1;
else
Options.kernelratio=1;
Options.windowratio=10;
Options.filterstrength=sigma_hat/255*2;
end
Options.nThreads=4;
Options.enablepca=true;
output=255*NLMF(noisy/255,Options);
end
case 'Gauss'
h = fspecial('gaussian',5,sigma_hat);
output=imfilter(noisy,h,'symmetric');
case 'Bilateral'
Options.kernelratio=0;
Options.blocksize=256;
if sigma_hat>200
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*5;
elseif sigma_hat>150
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*4.5;
elseif sigma_hat>100
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*3.5;
elseif sigma_hat>=75
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*3;
elseif sigma_hat>=45
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*2.5;
elseif sigma_hat>=30
Options.windowratio=17;
Options.filterstrength=sigma_hat/255*2.2;
elseif sigma_hat>=15
Options.windowratio=10;
Options.filterstrength=sigma_hat/255*2.2;
else
Options.windowratio=10;
Options.filterstrength=sigma/255*2;
end
Options.nThreads=4;
Options.enablepca=false;
output=255*NLMF(noisy/255,Options);
case 'BLS-GSM'
%Parameters are BLS-GSM default values
PS = ones([width,height]);
seed = 0;
Nsc = ceil(log2(min(width,height)) - 4);
Nor = 3;
repres1 = 'uw';
repres2 = 'daub1';
blSize = [3 3];
parent = 0;
boundary = 1;
covariance = 1;
optim = 1;
output = denoi_BLS_GSM(noisy, sigma_hat, PS, blSize, parent, boundary, Nsc, Nor, covariance, optim, repres1, repres2, seed);
case 'BM3D'
[NA, output]=BM3D(1,noisy,sigma_hat,'np',0);
output=255*output;
case 'fast-BM3D'
[NA, output]=BM3D(1,noisy,sigma_hat,'lc',0);
output=255*output;
case 'BM3D-SAPCA'
output = 255*BM3DSAPCA2009(noisy/255,sigma_hat/255);
otherwise
error('Unrecognized Denoiser')
end

Can the contributor(s) of the D-AMP_Toolbox help with the completion of the DnCNN denoiser? Certainly, I can make my own one. But if the issue is not solved, how could the wonderful D-AMP_Toolbox preserve its integrity? @strikemetz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.