bwdist

Implementation

OpenCL

Usage

output = BWDIST_ATI(input);

Class Support

Both output and input are float types. But input shall only contain values of zero or one.

Algorithm

Distance transform is divided into two stages: the first stage is to calculate the horizontal distance of each point and the second stage is to calculate the vertical distance and pick up the final result based on the results from stage one. For the first stage, each row is split into several chunks and the leftmost and rightmost point of each chunk are stored into shared memory to update the points lying on each chunk later on. For the second stage, the matrix returned from stage one is transposed at first in order to avoid the non-coalesced reading and then fed into the second kernel. The result from the second kernel is transposed back to the original coordinator.