IJ-801-An Image Filter For Counting Pixel Neighbors
IJ-801-An Image Filter For Counting Pixel Neighbors
Release 0.01
Robert Tamburo1
Abstract
This papers describes an image filter that counts the number of neighbors a pixel has storing that value at
the pixel’s image index. Functionality is provided to 1) adjust the neighborhood size, 2) count only those
pixels within a specific value range, and 3) only record a neighbor count for specific pixels of interest.
This paper is accompanied with source code for the filter and test, test images and parameters, and
expected output images.
Contents
1 Implementation of Algorithm 1
2 Example Usage 2
3 Software Used 2
1 Implementation of Algorithm
CountNeighborsImageFilter counts the number of neighbors a pixel has and stores the count at the pixel’s
image index. The entire is image is iterated over and at each pixel a neighborhood, centered at the current
pixel, is constructed. Pixels within the neighborhood are counted if the user-defined criteria is satisfied.
The count does not include the pixel of interest. The size of the neighborhood can be set with the function
SetRadius(), which has a default setting of 1 to contain all fully connected pixels. Several options for
count inclusion criteria are available:
SetValueOfInterest() allows the user to only count neighbors for pixels of a specific value, which is
disabled by default
2 Example Usage
This filter requires setting an input image SetInput(), the radius of the neighborhood with SetRadius(),
the counting strategy, and the option to count neighbors for specific pixels. Example usage is shown below.
3 Software Used
This filter was developed on a Windows 7 64-bit computer. It has been successfully tested with ITK version
3.18.0, MinGW version 5.1.6, and CMake version 2.8.2 (Windows binary).
Figure 2: The output image produced with the first set of parameters. Intensities scaled in a viewer for visualization
purposes
Figure 3: The output image produced with the second set of parameters. Intensities scaled in a viewer for visualization
purposes
Figure 4: The output image produced with the third set of parameters. Intensities scaled in a viewer for visualization
purposes
Figure 5: The output image produced with the fourth set of parameters. Intensities scaled in a viewer for visualization
purposes