Threshold operator for signed images.
::dual_threshold segments the input image into a region with gray values >= Threshold (``positive'' regions) and a region with gray values <= -Threshold (``negative'' regions). ``Positive'' or ``negative'' regions having a size of less than MinSize are suppressed, as well as regions whose maximum gray value is less than MinGray in absolute value.
The segmentation performed is not complete, i.e., the ``positive'' and ``negative'' regions together do not necessarily cover the entire image: Areas with a gray value between -Threshold and Threshold, -MinGray and MinGray respectively, are not taken into account.
::dual_threshold is usually called after applying a Laplace operator (::laplace, ::derivate_gauss or ::diff_of_gauss) or the difference of two images (::sub_image) to an image.
The zero crossings of a Laplace image correspond to edges in an image, and are the separating regions of the ``positive'' and ``negative'' regions in the Laplace image. They can be determined by calling ::dual_threshold with Threshold = 1. The parameter MinGray controls the noise invariance, while MinSize controls the resolution of the edge detection.
Using byte images only the positive part of the operator is applied. Therefore ::dual_threshold behaves like a standard threshold operator (::threshold) with successive ::connection and ::select_gray.
|
Image (input_object) |
image(-array) -> Hobject: HImage(Array) ( byte / int2 / int4 / real ) |
| Input Laplace image. | |
|
RegionCrossings (output_object) |
region-array -> Hobject * : HRegionArray |
| ``Positive'' and ``negative'' regions. | |
|
MinSize (input_control) |
integer -> HTuple.long |
| Regions smaller than MinSize are suppressed. | |
| Default value: 20 | |
| Suggested values: 0, 10, 20, 50, 100, 200, 500, 1000 | |
| Typical range of values: 0 <= MinSize <= 10000 (lin) | |
| Minimum increment: 1 | |
|
Recommended increment: 10 | |
|
MinGray (input_control) |
real -> HTuple.double |
| Regions whose maximum absolute gray value is smaller than MinGray are suppressed. | |
| Default value: 5.0 | |
| Suggested values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0 | |
| Typical range of values: 0.001 <= MinGray <= 10000.0 (lin) | |
| Minimum increment: 1.0 | |
|
Recommended increment: 10.0 | |
| Restriction: MinGray > 0 | |
|
Threshold (input_control) |
real -> HTuple.double |
| Regions which have a gray value larger than Threshold (or smaller than -Threshold) are suppressed. | |
| Default value: 2.0 | |
| Suggested values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0 | |
| Typical range of values: 0.001 <= Threshold <= 10000.0 (lin) | |
| Minimum increment: 1.0 | |
|
Recommended increment: 10.0 | |
| Restriction: (Threshold >= 1) && (Threshold <= MinGray) | |
#include <iostream.h>
#include "HalconCpp.h"
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " 'image' " << endl;
return (-1);
}
HImage image (argv[1]),
laplace;
HWindow win;
HRegionArray region,
nulldg;
image.Display (win);
laplace = image.DiffOfGauss (2.0, 1.6);
region = laplace.DualThreshold (20, 2, 1);
nulldg = region.Complement ();
laplace.Display (win); win.Click ();
region.Display (win); win.Click ();
nulldg.Display (win); win.Click ();
return (0);
}
::dual_threshold returns H_MSG_TRUE if all parameters are correct. The behavior with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result', 'empty_region_result', and 'store_empty_region' with ::set_system. If necessary, an exception is raised.
::min_max_gray, ::sobel_amp, ::gauss_image, ::reduce_domain, ::diff_of_gauss, ::sub_image, ::derivate_gauss
::connection, ::dilation1, ::erosion1, ::opening, ::closing, ::rank_region, ::shape_trans, ::skeleton
::threshold, ::connection, ::select_shape, ::select_gray, ::dyn_threshold, ::check_difference
::laplace, ::diff_of_gauss, ::expand_region
Region processing