Skip to content

histo_to_threshhisto_to_threshHistoToThreshHistoToThreshhisto_to_threshT_histo_to_thresh🔗

Short description🔗

histo_to_threshhisto_to_threshHistoToThreshHistoToThreshhisto_to_threshT_histo_to_thresh — Determine gray value thresholds from a histogram.

Signature🔗

histo_to_thresh( histogram Histogramm, number Sigma, out integer MinThresh, out integer MaxThresh )histo_to_thresh( : : Histogramm, Sigma : MinThresh, MaxThresh )void HistoToThresh( const HTuple& Histogramm, const HTuple& Sigma, HTuple* MinThresh, HTuple* MaxThresh )static void HOperatorSet.HistoToThresh( HTuple histogramm, HTuple sigma, out HTuple minThresh, out HTuple maxThresh )def histo_to_thresh( histogramm: Sequence[Union[int, float]], sigma: float ) -> Tuple[Sequence[int], Sequence[int]]

Herror T_histo_to_thresh( const Htuple Histogramm, const Htuple Sigma, Htuple* MinThresh, Htuple* MaxThresh )

Description🔗

histo_to_threshHistoToThresh determines gray value thresholds from a histogram for a segmentation of an image using thresholdThreshold. The thresholds returned are 0, the maximum gray value in the histogram, and all minima extracted from the histogram. Before the thresholds are determined, the histogram is smoothed with a Gaussian smoothing function.

histo_to_threshHistoToThresh can process the absolute and relative histograms that are returned by gray_histoGrayHisto. Note, however, that here only byte images should be used, because otherwise the returned thresholds cannot easily be transformed to the thresholds for the actual image. For images of type uint2, the histograms should be computed with gray_histo_absGrayHistoAbs since this facilitates a simple transformation of the thresholds by simply multiplying the thresholds with the quantization selected in gray_histo_absGrayHistoAbs. For uint2 images, it is important to ensure that the quantization must be chosen in such a manner that the histogram still contains salient information. For example, a 640 x 480 image with 16 bits per pixel gray value resolution contains on average only \(307200 / 65536 = 4.7\) entries per histogram bin, i.e., the histogram is too sparsely populated to derive any useful statistics from it. To be able to extract useful thresholds from such a histogram, Sigmasigmasigma would have to be set to an extremely large value, which would lead to very high run times and numerical problems. The quantization in gray_histo_absGrayHistoAbs should therefore normally be chosen such that the histogram contains a maximum of 1024 entries. Hence, for images with more than 10 bits per pixel, the quantization must be chosen greater than 1. The histogram returned by gray_histo_absGrayHistoAbs should furthermore be restricted to the parts that contain salient information. For example, for an image with 12 bits per pixel, the quantization should be set to 4. Only the first 1024 entries of the computed histogram (which contains 16384 entries in this example) should be passed to histo_to_threshHistoToThresh. Finally, MinThreshminThreshmin_thresh must be multiplied by 4 (i.e., the quantization), while MaxThreshmaxThreshmax_thresh must be multiplied by 4 and increased by 3 (i.e., the quantization minus 1).

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Histogrammhistogrammhistogramm (input_control) histogram-array → (integer / real)(integer / real)HTuple (Hlong / double)HTuple (int / long / double)Sequence[Union[int, float]]Htuple (Hlong / double)

Gray value histogram.

Sigmasigmasigma (input_control) number → (real)(real)HTuple (double)HTuple (double)floatHtuple (double)

Sigma for the Gaussian smoothing of the histogram.

Default: 2.02.0
Suggested values: 0.5, 1.0, 2.0, 3.0, 4.0, 5.00.5, 1.0, 2.0, 3.0, 4.0, 5.0
Value range: 0.5 ≤ Sigma ≤ 30.0 (lin)
Minimum increment: 0.01
Recommended increment: 0.2

MinThreshminThreshmin_thresh (output_control) integer-array → (integer)(integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Minimum thresholds.

MaxThreshmaxThreshmax_thresh (output_control) integer-array → (integer)(integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Maximum thresholds.

Example🔗

(HDevelop)


* Calculate thresholds from a byte image and threshold the image.
gray_histo (Image, Image, AbsoluteHisto, RelativeHisto)
histo_to_thresh (AbsoluteHisto, 4, MinThresh, MaxThresh)
threshold (Image, Region, MinThresh, MaxThresh)

* Calculate thresholds from a 12 bit uint2 image and threshold the image.
gray_histo_abs (Image, Image, 4, AbsoluteHisto)
AbsoluteHisto := AbsoluteHisto[0:1023]
histo_to_thresh (AbsoluteHisto, 16, MinThresh, MaxThresh)
MinThresh := MinThresh*4
MaxThresh := MaxThresh*4+3
threshold (Image, Region, MinThresh, MaxThresh)

Combinations with other operators🔗

Combinations

Possible predecessors

gray_histoGrayHisto

Possible successors

thresholdThreshold

See also

auto_thresholdAutoThreshold, binary_thresholdBinaryThreshold, char_thresholdCharThreshold

Module🔗

Foundation