Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[oneMKL samples][computed tomography] Revisions, refactoring and addition of a functional verification #2564

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Libraries/oneMKL/computed_tomography/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default: run
all: run

run: computed_tomography
./computed_tomography 400 400 input.bmp radon.bmp restored.bmp
./computed_tomography

MKL_COPTS = -DMKL_ILP64 -qmkl -qmkl-sycl-impl=dft

Expand All @@ -15,6 +15,6 @@ computed_tomography: computed_tomography.cpp
icpx $< -fsycl -o $@ $(DPCPP_OPTS)

clean:
-rm -f computed_tomography radon.bmp restored.bmp
-rm -f computed_tomography radon.bmp restored.bmp errors.bmp

.PHONY: clean run all
26 changes: 12 additions & 14 deletions Libraries/oneMKL/computed_tomography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ For more information on oneMKL and complete documentation of all oneMKL routines

Computed Tomography uses oneMKL 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.

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 back projection method for inverting the Radon transform, which involves a 1D DFT, followed by filtering, then an inverse 2D DFT to perform the final reconstruction.
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 Fourier reconstruction for inverting the Radon transform of a user-provided input image: using batched 1D real DFT of Radon transform data points, samples of the input image's Fourier spectrum may be estimated on a polar grid; after interpolating the latter onto a Cartesian grid, an inverse 2D real DFT produces a fair reproduction of the original image.

This sample performs its computations on the default SYCL* device. You can set the `SYCL_DEVICE_TYPE` environment variable to `cpu` or `gpu` to select the device to use.

This article explains in detail how oneMKL fast Fourier transform (FFT) functions can be used to reconstruct the original image from the Computer Tomography (CT) data: https://www.intel.com/content/www/us/en/docs/onemkl/cookbook/current/ffts-for-computer-tomography-image-reconstruction.html.
This sample performs its computations on the default SYCL device. You can set the `ONEAPI_DEVICE_SELECTOR` environment variable to `*:cpu` or `*:gpu` to select the device to use.

## Key Implementation Details

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. The `compute_*` routines are then called to perform the actual computation with the appropriate descriptor object and input/output buffers.
To use oneMKL DFT routines, the sample creates double-precision real DFT descriptor objects, calls the `commit` member function with a `sycl::queue` object to define the device and context. The `compute_*` routines are then called to perform the actual computation with the appropriate descriptor object and input data.

## Using Visual Studio Code* (Optional)
You can use Visual Studio Code (VS Code) extensions to set your environment, create launch configurations,
Expand Down Expand Up @@ -70,18 +68,18 @@ Run `nmake` to build and run the sample. `nmake clean` removes temporary files.
## Running the Computed Tomography Reconstruction Sample

### Example of Output
If everything is working correctly, the example program will start with the 400x400 example image `input.bmp` then create simulated CT data from it (stored as `restored.bmp`). It will then reconstruct the original image in grayscale and store it as `restored.bmp`.
If everything is working correctly, the example program will start with the 400x400 example image `input.bmp` then create simulated CT data from it (stored as `radon.bmp`). It will then reconstruct the original image in grayscale and store it as `restored.bmp`.

```
./computed_tomography 400 400 input.bmp radon.bmp restored.bmp
./computed_tomography
Reading original image from input.bmp
Allocating radonImage for backprojection
Performing backprojection
Restoring original: step1 - fft_1d in-place
Allocating array for radial->cartesian interpolation
Restoring original: step2 - interpolation
Restoring original: step3 - ifft_2d in-place
Saving restored image to restored.bmp
Generating Radon transform data from input.bmp
Saving Radon transform data in radon.bmp
Reconstructing image from the Radon projection data
Step 1 - Batch of 400 real 1D in-place forward DFTs of length 400
Step 2 - Interpolating spectrum from polar to cartesian grid
Step 3 - In-place backward real 2D DFT of size 400x400
Saving restored image in restored.bmp
```

### Troubleshooting
Expand Down
Loading