[go: up one dir, main page]

CN102831579B - Text enhancement method and device, text extraction method and device - Google Patents

Text enhancement method and device, text extraction method and device Download PDF

Info

Publication number
CN102831579B
CN102831579B CN201110172095.1A CN201110172095A CN102831579B CN 102831579 B CN102831579 B CN 102831579B CN 201110172095 A CN201110172095 A CN 201110172095A CN 102831579 B CN102831579 B CN 102831579B
Authority
CN
China
Prior art keywords
stroke
original
text
color value
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201110172095.1A
Other languages
Chinese (zh)
Other versions
CN102831579A (en
Inventor
潘屹峰
胜山裕
孙俊
直井聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to CN201110172095.1A priority Critical patent/CN102831579B/en
Priority to JP2012132919A priority patent/JP5939047B2/en
Publication of CN102831579A publication Critical patent/CN102831579A/en
Application granted granted Critical
Publication of CN102831579B publication Critical patent/CN102831579B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Analysis (AREA)
  • Character Input (AREA)

Abstract

本发明实施例公开了文本增强方法及装置、文本提取方法及装置,所述文本增强方法包括:获取包括一行文本的原始图像;依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到原始图像的滤波后的更新亮度值或/和颜色值,邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与原始图像对应的文本增强图像。通过本发明实施例,可以增强原始图像中包括的文本,以使后续针对该文本增强图像进行的文本提取更为精确和准确。

The embodiment of the present invention discloses a text enhancement method and device, and a text extraction method and device. The text enhancement method includes: acquiring an original image including a line of text; The direct difference degree and indirect difference degree of each neighboring pixel point, the stroke two-dimensional filtering is performed on the original brightness value or/and color value of each original pixel point to obtain the updated brightness value or/and color value of the original image after filtering , the range of the neighborhood set is a square with the original pixel as the center and the side length is w, and the w is smaller than the height of the original image; the updated brightness value or/and color value after the filtering are respectively replaced by the corresponding The original brightness value or/and color value, so as to generate a text-enhanced image corresponding to the original image. Through the embodiments of the present invention, the text contained in the original image can be enhanced, so that the subsequent text extraction for the text-enhanced image is more precise and accurate.

Description

文本增强方法及装置、文本提取方法及装置Text enhancement method and device, text extraction method and device

技术领域technical field

本发明一般地涉及图像处理技术领域,尤其是文本增强方法及装置、文本提取方法及装置。The present invention generally relates to the technical field of image processing, in particular to a text enhancement method and device, and a text extraction method and device.

背景技术Background technique

在播放视频的过程中,或者在欣赏图像时,视频或者图像中往往会包含文本说明,例如,是对一段视频的发生时间和地点的说明,或者对于图像的解说等。而这些文本内容因为与视频或图像密切相关,所以提取视频或图像中的文本就成为至关重要的技术。During the process of playing a video, or when appreciating an image, the video or the image often contains a text description, for example, a description of the time and place where a video occurs, or an explanation of the image. Because these text contents are closely related to videos or images, extracting text from videos or images has become a crucial technology.

现有技术中进行视频或图像的文本提取方法,可以以二值化、边缘颜色聚类和检测技术为基础,针对图像或视频中的文本进行提取。The text extraction method of video or image in the prior art can be based on binarization, edge color clustering and detection technology to extract text in the image or video.

但是,现有技术在进行文本提取时,由于视频或图像中可能会存在过多的噪音,图像或视频模糊,甚至如果一段视频中存在光照变化,都会使得图像或视频中的文本与背景边界模糊,或者文本内容本身不够清楚,从而影响文本提取的效果。However, when the prior art extracts text, there may be too much noise in the video or image, the image or video is blurred, and even if there is a lighting change in a video, the boundary between the text and the background in the image or video will be blurred , or the text content itself is not clear enough, thus affecting the effect of text extraction.

因此,如何能对原始图像或视频中的文本进行增强处理,以增强图像或视频中的文本,进一步的优化文本提取的效果,已成为现有技术中亟待解决的问题。Therefore, how to enhance the text in the original image or video, so as to enhance the text in the image or video, and further optimize the effect of text extraction, has become an urgent problem to be solved in the prior art.

发明内容Contents of the invention

有鉴于此,本发明实施例提供了文本增强方法及装置、文本提取方法及装置,能够对包括一行文本的原始图像中的文本进行增强处理,使得原始图像中的文本更加明显,进一步还可以优化文本提取的效果。In view of this, the embodiment of the present invention provides a text enhancement method and device, and a text extraction method and device, which can enhance the text in the original image including a line of text, so that the text in the original image is more obvious, and can further optimize The effect of text extraction.

根据本发明实施例的一个方面,提供一种文本增强方法,包括:获取包括一行文本的原始图像;依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。According to an aspect of an embodiment of the present invention, a text enhancement method is provided, including: acquiring an original image including a line of text; degree of difference and degree of indirect difference, performing stroke two-dimensional filtering on the original brightness value or/and color value of each original pixel to obtain the filtered updated brightness value or/and color value of the original image, the The range of the neighborhood set is a square centered on the original pixel point and the side length is w, and the w is smaller than the height of the original image; the updated brightness value or/and color value after the filtering are respectively replaced by the corresponding The original brightness value or/and color value to generate a text-enhanced image corresponding to the original image.

根据本发明实施例的另一个方面,提供一种文本增强装置,包括:获取模块,用于获取包括一行文本的原始图像;滤波模块,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;替换模块,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。According to another aspect of the embodiments of the present invention, there is provided a text enhancement device, including: an acquisition module, configured to acquire an original image including a line of text; a filtering module, configured to filter any original pixel in the original image to The direct difference degree and indirect difference degree of each neighborhood pixel in its neighborhood set, and perform stroke two-dimensional filtering on the original brightness value or/and color value of each original pixel point to obtain the filtered original image Update the brightness value or/and color value, the scope of the neighborhood set is a square centered on the original pixel point and the side length is w, and the w is less than the height of the original image; the replacement module is used to convert the The filtered updated brightness value or/and color value respectively replaces the corresponding original brightness value or/and color value, so as to generate a text-enhanced image corresponding to the original image.

根据本发明实施例的再一方面,提供一种文本提取方法,包括:获取包括一行文本的原始图像;依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值;所述邻域集的范围为以原始像素点为中心且边长为w的正方形;所述w小于所述原始图像的高度;将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;提取所述文本增强图像中的文本。According to yet another aspect of the embodiments of the present invention, a text extraction method is provided, including: acquiring an original image including a line of text; direct difference degree and indirect difference degree, performing two-dimensional stroke filtering on the original luminance value or/and color value of each original pixel, so as to obtain the updated luminance value or/and color value of the original image after filtering; The range of the neighborhood set is a square centered on the original pixel point and the side length is w; the w is smaller than the height of the original image; the updated brightness value or/and color value after the filtering are respectively replaced by the corresponding The original brightness value or/and color value to generate a text-enhanced image corresponding to the original image; extract text in the text-enhanced image.

根据本发明实施例的再一方面,提供一种文本提取装置,包括:获取模块,用于获取包括一行文本的原始图像;滤波模块,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;替换模块,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;提取模块,用于提取所述文本增强图像中的文本。According to yet another aspect of the embodiments of the present invention, a text extraction device is provided, including: an acquisition module, configured to acquire an original image including a line of text; a filtering module, configured to obtain The direct difference degree and indirect difference degree of each neighborhood pixel in its neighborhood set, and perform stroke two-dimensional filtering on the original brightness value or/and color value of each original pixel point to obtain the filtered original image Update the brightness value or/and color value, the scope of the neighborhood set is a square centered on the original pixel point and the side length is w, and the w is less than the height of the original image; the replacement module is used to convert the The filtered update brightness value or/and color value respectively replaces the corresponding original brightness value or/and color value to generate a text-enhanced image corresponding to the original image; an extraction module is used to extract the text-enhanced image text in .

另外,根据本发明的另一方面,还提供了一种存储介质。所述存储介质包括机器可读的程序代码,当在信息处理设备上执行所述程序代码时,所述程序代码使得所述信息处理设备执行根据本发明的上述文本增强方法及文本提取方法。In addition, according to another aspect of the present invention, a storage medium is also provided. The storage medium includes machine-readable program code. When the program code is executed on the information processing device, the program code causes the information processing device to execute the above text enhancement method and text extraction method according to the present invention.

此外,根据本发明的再一方面,还提供了一种程序产品。所述程序产品包括机器可执行的指令,当在信息处理设备上执行所述指令时,所述指令使得所述信息处理设备执行根据本发明的上述文本增强方法及文本提取方法。In addition, according to still another aspect of the present invention, a program product is also provided. The program product includes machine-executable instructions. When the instructions are executed on the information processing device, the instructions cause the information processing device to execute the above text enhancement method and text extraction method according to the present invention.

根据本发明实施例的上述一种文本增强方法,得到的文本增强图像中的像素点中的文本笔画进行了增强,增强了笔画内部像素的一致性且加深文本与背景差异度,即增强了原始图像中包括的文本,从而可以使后续针对该文本增强图像进行的文本提取更为精确和准确。According to the above-mentioned text enhancement method of the embodiment of the present invention, the text strokes in the pixels in the obtained text enhancement image are enhanced, the consistency of the internal pixels of the strokes is enhanced and the difference between the text and the background is deepened, that is, the original The text included in the image, so that the subsequent text extraction for the text-enhanced image can be more precise and accurate.

根据本发明实施例的上述一种文本提取方法,基于得到的文本增强图像进行文本提取,不仅使得文本提取的结果更为精确和准确,也因为降低了文本提取的复杂度,所以提升了文本提取的效率。According to the above text extraction method of the embodiment of the present invention, text extraction is performed based on the obtained text enhanced image, which not only makes the result of text extraction more precise and accurate, but also reduces the complexity of text extraction, thus improving the text extraction efficiency. s efficiency.

在下面的说明书部分中给出本发明实施例的其他方面,其中,详细说明用于充分地公开本发明实施例的优选实施例,而不对其施加限定。Further aspects of the embodiments of the present invention are given in the description section below, wherein the detailed description serves to fully disclose preferred embodiments of the embodiments of the present invention without imposing limitations thereon.

附图说明Description of drawings

下面结合具体的实施例,并参照附图,对本发明实施例的上述和其它目的和优点做进一步的描述。在附图中,相同的或对应的技术特征或部件将采用相同或对应的附图标记来表示。The above and other objectives and advantages of the embodiments of the present invention will be further described below in conjunction with specific embodiments and with reference to the accompanying drawings. In the drawings, the same or corresponding technical features or components will be indicated by the same or corresponding reference numerals.

图1是示出作为本发明实施例提供的第一种文本增强方法的流程图;Fig. 1 is a flowchart showing the first text enhancement method provided as an embodiment of the present invention;

图2是示出作为第一种文本增强方法中步骤S102的流程图;Fig. 2 is a flowchart showing step S102 as the first text enhancement method;

图3是示出作为本发明实施例提供的第二种文本增强方法的流程图;Fig. 3 is a flowchart showing a second text enhancement method provided as an embodiment of the present invention;

图4是示出作为第二种文本增强方法中步骤S302的一种流程图;Fig. 4 is a flow chart showing step S302 as the second text enhancement method;

图5是示出作为第二种文本增强方法中步骤S302的另一种流程图;Fig. 5 is another flow chart showing step S302 as the second text enhancement method;

图6是示出作为第二种文本增强方法中步骤S302的再一种流程图;Fig. 6 is another flow chart showing step S302 in the second text enhancement method;

图7是示出作为第二种文本增强方法中步骤S302的又一种流程图;Fig. 7 is another flow chart showing step S302 as the second text enhancement method;

图8是示出作为第二种文本增强方法中步骤S304的流程图;FIG. 8 is a flow chart showing step S304 as a second text enhancement method;

图9是示出作为本发明实施例提供的第一种文本增强装置的示意图;Fig. 9 is a schematic diagram showing a first text enhancement device provided as an embodiment of the present invention;

图10是示出作为第一种文本增强装置中滤波模块902的示意图;FIG. 10 is a schematic diagram showing a filtering module 902 in the first text enhancement device;

图11是示出作为本发明实施例提供的第二种文本增强装置的示意图;Fig. 11 is a schematic diagram showing a second text enhancement device provided as an embodiment of the present invention;

图12是示出作为第二种文本增强装置中笔画极性估计模块1101的示意图;Fig. 12 is a schematic diagram showing the stroke polarity estimation module 1101 in the second text enhancement device;

图13是示出作为第二种文本增强装置中笔画极性估计模块1101的另一示意图;FIG. 13 is another schematic diagram showing the stroke polarity estimation module 1101 in the second text enhancement device;

图14是示出作为第二种文本增强装置中笔画极性估计模块1101的再一示意图;Fig. 14 is another schematic diagram showing the stroke polarity estimation module 1101 in the second text enhancement device;

图15是示出作为第二种文本增强装置中笔画极性估计模块1101的又一示意图;Fig. 15 is another schematic diagram showing the stroke polarity estimation module 1101 in the second text enhancement device;

图16是示出作为第二种文本增强装置中判断模块1102的示意图;FIG. 16 is a schematic diagram showing a judgment module 1102 in the second text enhancement device;

图17是示出作为本发明实施例提供的文本提取方法的流程图;Fig. 17 is a flowchart illustrating a text extraction method provided as an embodiment of the present invention;

图18是示出作为本发明实施例提供的文本提取装置的示意图;Fig. 18 is a schematic diagram showing a text extraction device provided as an embodiment of the present invention;

图19是示出作为本发明的实施例中所采用的信息处理设备的个人计算机的示例性结构的框图。FIG. 19 is a block diagram showing an exemplary structure of a personal computer as an information processing device employed in an embodiment of the present invention.

具体实施方式Detailed ways

下面参照附图来说明本发明的实施例。Embodiments of the present invention will be described below with reference to the drawings.

具体的,参见图1,本发明实施例提供了第一种文本增强方法,具体可以包括:Specifically, referring to FIG. 1, the embodiment of the present invention provides a first text enhancement method, which may specifically include:

S101:获取包括一行文本的原始图像。S101: Acquire an original image including a line of text.

在本发明实施例中,所述的文本增强是指对包括一行文本的原始图像中的文本进行增强处理。这里的增强可以理解为,加深文本的边缘,或者突出文本与背景的区别等。本发明实施例在应用时,考虑了文本的笔画表象(例如亮度或颜色等)和其形状(例如文本呈现条纹状)信息,以期达到增强笔画内部像素的一致性且加深文本与背景差异度的效果。In the embodiment of the present invention, the text enhancement refers to enhancing the text in the original image including a line of text. The enhancement here can be understood as deepening the edge of the text, or highlighting the difference between the text and the background. When the embodiment of the present invention is applied, the stroke appearance (such as brightness or color, etc.) and its shape (such as the text presents stripes) information of the text are considered, in order to achieve the purpose of enhancing the consistency of the internal pixels of the stroke and deepening the difference between the text and the background. Effect.

S102:依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度。S102: According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, the original brightness value or/and color value of each original pixel point is calculated Two-dimensional filtering of strokes to obtain the filtered updated brightness value or/and color value of the original image, the range of the neighborhood set is a square centered on the original pixel and with a side length of w, where w is less than The height of the original image.

本步骤中的直接差异度表示了任一原始像素点与其邻域集中各个领域像素点的直接表象差异,例如颜色或亮度差异,间接差异度则表示了原始像素点到其邻域集中各个领域像素点所经过的像素的梯度模值。利用直接差异度和间接差异度可以对各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值。其中,这里提到的邻域集可以采用以原始像素点为中心以w为边长选取正方形的方式获得,其中,w小于原始图像的图像高度,优选情况下可以取原始图像高度的八分之一。The direct difference degree in this step represents the direct appearance difference between any original pixel point and pixels in various fields in its neighborhood set, such as color or brightness difference, and the indirect difference degree represents the difference between the original pixel point and the pixels in each field in its neighborhood set. The gradient modulus of the pixels the point passes through. The original luminance value or/and color value of each original pixel point can be subjected to two-dimensional stroke filtering by using the direct difference degree and the indirect difference degree, so as to obtain the filtered updated luminance value or/and color value of the original image. Among them, the neighborhood set mentioned here can be obtained by selecting a square with the original pixel as the center and w as the side length, where w is less than the image height of the original image, preferably one-eighth of the original image height one.

在实际应用中,参考图2所示,所述S102具体可以包括:In practical applications, as shown in FIG. 2, the S102 may specifically include:

S201:将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度。S201: Algebraically subtract the original pixel point from the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree.

在本实施例中,采用D1(i,j)表示像素i和j的直接差异度,则可以采用如下公式(1)计算亮度值的直接差异度:In this embodiment, D 1 (i, j) is used to represent the direct difference between pixels i and j, then the following formula (1) can be used to calculate the direct difference of brightness values:

DD. 11 (( ii ,, jj )) == dd [[ ff ′′ (( ii )) ,, ff ′′ (( jj )) ]] aa ·· σσ (( ii )) -- -- -- (( 11 ))

其中,f′(i)表示目标像素邻域亮度的均值,即用邻域像素均值代替目标像素值计算直接差异度;σ(i)表示像素i周围的局部亮度标准差,可以起归一化作用。Among them, f'(i) represents the mean value of the neighborhood brightness of the target pixel, that is, the direct difference degree is calculated by using the neighborhood pixel mean value instead of the target pixel value; σ(i) represents the local brightness standard deviation around pixel i, which can be normalized effect.

也可以采用如下公式(2)计算像素i和j的亮度值的直接差异度:The following formula (2) can also be used to calculate the direct difference between the brightness values of pixels i and j:

DD. 11 (( ii ,, jj )) == dd [[ ff (( ii )) ,, ff (( jj )) ]] aa ·· σσ (( ii )) -- -- -- (( 22 ))

其中,f(i)表示目标像素邻域亮度。Among them, f(i) represents the brightness of the neighborhood of the target pixel.

需要说明的是,当计算像素i和j的颜色值的直接差异度时,可以分别采用公式(3)或者公式(4)来计算:It should be noted that when calculating the direct difference degree of the color values of pixels i and j, formula (3) or formula (4) can be used to calculate:

DD. 11 (( ii ,, jj )) == dd [[ ff nno (( ii )) ,, ff nno (( jj )) ]] aa ·· σσ nno (( ii )) -- -- -- (( 33 ))

DD. 11 (( ii ,, jj )) == dd [[ ff nno ′′ (( ii )) ,, ff nno ′′ (( jj )) ]] aa ·· σσ nno (( ii )) -- -- -- (( 44 ))

公式(3)和(4)中的n表示颜色的R通道、G通道和B通道。需要说明的是,以上计算直接差异度的公式只是举例示意,本领域技术人员可以对上述公式做出适应性的变形。n in formulas (3) and (4) represents the R channel, G channel and B channel of the color. It should be noted that the above formula for calculating the direct difference degree is just an example, and those skilled in the art can make adaptive changes to the above formula.

S202:依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度。S202: Obtain the indirect difference degree according to the gradient modulus from the original pixel point to each neighboring pixel point in its neighborhood set.

其中在本实施例中,采用D2(i,j)表示像素i和j的间接差异度,则可以采用公式(5)计算像素i和j的亮度值的间接差异度:Wherein in this embodiment, D 2 (i, j) is used to represent the indirect difference degree of pixels i and j, then formula (5) can be used to calculate the indirect difference degree of the luminance values of pixels i and j:

DD. 22 (( ii ,, jj )) == maxmax ll ∈∈ {{ ii →&Right Arrow; jj }} devdev ii →&Right Arrow; jj (( ll )) bb ·· σσ (( ll )) -- -- -- (( 55 ))

其中,表示沿i到j方向,像素l处的梯度模值。公式(5)中的b和公式(1)中的a均为预先设定的参数,两者的单调性一致以控制滤波平滑程度。in, Indicates the gradient modulus at pixel l along the direction i to j. Both b in the formula (5) and a in the formula (1) are pre-set parameters, and the monotonicity of the two is consistent to control the smoothness of the filter.

当然,在实际应用中,还可以用i到j经过像素的亮度的最大与最小梯度值之差代替公式(5)中的最大梯度值来计算,计算方式如公式(6)所示:Of course, in practical applications, the difference between the maximum and minimum gradient values of the brightness of pixels passing through i to j can also be used to replace the maximum gradient value in formula (5), and the calculation method is shown in formula (6):

DD. 22 (( ii ,, jj )) == maxmax ll ∈∈ {{ ii →&Right Arrow; jj }} devdev ii →&Right Arrow; jj (( ll )) bb ·&Center Dot; σσ (( ll )) -- minmin ll ∈∈ {{ ii →&Right Arrow; jj }} devdev ii →&Right Arrow; jj (( ll )) bb ·&Center Dot; σσ (( ll )) -- -- -- (( 66 ))

其中,Max表示梯度值的最大值,min表示梯度值的最小值。Among them, Max represents the maximum value of the gradient value, and min represents the minimum value of the gradient value.

而像素i和j的颜色值的间接差异度,则分别可以采用公式(7)和公式(8)计算:The indirect difference between the color values of pixels i and j can be calculated using formula (7) and formula (8) respectively:

DD. 22 (( ii ,, jj )) == maxmax ll ∈∈ {{ ii →&Right Arrow; jj }} devdev nno ii →&Right Arrow; jj (( ll )) bb ·· σσ nno (( ll )) -- -- -- (( 77 ))

DD. 22 (( ii ,, jj )) == maxmax ll ∈∈ {{ ii →&Right Arrow; jj }} devdev nno ii →&Right Arrow; jj (( ll )) bb ·&Center Dot; σσ nno (( ll )) -- minmin ll ∈∈ {{ ii →&Right Arrow; jj }} devdev nno ii →&Right Arrow; jj (( ll )) bb ·&Center Dot; σσ nno (( ll )) -- -- -- (( 88 ))

其中的n表示颜色的R通道、G通道和B通道。需要说明的是,以上计算间接差异度的公式只是举例示意,本领域技术人员可以对上述公式做出适应性的变形。Among them, n represents the R channel, G channel and B channel of the color. It should be noted that the above formula for calculating the indirect difference degree is just an example, and those skilled in the art can make adaptive changes to the above formula.

S203:根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值。S203: According to the direct difference degree and the indirect difference degree, calculate the weight value of each neighboring pixel point for the brightness value or/and color value of the original pixel point.

在得到间接差异度和直接差异度之后,可以采用公式(9)计算权重值:After obtaining the indirect difference degree and direct difference degree, the weight value can be calculated by formula (9):

w(i,j)/wn(i,j)=exp{-[D1(i,j)+D2(i,j)]}  (9)w(i, j)/w n (i, j)=exp{-[D 1 (i, j)+D 2 (i, j)]} (9)

其中,D1(i,j)表示像素i和j的亮度和/或颜色值的直接差异度,D2(i,j)表示像素i和j亮度和/或颜色值的间接差异度,其中,w(i,j)表示亮度权重值,wn(i,j)表示颜色权重值。Among them, D 1 (i, j) represents the direct difference degree of brightness and/or color value of pixel i and j, and D 2 (i, j) represents the indirect difference degree of brightness and/or color value of pixel i and j, where , w(i, j) represents the brightness weight value, w n (i, j) represents the color weight value.

S204:采用笔画二维滤波公式(10)计算所述原始像素点的更新亮度值。S204: Calculate the updated luminance value of the original pixel by using stroke two-dimensional filtering formula (10).

gg (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww (( ii ,, jj )) ]] ·· ff (( jj )) -- -- -- (( 1010 ))

其中,所述N(i)表示像素点i的邻域集;所述w(i,j)表示邻域像素点j对原始像素点i的亮度值的权重值;f(j)为所述邻域集内像素点j的亮度值。Wherein, the N(i) represents the neighborhood set of the pixel i; the w(i, j) represents the weight value of the neighborhood pixel j to the brightness value of the original pixel i; f(j) is the Brightness value of pixel point j in the neighborhood set.

S205:采用笔画二维滤波公式(11)计算所述原始像素点的更新颜色值。S205: Calculate the updated color value of the original pixel by using stroke two-dimensional filter formula (11).

gg nno (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww nno (( ii ,, jj )) ]] ·· ff nno (( jj )) -- -- -- (( 1111 ))

其中,所述wn(i,j)表示在n通道上邻域像素点j对原始像素点i的颜色值的权重值;fn(j)为n通道上所述邻域集内像素点j的颜色值。Wherein, the w n (i, j) represents the weight value of the color value of the neighborhood pixel j to the original pixel i on the n channel; f n (j) is the pixel in the neighborhood set on the n channel The color value of j.

需要说明的是,步骤S204和S205因为分别计算了更新亮度值和更新颜色值,所以在实际应用中可以选择任意一个步骤执行,或者两个步骤同时执行,都可以实现本发明实施例。It should be noted that since steps S204 and S205 calculate the updated brightness value and updated color value respectively, in practical applications, any one step can be selected to be executed, or both steps can be executed simultaneously to implement the embodiment of the present invention.

S103:将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。S103: Replace the corresponding original brightness value or/and color value with the filtered updated brightness value or/and color value, respectively, so as to generate a text-enhanced image corresponding to the original image.

在得到滤波后的更新亮度值或/和颜色值之后,用更新亮度值或/和颜色值分别替换原始的亮度值或/和颜色值,这样替换之后原始图像中的像素点中的文本笔画就进行了增强,也能够增强笔画内部像素的一致性且加深文本与背景差异度。After obtaining the updated brightness value or/and color value after filtering, replace the original brightness value or/and color value with the updated brightness value or/and color value respectively, so that the text strokes in the pixels in the original image after replacement are just Enhanced, it can also enhance the consistency of the pixels inside the stroke and deepen the difference between the text and the background.

