Simulate projections and noise#

Forward-project an image and add realistic Poisson and Gaussian noise.

Source: Python/demos/d03_generateData.py · MATLAB/Demos/d03_generateData.m

MATLAB version of this demo
%% DEMO 03: Generate sample data and add realistic CT noise to it.
%
% This demo will show how to generate sample data for image reconstruction
%
%
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% This file is part of the TIGRE Toolbox
% 
% Copyright (c) 2015, University of Bath and 
%                     CERN-European Organization for Nuclear Research
%                     All rights reserved.
%
% License:            Open Source under BSD. 
%                     See the full license at
%                     https://github.com/CERN/TIGRE/blob/master/LICENSE
%
% Contact:            tigre.toolbox@gmail.com
% Codes:              https://github.com/CERN/TIGRE/
% Coded by:           Ander Biguri 
%--------------------------------------------------------------------------
%% Initialize
clear;
close all;
%% Geometry
geo=defaultGeometry();
%% Define angles of projection and load phantom image

% define projection angles (in radians)
angles=linspace(0,2*pi,100);
% load phatnom image
head=headPhantom(geo.nVoxel);

% Simulate forward projection.
% Strongly suggested to use 'iterpolated' option for more accurate
% projections. reduce geo.accuracy for better results
projections=Ax(head,geo,angles,'interpolated');

% Add realistic noise. Adds photon scattering noise ('Poisson') and
% electronic noise of the detector ('Gaussian').
%
% 'Poisson' is related to the maximum photon count in the detector. 1e5 is
% a standard clinical number, reduce it for more noise
% 'Gaussian' is related to possible electronic noise in the detector. mean
% of 0 and std of 10 is common in clinical scenario. Increase std for more
% noise.
noise_projections=addCTnoise(projections,'Poisson',1e5,'Gaussian',[0 10]);

% Plot Projections
plotProj(projections,angles)
% plot noise
plotProj(projections-noise_projections,angles)
import tigre
import numpy as np
from tigre.utilities import sample_loader
from tigre.utilities import CTnoise

geo = tigre.geometry_default(high_resolution=False)

Define angles of projection and load phantom image#

# define projection angles (in radians)
angles = np.linspace(0, 2 * np.pi, 50, endpoint=False)
# load phantom image
head = sample_loader.load_head_phantom(geo.nVoxel)

# Simulate forward projection.
# To match with mathematical notation, the projection operation is called Ax
projections = tigre.Ax(head, geo, angles)

# Add realistic noise. Adds photon scattering noise ('Poisson') and
# electronic noise of the detector ('Gaussian').
#
# 'Poisson' is related to the maximum photon count in the detector. 1e5 is
# a standard clinical number, reduce it for more noise
# 'Gaussian' is related to possible electronic noise in the detector. mean
# of 0 and std of 10 is common in clinical scenario. Increase std for more
# noise.
noise_projections = CTnoise.add(projections, Poisson=1e5, Gaussian=np.array([0, 10]))

Plot Projections#

tigre.plotproj(projections)
# plot noise
tigre.plotproj(projections - noise_projections)
  • d03 generateData
  • d03 generateData

Total running time of the script: (0 minutes 11.219 seconds)

Gallery generated by Sphinx-Gallery