[go: up one dir, main page]

CN114298932A - A text enhancement processing method, device, equipment and medium - Google Patents

A text enhancement processing method, device, equipment and medium Download PDF

Info

Publication number
CN114298932A
CN114298932A CN202111595841.8A CN202111595841A CN114298932A CN 114298932 A CN114298932 A CN 114298932A CN 202111595841 A CN202111595841 A CN 202111595841A CN 114298932 A CN114298932 A CN 114298932A
Authority
CN
China
Prior art keywords
image
target
pixel value
edge
text
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.)
Granted
Application number
CN202111595841.8A
Other languages
Chinese (zh)
Other versions
CN114298932B (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.)
Jiangsu Ares Intelligent Equipment Co ltd
Original Assignee
Jiangsu Ares Intelligent Equipment Co 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 Jiangsu Ares Intelligent Equipment Co ltd filed Critical Jiangsu Ares Intelligent Equipment Co ltd
Priority to CN202111595841.8A priority Critical patent/CN114298932B/en
Publication of CN114298932A publication Critical patent/CN114298932A/en
Application granted granted Critical
Publication of CN114298932B publication Critical patent/CN114298932B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a medium for character enhancement processing. The method comprises the following steps: acquiring a scanning gray scale image with uniform brightness; performing enhancement processing on the edge points of the scanning gray level image to obtain a target image with hardened text edges; adjusting the gray distribution interval of the target image to obtain an adjusted image; and carrying out edge marking and edge enhancement processing on the adjusted image to obtain a character enhanced image. By the technical scheme of the embodiment of the invention, the character enhancement processing can be carried out on the character image while the algorithm complexity is simplified, the algorithm running speed is increased and the accuracy of the printed characters is ensured, so that the speed and the accuracy of the character enhancement are increased.

Description

一种文字增强处理方法、装置、设备及介质A text enhancement processing method, device, equipment and medium

技术领域technical field

本发明实施例涉及图像处理技术,尤其涉及一种文字增强处理方法、装置、设备及介质。Embodiments of the present invention relate to image processing technologies, and in particular, to a text enhancement processing method, apparatus, device, and medium.

背景技术Background technique

随着科学技术的逐渐发展,人们对于复印机以及打印机等设备印刷出的文字清晰度有了更高的要求。因此,需要利用图像文字增强算法对扫描得到的文字图像进行文字增强处理,以提高印刷出的文字清晰度。With the gradual development of science and technology, people have higher requirements for the clarity of text printed by copiers and printers. Therefore, it is necessary to use an image text enhancement algorithm to perform text enhancement processing on the scanned text image, so as to improve the clarity of the printed text.

现有技术中,通常采用边缘查找、图像模糊、图层叠加以及对比增强运算等一系列的算法来实现对图像文字边缘的增强,然而,由于现有技术所利用的一系列算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰。因此,如何在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理,是目前亟待解决的问题。In the prior art, a series of algorithms such as edge finding, image blurring, layer stacking, and contrast enhancement operations are usually used to enhance the edges of image text. It is complicated and causes great troubles to equipment with limited resources and high real-time requirements. Therefore, how to perform text enhancement processing on text images while simplifying the complexity of the algorithm, improving the running speed of the algorithm and ensuring the accuracy of the printed text is an urgent problem to be solved at present.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供一种文字增强处理方法、装置、设备及介质,可以实现在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理。Embodiments of the present invention provide a text enhancement processing method, device, device and medium, which can implement text enhancement processing on text images while simplifying algorithm complexity, improving algorithm running speed, and ensuring the accuracy of printed text.

第一方面,本发明实施例提供了一种文字增强处理方法,包括:In a first aspect, an embodiment of the present invention provides a text enhancement processing method, including:

获取亮度均匀的扫描灰度图;Obtain a scanned grayscale image with uniform brightness;

对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;

将所述目标图像进行灰度分布区间调整,得到调整图像;Adjusting the gray distribution interval of the target image to obtain an adjusted image;

对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。Perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.

第二方面,本发明实施例还提供了一种文字增强处理装置,该装置包括:In a second aspect, an embodiment of the present invention further provides a text enhancement processing device, the device comprising:

数据获取模块,用于获取亮度均匀的扫描灰度图;The data acquisition module is used to acquire the scanned grayscale image with uniform brightness;

第一增强处理模块,用于对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;a first enhancement processing module, configured to perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;

灰度分布区间调整模块,用于将所述目标图像进行灰度分布区间调整,得到调整图像;a grayscale distribution interval adjustment module, which is used to adjust the grayscale distribution interval of the target image to obtain an adjusted image;

第二增强处理模块,用于对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。The second enhancement processing module is configured to perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.

第三方面,本发明实施例还提供了一种电子设备,所述电子设备包括:In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

一个或多个处理器;one or more processors;

存储装置,用于存储一个或多个程序,storage means for storing one or more programs,

当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本发明任一实施例所述的文字增强处理方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the text enhancement processing method according to any embodiment of the present invention.

第四方面,本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如本发明任一实施例所述的文字增强处理方法。In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the text enhancement described in any embodiment of the present invention is implemented Approach.

本发明实施例的技术方案通过对获取的亮度均匀的扫描灰度图进行边缘点增强处理以得到目标图像,再对目标图像进行灰度分布区间调整,并对调整图像进行边缘标记以及边缘加强处理,得到文字增强图像,解决了现有技术中所利用的算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰的问题,实现在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理。The technical scheme of the embodiment of the present invention obtains the target image by performing edge point enhancement processing on the acquired scanned grayscale image with uniform brightness, then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image. , obtain text-enhanced images, solve the problem that the algorithm preprocessing process used in the prior art is too complicated, and cause great troubles to equipment with limited resources and high real-time requirements, and realizes simplifying algorithm complexity and improving algorithm operation. While ensuring the accuracy of the printed text, the text image is enhanced.

附图说明Description of drawings

图1是现有技术中的一种文字增强方法的流程示意图;1 is a schematic flowchart of a text enhancement method in the prior art;

图2a是本发明实施例提供的一种文字增强处理方法的流程图;2a is a flowchart of a text enhancement processing method provided by an embodiment of the present invention;

图2b是本发明实施例提供的一种图像细节显示的示意图;2b is a schematic diagram of an image detail display provided by an embodiment of the present invention;

图2c是本发明实施例提供的一种灰度分布区间的分布示意图;2c is a schematic diagram of the distribution of a grayscale distribution interval provided by an embodiment of the present invention;

图3a是本发明实施例提供的一种文字增强处理方法的流程图;3a is a flowchart of a text enhancement processing method provided by an embodiment of the present invention;

图3b是本发明实施例提供的一种周围像素模式图的示意图;3b is a schematic diagram of a surrounding pixel pattern diagram provided by an embodiment of the present invention;

图3c是本发明实施例提供的一种目标图像的结果示意图;3c is a schematic diagram of a result of a target image provided by an embodiment of the present invention;

图3d是本发明实施例提供的一种调整图像的结果示意图;3d is a schematic diagram of a result of adjusting an image according to an embodiment of the present invention;

图3e是本发明实施例提供的一种目标标记图生成过程的示意图;3e is a schematic diagram of a process for generating a target marker map according to an embodiment of the present invention;

图3f是本发明实施例提供的一种目标边缘过滤图的示意图;3f is a schematic diagram of a target edge filtering graph provided by an embodiment of the present invention;

图3g是本发明实施例提供的一种目标标记图与目标边缘过滤图叠加结果的示意图3g is a schematic diagram of a result of superimposing a target marker map and a target edge filter map according to an embodiment of the present invention

图3h是本发明实施例提供的一种文字增强图像生成过程的示意图;3h is a schematic diagram of a text-enhanced image generation process provided by an embodiment of the present invention;

图3i是本发明实施例提供的一种文字增强图像的结果示意图;3i is a schematic diagram of a result of a text-enhanced image provided by an embodiment of the present invention;

图3j是本发明实施例提供的一种二值化处理的结果示意图;3j is a schematic diagram of a result of a binarization process provided by an embodiment of the present invention;

图4a是本发明实施例提供的一种优选的文字增强处理方法流程的示意图;Fig. 4a is a schematic diagram of the flow of a preferred text enhancement processing method provided by an embodiment of the present invention;

图4b是本发明实施例提供的一种半色调图像的结果示意图;4b is a schematic diagram of a result of a halftone image provided by an embodiment of the present invention;

图5是本发明实施例提供的一种文字增强处理装置的结构示意图;5 is a schematic structural diagram of a text enhancement processing device provided by an embodiment of the present invention;

图6是本发明实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.

具体实施方式Detailed ways

下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部结构。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention. In addition, it should be noted that, for the convenience of description, the drawings only show some but not all structures related to the present invention.

图1为现有技术中的一种文字增强方法的流程示意图。首先,采用粗定位或细定位来识别文字区域和图片区域,将文字区域与图片区域进行分离;进一步的,对文字区域进行图像优化处理,消除背景无效像素,扫描像素确认文字边缘点并持续查找相邻边缘点,记录边缘位置数据;进一步的,模糊文字图像原图,将边缘位置加深图与模糊后的边缘叠加,并叠加到原图像;最后,对文字区域做动态对比增强使文字整体更清晰。然而,现有技术所使用的文字增强方法在分离文字区域时使用到的识别算法以及特征分析算法复杂度较高且准确性不稳定,大量浮点运算会导致运行效率下降;现有技术所使用的边缘识别算法在对文字的边缘点进行识别时,容易受到输入图像本身特点的影响,若图像中的文字断续不清晰,则会增大边缘识别算法的运算量,产生较大的内存消耗。因此,现有技术所使用的文字增强方法对于集成度、运算量和实时性要求较高的嵌入式设备来讲,具有较大的挑战性。FIG. 1 is a schematic flowchart of a text enhancement method in the prior art. First, use coarse positioning or fine positioning to identify the text area and the picture area, and separate the text area from the picture area; further, perform image optimization processing on the text area, eliminate invalid pixels in the background, scan the pixels to confirm the text edge points and continue to search Adjacent edge points, record the edge position data; further, blur the original image of the text image, superimpose the edge position deepening map with the blurred edge, and superimpose it on the original image; finally, perform dynamic contrast enhancement on the text area to make the text as a whole. clear. However, the recognition algorithm and feature analysis algorithm used in the text enhancement method used in the prior art have high complexity and unstable accuracy, and a large number of floating-point operations will lead to a decrease in operating efficiency; When identifying the edge points of the text, the edge recognition algorithm is easily affected by the characteristics of the input image itself. If the text in the image is not clear, it will increase the calculation amount of the edge recognition algorithm, resulting in a large memory consumption. . Therefore, the text enhancement method used in the prior art is quite challenging for embedded devices that require high integration, computational complexity and real-time performance.

因此,为解决现有技术中所利用的算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰的问题,本发明实施例提出了一种文字增强处理方法。Therefore, in order to solve the problem that the algorithm preprocessing process used in the prior art is too complicated and causes great trouble to devices with limited resources and high real-time requirements, an embodiment of the present invention proposes a text enhancement processing method.

图2a为本发明实施例提供的一种文字增强处理方法的流程图,本实施例可适用于对图像中的文字进行增强处理的情况,该方法可以由文字增强处理装置来执行,该装置可采用硬件和/或软件的方式实现,并一般可以集成在电子设备中,例如,复印机、打印机或文字扫描识别设备等嵌入式设备中。FIG. 2a is a flowchart of a text enhancement processing method provided by an embodiment of the present invention. This embodiment can be applied to the case of performing enhancement processing on text in an image. The method can be executed by a text enhancement processing device, and the device can It is implemented by means of hardware and/or software, and can generally be integrated into electronic devices, such as copiers, printers, or embedded devices such as text scanning and recognition devices.

如图2a所示,本发明实施例提供的一种文字增强处理方法包括以下具体步骤:As shown in FIG. 2a, a text enhancement processing method provided by an embodiment of the present invention includes the following specific steps:

S210:获取亮度均匀的扫描灰度图。S210: Obtain a scanned grayscale image with uniform brightness.

其中,扫描灰度图可以指经接触式图像传感器(Contact Image Sensor,CIS)扫描得到的灰度图。亮度均匀的扫描灰度图可以指扫描灰度图是灰度均匀分布的,且灰度区间为在灰度值0-255之间的标准图像。The scanned grayscale image may refer to a grayscale image scanned by a contact image sensor (Contact Image Sensor, CIS). The scanned grayscale image with uniform brightness may refer to the scanned grayscale image with uniform grayscale distribution, and the grayscale interval is a standard image with a grayscale value of 0-255.

S220:对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像。S220: Perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges.

其中,边缘点可以指扫描灰度图中文字图像边缘的像素点;文字图像边缘也可以称为阴影区,是黑色到白色的一种渐变区域,当相机精度及各项指标达到要求时阴影区可以控制在一个像素。增强处理可以指将文字的边缘点的像素值进行加深处理,以增强文字的边缘点,例如,将文字的边缘点的像素值设置为比当前边缘点的像素值更小的像素值。目标图像可以指经边缘点增强处理后得到的文字边缘硬化的灰度图。Among them, the edge point can refer to the pixel point on the edge of the text image in the scanned grayscale image; the edge of the text image can also be called the shadow area, which is a gradient area from black to white. When the camera accuracy and various indicators meet the requirements, the shadow area Can be controlled in one pixel. The enhancement processing may refer to deepening the pixel value of the edge point of the text to enhance the edge point of the text, for example, setting the pixel value of the edge point of the text to a smaller pixel value than the pixel value of the current edge point. The target image may refer to the hardened grayscale image of the text edge obtained after edge point enhancement processing.

S230:将所述目标图像进行灰度分布区间调整,得到调整图像。S230: Adjust the gray distribution interval of the target image to obtain an adjusted image.

图2b为本发明实施例提供的一种图像细节显示的示意图。当灰度图像转换为二值图像之后,如图2b所示,第一行文字图像中的前两行数字较最后一行数字显示的更为清楚;第二行文字图像中的数字均可以清楚显示;第三行文字图像中的第二行数字几乎不能清楚显示;第四行文字图像中的前二行数字几乎不能清楚显示。因此,为了提升文字图像最后的表现效果,保证明暗对比更清晰,图像细节更明显,需要对文字图像的灰度分布区间进行调整。FIG. 2b is a schematic diagram of an image detail display provided by an embodiment of the present invention. After the grayscale image is converted into a binary image, as shown in Figure 2b, the first two lines of numbers in the first line of text images are displayed more clearly than the last line of numbers; the numbers in the second line of text images can be clearly displayed ; The second line of numbers in the third line of text images can hardly be displayed clearly; the first two lines of numbers in the fourth line of text images can hardly be displayed clearly. Therefore, in order to improve the final performance effect of the text image, ensure that the contrast between light and dark is clearer, and the image details are more obvious, it is necessary to adjust the grayscale distribution interval of the text image.

图2c为本发明实施例提供的一种灰度分布区间的分布示意图,其中,黑色标记为印刷机着墨点处。本发明实施例以滚筒式油墨印刷机为测试机器,如图2c所示调整灰度分布区间,具体的,由于滚筒式油墨印刷机的墨点容易外扩使墨点粘连,在图像暗部(像素值较低区域,0~80)区分度不明显,因此需要将暗部继续加深,让出更多灰度区间;次暗部(80~120)由于区分度还是不明显,因此也需要扩大范围提升对比度;亮部(120~240)对比明显,可以将其区间向右侧压缩,给次暗部让出空间;高光部(240以上)变化不大,不需要再次进行调整。最终得到图像暗部区间为0~50,次暗部区间为50~155,亮部区间为155~245,高光部区间为245~255的灰度分布区间。由此,通过将文字图像的灰度图像进行调整,可以让文字图像的暗部更暗,亮部更亮,使得文字边缘更清晰,能在增强文字的同时兼顾图像的清晰度。FIG. 2c is a schematic diagram of the distribution of a gray-scale distribution interval provided by an embodiment of the present invention, wherein the black marks are the ink points of the printing press. In the embodiment of the present invention, a cylinder type ink printing machine is used as a test machine, and the gray scale distribution interval is adjusted as shown in Figure 2c. In the area with lower value, the degree of discrimination is not obvious, so it is necessary to deepen the dark part to make more grayscale intervals; the degree of discrimination in the second dark part (80-120) is still not obvious, so it is also necessary to expand the range to improve the contrast. ; The bright part (120~240) has obvious contrast, and the interval can be compressed to the right to make room for the second dark part; the highlight part (above 240) does not change much, and does not need to be adjusted again. Finally, the gray distribution interval of the dark part of the image is 0-50, the sub-dark part is 50-155, the bright part is 155-245, and the highlight part is 245-255. Therefore, by adjusting the grayscale image of the text image, the dark part of the text image can be made darker, and the bright part of the text image can be brighter, so that the edge of the text can be sharper, and the text can be enhanced while taking into account the clarity of the image.

值得注意的是,本发明实施例提供的一种灰度分布区间的分布示意图虽然能够反应出视觉上均匀变化的趋势,但由于不同印刷方式以及印刷条件都会对墨点大小产生影响,导致实际印刷的效果和理论值有差异,因此,在不同应用环境中,应当在本发明实施例的基础上根据机器以及耗材属性对参数进行进一步调整或作其他运算处理,本发明实施例对此不进行限制。It is worth noting that although the distribution schematic diagram of a grayscale distribution interval provided by the embodiment of the present invention can reflect the trend of visual uniform change, different printing methods and printing conditions will affect the size of the ink dots, resulting in actual printing. Therefore, in different application environments, the parameters should be further adjusted or processed according to the properties of the machine and consumables on the basis of the embodiment of the present invention, which is not limited in the embodiment of the present invention .

S240:对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。S240: Perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.

其中,边缘标记可以指对调整图像中的文字边缘点进行标记处理,例如,可以在新建的一张标记图中将调整图像中的文字边缘点在标记图中对应位置进行标记。边缘加强处理可以指将边缘标记得到的边缘点进行增强处理,以得到边缘增强后的文字增强图像。The edge marking may refer to marking the text edge points in the adjusted image, for example, the text edge points in the adjusted image may be marked at corresponding positions in the marking map in a newly created marking map. The edge enhancement processing may refer to enhancing the edge points obtained by the edge marking to obtain the text-enhanced image after edge enhancement.

本发明实施例的技术方案通过对获取的亮度均匀的扫描灰度图进行边缘点增强处理以得到目标图像,再对目标图像进行灰度分布区间调整,并对调整图像进行边缘标记以及边缘加强处理,得到文字增强图像,解决了现有技术中所利用的算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰的问题,实现在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理。The technical scheme of the embodiment of the present invention obtains the target image by performing edge point enhancement processing on the acquired scanned grayscale image with uniform brightness, then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image. , obtain text-enhanced images, solve the problem that the algorithm preprocessing process used in the prior art is too complicated, and cause great troubles to equipment with limited resources and high real-time requirements, and realizes simplifying algorithm complexity and improving algorithm operation. While ensuring the accuracy of the printed text, the text image is enhanced.

图3a为本发明实施例提供的一种文字增强处理方法的流程图。在本实施例中,可选的,对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像包括:利用周围像素模式图对所述扫描灰度图中的各个像素进行分析,得到文字的目标边缘点以及参考点;基于所述参考点的像素值以及目标边缘点的像素值确定边缘加深像素值,并利用边缘加深像素值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像。FIG. 3a is a flowchart of a text enhancement processing method provided by an embodiment of the present invention. In this embodiment, optionally, performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges includes: using the surrounding pixel pattern map to perform an enhancement process on each pixel in the scanned grayscale image. Analyze, obtain the target edge point and reference point of the text; Determine the edge deepening pixel value based on the pixel value of the reference point and the pixel value of the target edge point, and utilize the edge deepening pixel value to the target edge in the scanning grayscale image Point to darken to get the target image with hardened text edges.

可选的,所述对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像包括:构建各个像素值初始值均为最小像素值的标记图;获取所述调整图像中像素值大于等于标记背景值的目标像素点的像素值,并计算出以所述目标像素点为中心的设定区域中像素值低于标记实体值的像素点的数量以及像素值高于标记背景值的像素点的数量,分别作为第一数量和第二数量;若所述第一数量小于等于第一数量阈值或者所述第二数量小于等于第二数量阈值,则将所述标记图中目标像素点对应位置的像素值标记为第一目标像素值,否则,标记为目标像素点的像素值,得到预处理标记图;其中,所述第一数量阈值小于所述第二数量阈值;所述第一目标像素值大于所述最小像素值;对所述预处理标记图中以各个像素值大于标记背景值的像素点为中心的预设区域进行检索,将所述预设区域中像素值等于所述最小像素值的像素点的像素值标记为第二目标像素值,得到目标标记图;其中,所述第二目标像素值大于所述第一目标像素值;对所述调整图像进行备份得到调整图像副本,根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像。Optionally, performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image includes: constructing a marker map whose initial value of each pixel value is a minimum pixel value; obtaining a pixel value in the adjusted image that is greater than or equal to Mark the pixel value of the target pixel of the background value, and calculate the number of pixels whose pixel value is lower than the marked entity value and the number of pixels whose pixel value is higher than the marked background value in the set area centered on the target pixel. If the first number is less than or equal to the first number threshold or the second number is less than or equal to the second number threshold, the corresponding position of the target pixel in the marker map The pixel value of is marked as the first target pixel value, otherwise, marked as the pixel value of the target pixel point, to obtain a preprocessing mark map; wherein, the first quantity threshold is less than the second quantity threshold; the first target pixel value is greater than the minimum pixel value; search the preset area centered on the pixel whose pixel value is greater than the background value of the marker in the preprocessing marker map, and set the pixel value in the preset area equal to the minimum pixel value The pixel value of the pixel point of the value is marked as the second target pixel value, and the target marker map is obtained; wherein, the second target pixel value is greater than the first target pixel value; the adjusted image is backed up to obtain a copy of the adjusted image, Filling and blurring the adjusted image copy according to the target marker map to obtain a blurred image, and using the blurred image to perform edge enhancement processing on the adjusted image to obtain a text-enhanced image.

如图3a所示,本发明实施例提供的一种文字增强处理方法包括以下具体步骤:As shown in FIG. 3a, a text enhancement processing method provided by an embodiment of the present invention includes the following specific steps:

S310:获取亮度均匀的扫描灰度图。S310: Obtain a scanned grayscale image with uniform brightness.

S320:利用周围像素模式图对所述扫描灰度图中的各个像素进行分析,得到文字的目标边缘点以及参考点。S320: Use the surrounding pixel pattern map to analyze each pixel in the scanned grayscale image to obtain the target edge point and reference point of the text.

其中,周围像素模式图可以指根据文字图像中像素的周围环境拟定的模式图,示例性的,通常边缘点上方应该为背景像素点,则可以根据边缘点上方像素点的模式生成上边缘模式图。目标边缘点可以指需要从扫描灰度图中获取的文字图像的边缘像素点,通常为周围像素模式图中表示实体像素点的中心点。参考点可以指扫描灰度图中可以用于对目标边缘点进行处理的参考像素点。The surrounding pixel pattern map may refer to a pattern map prepared according to the surrounding environment of the pixels in the text image. Exemplarily, usually, the background pixels should be above the edge points, and the upper edge pattern map can be generated according to the pattern of the pixels above the edge points. . The target edge point may refer to the edge pixel point of the text image that needs to be obtained from the scanned grayscale image, and is usually the center point representing the entity pixel point in the surrounding pixel pattern image. The reference point may refer to a reference pixel point that can be used to process the target edge point in the scanned grayscale image.

如图3b所示为本发明实施例提供的一种周围像素模式图的示意图,其中,M1表示上边缘模式,M2表示下边缘模式,M3表示左边缘模式,M4表示右边缘模式,M5表示左上边缘模式,M6表示左下边缘模式,M7表示右上边缘模式,M8表示右下边缘模式,图中实心圆表示实体像素点,空白圆圈表示背景像素点,X表示参考点,灰色背景的实心圆表示目标边缘点。其中,需要根据两个阈值来判定当前像素点为实体像素点还是背景像素点,示例性的,在本发明实施例中,将背景像素点的像素值阈值设定为dW,将实体像素点的像素值阈值设定为dB,若当前像素点的像素值小于dB则判定该像素点为实体像素点,若当前像素点的像素值大于dW则判定该像素点为背景像素点,在一个可选的实施方式中,dW取值250,dB根据图像实际需求可以取160~240。具体的,首先,对扫描灰度图中的各个像素点进行扫描,根据像素值阈值对扫描灰度图中的各个像素点进行判定得出实体像素点以及背景像素点,再根据周围像素模式图M1-M8中各个像素点的位置即可确定出目标边缘点以及参考点。3b is a schematic diagram of a surrounding pixel pattern diagram provided by an embodiment of the present invention, wherein M1 represents the upper edge mode, M2 represents the lower edge mode, M3 represents the left edge mode, M4 represents the right edge mode, and M5 represents the upper left edge mode. Edge mode, M6 represents the lower left edge mode, M7 represents the upper right edge mode, M8 represents the lower right edge mode, the solid circle in the figure represents the solid pixel point, the blank circle represents the background pixel point, X represents the reference point, and the solid circle with the gray background represents the target edge point. Among them, it is necessary to determine whether the current pixel is a solid pixel or a background pixel according to two thresholds. Exemplarily, in this embodiment of the present invention, the pixel value threshold of the background pixel is set to dW, and the The pixel value threshold is set to dB. If the pixel value of the current pixel is less than dB, the pixel is determined to be a solid pixel. If the pixel value of the current pixel is greater than dW, the pixel is determined to be a background pixel. In the embodiment of , the dW value is 250, and the dB value can be 160-240 according to the actual needs of the image. Specifically, first, each pixel in the scanned grayscale image is scanned, and each pixel in the scanned grayscale image is determined according to the pixel value threshold to obtain a solid pixel point and a background pixel point, and then according to the surrounding pixel pattern map The position of each pixel point in M1-M8 can determine the target edge point and the reference point.

S330:基于所述参考点的像素值以及目标边缘点的像素值确定边缘加深像素值,并利用边缘加深像素值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像。S330: Determine an edge deepening pixel value based on the pixel value of the reference point and the pixel value of the target edge point, and use the edge deepening pixel value to deepen the target edge point in the scanned grayscale image to obtain a text edge hardening target image.

其中,边缘加深像素值可以指计算得到的,对目标边缘点的像素值进行加深的像素值,示例性的,可以将参考点的像素值和目标边缘点的像素值的中间值作为边缘加深像素值。具体的,若扫描灰度图中的各个像素点的位置与周围像素模式图M1-M8中各个像素点的位置匹配,在确定出目标边缘点以及参考点之后,可以按照公式:边缘加深像素值=(参考点的像素值+目标边缘点的像素值)/2,计算得出边缘加深像素值,并利用计算得到的边缘加深像素值对扫描灰度图中的目标边缘点进行加深,以得到目标图像。Wherein, the edge deepening pixel value may refer to the calculated pixel value that deepens the pixel value of the target edge point. Exemplarily, the middle value of the pixel value of the reference point and the pixel value of the target edge point may be used as the edge deepening pixel. value. Specifically, if the position of each pixel in the scanned grayscale map matches the position of each pixel in the surrounding pixel pattern maps M1-M8, after determining the target edge point and the reference point, you can follow the formula: edge deepening pixel value =(the pixel value of the reference point + the pixel value of the target edge point)/2, calculate the edge deepening pixel value, and use the calculated edge deepening pixel value to deepen the target edge point in the scanned grayscale image to obtain target image.

在一个可选的实施方式中,所述利用边缘加深目标值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像包括:获取在各个周围像素模式图中计算得到的最小边缘加深像素值,并将所述最小边缘加深像素值与目标边缘点的像素值进行比较;若所述最小边缘加深像素值小于目标边缘点的像素值,则将所述目标边缘点的像素值赋值为最小边缘加深像素值,得到文字边缘硬化的目标图像。具体的,若扫描灰度图中的各个像素点的位置与周围像素模式图M1中各个像素点的位置匹配成功,计算得到边缘加深像素值VT1,若边缘加深像素值VT1小于目标边缘点的像素值,则将所述目标边缘点的像素值赋值为边缘加深像素值VT1;进一步的,再将扫描灰度图中的各个像素点的位置与周围像素模式图M2中各个像素点的位置进行匹配,若扫描灰度图中的各个像素点的位置与周围像素模式图M2中各个像素点的位置匹配成功,计算得到边缘加深像素值VT2,若边缘加深像素值VT2小于边缘加深像素值VT1,则利用边缘加深像素值VT2替换边缘加深像素值VT1,并将目标边缘点的像素值赋值为边缘加深像素值VT2;以此为例,再依次完成周围像素模式图M3-M8的匹配,最终将目标边缘点的像素值赋值为最小边缘加深像素值,即可以得到文字边缘硬化的目标图像。In an optional implementation manner, the step of deepening the target edge points in the scanned grayscale image by using the edge deepening target value to obtain the target image of text edge hardening includes: obtaining the image obtained by calculating in each surrounding pixel pattern map. The minimum edge deepening pixel value, and the minimum edge deepening pixel value is compared with the pixel value of the target edge point; if the minimum edge deepening pixel value is less than the pixel value of the target edge point, then the target edge point The pixel value is assigned as the minimum edge deepening pixel value to obtain the target image with hardened text edges. Specifically, if the position of each pixel in the scanned grayscale image is successfully matched with the position of each pixel in the surrounding pixel pattern map M1, the edge deepening pixel value VT1 is calculated, and if the edge deepening pixel value VT1 is smaller than the pixel of the target edge point value, then the pixel value of the target edge point is assigned as the edge deepening pixel value VT1; Further, the position of each pixel point in the scanning grayscale map is matched with the position of each pixel point in the surrounding pixel pattern map M2 , if the position of each pixel in the scanned grayscale image is successfully matched with the position of each pixel in the surrounding pixel pattern map M2, the edge deepening pixel value VT2 is calculated, and if the edge deepening pixel value VT2 is less than the edge deepening pixel value VT1, then Use the edge deepening pixel value VT2 to replace the edge deepening pixel value VT1, and assign the pixel value of the target edge point to the edge deepening pixel value VT2; take this as an example, and then complete the matching of the surrounding pixel pattern maps M3-M8 in turn, and finally the target The pixel value of the edge point is assigned as the minimum edge deepening pixel value, that is, the target image with hardened text edge can be obtained.

如图3c所示为本发明实施例提供的一种目标图像的结果示意图。其中,左侧为扫描灰度图,右侧为文字边缘硬化的目标图像。从图3c中可以看出,本发明实施例所得到的目标图像在文字边缘区域有部分像素被明显加深,使得文字图像更加清晰。FIG. 3c is a schematic diagram of a result of a target image provided by an embodiment of the present invention. Among them, the left side is the scanned grayscale image, and the right side is the target image with hardened text edges. It can be seen from FIG. 3c that, in the target image obtained in the embodiment of the present invention, some pixels in the text edge region are obviously deepened, so that the text image is clearer.

S340:将所述目标图像进行灰度分布区间调整,得到调整图像。S340: Adjust the gray distribution interval of the target image to obtain an adjusted image.

如图3d所示为本发明实施例提供的一种调整图像的结果示意图。其中,左侧为灰度分布区间调整之前的目标图像,右侧为灰度分布区间调整之后的调整图像。从图3d中可以看出,调整图像有明显的对比度增强的效果,“翁”字笔画间的多余灰度被减弱,“黨”字周围则更加清晰,并且文字图像边缘过渡区在灰度分布区间调整过程中已经被减淡,为后续工作提供了便利。FIG. 3d is a schematic diagram of a result of adjusting an image according to an embodiment of the present invention. Among them, the left side is the target image before the gray distribution interval adjustment, and the right side is the adjusted image after the gray distribution interval adjustment. It can be seen from Figure 3d that adjusting the image has obvious contrast enhancement effect, the excess grayscale between the strokes of the word "Weng" is weakened, and the surrounding of the word "Dang" is clearer, and the transition area of the edge of the text image is distributed in the grayscale. The interval adjustment process has been lightened, which provides convenience for the follow-up work.

S350:构建各个像素值初始值均为最小像素值的标记图。S350: Constructing a marker map in which the initial value of each pixel value is the minimum pixel value.

其中,最小像素值可以指每个像素点的像素初始值均为0。标记图可以指每个像素点的像素初始值均为0的图像。The minimum pixel value may refer to that the initial pixel value of each pixel is 0. A marker map can refer to an image in which the initial value of each pixel is 0.

S360:获取所述调整图像中像素值大于等于标记背景值的目标像素点的像素值,并计算出以所述目标像素点为中心的设定区域中像素值低于标记实体值的像素点的数量以及像素值高于标记背景值的像素点的数量,分别作为第一数量和第二数量。S360: Acquire the pixel value of the target pixel whose pixel value is greater than or equal to the marked background value in the adjusted image, and calculate the pixel value of the pixel whose pixel value is lower than the marked entity value in the set area centered on the target pixel. The number and the number of pixel points whose pixel value is higher than the marked background value are taken as the first number and the second number, respectively.

其中,设定区域可以指以目标像素点为中心的正方形区域,例如,以目标像素点为中心的5×5区域。标记背景值可以指用于标记实体像素点的阈值mW,示例性的,mW可以取值为230;标记实体值可以指用于标记背景像素点的阈值mB,示例性的,mB可以取值为135。通常,像素值高于标记背景值mW的像素点视作标记背景像素点,像素值低于标记实体值mB的像素点视为标记实体像素点。第一数量可以指以目标像素点为中心的设定区域中标记实体像素点的数量nB;第二数量可以指以目标像素点为中心的设定区域中标记背景像素点的数量nW。The setting area may refer to a square area centered on the target pixel, for example, a 5×5 area centered on the target pixel. The marked background value may refer to the threshold mW used to mark the entity pixels, for example, mW may be 230; the marked entity value may refer to the threshold mB used to mark the background pixels, for example, mB may take the value of 230. 135. Generally, the pixels whose pixel values are higher than the marked background value mW are regarded as marked background pixels, and the pixels whose pixel values are lower than the marked entity value mB are regarded as marked real pixels. The first number may refer to the number nB of marked entity pixels in the set area centered on the target pixel; the second number may refer to the number nW of marked background pixels in the set area centered on the target pixel.

具体的,对调整图像中的各个像素点进行扫描,当目标像素点的像素值f(x,y)大于等于标记背景值mW时,以目标像素点为中心点,按照表1的形式取样并检索目标像素点周围5×5范围内的像素点,对5×5范围内标记实体像素点的数量nB以及标记背景像素点的数量nW进行统计,得到第一数量和第二数量。Specifically, scan each pixel in the adjusted image, and when the pixel value f(x, y) of the target pixel is greater than or equal to the marked background value mW, take the target pixel as the center point, and sample and analyze in the form of Table 1. Retrieve the pixels within a 5×5 range around the target pixel, and count the number nB of marked entity pixels and the number of marked background pixels nW within the 5×5 range to obtain the first number and the second number.

表1以目标像素点为中心点5×5范围内的像素点Table 1 takes the target pixel as the center point and the pixels in the range of 5 × 5

Figure BDA0003431083930000091
Figure BDA0003431083930000091

S370:若所述第一数量小于等于第一数量阈值或者所述第二数量小于等于第二数量阈值,则将所述标记图中目标像素点对应位置的像素值标记为第一目标像素值,否则,标记为目标像素点的像素值,得到预处理标记图;其中,所述第一数量阈值小于所述第二数量阈值;所述第一目标像素值大于所述最小像素值。S370: If the first quantity is less than or equal to the first quantity threshold or the second quantity is less than or equal to the second quantity threshold, marking the pixel value at the corresponding position of the target pixel in the marking map as the first target pixel value, Otherwise, mark the pixel value of the target pixel to obtain a preprocessing mark map; wherein the first number threshold is less than the second number threshold; the first target pixel value is greater than the minimum pixel value.

其中,第一数量阈值可以指用于对第一数量进行评估的数值;第二数量阈值可以指用于对第二数量进行评估的数值。第一目标像素值可以指在第一数量小于等于第一数量阈值或者所述第二数量小于等于第二数量阈值时,将标记图中目标像素点对应位置的像素初始值进行修改的数值。示例性的,在本发明实施例中,可以将第一数量阈值设置为1;将第二数量阈值设置为2;将第一目标像素值设置为1,表示为远离边缘的背景像素点。具体的,当f(x,y)>=mW时,则f(x,y)对应的目标像素点可能为背景像素点,若nB太小说明目标像素点远离实体,若nW太小说明目标像素点远离空白即可能处于一片色块之中,由于边缘像素点周围通常既有实体像素点又有背景像素点,因此,nB太小或者nW太小目标像素点都不能作为临近边缘的像素点,故当第一数量nB<=1或者第二数量nW<=2时,则将标记图中目标像素点对应位置(x,y)的像素值标记为1,视作远离边缘的背景像素点,否则标记为目标像素点的像素值f(x,y)。Wherein, the first quantity threshold may refer to a numerical value used for evaluating the first quantity; the second quantity threshold may refer to a numerical value used for evaluating the second quantity. The first target pixel value may refer to a value that modifies the initial value of the pixel at the corresponding position of the target pixel in the marker diagram when the first quantity is less than or equal to the first quantity threshold or the second quantity is less than or equal to the second quantity threshold. Exemplarily, in the embodiment of the present invention, the first quantity threshold may be set to 1; the second quantity threshold may be set to 2; Specifically, when f(x,y)>=mW, the target pixel corresponding to f(x,y) may be the background pixel. If nB is too small, the target pixel is far away from the entity. If nW is too small, the target Pixels that are far from the blank may be in a color block. Since there are usually both solid pixels and background pixels around the edge pixels, if nB is too small or nW is too small, the target pixels cannot be used as pixels near the edge. , so when the first number nB<=1 or the second number nW<=2, the pixel value of the corresponding position (x, y) of the target pixel in the marked image is marked as 1, which is regarded as a background pixel far away from the edge , otherwise marked as the pixel value f(x,y) of the target pixel.

S380:对所述预处理标记图中以各个像素值大于标记背景值的像素点为中心的预设区域进行检索,将所述预设区域中像素值等于所述最小像素值的像素点的像素值标记为第二目标像素值,得到目标标记图;其中,所述第二目标像素值大于所述第一目标像素值。S380: Retrieve a preset area centered on the pixels whose pixel values are greater than the marked background value in the preprocessed marking map, and retrieve the pixels whose pixel values are equal to the minimum pixel value in the preset area. The value is marked as a second target pixel value, and a target marker map is obtained; wherein, the second target pixel value is greater than the first target pixel value.

其中,预设区域可以指以各个像素值大于标记背景值的像素点为中心的正方形区域,示例性的,可以为如表2所示的3×3区域,其中,中心点的像素值记为f(x,y)。第二目标像素值可以指在预设区域中存在最小像素值的像素点时,对该像素点进行修改的数值,在本发明实施例中,第二目标像素值可以为2,表示为待加深的边缘像素点。The preset area may refer to a square area centered on a pixel whose pixel value is greater than the marked background value, exemplarily, may be a 3×3 area as shown in Table 2, where the pixel value of the center point is denoted as f(x,y). The second target pixel value may refer to a value for modifying the pixel point when there is a pixel point with the minimum pixel value in the preset area. In the embodiment of the present invention, the second target pixel value may be 2, which indicates that the pixel point is to be deepened. edge pixels.

具体的,当对以预处理标记图中像素值大于标记背景值的像素点为中心的3×3范围进行检索时,若检索到存在像素值为0的像素点,则将该像素点的像素值标记为2,即待加深的边缘像素点,得到最终的目标标记图。Specifically, when retrieving the 3 × 3 range centered on the pixels whose pixel values in the preprocessing marker map are greater than the marker background value, if a pixel with a pixel value of 0 is retrieved, the pixel of the pixel is retrieved. The value is marked as 2, that is, the edge pixels to be deepened, and the final target mark map is obtained.

表2以像素值大于标记背景值的像素点为中心的3×3范围内的像素点Table 2 Pixels within a 3×3 range centered on the pixel whose pixel value is greater than the marked background value

Figure BDA0003431083930000111
Figure BDA0003431083930000111

如图3e所示为本发明实施例提供的一种目标标记图生成过程的示意图。其中,图(a)为调整图像,图(b)为调整图像的局部放大图,图(c)为局部的目标标记图,图(d)为目标标记图中值为2的边缘像素点与调整图像图像叠加得到的图像。从图3e可以看出,目标标记图中值为2的边缘像素点较为准确,若依据目标标记图对调整图像的边缘进行再次加强,得到的图(d)相较于图(a)将会有更好的文字增强效果。FIG. 3e is a schematic diagram of a process of generating a target marker map according to an embodiment of the present invention. Among them, Figure (a) is the adjusted image, Figure (b) is a partial enlarged image of the adjusted image, Figure (c) is the local target marker image, and Figure (d) is the edge pixel with a value of 2 in the target marker image. Adjusts the image resulting from the image overlay. As can be seen from Figure 3e, the edge pixels with a value of 2 in the target marker map are more accurate. If the edge of the adjusted image is enhanced again according to the target marker map, the resulting image (d) will be more accurate than image (a). There are better text enhancements.

S390:对所述调整图像进行备份得到调整图像副本,并根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像。S390: Backing up the adjusted image to obtain a copy of the adjusted image, and filling and blurring the copy of the adjusted image according to the target marker map to obtain a blurred image, and using the blurred image to align the adjusted image Perform edge enhancement processing to obtain text-enhanced images.

其中,对所述目标标记图进行填充可以指将目标标记图中像素值超过标记背景值mW的像素点的像素值进行填充。模糊处理可以指利用算法对填充后的目标标记图进行模糊操作;通过模糊处理可以使临近文字边缘的背景像素点和实体像素点同时对文字边缘进行侵染,文字边缘在模糊处理的过程中可以被明显加深,同时临近文字边缘的实体像素点可以被减淡。调整图像副本可以指对调整图像进行备份处理的副本图像。Wherein, filling the target marker map may refer to filling the pixel values of the pixel points whose pixel values in the target marker map exceed the marker background value mW. Blur processing can refer to the use of algorithms to blur the filled target marker map; through blurring processing, the background pixels and solid pixels near the text edge can simultaneously infect the text edge, and the text edge can be blurred in the process of processing. is significantly darkened, while solid pixels near the edge of the text can be lightened. The adjusted image copy may refer to a duplicate image that is backed up of the adjusted image.

在一个可选的实施方式中,所述根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像包括:将所述调整图像副本中与所述目标标记图中像素值超过标记背景值的像素点所对应的像素点的像素值替换为目标像素值,得到目标填充图;利用线性插值缩放方法对所述目标填充图进行缩放变换,得到模糊后的图像;将所述模糊后的图像中符合设定条件的像素值赋值至所述调整图像的相应位置,得到文字增强图像。其中,在本发明实施例中,目标像素值可以设定为155。设定条件的像素值可以指模糊后的图像中被加深的像素点的像素值。调整图像的相应位置可以指可以指目标标记图中值为2且在目标边缘过滤图中有效的像素点的位置;还可以指在目标边缘过滤图中无效但本身像素值很深,例如像素值小于80的像素点的位置。其中,目标边缘过滤图可以指根据周围像素模式图M1-M8对调整图像进行边缘点判断的边缘过滤图,在目标边缘过滤图中将背景像素值固定为255,像素值小于255的像素点视作实体像素点,并将目标边缘过滤图中非空白的像素点作为边缘过滤的标记。如图3f所示为本发明实施例提供的一种目标边缘过滤图的示意图,其中,示意图为将目标边缘过滤图与调整图像叠加后的结果图。如图3g所示为本发明实施例提供的一种目标标记图与目标边缘过滤图叠加结果的示意图,其中,浅灰色为目标边缘过滤图的边缘结果,深灰色为目标标记图的边缘结果,黑色为目标标记图与目标边缘过滤图的叠加结果,由于目标标记图中标记的边缘,小字临近笔画之间容易被标记为边缘加深,但这部分加深容易使笔画间隙变小,使最终字迹模糊不清;另外,若文字周围一圈完全被标记,标记边缘会太满使得加深后可能造成字体笔画过粗,比原稿粗出一大圈的现象。因此,本发明实施例在实际加深时,加深的区域必须是目标标记图与目标边缘过滤图的交集。In an optional implementation manner, the adjusted image copy is filled and blurred according to the target marker map to obtain a blurred image, and edge enhancement processing is performed on the adjusted image by using the blurred image , obtaining the text-enhanced image includes: replacing the pixel value of the pixel corresponding to the pixel whose pixel value in the target marker map exceeds the marker background value in the adjustment image copy with the target pixel value to obtain the target fill map; using The linear interpolation scaling method scales and transforms the target fill image to obtain a blurred image; assigns pixel values that meet the set conditions in the blurred image to corresponding positions in the adjusted image to obtain a text-enhanced image. Wherein, in this embodiment of the present invention, the target pixel value may be set to 155. The pixel value of the setting condition may refer to the pixel value of the darkened pixel point in the blurred image. Adjusting the corresponding position of the image can refer to the position of the pixel that has a value of 2 in the target marker map and is valid in the target edge filter map; it can also refer to the pixel value that is invalid in the target edge filter map but has a deep pixel value, such as pixel value The position of the pixel that is less than 80. Among them, the target edge filter map may refer to the edge filter map for judging the edge points of the adjusted image according to the surrounding pixel pattern maps M1-M8. Make solid pixels, and use non-blank pixels in the target edge filtering image as edge filtering marks. FIG. 3f is a schematic diagram of a target edge filter map provided by an embodiment of the present invention, wherein the schematic diagram is a result map after superimposing the target edge filter map and the adjusted image. Figure 3g is a schematic diagram of the superimposed result of a target marker graph and a target edge filter graph provided by an embodiment of the present invention, wherein the light gray is the edge result of the target edge filter graph, and the dark gray is the edge result of the target marker graph, The black color is the superposition result of the target marker image and the target edge filter image. Due to the edge of the marker in the target marker image, the adjacent strokes of small characters are easily marked as edge deepening, but this part of the deepening can easily make the stroke gap smaller, making the final handwriting blurred Not clear; in addition, if a circle around the text is completely marked, the edge of the mark will be too full, and after deepening, it may cause the font stroke to be too thick and a large circle thicker than the original. Therefore, when the embodiment of the present invention is actually deepened, the deepened area must be the intersection of the target marker map and the target edge filter map.

如图3h所示为本发明实施例提供的一种文字增强图像生成过程的示意图,其中,图(a)为目标填充图,图(b)为模糊后的图像。示例性的,首先,将调整图像副本中与目标标记图中像素值超过标记背景值mW的像素点对应的像素点的像素值替换为155得到目标填充图,再使用线性插值缩放方法对目标填充图进行两次缩放变换,例如,先将目标填充图放大至1.5倍,再将放大后的图像缩小回原来的尺寸,以得到模糊后的图像。若存在目标标记图中值为2且在目标边缘过滤图中有效的像素点或者在目标边缘过滤图中无效但本身像素值很深的像素点,则将模糊后的图像中该像素点的像素值赋值至调整图像的相应位置,得到文字增强图像。如图3i所示为本发明实施例提供的一种文字增强图像的结果示意图,其中,图(a)为调整图像,图(b)为增强图像,从图中可以看出增强后的文字边缘得到适度加深,并且避开了笔画接近的部位,有利于在后续操作中,文字边缘获得更多的墨点。Figure 3h is a schematic diagram of a text-enhanced image generation process provided by an embodiment of the present invention, wherein Figure (a) is a target fill map, and Figure (b) is a blurred image. Exemplarily, first, replace the pixel value of the pixel point corresponding to the pixel point in the target marker image with the pixel value exceeding the marker background value mW with 155 in the adjustment image copy to obtain the target fill image, and then use the linear interpolation scaling method to fill the target image. The image is scaled twice, for example, the target fill image is first enlarged to 1.5 times, and then the enlarged image is reduced back to the original size to obtain a blurred image. If there is a pixel with a value of 2 in the target marker map and is valid in the target edge filter map, or a pixel point that is invalid in the target edge filter map but has a deep pixel value, the pixels of the pixel in the blurred image will be blurred. The value is assigned to the corresponding position of the adjusted image, and the text-enhanced image is obtained. Figure 3i is a schematic diagram showing the result of a text-enhanced image provided by an embodiment of the present invention, wherein Figure (a) is an adjusted image, and Figure (b) is an enhanced image. It can be seen from the figure that the enhanced text edge It is moderately deepened, and the parts where the strokes are approached are avoided, which is beneficial to obtain more ink dots on the edge of the text in the subsequent operations.

在另一个可选的实施方式中,在将所述模糊后的图像中符合设定条件的像素值赋值至调整图像的相应位置,得到文字增强图像之后,还包括:在文字增强图像中匹配出与目标标记图中非最小像素值的像素点相对应的像素点,并将匹配的像素点的像素值修改为最大像素值,以去除填充的目标像素值。具体的,将文字增强图像中与目标标记图中非0像素值的像素点对应位置的像素点的像素值修改为255像素值,以抹去之前填充的目标像素值。在另一个可选的实施方式中,还可以关注目标标记图像素值为1的像素点,将文字增强图像中与该像素点对应位置的像素点的像素值修改为255像素值,以去除文字增强图像中的底部噪声。In another optional implementation manner, after assigning pixel values that meet the set conditions in the blurred image to corresponding positions in the adjusted image to obtain a text-enhanced image, the method further includes: matching out a text-enhanced image in the text-enhanced image. The pixel corresponding to the pixel with the non-minimum pixel value in the target marker map, and the pixel value of the matched pixel is modified to the maximum pixel value to remove the padded target pixel value. Specifically, the pixel value of the pixel in the text-enhanced image corresponding to the pixel with the non-zero pixel value in the target marker image is modified to a pixel value of 255 to erase the previously filled target pixel value. In another optional implementation, it is also possible to pay attention to a pixel with a pixel value of 1 in the target marker image, and modify the pixel value of the pixel at the position corresponding to the pixel in the text-enhanced image to a pixel value of 255 to remove the text. Enhances the bottom noise in the image.

本发明实施例的技术方案通过对获取的亮度均匀的扫描灰度图进行边缘点增强处理以得到目标图像,再对目标图像进行灰度分布区间调整,并对调整图像进行边缘标记以及边缘加强处理,得到文字增强图像,解决了现有技术中所利用的算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰的问题,实现在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理。The technical scheme of the embodiment of the present invention obtains the target image by performing edge point enhancement processing on the obtained scanned grayscale image with uniform brightness, then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image. , obtain text-enhanced images, solve the problem that the algorithm preprocessing process used in the prior art is too complicated, and cause great troubles to equipment with limited resources and high real-time requirements, and realizes simplifying algorithm complexity and improving algorithm operation. While ensuring the accuracy of the printed text, the text image is enhanced.

在上述实施例的基础上,所述在对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像之后,还包括:使用误差扩散方法将所述文字增强图像进行二值化处理得到半色调图像,以为印刷设备提供打点信号。由于印刷设备需要0和1两信号来判定某个位置是否有墨点,因此,要将8位灰度图像转化为2位的二值图像,才能传入印刷设备中,即印刷设备二值化的过程必须将灰度图的连续调图像转化为半色调图像,也就是用黑点的分布疏密变化来模拟图像的浓淡变化。在本发明实施例中采用误差扩散法来转化文字增强图像,并在误差扩散运算中使用扩散范围大且容易提升边缘对比度的“Javis滤波器”。其中,滤波器的工作形态可如表3所示,“*”为文字增强图像中的待处理像素点。具体的,当*处的像素值转化为0或255的时候,产生的误差将按表3的权重累加到周围对应位置的像素点,示例性的,以中值127为阈值,若*处的像素值60二值化为0,则产生-60的误差,为平衡数值应在其他像素点位置+60,即按滤波器扫描周边像素,如右侧像素点的像素值所占权重为7/48,那么右侧像素点的像素值应累加一个+60*(7/48)的值,滤波器中的其他像素点位置同理变化,每个像素点在先前像素点误差扩散后的新像素值基础上做二值化,并向后续像素点扩散新的误差以实现误差扩散。如图3j所示为本发明实施例提供的一种二值化处理的结果示意图,其中,左图为连续调8位灰度图,右图为半色调1位图像。从图3j中可以看出生成的半色调图像墨点更加清晰,可以为印刷设备提供打点信号。On the basis of the above embodiment, after performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image, the method further includes: using an error diffusion method to binarize the text-enhanced image to obtain a half- Toned image to provide dot signal for printing equipment. Since the printing equipment needs two signals of 0 and 1 to determine whether there is an ink dot at a certain position, the 8-bit grayscale image must be converted into a 2-bit binary image before it can be transferred to the printing equipment, that is, the printing equipment is binarized. The process must convert the continuous-tone image of the grayscale image into a half-tone image, that is, use the density change of the distribution of black dots to simulate the shade change of the image. In the embodiment of the present invention, the error diffusion method is used to transform the text-enhanced image, and the "Javis filter" which has a large diffusion range and is easy to improve edge contrast is used in the error diffusion operation. Among them, the working form of the filter can be as shown in Table 3, and "*" is the pixel to be processed in the text-enhanced image. Specifically, when the pixel value at * is converted to 0 or 255, the resulting error will be accumulated to the pixels at the corresponding surrounding positions according to the weights in Table 3. Exemplarily, the median value of 127 is used as the threshold. If the pixel value 60 is binarized to 0, an error of -60 will be generated. To balance the value, it should be +60 at other pixel positions, that is, the surrounding pixels are scanned by the filter. For example, the weight of the pixel value of the right pixel is 7/ 48, then the pixel value of the pixel on the right should accumulate a value of +60*(7/48), the position of other pixels in the filter changes in the same way, each pixel is a new pixel after the error of the previous pixel is diffused Binarization is performed on the basis of the value, and new errors are diffused to subsequent pixels to achieve error diffusion. FIG. 3j is a schematic diagram showing a result of a binarization process provided by an embodiment of the present invention, wherein the left image is a continuous tone 8-bit grayscale image, and the right image is a halftone 1-bit image. It can be seen from Fig. 3j that the generated halftone image dots are clearer, and can provide dot signals for printing equipment.

表3滤波器的工作形态表Table 3 The working form of the filter

Figure BDA0003431083930000141
Figure BDA0003431083930000141

图4a为本发明实施例提供的一种优选的文字增强处理方法流程的示意图。具体的,首先,输入亮度均衡的扫描灰度图像。之后,将扫描灰度图像输入至图像增强处理模块中依次完成边缘增强处理一(即第一增强处理模块)、明暗对比度调节(即灰度分布区间调整模块)以及边缘增强处理二(即第二增强处理模块),得到文字增强图像,示例性的,首先,对扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;之后,进行明暗对比度调节,得到调整图像;进一步的,准备一张与调整图像尺寸相同的0初始像素值备份图,为产生较好的边缘硬化效果确定二值化背景阈值hW和背景填充值hB,其中,hW取值230,hB取值220,在备份图标记出调整图像中像素值超过hW的像素点,同时将调整图像中像素值高于hW的像素点的像素值替换成hB,得到文字增强图像。最后,将文字增强图像进行半色调处理,将二值化图像输出给印刷设备。如图4b所示为本发明实施例提供的一种半色调图像的结果示意图,其中,上图为直接将扫描灰度图进行二值化得到的处理结果,下图为本发明实施例经文字增强处理后再进行二值化得到的处理结果。从图4b中可以看出,本发明实施例所得的二值化图像能够在对文字图像影响极小的情况下,增强了印刷图像的文字显示效果。FIG. 4a is a schematic diagram of a flow of a preferred text enhancement processing method provided by an embodiment of the present invention. Specifically, first, a scanned grayscale image with balanced brightness is input. After that, input the scanned grayscale image into the image enhancement processing module to complete the first edge enhancement processing (ie the first enhancement processing module), the light and dark contrast adjustment (ie the grayscale distribution interval adjustment module) and the second edge enhancement processing (ie the second enhancement processing module). Enhancement processing module) to obtain a text-enhanced image. Exemplarily, first, the edge points of the scanned grayscale image are enhanced to obtain a target image with hardened text edges; then, the contrast of light and dark is adjusted to obtain an adjusted image; further, Prepare a backup image of 0 initial pixel value with the same size as the adjusted image, and determine the binarized background threshold hW and background fill value hB for better edge hardening effect, where hW is 230 and hB is 220. The backup image marks the pixel points whose pixel value exceeds hW in the adjusted image, and at the same time replaces the pixel value of the pixel point whose pixel value in the adjusted image is higher than hW with hB to obtain a text-enhanced image. Finally, the text-enhanced image is halftoned, and the binarized image is output to the printing device. Figure 4b is a schematic diagram of the result of a halftone image provided by an embodiment of the present invention, wherein the upper figure is a processing result obtained by directly binarizing the scanned grayscale image, and the lower figure is an embodiment of the present invention after the text The processing result obtained by binarization after enhancement processing. It can be seen from FIG. 4b that the binarized image obtained in the embodiment of the present invention can enhance the text display effect of the printed image under the condition that the influence on the text image is extremely small.

图5为本发明实施例提供的一种文字增强处理装置的结构示意图,该装置可以执行上述各实施例中涉及到的文字增强处理方法。该装置可采用软件和/或硬件的方式实现,如图5所示,所述文字增强处理装置具体包括:数据获取模块510、第一增强处理模块520、灰度分布区间调整模块530、第二增强处理模块540。FIG. 5 is a schematic structural diagram of a text enhancement processing apparatus according to an embodiment of the present invention, and the apparatus can execute the text enhancement processing methods involved in the above embodiments. The device can be implemented in software and/or hardware. As shown in FIG. 5 , the text enhancement processing device specifically includes: a data acquisition module 510, a first enhancement processing module 520, a gray distribution interval adjustment module 530, a second Enhanced processing module 540.

其中,数据获取模块510,用于获取亮度均匀的扫描灰度图;Wherein, the data acquisition module 510 is used to acquire a scanned grayscale image with uniform brightness;

第一增强处理模块520,用于对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;The first enhancement processing module 520 is configured to perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;

灰度分布区间调整模块530,用于将所述目标图像进行灰度分布区间调整,得到调整图像;The grayscale distribution interval adjustment module 530 is used to adjust the grayscale distribution interval of the target image to obtain an adjusted image;

第二增强处理模块540,用于对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。The second enhancement processing module 540 is configured to perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.

本发明实施例的技术方案通过对获取的亮度均匀的扫描灰度图进行边缘点增强处理以得到目标图像,再对目标图像进行灰度分布区间调整,并对调整图像进行边缘标记以及边缘加强处理,得到文字增强图像,解决了现有技术中所利用的算法预处理过程过于繁杂,对资源有限且实时性要求较高的设备造成较大困扰的问题,实现在简化算法复杂度、提高算法运行速度以及保证印刷文字准确度的同时,对文字图像进行文字增强处理。The technical scheme of the embodiment of the present invention obtains the target image by performing edge point enhancement processing on the obtained scanned grayscale image with uniform brightness, then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image. , obtain text-enhanced images, solve the problem that the algorithm preprocessing process used in the prior art is too complicated, and cause great troubles to equipment with limited resources and high real-time requirements, and realizes simplifying algorithm complexity and improving algorithm operation. While ensuring the accuracy of the printed text, the text image is enhanced.

可选的,第一增强处理模块520可以包括像素点获取单元以及目标图像获取单元;Optionally, the first enhancement processing module 520 may include a pixel point acquisition unit and a target image acquisition unit;

其中,像素点获取单元,可以用于利用周围像素模式图对所述扫描灰度图中的各个像素进行分析,得到文字的目标边缘点以及参考点;Wherein, the pixel point acquisition unit can be used to analyze each pixel in the scanned grayscale image by using the surrounding pixel pattern map to obtain the target edge point and reference point of the text;

目标图像获取单元,可以用于基于所述参考点的像素值以及目标边缘点的像素值确定边缘加深像素值,并利用边缘加深像素值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像。The target image acquisition unit can be used to determine the edge deepening pixel value based on the pixel value of the reference point and the pixel value of the target edge point, and utilize the edge deepening pixel value to deepen the target edge point in the scanned grayscale image, Get the target image with hardened text edges.

可选的,第二增强处理模块540可以包括标记图构建单元、数量计算单元、预处理标记图获取单元、目标标记图获取单元以及文字增强图像获取单元;Optionally, the second enhancement processing module 540 may include a label map construction unit, a quantity calculation unit, a preprocessing label map acquisition unit, a target label map acquisition unit, and a text-enhanced image acquisition unit;

其中,标记图构建单元,用于构建各个像素值初始值均为最小像素值的标记图;Among them, the label map construction unit is used to construct a label map whose initial value of each pixel value is the minimum pixel value;

数量计算单元,用于获取所述调整图像中像素值大于等于标记背景值的目标像素点的像素值,并计算出以所述目标像素点为中心的设定区域中像素值低于标记实体值的像素点的数量以及像素值高于标记背景值的像素点的数量,分别作为第一数量和第二数量;A quantity calculation unit, used to obtain the pixel value of the target pixel whose pixel value in the adjusted image is greater than or equal to the marked background value, and calculates that the pixel value in the set area centered on the target pixel is lower than the marked entity value The number of pixels and the number of pixels whose pixel value is higher than the marked background value are taken as the first number and the second number, respectively;

预处理标记图获取单元,用于若所述第一数量小于等于第一数量阈值或者所述第二数量小于等于第二数量阈值,则将所述标记图中目标像素点对应位置的像素值标记为第一目标像素值,否则,标记为目标像素点的像素值,得到预处理标记图;其中,所述第一数量阈值小于所述第二数量阈值;所述第一目标像素值大于所述最小像素值;A preprocessing marker map obtaining unit, configured to mark the pixel value of the corresponding position of the target pixel in the marker map if the first number is less than or equal to the first number threshold or the second number is less than or equal to the second number threshold is the first target pixel value, otherwise, it is marked as the pixel value of the target pixel point to obtain a preprocessing mark map; wherein, the first quantity threshold is less than the second quantity threshold; the first target pixel value is greater than the minimum pixel value;

目标标记图获取单元,用于对所述预处理标记图中以各个像素值大于标记背景值的像素点为中心的预设区域进行检索,将所述预设区域中像素值等于所述最小像素值的像素点的像素值标记为第二目标像素值,得到目标标记图;其中,所述第二目标像素值大于所述第一目标像素值;A target marker map acquisition unit, configured to retrieve a preset area in the preprocessed marker map centered on pixels whose pixel values are greater than the marker background value, and set the pixel value in the preset area equal to the minimum pixel value The pixel value of the pixel point of the value is marked as the second target pixel value, and a target mark map is obtained; wherein, the second target pixel value is greater than the first target pixel value;

文字增强图像获取单元,用于对所述调整图像进行备份得到调整图像副本,并根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像。The text-enhanced image acquisition unit is used for backing up the adjusted image to obtain an adjusted image copy, and filling and blurring the adjusted image copy according to the target marker map to obtain a blurred image, and use the blurred image to obtain a copy of the adjusted image. The image performs edge enhancement processing on the adjusted image to obtain a text-enhanced image.

可选的,文字增强图像获取单元具体可以用于将所述调整图像副本中与所述目标标记图中像素值超过标记背景值的像素点所对应的像素点的像素值替换为目标像素值,得到目标填充图;利用线性插值缩放方法对所述目标填充图进行缩放变换,得到模糊后的图像;将所述模糊后的图像中符合设定条件的像素值赋值至所述调整图像的相应位置,得到文字增强图像。Optionally, the text-enhanced image acquisition unit may be specifically configured to replace the pixel value of the pixel corresponding to the pixel whose pixel value in the target marker map exceeds the marker background value in the adjusted image copy with the target pixel value, Obtaining a target fill map; scaling and transforming the target fill map using a linear interpolation scaling method to obtain a blurred image; assigning pixel values that meet the set conditions in the blurred image to corresponding positions in the adjusted image , to get a text-enhanced image.

可选的,目标图像获取单元具体可以用于获取在各个周围像素模式图中计算得到的最小边缘加深像素值,并将所述最小边缘加深像素值与目标边缘点的像素值进行比较;若所述最小边缘加深像素值小于目标边缘点的像素值,则将所述目标边缘点的像素值赋值为最小边缘加深像素值,得到文字边缘硬化的目标图像。Optionally, the target image acquisition unit can be specifically used to obtain the minimum edge deepening pixel value calculated in each surrounding pixel pattern map, and compare the minimum edge deepening pixel value with the pixel value of the target edge point; If the minimum edge deepening pixel value is smaller than the pixel value of the target edge point, the pixel value of the target edge point is assigned as the minimum edge deepening pixel value to obtain a target image with hardened text edges.

可选的,文字增强处理装置还可以包括二值化处理模块,用于在对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像之后,使用误差扩散方法将所述文字增强图像进行二值化处理得到半色调图像,以为印刷设备提供打点信号。Optionally, the text enhancement processing device may further include a binarization processing module for performing edge marking and edge enhancement processing on the adjusted image to obtain the text enhanced image, and then using the error diffusion method to perform the text enhanced image processing. The binarization process obtains a halftone image to provide a dot signal for printing equipment.

可选的,文字增强处理装置还可以包括目标像素值去除模块,用于在将所述模糊后的图像中符合设定条件的像素值赋值至调整图像的相应位置,得到文字增强图像之后,在文字增强图像中匹配出与目标标记图中非最小像素值的像素点相对应的像素点,并将匹配的像素点的像素值修改为最大像素值,以去除填充的目标像素值。本发明实施例所提供的文字增强处理装置可执行本发明任意实施例所提供的文字增强处理方法,具备执行方法相应的功能模块和有益效果。Optionally, the text enhancement processing device may also include a target pixel value removal module for assigning pixel values that meet the set conditions in the blurred image to the corresponding position of the adjusted image, and after obtaining the text enhanced image, In the text-enhanced image, the pixel corresponding to the pixel with the non-minimum pixel value in the target marker map is matched, and the pixel value of the matched pixel is modified to the maximum pixel value to remove the filled target pixel value. The text enhancement processing apparatus provided by the embodiment of the present invention can execute the text enhancement processing method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

图6为本发明实施例提供的一种电子设备的结构示意图,如图6所示,该电子设备包括处理器610、存储器620、输入装置630和输出装置640;电子设备中处理器610的数量可以是一个或多个,图6中以一个处理器610为例;电子设备中的处理器610、存储器620、输入装置630和输出装置640可以通过总线或其他方式连接,图6中以通过总线连接为例。FIG. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 6 , the electronic device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of processors 610 in the electronic device There may be one or more, and a processor 610 is taken as an example in FIG. 6 ; the processor 610, memory 620, input device 630 and output device 640 in the electronic device can be connected by a bus or in other ways. Connect as an example.

存储器620作为一种计算机可读存储介质,可用于存储软件程序、计算机可执行程序以及模块,如本发明实施例中的文字增强处理方法对应的程序指令/模块(例如,文字增强处理装置中的数据获取模块510、第一增强处理模块520、灰度分布区间调整模块530和第二增强处理模块540)。处理器610通过运行存储在存储器620中的软件程序、指令以及模块,从而执行电子设备的各种功能应用以及数据处理,即实现上述的文字增强处理方法。As a computer-readable storage medium, the memory 620 can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the text enhancement processing method in the embodiment of the present invention (for example, the The data acquisition module 510, the first enhancement processing module 520, the gray distribution interval adjustment module 530, and the second enhancement processing module 540). The processor 610 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 620 , that is, to implement the above-mentioned text enhancement processing method.

存储器620可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序;存储数据区可存储根据终端的使用所创建的数据等。此外,存储器620可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实例中,存储器620可进一步包括相对于处理器610远程设置的存储器,这些远程存储器可以通过网络连接至电子设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 620 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Additionally, memory 620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, memory 620 may further include memory located remotely from processor 610, which may be connected to the electronic device through a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

输入装置630可用于接收输入的数字或字符信息,以及产生与电子设备的用户设置以及功能控制有关的键信号输入。输出装置640可包括显示屏等显示设备。The input device 630 may be used to receive input numerical or character information, and generate key signal input related to user settings and function control of the electronic device. The output device 640 may include a display device such as a display screen.

本发明实施例还提供一种包含计算机可执行指令的存储介质,所述计算机可执行指令在由计算机处理器执行时用于执行一种文字增强处理方法,该方法包括:An embodiment of the present invention also provides a storage medium containing computer-executable instructions, where the computer-executable instructions are used to execute a text enhancement processing method when executed by a computer processor, and the method includes:

获取亮度均匀的扫描灰度图;Obtain a scanned grayscale image with uniform brightness;

对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;

将所述目标图像进行灰度分布区间调整,得到调整图像;Adjusting the gray distribution interval of the target image to obtain an adjusted image;

对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。Perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.

当然,本发明实施例所提供的一种包含计算机可执行指令的存储介质,其计算机可执行指令不限于如上所述的方法操作,还可以执行本发明任意实施例所提供的文字增强处理方法中的相关操作。Of course, a storage medium containing computer-executable instructions provided by an embodiment of the present invention is not limited to the above-mentioned method operations, and can also execute the text enhancement processing method provided by any embodiment of the present invention. related operations.

通过以上关于实施方式的描述,所属领域的技术人员可以清楚地了解到,本发明可借助软件及必需的通用硬件来实现,当然也可以通过硬件实现,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如计算机的软盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(RandomAccess Memory,RAM)、闪存(FLASH)、硬盘或光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。From the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be realized by software and necessary general-purpose hardware, and of course can also be realized by hardware, but in many cases the former is a better embodiment . Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in a computer-readable storage medium, such as a floppy disk of a computer , read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), flash memory (FLASH), hard disk or CD, etc., including several instructions to make a computer device (which can be a personal computer, A server, or a network device, etc.) executes the methods described in the various embodiments of the present invention.

值得注意的是,上述文字增强处理装置的实施例中,所包括的各个单元和模块只是按照功能逻辑进行划分的,但并不局限于上述的划分,只要能够实现相应的功能即可;另外,各功能单元的具体名称也只是为了便于相互区分,并不用于限制本发明的保护范围。It is worth noting that, in the above embodiments of the text enhancement processing device, the included units and modules are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, The specific names of the functional units are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present invention.

注意,上述仅为本发明的较佳实施例及所运用技术原理。本领域技术人员会理解,本发明不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本发明的保护范围。因此,虽然通过以上实施例对本发明进行了较为详细的说明,但是本发明不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本发明的范围由所附的权利要求范围决定。Note that the above are only preferred embodiments of the present invention and applied technical principles. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present invention. The scope is determined by the scope of the appended claims.

Claims (10)

1.一种文字增强处理方法,其特征在于,包括:1. a text enhancement processing method, is characterized in that, comprises: 获取亮度均匀的扫描灰度图;Obtain a scanned grayscale image with uniform brightness; 对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges; 将所述目标图像进行灰度分布区间调整,得到调整图像;Adjusting the grayscale distribution interval of the target image to obtain an adjusted image; 对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。Perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image. 2.根据权利要求1所述的方法,其特征在于,对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像包括:2. The method according to claim 1, characterized in that, performing enhancement processing on the edge points of the scanned grayscale image, and obtaining the target image of character edge hardening comprises: 利用周围像素模式图对所述扫描灰度图中的各个像素进行分析,得到文字的目标边缘点以及参考点;Use the surrounding pixel pattern map to analyze each pixel in the scanned grayscale image to obtain the target edge point and reference point of the text; 基于所述参考点的像素值以及目标边缘点的像素值确定边缘加深像素值,并利用边缘加深像素值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像。Based on the pixel value of the reference point and the pixel value of the target edge point, the edge deepening pixel value is determined, and the edge deepening pixel value is used to deepen the target edge point in the scanned grayscale image to obtain a target image with hardened text edges. 3.根据权利要求1所述的方法,其特征在于,所述对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像包括:3. The method according to claim 1, wherein, performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image comprising: 构建各个像素值初始值均为最小像素值的标记图;Construct a marker map whose initial value of each pixel value is the minimum pixel value; 获取所述调整图像中像素值大于等于标记背景值的目标像素点的像素值,并计算出以所述目标像素点为中心的设定区域中像素值低于标记实体值的像素点的数量以及像素值高于标记背景值的像素点的数量,分别作为第一数量和第二数量;Obtain the pixel value of the target pixel whose pixel value is greater than or equal to the marked background value in the adjusted image, and calculate the number of pixels whose pixel value is lower than the marked entity value in the set area centered on the target pixel point and The number of pixel points whose pixel value is higher than the marked background value are used as the first number and the second number respectively; 若所述第一数量小于等于第一数量阈值或者所述第二数量小于等于第二数量阈值,则将所述标记图中目标像素点对应位置的像素值标记为第一目标像素值,否则,标记为目标像素点的像素值,得到预处理标记图;其中,所述第一数量阈值小于所述第二数量阈值;所述第一目标像素值大于所述最小像素值;If the first number is less than or equal to the first number threshold or the second number is less than or equal to the second number threshold, the pixel value at the corresponding position of the target pixel in the marked map is marked as the first target pixel value, otherwise, Marking the pixel value of the target pixel point to obtain a preprocessing marked map; wherein, the first number threshold is less than the second number threshold; the first target pixel value is greater than the minimum pixel value; 对所述预处理标记图中以各个像素值大于标记背景值的像素点为中心的预设区域进行检索,将所述预设区域中像素值等于所述最小像素值的像素点的像素值标记为第二目标像素值,得到目标标记图;其中,所述第二目标像素值大于所述第一目标像素值;Retrieve the preset area centered on the pixel whose pixel value is greater than the marked background value in the preprocessing marking map, and mark the pixel value of the pixel whose pixel value is equal to the minimum pixel value in the preset area. is the second target pixel value to obtain a target marker map; wherein, the second target pixel value is greater than the first target pixel value; 对所述调整图像进行备份得到调整图像副本,并根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像。The adjusted image is backed up to obtain an adjusted image copy, and the adjusted image copy is filled and blurred according to the target marker map to obtain a blurred image, and the adjusted image is edged with the blurred image. Enhance the processing to get text-enhanced images. 4.根据权利要求3所述的方法,其特征在于,所述根据所述目标标记图对所述调整图像副本进行填充以及模糊处理,得到模糊后的图像,并利用模糊后的图像对所述调整图像进行边缘加强处理,得到文字增强图像包括:4 . The method according to claim 3 , wherein the adjustment image copy is filled and blurred according to the target marker map to obtain a blurred image, and the blurred image is used to align the adjustment image. 5 . Adjust the image to perform edge enhancement processing, and obtain a text-enhanced image including: 将所述调整图像副本中与所述目标标记图中像素值超过标记背景值的像素点所对应的像素点的像素值替换为目标像素值,得到目标填充图;Replacing the pixel value of the pixel corresponding to the pixel whose pixel value in the target marking map exceeds the marking background value in the adjustment image copy is the target pixel value to obtain the target filling map; 利用线性插值缩放方法对所述目标填充图进行缩放变换,得到模糊后的图像;Use the linear interpolation scaling method to scale and transform the target fill image to obtain a blurred image; 将所述模糊后的图像中符合设定条件的像素值赋值至所述调整图像的相应位置,得到文字增强图像。The pixel values in the blurred image that meet the set conditions are assigned to corresponding positions in the adjusted image to obtain a text-enhanced image. 5.根据权利要求2所述的方法,其特征在于,所述利用边缘加深目标值对所述扫描灰度图中的目标边缘点进行加深,得到文字边缘硬化的目标图像包括:5. The method according to claim 2, wherein the target edge point in the scanned grayscale image is deepened by using the edge deepening target value to obtain the target image of character edge hardening comprising: 获取在各个周围像素模式图中计算得到的最小边缘加深像素值,并将所述最小边缘加深像素值与目标边缘点的像素值进行比较;Obtain the minimum edge deepening pixel value calculated in each surrounding pixel pattern map, and compare the minimum edge deepening pixel value with the pixel value of the target edge point; 若所述最小边缘加深像素值小于目标边缘点的像素值,则将所述目标边缘点的像素值赋值为最小边缘加深像素值,得到文字边缘硬化的目标图像。If the minimum edge deepening pixel value is smaller than the pixel value of the target edge point, the pixel value of the target edge point is assigned as the minimum edge deepening pixel value to obtain a target image with hardened text edges. 6.根据权利要求1所述的方法,其特征在于,所述在对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像之后,还包括:6. The method according to claim 1, wherein, after performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image, the method further comprises: 使用误差扩散方法将所述文字增强图像进行二值化处理得到半色调图像,以为印刷设备提供打点信号。Using the error diffusion method, the text-enhanced image is binarized to obtain a halftone image, which provides a dot signal for printing equipment. 7.根据权利要求4所述的方法,其特征在于,在将所述模糊后的图像中符合设定条件的像素值赋值至调整图像的相应位置,得到文字增强图像之后,还包括:7. The method according to claim 4, characterized in that, after assigning the pixel value that meets the setting condition in the blurred image to the corresponding position of the adjustment image, after obtaining the text-enhanced image, it also comprises: 在文字增强图像中匹配出与目标标记图中非最小像素值的像素点相对应的像素点,并将匹配的像素点的像素值修改为最大像素值,以去除填充的目标像素值。In the text-enhanced image, the pixels corresponding to the pixels with non-minimum pixel values in the target marker map are matched, and the pixel values of the matched pixels are modified to the maximum pixel value to remove the filled target pixel value. 8.一种文字增强处理装置,其特征在于,包括:8. A character enhancement processing device, comprising: 数据获取模块,用于获取亮度均匀的扫描灰度图;The data acquisition module is used to acquire the scanned grayscale image with uniform brightness; 第一增强处理模块,用于对所述扫描灰度图的边缘点进行增强处理,得到文字边缘硬化的目标图像;a first enhancement processing module, configured to perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges; 灰度分布区间调整模块,用于将所述目标图像进行灰度分布区间调整,得到调整图像;a grayscale distribution interval adjustment module, which is used to adjust the grayscale distribution interval of the target image to obtain an adjusted image; 第二增强处理模块,用于对所述调整图像进行边缘标记以及边缘加强处理,得到文字增强图像。The second enhancement processing module is configured to perform edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image. 9.一种电子设备,其特征在于,所述电子设备包括:9. An electronic device, characterized in that the electronic device comprises: 一个或多个处理器;one or more processors; 存储装置,用于存储一个或多个程序,storage means for storing one or more programs, 当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-7中任一所述的文字增强处理方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the text enhancement processing method according to any one of claims 1-7. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1-7中任一所述的文字增强处理方法。10. A computer-readable storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the text enhancement processing method according to any one of claims 1-7 is implemented.
CN202111595841.8A 2021-12-24 2021-12-24 A text enhancement processing method, device, equipment and medium Active CN114298932B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111595841.8A CN114298932B (en) 2021-12-24 2021-12-24 A text enhancement processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111595841.8A CN114298932B (en) 2021-12-24 2021-12-24 A text enhancement processing method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN114298932A true CN114298932A (en) 2022-04-08
CN114298932B CN114298932B (en) 2025-03-14

Family

ID=80969699

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111595841.8A Active CN114298932B (en) 2021-12-24 2021-12-24 A text enhancement processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN114298932B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118172224A (en) * 2024-05-16 2024-06-11 四川鑫海工程造价咨询事务所有限公司 Engineering cost data management method
CN118587271A (en) * 2024-07-01 2024-09-03 中国地质大学(北京) A rock CT image analysis and processing method

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108737686A (en) * 2018-06-11 2018-11-02 昆明理工大学 Edge enhancing error based on image coefficient change spreads digital halftoning method
CN108810314A (en) * 2018-06-11 2018-11-13 昆明理工大学 Unordered error based on the enhancing of multi-grey image edge spreads digital halftoning method
CN109670500A (en) * 2018-11-30 2019-04-23 平安科技(深圳)有限公司 A kind of character area acquisition methods, device, storage medium and terminal device
CN110826360A (en) * 2018-08-10 2020-02-21 南京宁融信网络科技有限公司 OCR image preprocessing and character recognition
CN111145114A (en) * 2019-12-19 2020-05-12 腾讯科技(深圳)有限公司 Image enhancement method and device and computer readable storage medium
CN112749696A (en) * 2020-09-01 2021-05-04 腾讯科技(深圳)有限公司 Text detection method and device
CN112950588A (en) * 2021-03-02 2021-06-11 江苏阿瑞斯智能设备有限公司 Image processing method and device, electronic equipment and medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108737686A (en) * 2018-06-11 2018-11-02 昆明理工大学 Edge enhancing error based on image coefficient change spreads digital halftoning method
CN108810314A (en) * 2018-06-11 2018-11-13 昆明理工大学 Unordered error based on the enhancing of multi-grey image edge spreads digital halftoning method
CN110826360A (en) * 2018-08-10 2020-02-21 南京宁融信网络科技有限公司 OCR image preprocessing and character recognition
CN109670500A (en) * 2018-11-30 2019-04-23 平安科技(深圳)有限公司 A kind of character area acquisition methods, device, storage medium and terminal device
CN111145114A (en) * 2019-12-19 2020-05-12 腾讯科技(深圳)有限公司 Image enhancement method and device and computer readable storage medium
CN112749696A (en) * 2020-09-01 2021-05-04 腾讯科技(深圳)有限公司 Text detection method and device
CN112950588A (en) * 2021-03-02 2021-06-11 江苏阿瑞斯智能设备有限公司 Image processing method and device, electronic equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118172224A (en) * 2024-05-16 2024-06-11 四川鑫海工程造价咨询事务所有限公司 Engineering cost data management method
CN118587271A (en) * 2024-07-01 2024-09-03 中国地质大学(北京) A rock CT image analysis and processing method

Also Published As

Publication number Publication date
CN114298932B (en) 2025-03-14

Similar Documents

Publication Publication Date Title
US20030161534A1 (en) Feature recognition using loose gray scale template matching
US20030179935A1 (en) Image processing apparatus, image processing method, image processing program, and computer-readable record medium storing image processing program
JP4471062B2 (en) Adaptive image enhancement filter and method of generating enhanced image data
CN110490204B (en) Image processing method, image processing device and terminal
CN114596290A (en) Defect detection method, defect detection device, storage medium, and program product
CN114298932A (en) A text enhancement processing method, device, equipment and medium
CN112508024A (en) Intelligent identification method for embossed seal font of electrical nameplate of transformer
JP2004336282A (en) Image processor, image processing program and recording medium recorded with relevant program
US7525694B2 (en) Image processing device, image processing method, image processing program, and recording medium
CN110210467B (en) Formula positioning method of text image, image processing device and storage medium
CN114519788A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
US7724981B2 (en) Adaptive contrast control systems and methods
Boiangiu et al. Methods of bitonal image conversion for modern and classic documents
CN116739930A (en) Laser printer image data processing method and system
US9424499B2 (en) Method for printing a grayscale raster image by grayscale value dispersion
CN113362319A (en) Laser printing method and device based on image processing, laser printer and computer readable storage medium
RU2520407C1 (en) Method and system of text improvement at digital copying of printed documents
JP2004246110A (en) Plate inspection apparatus, printing system, method for inspecting printed data on plate, and program
CN115082354B (en) Fax image processing method and device and readable medium
CN111553317B (en) Anti-fake code acquisition method and device, computer equipment and storage medium
US12062246B2 (en) Extracting text from an image
CN114821077B (en) Test paper image processing method, device, storage medium and electronic equipment
CN116777768B (en) Robust and efficient scanned document image enhancement method and device
CN111127483B (en) Color picture processing method, device, equipment, storage medium and system
US9251568B1 (en) Pseudo-skeleton based image enhancement for document image reproduction

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant