From 789c19923d7b60b471e0f7e240d8d2957c0adb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20B=C3=B8=20Fl=C3=B8ystad?= Date: Thu, 4 Jul 2013 15:29:53 +0200 Subject: [PATCH] Radon example: print RMS errors of the reconstructions. --- doc/examples/plot_radon_transform.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/examples/plot_radon_transform.py b/doc/examples/plot_radon_transform.py index 4b5b8d8d..d457d5a6 100644 --- a/doc/examples/plot_radon_transform.py +++ b/doc/examples/plot_radon_transform.py @@ -48,6 +48,8 @@ provided by the projections), and we follow that rule here. Below is the original image and its Radon transform, often known as its _sinogram_: """ +from __future__ import print_function, division + import numpy as np import matplotlib.pyplot as plt @@ -97,6 +99,8 @@ different options for the filter. from skimage.transform import iradon reconstruction_fbp = iradon(sinogram, theta=theta, circle=True) +error = reconstruction_fbp - image +print('FBP rms reconstruction error: %.3g' % np.sqrt(np.mean(error**2))) imkwargs = dict(vmin=-0.2, vmax=0.2) plt.figure(figsize=(8, 4.5)) @@ -148,6 +152,9 @@ to the reconstruction. from skimage.transform import iradon_sart reconstruction_sart = iradon_sart(sinogram, theta=theta) +error = reconstruction_sart - image +print('SART (1 iteration) rms reconstruction error: %.3g' + % np.sqrt(np.mean(error**2))) plt.figure(figsize=(8, 8.5)) @@ -162,9 +169,9 @@ plt.imshow(reconstruction_sart - image, cmap=plt.cm.Greys_r, **imkwargs) # from the first iteration as an initial estimate reconstruction_sart2 = iradon_sart(sinogram, theta=theta, image=reconstruction_sart) - -d = reconstruction_sart - image -print(d.max(), d.min()) +error = reconstruction_sart2 - image +print('SART (2 iterations) rms reconstruction error: %.3g' + % np.sqrt(np.mean(error**2))) plt.subplot(223) plt.title("Reconstruction\nSART, 2 iterations")