Skip to content

Ray may accumulate past the detector in rtkCudaForwardProjectionImageFilter.cu #980

Description

@maxime-y-monin

RTK provides a GPU-backed forward projection image filter, which internally calls the kernel_forwardProject CUDA kernel defined in rtkCudaForwardProjectionImageFilter.cu. During the kernel execution, each GPU thread steps through the input volume to compute a ray integral from X-ray source to detector pixels. The start (tnear) and end (tfar) positions for the integral are defined as the entry and exit points of the ray-box intersection provided by the intersectBox function.

While the starting point is explicitly clamped to the X-ray source location, I am surprised by the absence of a matching upper bound for tfar. This means that if the volume boundaries go past the detector plane, the ray integral will accumulate volume intensities beyond the detector pixel. I assume it would be more correct to also clamp the end point as:

 ray.d = pixelPos - ray.o;
 const float tmax = norm3df(ray.d);
 ray.d /= tmax;

/* compute box intersection */
// [...]

if (tnear < 0.f)
    tnear = 0.f; // clamp to near plane

if (tfar > tmax)
    tfar = tmax; // clamp to far plane

Conversely, the documentation of the Joseph forward projector states that "The forward projector tests if the detector has been placed after the source and the volume. If the detector is in the volume the ray tracing is performed only until that point.". Therefore, adding far-plane clamping in the GPU forward projector would match the behavior of its CPU counterpart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions