List of Sections ↓
This chapter contains operators for filtering.
Filters are an important part of nearly every machine vision application. For example, mean_image can be used to smooth images, edges_sub_pix to extract sub-pixel precise edges, and fft_image to compute the fast Fourier transform of an image.
In the following, we will take a closer look at special cases: Using an image with a reduced domain as input for a filter, and problems caused by gray values outside of the image domain.
If a filter that is using a mask is applied to an image with a reduced domain, the result along the domain boundary might be surprising because gray values lying outside the boundary are used as input for the filter process. To understand this, you must consider the definition of domains in this context: For a filter, a domain defines for which input pixels output pixels must be calculated. But pixels outside the domain (which lie within the image matrix) might be used for processing.
Operators that have an image as output (most filter operators) only return results for pixels that were contained in the input domain.
For performance reasons, pixels that lie outside of the image domain become 'undefined'. These undefined pixels can differ from system to system, for example if parallelization is activated or not. It is merely guaranteed that the values are consistent if the program is executed repeatedly on systems with the same configuration. In certain cases, these 'undefined' pixels might lead to problems. Expanding the resulting image to the full domain with full_domain will lead to artifacts appearing outside of the former image domain. Another cause of problems are undefined values outside of the domain if two or more filters are applied consecutively as the filters consider the undefined values close to the domain border as well. This means that with every following filter the error increases, starting from the border to the middle. In the following, four strategies for solving those problems are presented.
Errors caused by undefined pixels can easily be prevented by, e.g., choosing a domain that is considerably larger than the image part that is actually needed and reducing the image domain (e.g., with the operators erosion_rectangle1 and reduce_domain) by half of the filter width before applying the next filter. In doing so, those parts of the image containing incorrect values are cut off and therefore will not increase the error for the next filter operation.
Another option is to set the domain exactly to the size of the interesting part within the image and then calling the operator expand_domain_gray before applying a filter. This operator copies the pixels inside of the border to the outside of the border and therefore avoids errors caused by pixels that are undefined outside of the domain. Subsequently, the domain can again be reduced to its original size. This process should be repeated for every following filter operation. Note, however, that this option increases the runtime significantly.
If runtime is not an issue, the operator full_domain can be called before applying the first filter to the image. That way, the whole image is defined as domain and undefined pixels are avoided completely.
Another possibility of getting an image without undefined pixels is by calling the operator crop_domain before applying a filter. The operator crop_domain crops the image to the size of the domain, which means that the domain then covers a complete smaller image. Note, however, that for the cropped image the coordinate system has changed in relation to the original image, which will influence all following applications depending on the image coordinate system (e.g., calculating the center of gravity).