Skip to content

nabu.reconstruction.filtering

source module nabu.reconstruction.filtering

Classes

  • SinoFilter Initialize a SinoFilter instance.

Functions

source class SinoFilter(sino_shape, filter_name=None, padding_mode='zeros', crop_filtered_data=True, extra_options=None)

Initialize a SinoFilter instance.

Parameters

  • sino_shape : tuple Shape of sinogram, in the form (n_angles, detector_width) or (n_sinos, n_angles, detector_width)

  • filter_name : str, optional Name of the filter. Default is ram-lak.

  • padding_mode : str, optional How to pad the data prior to filtering. Default is zero-padding, corresponding to linear convolution with the filter kernel. In practice this value is often set to "edges" for interior tomography.

  • crop_filtered_data : bool, optional Whether to crop the final, filtered sinogram. Default is True. See notes below.

  • extra_options : dict, optional Dictionary of advanced extra options.

Notes

Sinogram filtering done in the Filtered Back-Projection (FBP) method consists, in theory, in applying a high-pass filter to the sinogram prior to backprojection. This high-pass filter is normally the Ramachandran-Lakshminarayanan (Ram-Lak) filter yielding a close-to-ideal reconstruction (see Natterer's "Mathematical methods in image reconstruction"). As the filter kernel has a large extent in spatial domain, it's best performed in Fourier domain via the Fourier-convolution theorem. Filtering in Fourier domain should be done with a data padded to at least twice its size. Zero-padding should be used for mathematical correctness (so that multiplication in Fourier domain corresponds to an actual linear convolution). However if the sinogram does not decay to "zero" near the edges (i.e in interior tomography), padding with zeros usually gives artefacts after filtering. In this case, padding with edges is preferred (corresponding to a convolution with the "edges" extension mode).

After inverse Fourier transform, the (padded and filtered) data is cropped back to its original size. In some cases, it's preferable to keep the data un-cropped for further processing.

Attributes

  • available_filters A class for sinogram filtering. It does the following: - pad input array - Fourier transform each row - multiply with a 1D or 2D filter - inverse Fourier transform

Methods

source method SinoFilter.set_filter(h_filt, normalize=True)

Set a filter for sinogram filtering.

Parameters

  • h_filt : numpy.ndarray Array containing the filter. Each line of the sinogram will be filtered with this filter. It has to be the Real-to-Complex Fourier Transform of some real filter, padded to 2*sinogram_width.

  • normalize : bool or float, optional Whether to normalize (multiply) the filter with pi/num_angles.

Raises

  • ValueError

source method SinoFilter.filter_sino(sino, output=None)

Perform the sinogram siltering.

Parameters

  • sino : array Input sinogram (2D or 3D)

  • output : array, optional Output array.

source filter_sinogram(sinogram, padded_width, filter_name='ramlak', padding_mode='constant', normalize=True, filter_cutoff=1.0, crop_filtered_data=True, **padding_kwargs)

Simple function to filter sinogram.

Parameters

  • sinogram : numpy.ndarray Sinogram, two dimensional array with shape (n_angles, sino_width)

  • padded_width : int Width to use for padding. Must be greater than sinogram width (i.e than sinogram.shape[-1])

  • filter_name : str, optional Which filter to use. Default is ramlak (roughly equivalent to abs(nu) in frequency domain)

  • padding_mode : str, optional Which padding mode to use. Default is zero-padding.

  • normalize : bool, optional Whether to multiply the filtered sinogram with pi/n_angles

  • filter_cutoff : float, optional frequency cutoff for filter