# 7.5.2. `algotom.util.simulation`

Module of simulation methods:

• Methods for designing a customized 2D phantom.

• Method for calculating a sinogram of a phantom based on the Fourier slice theorem.

• Methods for adding artifacts to a simulated sinogram.

Functions:

 `make_elliptic_mask`(size, center, length, angle) Create an elliptic mask. `make_rectangular_mask`(size, center, length, ...) Create a rectangular mask. `make_triangular_mask`(size, center, length, angle) Create an isosceles triangle mask. Create line patterns for testing the resolution of a reconstructed image. Create a face phantom for testing reconstruction methods. `make_sinogram`(mat, angles[, pad_rate, pad_mode]) Create a sinogram (series of 1D projections) from a 2D image based on the Fourier slice theorem (Ref. `add_noise`(mat[, noise_ratio]) Add Gaussian noise to an image. `add_stripe_artifact`(sinogram, size, position) Add stripe artifacts to a sinogram. `convert_to_Xray_image`(sinogram[, global_max]) Convert a simulated sinogram to an equivalent X-ray image. `add_background_fluctuation`(sinogram[, ...]) Fluctuate the background of a sinogram image using a Gaussian profile beam.

Parameters
• size (int) – Size of a square array.

• center (float or tuple of float) – Ellipse center.

• length (float or tuple of float) – Lengths of ellipse axes.

• angle (float) – Rotation angle (Degree) of the ellipse.

Returns

array_like – Square array.

Parameters
• size (int) – Size of a square array.

• center (float or tuple of float) – Center of the mask.

• length (float or tuple of float) – Lengths of the rectangular mask.

• angle (float) – Rotation angle (Degree) of the mask.

Returns

array_like – Square array.

Parameters
• size (int) – Size of a square array.

• center (float or tuple of float) – Center of the mask.

• length (float or tuple of float) – Lengths of the mask.

• angle (float) – Rotation angle (Degree) of the mask.

Returns

array_like – Square array.

algotom.util.simulation.make_line_target(size)[source]

Create line patterns for testing the resolution of a reconstructed image.

Parameters

size (int) – Size of a square array.

Returns

array_like – Square array.

algotom.util.simulation.make_face_phantom(size)[source]

Create a face phantom for testing reconstruction methods.

Parameters

size (int) – Size of a square array.

Returns

array_like – Square array.

Create a sinogram (series of 1D projections) from a 2D image based on the Fourier slice theorem (Ref. [1]).

Parameters
• mat (array_like) – Square array.

• angles (array_like) – 1D array. List of angles (in radian) for projecting.

References

Add Gaussian noise to an image.

Parameters
• mat (array_like) – 2D array

• noise_ratio (float) – Ratio between the noise level and the mean of the array.

Returns

array_like

Add stripe artifacts to a sinogram.

Parameters
• sinogram (array_like) – 2D array. Sinogram image.

• size (int) – Size of stripe artifact.

• position (int) – Position of the stripe.

• strength_ratio (float) – To define the strength of the artifact. The value is in the range of [0.0, 1.0].

• stripe_type ({“partial”, “full”, “dead”, “fluctuating”}) – Type of stripe as classified in Ref. [1].

Returns

array_like

References

algotom.util.simulation.convert_to_Xray_image(sinogram, global_max=None)[source]

Convert a simulated sinogram to an equivalent X-ray image.

Parameters
• sinogram (array_like) – 2D array.

• global_max (float) – Maximum value used for normalizing array values to stay in the range of [0.0, 1.0].

Returns

array_like