针对上述问题,本发明实施例也提供了相应的解决方案,具体的,参见图3,本发明实施例提供了另一种文本增强方法,具体可以包括:For the above problems, the embodiment of the present invention also provides a corresponding solution. Specifically, referring to FIG. 3 , the embodiment of the present invention provides another text enhancement method, which may specifically include:

S301:获取包括一行文本的原始图像。S301: Acquire an original image including a line of text.

S302:估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系。S302: Estimate the stroke polarity of the text in the original image, where the polarity represents the relationship between brightness values or/and color values between pixels inside the stroke area and pixels outside the stroke area.

在实际应用中,由于文本的笔画增强主要依据滤波技术,即利用笔画外的周围像素值增强笔画内的目标像素值,因此笔画内的目标像素周围的噪声像素点会对笔画增强效果产生负面影响,这种影响在处理较细的笔画或者笔画间隔时尤为明显。为了防止这种降质情况的发生,本实施例中引入了笔画极性估计方案。本步骤中估计得到的笔画极性可以表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系。In practical applications, since the stroke enhancement of text is mainly based on filtering technology, that is, the surrounding pixel values outside the stroke are used to enhance the target pixel value inside the stroke, so the noise pixels around the target pixel inside the stroke will have a negative impact on the stroke enhancement effect , this effect is especially noticeable when dealing with thinner strokes or intervals between strokes. In order to prevent such degradation, a stroke polarity estimation scheme is introduced in this embodiment. The stroke polarity estimated in this step may represent the magnitude relationship between the brightness value or/and the color value between the pixels inside the stroke area and the pixels outside the stroke area.

具体的,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,参考图4所示,所述估计原始图像中文本的笔画极性的步骤,包括:Specifically, in the case where the polarity represents the relationship between the brightness value of the pixel points inside the stroke area and the pixel points outside the stroke area, refer to Figure 4, the step of estimating the stroke polarity of the text in the original image ,include:

S401:在水平方向、竖直方向以及两个对角线方向上分别采用公式(12)计算笔画响应强度:S401: Calculate the stroke response intensity using formula (12) in the horizontal direction, vertical direction and two diagonal directions respectively:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] || -- -- -- (( 1212 ))

其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值。本步骤可以得到水平方向、竖直方向以及两个对角线方向上的四个笔画响应强度。Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel point i. In this step, four stroke response intensities in the horizontal direction, vertical direction and two diagonal directions can be obtained.

S402:判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值;如果是,则执行步骤S403;如果否,则执行步骤S404。S402: Judging whether the largest stroke response strength among the four calculated stroke response strengths meets the following two conditions: the polarity of [f(i)-f(l)] and [f(i)-f(k)] The same and the stroke response intensity is greater than the preset threshold; if yes, execute step S403; if no, execute step S404.

在具体应用中,因为文本笔画内部的像素点与背景像素点的亮度或者颜色值通常是相反的,所以如果[f(i)-f(l)]与[f(i)-f(k)]的极性相同,则表示i像素点极有可能是笔画内部的像素点,本步骤即是从原始图像中的所有像素点中找出有可能是笔画内部像素点。这里的极性相同,表示i点的亮度值和/或颜色值同时大于l像素点和k像素点,或者i点的亮度值和/或颜色值同时小于或等于l像素点和k像素点,即是[f(i)-f(l)]与[f(i)-f(k)]都大于零,或者都小于或等于零。笔画响应强度的阈值可以根据实际需求进行调整,因此本发明并不限定该阈值的选取。In a specific application, because the brightness or color value of the pixel inside the text stroke and the background pixel is usually opposite, if [f(i)-f(l)] and [f(i)-f(k) ] have the same polarity, it means that the i pixel point is very likely to be a pixel point inside the stroke. This step is to find out the pixel point that may be inside the stroke from all the pixels in the original image. The polarity here is the same, which means that the brightness value and/or color value of point i is greater than l pixel and k pixel at the same time, or the brightness value and/or color value of i point is less than or equal to l pixel and k pixel at the same time, That is, both [f(i)-f(l)] and [f(i)-f(k)] are greater than zero, or both are less than or equal to zero. The threshold value of stroke response intensity can be adjusted according to actual needs, so the present invention does not limit the selection of the threshold value.

S403:依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性。S403: Determine the estimated stroke polarity of the line of text according to the polarity of [f(i)-f(l)] or [f(i)-f(k)].

当i像素点满足上述两个条件时,则根据[f(i)-f(l)]或[f(i)-f(k)]的极性确定文本内的估计笔画极性为p(i),其取值可以任意,只需区分出笔画内部像素点和外部像素点即可。例如,文本内笔画亮度值要低于背景像素点的亮度值,则设置p(i)为0,那么相应的,p(i)为1则表示文本内笔画亮度值要高于或等于背景像素点的亮度值。When the i pixel point satisfies the above two conditions, then determine the estimated stroke polarity in the text according to the polarity of [f(i)-f(l)] or [f(i)-f(k)] as p( i), its value can be arbitrary, it only needs to distinguish the internal pixel points and external pixel points of the stroke. For example, if the brightness value of the strokes in the text is lower than the brightness value of the background pixels, then set p(i) to 0, then correspondingly, p(i) is 1, which means that the brightness value of the strokes in the text is higher than or equal to the background pixels The brightness value of the point.

S404:依次按照大小关系选取所述计算得到的笔画响应强度执行所述步骤S402。S404: Select the calculated stroke response strengths in sequence according to the size relationship, and execute the step S402.

当最大的笔画响应强度不满足上述两个条件时,则选取次大的笔画响应强度执行所述步骤S402的判断步骤,按照笔画响应强度的大小关系以此类推,直至得到满足所述两个条件的笔画响应强度,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。When the maximum stroke response intensity does not meet the above two conditions, then select the next largest stroke response intensity to execute the judgment step of step S402, and so on according to the relationship between the stroke response intensity until the two conditions are met or, in the case that none of the four stroke response strengths satisfies the two conditions, the pixel point i is taken as a non-stroke pixel point.

具体的,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,还存在另一种实施方式,参考图5所示,所述估计原始图像中文本的笔画极性的步骤,具体可以包括:Specifically, in the case where the polarity represents the magnitude relationship between the brightness values of the pixels inside the stroke area and the pixels outside the stroke area, there is another implementation mode. Referring to FIG. 5 , the estimated original image The steps of stroke polarity of Chinese text may specifically include:

S501:在一个方向上采用公式(12)计算所述原始图像中各个原始像素点的笔画响应强度;所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向。S501: Calculate the stroke response intensity of each original pixel in the original image using formula (12) in one direction; the one direction is any one of the horizontal direction, the vertical direction and two diagonal directions.

本步骤先在水平方向、竖直方向以及两个对角线方向中的任一个方向上计算笔画响应强度。In this step, the stroke response intensity is firstly calculated in any one of the horizontal direction, the vertical direction and the two diagonal directions.

S502:判断所述笔画响应强度是否同时满足如下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值,如果是,则执行步骤S503。S502: Determine whether the stroke response intensity satisfies the following two conditions at the same time: [f(i)-f(l)] and [f(i)-f(k)] have the same polarity and the stroke response intensity is greater than The preset threshold, if yes, execute step S503.

接着判断计算得到的这一个笔画响应强度是否同时满足上述两个条件,如果不满足的情况下,则不对计算得到的笔画响应强度进行任何处理,再在没有计算的其他方向上计算所述原始图像中各个原始像素点的笔画响应强度。Then judge whether the calculated stroke response intensity satisfies the above two conditions at the same time, if not, then do not perform any processing on the calculated stroke response intensity, and then calculate the original image in other directions that have not been calculated The stroke response strength of each original pixel in .

S503:依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述原始像素点i的初始极性。S503: Determine the initial polarity of the original pixel point i according to the polarity of [f(i)-f(l)] or [f(i)-f(k)].

如果计算得到的这个笔画响应强度已经满足上述两个条件,则依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述原始像素点i的初始极性。这里确定的初始极性应该与[f(i)-f(l)]或者[f(i)-f(k)]的极性相同。If the calculated stroke response intensity has met the above two conditions, then determine the original pixel point i according to the polarity of [f(i)-f(l)] or [f(i)-f(k)] initial polarity. The initial polarity determined here should be the same as [f(i)-f(l)] or [f(i)-f(k)].

S504:判断四个方向上的笔画响应强度是否全部计算完毕,如果是,则执行步骤S505;如果否,则执行所述步骤S501。S504: Determine whether all stroke response strengths in the four directions have been calculated, if yes, perform step S505; if not, perform step S501.

接着判断在水平方向、竖直方向以及两个对角线方向共四个方向上的笔画响应强度是否全部计算完毕,如果没有计算完毕,则需要在选取任一个还未计算笔画响应强度的方向并执行所述步骤S501。Then judge whether all the stroke response strengths in the four directions of horizontal direction, vertical direction and two diagonal directions have been calculated. Execute the step S501.

S505:将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性。S505: Determine the initial polarity corresponding to the largest stroke response strength in the four directions as the estimated stroke polarity of the line of text.

如果四个方向上的笔画响应强度均以计算完毕,就在满足上述两个条件的笔画响应强度中,选取最大的笔画响应强度对应的初始极性来确定所述文本的估计笔画极性,即是原始图像中的文本的估计笔画极性与最大的笔画响应强度对应的初始极性相同。If the stroke response strengths in the four directions are all calculated, among the stroke response strengths satisfying the above two conditions, select the initial polarity corresponding to the largest stroke response strength to determine the estimated stroke polarity of the text, namely is that the estimated stroke polarity of the text in the original image is the same as the initial polarity corresponding to the maximum stroke response strength.

具体的,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,参考图6所示,具体可以包括:Specifically, in the case where the polarity represents the color value size relationship between the pixels inside the stroke area and the pixels outside the stroke area, the step of estimating the stroke polarity of the text in the original image is shown in FIG. 6 , which can include:

S601:在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算各通道的笔画响应强度:S601: Calculate the stroke response intensity of each channel in the horizontal direction, vertical direction and two diagonal directions respectively using the following formulas:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] || -- -- -- (( 1313 ))

其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值。例如,n通道分别为R通道、G通道和B通道,则笔画响应强度为R通道、G通道和B通道上的笔画响应强度之和。Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel point i on the channel n. For example, if the n channels are R channel, G channel and B channel respectively, then the stroke response intensity is the sum of the stroke response intensities on the R channel, G channel and B channel.

S602:判断计算得到的各通道的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值,如果是,则执行步骤S603;如果否,则执行步骤S604。S602: Judging whether the largest stroke response strength among the four stroke response strengths of each channel obtained by calculation satisfies the following two conditions: [f n (i)-f n (l)] and [f n (i) on channel n )-f n (k)] are consistent in polarity and the stroke response intensity is greater than a preset threshold, if yes, execute step S603; if no, execute step S604.

在本步骤中,在任一通道上都需要满足[fn(i)-fn(l)]和[fn(i)-fn(k)]极性保持一致的条件。In this step, the condition that the polarities of [f n (i)-f n (l)] and [f n (i)-f n (k)] must be consistent must be met on any channel.

S603:依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性。S603: Determine the estimated stroke polarity of the line of text according to the polarity of [f n (i)-f n (l)] or [f n (i)-f n (k)].

S604:依次按照大小关系选取所述计算得到的笔画响应强度执行所述步骤S602。S604: Select the calculated stroke response strengths sequentially according to the size relationship, and execute the step S602.

当最大的笔画响应强度不满足上述两个条件时,本步骤就需要按照大小关系依次选取次大、第三以及第四大小的笔画响应强度来执行步骤S602,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。例如,当次大的笔画响应强度已经满足上述两个条件时,则停止笔画极性估计的流程。When the largest stroke response intensity does not meet the above two conditions, this step needs to select the next largest, third and fourth largest stroke response intensity according to the size relationship to perform step S602 until a certain stroke response intensity satisfies the described Two conditions, or, in the case that the four stroke response intensities do not satisfy the two conditions, the pixel i is regarded as a non-stroke pixel. For example, when the next largest stroke response intensity meets the above two conditions, the stroke polarity estimation process is stopped.

在实际应用中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,还存在另外一种场景,参考图7所示,所述估计原始图像中文本的笔画极性的步骤,包括:In practical applications, in the case where the polarity represents the color value size relationship between the pixels inside the stroke area and the pixels outside the stroke area, there is another scenario, as shown in Figure 7, the estimated original Steps for stroke polarity of text in an image, including:

S701:在一个方向上采用公式(13)计算所述原始图像中各个原始像素点各通道的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向。S701: Use formula (13) to calculate the stroke response strength of each channel of each original pixel point in the original image in one direction, the one direction being any one of the horizontal direction, the vertical direction and the two diagonal directions direction.

S702:判断所述一个方向上各通道的笔画响应强度是否同时满足如下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值,如果是,则执行步骤S703。S702: Determine whether the stroke response intensity of each channel in the one direction satisfies the following two conditions at the same time: [f n (i)-f n (l)] and [f n (i)-f n ( The polarities of k)] are consistent and the stroke response intensity is greater than the preset threshold, if yes, execute step S703.

