1

I'm currently working on a project that involves using an electron gun and it would be really nice to know the spot shape of the electrons coming out of the gun (the frequency of electrons at some x,y away from the center of the beam). Our current assumption is that the beam's spot shape is somewhat gaussian.

We have a picoammeter hooked up to a detector that outputs that current corresponding to the number of electrons that hit the detector. The detector is circular with some radius, R.

If I'm not mistaken, sweeping the beam and recording readings from the picoammeter will result in an matrix that is the convolution of the beam spot shape and a 2D step function that's 0 outside of R and non-zero inside R. I have looked through a few previous questions about deconvolutions related to images with a gaussian blur and it seems like this is very similar except the function is a step function instead of a gaussian.

I have tried using Matlab's conv2, FFT2, and iFFT2 functions to get the deconvolution as this thread suggests, but it produces something looking like this:

Deconvolution Attempt

The code that produced this is:

mu = [0 0]; 
Sigma = [1 0; 0 1]; 
x = -3:.2:3;
[X1,X2] = meshgrid(x,x);
F = mvnpdf([X1(:) X2(:)],mu,Sigma);
F = reshape(F,length(x),length(x));
for i=1:31
    for j=1:31 
        if x(i)^2+x(j)^2 >= 4 
            circ(i,j)=0; 
        else
            circ(i,j)=1; 
        end 
    end 
end 
conv = conv2(F,circ,'same');
D = ifft2( fft2(conv) ./ fft2(circ) ); 
surf(x1,x2,D);

Is there something inherently wrong with trying to deconvolves a step function? Also, I tried using the full convolution, but that seemed to produce an even weirder deconvolution...

Am I just going about this the wrong way? (I've included python because I would prefer to use python if a solution exists, but matlab is fine too)

Community
  • 1
  • 1
OstrichProjects
  • 318
  • 1
  • 2
  • 13
  • Do you need to zeropad the data prior to putting it into the frequency domain? If you don't get help here, you can ask a moderator to move this to dsp.stackexchange.com. – AnonSubmitter85 Oct 14 '14 at 04:08
  • What do you expect the output to look like? Did you centre your spectra (`conv`, `circ`) before you performed deconvolution? Performing `fft2` assumes that the centre of the spectrum is at the top left corner. Try using `fftshift` on your spectrum before taking the `fft2` itself. As such, try doing this after your `conv2` statement: `conv_shift = fftshift(conv); circ_shift = fftshift(circ); D = ifftshift(ifft2(fft2(conv_shift) ./ fft2(circ_shift)));` – rayryeng Oct 14 '14 at 14:00
  • Thanks @rayryeng. This seems to work for the most part (the deconvolved surface seems to be a little wider than the original gaussian, but other than that, they're about the same. – OstrichProjects Oct 14 '14 at 14:42

0 Answers0