In this series Learning Tomography, I mentioned a backProjImproved.js script in several posts to compute a 2D reconstruction according to the backprojection technique.... Unfortunately, I have never published it. Here it is...
1- Script
This is exactly the same algorithm as those described [here].The differences are:
- Pre-computation of the angles (lines #20-24).
- In the main loop, the methods of ImageJ API are used rather than the equivalent plugins...
- Extraction of the row by ImageProcessor.crop().
- Use of the methods ImageProcessor.resize(...) and ImageProcessor.rotate(...) instead of the plugins Image>Adjust>Size... and Image>Transform>Rotate...
Now the script looks like...
+++ IJ JavaScript snippet: backProjImproved.js +++
+++ End of IJ JavaScript snippet: backProjImproved.js +++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple back-projection technique | |
// Improved version | |
// Updated 2019/03/18 (ES6) | |
// Jean-Christophe Taveau | |
// http://crazybiocomputing.blogspot.com | |
// 1- Get sinogram and create the final stack | |
let sino = IJ.getImage(); | |
let sino_ip = sino.getProcessor(); | |
let w=sino.getWidth(); | |
let nbProj=sino.getHeight(); | |
// Output 2D reconstruction | |
let rec = IJ.createImage("Rec2D", "32-bit Black", w, w, 1); | |
// Global variables | |
let tmp = IJ.createImage("tmp", "32-bit Black", w, w, 1); | |
let ic = new ImageCalculator(); | |
let bp = null; | |
// Precompute angles | |
let step=180/nbProj; | |
let angles=[]; | |
for (let i=0;i<nbProj;i++) | |
angles[i]=-i*step; | |
// M a i n l o o p | |
for (let i in angles) { | |
// 1- get ith row | |
sino_ip.setRoi(0,i,w,1); | |
row = sino_ip.crop(); | |
// 2- back-project | |
bp = row.resize(w,w); | |
// 3- rotate accordingly | |
bp.rotate(angles[i]); | |
// 4- add to 2D rec | |
tmp.setProcessor(bp); | |
ic.run("Add",rec,tmp); | |
} | |
rec.show(); | |
Note: This script is the core of the script used for 3D reconstruction [Link].
2- Result
The procedure is exactly the same and is divided in four steps.- First, download our test image − the sinogram of Lena [Link] (or [Link] and choose in Tomography section, the image entitled "32-bit sinogram in TIFF" ) − and open it in ImageJ.
- Second, create a 32-bit 256x256 image entitled "rampFilter" with a black background and in Process>Math>Macro..., type the following formula:
- Third, apply this ramp filter to the sinogram with Process > FFT > Custom Filter and choose "rampFilter".
- Fourth, run the script from the filtered sinogram and Lena is reconstructed (Fig. 1).
if (d > 120.0) v=0.0; else v=d;
![]() |
Fig.1: Pipeline of 2D reconstruction. From the sinogram, |
Note: If you experience some trouble with the custom filter, try to pad the 256x180 sinogram in a larger canvas (for example, 512x180 with Image > Adjust> Canvas Size...) and then, apply the ramp filter and finally, run the script.
Thank you for reading this post and feel free to add any comment or suggestion below.
No comments:
Post a Comment