Skip to content

Commit fb3167f

Browse files
authored
Add computed_tomography sample (oneapi-src#212)
1 parent e70278b commit fb3167f

File tree

6 files changed

+705
-0
lines changed

6 files changed

+705
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Makefile for GNU make
2+
3+
default: run
4+
5+
run: computed_tomography
6+
./computed_tomography 400 400 input.bmp radon.bmp restored.bmp
7+
8+
DPCPP_OPTS = -I${MKLROOT}/include -mkl -fsycl-device-code-split=per_kernel
9+
10+
computed_tomography: computed_tomography.cpp
11+
dpcpp $< -o $@ $(DPCPP_OPTS)
12+
13+
clean:
14+
-rm -f computed_tomography radon.bmp restored.bmp
15+
16+
.PHONY: clean run
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Computed Tomography Reconstruction Sample
2+
3+
Computed Tomography shows how to use the oneMKL library's DFT functionality to simulate computed tomography (CT) imaging.
4+
5+
For more information on oneMKL, and complete documentation of all oneMKL routines, see https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html.
6+
7+
| Optimized for | Description
8+
|:--- |:---
9+
| OS | Linux* Ubuntu* 18.04; Windows 10
10+
| Hardware | Skylake with Gen9 or newer
11+
| Software | Intel&reg; oneMKL beta
12+
| What you will learn | How to use oneMKL's Discrete Fourier Transform (DFT) functionality
13+
| Time to complete | 15 minutes
14+
15+
## Purpose
16+
17+
Computed Tomography uses oneMKL's discrete Fourier transform (DFT) routines to transform simulated raw CT data (as collected by a CT scanner) into a reconstructed image of the scanned object.
18+
19+
In computed tomography, the raw imaging data is a set of line integrals over the actual object, also known as its _Radon transform_. From this data, the original image must be recovered by approximately inverting the Radon transform. This sample uses the filtered backprojection method for inverting the Radon transform, which involves a 1D DFT, followed by filtering, then an inverse 2D DFT to perform the final reconstruction.
20+
21+
This sample performs its computations on the default DPC++ device. You can set the `SYCL_DEVICE_TYPE` environment variable to `cpu` or `gpu` to select the device to use.
22+
23+
## Key Implementation Details
24+
25+
To use oneMKL DFT routines, the sample creates a descriptor object for the given precision and domain (real-to-complex or complex-to-complex), calls the `commit` method, and provides a `sycl::queue` object to define the device and context. Then the `compute_*` routines are called to perform the actual computation with the appropriate descriptor object and input/output buffers.
26+
27+
## License
28+
29+
This code sample is licensed under the MIT license.
30+
31+
## Building the Computed Tomography Reconstruction Sample
32+
33+
### Running Samples In DevCloud
34+
If running a sample in the Intel DevCloud, remember that you must specify the compute node (CPU, GPU, FPGA) as well whether to run in batch or interactive mode. For more information see the Intel® oneAPI Base Toolkit Get Started Guide (https://devcloud.intel.com/oneapi/get-started/base-toolkit/)
35+
36+
### On a Linux* System
37+
Run `make` to build and run the sample.
38+
39+
You can remove all generated files with `make clean`.
40+
41+
### On a Windows* System
42+
Run `nmake` to build and run the sample. `nmake clean` removes temporary files.
43+
44+
## Running the Computed Tomography Reconstruction Sample
45+
46+
### Example of Output
47+
If everything is working correctly, the example program will start with the 400x400 example image `input.bmp`, create simulated CT data from it (stored as `restored.bmp`), then reconstruct the original image in grayscale and store it as `restored.bmp`.
48+
49+
```
50+
./computed_tomography 400 400 input.bmp radon.bmp restored.bmp
51+
Reading original image from input.bmp
52+
Allocating radonImage for backprojection
53+
Performing backprojection
54+
Restoring original: step1 - fft_1d in-place
55+
Allocating array for radial->cartesian interpolation
56+
Restoring original: step2 - interpolation
57+
Restoring original: step3 - ifft_2d in-place
58+
Saving restored image to restored.bmp
59+
```

0 commit comments

Comments
 (0)