expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayexpand_domain_gray (算子)

名称

expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayexpand_domain_gray — 扩大图像的域,并在扩大的域中设置灰度值。

签名

expand_domain_gray(InputImage : ExpandedImage : ExpansionRange : )

Herror expand_domain_gray(const Hobject InputImage, Hobject* ExpandedImage, const Hlong ExpansionRange)

Herror T_expand_domain_gray(const Hobject InputImage, Hobject* ExpandedImage, const Htuple ExpansionRange)

void ExpandDomainGray(const HObject& InputImage, HObject* ExpandedImage, const HTuple& ExpansionRange)

HImage HImage::ExpandDomainGray(Hlong ExpansionRange) const

static void HOperatorSet.ExpandDomainGray(HObject inputImage, out HObject expandedImage, HTuple expansionRange)

HImage HImage.ExpandDomainGray(int expansionRange)

def expand_domain_gray(input_image: HObject, expansion_range: int) -> HObject

描述

expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayExpandDomainGrayexpand_domain_gray expands the border gray values of the domain outwards. The width of the expansion is set by the parameter ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range, which describes the expansion radius in pixels. All filters in HALCON which are applied to the image domain also include the gray values of a certain number of pixels, depending on the filter size, outside of the image domain in their calculation. This may lead to undesirable side effects especially in the border region of the domain. For example, if the foreground (domain) and the background of the image differ strongly in brightness, the result of a filter operation may lead to undesired darkening or brightening at the border of the domain. In order to avoid this drawback, the domain is artificially expanded by expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayExpandDomainGrayexpand_domain_gray in a preliminary stage, copying the gray values of the border pixels to the outside of the domain. In addition, the domain itself is also expanded to reflect the newly set pixels. Therefore, in many cases it is reasonable to reduce the domain again (reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain or change_domainchange_domainChangeDomainChangeDomainChangeDomainchange_domain) after using expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayExpandDomainGrayexpand_domain_gray and call the filter operation afterwards. ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range should be set to a value high enough to make sure the whole region including its dilatation through the filter mask has initialized values. Usually this leads to ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range values of half the filter length or greater. In combination with the filter mean_imagemean_imageMeanImageMeanImageMeanImagemean_image on images of type real we recommend to determine the value for ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range as shown in the example below. For speed reasons this filter uses the values from pixels within the smallest rectangle around the dilated region.

注意

请注意,若使用域缩减后的图像作为输入,滤波器算子可能会返回意外结果。请参阅 滤波器 一章

执行信息

参数

InputImageInputImageInputImageInputImageinputImageinput_image (输入对象)  (multichannel-)image(-array) objectHImageHObjectHImageHobject (byte / int1 / int2 / uint2 / int4 / real)

Input image with domain to be expanded.

ExpandedImageExpandedImageExpandedImageExpandedImageexpandedImageexpanded_image (输出对象)  image(-array) objectHImageHObjectHImageHobject * (byte / int1 / int2 / uint2 / int4 / real)

Output image with new gray values in the expanded domain.

ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Radius of the gray value expansion, measured in pixels.

默认值: 2

建议值: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16

限制: ExpansionRange >= 1

示例(HDevelop)

read_image(Fabrik, 'fabrik')
gen_rectangle2(Rectangle_Label,243,320,-1.55,62,28)
reduce_domain(Fabrik, Rectangle_Label, Fabrik_Label)
* Character extraction without gray value expansion:
MaskSize := 31
mean_image(Fabrik_Label,Label_Mean_normal,MaskSize, MaskSize)
dyn_threshold(Fabrik_Label,Label_Mean_normal,Characters_normal,10,'dark')
dev_display(Fabrik)
dev_display(Characters_normal)
* The characters in the border region are not extracted !
stop()
* Character extraction with gray value expansion:
get_domain (Fabrik_Label, Domain)
expand_domain_gray (Fabrik_Label, Expanded_Fabrik_Label, MaskSize)
get_domain (Expanded_Fabrik_Label, Expanded_Domain)
shape_trans (Expanded_Domain, RegionRect, 'rectangle1')
difference (RegionRect, Expanded_Domain, Region_Difference)
overpaint_region (Expanded_Fabrik_Label, Region_Difference, 0, 'fill')
reduce_domain (Expanded_Fabrik_Label, Domain, Reduced_Expanded_Fabrik_Label)
mean_image (Reduced_Expanded_Fabrik_Label, Label_Mean_Expanded,\
MaskSize, MaskSize)
dyn_threshold(Fabrik_Label,Label_Mean_Expanded,\
Characters_expanded,10,'dark')
dev_display(Fabrik)
dev_display(Characters_expanded)

复杂度

Let L the perimeter of the domain. Then the runtime complexity is approximately O(L)*ExpansionRangeExpansionRangeExpansionRangeExpansionRangeexpansionRangeexpansion_range

结果

expand_domain_grayexpand_domain_grayExpandDomainGrayExpandDomainGrayExpandDomainGrayexpand_domain_gray 在所有参数正确时返回 2 ( H_MSG_TRUE )。如有必要,则抛出异常。

可能的前趋

reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain

可能的后继

reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, mean_imagemean_imageMeanImageMeanImageMeanImagemean_image, dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold

另见

reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, mean_imagemean_imageMeanImageMeanImageMeanImagemean_image

模块

基础