本步骤直接判断步骤S701计算得到的一个笔画响应强度是否满足所述两个条件,如果不满足的话,则在该方向上不设置初始极性。This step directly judges whether a stroke response intensity calculated in step S701 satisfies the two conditions, and if not, no initial polarity is set in this direction.

S703:依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述原始像素点i的初始极性。S703: Determine the initial polarity of the original pixel i according to the polarity of [f n (i)-f n (l)] or [f n (i)-f n (k)].

如果步骤S701计算得到的一个笔画响应强度满足所述两个条件,则将原始像素点i在该方向上的初始极性设置为与[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性相同。If a stroke response intensity calculated in step S701 satisfies the two conditions, then the initial polarity of the original pixel i in this direction is set to be consistent with [f n (i)-f n (l)] or [f n (i)-f n (k)] have the same polarity.

S704:判断四个方向上的笔画响应强度是否全部计算完毕,如果是,则执行步骤S705;如果否,则执行步骤S701S704: Determine whether all stroke response strengths in the four directions have been calculated, if yes, execute step S705; if not, execute step S701

S705:将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性。S705: Determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke polarity of the line of text.

如果四个方向上的笔画响应强度是否全部计算完毕,则从四个方向上的满足上述两个条件的笔画响应强度中选取最大的笔画响应强度对应的初始极性,作为所述文本的估计笔画极性。如果四个方向上的笔画响应强度没有全部计算完毕,则再选取还未计算的任一方向执行所述步骤S701。If the stroke response strengths in the four directions are all calculated, select the initial polarity corresponding to the largest stroke response strength from the stroke response strengths in the four directions satisfying the above two conditions, as the estimated stroke of the text polarity. If the stroke response strengths in the four directions have not all been calculated, then select any direction that has not been calculated to execute the step S701.

S303:依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度。S303: According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, the original brightness value or/and color value of each original pixel point is calculated Stroke two-dimensional filtering, to obtain the filtered updated brightness value or/and color value of the original image, the range of the neighborhood set is a square with the original pixel as the center and a side length of w, and the w is less than The height of the original image.

本步骤的详细介绍可参考实施例1中的相关内容,在此不再赘述。需要说明的是,本步骤可与步骤S302同时执行,或者先执行步骤S303,再执行步骤S302均可。For a detailed introduction of this step, reference may be made to relevant content in Embodiment 1, and details are not repeated here. It should be noted that this step can be executed simultaneously with step S302, or step S303 can be executed first, and then step S302 can be executed.

S304:针对原始图像的各个像素点,判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则执行步骤S305,如果否,则不进行替换。S304: For each pixel of the original image, determine whether the filtered updated brightness value or/and color value matches the stroke polarity, if yes, execute step S305, if not, do not replace.

在计算得到笔画极性,以及进行笔画滤波之后,可以依次判断原始图像的各个像素点的滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果某个像素点的滤波后的更新亮度值或/和颜色值与所述笔画极性不匹配,则不替换该像素点的原始亮度值或/和颜色值,并继续判断下一个像素点的滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配。After the stroke polarity is calculated and stroke filtering is performed, it can be judged in turn whether the filtered updated brightness value or/and color value of each pixel of the original image matches the stroke polarity. If the updated brightness value or/and color value does not match the stroke polarity, the original brightness value or/and color value of the pixel point will not be replaced, and continue to judge the filtered updated brightness value or // and whether the color value matches said stroke polarity.

参考图8所示,所述步骤S304,具体可以包括:Referring to FIG. 8, the step S304 may specifically include:

S801:获取所述滤波后的更新亮度值或/和颜色值与原始亮度值或/和颜色值的第一大小关系。S801: Obtain a first magnitude relationship between the filtered updated brightness value or/and color value and the original brightness value or/and color value.

首先获取滤波后的更新亮度值或/和颜色值与原始亮度值或/和颜色值的第一大小关系,这里的第一大小关系,可以例如,更新亮度值比原始亮度值的亮度更亮,则第一大小关系为更新亮度值大于原始亮度值,或者,还可以例如,更新颜色值比原始颜色值更大,则第一大小关系为更新颜色值大于原始颜色值。该第一大小关系可以通过将更新亮度值或/和颜色值与原始亮度值或/和颜色值进行代数相减的方式获得。First obtain the first size relationship between the filtered updated brightness value or/and color value and the original brightness value or/and color value, the first size relationship here can be, for example, the brightness of the updated brightness value is brighter than the original brightness value, Then the first magnitude relationship is that the updated brightness value is greater than the original brightness value, or, for example, the updated color value is greater than the original color value, then the first magnitude relationship is that the updated color value is greater than the original color value. The first size relationship can be obtained by algebraically subtracting the updated brightness value or/and color value from the original brightness value or/and color value.

S802:判断所述第一大小关系与所述笔画极性所表示出的第二大小关系是否匹配。S802: Determine whether the first size relationship matches the second size relationship represented by the stroke polarity.

而所述笔画极性表示笔画内部的像素点的亮度值或/和颜色值与笔画外部的像素点的亮度值或/和颜色值的大小关系,因此,在更新颜色值比原始颜色值更大,且笔画极性表示的第二大小关系也为更新颜色值比原始颜色值更大时,或者在更新颜色值比原始颜色值更小,且笔画极性表示的第二大小关系也为更新颜色值比原始颜色值更小时,则认为所述第一大小关系与所述笔画极性所表示出的第二大小关系匹配,反之,则认为第一大小关系与第二大小关系不匹配。The stroke polarity represents the relationship between the brightness value or/and color value of the pixel inside the stroke and the brightness value or/and color value of the pixel outside the stroke, therefore, when the updated color value is larger than the original color value , and the second size relationship represented by the stroke polarity is also when the updated color value is larger than the original color value, or when the updated color value is smaller than the original color value, and the second size relationship represented by the stroke polarity is also the updated color If the value is smaller than the original color value, it is considered that the first size relationship matches the second size relationship represented by the stroke polarity; otherwise, it is considered that the first size relationship does not match the second size relationship.

S305:将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。S305: Replace the corresponding original brightness value or/and color value with the filtered updated brightness value or/and color value, respectively, so as to generate a text-enhanced image corresponding to the original image.

在第一大小关系与所述第二大小关系匹配的情况下,将滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,就能得到与所述原始图像对应的文本增强图像。本实施例通过笔画极性估计的步骤,可以使得在笔画极性与滤波后的更新亮度值或颜色值匹配的情况下,再进行文本增强,与实施例1相比,这样可以使得文本增强的效果更为突出,从而也就更有利于后续的文本提取的准确性的提升。In the case that the first size relationship matches the second size relationship, the corresponding original brightness value or/and color value can be replaced by the updated brightness value or/and color value after filtering, so as to obtain the The text augmented image corresponding to the original image. In this embodiment, through the steps of stroke polarity estimation, text enhancement can be performed when the stroke polarity matches the updated brightness value or color value after filtering. Compared with embodiment 1, the enhanced text The effect is more prominent, which is more conducive to the improvement of the accuracy of subsequent text extraction.

与本发明实施例提供的第一种文本增强方法相对应,本发明实施例还提供了一种文本增强装置,参见图9,该装置可以包括:Corresponding to the first text enhancement method provided in the embodiment of the present invention, the embodiment of the present invention also provides a text enhancement device, see FIG. 9, the device may include:

获取模块901,用于获取包括一行文本的原始图像。An acquisition module 901, configured to acquire an original image including a line of text.

滤波模块902,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度。The filtering module 902 is configured to, according to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, calculate the original brightness value or/or of each original pixel point Perform two-dimensional filtering of strokes and color values to obtain filtered update brightness values or/and color values of the original image, the range of the neighborhood set is a square centered on the original pixel point and a side length of w, The w is smaller than the height of the original image.

其中,参考图10,所述滤波模块902具体可以包括:Wherein, referring to FIG. 10, the filtering module 902 may specifically include:

第一获取子模块1001,用于将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度;The first acquisition sub-module 1001 is used to algebraically subtract the original pixel point from the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree;

第二获取子模块1002,用于依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度;The second acquisition sub-module 1002 is used to acquire the indirect difference degree according to the gradient modulus from the original pixel point to each neighboring pixel point in its neighborhood set;

权重计算子模块1003,用于根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值;The weight calculation sub-module 1003 is used to calculate the weight value of each neighboring pixel point for the brightness value or/and color value of the original pixel point according to the direct difference degree and the indirect difference degree;

更新亮度值计算子模块1004,用于采用笔画二维滤波公式(10)计算所述原始像素点的更新亮度值。The updated luminance value calculation sub-module 1004 is used to calculate the updated luminance value of the original pixel by using stroke two-dimensional filtering formula (10).

更新颜色值计算子模块1005,用于采用笔画二维滤波公式(11)计算所述原始像素点的更新颜色值。The updated color value calculation sub-module 1005 is used to calculate the updated color value of the original pixel by using stroke two-dimensional filtering formula (11).

替换模块903,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。The replacement module 903 is configured to replace the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image.

通过本发明实施例提供的上述文本增强装置,在得到滤波后的更新亮度值或/和颜色值之后,用更新亮度值或/和颜色值分别替换原始的亮度值或/和颜色值,这样替换之后原始图像中的像素点中的文本笔画就进行了增强,也能够增强笔画内部像素的一致性且加深文本与背景差异度,从而为后续文本提取提供更好的文本增强图像,也能够提升后续文本提取的准确性和精确度。Through the above-mentioned text enhancement device provided by the embodiment of the present invention, after obtaining the updated brightness value or/and color value after filtering, replace the original brightness value or/and color value with the updated brightness value or/and color value respectively, thus replacing Afterwards, the text strokes in the pixels in the original image are enhanced, which can also enhance the consistency of the pixels inside the strokes and deepen the difference between the text and the background, thereby providing better text enhancement images for subsequent text extraction, and can also improve subsequent text extraction. Accuracy and precision of text extraction.

与本发明实施例提供的第二种文本增强方法相对应,本发明实施例还提供了一种文本增强装置,参见图11,该装置可以包括:Corresponding to the second text enhancement method provided by the embodiment of the present invention, the embodiment of the present invention also provides a text enhancement device, see FIG. 11, the device may include:

获取模块901,用于获取包括一行文本的原始图像。An acquisition module 901, configured to acquire an original image including a line of text.

笔画极性估计模块1101,用于估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系。The stroke polarity estimation module 1101 is configured to estimate the stroke polarity of the text in the original image, and the polarity represents the brightness value or/and the size of the color value between the pixels inside the stroke area and the pixels outside the stroke area relation.

所述笔画极性估计模块1101在不同的应用场景下,可以进行不同的具体配置。在一种场景中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,参考图12所示,所述笔画极性估计模块1101可以包括:The stroke polarity estimation module 1101 can be configured differently in different application scenarios. In one scenario, in the case where the polarity represents the relationship between the brightness values of the pixels inside the stroke area and the pixels outside the stroke area, as shown in FIG. 12 , the stroke polarity estimation module 1101 may include :

第一计算子模块1201,用于在水平方向、竖直方向以及两个对角线方向上分别采用公式(12)计算笔画响应强度。The first calculation sub-module 1201 is used to calculate the stroke response intensity using formula (12) in the horizontal direction, vertical direction and two diagonal directions respectively.

第一判断子模块1202,用于判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值。The first judging sub-module 1202 is used to judge whether the maximum stroke response strength among the four calculated stroke response strengths satisfies the following two conditions: [f(i)-f(l)] and [f(i)-f (k)] have the same polarity and the stroke response intensity is greater than a preset threshold.

第一确定子模块1203,用于在所述第一判断子模块的结果为是的情况下,依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性。The first determination sub-module 1203 is used to, in the case that the result of the first determination sub-module is yes, according to [f(i)-f(l)] or [f(i)-f(k)] Polarity determines the estimated stroke polarity of the line of text.

第一触发子模块1204,用于在所述第一判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第一判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The first triggering submodule 1204 is used to select the stroke response strengths obtained according to the size relationship in sequence and trigger the first judging submodule if the result of the first judging submodule is negative, until a certain One stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel.

在另外的场景中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,参考图13所示,所述笔画极性估计模块1101包括:In another scenario, in the case where the polarity represents the relationship between brightness values between the pixels inside the stroke area and the pixels outside the stroke area, as shown in FIG. 13 , the stroke polarity estimation module 1101 includes:

第二计算子模块1301,用于在一个方向上采用公式(12)计算所述原始图像中各个原始像素点的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向。The second calculation sub-module 1301 is used to calculate the stroke response strength of each original pixel in the original image using formula (12) in one direction, the one direction being the horizontal direction, the vertical direction and two diagonal lines any of the directions.

第二判断子模块1302,用于判断所述笔画响应强度是否同时满足如下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值。The second judging submodule 1302 is used to judge whether the stroke response intensity satisfies the following two conditions at the same time: the polarity of [f(i)-f(l)] is the same as that of [f(i)-f(k)]. And the stroke response intensity is greater than a preset threshold.

第二确定子模块1303,用于在所述第二判断子模块为是的情况下,依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述原始像素点i的初始极性。The second determination sub-module 1303 is used for determining the polarity according to [f(i)-f(l)] or [f(i)-f(k)] when the second determination sub-module is yes Determine the initial polarity of the original pixel point i.

第三判断子模块1304,用于判断四个方向上的笔画响应强度是否全部计算完毕。The third judging sub-module 1304 is used for judging whether all the stroke response strengths in the four directions have been calculated.

第三确定子模块1305,用于在所述第三判断子模块的结果为是的情况下,将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性。The third determination sub-module 1305 is used to determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke of the line of text when the result of the third determination sub-module is yes polarity.

第二触发子模块1306,用于在第三判断子模块的结果为否的情况下,触发所述第二计算子模块。The second triggering submodule 1306 is configured to trigger the second calculation submodule when the result of the third judging submodule is negative.

在另外的场景中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,参考图14所示,所述笔画极性估计模块1101具体可以包括:In another scenario, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, as shown in FIG. 14 , the stroke polarity estimation module 1101 can specifically include:

第三计算子模块1401,用于在水平方向、竖直方向以及两个对角线方向上分别采用公式(13)计算笔画响应强度。The third calculation sub-module 1401 is used to calculate the stroke response intensity using formula (13) in the horizontal direction, vertical direction and two diagonal directions respectively.

第四判断子模块1402,用于判断计算得到的笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值。The fourth judging sub-module 1402 is used to judge whether the largest stroke response strength among the calculated stroke response strengths meets the following two conditions: [f n (i)-f n (l)] and [f n The polarities of (i)-f n (k)] are consistent and the stroke response intensity is greater than a preset threshold.

第四确定子模块1403,用于在所述第四判断子模块的结果为是的情况下,依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性。The fourth determination submodule 1403 is configured to, when the result of the fourth determination submodule is yes, according to [f n (i)-f n (l)] or [f n (i)-f n ( k)] determines the estimated stroke polarity of the line of text.

第三触发子模块1404,用于在所述第四判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第四判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The third triggering submodule 1404 is configured to select the stroke response strengths obtained according to the size relationship in sequence and trigger the fourth judging submodule in the case that the result of the fourth judging submodule is negative, until a certain One stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel.

在另外的场景中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,参考图15所示,所述笔画极性估计模块1101具体可以包括:In another scenario, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, as shown in FIG. 15 , the stroke polarity estimation module 1101 can specifically include:

第四计算子模块1501,用于在一个方向上采用公式(13)计算所述原始图像中各个原始像素点的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向。The fourth calculation sub-module 1501 is used to calculate the stroke response strength of each original pixel in the original image using formula (13) in one direction, the one direction being the horizontal direction, the vertical direction and two diagonal lines any of the directions.

第五判断子模块1502,用于判断所述笔画响应强度是否同时满足如下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值。The fifth judging sub-module 1502 is used to judge whether the stroke response intensity satisfies the following two conditions at the same time: [f n (i)-f n (l)] and [f n (i)-f n on the channel n (k)] are consistent in polarity and the stroke response intensity is greater than a preset threshold.

第五确定子模块1503,用于在所述第五判断子模块的结果为是的情况下,依据[fn(i)-fn(i)]或者[fn(i)-fn(k)]的极性确定所述原始像素点i的初始极性。The fifth determination submodule 1503 is configured to, in the case that the result of the fifth determination submodule is yes, according to [f n (i)-f n (i)] or [f n (i)-f n ( k)] determine the initial polarity of the original pixel point i.

第六判断子模块1504,用于判断四个方向上的笔画响应强度是否全部计算完毕。The sixth judging sub-module 1504 is used to judge whether all the stroke response strengths in the four directions have been calculated.

第六确定子模块1505,用于在所述第六判断子模块的结果为是的情况下,将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性。The sixth determination sub-module 1505 is configured to determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke of the line of text when the result of the sixth determination sub-module is Yes polarity.

第四触发子模块1506,用于在所述第六判断子模块的结果为否的情况下,触发所述第四计算子模块。The fourth triggering submodule 1506 is configured to trigger the fourth calculation submodule when the result of the sixth judging submodule is negative.

滤波模块902,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度。The filtering module 902 is configured to, according to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, calculate the original brightness value or/or of each original pixel point Perform two-dimensional filtering of strokes and color values to obtain filtered update brightness values or/and color values of the original image, the range of the neighborhood set is a square centered on the original pixel point and a side length of w, The w is smaller than the height of the original image.

判断模块1102,应用判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则触发替换模块903。The judging module 1102 is used to judge whether the filtered updated brightness value or/and color value matches the stroke polarity, and if so, trigger the replacement module 903 .

参考图16,在实际应用中,所述判断模块1102具体可以包括:Referring to FIG. 16, in practical applications, the judging module 1102 may specifically include:

第三获取子模块1601,用于获取所述滤波后的更新亮度值或/和颜色值与原始亮度值或/和颜色值的第一大小关系。The third obtaining sub-module 1601 is configured to obtain a first magnitude relationship between the filtered updated brightness value or/and color value and the original brightness value or/and color value.

第七判断子模块1602,用于判断所述第一大小关系与所述笔画极性所表示出的第二大小关系是否匹配。The seventh judging sub-module 1602 is configured to judge whether the first size relationship matches the second size relationship represented by the stroke polarity.

替换模块903,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。The replacement module 903 is configured to replace the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image.

通过本发明实施例提供的上述装置,进一步采用笔画极性估计的方式,能够对滤波后的更新颜色值或者更新亮度值进行验证,在笔画极性与滤波后的更新颜色值和/或更新亮度值匹配的情况下,再将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,这样得到的文本增强图像更为有效和精确。Through the above-mentioned device provided by the embodiment of the present invention, the stroke polarity estimation method can be further used to verify the updated color value or updated brightness value after filtering, and the stroke polarity and the updated color value and/or updated brightness value after filtering If the values match, the filtered updated brightness value or/and color value is then replaced with the corresponding original brightness value or/and color value, so that the text-enhanced image obtained in this way is more effective and accurate.

除此之外,参考图17所示,在本文增强之后,本发明实施例还提供了一种文本提取方法,该方法可以包括:In addition, as shown in FIG. 17, after the enhancement of this text, the embodiment of the present invention also provides a text extraction method, which may include:

S1701:获取包括一行文本的原始图像。S1701: Acquire an original image including a line of text.

S1702:依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值;所述邻域集的范围为以原始像素点为中心且边长为w的正方形;所述w小于所述原始图像的高度。S1702: According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, perform an original brightness value or/and color value of each original pixel point Two-dimensional filtering of strokes to obtain the filtered updated brightness value or/and color value of the original image; the range of the neighborhood set is a square with the original pixel as the center and a side length of w; the w is less than The height of the original image.

S1703:将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;S1703: Replace the filtered updated brightness value or/and color value with the corresponding original brightness value or/and color value, respectively, to generate a text-enhanced image corresponding to the original image;

S1704:提取所述文本增强图像中的文本。S1704: Extract text in the text-enhanced image.

采用上述文本提取方法,可以基于文本增强图像进行,这样提取出的文本将更为准确和精确,同时,提取时因为文本已经进行了增强,也能够减少文本提取的复杂度,提高文本提取的效率。Using the above text extraction method, it can be performed based on text enhancement images, so that the extracted text will be more accurate and precise. At the same time, because the text has been enhanced during extraction, it can also reduce the complexity of text extraction and improve the efficiency of text extraction. .

与上述一种文本提取方法相对应,参考图18所示,本发明实施例还提供了一种文本提取装置,该装置可以包括:Corresponding to the above text extraction method, as shown in FIG. 18, an embodiment of the present invention also provides a text extraction device, which may include:

获取模块901,用于获取包括一行文本的原始图像。An acquisition module 901, configured to acquire an original image including a line of text.

滤波模块902,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度。The filtering module 902 is configured to, according to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, calculate the original brightness value or/or of each original pixel point Perform two-dimensional filtering of strokes and color values to obtain filtered update brightness values or/and color values of the original image, the range of the neighborhood set is a square centered on the original pixel point and a side length of w, The w is smaller than the height of the original image.

替换模块903,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。The replacement module 903 is configured to replace the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image.

提取模块1801,用于提取所述文本增强图像中的文本。An extraction module 1801, configured to extract text in the text-enhanced image.

采用上述文本提取装置,可以基于文本增强图像进行,这样提取出的文本将更为准确和精确,同时,提取时因为文本已经进行了增强,也能够减少文本提取的复杂度,提高文本提取的效率。Using the above text extraction device can be performed based on text enhancement images, so that the extracted text will be more accurate and precise. At the same time, because the text has been enhanced during extraction, it can also reduce the complexity of text extraction and improve the efficiency of text extraction. .

另外,还应该指出的是,上述系列处理和装置也可以通过软件和/或固件实现。在通过软件和/或固件实现的情况下,从存储介质或网络向具有专用硬件结构的计算机,例如图19所示的通用个人计算机1900安装构成该软件的程序,该计算机在安装有各种程序时,能够执行各种功能等等。In addition, it should also be noted that the series of processes and devices described above may also be implemented by software and/or firmware. In the case of realization by software and/or firmware, the program constituting the software is installed from a storage medium or a network to a computer having a dedicated hardware configuration, such as a general-purpose personal computer 1900 shown in FIG. , can perform various functions and so on.

在图19中,中央处理单元(CPU)1901根据只读存储器(ROM)1902中存储的程序或从存储部分1908加载到随机存取存储器(RAM)1903的程序执行各种处理。在RAM 1903中,也根据需要存储当CPU 1901执行各种处理等等时所需的数据。In FIG. 19 , a central processing unit (CPU) 1901 executes various processes according to programs stored in a read only memory (ROM) 1902 or programs loaded from a storage section 1908 to a random access memory (RAM) 1903 . In the RAM 1903, data required when the CPU 1901 executes various processing and the like is also stored as necessary.

CPU 1901、ROM 1902和RAM 1903经由总线1904彼此连接。输入/输出接口1905也连接到总线1904。The CPU 1901, ROM 1902, and RAM 1903 are connected to each other via a bus 1904. The input/output interface 1905 is also connected to the bus 1904 .

下述部件连接到输入/输出接口1905:输入部分1906,包括键盘、鼠标等等;输出部分1907,包括显示器,比如阴极射线管(CRT)、液晶显示器(LCD)等等,和扬声器等等;存储部分1908,包括硬盘等等;和通信部分1909,包括网络接口卡比如LAN卡、调制解调器等等。通信部分1909经由网络比如因特网执行通信处理。The following components are connected to the input/output interface 1905: an input section 1906 including a keyboard, a mouse, etc.; an output section 1907 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; The storage section 1908 includes a hard disk and the like; and the communication section 1909 includes a network interface card such as a LAN card, a modem, and the like. The communication section 1909 performs communication processing via a network such as the Internet.

根据需要,驱动器1910也连接到输入/输出接口1905。可拆卸介质1911比如磁盘、光盘、磁光盘、半导体存储器等等根据需要被安装在驱动器1910上,使得从中读出的计算机程序根据需要被安装到存储部分1908中。A driver 1910 is also connected to the input/output interface 1905 as needed. A removable medium 1911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1910 as necessary, so that a computer program read therefrom is installed into the storage section 1908 as necessary.

在通过软件实现上述系列处理的情况下,从网络比如因特网或存储介质比如可拆卸介质1911安装构成软件的程序。In the case of realizing the above-described series of processing by software, the programs constituting the software are installed from a network such as the Internet or a storage medium such as the removable medium 1911 .

本领域的技术人员应当理解,这种存储介质不局限于图19所示的其中存储有程序、与设备相分离地分发以向用户提供程序的可拆卸介质1911。可拆卸介质1911的例子包含磁盘(包含软盘(注册商标))、光盘(包含光盘只读存储器(CD-ROM)和数字通用盘(DVD))、磁光盘(包含迷你盘(MD)(注册商标))和半导体存储器。或者,存储介质可以是ROM 1902、存储部分1908中包含的硬盘等等,其中存有程序,并且与包含它们的设备一起被分发给用户。Those skilled in the art should understand that such a storage medium is not limited to the removable medium 1911 shown in FIG. 19 in which the program is stored and distributed separately from the device to provide the program to the user. Examples of the removable media 1911 include magnetic disks (including floppy disks (registered trademark)), optical disks (including compact disk read only memory (CD-ROM) and digital versatile disks (DVD)), magneto-optical disks (including )) and semiconductor memory. Alternatively, the storage medium may be a ROM 1902, a hard disk contained in the storage section 1908, or the like, in which the programs are stored and distributed to users together with devices containing them.

