Addressed issues with averaging filter function caused by the inability to synchronize blocks in the grid.  This was overcome by separating the average calculations from the voxel value modification into two kernel functions.  Parameters were also added to the header file defining the neighborhood radius of the filter and the threshold value used to identify voxels belonging to the object when applying the filter to a hull image.  To make the host/GPU functions generic and capable of applying an average filter to any type of image, not just a hull, these were implemented as template functions.  Thus, the average filter can be applied to an image of any type (i.e. bool, int, float, etc) and is capable of generating a hull or simply a filtered image from any of these inputs.  To accomplish this, the function checks the type of the input parameter corresponding to where the result is to be stored and if it is boolean, a hull is generated, otherwise it applies the average filter in the standard way and converts the resulting average value calculated into the type of the output image (if integer, truncation occurs).

Applying an average filter