dyn_threshold__ ( OrigImage, ThresholdImage : RegionDynThresh : Offset, LightDark : )

Segment an image using a local threshold.

dyn_threshold__ selects from the input image those regions in which the fulfill a threshold condition. Let g_{o} = g_{OrigImage}, and g_{m} = g_{ThresholdImage}. Then the condition for LightDark = 'light' is:

                 g_o >= g_m + Offset
For LightDark = 'dark' the condition is:
                 g_o <= g_m - Offset
Finally, for LightDark = 'equal' it is:
                 g_m - Offset <= g_o <= g_m + Offset
This means that all points in OrigImage for which the gray value is larger or equal to the gray value in ThresholdImage plus an offset are aggregated into the resulting region.

Typically, the threshold images are smoothed versions of the original image (e.g., by applying mean__, gauss__, etc.). Then the effect of dyn_threshold__ is similar to applying threshold__ to a highpass-filtered version of the original image (see highpass__).

With dyn_threshold__ objects' contours can be extracted, where the objects' size (diameter) is determined by the mask size of the lowpass filter and the amplitude of the objects' edges:

The larger the mask size is chosen, the larger the found regions get. As a rule of thumb, the mask size should be about twice the diameter of the objects to be extracted. It is important not to set the parameter Offset to zero because in this case too many small regions will be found (noise). Values between 5 and 40 are a sensible choice. The larger Offset is chosen, the smaller the extracted regions get.

All points of the input image fulfilling the above condition are stored jointly in one region. If necessary, the connected components can be obtained by calling connection.


Attention

If Offset is chosen from -1 .. 1 usually a very noisy region is generated, requiring large storage. If Offset is chosen too large (> 60, say) it may happen that no points fulfill the threshold condition (i.e., an empty region is returned). If Offset is chosen too small (< -60, say) it may happen that all points fulfill the threshold condition (i.e., a full region is returned).


Parameters

OrigImage (input_object)
image(-array) -> object : byte / int2 / int4 / real
Image to be segmented.

ThresholdImage (input_object)
image(-array) -> object : byte / int2 / int4 / real
Image containing the local thresholds.

RegionDynThresh (output_object)
region(-array) -> object
Segmented regions.

Offset (input_control)
number -> real / integer
Offset added to ThresholdImage.
Default value: 5.0
Suggested values: 1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0
Range of values: -255.0 <= Offset <= 255.0 (lin)
Minimum increment: 0.01
Recommended increment: 5
Restriction: (-255 < Offset) && (Offset < 255)

LightDark (input_control)
string -> string
Extract light or dark areas?
Default value: 'light'
List of values: 'dark', 'light', 'equal'


Example
/* Looking for regions with the diameter D */
mean__(Image:Mean:D*2+1,D*2+1:) >
dyn_threshold__(Image,Mean:Seg:5,'light':) >
connection(Seg:Regions).

Complexity

Let F be the area of the input region. Then the runtime complexity is O(F).


Result

dyn_threshold__ returns TRUE if all parameters are correct. The behaviour 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.


Possible Predecessors

mean__, smooth__, gauss__


Possible Successors

connection, select_shape, reduce_domain, select_grey__, count, dilation1, opening


Alternatives

highpass__, threshold__



Copyright © 1996-1997 MVTec Software GmbH