Pretty much any image processing application uses filters of some sort. Noise reduction, edge detection or texture analysis are the most obvious examples, but even higher level algorithms like pattern matching use them internally. Mastering them makes application development much more fun.
In essence filters calculate a value based on the intensity of a certain neighborhood of pixels. The size of that neighborhood can be adjusted, and in HALCON this is typically done through parameters like MaskWidth/MaskHeight, Sigma or Alpha. The larger the filter the more smoothing is applied to the image, which can help reduce or eliminate unwanted noise or texture in the image.
In the example below we would like to detect the edges of the rectangular pads.
Easy, right? Just us an edge filter, for example
edges_sub_pix(Image, Edges, ‘canny’, 1, 10, 20)
Well, what looks so obvious from a distance looks much harder once you look at the local edge profile – it seems to contain nothing but noise. In fact this is what you get, if you use the default value for Alpha (=1)
Don’t give up, however, the fix could not be easier, if you know what to adjust. Just use a larger filter:
edges_sub_pix(ImageReduced, Edges, ‘canny’, 5, 10, 20)
Magic? No. This adjustment has the effect that the edge profile is smoothed to a higher degree and the filter is made sensitive to a gray value transition across a larger distance as can be seen in the 1D profile.
In general the filter size should be adjusted to match the extent of the gray value transition of an edge. This will give you optimal noise reduction with best sensitivity to the edge you want to detect. Note that as you increase the filter size, the edge amplitude decreases, and you will typically need to lower the detection threshold as you increase Alpha (last two parameters of edges_sub_pix).
The concept of matching the filter size to the scale of the feature you want to detect does not just apply to edges. One of the favorite operators is lines_gauss. We encourage you to use it for example, scratch detection. Keep this section in mind for adjusting the filter size!