char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold (算子)
名称
char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold — 执行阈值分割以提取字符。
签名
Herror char_threshold(const Hobject Image, const Hobject HistoRegion, Hobject* Characters, double Sigma, double Percent, Hlong* Threshold)
Herror T_char_threshold(const Hobject Image, const Hobject HistoRegion, Hobject* Characters, const Htuple Sigma, const Htuple Percent, Htuple* Threshold)
void CharThreshold(const HObject& Image, const HObject& HistoRegion, HObject* Characters, const HTuple& Sigma, const HTuple& Percent, HTuple* Threshold)
HRegion HImage::CharThreshold(const HRegion& HistoRegion, double Sigma, const HTuple& Percent, HTuple* Threshold) const
HRegion HImage::CharThreshold(const HRegion& HistoRegion, double Sigma, double Percent, Hlong* Threshold) const
static void HOperatorSet.CharThreshold(HObject image, HObject histoRegion, out HObject characters, HTuple sigma, HTuple percent, out HTuple threshold)
HRegion HImage.CharThreshold(HRegion histoRegion, double sigma, HTuple percent, out HTuple threshold)
HRegion HImage.CharThreshold(HRegion histoRegion, double sigma, double percent, out int threshold)
def char_threshold(image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float]) -> Tuple[HObject, Sequence[int]]
def char_threshold_s(image: HObject, histo_region: HObject, sigma: float, percent: Union[int, float]) -> Tuple[HObject, int]
描述
The main application of char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold is to segment single-channel
images of dark characters on bright paper. The operator works as follows:
First, a histogram of the gray values in the image ImageImageImageImageimageimage is computed
for the points in the region HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region{}. To eliminate noise, the
histogram is smoothed with the given SigmaSigmaSigmaSigmasigmasigma (Gaussian smoothing). In
the histogram, the background (white paper) corresponds to a large peak at
high gray values, while the characters form a small peak at low gray
values. In contrast to the operator binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold
(with MethodMethodMethodMethodmethodmethod='smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo"), which locates the
minimum between the two peaks, here the threshold for the segmentation is
determined in relation to the maximum of the histogram, i.e., the background,
with the following condition:
histogram[threshold] * 100.0 < histogram[maximum] * (100.0 - PercentPercentPercentPercentpercentpercent)
For example, if you choose PercentPercentPercentPercentpercentpercent = 95 the operator locates the
gray value whose frequency is at most 5 percent of the maximum
frequency. Because char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold assumes that the characters are
darker than the background, the threshold is searched for “to the left” of
the maximum.
In comparison to binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold, this operator should be used if
there is no clear minimum between the histogram peaks corresponding to the
characters and the background, respectively, or if there is no peak
corresponding to the characters at all. This may happen, e.g., if the image
contains only few characters or in the case of a non-uniform illumination.
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 在元组级别上自动并行化。
- 在内部数据级别上自动并行化。
参数
ImageImageImageImageimageimage (输入对象) singlechannelimage(-array) → objectHImageHObjectHImageHobject (byte)
输入图像。
HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region (输入对象) region → objectHRegionHObjectHRegionHobject
Region in which the histogram is computed.
CharactersCharactersCharactersCharacterscharacterscharacters (输出对象) region(-array) → objectHRegionHObjectHRegionHobject *
Dark regions (characters).
SigmaSigmaSigmaSigmasigmasigma (输入控制) number → HTuplefloatHTupleHtuple (real) (double) (double) (double)
用于直方图高斯平滑的西格玛(Sigma)值。
默认值:
2.0
建议值:
0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
值范围:
0.0
≤
Sigma
Sigma
Sigma
Sigma
sigma
sigma
≤
50.0 (lin)
最小增量:
0.01
建议增量:
0.2
PercentPercentPercentPercentpercentpercent (输入控制) number → HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)
Percentage for the gray value difference.
默认值:
95
建议值:
90, 92, 95, 96, 97, 98, 99, 99.5, 100
值范围:
0.0
≤
Percent
Percent
Percent
Percent
percent
percent
≤
100.0 (lin)
最小增量:
0.1
建议增量:
0.5
ThresholdThresholdThresholdThresholdthresholdthreshold (输出控制) integer(-array) → HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Calculated threshold.
示例(HDevelop)
read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)
示例(C)
read_image(&Image,"letters");
char_threshold(Image,Image,&Seg,0.0,5.0,&Threshold);
connection(Seg,&Connected);
set_colored(WindowHandle,12);
set_shape(WindowHandle,"rectangle1");
disp_region(Connected,WindowHandle);
示例(HDevelop)
read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)
示例(HDevelop)
read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)
示例(HDevelop)
read_image (Image, 'letters')
char_threshold (Image, Image, Seg, 0.0, 5.0, Threshold)
connection (Seg, Connected)
可能的前趋
anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusionAnisotropicDiffusionanisotropic_diffusion,
median_imagemedian_imageMedianImageMedianImageMedianImagemedian_image,
illuminateilluminateIlluminateIlluminateIlluminateilluminate
可能的后继
connectionconnectionConnectionConnectionConnectionconnection,
select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape,
select_grayselect_graySelectGraySelectGraySelectGrayselect_gray
替代
binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold,
auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold,
gray_histogray_histoGrayHistoGrayHistoGrayHistogray_histo,
smooth_funct_1d_gausssmooth_funct_1d_gaussSmoothFunct1dGaussSmoothFunct1dGaussSmoothFunct1dGausssmooth_funct_1d_gauss,
thresholdthresholdThresholdThresholdThresholdthreshold
模块
基础