Waller-Lab / DiffuserCam

DiffuserCam Processing Code
BSD 3-Clause "New" or "Revised" License
111 stars 29 forks source link

psf shift question #10

Open Starsmith2 opened 6 years ago

Starsmith2 commented 6 years ago

psf = circshift(flip(psf,3),ceil(Nz/2)+2,3)/norm(psf(:)); %Shift impulse stack I cant understand this code. h(, ;-z) = h(, ; Nz - z) is a z-stack that is flipped in the zdirection. Why circshift is needed?

antipa commented 6 years ago

It's just an fft convention thing. The way I implemented the laplacian is with the center of the kernel being in the top, rear, left of the volume, to match the convention of fft algorithms. This is what one would get if the laplacian kernel were placed in the center of the volume then ifftshift were applied. By circshift-ing the PSF in z, the DC term of the z-direction fft comes out in the first layer, which is what we crop out. It would also have been fine to leave out the circ shift and define the 3D cropping to take the center section of the volume after 3D convolution.