estimate_blur

pysaber.estimate_blur(rads, sod, odd, pix_wid, edge, thresh=1e-06, pad=[3, 3], masks=None, bdary_mask=5.0, perp_mask=5.0, power=1.0, save_dir='./', only_src=False, only_det=False, mix_det=True)

Estimate parameters of point spread functions (PSF) that model X-ray source blur and/or detector blur from normalized radiographs of a straight sharp edge or mutually perpendicular intersecting pair of sharp edges.

This function is used to estimate parameters of the PSFs that model X-ray source blur and/or detector blur. It takes as input the normalized radiographs at multiple source to object distances (SOD) and object to detector distances (ODD). If each radiograph has a single straight edge, then the measurement must be repeated for two different, preferably perpendicular, orientations of the edge. If the radiograph consists of two intersecting perpendicular edges, then a single radiograph at each specified SOD/ODD is sufficient. Simultaneous estimation of source and detector blur will require radiographs at a minimum of two different value pairs for SOD/ODD. During PSF parameter estimation, the influence of certain regions within each radiograph can be removed by masking. For more details, please read ahead and also refer to the documents listed in References.

Parameters
  • rads (list) – List of radiographs, each of type numpy.ndarray, at various SODs and ODDs. Each radiograph must be normalized using the bright-field (also called flat-field) and dark-field images.

  • sod (list) – List of source to object distances (SOD), each of type float, at which each corresponding radiograph in the list rads was acquired.

  • odd (list) – List of object to detector distances (ODD), each of type float, at which each corresponding radiograph in the list rads was acquired.

  • pix_wid (float) – Effective width of each detector pixel. Note that this is the effective pixel size given by dividing the physical width of each detector pixel by the zoom factor of the optical lens.

  • edge (str) – Used to indicate whether there is a single straight edge or two mutually perpendicular edges in each radiograph. If edge is perpendicular, then each radiograph is assumed to have two mutually perpendicular edges. If it is straight, then each radiograph is assumed to have a single straight edge. Only perpendicular and straight are legal choices for edge.

  • thresh (float) – Convergence threshold for the minimizer during parameter estimation. The iterations stop when the ratio of the reduction in the error function (cost value) and the magnitude of the error function is lower than thresh. This is the parameter ftol that is specified in the options parameter of scipy.optimize.minimize. The optimizer used is L-BFGS-B. During joint estimation of source and detector blur, the convergence threshold for the minimizer during the first two initialization steps is ten times this value.

  • pad (list) – List of two integers that determine the amount of padding that must be applied to the radiographs to reduce aliasing during convolution. The number of rows/columns after padding is equal to pad_factor[0]/pad_factor[1] times the number of rows/columns in each radiograph before padding. For example, if the first element in pad_factor is 2, then the radiograph is padded to twice its size along the first dimension.

  • masks (list) – List of boolean masks, each of type numpy.ndarray and same shape as the radiograph, that is used to exclude pixels from blur estimation. This is in addition to the masking specified by bdary_mask and perp_mask. An example use case is if some pixels in the radiograph rads[i] are bad, then those pixels can be excluded from blur estimation by setting the corresponding entries in masks[i] to False and True otherwise. If None, no user specified mask is used.

  • bdary_mask (float) – Percentage of image region in the radiographs as measured from the outer edge going inwards that must be excluded from blur estimation. Pixels are excluded (or masked) beginning from the outermost periphery of the image and working inwards until the specified percentage of pixels is reached.

  • perp_mask (float) – Percentage of circular region to ignore during blur estimation around the intersecting corner of two perpendicular edges. Ignored if edge is straight.

  • power (float) – Shape parameter of the density function used to model each PSF. For example, choosing a value of one for power creates an exponential (Laplacian) density function. Choosing a value of two for power creates a Gaussian density function.

  • save_dir (str) – Directory where estimated parameters are saved in yaml file format. Source blur parameters are saved in the file source_params.yml within the folder save_dir. Similary, detector blur and transmission function parameters are saved as detector_params.yml and transmission_params.yml.

  • only_src (bool) – If True, only estimate source blur parameters.

  • only_det (bool) – If True, only estimate detector blur parameters.

  • mix_det (bool) – If True, do not use mixture model for detector blur.

Returns

Tuple of objects containing the estimated parameters. If estimating both source and detector blur parameters, returns the three element tuple (src_pars, det_pars, tran_pars). If estimating only source blur parameters, returns the two element tuple (src_pars, tran_pars). If estimating only detector blur parameters, returns the two element tuple (det_pars, tran_pars). src_pars and det_pars are python dictionaries. tran_pars is a list of lists.

src_pars contains the estimated parameters of X-ray source PSF. It consists of several key-value pairs. The value for key source_FWHM_x_axis is the full width half maximum (FWHM) of the source PSF along the x-axis (i.e., second numpy.ndarray dimension). The value for key source_FWHM_y_axis is the FWHM of source PSF along the y-axis (i.e., first numpy.ndarray dimension). All FWHMs are for the source PSF in the plane of the X-ray source (and not the plane of the detector). The value for key cutoff_FWHM_multiplier decides the non-zero spatial extent of the source PSF. The PSF is clipped to zero beginning at a distance, as measured from the PSF’s origin, equal to the maximum of src_pars['cutoff_FWHM_multiplier'] times src_pars['source_FWHM_x_axis']/2 and src_pars['cutoff_FWHM_multiplier'] times src_pars['source_FWHM_y_axis']/2.

det_pars contains estimated parameters of detector PSF. It consists of several key-value pairs. The value for key detector_FWHM_1 is the FWHM of the first density function in the mixture density model for detector blur. The first density function is the most dominant part of detector blur. The value for key detector_FWHM_2 is the FWHM of the second density function in the mixture density model. This density function has the largest FWHM and models the long running tails of the detector blur’s PSF. The value for key detector_weight_1 is between 0 and 1 and is a measure of the amount of contribution of the first density function to the detector blur. The values for keys cutoff_FWHM_1_multiplier and cutoff_FWHM_2_multiplier decide the non-zero spatial extent of the detector PSF. The PSF is clipped to zero beginning at a distance, as measured from the PSF’s origin, equal to the maximum of det_pars['cutoff_FWHM_1_multiplier'] times det_pars['detector_FWHM_1']/2 and det_pars['cutoff_FWHM_2_multiplier'] times det_pars['detector_FWHM_2']/2. If mix_det is False, then value for key detector_weight_1 is fixed at 1 and value for key detector_FWHM_2 is fixed at 0.

tran_pars contains estimated parameters of the transmission function for each input radiograph. This return value is a list of lists, where each inner nested list consists of two parameters of type float. These float values give the low and high values respectively of the transmission function. The number of nested lists in the returned list equals the number of input radiographs. Note that the transmission function is the normalized radiograph image that would have resulted in the absence of blur and noise.

Return type

tuple