char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold字符阈值(算子)

名称

char_thresholdchar_thresholdCharThresholdCharThresholdchar_threshold — 执行阈值分割以提取字符。

签名

char_threshold(Image, HistoRegion : Characters : Sigma, Percent : 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]

描述

char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold 的主要应用是分割明亮纸张上深色字符的单通道图像。该算子的工作原理如下:首先,针对区域 ImageImageImageImageimageimage 中的点,计算图像 HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region{} 中灰度值的直方图。为消除噪声,直方图通过给定的 SigmaSigmaSigmaSigmasigmasigma 进行平滑处理(高斯平滑)。在直方图中,背景(白纸)对应于高灰度值处的大峰值,而字符则在低灰度值处形成小峰值。与算子 binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold(方法设为 MethodMethodMethodMethodmethodmethod='smooth_histo'"smooth_histo""smooth_histo""smooth_histo""smooth_histo""smooth_histo")定位两个峰值之间的最小值不同,此处的分割阈值是根据直方图的最大值(即背景)确定的,具体条件如下: histogram[threshold] * 100.0 < histogram[maximum] * (100.0 - PercentPercentPercentPercentpercentpercent)

例如,若选择 PercentPercentPercentPercentpercentpercent = 95,则算子将定位灰度值频率不超过最大频率5%的像素。由于 char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold 假设字符比背景更暗,因此阈值搜索范围位于最大值的“左侧”。

相较于 binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold 算子,当字符对应的直方图峰值与背景峰值之间不存在明显最低值,或字符峰值完全缺失时,应采用此算子。例如当图像仅含少量字符或存在非均匀照明时,可能出现此类情况。

执行信息

参数

ImageImageImageImageimageimage (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte)

输入图像。

HistoRegionHistoRegionHistoRegionHistoRegionhistoRegionhisto_region (输入对象)  region objectHRegionHObjectHRegionHobject

计算直方图的区域。

CharactersCharactersCharactersCharacterscharacterscharacters (输出对象)  region(-array) objectHRegionHObjectHRegionHobject *

暗区(字符)。

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)

灰度值差异百分比。

默认值: 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)

计算出的阈值。

示例(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

模块

基础