还需要指出的是,执行上述系列处理的步骤可以自然地按照说明的顺序按时间顺序执行,但是并不需要一定按照时间顺序执行。某些步骤可以并行或彼此独立地执行。It should also be pointed out that the steps for executing the above series of processes can naturally be executed in chronological order according to the illustrated order, but it does not need to be executed in chronological order. Certain steps may be performed in parallel or independently of each other.

虽然已经详细说明了本发明及其优点,但是应当理解在不脱离由所附的权利要求所限定的本发明的精神和范围的情况下可以进行各种改变、替代和变换。而且,本发明实施例的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。Although the present invention and its advantages have been described in detail, it should be understood that various changes, substitutions and alterations can be made hereto without departing from the spirit and scope of the invention as defined by the appended claims. Moreover, the terms "comprising", "comprising" or any other variation thereof in the embodiments of the present invention are intended to cover a non-exclusive inclusion such that a process, method, article or device comprising a series of elements includes not only those elements, but also Including other elements not expressly listed, or also including elements inherent in such process, method, article or apparatus. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

关于包括以上实施例的实施方式,还公开下述附记:Regarding the implementation manner comprising the above embodiments, the following additional notes are also disclosed:

附记1、一种文本增强方法,包括:Additional Note 1. A text enhancement method, comprising:

