histo_to_threshT_histo_to_threshHistoToThreshHistoToThreshhisto_to_thresh (Operator)

Name

histo_to_threshT_histo_to_threshHistoToThreshHistoToThreshhisto_to_thresh — Determine gray value thresholds from a histogram.

Signature

histo_to_thresh( : : Histogramm, Sigma : MinThresh, MaxThresh)

Herror T_histo_to_thresh(const Htuple Histogramm, const Htuple Sigma, Htuple* MinThresh, Htuple* 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]]

Description

histo_to_threshhisto_to_threshHistoToThreshHistoToThreshHistoToThreshhisto_to_thresh determines gray value thresholds from a histogram for a segmentation of an image using thresholdthresholdThresholdThresholdThresholdthreshold. 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_threshhisto_to_threshHistoToThreshHistoToThreshHistoToThreshhisto_to_thresh can process the absolute and relative histograms that are returned by gray_histogray_histoGrayHistoGrayHistoGrayHistogray_histo. 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_absgray_histo_absGrayHistoAbsGrayHistoAbsGrayHistoAbsgray_histo_abs since this facilitates a simple transformation of the thresholds by simply multiplying the thresholds with the quantization selected in gray_histo_absgray_histo_absGrayHistoAbsGrayHistoAbsGrayHistoAbsgray_histo_abs. 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, SigmaSigmaSigmaSigmasigmasigma 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_absgray_histo_absGrayHistoAbsGrayHistoAbsGrayHistoAbsgray_histo_abs 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_absgray_histo_absGrayHistoAbsGrayHistoAbsGrayHistoAbsgray_histo_abs 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_threshhisto_to_threshHistoToThreshHistoToThreshHistoToThreshhisto_to_thresh. Finally, MinThreshMinThreshMinThreshMinThreshminThreshmin_thresh must be multiplied by 4 (i.e., the quantization), while MaxThreshMaxThreshMaxThreshMaxThreshmaxThreshmax_thresh must be multiplied by 4 and increased by 3 (i.e., the quantization minus 1).

Execution Information

Parameters

HistogrammHistogrammHistogrammHistogrammhistogrammhistogramm (input_control)  histogram-array HTupleSequence[Union[int, float]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Gray value histogram.

SigmaSigmaSigmaSigmasigmasigma (input_control)  number HTuplefloatHTupleHtuple (real) (double) (double) (double)

Sigma for the Gaussian smoothing of the histogram.

Default value: 2.0

Suggested values: 0.5, 1.0, 2.0, 3.0, 4.0, 5.0

Typical range of values: 0.5 ≤ Sigma Sigma Sigma Sigma sigma sigma ≤ 30.0 (lin)

Minimum increment: 0.01

Recommended increment: 0.2

MinThreshMinThreshMinThreshMinThreshminThreshmin_thresh (output_control)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Minimum thresholds.

MaxThreshMaxThreshMaxThreshMaxThreshmaxThreshmax_thresh (output_control)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (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)

Possible Predecessors

gray_histogray_histoGrayHistoGrayHistoGrayHistogray_histo

Possible Successors

thresholdthresholdThresholdThresholdThresholdthreshold

See also

auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold, binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold, char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold

Module

Foundation