catrujilla / pyDHM

A Python library to numerically recover the complex wavefield information of samples from Digital Holographic Microscopy (DHM) recordings. Phase compensation, phase-shifting methods, and numerical propagators for different configurations and types of recordings in DHM are provided.
MIT License
20 stars 4 forks source link

Trouble recreating numerical propagation results from other DHM tools #6

Open isConic opened 1 year ago

isConic commented 1 year ago

Problem

I've been using ImageJ's numerical propagation plugin written in Java, The visual results from running Angular spectrum using the same parameters/measurements differ substantially between pyDHM and ImageJ Numerical Prop. The ImageJ output appears to be qualitatively more accurate.

Input Image:

20230110_15_44_54

ImageJ Numerical Propagation (Angular Spectrum) Results

Input Parameters:

wavelength:  409 [nm]  
distance:  1.1  [mm]  
input width:  3.85 [mm]
input height:  2.76 [mm]  

Visual Output

image

pyDHM Numerical Propagation(Angular Spectrum) Results

Input Parameters

wavelength:  409 [nm]  
distance:  1.1  [mm]  
input width:  3.85 [mm]
input height:  2.76 [mm]  

Note: All mm parameters are divided by 1000 to bring to meters. Note: wavelength is divided by 10^9 (otherwise no visual results) So 409 --> 409/(10.0^9)

Visual Output

image

Code:


mm_to_m = lambda x: x/(10.0**3)
nm_to_m = lambda x: x/(10.0**9)
params = dict(wavelength = nm_to_m(409), 
                       z = mm_to_m(1.01), 
                      dx = mm_to_m(3.85), 
                      dy = mm_to_m(2.76))

image = utilities.imageRead("test_data/plankton.jpg")   

# filter is not applied (Nor is it applied in other Numerical prop tools)  
output = angularSpectrum(image, **params)    

enhanced_output = utilities.intensity(output, False)     

General Question about filters

If I did not wish to apply a visual filter or restrict the ROI and wanted numerical propagation on the full image, Are there any transforms within the sfr, or sfmr that I'm missing outside of it?

isConic commented 1 year ago

References: https://read.qxmd.com/read/26367821/numerical-wave-propagation-in-imagej

isConic commented 1 year ago

Does angular spectrum accept unfiltered grayscale image arrays?

catrujilla commented 1 year ago

Sorry for getting back to you so late. It has been a busy couple of weeks.

Regarding your first question, the 'sfr' and 'sfmr' are not used in numerical propagations using the angular spectrum method. The propagation units seem not properly inputted to the function call, although it appears to be coded correctly with your 'mm_to_m' and 'nm_to_m'. I cannot identify any other potential issues that could impede proper propagation. The ImageJ numerical propagation plugin code for the angular spectrum and the pyDHM code for the same propagator are the same. The only difference is that ImageJ plugins were developed in JAVA.

Regarding your second question, yes, PyDHM's angular spectrum accepts unfiltered images, including .jpg files as you are using. However, please try converting the input image file to .tiff to be 100% sure that this is not the issue.