获取包括一行文本的原始图像;Get the original image including a line of text;

依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, the stroke two is performed on the original brightness value or/and color value of each original pixel point Dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image, the range of the neighborhood set is a square with the original pixel as the center and a side length of w, and the w is smaller than the the height of the original image;

将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。replacing the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image.

2、根据附记1所述的方法,其中,所述对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波的步骤,包括:2. The method according to Supplement 1, wherein the step of performing two-dimensional stroke filtering on the original brightness value or/and color value of each original pixel point includes:

将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度;Perform algebraic subtraction of the original pixel point and the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree;

依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度;Obtain the indirect difference degree according to the gradient modulus from the original pixel point to each neighboring pixel point in its neighborhood set;

根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值;Calculate the weight value of each neighboring pixel point for the brightness value or/and color value of the original pixel point according to the direct difference degree and the indirect difference degree;

采用如下笔画二维滤波公式计算所述原始像素点的更新亮度值;The updated brightness value of the original pixel is calculated by using the following stroke two-dimensional filtering formula;

gg (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww (( ii ,, jj )) ]] ·· ff (( jj ))

其中,所述N(i)表示像素点i的邻域集;所述w(i,j)表示邻域像素点j对原始像素点i的亮度值的权重值;f(j)为所述邻域集内像素点j的亮度值;Wherein, the N(i) represents the neighborhood set of the pixel i; the w(i, j) represents the weight value of the neighborhood pixel j to the brightness value of the original pixel i; f(j) is the The brightness value of pixel point j in the neighborhood set;

和/或,and / or,

采用如下笔画二维滤波公式计算所述原始像素点的更新颜色值;The updated color value of the original pixel is calculated by using the following stroke two-dimensional filtering formula;

gg nno (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww nno (( ii ,, jj )) ]] ·· ff nno (( jj ))

其中,所述wn(i,j)表示在n通道上邻域像素点j对原始像素点i的颜色值的权重值;fn(j)为n通道上所述邻域集内像素点j的颜色值。Wherein, the w n (i, j) represents the weight value of the color value of the neighborhood pixel j to the original pixel i on the n channel; f n (j) is the pixel in the neighborhood set on the n channel The color value of j.

3、根据附记1所述的方法,其中,所述获取包括一行文本的原始图像之后,还包括:3. The method according to Note 1, wherein, after acquiring the original image including a line of text, further comprising:

估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系;Estimating the stroke polarity of the text in the original image, the polarity representing the magnitude relationship between the brightness value or/and color value between the pixels inside the stroke area and the pixels outside the stroke area;

以及所述得到所述原始图像的滤波后的更新亮度值或/和颜色值之后,还包括:And after obtaining the filtered updated brightness value or/and color value of the original image, it also includes:

判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则执行所述替换所述原始亮度值或/和颜色值的步骤。Judging whether the updated brightness value or/and color value after filtering matches the polarity of the stroke, if so, performing the step of replacing the original brightness value or/and color value.

4、根据附记3所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:4. The method according to Note 3, wherein, in the case where the polarity represents the relationship between the brightness value of the pixels inside the stroke area and the pixels outside the stroke area, the estimated strokes of the text in the original image Polarity steps, including:

在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The following formulas are used to calculate the stroke response strength in the horizontal direction, vertical direction and two diagonal directions respectively:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i;

判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值,如果是,则依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性;如果否,则依次按照大小关系选取所述计算得到的笔画响应强度执行所述判断步骤,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。Judging whether the maximum stroke response intensity among the four calculated stroke response intensity meets the following two conditions: [f(i)-f(l)] has the same polarity as [f(i)-f(k)] and The stroke response intensity is greater than a preset threshold, if so, determine the estimated stroke polarity of the line of text according to the polarity of [f(i)-f(l)] or [f(i)-f(k)] If not, then select the calculated stroke response strength according to the magnitude relationship to execute the judgment step until a certain stroke response strength satisfies the two conditions, or, when none of the four stroke response strengths When the two conditions are satisfied, the pixel i is regarded as a non-stroke pixel.

5、根据附记3所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:5. The method according to supplementary note 3, wherein, in the case where the polarity represents the relationship between the brightness value of the pixels inside the stroke area and the pixels outside the stroke area, the estimated strokes of the text in the original image Polarity steps, including:

在一个方向上采用如下公式计算所述原始图像中各个原始像素点的笔画响应强度;所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向;In one direction, the following formula is used to calculate the stroke response strength of each original pixel in the original image; the one direction is any direction in the horizontal direction, the vertical direction and the two diagonal directions;

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i;

判断所述笔画响应强度是否同时满足如下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值,如果是,则依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述原始像素点i的初始极性;Judging whether the stroke response strength meets the following two conditions at the same time: [f(i)-f(l)] and [f(i)-f(k)] have the same polarity and the stroke response strength is greater than the preset Threshold, if yes, then determine the initial polarity of the original pixel i according to the polarity of [f(i)-f(l)] or [f(i)-f(k)];

判断四个方向上的笔画响应强度是否全部计算完毕,如果是,则将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性;如果否,则重复所述计算所述原始图像中各个原始像素点的笔画响应强度的步骤。Determine whether all stroke response strengths in the four directions have been calculated, and if so, determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke polarity of the line of text; if not, then Repeating the step of calculating the stroke response intensity of each original pixel in the original image.

6、根据附记3所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:6. The method according to Note 3, wherein, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, the estimated strokes of the text in the original image Polarity steps, including:

在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The following formulas are used to calculate the stroke response strength in the horizontal direction, vertical direction and two diagonal directions respectively:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n;

判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值,如果是,则依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性;如果否,则依次按照大小关系选取所述计算得到的笔画响应强度执行所述判断步骤,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。Judging whether the maximum stroke response strength among the four stroke response strengths obtained by calculation satisfies the following two conditions: [f n (i)-f n (l)] and [f n (i)-f n ( The polarities of k)] are consistent and the stroke response intensity is greater than the preset threshold, if so, according to [f n (i)-f n (l)] or [f n (i)-f n (k )] to determine the estimated stroke polarity of the line of text; if not, then select the calculated stroke response strength according to the size relationship to execute the judgment step until a certain stroke response strength satisfies the two condition, or, in the case that none of the four stroke response intensities satisfies the two conditions, the pixel i is regarded as a non-stroke pixel.

7、根据附记3所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:7. The method according to Note 3, wherein, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, the estimated strokes of the text in the original image Polarity steps, including:

在一个方向上采用如下公式计算所述原始图像中各个原始像素点的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向;In one direction, the following formula is used to calculate the stroke response strength of each original pixel in the original image, and the one direction is any direction in the horizontal direction, the vertical direction and the two diagonal directions;

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n;

判断所述笔画响应强度是否同时满足如下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值,如果是,则依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述原始像素点i的初始极性;Determine whether the stroke response strength meets the following two conditions at the same time: the polarities of [f n (i)-f n (l)] and [f n (i)-f n (k)] on the channel n are maintained consistent and the stroke response intensity is greater than the preset threshold , if so, determine the The initial polarity of the original pixel point i;

判断四个方向上的笔画响应强度是否全部计算完毕,如果是,则将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性;如果否,则重复所述计算所述原始图像中各个原始像素点的笔画响应强度的步骤。Determine whether all stroke response strengths in the four directions have been calculated, and if so, determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke polarity of the line of text; if not, then Repeating the step of calculating the stroke response intensity of each original pixel in the original image.

8、根据附记3所述的方法,其中,所述判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配的步骤,包括:8. The method according to Note 3, wherein the step of judging whether the filtered updated brightness value or/and color value matches the polarity of the stroke includes:

获取所述滤波后的更新亮度值或/和颜色值与原始亮度值或/和颜色值的第一大小关系;Acquiring a first magnitude relationship between the filtered updated brightness value or/and color value and the original brightness value or/and color value;

判断所述第一大小关系与所述笔画极性所表示出的第二大小关系是否匹配。It is judged whether the first size relationship matches the second size relationship represented by the stroke polarity.

9、一种文本增强装置,包括:9. A text enhancement device, comprising:

获取模块,用于获取包括一行文本的原始图像;An acquisition module, configured to acquire an original image including a line of text;

滤波模块,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;A filtering module, configured to perform an original luminance value or/and The color value is subjected to stroke two-dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image, and the range of the neighborhood set is a square with the original pixel as the center and a side length of w, so Said w is less than the height of said original image;

替换模块,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像。A replacement module, configured to respectively replace the corresponding original brightness value or/and color value with the filtered updated brightness value or/and color value, so as to generate a text-enhanced image corresponding to the original image.

10、根据附记9所述的装置,其中,所述滤波模块包括:10. The device according to supplementary note 9, wherein the filtering module includes:

第一获取子模块,用于将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度;The first acquisition submodule is used to algebraically subtract the original pixel point from the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree;

第二获取子模块,用于依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度;The second acquisition sub-module is used to acquire the indirect difference degree according to the gradient modulus from the original pixel point to each neighborhood pixel point of its neighborhood set;

权重计算子模块,用于根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值;The weight calculation sub-module is used to calculate the weight value of each neighborhood pixel for the brightness value or/and color value of the original pixel according to the direct difference degree and the indirect difference degree;

更新亮度值计算子模块,用于采用如下笔画二维滤波公式计算所述原始像素点的更新亮度值;An updated brightness value calculation sub-module, used to calculate the updated brightness value of the original pixel by using the following stroke two-dimensional filtering formula;

gg (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww (( ii ,, jj )) ]] ·· ff (( jj ))

其中,所述N(i)表示像素点i的邻域集,所述w(i,j)表示邻域像素点j对原始像素点i的亮度值的权重值,f(j)为所述邻域集内像素点j的亮度值;和/或,Wherein, the N(i) represents the neighborhood set of the pixel i, the w(i, j) represents the weight value of the neighborhood pixel j to the brightness value of the original pixel i, and f(j) is the The brightness value of pixel point j in the neighborhood set; and/or,

更新颜色值计算子模块,用于采用如下笔画二维滤波公式计算所述原始像素点的更新颜色值;The updated color value calculation submodule is used to calculate the updated color value of the original pixel by using the following stroke two-dimensional filtering formula;

gg nno (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww nno (( ii ,, jj )) ]] ·· ff nno (( jj ))

其中,所述wn(i,j)表示在n通道上邻域像素点j对原始像素点i的颜色值的权重值,fn(j)为n通道上所述邻域集内像素点j的颜色值。Wherein, the w n (i, j) represents the weight value of the color value of the neighborhood pixel point j to the original pixel point i on the n channel, and f n (j) is the pixel point in the neighborhood set on the n channel The color value of j.

11、根据附记9所述的装置,还包括:11. The device according to appendix 9, further comprising:

笔画极性估计模块,用于估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系;以及The stroke polarity estimation module is used to estimate the stroke polarity of the text in the original image, and the polarity represents the magnitude relationship between the brightness value or/and the color value between the pixels inside the stroke area and the pixels outside the stroke area ;as well as

判断模块,应用判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则触发所述替换模块。The judging module is used to judge whether the filtered updated brightness value or/and color value matches the polarity of the stroke, and if so, trigger the replacing module.

12、根据附记11所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述笔画极性估计模块包括:12. According to the device described in supplementary note 11, in the case where the polarity represents the relationship between the brightness value of the pixels inside the stroke area and the pixels outside the stroke area, the stroke polarity estimation module includes:

第一计算子模块,用于在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The first calculation sub-module is used to calculate the stroke response strength using the following formulas in the horizontal direction, the vertical direction and the two diagonal directions respectively:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i;

第一判断子模块,用于判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值;The first judging submodule is used to judge whether the maximum stroke response strength among the four stroke response strengths obtained by the calculation satisfies the following two conditions: [f(i)-f(l)] and [f(i)-f( k)] have the same polarity and the stroke response intensity is greater than a preset threshold;

第一确定子模块,用于在所述第一判断子模块的结果为是的情况下,依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性;The first determining submodule is used for determining the pole according to [f(i)-f(l)] or [f(i)-f(k)] when the result of the first judging submodule is yes determining an estimated stroke polarity of the line of text;

第一触发子模块,用于在所述第一判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第一判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The first triggering submodule is used to select the stroke response strengths obtained according to the size relationship and trigger the first judging submodule sequentially until a certain The stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel.

13、根据附记11所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述笔画极性估计模块包括:13. According to the device described in Supplementary Note 11, in the case where the polarity represents the relationship between the brightness value of the pixels inside the stroke area and the pixels outside the stroke area, the stroke polarity estimation module includes:

第二计算子模块,用于在一个方向上采用如下公式计算所述原始图像中各个原始像素点的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向;The second calculation sub-module is used to calculate the stroke response strength of each original pixel in the original image using the following formula in one direction, the one direction being the horizontal direction, the vertical direction and the two diagonal directions either direction;

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i;

第二判断子模块,用于判断所述笔画响应强度是否同时满足如下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值;The second judging submodule is used to judge whether the stroke response intensity satisfies the following two conditions at the same time: [f(i)-f(l)] and [f(i)-f(k)] have the same polarity and The stroke response intensity is greater than a preset threshold;

第二确定子模块,用于在所述第二判断子模块为是的情况下,依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述原始像素点i的初始极性;The second determining submodule is used to determine the polarity according to [f(i)-f(l)] or [f(i)-f(k)] when the second judging submodule is yes The initial polarity of the original pixel point i;

第三判断子模块,用于判断四个方向上的笔画响应强度是否全部计算完毕;The third judging sub-module is used to judge whether the stroke response strengths in the four directions have all been calculated;

第三确定子模块,用于在所述第三判断子模块的结果为是的情况下,将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性;The third determining submodule is used to determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke pole of the line of text when the result of the third judging submodule is Yes sex;

第二触发子模块,用于在第三判断子模块的结果为否的情况下,触发所述第二计算子模块。The second triggering submodule is configured to trigger the second calculation submodule when the result of the third judging submodule is negative.

14、根据附记11所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述笔画极性估计模块包括:14. According to the device described in supplementary note 11, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, the stroke polarity estimation module includes:

第三计算子模块,用于在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The third calculation sub-module is used to calculate the stroke response strength using the following formulas in the horizontal direction, the vertical direction and the two diagonal directions respectively:

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n;

第四判断子模块,用于判断计算得到的笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值;The fourth judging submodule is used to judge whether the maximum stroke response strength in the calculated stroke response strength meets the following two conditions: [f n (i)-f n (l)] and [f n ( The polarities of i)-f n (k)] are consistent and the stroke response intensity is greater than a preset threshold;

第四确定子模块,用于在所述第四判断子模块的结果为是的情况下,依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性;The fourth determining submodule is used to, when the result of the fourth judging submodule is yes, according to [f n (i)-f n (l)] or [f n (i)-f n (k )] determine the estimated stroke polarity of the line of text;

第三触发子模块,用于在所述第四判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第四判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The third triggering submodule is used to select the stroke response strengths obtained according to the size relationship and trigger the fourth judging submodule in sequence, until the result of the fourth judging submodule is negative, until a certain The stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel.

15、根据附记11所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述笔画极性估计模块包括:15. According to the device described in supplementary note 11, in the case where the polarity represents the color value magnitude relationship between the pixels inside the stroke area and the pixels outside the stroke area, the stroke polarity estimation module includes:

第四计算子模块,用于在一个方向上采用如下公式计算所述原始图像中各个原始像素点的笔画响应强度,所述一个方向为水平方向、竖直方向以及两个对角线方向中的任一方向;The fourth calculation sub-module is used to calculate the stroke response strength of each original pixel in the original image using the following formula in one direction, the one direction being the horizontal direction, the vertical direction and the two diagonal directions either direction;

StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] ||

其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n;

第五判断子模块,用于判断所述笔画响应强度是否同时满足如下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值;The fifth judging submodule is used to judge whether the stroke response intensity satisfies the following two conditions at the same time: [f n (i)-f n (l)] and [f n (i)-f n ( k)] polarities are consistent and the stroke response intensity is greater than a preset threshold;

第五确定子模块,用于在所述第五判断子模块的结果为是的情况下,依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述原始像素点i的初始极性;The fifth determining submodule is used to, when the result of the fifth judging submodule is yes, according to [f n (i)-f n (l)] or [f n (i)-f n (k )] to determine the initial polarity of the original pixel i;

第六判断子模块,用于判断四个方向上的笔画响应强度是否全部计算完毕;The sixth judging sub-module is used to judge whether all the stroke response strengths in the four directions have been calculated;

第六确定子模块,用于在所述判断子模块的结果为是的情况下,将四个方向上的最大的笔画响应强度对应的初始极性确定为所述一行文本的估计笔画极性;The sixth determining submodule is used to determine the initial polarity corresponding to the maximum stroke response strength in the four directions as the estimated stroke polarity of the line of text when the result of the judging submodule is yes;

第四触发子模块,用于在所述第六判断子模块的结果为否的情况下,触发所述第四计算子模块。The fourth triggering submodule is configured to trigger the fourth calculating submodule when the result of the sixth judging submodule is negative.

16、根据附记11所述的装置,所述判断模块包括:16. The device according to supplementary note 11, the judging module includes:

第三获取子模块,用于获取所述滤波后的更新亮度值或/和颜色值与原始亮度值或/和颜色值的第一大小关系;A third acquiring submodule, configured to acquire a first magnitude relationship between the filtered updated brightness value or/and color value and the original brightness value or/and color value;

第七判断子模块,用于判断所述第一大小关系与所述笔画极性所表示出的第二大小关系是否匹配。A seventh judging submodule, configured to judge whether the first size relationship matches the second size relationship represented by the stroke polarity.

17、一种文本提取方法,包括:17. A text extraction method, comprising:

获取包括一行文本的原始图像;Get the original image including a line of text;

依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值;所述邻域集的范围为以原始像素点为中心且边长为w的正方形;所述w小于所述原始图像的高度;According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, the stroke two is performed on the original brightness value or/and color value of each original pixel point Dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image; the range of the neighborhood set is a square with the original pixel as the center and a side length of w; the w is smaller than the the height of the original image;

将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;Replacing the filtered updated brightness value or/and color value with the corresponding original brightness value or/and color value, respectively, to generate a text-enhanced image corresponding to the original image;

提取所述文本增强图像中的文本。Text in the text-enhanced image is extracted.

18、一种文本提取装置,包括:18. A text extraction device, comprising:

获取模块,用于获取包括一行文本的原始图像;An acquisition module, configured to acquire an original image including a line of text;

滤波模块,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;A filtering module, configured to perform an original luminance value or/and The color value is subjected to stroke two-dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image, and the range of the neighborhood set is a square with the original pixel as the center and a side length of w, so Said w is less than the height of said original image;

替换模块,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;A replacement module, configured to replace the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image;

提取模块,用于提取所述文本增强图像中的文本。An extraction module, configured to extract text in the text-enhanced image.

Claims (6)

1.一种文本增强方法,包括:1. A text enhancement method, comprising: 获取包括一行文本的原始图像;Get the original image including a line of text; 依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;According to the direct difference degree and indirect difference degree between any original pixel point in the original image and each neighboring pixel point in its neighborhood set, the stroke two is performed on the original brightness value or/and color value of each original pixel point Dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image, the range of the neighborhood set is a square with the original pixel as the center and a side length of w, and the w is smaller than the the height of the original image; 将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像,replacing the corresponding original brightness value or/and color value with the filtered updated brightness value or/and color value, respectively, to generate a text-enhanced image corresponding to the original image, 其中,所述获取包括一行文本的原始图像之后,还包括:Wherein, after the acquisition of the original image including a line of text, it also includes: 估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系;Estimating the stroke polarity of the text in the original image, the polarity representing the magnitude relationship between the brightness value or/and color value between the pixels inside the stroke area and the pixels outside the stroke area; 以及所述得到所述原始图像的滤波后的更新亮度值或/和颜色值之后,还包括:And after obtaining the filtered updated brightness value or/and color value of the original image, it also includes: 判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则执行所述替换所述原始亮度值或/和颜色值的步骤,judging whether the filtered updated brightness value or/and color value matches the stroke polarity, and if so, performing the step of replacing the original brightness value or/and color value, 其中,所述对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波的步骤,包括:Wherein, the step of performing stroke two-dimensional filtering on the original brightness value or/and color value of each original pixel point includes: 将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度;Perform algebraic subtraction of the original pixel point and the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree; 依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度;Obtain the indirect difference degree according to the gradient modulus from the original pixel point to each neighboring pixel point in its neighborhood set; 根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值;Calculate the weight value of each neighboring pixel point for the brightness value or/and color value of the original pixel point according to the direct difference degree and the indirect difference degree; 采用如下笔画二维滤波公式计算所述原始像素点的更新亮度值;The updated brightness value of the original pixel is calculated by using the following stroke two-dimensional filtering formula; gg (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww (( ii ,, jj )) ]] ·&Center Dot; ff (( jj )) 其中,所述N(i)表示像素点i的邻域集;所述w(i,j)表示邻域像素点j对原始像素点i的亮度值的权重值;f(j)为所述邻域集内像素点j的亮度值;Wherein, the N(i) represents the neighborhood set of the pixel i; the w(i, j) represents the weight value of the neighborhood pixel j to the brightness value of the original pixel i; f(j) is the The brightness value of pixel point j in the neighborhood set; 和/或and / or 采用如下笔画二维滤波公式计算所述原始像素点的更新颜色值;The updated color value of the original pixel is calculated by using the following stroke two-dimensional filtering formula; gg nno (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww nno (( ii ,, jj )) ]] ·&Center Dot; ff nno (( jj )) 其中,所述wn(i,j)表示在n通道上邻域像素点j对原始像素点i的颜色值的权重值;fn(j)为n通道上所述邻域集内像素点j的颜色值。Wherein, the w n (i, j) represents the weight value of the color value of the neighborhood pixel j to the original pixel i on the n channel; f n (j) is the pixel in the neighborhood set on the n channel The color value of j. 2.根据权利要求1所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:2. The method according to claim 1, wherein, under the condition that the polarity represents the brightness value magnitude relationship between the internal pixels of the stroke area and the external pixels of the stroke area, the stroke of the text in the estimated original image Polarity steps, including: 在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The following formulas are used to calculate the stroke response strength in the horizontal direction, vertical direction and two diagonal directions respectively: StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] || 其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i; 判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值,如果是,则依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性;如果否,则依次按照大小关系选取所述计算得到的笔画响应强度执行所述判断步骤,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。Determine whether the maximum stroke response intensity among the four calculated stroke response intensity meets the following two conditions: [f(i)-f(l)] has the same polarity as [f(i)-f(k)] and The stroke response intensity is greater than a preset threshold, if so, determine the estimated stroke polarity of the line of text according to the polarity of [f(i)-f(l)] or [f(i)-f(k)] If not, then select the calculated stroke response strength according to the size relationship to execute the judgment step until a certain stroke response strength satisfies the two conditions, or, when none of the four stroke response strengths When the two conditions are satisfied, the pixel point i is regarded as a non-stroke pixel point. 3.根据权利要求1所述的方法,其中,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述估计原始图像中文本的笔画极性的步骤,包括:3. The method according to claim 1, wherein, under the condition that the polarity represents the color value magnitude relationship between the internal pixels of the stroke area and the external pixels of the stroke area, the stroke of the text in the estimated original image Polarity steps, including: 在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The following formulas are used to calculate the stroke response strength in the horizontal direction, vertical direction and two diagonal directions respectively: StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] || 其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n; 判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值,如果是,则依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性;如果否,则依次按照大小关系选取所述计算得到的笔画响应强度执行所述判断步骤,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。Judging whether the maximum stroke response strength among the four stroke response strengths obtained by calculation satisfies the following two conditions: [f n (i)-f n (l)] and [f n (i)-f n ( The polarities of k)] are consistent and the stroke response intensity is greater than the preset threshold, if so, according to [f n (i)-f n (l)] or [f n (i)-f n (k )] to determine the estimated stroke polarity of the line of text; if not, then select the calculated stroke response strength according to the size relationship to execute the judgment step until a certain stroke response strength satisfies the two condition, or, in the case that none of the four stroke response intensities satisfies the two conditions, the pixel i is regarded as a non-stroke pixel. 4.一种文本增强装置,包括:4. A text enhancement device comprising: 获取模块,用于获取包括一行文本的原始图像;An acquisition module, configured to acquire an original image including a line of text; 滤波模块,用于依据所述原始图像中的任一原始像素点到其邻域集中各个邻域像素点的直接差异度和间接差异度,对所述各个原始像素点的原始亮度值或/和颜色值进行笔画二维滤波,以得到所述原始图像的滤波后的更新亮度值或/和颜色值,所述邻域集的范围为以原始像素点为中心且边长为w的正方形,所述w小于所述原始图像的高度;A filtering module, configured to perform an original luminance value or/and The color value is subjected to stroke two-dimensional filtering to obtain the filtered updated brightness value or/and color value of the original image, and the range of the neighborhood set is a square with the original pixel as the center and a side length of w, so Said w is less than the height of said original image; 替换模块,用于将所述滤波后的更新亮度值或/和颜色值分别替换对应的所述原始亮度值或/和颜色值,以生成与所述原始图像对应的文本增强图像;A replacement module, configured to replace the corresponding original brightness value or/and color value with the updated brightness value or/and color value after filtering, so as to generate a text-enhanced image corresponding to the original image; 笔画极性估计模块,用于估计所述原始图像中文本的笔画极性,所述极性表示位于笔画区域内部像素点与笔画区域外部像素点之间的亮度值或/和颜色值的大小关系;以及The stroke polarity estimation module is used to estimate the stroke polarity of the text in the original image, and the polarity represents the magnitude relationship between the brightness value or/and the color value between the pixels inside the stroke area and the pixels outside the stroke area ;as well as 判断模块,用于判断所述滤波后的更新亮度值或/和颜色值与所述笔画极性是否匹配,如果是,则触发所述替换模块,a judging module, configured to judge whether the filtered updated brightness value or/and color value matches the polarity of the stroke, and if so, trigger the replacement module, 其中,所述滤波模块包括:Wherein, the filter module includes: 第一获取子模块,用于将所述原始像素点与各个邻域像素点的原始亮度值或/和颜色值进行代数相减以获取所述直接差异度;The first acquisition submodule is used to algebraically subtract the original pixel point from the original brightness value or/and color value of each neighboring pixel point to obtain the direct difference degree; 第二获取子模块,用于依据所述原始像素点到其邻域集的各个邻域像素点的梯度模值,获取所述间接差异度;The second acquisition sub-module is used to acquire the indirect difference degree according to the gradient modulus from the original pixel point to each neighborhood pixel point of its neighborhood set; 权重计算子模块,用于根据所述直接差异度和间接差异度计算各个邻域像素点对于所述原始像素点的亮度值或/和颜色值的权重值;The weight calculation sub-module is used to calculate the weight value of each neighborhood pixel for the brightness value or/and color value of the original pixel according to the direct difference degree and the indirect difference degree; 更新亮度值计算子模块,用于采用如下笔画二维滤波公式计算所述原始像素点的更新亮度值;An updated brightness value calculation sub-module, used to calculate the updated brightness value of the original pixel by using the following stroke two-dimensional filtering formula; gg (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww (( ii ,, jj )) ]] ·&Center Dot; ff (( jj )) 其中,所述N(i)表示像素点i的邻域集,所述w(i,j)表示邻域像素点j对原始像素点i的亮度值的权重值,f(j)为所述邻域集内像素点j的亮度值;和/或Wherein, the N(i) represents the neighborhood set of the pixel i, the w(i, j) represents the weight value of the neighborhood pixel j to the brightness value of the original pixel i, and f(j) is the The brightness value of pixel point j in the neighborhood set; and/or 更新颜色值计算子模块,用于采用如下笔画二维滤波公式计算所述原始像素点的更新颜色值;The updated color value calculation submodule is used to calculate the updated color value of the original pixel by using the following stroke two-dimensional filtering formula; gg nno (( ii )) == ΣΣ jj ∈∈ NN (( ii )) expexp [[ -- ww nno (( ii ,, jj )) ]] ·· ff nno (( jj )) 其中,所述wn(i,j)表示在n通道上邻域像素点j对原始像素点i的颜色值的权重值,fn(j)为n通道上所述邻域集内像素点j的颜色值。Wherein, the w n (i, j) represents the weight value of the color value of the neighborhood pixel point j to the original pixel point i on the n channel, and f n (j) is the pixel point in the neighborhood set on the n channel The color value of j. 5.根据权利要求4所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的亮度值大小关系的情况下,所述笔画极性估计模块包括:5. The device according to claim 4, in the case where the polarity represents the brightness value magnitude relationship between the internal pixels of the stroke area and the external pixels of the stroke area, the stroke polarity estimation module includes: 第一计算子模块,用于在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The first calculation sub-module is used to calculate the stroke response strength using the following formulas in the horizontal direction, the vertical direction and the two diagonal directions respectively: StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} || [[ ff (( ii )) -- ff (( ll )) ]] ++ [[ ff (( ii )) -- ff (( kk )) ]] || 其中,所述w为所述原始图像的高度的八分之一,所述f(i)表示像素点i的亮度值;Wherein, the w is one-eighth of the height of the original image, and the f(i) represents the brightness value of the pixel i; 第一判断子模块,用于判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:[f(i)-f(l)]与[f(i)-f(k)]的极性相同且所述笔画响应强度大于预设阈值;The first judging sub-module is used to judge whether the maximum stroke response strength among the four stroke response strengths obtained by the calculation satisfies the following two conditions: [f(i)-f(l)] and [f(i)-f( k)] have the same polarity and the stroke response intensity is greater than a preset threshold; 第一确定子模块,用于在所述第一判断子模块的结果为是的情况下,依据[f(i)-f(l)]或者[f(i)-f(k)]的极性确定所述一行文本的估计笔画极性;The first determining submodule is used for determining the pole according to [f(i)-f(l)] or [f(i)-f(k)] when the result of the first judging submodule is yes determining an estimated stroke polarity of the line of text; 第一触发子模块,用于在所述第一判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第一判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The first triggering submodule is used to select the stroke response strengths obtained according to the size relationship and trigger the first judging submodule sequentially until a certain The stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel. 6.根据权利要求4所述的装置,在所述极性表示笔画区域内部像素点与笔画区域外部像素点之间的颜色值大小关系的情况下,所述笔画极性估计模块包括:6. The device according to claim 4, in the case where the polarity represents the color value magnitude relationship between the internal pixels of the stroke area and the external pixels of the stroke area, the stroke polarity estimation module includes: 第二计算子模块,用于在水平方向、竖直方向以及两个对角线方向上分别采用如下公式计算笔画响应强度:The second calculation sub-module is used to calculate the stroke response strength using the following formulas in the horizontal direction, the vertical direction and the two diagonal directions respectively: StrokeStrengthStroke Strength (( ii )) == maxmax kk ∈∈ {{ ii -- ww // 22 ,, ii }} ,, ll ∈∈ {{ ii ,, ii ++ ww // 22 }} ΣΣ || [[ ff nno (( ii )) -- ff nno (( ll )) ]] ++ [[ ff nno (( ii )) -- ff nno (( kk )) ]] || 其中,所述w为所述原始图像的高度的八分之一,所述fn(i)表示在通道n上像素点i的颜色值;Wherein, the w is one-eighth of the height of the original image, and the f n (i) represents the color value of the pixel i on the channel n; 第二判断子模块,用于判断计算得到的四个笔画响应强度中最大的笔画响应强度是否满足以下两个条件:在通道n上[fn(i)-fn(l)]和[fn(i)-fn(k)]的极性均保持一致且所述笔画响应强度大于预设阈值;The second judging sub-module is used to judge whether the maximum stroke response intensity among the four stroke response intensity calculated by calculation satisfies the following two conditions: [f n (i)-f n (l)] and [f on the channel n The polarities of n (i)-f n (k)] are consistent and the stroke response intensity is greater than a preset threshold; 第二确定子模块,用于在所述第二判断子模块的结果为是的情况下,依据[fn(i)-fn(l)]或者[fn(i)-fn(k)]的极性确定所述一行文本的估计笔画极性;The second determining submodule is used to, when the result of the second judging submodule is yes, according to [f n (i)-f n (l)] or [f n (i)-f n (k )] determine the estimated stroke polarity of the line of text; 第二触发子模块,用于在所述第二判断子模块的结果为否的情况下,依次按照大小关系选取所述计算得到的笔画响应强度并触发所述第二判断子模块,直至某一个笔画响应强度满足所述两个条件,或者,在所述四个笔画响应强度都不满足所述两个条件的情况下,将所述像素点i作为非笔画像素点。The second triggering submodule is used to select the stroke response strengths obtained according to the size relationship and trigger the second judging submodule sequentially until a certain The stroke response intensity satisfies the two conditions, or, when none of the four stroke response intensities meets the two conditions, the pixel i is regarded as a non-stroke pixel.
CN201110172095.1A 2011-06-16 2011-06-16 Text enhancement method and device, text extraction method and device Expired - Fee Related CN102831579B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201110172095.1A CN102831579B (en) 2011-06-16 2011-06-16 Text enhancement method and device, text extraction method and device
JP2012132919A JP5939047B2 (en) 2011-06-16 2012-06-12 Text enhancement method and apparatus, and text extraction method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110172095.1A CN102831579B (en) 2011-06-16 2011-06-16 Text enhancement method and device, text extraction method and device

Publications (2)

Publication Number Publication Date
CN102831579A CN102831579A (en) 2012-12-19
CN102831579B true CN102831579B (en) 2015-06-17

Family

ID=47334696

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110172095.1A Expired - Fee Related CN102831579B (en) 2011-06-16 2011-06-16 Text enhancement method and device, text extraction method and device

Country Status (2)

Country Link
JP (1) JP5939047B2 (en)
CN (1) CN102831579B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106485666B (en) * 2015-08-31 2019-11-29 中国航天科工集团第四研究院指挥自动化技术研发与应用中心 A kind of information indicating method and apparatus
CN109285123B (en) * 2017-07-20 2020-09-11 展讯通信(上海)有限公司 Image smoothing method and device, computer readable storage medium and terminal
CN107424137B (en) * 2017-08-01 2020-06-19 深信服科技股份有限公司 Text enhancement method and device, computer device and readable storage medium
CN110263301B (en) * 2019-06-27 2023-12-05 北京百度网讯科技有限公司 Method and apparatus for determining the color of text
CN110738625B (en) * 2019-10-21 2022-03-11 Oppo广东移动通信有限公司 Image resampling method, device, terminal and computer readable storage medium
CN111582290B (en) * 2020-05-13 2023-04-07 郑州轻工业大学 Computer image recognition method
CN116468640B (en) * 2023-06-20 2023-08-29 山东正禾大教育科技有限公司 A video image enhancement method for Internet teaching

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101021905A (en) * 2006-02-15 2007-08-22 中国科学院自动化研究所 File image binaryzation method

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3501031B2 (en) * 1999-08-24 2004-02-23 日本電気株式会社 Image region determination device, image region determination method, and storage medium storing program thereof
JP3488678B2 (en) * 2000-08-10 2004-01-19 シャープ株式会社 Image classification device
JP4659789B2 (en) * 2006-06-30 2011-03-30 キヤノン株式会社 Image processing apparatus, image processing method, program, and recording medium
US7856142B2 (en) * 2007-01-26 2010-12-21 Sharp Laboratories Of America, Inc. Methods and systems for detecting character content in a digital image
JP2009278363A (en) * 2008-05-14 2009-11-26 Canon Inc Image processor and image processing method
JP2009302761A (en) * 2008-06-11 2009-12-24 Canon Inc Image processor

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101021905A (en) * 2006-02-15 2007-08-22 中国科学院自动化研究所 File image binaryzation method

Also Published As

Publication number Publication date
JP2013004094A (en) 2013-01-07
CN102831579A (en) 2012-12-19
JP5939047B2 (en) 2016-06-22

Similar Documents

Publication Publication Date Title
CN102831579B (en) Text enhancement method and device, text extraction method and device
CN110033471B (en) Frame line detection method based on connected domain analysis and morphological operation
EP2911113B1 (en) Method, apparatus and computer program product for image segmentation
JP3944738B2 (en) Image processing apparatus and method, recording medium, and program
CN103377462B (en) The method and apparatus that scan image is processed
CN104462381A (en) Trademark image retrieval method
CN104036479B (en) Multi-focus image fusion method based on non-negative matrix factorization
CN105741322B (en) A kind of field of view dividing method based on the fusion of video features layer
CN111489333B (en) No-reference night natural image quality evaluation method
CN102063704B (en) Airborne vision enhancement method and device
CN104574328A (en) Color image enhancement method based on histogram segmentation
CN106612386A (en) Noise reduction method combined with spatio-temporal correlation
CN102592113B (en) Rapid identification method for static gestures based on apparent characteristics
CN103312963A (en) Image processing device and image processing method
WO2017088479A1 (en) Method of identifying digital on-screen graphic and device
CN106550244A (en) The picture quality enhancement method and device of video image
CN102625030A (en) Video enhancement method and system
CN103530845A (en) Improved image zooming method
TWI376648B (en) Method and device for keeping image background by multiple gauss models
JP2008210387A (en) Noise removal apparatus and noise removal program for improving binarization performance of document image
EP3062288A1 (en) Method, apparatus and computer program product for reducing chromatic aberrations in deconvolved images
CN103425973A (en) Method and apparatus for performing enhancement processing on text-containing image, and video display device
CN104217411B (en) A kind of irregularly quick joining method of broken one-sided image
CN104506968A (en) Method and device for determining video abstract figure
EP3240291A1 (en) Content providing apparatus, display apparatus and control method therefor

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150617