Image processing method and device, electronic equipment and readable medium
By using a target dither matrix to perform halftone processing on the pixel matrix units of the scanned image, the problems of high computational overhead and slow processing speed during the copying process are solved, and more efficient image processing is achieved.
Patent Information
- Application Number
- CN202511247672.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-02
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-09-02
AI Technical Summary
In the prior art, during the copying process, it is necessary to perform linear interpolation on the original scanned image using an image magnification algorithm, which results in high computational overhead and slow processing speed.
The target dither matrix is used to perform halftone processing on the pixel matrix units of the original scanned image to directly generate a printable image, avoiding the use of an image enlargement algorithm.
It reduces computational overhead, improves processing speed, and ensures image processing efficiency.
Smart Images

Figure CN120751070A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image technology, and in particular to an image processing method, device, electronic device and readable medium. Background Art
[0002] In the current copying process, after the document to be copied is scanned by a scanning component, the obtained original scanned image needs to be converted into a printable image of a larger size and then sent to a printing component for processing.
[0003] In existing technologies, linear interpolation of the original scanned image is first performed using an image magnification algorithm to magnify the rows and columns of the original scanned image to the corresponding row and column magnification factors, thereby obtaining an enlarged scanned image. This enlarged scanned image is then converted into a bitmap to produce a printable image. This results in high computational overhead and slow processing speed. Summary of the Invention
[0004] Embodiments of the present invention provide an image processing method, device, electronic device, and readable medium, which can solve the problems of high computational overhead and slow processing speed.
[0005] In order to solve the above problems, an embodiment of the present invention discloses an image processing method, which includes: Get the target dither matrix pre-set for the original scanned image; For any first pixel point in the original scanned image, the pixel values of each pixel point in an m×n pixel matrix are set to the pixel value of the first pixel point, to obtain a pixel matrix unit; m and n are respectively a preset row magnification factor and a preset column magnification factor; Performing halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point; Based on the bitmap matrix units respectively corresponding to all first pixels in the original scanned image, a printable image corresponding to the original scanned image is composed.
[0006] In another aspect, an embodiment of the present invention discloses an image processing device, comprising: An acquisition module, used for acquiring a target dither matrix preset for an original scanned image; a generating module configured to, for any first pixel point in the original scanned image, set the pixel value of each pixel point in an m×n pixel matrix to the pixel value of the first pixel point, thereby obtaining a pixel matrix unit; wherein m and n are respectively a preset row magnification factor and a preset column magnification factor; A first processing module is configured to perform halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point; The second processing module is configured to compose a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all first pixels in the original scanned image.
[0007] On the other hand, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the aforementioned method.
[0008] An embodiment of the present invention further discloses a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method described above.
[0009] Embodiments of the present invention include the following advantages: The image processing method provided by the embodiment of the present invention obtains a target dither matrix pre-set for the original scanned image. For any first pixel in the original scanned image, the pixel values of each pixel in an m×n pixel matrix are set to the pixel value of the first pixel, thereby obtaining a pixel matrix unit; m and n are respectively a preset row magnification factor and a preset column magnification factor. Based on the target dither matrix, halftone processing is performed on the pixel matrix unit to obtain a bitmap matrix unit corresponding to the first pixel. Based on the bitmap matrix units corresponding to all first pixels in the original scanned image, a printable image corresponding to the original scanned image is formed. In this way, the pixel matrix unit expanded from each pixel in the original scanned image is directly used as the processing granularity, and halftone processing is performed on the pixel matrix unit to obtain a bitmap matrix unit. Finally, a printable image can be formed based on all the bitmap matrix units. Since there is no need to first use an image magnification algorithm to generate an enlarged scanned image, computational overhead can be reduced and processing speed can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] Figure 1 is a flowchart of the steps of an image processing method provided by an embodiment of the present invention; Figure 2This is a division diagram provided by an embodiment of the present invention; Figure 3 This is another division diagram provided by an embodiment of the present invention; Figure 4 is a schematic diagram of an original scanned image provided by an embodiment of the present invention; Figure 5 is a schematic diagram of a dithering sub-matrix provided by an embodiment of the present invention; Figure 6 This is another division diagram provided by an embodiment of the present invention; Figure 7 is a schematic diagram of a printable image provided by an embodiment of the present invention; Figure 8 is a block diagram of an image processing device provided by an embodiment of the present invention; Figure 9 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0012] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0013] Figure 1 This is a flowchart of an image processing method provided by an embodiment of the present invention. Figure 1 As shown, the image processing method may include the following steps: Step 101: Obtain a target dither matrix preset for an original scanned image.
[0014] Step 102: For any first pixel point in the original scanned image, set the pixel value of each pixel point in a pixel matrix of size m×n to the pixel value of the first pixel point to obtain a pixel matrix unit; m and n are respectively a preset row magnification factor and a preset column magnification factor.
[0015] Step 103: Perform halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point.
[0016] Step 104 : compose a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all first pixels in the original scanned image.
[0017] In an embodiment of the present invention, the target dither matrix is a dither matrix used for halftoning. The same target dither matrix can be used for processing the original scanned image obtained by the scanning component each time. Specifically, a pre-set target dither matrix can be loaded from a specified location to obtain the target dither matrix pre-set for the original scanned image. The specified location can be a location pre-defined by the developer for storing the target dither matrix.
[0018] The preset row magnification factor (i.e., m) and the preset column magnification factor (i.e., n) can be determined by the target size of the printable image required by the printing component. Both the row magnification factor and the column magnification factor are positive integers not less than 2. Specifically, the image processing method provided in embodiments of the present invention can be applied to an all-in-one printer (M2M) equipped with a copying function. Specifically, the M2M includes a scanning component and a printing component. In a copying scenario, the scanning component scans the document to be copied, generating a scanned image. The scanned image is then processed to generate a printable image that can be processed by the printing component. The printable image is then sent to the printing component for printing, completing the entire copying process. During the copying process, if the speed of generating the printable image is slower than the printing speed, the printing component will wait, which will in turn hinder the printing process and affect the machine's copying performance. Therefore, the scanning speed of the scanning component is often higher than the printing speed of the printing component. The printing and scanning components use dots per inch (DPI) to express the print speed / scan speed. The DPI of the printing component is negatively correlated with the printing speed, and the DPI of the scanning component is negatively correlated with the scanning speed. The DPI of the printing component can be specifically used to describe the printing resolution. The printing resolution determines the clarity and detail of the printed image. Therefore, the printing speed is closely related to the printing resolution. The higher the printing resolution, the more ink dots the print head needs to place per unit length to form an image, and the slower the printing speed. Therefore, DPI can be used to represent the printing speed. Furthermore, the DPI of the scanning component can be specifically used to describe the scanning resolution. The scanning resolution determines the clarity and detail of the scanned image. Therefore, the scanning speed is closely related to the scanning resolution. When the scanning resolution is higher, the scanner needs to collect more pixels per unit length to form a scanned image, and the scanning speed is slower. Therefore, DPI can be used to represent the scanning speed.
[0019] In an embodiment of the present invention, the DPI of the printing component / the DPI of the scanning component can be calculated as the row magnification factor and the column magnification factor. Specifically, the DPI of the printing component follows the industry measurement standard for printing, and the DPI used by the printing component is 600 DPI. The scanning component can support scanning parameters of 300 / 600 / 1200 DPI. However, only when using 300 DPI can the scanning speed be higher than the printing speed, achieving fast scanning. Therefore, the DPI of the scanning component is 300 DPI. Accordingly, since the DPI of the scanning component is 300 DPI and the DPI of the printing component is 600 DPI, it is necessary to enlarge the 300 DPI scanned image to a 600 DPI image. Let m represent the preset row magnification factor and n represent the preset column magnification factor, then m=n=600 / 300=2, which means that the final printable image generated is twice the size of the original scanned image in both horizontal and vertical directions. Correspondingly, the number of rows of the target size is the number of rows of the original scanned image × m, and the number of columns of the target size is the number of rows and columns of the original scanned image × n.
[0020] A first pixel refers to any pixel in the original scanned image, and the pixel value of the pixel can be a grayscale value. During the process of converting the original scanned image into a printable image, each pixel in the original scanned image is expanded into a pixel matrix unit. The pixel matrix unit expanded from a first pixel can be considered the pixel matrix unit corresponding to the first pixel. A pixel matrix unit is essentially a matrix containing pixel values, with the number of rows and columns of the matrix being a preset row magnification factor and a preset column magnification factor, respectively. Thus, the total size of the pixel matrix represented by all pixel matrix units of the first pixel is the target size. Generating a pixel matrix unit for a first pixel is equivalent to performing expansion for that first pixel. For any first pixel in the original scanned image, the pixel value of the first pixel can be read as the target pixel value. A pixel matrix of size m×n is generated. The pixel matrix can be an empty matrix or a matrix containing all zeros, with each element in the pixel matrix representing a pixel. The values of all elements in the pixel matrix are then set to the target pixel value, thereby obtaining the pixel matrix unit corresponding to the first pixel.
[0021] In an embodiment of the present invention, the position coordinates of the first pixel point can be used as input parameters of a preset pixel value acquisition function, and then the output of the pixel value acquisition function is used as the target pixel value. The position coordinates of the first pixel point are used to indicate the row and column where the first pixel point is located in the original scanned image. Exemplarily, the pixel value acquisition function can be getpixel(z), where z represents an input parameter, and the position coordinates of the first pixel point can be expressed as (i, j). The original scanned image includes multiple pixel rows and multiple pixel columns, i can be the row identifier of the row where the first pixel point is located in the original scanned image, j can be the column identifier of the column where the first pixel point is located in the original scanned image, the row identifier can be the row number, and the column identifier can be the column number.
[0022] Then, the parameters (m, n) representing the size of the matrix to be created and the target pixel value are used as input parameters of the pixel matrix creation function. By executing the pixel matrix creation function, the pixel matrix creation function can first generate an m×n pixel matrix, and then set the pixel value of each pixel point to the target pixel value. Ultimately, a pixel matrix of size m×n can be obtained, in which all element values are the target pixel values. This matrix is the pixel matrix unit corresponding to the first pixel point. Exemplarily, the matrix creation function can be the Eigen::Matrix function.
[0023] Assuming that the pixel value of the first pixel in the i-th row and j-th column is 175, and m=n=2, the pixel value of the pixel in the generated pixel matrix unit can be:
[0024] Generating a pixel matrix unit for the first pixel is equivalent to copying the first pixel into m×n copies. In this embodiment of the present invention, the pixel matrix unit is obtained by reading the pixel value of the first pixel as the target pixel value and generating an m×n pixel matrix whose element values are all the target pixel values. This allows for convenient pixel expansion.
[0025] Furthermore, the bitmap matrix unit corresponding to the first pixel point is essentially a matrix including pixel values, and therefore, the size of the bitmap matrix unit is consistent with the size of the pixel matrix unit corresponding to the first pixel point. Accordingly, the total size of the pixel matrix represented by all bitmap matrix units is also the target size. Therefore, based on the bitmap matrix unit, the printable image required by the printing component can be composed, and the number of rows of the printable image finally obtained is m times the number of rows of the original scanned image, and the number of columns of the printable image is n times the number of columns of the original scanned image. For example, taking the DPI of the scanning component as 300 as an example, assuming that the width of the original scanned image is W and the height is H, then the number of columns of the printable image finally generated is n×W×300, and the number of rows of the printable image is m×H×300.
[0026] Since the scanned image obtained by the scanning component is a grayscale image, and the printing component processes a bitmap, for example, the scanned image can be an 8-bit deep grayscale image. The pixel values of the pixels in the scanned image occupy 8 bits of memory, and the pixel values of the pixels in the scanned image range from 0 to 255. The printable image is a bitmap, and the pixel values of the pixels in the printable image occupy 1 bit of memory, and the pixel values of the pixels in the printable image range from 0 to 1. Therefore, halftoning can be performed on the pixel matrix unit to obtain a bitmap matrix unit. A bitmap matrix unit can represent a portion of the bitmap. Halftoning can simulate the visual effect of a continuous tone image. Halftoning can use a small number of colors to quantize a continuous tone image into an image with only a few colors. The quantized image looks similar to the original image at a certain distance. In embodiments of the present invention, halftoning is used to set the pixel values of the pixels in the pixel matrix unit to 0 or 1, thereby obtaining a bitmap matrix unit. In other words, the pixel values in the resulting printable image are either 0 or 1, i.e., only black and white.
[0027] After obtaining the bitmap matrix units corresponding to all the first pixel points, the bitmap matrix units corresponding to all the first pixel points can be placed in the corresponding positions according to the positions of the first pixel points, thereby obtaining a bitmap of the target size, which is the printable image corresponding to the original scanned image. For example, for the first pixel point in the i-th row and j-th column, the bitmap matrix unit corresponding to the first pixel point is placed in the position of the i-th row and j-th column. Where i and j are integers, i∈[1,a], j∈[1,b], a and b are the number of rows and columns of the original scanned image, respectively. Taking the DPI of the scanning component as 300 as an example, the number of columns of the original scanned image is W×300, and the number of rows of the original scanned image is H×300.
[0028] In summary, the image processing method provided by the embodiment of the present invention obtains a target dither matrix pre-set for the original scanned image. For any first pixel point in the original scanned image, the pixel values of each pixel point in the pixel matrix of size m×n are set to the pixel value of the first pixel point to obtain a pixel matrix unit; m and n are respectively the preset row magnification and the preset column magnification. Based on the target dither matrix, the pixel matrix unit is halftoned to obtain a bitmap matrix unit corresponding to the first pixel point. Based on the bitmap matrix units corresponding to all the first pixel points in the original scanned image, a printable image corresponding to the original scanned image is composed. In this way, the pixel matrix unit expanded from each pixel point in the original scanned image is directly used as the processing granularity, and the pixel matrix unit is halftoned to obtain a bitmap matrix unit. Finally, a printable image can be composed based on all the bitmap matrix units. Since there is no need to use an image magnification algorithm to generate an enlarged scanned image first, the computational overhead can be reduced and the processing speed can be improved.
[0029] Optionally, in an embodiment of the present invention, the target dither matrix includes a plurality of pre-divided dither sub-matrices, and there is no overlap between different dither sub-matrices. The step of performing halftone processing on the pixel matrix unit based on the target dither matrix may specifically include: Step 1031: Select a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the multiple dithering sub-matrices; wherein the second pixel point is any pixel point in the pixel matrix unit.
[0030] Step 1032: For any second pixel point, select an element whose position coordinates match the position coordinates of the first pixel point from the target dithering sub-matrix of the second pixel point as the target element.
[0031] Step 1033: Binarize the pixel value of the second pixel based on the element value of the target element and the pixel value of the second pixel.
[0032] In an embodiment of the present invention, the second pixel point refers to any pixel point included in the pixel matrix unit. For example, for the pixel matrix unit in the aforementioned example, the four elements included in the pixel matrix unit are four second pixel points, and the pixel value of each second pixel point is 175. The target jitter matrix is divided into multiple parts, and each part represents a jitter sub-matrix. Based on the position of the jitter sub-matrix in the target jitter matrix and the position of the second pixel point in the pixel matrix unit, the target jitter sub-matrix is selected for the second pixel point.
[0033] Optionally, in an embodiment of the present invention, the number of the multiple dithering sub-matrices may be the same as the number of second pixel points in the pixel matrix unit. The above-mentioned step of selecting a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the multiple dithering sub-matrices may specifically include: step 1031a, for any second pixel point, selecting a target dithering sub-matrix for the second pixel point from the multiple dithering sub-matrices according to the position information of the second pixel point; wherein different second pixel points have different target dithering sub-matrices.
[0034] In an embodiment of the present invention, the number of dithering sub-matrices may be m×n, so that the number of dithering sub-matrices is the same as the number of second pixel points included in a single pixel matrix unit, thereby enabling different target dithering sub-matrices to be selected for different second pixel points, while also avoiding an excessive number of dithering sub-matrices, which would result in unnecessary waste of resources. In an embodiment of the present invention, by setting the number of second pixel points to a dithering sub-matrix and selecting different target dithering sub-matrices for different second pixel points, it is possible to avoid the situation where the same dithering sub-matrix is used in multiple second pixel points obtained by expanding the same first pixel point, thereby avoiding the problem of unnatural image effects caused by repeated use of the dithering matrix, and thereby ensuring the subsequent image processing effect.
[0035] In one implementation, the position information of the second pixel includes the row identifier of the row and the column identifier of the column in which the second pixel is located in the pixel matrix unit, that is, the position information of the second pixel can indicate the row and column in which the second pixel is located in the pixel matrix unit, and the position information of the dithering sub-matrix can indicate the row and column in which the dithering sub-matrix is located in the target dithering matrix, and the position information of the dithering sub-matrix can include the row identifier of the row and the column identifier of the column in which the dithering sub-matrix is located in the target dithering matrix. The above-mentioned step 1031a can specifically include: for any dithering sub-matrix among the multiple dithering sub-matrices, if the row identifier of the row and the column identifier of the column in which the dithering sub-matrix is located in the target dithering matrix are the same as the row identifier and the column identifier included in the position information of the second pixel, then the dithering sub-matrix is determined as the target dithering sub-matrix of the second pixel.
[0036] Accordingly, when the number of dithering sub-matrices is the same as the number of second pixels in the pixel matrix unit, the target dithering matrix includes multiple rows of dithering sub-matrices and multiple columns of dithering sub-matrices. With the dithering sub-matrix as the division granularity, the target dithering matrix includes m dithering sub-matrix rows and n dithering sub-matrix columns. The target dithering matrix is obtained by dividing the original dithering matrix. Figure 2 This is a division diagram provided by an embodiment of the present invention, such as Figure 2As shown in the figure, (A) represents the original jitter matrix before division (the specific element values are not shown in the figure), and (B) represents the target jitter matrix obtained after division. Under the jitter sub-matrix division granularity, the target jitter matrix obtained after division includes 4 rows and 4 columns, a total of 16 jitter sub-matrices. Among them, a square in (B) represents a jitter sub-matrix, and each jitter sub-matrix itself includes 16 elements. Figure 2 Not shown in the figure.
[0037] The position information of the second pixel point is represented by (p, q), wherein p represents the row number of the row where the second pixel point is located in the pixel matrix unit, and a represents the column number of the column where the second pixel point is located in the pixel matrix unit. Then the jitter sub-matrix of the p-th row and the q-th column can be determined as the target jitter sub-matrix of the second pixel point. Wherein, p and q are integers, p∈[1,m], q∈[1,n]. That is to say, in an embodiment of the present invention, the jitter sub-matrix with the same position information as the position information of the second pixel point can be used as the target jitter sub-matrix of the second pixel point. In this implementation method, the target jitter sub-matrix can be selected for the second pixel point by comparing the row identifier and the column identifier, and the selection efficiency is high.
[0038] Of course, when the number of dithering sub-matrices is less than m×n, there will be a situation where the value of p exceeds the number of dithering sub-matrix rows of the target dithering matrix and the value of q exceeds the number of dithering sub-matrix columns of the target dithering matrix. Accordingly, when p exceeds the number of dithering sub-matrix rows of the target dithering matrix, a remainder operation is performed based on p and the number of dithering sub-matrix rows of the target dithering matrix, that is, the remainder of p divided by the number of dithering sub-matrix rows of the target dithering matrix is determined, and the remainder is recorded as p'. When q exceeds the number of dithering sub-matrix columns of the target dithering matrix, a remainder operation is performed based on q and the number of dithering sub-matrix columns of the target dithering matrix, that is, the remainder of q divided by the number of dithering sub-matrix columns of the target dithering matrix is determined, and the remainder is recorded as q'. If the value of p exceeds the number of dithering sub-matrix rows of the target dithering matrix, and q exceeds the number of dithering sub-matrix columns of the target dithering matrix, the dithering sub-matrix of the p'th row and the q'th column is determined as the target dithering sub-matrix of the second pixel. If only the value of p exceeds the number of dither submatrix rows of the target dither matrix, the dither submatrix in the p'th row and q'th column is determined as the target dither submatrix for the second pixel. If only q exceeds the number of dither submatrix columns of the target dither matrix, the dither submatrix in the p'th row and q'th column is determined as the target dither submatrix for the second pixel. In this way, the remainder is used to ensure that a target dither submatrix is selected for each second pixel.
[0039] In another implementation, the position information of the second pixel may indicate the quadrant in which the second pixel is located. The position information of the dither sub-matrix may indicate the quadrant in which the dither sub-matrix is located. Accordingly, for any second pixel, a dither sub-matrix whose quadrant is consistent with that of the second pixel may be selected as the target dither sub-matrix for the second pixel.
[0040] Optionally, in an embodiment of the present invention, the pixel matrix unit is a homogeneous matrix with a matrix order of 2, and the multiple dithering sub-matrices include dithering sub-matrices corresponding to different quadrants. Among them, a homogeneous matrix refers to a matrix with the same number of rows and columns, and the matrix order represents the number of rows / columns of the homogeneous matrix. The pixel matrix unit is a homogeneous matrix with a matrix order of 2, indicating that a first pixel point is expanded to 4 points, that is, the pixel matrix unit is a 2×2 matrix. Furthermore, the quadrant corresponding to the dithering sub-matrix is the quadrant in which the dithering sub-matrix is located. The multiple dithering sub-matrices may include a dithering sub-matrix corresponding to the upper left quadrant (i.e., the second quadrant), a dithering sub-matrix corresponding to the upper right quadrant (i.e., the first quadrant), a dithering sub-matrix corresponding to the lower left quadrant (i.e., the third quadrant), and a dithering sub-matrix corresponding to the lower right quadrant (i.e., the fourth quadrant). In this way, the division of the dithering sub-matrix can be more in line with the needs of the copying scenario.
[0041] The selecting a target dithering sub-matrix for the second pixel from the multiple dithering sub-matrices according to the position information of the second pixel may specifically include: Step 1031a1: Divide the second pixel points included in the pixel matrix unit into different quadrants.
[0042] Step 1031a2: Select a dithering sub-matrix whose corresponding quadrant is the same as the quadrant where the second pixel is located from the multiple dithering sub-matrices as the target dithering sub-matrix for the second pixel.
[0043] In an embodiment of the present invention, a pixel matrix unit includes four pixels located in different orientations. Accordingly, a two-dimensional coordinate system can be established using the center of the pixel matrix unit as the coordinate origin. For example, an X-axis can be established along the horizontal direction, with the left-to-right direction being the positive direction of the X-axis, and a Y-axis can be established along the vertical direction, with the top-to-bottom direction being the positive direction of the Y-axis. Figure 3 This is another division diagram provided by an embodiment of the present invention, such as Figure 3 As shown, the four second pixel points are divided into the upper left quadrant, the upper right quadrant, the lower left quadrant, and the lower right quadrant. Correspondingly, the position information of these four second pixel points can be: upper left quadrant, upper right quadrant, lower left quadrant, and lower right quadrant. Or, they can be set to: second quadrant, first quadrant, third quadrant, and fourth quadrant respectively. Among them, Figure 3In the example, the pixel values of all second pixel points in the pixel matrix unit are 8.
[0044] It should be noted that when the number of second pixel points included in the pixel matrix unit exceeds 4, the pixel matrix unit can be divided into multiple coordinate systems until each quadrant includes only one second pixel point. For example, assuming that the size of the pixel matrix unit is 16×16, you can start from the upper left corner of the pixel matrix unit, use a 2×2 square matrix in the pixel matrix unit as a division unit, and use the center of the division unit as the coordinate origin to establish a two-dimensional coordinate system, thereby achieving the division of the four second pixel points in the square matrix into different quadrants. Then, divide the next division unit in the same way until the division of all second pixel points in the pixel matrix unit is completed.
[0045] Furthermore, the dithering sub-matrix corresponding to the upper left quadrant can be used as the target dithering sub-matrix for the second pixel point in the upper left quadrant, the dithering sub-matrix corresponding to the upper right quadrant can be used as the target dithering sub-matrix for the second pixel point in the upper right quadrant, the dithering sub-matrix corresponding to the lower left quadrant can be used as the target dithering sub-matrix for the second pixel point in the lower left quadrant, and the dithering sub-matrix corresponding to the lower right quadrant can be used as the target dithering sub-matrix for the second pixel point in the lower right quadrant. That is, in this embodiment of the present invention, the original first pixel point is regarded as four pixels with the same pixel value divided into four quadrants, which respectively correspond to the dithering sub-matrices of the above four quadrants.
[0046] In an embodiment of the present invention, by dividing the second pixel points included in the pixel matrix unit into different quadrants, a dither submatrix having the same quadrant as the second pixel point is selected from multiple dither submatrices, thereby conveniently determining a target dither submatrix for the second pixel point.
[0047] Furthermore, for any first pixel point, when processing the second pixel point obtained by expanding the first pixel point (that is, the second pixel point included in the pixel matrix unit corresponding to the first pixel point), the position coordinates of the first pixel point are represented by (i, j), and the element in the i-th row and j-th column of the target jitter submatrix of the second pixel point can be selected as the target element corresponding to the second pixel point. Each second pixel point in the pixel matrix unit corresponding to the first pixel point is the element in the i-th row and j-th column of the target jitter submatrix of each second pixel point as the target element. In this way, for the pixel points expanded from the pixel point in the i-th row and j-th column (that is, all the second pixel points in the pixel matrix unit generated based on the pixel point in the i-th row and j-th column), the elements in the same rows and columns in the respective target jitter submatrices are used for comparison, that is, the values at the same coordinate position are selected as the target elements for comparison in the subsequent process. In this way, the regularity of the processing process can be ensured to a certain extent, and the problem of uncontrollable texture of the processed image can be avoided.
[0048] Among them, the elements in the dithering submatrix are the members of the dithering submatrix, and the element values of the elements in the dithering submatrix are the member values. It should be noted that, when the scale of the target dithering submatrix is smaller than the scale of the original scanned image, it may be that i is greater than the number of rows of the target dithering submatrix itself, and j is greater than the number of columns of the target dithering submatrix itself. Accordingly, when i is greater than the number of rows of the target dithering submatrix itself, a remainder operation is performed based on i and the number of rows of the target dithering submatrix itself, and the remainder is recorded as i'. When j is greater than the number of columns of the target dithering submatrix itself, a remainder operation is performed based on j and the number of columns of the target dithering submatrix itself, and the remainder is recorded as j'. If i is greater than the number of rows of the target dithering submatrix itself, and j is greater than the number of columns of the target dithering submatrix itself, the elements in the i'th row and j'th column of the target dithering submatrix are determined as the target elements of the second pixel point. If only i is greater than the number of rows of the target dithering submatrix itself, the elements in the i'th row and j'th column of the target dithering submatrix are determined as the target elements of the second pixel point. If only j is greater than the number of columns of the target dithering submatrix itself, the element in the i-th row and j'th column of the target dithering submatrix is determined as the target element of the second pixel. In this way, the target element is selected for each second pixel by taking the remainder. For example, Figure 4 is a schematic diagram of an original scanned image provided by an embodiment of the present invention, such as Figure 4 As shown, the original scanned image may be a matrix of size 8×8. Figure 5 is a schematic diagram of a dithering sub-matrix provided by an embodiment of the present invention, such as Figure 5 As shown, the number of rows and columns of the dithering sub-matrix itself is 4, and the number of rows and columns of the dithering sub-matrix is less than 8, that is, the scale of the target dithering sub-matrix is smaller than the scale of the original scanned image.
[0049] Furthermore, a binarization process may be performed based on the magnitude relationship between the element value of the target element and the pixel value of the second pixel point, wherein the binarization process refers to setting the pixel value of the second pixel point to 0 or 1.
[0050] In this embodiment of the present invention, a target dither submatrix is selected for each second pixel in the pixel matrix unit. An element whose position coordinates match the position coordinates of the first pixel is selected from the target dither submatrix for the second pixel as the target element. Finally, binarization is performed based on the element value of the target element and the pixel value of the second pixel. By using the target dither submatrix, the resulting bitmap pixel unit appears smoother and more natural, thereby ensuring the visual quality of the resulting printable image.
[0051] Optionally, in the embodiment of the present invention, the target jitter matrix may be set by the following steps: Step S21: Generate an original dither matrix of a specified size, and adjust the element value of each element in the original dither matrix according to a preset discarding precision.
[0052] Step S22: Divide the adjusted original dither matrix into multiple dither sub-matrices as the target dither matrix.
[0053] In an embodiment of the present invention, an original dither matrix of a specified size can be generated based on a preset initial value matrix and a preset matrix recursion algorithm. The original dither matrix can be an ordered dither matrix. The dither matrix (DitherMatrix) can be used as a template for image processing. The dither matrix produces corresponding changes through a specific algorithm according to the grayscale values of the pixels in the processed image, thereby improving the image quality or achieving a specific visual effect. The ordered dither matrix is widely used in the products of major printer manufacturers because it can produce good image effects and efficient processing speed. The ordered dither matrix can be divided into two types: dispersed and aggregated. The preset initial value matrix and the matrix recursion algorithm can be used to generate a dispersed ordered dither matrix.
[0054] For example, the initial value matrix may be a 2×2 matrix, denoted by M1, and M1 may be:
[0055] The matrix recursion algorithm can be expressed as: Mn+1=
[0056] Among them, the value of Un is 1, and the initial value matrix can be input into the matrix recursion formula to obtain ordered dither matrices of different sizes through iteration. An ordered dither matrix of corresponding size can be generated according to the preset specified size as the original dither matrix. Among them, the specified size can be pre-set by the developer. For example, the processing speed and processing quality when processing with dither matrices of different sizes can be pre-tested, and the specified size can be selected based on the processing speed and processing quality. Among them, the processing quality can be used to characterize the loss of image details. The more image details are lost, the worse the processing quality. The size in which the processing quality and processing speed are both within an acceptable range can be selected as the specified size to balance the algorithm speed and image detail loss.
[0057] Exemplarily, the specified size can be 8×8. Accordingly, M1 can be first used as the input of the matrix recursion formula to obtain M2. Then M2 can be used as the input of the matrix recursion formula to obtain M3. M3 is the original 8×8 dither matrix. Since the size of the initial value matrix is 2×2, that is, the matrix order of the generating formula of the original dither matrix is 2, and the original dither matrix is generated by superimposing and applying the initial value matrix. Therefore, the matrix order of the generated original dither matrix is a power of 2, that is, 2, 4, 8, 16, 32... By completely superimposing and applying the generating formula, the integrity of the original dither matrix finally generated can be ensured, thereby ensuring the subsequent processing effect. Accordingly, the embodiment of the present invention can be applied to the expansion scenario of m=n=2. In this way, the expanded size is more in line with the characteristics of the dither matrix itself, thereby ensuring the processing effect of halftone processing using the dither matrix. Of course, in actual application scenarios, only part of the generation formula can be used, for example, half of the generation formula can be used to generate an original dither matrix of 2s times the size, where s is a positive integer. This is not limited in the embodiment of the present invention.
[0058] It should be noted that the element values in the calculated original dither matrix can also be adjusted to improve the processing effect of the dither matrix on the image. For example, since there is a maximum value point in the original dither matrix, the maximum value point is 255. In this way, when the pixel point with a pixel value of 255 (that is, a white point) is binarized, the pixel value of the pixel point will be set to 0, that is, it will become a black point. Therefore, the maximum value point in the original dither matrix can be lowered, for example, 255 can be modified to 248 to avoid abnormal black points. Furthermore, for the minimum value point 0 in the original dither matrix, the minimum value point can be raised, for example, the minimum value point can be modified to 1 to avoid abnormal white points.
[0059] Furthermore, the dither sub-matrix can be pre-divided, rotated, mirror-flipped and weighted averaged to obtain a processed dither sub-matrix. Among them, segmentation can increase the texture irregularity of the final bitmap. Rotation and mirror flipping can make the dither sub-matrix make more image distinctions in similar grayscales. Mirror flipping processing can be to swap the dither sub-matrix front to back or up and down. Rotation processing refers to rotating the dither sub-matrix 90, 180 or 270 degrees. Weighted average processing is generally used in areas with large color differences. For example, the variance of the color value or element value and the surrounding element values can be used as a weight to perform weighted average processing on the image edge. Then, the processing effect of the processed dither sub-matrix is tested, for example, the rationality of the numerical value in the bitmap generated by using the processed dither sub-matrix is detected. If the processing effect of the processed dither sub-matrix is better, the processed dither sub-matrix is set for the all-in-one machine.
[0060] Furthermore, the preset discarding precision can be a preset number of discarding bits, and the specific value of the preset discarding precision can be predefined by the developer. The range of the element value in the generated original dither matrix is 0~255 (ie, 2 8 ), that is, the element value of a single point occupies eight bits of memory, which is an eight-bit binary number. The eight-bit binary number directly corresponds to the element value. Therefore, the data weight decreases from high to low. Accordingly, in scenarios where detail requirements are not high, some low bits can be regarded as noise. For example, the lower 2 bits can be regarded as noise, and the preset discarding precision is set to 2. The higher the preset discarding precision, the higher the degree of detail loss. When the preset discarding precision is 0, it means no discarding. By adjusting according to the preset discarding precision, the value range of the element value in the original jitter matrix can be changed. Let x represent the number of discarded bits, so the range of the element value in the original jitter matrix is adjusted to 0~2 8-x Specifically, for any element value in the original jitter matrix, the element value can be adjusted to: element value / 2 x .
[0061] Furthermore, the center of the adjusted original dither matrix can be used as the coordinate origin to establish a two-dimensional coordinate system. For any quadrant in the two-dimensional coordinate system, the portion of the original dither matrix located in that quadrant is determined as the dither sub-matrix corresponding to that quadrant. The method of establishing a two-dimensional coordinate system for the original dither matrix is consistent with the method of establishing a two-dimensional coordinate system for the pixel matrix unit described above. For example, Figure 6 This is another division diagram provided by an embodiment of the present invention, such as Figure 6 As shown in FIG, for the original dither matrix of 8×8, it can be divided into 4 dither sub-matrices as the target dither matrix. In the embodiment of the present invention, the original dither matrix is divided from the center into 4 parts corresponding to 4 quadrants. This division method is more in line with the recursive relationship of the matrix recursion algorithm. Alternatively, in another implementation method, the original dither matrix can be divided into 4 parts according to Figure 2 In the manner shown, the matrix is divided into m dithering sub-matrix rows and n dithering sub-matrix columns.
[0062] In an embodiment of the present invention, the element value of each element in the original jitter matrix is adjusted according to a preset discarding precision, which can reduce the number of bits of the element value in the target jitter matrix finally generated, reduce the overall storage size occupied by the target jitter matrix and the traversal overhead of the target jitter matrix, thereby reducing the amount of calculation when continuing to use the target jitter matrix and improving subsequent processing efficiency.
[0063] Optionally, in the embodiment of the present invention, the step of binarizing the pixel value of the second pixel based on the element value of the target element and the pixel value of the second pixel may specifically include: Step 1033a: Determine the restoration coefficient according to the discard accuracy of the element values in the target dither sub-matrix.
[0064] Step 1033b: Generate a restored element value based on the restoration coefficient and the element value of the target element.
[0065] Step 1033c: When the pixel value of the second pixel point is greater than the restored element value, set the pixel value of the second pixel point to 1.
[0066] Step 1033d: If the pixel value of the second pixel point is not greater than the restored element value, set the pixel value of the second pixel point to 0.
[0067] In the embodiment of the present invention, the discarding precision of the element value in the target jitter sub-matrix is the above-mentioned preset discarding precision, and the restored element value can be regarded as the original value without discarding precision. Specifically, when the preset discarding precision is not 0, 2 x As the recovery coefficient, the product of the recovery coefficient and the element value of the target element is calculated as the recovered element value. When the preset discarding precision is 0, 1 can be used as the recovery coefficient, that is, when the preset discarding precision is 0, the element value of the target element is directly used as the recovered element value.
[0068] Exemplarily, taking x=2 as an example, for the second pixel point in the second quadrant obtained by expanding the first pixel point in the first row and first column, the restored element value can be obtained by multiplying the element value of the first row and first column in the dithering submatrix corresponding to the second quadrant by 4. Compare the pixel value of the second pixel point with the restored element value. If the pixel value of the second pixel point is greater than the restored element value, the pixel value of the second pixel point is set to 1. Otherwise, the pixel value of the second pixel point is set to 0. Through the target dithering matrix, the first pixel point in the original scanned image is traversed to finally obtain a printable image. With m=n=2, the size of the original scanned image is 8×8, Figure 7 is a schematic diagram of a printable image provided by an embodiment of the present invention, such as Figure 7 As shown in the figure, after traversing the first pixel in the original scanned image, a bitmap with a size of 16×16 is finally obtained. It should be noted that Figures 2 to 7 The size of the box containing each pixel in the matrix shown in FIG is only a schematic illustration and does not represent the actual size of a single pixel.
[0069] In this embodiment of the present invention, a restoration coefficient is first determined based on the discard accuracy of element values in the target dither submatrix. A restored element value is generated based on the restoration coefficient and the element value of the target element. Then, based on the magnitude relationship between the pixel value of the second pixel and the restored element value of the target element, the pixel value of the second pixel is binarized, thereby ensuring the accuracy of the binarization process.
[0070] In the prior art, the scanned image is first converted into an enlarged scanned image with m times the original number of rows and n times the original number of columns through image magnification technology. Image magnification technology refers to the process of converting a low-resolution image into a high-resolution image, aiming to maintain or enhance the visual effect of the image. Image magnification technology is essentially the process of interpolating an image, that is, increasing the size of the image by interpolating pixels at sub-pixel positions without changing the pixel values of the original image. Specifically, in the prior art, image magnification is often performed using a bilinear interpolation algorithm. Among them, the linear interpolation method assumes that the change and development of the phenomenon is linear and uniform, so linear interpolation can be performed using a two-point straight line equation. The interpolation function of linear interpolation is a linear polynomial interpolation method. The interpolation error of linear interpolation at the interpolation node is zero. In this algorithm, the value of an unknown quantity between two known quantities is determined by connecting a straight line between the two known quantities. Bilinear interpolation is a method of extending this interpolation method to two-dimensional cases. By using the grayscale values of known adjacent pixels to generate the grayscale values of unknown pixels, an image with higher resolution can be regenerated from the original image.
[0071] Since the interpolation algorithm needs to traverse the pixels of the entire image to perform floating-point operations, the processing efficiency is low, the amount of calculation is large, and the computational overhead is high. When the number of rows / columns of the image is not an integer multiple, for example, when the number of rows is an odd number, there will be a problem that there are no pixels that can be calculated with the pixels in the last row. Therefore, the last row or column generated is not the correct original data and there are boundary problems. In addition, the interpolation algorithm includes the algorithm requirement for image reduction, which will not be used in the copying scenario, but it will increase the processing resources required for the algorithm operation, thus causing the problem of wasting processing resources.
[0072] Moreover, in the prior art, halftone processing can only be performed after image enlargement is completed. That is, a single algorithm only solves a single function. Only after the linear interpolation algorithm is used to achieve image enlargement can the halftone processing algorithm be used to convert the enlarged scanned image into a printable image. Since there is also overhead in data exchange between algorithms, the overall computational overhead of the prior art is large, the computation takes a long time, and the scanned image sorting and processing speed is slow. For example, assuming that the required target size is 16×16, for an 8×8 original scanned image, the prior art needs to first expand the 8×8 original scanned image to a 16×16 scanned image through linear interpolation. Then, using a dither matrix of the same size as the target size, the 16×16 dither matrix is directly overlaid on the 16×16 scanned image, and the pixel points with a value greater than the dither matrix element value at the corresponding position are set to 1, and vice versa.
[0073] The image processing method provided in the embodiments of the present invention can be implemented as an algorithm. Accordingly, this image processing algorithm processes the original scanned image, ultimately producing an enlarged, halftoned, printable image. This eliminates the need for data exchange between different algorithms, reduces data handling, and shortens the computational data flow. Furthermore, it simplifies the image processing steps, lowers overall computational overhead and time, and thus improves the speed of scanning image processing. This image processing algorithm is a printing algorithm for an all-in-one printer.
[0074] In this embodiment of the present invention, expansion is achieved by creating multiple copies of a single pixel in the original scanned image. All expanded points are derived from the original scanned image. This avoids boundary issues and, since linear interpolation algorithms are not required, avoids a host of other issues associated with image magnification using linear interpolation algorithms. Furthermore, using a dither submatrix to process the pixel matrix units expanded from a single pixel avoids the limitation of using a dither matrix of the same size as the target, resulting in a more flexible solution.
[0075] Reference Figure 8 , which shows a block diagram of an image processing device provided by an embodiment of the present invention, such as Figure 8 As shown, the image processing device may specifically include: The acquisition module 201 is configured to acquire a target dither matrix preset for the original scanned image.
[0076] The generation module 202 is used to set the pixel values of each pixel point in a pixel matrix of size m×n to the pixel value of any first pixel point in the original scanned image, thereby obtaining a pixel matrix unit; the m and n are respectively a preset row magnification factor and a preset column magnification factor.
[0077] The first processing module 203 is configured to perform halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point.
[0078] The second processing module 204 is configured to compose a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all first pixels in the original scanned image.
[0079] Optionally, the target jitter matrix includes a plurality of jitter sub-matrices obtained by pre-division, and there is no overlapping portion between different jitter sub-matrices; the first processing module 203 is specifically configured to: Selecting a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the multiple dithering sub-matrices; wherein the second pixel point is any pixel point in the pixel matrix unit; For any second pixel point, selecting an element whose position coordinates match the position coordinates of the first pixel point from the target dithering sub-matrix of the second pixel point as a target element; Based on the element value of the target element and the pixel value of the second pixel, the pixel value of the second pixel is binarized.
[0080] Optionally, the number of the multiple dithering sub-matrices is the same as the number of second pixel points in the pixel matrix unit; The first processing module 203 is further configured to: For any second pixel point, selecting a target dithering sub-matrix for the second pixel point from the multiple dithering sub-matrices according to the position information of the second pixel point; Among them, the target dithering sub-matrices of different second pixel points are different.
[0081] Optionally, the pixel matrix unit is a homogeneous matrix with a matrix order of 2, the position information of the second pixel point is used to represent the quadrant in which the second pixel point is located, and the multiple dithering sub-matrices include dithering sub-matrices corresponding to different quadrants; The first processing module 203 is further configured to: Dividing the second pixel points included in the pixel matrix unit into different quadrants respectively; A dithering sub-matrix having the same quadrant as the second pixel point is selected from the multiple dithering sub-matrices as the target dithering sub-matrix for the second pixel point.
[0082] Optionally, the position information of the second pixel point includes a row identifier of a row and a column identifier of a column in which the second pixel point is located in the pixel matrix unit; The first processing module 203 is further configured to: For any dithering sub-matrix among the multiple dithering sub-matrices, if the row identifier of the row and the column identifier of the column in which the dithering sub-matrix is located in the target dithering matrix are the same as the row identifier and the column identifier included in the position information of the second pixel point, then the dithering sub-matrix is determined as the target dithering sub-matrix of the second pixel point.
[0083] Optionally, the first processing module 203 is further configured to: Determining a restoration coefficient according to a discarding accuracy of element values in the target jitter submatrix; generating a restored element value based on the restoration coefficient and the element value of the target element; When the pixel value of the second pixel point is greater than the restored element value, setting the pixel value of the second pixel point to 1; When the pixel value of the second pixel point is not greater than the restored element value, the pixel value of the second pixel point is set to 0.
[0084] Optionally, the target jitter matrix is set by the following modules: a third processing module, configured to generate an original dither matrix of a specified size, and adjust the element value of each element in the original dither matrix according to a preset discarding precision; The division module is used to divide the adjusted original dither matrix into multiple dither sub-matrices as the target dither matrix.
[0085] In summary, in the image processing device provided by the embodiment of the present invention, a target dither matrix pre-set for the original scanned image is obtained. For any first pixel point in the original scanned image, the pixel values of each pixel point in the pixel matrix of size m×n are set to the pixel value of the first pixel point to obtain a pixel matrix unit; m and n are respectively the preset row magnification and the preset column magnification. Based on the target dithering matrix, the pixel matrix unit is halftoned to obtain a bitmap matrix unit corresponding to the first pixel point. Based on the bitmap matrix units corresponding to all the first pixel points in the original scanned image, a printable image corresponding to the original scanned image is composed. In this way, the pixel matrix unit expanded from each pixel point in the original scanned image is directly used as the processing granularity, and the pixel matrix unit is halftoned to obtain a bitmap matrix unit. Finally, a printable image can be composed based on all the bitmap matrix units. Since there is no need to use an image magnification algorithm to generate an enlarged scanned image first, the computational overhead can be reduced and the processing speed can be improved.
[0086] Reference Figure 9 Schematic diagram of the structure of the electronic device provided by the embodiment of the present invention. Figure 9 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus.
[0087] The processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, which enables the processor to execute the image processing method of the above embodiment. The executable instruction can form a program.
[0088] An embodiment of the present invention provides a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to perform the image processing method of the aforementioned embodiment. The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0089] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0090] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0091] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0094] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0095] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0096] Moreover, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or terminal device that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not preclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0097] The above describes in detail an image processing method, an image processing device, an electronic device, and one or more readable media provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.
Claims
1. An image processing method, characterized in that: The method comprises: Get the target dither matrix pre-set for the original scanned image; For any first pixel point in the original scanned image, the pixel values of each pixel point in an m×n pixel matrix are set to the pixel value of the first pixel point, to obtain a pixel matrix unit; m and n are respectively a preset row magnification factor and a preset column magnification factor; Performing halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point; Based on the bitmap matrix units respectively corresponding to all first pixels in the original scanned image, a printable image corresponding to the original scanned image is composed.
2. The method according to claim 1, characterized in that The target dither matrix includes a plurality of dither sub-matrices obtained by pre-division, and there is no overlapping portion between different dither sub-matrices; and performing halftone processing on the pixel matrix unit based on the target dither matrix includes: Selecting a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the multiple dithering sub-matrices; wherein the second pixel point is any pixel point in the pixel matrix unit; For any second pixel point, selecting an element whose position coordinates match the position coordinates of the first pixel point from the target dithering sub-matrix of the second pixel point as a target element; Based on the element value of the target element and the pixel value of the second pixel, the pixel value of the second pixel is binarized.
3. The method according to claim 2, characterized in that The number of the multiple dithering sub-matrices is the same as the number of second pixel points in the pixel matrix unit; The selecting a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the multiple dithering sub-matrices includes: For any second pixel point, selecting a target dithering sub-matrix for the second pixel point from the multiple dithering sub-matrices according to the position information of the second pixel point; Among them, the target dithering sub-matrices of different second pixel points are different.
4. The method according to claim 3, characterized in that The pixel matrix unit is a homogeneous matrix with a matrix order of 2, the position information of the second pixel point is used to represent the quadrant in which the second pixel point is located, and the multiple dithering sub-matrices include dithering sub-matrices corresponding to different quadrants; The selecting a target dithering sub-matrix for the second pixel from the multiple dithering sub-matrices according to the position information of the second pixel includes: Dividing the second pixel points included in the pixel matrix unit into different quadrants respectively; A dithering sub-matrix having the same quadrant as the second pixel point is selected from the multiple dithering sub-matrices as the target dithering sub-matrix for the second pixel point.
5. The method according to claim 3, characterized in that The position information of the second pixel point includes a row identifier of a row and a column identifier of a column in which the second pixel point is located in the pixel matrix unit; The selecting a target dithering sub-matrix for the second pixel from the multiple dithering sub-matrices according to the position information of the second pixel includes: For any dithering sub-matrix among the multiple dithering sub-matrices, if the row identifier of the row and the column identifier of the column in which the dithering sub-matrix is located in the target dithering matrix are the same as the row identifier and the column identifier included in the position information of the second pixel point, then the dithering sub-matrix is determined as the target dithering sub-matrix of the second pixel point.
6. The method according to claim 2, characterized in that The binarizing the pixel value of the second pixel based on the element value of the target element and the pixel value of the second pixel includes: Determining a restoration coefficient according to a discarding accuracy of element values in the target jitter submatrix; generating a restored element value based on the restoration coefficient and the element value of the target element; When the pixel value of the second pixel point is greater than the restored element value, setting the pixel value of the second pixel point to 1; When the pixel value of the second pixel point is not greater than the restored element value, the pixel value of the second pixel point is set to 0.
7. The method according to any one of claims 1 to 6, characterized in that: The target jitter matrix is set as follows: Generate an original dither matrix of a specified size, and adjust the element value of each element in the original dither matrix according to a preset discarding precision; The adjusted original dither matrix is divided into a plurality of dither sub-matrices as the target dither matrix.
8. An image processing device, characterized in that: The device comprises: An acquisition module, used for acquiring a target dither matrix preset for an original scanned image; a generating module configured to, for any first pixel point in the original scanned image, set the pixel value of each pixel point in an m×n pixel matrix to the pixel value of the first pixel point, thereby obtaining a pixel matrix unit; wherein m and n are respectively a preset row magnification factor and a preset column magnification factor; A first processing module is configured to perform halftone processing on the pixel matrix unit based on the target dither matrix to obtain a bitmap matrix unit corresponding to the first pixel point; The second processing module is configured to compose a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all first pixels in the original scanned image.
9. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to execute the method according to any one of claims 1 to 7.
10. One or more machine-readable media, characterized in that Instructions are stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image resolution expansion processing method and device and control terminal
CN113724138A
Pixel enhancement method and device based on interpolation technology, and computer equipment
CN118279132A
Image processing method and device, printing equipment and computer readable storage medium
CN118317036A
Image processing method and device and storage medium
CN120020858A
Half-tone processing method
US5973794A