In [1]:
# all the imports
import os
import tempfile
from subprocess import call
import scipy
import numpy as np
import matplotlib.pyplot as plt
from pims import ImageSequence
import zipfile
from skxray.core import dpc
%matplotlib notebook
dpc.logger.setLevel(dpc.logging.DEBUG)
In [2]:
# some helper functions
def load_image(filename):
"""
Load an image
Parameters
----------
filename : string
the location and name of an image
Return
----------
t : 2-D numpy array
store the image data
"""
if os.path.exists(filename):
t = plt.imread(filename)
else:
print('Please download and decompress the test data to your home directory\n\
Dropbox link, https://www.dropbox.com/s/ntvk7866h23jdpr/SOFC.zip?dl=0')
raise Exception('File not found: %s' % filename)
return t
In [3]:
import download
download.run()
In [4]:
# Set parameters
start_point = [1, 0]
first_image = 1
pixel_size = (55, 55)
focus_to_det = 1.46e6
scan_xstep = 0.1
scan_ystep = 0.1
scan_rows = 121
scan_cols = 121
energy = 19.5
roi = None
padding = 0
weighting = 1.
bad_pixels = None
solver = 'Nelder-Mead'
images = ImageSequence(os.path.join('SOFC', '*.tif'))
img_size = images[0].shape
ref_image = np.ones(img_size)
scale = True
negate = True
In [5]:
# Use skxray.dpc.dpc_runner
phase, amplitude = dpc.dpc_runner(
ref_image, images, start_point, pixel_size, focus_to_det, scan_rows,
scan_cols, scan_xstep, scan_ystep, energy, padding, weighting, solver,
roi, bad_pixels, negate, scale)
In [7]:
# display results
fig, ax = plt.subplots(ncols=2)
ax[0].imshow(phase, cmap='gray')
ax[1].imshow(amplitude, cmap='gray')
ax[0].set_title('Phase')
ax[1].set_title('Amplitude')
Out[7]:
In [8]:
import skxray
In [9]:
skxray.__version__
Out[9]:
In [ ]: