A text enhancement processing method, device, equipment and medium
By performing edge point enhancement processing, grayscale distribution interval adjustment and edge mark enhancement processing on the scanned grayscale map, the complex algorithm preprocessing problem in the prior art is solved, and efficient text enhancement processing of text images is realized.
Patent Information
- Application Number
- CN202111595841.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In the prior art, the preprocessing process of text enhancement processing algorithms is too complicated, resulting in troublesome equipment with limited resources and high real-time requirements.
By performing edge point enhancement processing on the acquired scanned grayscale map with uniform brightness, the target image is obtained, and then the grayscale distribution interval is adjusted for the target image, and edge marking and edge enhancement processing is performed on the adjusting image to obtain a text enhancement image.
While simplifying the complexity of the algorithm and improving the running speed of the algorithm, it ensures the accuracy of printed text and realizes effective text enhancement processing for text images.
Smart Images

Figure CN114298932B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to image processing technology, and in particular to a text enhancement processing method, device, equipment and medium. Background Art
[0002] 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 image text enhancement algorithms to perform text enhancement processing on the scanned text images to improve the clarity of the printed text.
[0003] In the prior art, a series of algorithms such as edge search, image blurring, layer overlay and contrast enhancement are usually used to enhance the edges of image text. However, since the series of algorithm preprocessing processes used in the prior art are too complicated, it causes great trouble to equipment with limited resources and high real-time requirements. Therefore, how to perform text enhancement processing on text images while simplifying the algorithm complexity, improving the algorithm running speed and ensuring the accuracy of printed text is a problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present invention provide a text enhancement processing method, device, equipment and medium, which can realize text enhancement processing on text images while simplifying algorithm complexity, improving algorithm operation speed and ensuring printed text accuracy.
[0005] In a first aspect, an embodiment of the present invention provides a text enhancement processing method, comprising:
[0006] Obtain a scanned grayscale image with uniform brightness;
[0007] Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;
[0008] Adjusting the grayscale distribution interval of the target image to obtain an adjusted image;
[0009] The adjusted image is subjected to edge marking and edge enhancement processing to obtain a text-enhanced image.
[0010] In a second aspect, an embodiment of the present invention further provides a text enhancement processing device, the device comprising:
[0011] A data acquisition module, used to acquire a scanning grayscale image with uniform brightness;
[0012] A first enhancement processing module is used to perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;
[0013] A grayscale distribution interval adjustment module, used for adjusting the grayscale distribution interval of the target image to obtain an adjusted image;
[0014] The second enhancement processing module is used to perform edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image.
[0015] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0016] one or more processors;
[0017] a storage device for storing one or more programs,
[0018] 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 as described in any embodiment of the present invention.
[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the text enhancement processing method as described in any embodiment of the present invention.
[0020] The technical solution of the embodiment of the present invention obtains a target image by performing edge point enhancement processing on an acquired scanned grayscale image with uniform brightness, and then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image. This solves the problem that the algorithm preprocessing process used in the prior art is too complicated, which causes great trouble to equipment with limited resources and high real-time requirements. It achieves text enhancement processing on text images while simplifying the algorithm complexity, improving the algorithm running speed and ensuring the accuracy of printed text. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a flowchart of a text enhancement method in the prior art;
[0022] Figure 2a is a flow chart of a text enhancement processing method provided by an embodiment of the present invention;
[0023] Figure 2b is a schematic diagram of an image detail display provided by an embodiment of the present invention;
[0024] Figure 2c is a distribution diagram of a grayscale distribution interval provided by an embodiment of the present invention;
[0025] Figure 3a is a flow chart of a text enhancement processing method provided by an embodiment of the present invention;
[0026] Figure 3b is a schematic diagram of a surrounding pixel pattern diagram provided by an embodiment of the present invention;
[0027] Figure 3c is a result schematic diagram of a target image provided by an embodiment of the present invention;
[0028] Figure 3d is a schematic diagram of a result of adjusting an image provided by an embodiment of the present invention;
[0029] Figure 3e is a schematic diagram of a target marking map generation process provided by an embodiment of the present invention;
[0030] Figure 3f is a schematic diagram of a target edge filtering graph provided by an embodiment of the present invention;
[0031] Figure 3g Schematic diagram of the superposition result of a target marking image and a target edge filtering image provided by an embodiment of the present invention
[0032] Figure 3h is a schematic diagram of a text-enhanced image generation process provided by an embodiment of the present invention;
[0033] Figure 3i is a schematic diagram of a text-enhanced image result provided by an embodiment of the present invention;
[0034] Figure 3j is a schematic diagram of a binarization result provided by an embodiment of the present invention;
[0035] Figure 4a It is a schematic diagram of a preferred text enhancement processing method provided by an embodiment of the present invention;
[0036] Figure 4b is a result schematic diagram of a halftone image provided by an embodiment of the present invention;
[0037] Figure 5 is a structural schematic diagram of a text enhancement processing device provided by an embodiment of the present invention;
[0038] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0040] Figure 1The present invention is a flowchart of a text enhancement method in the prior art. First, coarse positioning or fine positioning is used to identify the text area and the picture area, and the text area is separated from the picture area; further, the text area is subjected to image optimization processing, invalid background pixels are eliminated, pixels are scanned to confirm the text edge points and adjacent edge points are continuously searched, and edge position data is recorded; further, the original text image is blurred, and the edge position deepening image is superimposed with the blurred edge, and superimposed on the original image; finally, the text area is subjected to dynamic contrast enhancement to make the text clearer as a whole. However, the recognition algorithm and feature analysis algorithm used in the text enhancement method used in the prior art when separating the text area are highly complex and the accuracy is unstable, and a large number of floating-point operations will lead to a decrease in operating efficiency; the edge recognition algorithm used in the prior art is easily affected by the characteristics of the input image itself when identifying the edge points of the text. If the text in the image is intermittent and unclear, the computational complexity of the edge recognition algorithm will be increased, resulting in a large memory consumption. Therefore, the text enhancement method used in the prior art is very challenging for embedded devices with high integration, computational complexity and real-time requirements.
[0041] 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.
[0042] Figure 2a A flowchart of a text enhancement processing method provided in an embodiment of the present invention is applicable to the case of enhancing text in an image. The method can be executed by a text enhancement processing device, which can be implemented in hardware and / or software and can generally be integrated in electronic devices, such as copiers, printers, or embedded devices such as text scanning and recognition devices.
[0043] like Figure 2a As shown, a text enhancement processing method provided by an embodiment of the present invention includes the following specific steps:
[0044] S210: Obtain a scanned grayscale image with uniform brightness.
[0045] The scanned grayscale image may refer to a grayscale image scanned by a contact image sensor (CIS). The scanned grayscale image with uniform brightness may refer to a standard image in which the grayscale is uniformly distributed and the grayscale interval is between grayscale values 0-255.
[0046] S220: Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges.
[0047] Among them, edge points can refer to the pixel points at the edge of the text image in the scanned grayscale image; the edge of the text image can also be called a 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 at one pixel. Enhancement processing can 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 pixel value smaller than the pixel value of the current edge point. The target image can refer to the grayscale image of the text edge hardened after the edge point enhancement processing.
[0048] S230: Adjusting the grayscale distribution interval of the target image to obtain an adjusted image.
[0049] Figure 2b A schematic diagram of an image detail display provided by an embodiment of the present invention. After a grayscale image is converted into a binary image, Figure 2b As shown in the figure, the first two lines of numbers in the first line of text image are displayed more clearly than the last line of numbers; the numbers in the second line of text image can be displayed clearly; the second line of numbers in the third line of text image can hardly be displayed clearly; the first two lines of numbers in the fourth line of text image can hardly be displayed clearly. Therefore, in order to improve the final performance of the text image, ensure clearer light and dark contrast, and more obvious image details, it is necessary to adjust the grayscale distribution range of the text image.
[0050] Figure 2c A schematic diagram of a grayscale distribution interval provided by an embodiment of the present invention, wherein the black mark is the ink point of the printer. The present invention uses a drum ink printer as a test machine. Figure 2c The grayscale distribution interval is adjusted as shown in the figure. Specifically, since the ink dots of the drum ink printing machine are easy to expand outward and cause the ink dots to stick together, the distinction in the dark part of the image (the area with lower pixel values, 0-80) is not obvious, so the dark part needs to be further deepened to make more grayscale intervals; the distinction in the sub-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 its interval can be compressed to the right to make room for the sub-dark part; the highlight part (above 240) does not change much and does not need to be adjusted again. Finally, the grayscale distribution interval of the image dark part 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 brighter, so that the text edge is clearer, and the clarity of the image can be taken into account while enhancing the text.
[0051] It is worth noting that although the distribution diagram of the grayscale distribution range provided in the embodiment of the present invention can reflect the trend of visually uniform changes, different printing methods and printing conditions will affect the ink dot size, resulting in differences between the actual printing effect and the theoretical value. Therefore, in different application environments, the parameters should be further adjusted or other calculations should be performed based on the machine and consumables properties on the basis of the embodiment of the present invention, and the embodiment of the present invention does not limit this.
[0052] S240: performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image.
[0053] Among them, edge marking can refer to marking the text edge points in the adjusted image, for example, the text edge points in the adjusted image can be marked at corresponding positions in a newly created marking map. Edge enhancement processing can refer to enhancing the edge points obtained by edge marking to obtain a text enhanced image after edge enhancement.
[0054] The technical solution of the embodiment of the present invention obtains a target image by performing edge point enhancement processing on an acquired scanned grayscale image with uniform brightness, and then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image. This solves the problem that the algorithm preprocessing process used in the prior art is too complicated, which causes great trouble to equipment with limited resources and high real-time requirements. It achieves text enhancement processing on text images while simplifying the algorithm complexity, improving the algorithm running speed and ensuring the accuracy of printed text.
[0055] Figure 3a A flowchart of a text enhancement processing method provided by an embodiment of the present invention. In this embodiment, optionally, enhancing the edge points of the scanned grayscale image to obtain a target image with hardened text edges includes: analyzing each pixel in the scanned grayscale image using a surrounding pixel pattern image to obtain target edge points and reference points of the text; determining edge deepening pixel values based on the pixel values of the reference points and the pixel values of the target edge points, and using the edge deepening pixel values to deepen the target edge points in the scanned grayscale image to obtain a target image with hardened text edges.
[0056] Optionally, the edge marking and edge enhancement processing of the adjusted image to obtain a text enhanced image includes: constructing a marking map in which the initial value of each pixel value is the minimum pixel value; obtaining the pixel value of a target pixel point in the adjusted image whose pixel value is greater than or equal to the marking background value, and calculating the number of pixel points with pixel values lower than the marking entity value and the number of pixel points with pixel values higher than the marking background value in a set area centered on the target pixel point, as the first number and the second number, respectively; if the first number is less than or equal to a first number threshold or the second number is less than or equal to a second number threshold, marking the pixel value corresponding to the target pixel point in the marking map as the first target pixel value, otherwise, marking the pixel value of the target pixel point as the first target pixel value is obtained. 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 preset area centered on pixel points whose pixel values are greater than the marked background value in the preprocessing mark map is searched, and the pixel values of the pixel points in the preset area whose pixel values are equal to the minimum pixel value are marked as second target pixel values to obtain a target mark map; wherein the second target pixel value is greater than the first target pixel value; backing up the adjusted image to obtain an adjusted image copy, filling and blurring the adjusted image copy according to the target mark 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.
[0057] like Figure 3a As shown, a text enhancement processing method provided by an embodiment of the present invention includes the following specific steps:
[0058] S310: Obtain a scanned grayscale image with uniform brightness.
[0059] S320: Analyze each pixel in the scanned grayscale image using the surrounding pixel pattern image to obtain target edge points and reference points of the text.
[0060] The surrounding pixel pattern map may refer to a pattern map drawn up according to the surrounding environment of the pixels in the text image. For example, the background pixels should be above the edge points, and the upper edge pattern map may 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, which is usually the center point of the entity pixel point in the surrounding pixel pattern map. The reference point may refer to the reference pixel point in the scanned grayscale image that can be used to process the target edge point.
[0061] like Figure 3bThe figure shows a schematic diagram of a surrounding pixel pattern diagram provided by an embodiment of the present invention, wherein M1 represents an upper edge mode, M2 represents a lower edge mode, M3 represents a left edge mode, M4 represents a right edge mode, M5 represents an upper left edge mode, M6 represents a lower left edge mode, M7 represents an upper right edge mode, and M8 represents a lower right edge mode. In the figure, the solid circle represents an entity pixel point, the blank circle represents a background pixel point, X represents a reference point, and the solid circle with a gray background represents a target edge point. Among them, it is necessary to determine whether the current pixel point is an entity pixel point or a background pixel point based on two thresholds. For example, in an embodiment of the present invention, the pixel value threshold of the background pixel point is set to dW, and the pixel value threshold of the entity pixel point is set to dB. If the pixel value of the current pixel point is less than dB, the pixel point is determined to be an entity pixel point. If the pixel value of the current pixel point is greater than dW, the pixel point is determined to be a background pixel point. In an optional implementation, dW takes a value of 250, and dB can take a value of 160 to 240 according to the actual needs of the image. Specifically, first, each pixel point in the scanned grayscale image is scanned, and each pixel point in the scanned grayscale image is judged according to the pixel value threshold to obtain the entity pixel point and the background pixel point, and then the target edge point and the reference point can be determined according to the position of each pixel point in the surrounding pixel pattern image M1-M8.
[0062] S330: Determine edge deepening pixel values based on the pixel values of the reference points and the pixel values of the target edge points, and use the edge deepening pixel values to deepen the target edge points in the scanned grayscale image to obtain a target image with hardened text edges.
[0063] Among them, the edge deepening pixel value may refer to the calculated pixel value for deepening the pixel value of the target edge point. For example, the intermediate value between 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 point in the scanned grayscale image matches the position of each pixel point in the surrounding pixel pattern images M1-M8, after determining the target edge point and the reference point, the edge deepening pixel value may be calculated according to the formula: edge deepening pixel value = (pixel value of the reference point + pixel value of the target edge point) / 2, and the calculated edge deepening pixel value may be used to deepen the target edge point in the scanned grayscale image to obtain the target image.
[0064] In an optional embodiment, the process of deepening the target edge points in the scanned grayscale image using the edge deepening target value to obtain a target image with hardened text edges includes: obtaining the minimum edge deepening pixel value calculated in each surrounding pixel pattern image, and comparing the minimum edge deepening pixel value 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 assign the pixel value of the target edge point as the minimum edge deepening pixel value to obtain a target image with hardened text edges. Specifically, if the positions of the pixel points in the scanned grayscale image match successfully with the positions of the pixel points in the surrounding pixel pattern image M1, calculate the edge deepening pixel value VT1. If the edge deepening pixel value VT1 is less than the pixel value of the target edge point, then assign the pixel value of the target edge point as the edge deepening pixel value VT1; further, then match the positions of the pixel points in the scanned grayscale image with the positions of the pixel points in the surrounding pixel pattern image M2. If the positions of the pixel points in the scanned grayscale image match successfully with the positions of the pixel points in the surrounding pixel pattern image M2, calculate the edge deepening pixel value VT2. If the edge deepening pixel value VT2 is less than the edge deepening pixel value VT1, then replace the edge deepening pixel value VT1 with the edge deepening pixel value VT2, and assign the pixel value of the target edge point as the edge deepening pixel value VT2; taking this as an example, then successively complete the matching of the surrounding pixel pattern images M3 - M8, and finally assign the pixel value of the target edge point as the minimum edge deepening pixel value, that is, a target image with hardened text edges can be obtained.
[0065] As Figure 3c shown is a schematic diagram of the 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. As can be Figure 3c seen from it, in the target image obtained by the embodiment of the present invention, some pixels in the text edge area are significantly deepened, making the text image clearer.
[0066] S340: Adjust the grayscale distribution range of the target image to obtain an adjusted image.
[0067] As Figure 3d shown is a schematic diagram of the result of an adjusted image provided by an embodiment of the present invention. Among them, the left side is the target image before the grayscale distribution range adjustment, and the right side is the adjusted image after the grayscale distribution range adjustment. As can be Figure 3d seen from it, the adjusted image has an obvious effect of enhanced contrast. The extra grayscale between the strokes of the character "翁" is weakened, and the area around the character "黨" is clearer. Moreover, the edge transition area of the text image has been lightened during the grayscale distribution range adjustment, which provides convenience for subsequent work.
[0068] S350: Construct a labeling graph in which the initial value of each pixel value is the minimum pixel value.
[0069] The minimum pixel value may refer to an image in which the initial pixel value of each pixel is 0. The label image may refer to an image in which the initial pixel value of each pixel is 0.
[0070] S360: Obtain the pixel value of the target pixel point whose pixel value is greater than or equal to the marked background value in the adjusted image, and calculate the number of pixel points whose pixel values are lower than the marked entity value and the number of pixel points whose pixel values are higher than the marked background value in a set area centered on the target pixel point, as the first number and the second number, respectively.
[0071] Among them, the set 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 entity pixels. For example, mW may be 230; the marked entity value may refer to the threshold mB used to mark background pixels. For example, mB may be 135. Generally, pixels with pixel values higher than the marked background value mW are regarded as marked background pixels, and pixels with pixel values lower than the marked entity value mB are regarded as marked entity pixels. The first quantity may refer to the number nB of marked entity pixels in the set area centered on the target pixel; the second quantity may refer to the number nW of marked background pixels in the set area centered on the target pixel.
[0072] Specifically, each pixel point in the adjusted image is scanned, and when the pixel value f(x, y) of the target pixel point is greater than or equal to the marked background value mW, the target pixel point is taken as the center point, and the pixel points in a 5×5 range around the target pixel point are sampled and retrieved in the form of Table 1, and the number nB of marked entity pixels and the number nW of marked background pixels in the 5×5 range are counted to obtain a first number and a second number.
[0073] Table 1 Pixels within a 5×5 range with the target pixel as the center point
[0074]
[0075] S370: If the first number is less than or equal to a first number threshold or the second number is less than or equal to a second number threshold, the pixel value at the position corresponding to the target pixel point in the marking image is marked as the first target pixel value, otherwise, the pixel value marked as the target pixel point is obtained to obtain a preprocessed marking image; wherein the first number threshold is less than the second number threshold; and the first target pixel value is greater than the minimum pixel value.
[0076] Among them, the first quantity threshold may refer to a numerical value used to evaluate the first quantity; the second quantity threshold may refer to a numerical value used to evaluate the second quantity. The first target pixel value may refer to a numerical value for modifying the initial pixel value of the position corresponding to the target pixel point in the marking image 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 an embodiment of the present invention, the first quantity threshold may be set to 1; the second quantity threshold may be set to 2; and the first target pixel value may be set to 1, indicating a background pixel point far away from the edge. Specifically, when f(x,y)>=mW, the target pixel corresponding to f(x,y) may be a background pixel. If nB is too small, it means that the target pixel is far away from the entity. If nW is too small, it means that the target pixel is far away from the blank, that is, it may be in a color block. Since there are usually both entity pixels and background pixels around edge pixels, if nB is too small or nW is too small, the target pixel cannot be used as a pixel near the edge. Therefore, when the first number nB<=1 or the second number nW<=2, the pixel value of the position (x,y) corresponding to the target pixel in the marking image is marked as 1, and it is regarded as a background pixel far away from the edge. Otherwise, it is marked as the pixel value f(x,y) of the target pixel.
[0077] S380: Search a preset area in the preprocessed marking image centered on pixel points whose pixel values are greater than the marking background value, and mark the pixel values of the pixel points in the preset area whose pixel values are equal to the minimum pixel value as second target pixel values to obtain a target marking image; wherein the second target pixel value is greater than the first target pixel value.
[0078] The preset area may refer to a square area centered on pixels whose pixel values are greater than the marked background value. For example, it may be a 3×3 area as shown in Table 2, where the pixel value of the center point is recorded as f(x, y). The second target pixel value may refer to a value to be modified for a pixel point when there is a pixel point with a minimum pixel value in the preset area. In an embodiment of the present invention, the second target pixel value may be 2, indicating an edge pixel point to be deepened.
[0079] Specifically, when searching a 3×3 range centered on a pixel point whose pixel value is greater than the marking background value in the preprocessed marking image, if a pixel point with a pixel value of 0 is found, the pixel value of the pixel point is marked as 2, that is, the edge pixel point to be deepened, and the final target marking image is obtained.
[0080] Table 2 Pixels in a 3×3 range centered on a pixel whose pixel value is greater than the marked background value
[0081]
[0082] like Figure 3eFIG. 1 is a schematic diagram of a target labeling image generation process provided by an embodiment of the present invention. FIG. (a) is an adjusted image, FIG. (b) is a partially enlarged view of the adjusted image, FIG. (c) is a local target labeling image, and FIG. (d) is an image obtained by superimposing the edge pixel point with a value of 2 in the target labeling image and the adjusted image. Figure 3e It can be seen that the edge pixel points with a value of 2 in the target mark map are more accurate. If the edge of the adjusted image is further enhanced according to the target mark map, the resulting image (d) will have a better text enhancement effect than image (a).
[0083] S390: backing up the adjusted image to obtain an adjusted image copy, filling and blurring the adjusted image copy according to the target marking image 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.
[0084] Among them, filling the target mark image may refer to filling the pixel values of the pixel points in the target mark image that exceed the mark background value mW. Blurring may refer to using an algorithm to blur the filled target mark image; through blurring, the background pixels and entity pixels adjacent to the edge of the text can infect the edge of the text at the same time, and the edge of the text can be significantly deepened during the blurring process, while the entity pixels adjacent to the edge of the text can be lightened. The adjusted image copy may refer to a copy image of the adjusted image that is backed up.
[0085] In an optional embodiment, the step of filling and blurring the copy of the adjusted image according to the target mark 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 includes: replacing the pixel values of the pixels in the copy of the adjusted image corresponding to the pixels whose pixel values in the target mark map exceed the marked background value with the target pixel values to obtain a target filled image; scaling the target filled image using a linear interpolation scaling method to obtain a blurred image; assigning the pixel values in the blurred image that meet the set conditions to the corresponding positions of the adjusted image to obtain a text-enhanced image. In this embodiment of the present invention, the target pixel value can be set to 155. The pixel value of the set condition can refer to the pixel value of the darkened pixel in the blurred image. The corresponding position of the adjusted image can refer to the position of the pixel whose value in the target mark map is 2 and is valid in the target edge filter map; it can also refer to the position of the pixel whose pixel value is invalid in the target edge filter map but is very dark, for example, the pixel value is less than 80. The target edge filter map may refer to an edge filter map for edge point judgment of the adjusted image based on the surrounding pixel pattern maps M1-M8, in which the background pixel value is fixed to 255, and the pixel points with a pixel value less than 255 are regarded as entity pixels, and the non-blank pixel points in the target edge filter map are used as edge filter marks. Figure 3f FIG. 1 is a schematic diagram of a target edge filter image provided by an embodiment of the present invention, wherein the schematic diagram is a result image after the target edge filter image is superimposed with the adjusted image. Figure 3g The figure shows a schematic diagram of the superposition result of a target marking map and a target edge filter map provided by an embodiment of the present invention, wherein light gray is the edge result of the target edge filter map, dark gray is the edge result of the target marking map, and black is the superposition result of the target marking map and the target edge filter map. Due to the edges marked in the target marking map, the adjacent strokes of small characters are easily marked as edge deepening, but this part of the deepening is likely to reduce the stroke gap, making the final handwriting unclear; in addition, if the circle around the text is completely marked, the marked edge will be too full, so that after deepening, the font strokes may be too thick, which is much 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 marking map and the target edge filter map.
[0086] like Figure 3hThe figure shows 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, the pixel values of the pixels in the adjusted image copy corresponding to the pixels whose pixel values in the target mark map exceed the mark background value mW are replaced with 155 to obtain the target fill map, and then the linear interpolation scaling method is used to perform two scaling transformations on the target fill map. For example, the target fill map is first enlarged to 1.5 times, and then the enlarged image is reduced back to its original size to obtain the blurred image. If there is a pixel whose value in the target mark map is 2 and is valid in the target edge filter map, or a pixel whose value is invalid in the target edge filter map but whose pixel value is very deep, the pixel value of the pixel in the blurred image is assigned to the corresponding position of the adjusted image to obtain a text-enhanced image. Figure 3i The figure shows a result schematic diagram of a text enhancement 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 edge of the enhanced text is moderately deepened and the parts where the strokes are close are avoided, which is beneficial for obtaining more ink dots on the edge of the text in subsequent operations.
[0087] In another optional embodiment, after assigning the pixel values in the blurred image that meet the set conditions to the corresponding positions of the adjusted image to obtain the text-enhanced image, it also includes: matching the pixel points corresponding to the pixel points with non-minimum pixel values in the target mark image in the text-enhanced image, and modifying the pixel values of the matched pixel points to the maximum pixel values to remove the filled target pixel values. Specifically, the pixel values of the pixel points in the text-enhanced image that correspond to the pixel points with non-0 pixel values in the target mark image are modified to 255 pixel values to erase the previously filled target pixel values. In another optional embodiment, the pixel points with a pixel value of 1 in the target mark image can also be paid attention to, and the pixel values of the pixel points in the text-enhanced image that correspond to the pixel points are modified to 255 pixel values to remove the bottom noise in the text-enhanced image.
[0088] The technical solution of the embodiment of the present invention obtains a target image by performing edge point enhancement processing on an acquired scanned grayscale image with uniform brightness, and then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image. This solves the problem that the algorithm preprocessing process used in the prior art is too complicated, which causes great trouble to equipment with limited resources and high real-time requirements. It achieves text enhancement processing on text images while simplifying the algorithm complexity, improving the algorithm running speed and ensuring the accuracy of printed text.
[0089] On the basis of the above embodiment, after edge marking and edge enhancement processing are performed on the adjusted image to obtain a text enhanced image, the method further includes: binarizing the text enhanced image using an error diffusion method to obtain a halftone image to provide a dot signal for a printing device. Since the printing device requires two signals, 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 transmitted to the printing device, that is, the binarization process of the printing device must convert the continuous tone image of the grayscale image into a halftone image, that is, the density change of the distribution of black dots is used to simulate the light and dark changes of the image. In the embodiment of the present invention, the error diffusion method is used to convert the text enhanced image, and the "Javis filter" with a large diffusion range and easy to improve edge contrast is used in the error diffusion operation. Among them, the working form of the filter can be 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 error generated will be accumulated to the pixels at the corresponding positions around it according to the weights in Table 3. For example, with the median 127 as the threshold, if the pixel value 60 at * 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 filter scans the surrounding pixels. If the pixel value of the pixel on the right has a weight of 7 / 48, then the pixel value of the pixel on the right should be accumulated with a value of +60*(7 / 48). The positions of other pixel points in the filter change in the same way. Each pixel point is binarized based on the new pixel value after the error of the previous pixel point is diffused, and the new error is diffused to the subsequent pixel points to achieve error diffusion. Figure 3j FIG. 1 is a schematic diagram of a binarization result 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. Figure 3j It can be seen that the generated halftone image ink dots are clearer and can provide dot signals for the printing equipment.
[0090] Table 3 Filter working form table
[0091]
[0092] Figure 4aA schematic diagram of a preferred text enhancement processing method flow provided by an embodiment of the present invention. Specifically, first, input a scanned grayscale image with balanced brightness. Afterwards, the scanned grayscale image is input into the image enhancement processing module to sequentially complete edge enhancement processing one (i.e., the first enhancement processing module), light and dark contrast adjustment (i.e., the grayscale distribution interval adjustment module) and edge enhancement processing two (i.e., the second 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 light and dark contrast is adjusted to obtain an adjusted image; further, a backup image with an initial pixel value of 0 of the same size as the adjusted image is prepared to determine a binary background threshold hW and a background fill value hB to produce a better edge hardening effect, wherein hW takes a value of 230 and hB takes a value of 220, and the pixel points in the adjusted image whose pixel values exceed hW are marked in the backup image, and the pixel values of the pixel points in the adjusted image whose pixel values are higher than hW are replaced with hB to obtain a text enhanced image. Finally, the text enhanced image is halftoned and the binary image is output to a printing device. Figure 4b The figure shows a result schematic diagram of a halftone image provided by an embodiment of the present invention, wherein the upper figure is the processing result obtained by directly binarizing the scanned grayscale image, and the lower figure is the processing result obtained by binarizing after text enhancement processing according to the embodiment of the present invention. Figure 4b It can be seen from the figure that the binarized image obtained by the embodiment of the present invention can enhance the text display effect of the printed image with minimal impact on the text image.
[0093] Figure 5 The following is a schematic diagram of the structure of a text enhancement processing device provided by an embodiment of the present invention. The device can execute the text enhancement processing methods involved in the above embodiments. The device can be implemented in software and / or hardware, such as Figure 5 As shown, the text enhancement processing device specifically includes: a data acquisition module 510, a first enhancement processing module 520, a grayscale distribution interval adjustment module 530, and a second enhancement processing module 540.
[0094] The data acquisition module 510 is used to acquire a scanning grayscale image with uniform brightness;
[0095] The first enhancement processing module 520 is used to perform enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;
[0096] A grayscale distribution interval adjustment module 530 is used to adjust the grayscale distribution interval of the target image to obtain an adjusted image;
[0097] The second enhancement processing module 540 is used to perform edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image.
[0098] The technical solution of the embodiment of the present invention obtains a target image by performing edge point enhancement processing on an acquired scanned grayscale image with uniform brightness, and then adjusts the grayscale distribution interval of the target image, and performs edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image. This solves the problem that the algorithm preprocessing process used in the prior art is too complicated, which causes great trouble to equipment with limited resources and high real-time requirements. It achieves text enhancement processing on text images while simplifying the algorithm complexity, improving the algorithm running speed and ensuring the accuracy of printed text.
[0099] Optionally, the first enhancement processing module 520 may include a pixel acquisition unit and a target image acquisition unit;
[0100] The pixel acquisition unit may be used to analyze each pixel in the scanned grayscale image using a surrounding pixel pattern image to obtain target edge points and reference points of the text;
[0101] 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 use the edge deepening pixel value to deepen the target edge point in the scanned grayscale image to obtain a target image with hardened text edges.
[0102] Optionally, the second enhancement processing module 540 may include a label map construction unit, a quantity calculation unit, a pre-processed label map acquisition unit, a target label map acquisition unit, and a text enhancement image acquisition unit;
[0103] The label map construction unit is used to construct a label map in which the initial value of each pixel value is the minimum pixel value;
[0104] a quantity calculation unit, configured to obtain a pixel value of a target pixel point in the adjusted image whose pixel value is greater than or equal to the marked background value, and calculate the number of pixel points whose pixel values are lower than the marked entity value and the number of pixel points whose pixel values are higher than the marked background value in a set area centered on the target pixel point, as the first quantity and the second quantity, respectively;
[0105] A preprocessing mark map acquisition unit is used to mark the pixel value at the position corresponding to the target pixel point in the mark map as the first target pixel value if the first number is less than or equal to a first number threshold or the second number is less than or equal to a second number threshold, otherwise, mark the pixel value of the target pixel point 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;
[0106] A target label map acquisition unit is used to retrieve a preset area centered on pixel points whose pixel values are greater than the label background value in the preprocessed label map, mark the pixel values of the pixel points whose pixel values in the preset area are equal to the minimum pixel value as second target pixel values, and obtain a target label map; wherein the second target pixel value is greater than the first target pixel value;
[0107] The text-enhanced image acquisition unit is used to back up the adjusted image to obtain an adjusted image copy, fill and blur the adjusted image copy according to the target marking image to obtain a blurred image, and use the blurred image to perform edge enhancement processing on the adjusted image to obtain a text-enhanced image.
[0108] Optionally, the text-enhanced image acquisition unit can be specifically used to replace the pixel values of the pixel points in the adjusted image copy corresponding to the pixel points in the target mark image whose pixel values exceed the mark background value with the target pixel values to obtain a target fill image; use a linear interpolation scaling method to scale the target fill image to obtain a blurred image; assign the pixel values in the blurred image that meet the set conditions to the corresponding positions of the adjusted image to obtain a text-enhanced image.
[0109] 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 the minimum edge deepening pixel value to obtain the target image with hardened text edges.
[0110] Optionally, the text enhancement processing device may further include a binarization processing module, which is used to perform edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image, and then use an error diffusion method to binarize the text enhanced image to obtain a halftone image to provide a dot signal for a printing device.
[0111] Optionally, the text enhancement processing device may further include a target pixel value removal module, which is used to assign pixel values that meet the set conditions in the blurred image to corresponding positions of the adjusted image to obtain a text enhanced image, match pixel points corresponding to pixel points with non-minimum pixel values in the target marker image in the text enhanced image, and modify the pixel values of the matched pixel points to the maximum pixel value to remove the filled target pixel value. The text enhancement processing device 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 the functional modules and beneficial effects corresponding to the execution method.
[0112] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the electronic device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of the processor 610 in the electronic device can be one or more. Figure 6 A processor 610 is taken as an example; the processor 610, the memory 620, the input device 630 and the output device 640 in the electronic device can be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0113] The memory 620, as a computer-readable storage medium, 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 data acquisition module 510, the first enhancement processing module 520, the grayscale distribution interval adjustment module 530 and the second enhancement processing module 540 in the text enhancement processing device). 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, realizes the above-mentioned text enhancement processing method.
[0114] The memory 620 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 620 may further include a memory remotely arranged relative to the processor 610, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0115] The input device 630 may be used to receive input digital 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.
[0116] An embodiment of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to perform a text enhancement processing method when executed by a computer processor, the method comprising:
[0117] Obtain a scanned grayscale image with uniform brightness;
[0118] Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges;
[0119] Adjusting the grayscale distribution interval of the target image to obtain an adjusted image;
[0120] The adjusted image is subjected to edge marking and edge enhancement processing to obtain a text-enhanced image.
[0121] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention is not limited to the method operations described above, and can also execute related operations in the text enhancement processing method provided by any embodiment of the present invention.
[0122] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0123] It is worth noting that in the embodiment of the above-mentioned text enhancement processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0124] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A text enhancement processing method, characterized in that: include: 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; Performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image; The step of performing edge marking and edge enhancement processing on the adjusted image to obtain a text-enhanced image includes: Construct a labeling map in which the initial value of each pixel value is the minimum pixel value; Obtaining the pixel value of a target pixel point in the adjusted image whose pixel value is greater than or equal to the marked background value, and calculating the number of pixel points whose pixel values are lower than the marked entity value and the number of pixel points whose pixel values are higher than the marked background value in a set area centered on the target pixel point, as the first number and the second number, respectively; If the first number is less than or equal to a first number threshold or the second number is less than or equal to a second number threshold, the pixel value at the position corresponding to the target pixel point in the labeling map is marked as the first target pixel value, otherwise, the pixel value marked as the target pixel point is obtained to obtain a preprocessed labeling 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; Searching a preset area centered on pixel points whose pixel values are greater than the marked background value in the preprocessed marked image, marking the pixel values of the pixel points whose pixel values in the preset area are equal to the minimum pixel value as second target pixel values, to obtain a target marked image; 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 marking image to obtain a blurred image, and the blurred image is used to perform edge enhancement processing on the adjusted image to obtain a text enhanced image.
2. The method according to claim 1, characterized in that Performing enhancement processing on the edge points of the scanned grayscale image to obtain a target image with hardened text edges includes: Analyze each pixel in the scanned grayscale image using the surrounding pixel pattern image to obtain the target edge point and reference point of the text; The edge deepening pixel value is determined based on the pixel value of the reference point and the pixel value of the target edge point, and the target edge point in the scanned grayscale image is deepened using the edge deepening pixel value to obtain a target image with hardened text edges.
3. The method according to claim 1, characterized in that: The step of filling and blurring the copy of the adjusted image according to the target marking image to obtain a blurred image, and performing edge enhancement processing on the adjusted image using the blurred image to obtain a text enhanced image comprises: Replacing the pixel values of the pixels in the adjusted image copy corresponding to the pixels in the target marked image whose pixel values exceed the marked background value with the target pixel values to obtain the target filled image; The target filling image is scaled using a linear interpolation scaling method to obtain a blurred image; The pixel values in the blurred image that meet the set conditions are assigned to the corresponding positions of the adjusted image to obtain a text-enhanced image.
4. The method according to claim 2, characterized in that: The step of deepening the target edge points in the scanned grayscale image by using the edge deepening target value to obtain a target image with hardened text edges comprises: Obtaining the minimum edge deepening pixel value calculated in each surrounding pixel pattern map, and comparing the minimum edge deepening pixel value 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, 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.
5. The method according to claim 1, characterized in that After edge marking and edge enhancement processing are performed on the adjusted image to obtain a text enhanced image, the method further includes: The text enhancement image is binarized using an error diffusion method to obtain a halftone image to provide a dot signal for a printing device.
6. The method according to claim 3, characterized in that After assigning pixel values in the blurred image that meet the set conditions to corresponding positions of the adjusted image to obtain a text enhanced image, the method further includes: Pixel points corresponding to the pixel points with non-minimum pixel values in the target label image are matched in the text-enhanced image, and the pixel values of the matched pixel points are modified to the maximum pixel values to remove the filled target pixel values.
7. A text enhancement processing device, characterized in that: include: A data acquisition module, used to acquire a scanning grayscale image with uniform brightness; A first enhancement processing module is used 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, used for adjusting the grayscale distribution interval of the target image to obtain an adjusted image; A second enhancement processing module is used to perform edge marking and edge enhancement processing on the adjusted image to obtain a text enhanced image; The second enhancement processing module includes a label map construction unit, a quantity calculation unit, a pre-processing label map acquisition unit, a target label map acquisition unit and a text enhancement image acquisition unit; A label map construction unit, used for constructing a label map in which the initial value of each pixel value is the minimum pixel value; a quantity calculation unit, configured to obtain a pixel value of a target pixel point in the adjusted image whose pixel value is greater than or equal to the marked background value, and calculate the number of pixel points whose pixel values are lower than the marked entity value and the number of pixel points whose pixel values are higher than the marked background value in a set area centered on the target pixel point, as the first quantity and the second quantity, respectively; A preprocessing mark map acquisition unit is used to mark the pixel value at the position corresponding to the target pixel point in the mark map as the first target pixel value if the first number is less than or equal to a first number threshold or the second number is less than or equal to a second number threshold, otherwise, mark the pixel value of the target pixel point 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; A target label map acquisition unit is used to retrieve a preset area centered on pixel points whose pixel values are greater than the label background value in the preprocessed label map, mark the pixel values of the pixel points whose pixel values in the preset area are equal to the minimum pixel value as second target pixel values, and obtain a target label map; wherein the second target pixel value is greater than the first target pixel value; The text-enhanced image acquisition unit is used to back up the adjusted image to obtain an adjusted image copy, fill and blur the adjusted image copy according to the target marking image to obtain a blurred image, and use the blurred image to perform edge enhancement processing on the adjusted image to obtain a text-enhanced image.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device 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 as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the text enhancement processing method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and medium
CN112950588A