threshold threshold Threshold Threshold threshold (Operator)
Name
threshold threshold Threshold Threshold threshold
— Segment an image using global threshold.
Signature
def threshold (image : HObject, min_gray : MaybeSequence[Union[int, float, str]], max_gray : MaybeSequence[Union[int, float, str]]) -> HObject
Description
threshold threshold Threshold Threshold Threshold threshold
selects the pixels from the input image
whose gray values g fulfill the following condition:
All points of an image fulfilling the condition are returned as one
region. If more than one gray value interval is passed (tuples for
MinGray MinGray MinGray MinGray minGray min_gray
and MaxGray MaxGray MaxGray MaxGray maxGray max_gray
), one separate region is
returned for each interval. For vector field images, the threshold is
not applied to gray values but to the lengths of the vectors.
The parameters MinGray MinGray MinGray MinGray minGray min_gray
and MaxGray MaxGray MaxGray MaxGray maxGray max_gray
can be set to
'min' "min" "min" "min" "min" "min" or 'max' "max" "max" "max" "max" "max" in order to leave bottom and top limits,
respectively, open.
Attention
The usage of MinGray MinGray MinGray MinGray minGray min_gray
and MaxGray MaxGray MaxGray MaxGray maxGray max_gray
can be affected by the
input image type.
For images of type integer, floating point values in MinGray MinGray MinGray MinGray minGray min_gray
and
MaxGray MaxGray MaxGray MaxGray maxGray max_gray
are truncated. For images of type real or vector
field, floating point precision will be used for MinGray MinGray MinGray MinGray minGray min_gray
and
MaxGray MaxGray MaxGray MaxGray maxGray max_gray
, if they are of type double.
Execution Information
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Automatically parallelized on tuple level.
Automatically parallelized on internal data level.
Parameters
Image Image Image Image image image
(input_object) singlechannelimage(-array) →
object HImage HObject HImage Hobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / vector_field)
Input image.
Region Region Region Region region region
(output_object) region(-array) →
object HRegion HObject HRegion Hobject *
Segmented region.
MinGray MinGray MinGray MinGray minGray min_gray
(input_control) number(-array) →
HTuple MaybeSequence[Union[int, float, str]] HTuple Htuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)
Lower threshold for the gray values or 'min' "min" "min" "min" "min" "min" .
Default value: 128.0
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0, 'min' "min" "min" "min" "min" "min"
MaxGray MaxGray MaxGray MaxGray maxGray max_gray
(input_control) number(-array) →
HTuple MaybeSequence[Union[int, float, str]] HTuple Htuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)
Upper threshold for the gray values or 'max' "max" "max" "max" "max" "max" .
Default value: 255.0
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0, 'max' "max" "max" "max" "max" "max"
Restriction: MaxGray >= MinGray
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)
Example (C)
read_image(&Image,"fabrik");
sobel_amp(Image,&EdgeAmp,"sum_abs",3);
threshold(EdgeAmp,&Seg,50.0,255.0);
skeleton(Seg,&Rand);
connection(Rand,&Lines);
select_shape(Lines,&Edges,"area","and",10.0,1000000.0);
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)
Example (HDevelop)
read_image(Image,'fabrik')
sobel_dir(Image,EdgeAmp,EdgeDir,'sum_abs',3)
threshold(EdgeAmp,Seg,50,255)
skeleton(Seg,Rand)
connection(Rand,Lines)
select_shape(Lines,Edges,'area','and',10,1000000)
Complexity
Let A be the area of the input region. Then the runtime
complexity is O(A).
Result
threshold threshold Threshold Threshold Threshold threshold
returns 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' "no_object_result" "no_object_result" "no_object_result" "no_object_result" "no_object_result" , 'empty_region_result' "empty_region_result" "empty_region_result" "empty_region_result" "empty_region_result" "empty_region_result" , and
'store_empty_region' "store_empty_region" "store_empty_region" "store_empty_region" "store_empty_region" "store_empty_region" with set_system set_system SetSystem SetSystem SetSystem set_system
.
If necessary, an exception is raised.
Possible Predecessors
histo_to_thresh histo_to_thresh HistoToThresh HistoToThresh HistoToThresh histo_to_thresh
,
min_max_gray min_max_gray MinMaxGray MinMaxGray MinMaxGray min_max_gray
,
sobel_amp sobel_amp SobelAmp SobelAmp SobelAmp sobel_amp
,
binomial_filter binomial_filter BinomialFilter BinomialFilter BinomialFilter binomial_filter
,
gauss_filter gauss_filter GaussFilter GaussFilter GaussFilter gauss_filter
,
reduce_domain reduce_domain ReduceDomain ReduceDomain ReduceDomain reduce_domain
,
fill_interlace fill_interlace FillInterlace FillInterlace FillInterlace fill_interlace
Possible Successors
connection connection Connection Connection Connection connection
,
dilation1 dilation1 Dilation1 Dilation1 Dilation1 dilation1
,
erosion1 erosion1 Erosion1 Erosion1 Erosion1 erosion1
,
opening opening Opening Opening Opening opening
,
closing closing Closing Closing Closing closing
,
rank_region rank_region RankRegion RankRegion RankRegion rank_region
,
shape_trans shape_trans ShapeTrans ShapeTrans ShapeTrans shape_trans
,
skeleton skeleton Skeleton Skeleton Skeleton skeleton
Alternatives
class_2dim_sup class_2dim_sup Class2dimSup Class2dimSup Class2dimSup class_2dim_sup
,
hysteresis_threshold hysteresis_threshold HysteresisThreshold HysteresisThreshold HysteresisThreshold hysteresis_threshold
,
dyn_threshold dyn_threshold DynThreshold DynThreshold DynThreshold dyn_threshold
,
binary_threshold binary_threshold BinaryThreshold BinaryThreshold BinaryThreshold binary_threshold
,
char_threshold char_threshold CharThreshold CharThreshold CharThreshold char_threshold
,
auto_threshold auto_threshold AutoThreshold AutoThreshold AutoThreshold auto_threshold
,
dual_threshold dual_threshold DualThreshold DualThreshold DualThreshold dual_threshold
See also
zero_crossing zero_crossing ZeroCrossing ZeroCrossing ZeroCrossing zero_crossing
,
background_seg background_seg BackgroundSeg BackgroundSeg BackgroundSeg background_seg
,
regiongrowing regiongrowing Regiongrowing Regiongrowing Regiongrowing regiongrowing
Module
Foundation