Image processing methods, apparatus, electronic devices and readable media
By using a target dithering matrix to perform halftone processing on the original scanned image to generate a printable image, the problems of high computational overhead and slow processing speed in the prior art are solved, and more efficient image processing is achieved.
Patent Information
- Application Number
- CN202511247672.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-02
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-09-02
AI Technical Summary
In existing technologies, the photocopying process requires linear interpolation of the original scanned image using an image magnification algorithm, resulting in high computational overhead and slow processing speed.
The original scanned image is halftone processed using a target dithering matrix. By generating a pixel matrix unit for each pixel and performing halftone processing based on the dithering matrix, a printable image is directly generated, avoiding the use of image magnification algorithms.
It reduces computational overhead, increases processing speed, and ensures efficient image processing.
Smart Images

Figure CN120751070B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image technology, and in particular to an image processing method, apparatus, electronic device, and readable medium. Background Technology
[0002] In the current copying process, after the document to be copied is scanned by the scanning component, the original scanned image needs to be converted into a larger printable image before being sent to the printing component for processing.
[0003] In existing technologies, the original scanned image needs to be linearly interpolated using an image magnification algorithm to enlarge the number of rows and columns of the original scanned image to the corresponding row magnification and column magnification factors, thus obtaining an enlarged scanned image. Then, the enlarged scanned image is converted into a bitmap to obtain a printable image. Therefore, the computational overhead is large and the processing speed is slow. Summary of the Invention
[0004] The present invention provides an image processing method, apparatus, electronic device, and readable medium, which can solve the problems of high computational overhead and slow processing speed.
[0005] To address the above problems, this invention discloses an image processing method, the method comprising:
[0006] Obtain the target jitter matrix pre-set for the original scanned image;
[0007] For any first pixel in the original scanned image, the pixel value of each pixel in a pixel matrix of size m×n is set to the pixel value of the first pixel to obtain a pixel matrix unit; m and n are preset row magnification factor and preset column magnification factor, respectively.
[0008] Based on the target dithering matrix, the pixel matrix unit is half-toned to obtain the bitmap matrix unit corresponding to the first pixel.
[0009] Based on the bitmap matrix units corresponding to all the first pixels in the original scanned image, a printable image corresponding to the original scanned image is formed.
[0010] On the other hand, embodiments of the present invention disclose an image processing apparatus, the apparatus comprising:
[0011] The acquisition module is used to acquire the target jitter matrix that has been pre-set for the original scanned image;
[0012] The generation module is used to, for any first pixel in the original scanned image, set the pixel value of each pixel in a pixel matrix of size m×n to the pixel value of the first pixel to obtain a pixel matrix unit; where m and n are preset row magnification factor and preset column magnification factor, respectively.
[0013] The first processing module is used to perform halftone processing on the pixel matrix unit based on the target dithering matrix to obtain the bitmap matrix unit corresponding to the first pixel.
[0014] The second processing module is used to assemble a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all the first pixels in the original scanned image.
[0015] In another aspect, embodiments of the present invention disclose an electronic device, including: 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, the executable instruction causing the processor to execute the aforementioned method.
[0016] This invention also discloses a machine-readable medium storing instructions that, when executed by one or more processors, cause the processors to perform the methods described above.
[0017] The embodiments of the present invention have the following advantages: The image processing method provided by the embodiments of the present invention obtains a target jitter matrix pre-set for the original scanned image. For any first pixel in the original scanned image, the pixel value of each pixel in a pixel matrix of size m×n is set to the pixel value of the first pixel to obtain a pixel matrix unit; m and n are preset row magnification factor and preset column magnification factor, respectively. Halftone processing is performed on the pixel matrix unit based on the target jitter matrix to obtain the bitmap matrix unit corresponding to the first pixel. Based on the bitmap matrix units corresponding to all the 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 to perform halftone processing on the pixel matrix unit to obtain the bitmap matrix unit. Finally, a printable image can be formed based on all the bitmap matrix units. Since it is not necessary to first use an image magnification algorithm to generate an enlarged scanned image, the computational overhead can be reduced and the processing speed can be improved. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of the steps of an image processing method provided in an embodiment of the present invention;
[0020] Figure 2 This is a schematic diagram of a division provided in an embodiment of the present invention;
[0021] Figure 3 This is another schematic diagram of the division provided in an embodiment of the present invention;
[0022] Figure 4 This is a schematic diagram of an original scanned image provided in an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram of a dithering submatrix provided in an embodiment of the present invention;
[0024] Figure 6 This is another schematic diagram of division provided by an embodiment of the present invention;
[0025] Figure 7 This is a schematic diagram of a printable image provided in an embodiment of the present invention;
[0026] Figure 8 This is a block diagram of an image processing apparatus provided in an embodiment of the present invention;
[0027] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] Figure 1 This is a flowchart of the steps of an image processing method provided in an embodiment of the present invention, as follows: Figure 1 As shown, the image processing method may include the following steps:
[0030] Step 101: Obtain the target jitter matrix that has been pre-set for the original scanned image.
[0031] Step 102: For any first pixel in the original scanned image, set the pixel value of each pixel in a pixel matrix of size m×n to the pixel value of the first pixel to obtain a pixel matrix unit; m and n are the preset row magnification factor and the preset column magnification factor, respectively.
[0032] Step 103: Perform halftone processing on the pixel matrix unit based on the target dithering matrix to obtain the bitmap matrix unit corresponding to the first pixel.
[0033] Step 104: Based on the bitmap matrix units corresponding to all the first pixels in the original scanned image, form a printable image corresponding to the original scanned image.
[0034] In this embodiment of the invention, the target jitter matrix is a jitter matrix used for halftone processing. The same target jitter matrix can be used when processing the original scanned image obtained from each scan by the scanning component. Specifically, a pre-set target jitter matrix can be loaded from a specified location to achieve the operation of obtaining the target jitter matrix pre-set for the original scanned image. The specified location can be a location pre-defined by the developer for storing the target jitter matrix.
[0035] The preset row magnification factor (i.e., m mentioned above) and the preset column magnification factor (i.e., n mentioned above) 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 this embodiment of the invention can be applied to an all-in-one printer, which has a copying function. Specifically, the all-in-one printer includes a scanning component and a printing component. In a copying scenario, the scanning component needs to scan the document to be copied, and after scanning, a scanned image is obtained. Then, the scanned image is processed to obtain a printable image that can be processed by the printing component. Next, the printable image is sent to the printing component for printing, thereby completing the entire copying process. In the copying process, if the speed of generating the printable image is slower than the printing speed, it will cause the printing component to wait, which will slow down the printing operation and affect the copying performance of the machine. Therefore, the scanning speed of the scanning component is often higher than the printing speed of the printing component. The printing component and the scanning component use dots per inch (DPI) to represent the printing speed / scanning speed. The DPI of a printing component is negatively correlated with printing speed, and the DPI of a scanning component is negatively correlated with scanning speed. Specifically, the DPI of a printing component describes printing resolution, which determines the sharpness and detail of the printed image; therefore, printing speed is closely related to printing resolution. Higher printing resolution requires the print head to place more ink dots per unit length to form an image, resulting in a slower printing speed. Therefore, DPI can be used to represent printing speed. Similarly, the DPI of a scanning component describes scanning resolution, which determines the sharpness and detail of the scanned image; therefore, scanning speed is closely related to scanning resolution. Higher scanning resolution requires the scanner to acquire more pixels per unit length to form a scanned image, resulting in a slower scanning speed. Therefore, DPI can be used to represent scanning speed.
[0036] In this embodiment of the invention, the DPI of the printing component and the DPI of the scanning component can be calculated as the row magnification factor and column magnification factor. Specifically, the DPI of the printing component follows the industry 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. Correspondingly, since the DPI of the scanning component is 300 DPI and the DPI of the printing component is 600 DPI, it is necessary to magnify 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, meaning that the final printable image is double the original scanned image in both horizontal and vertical dimensions. 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.
[0037] The first pixel refers to any pixel in the original scanned image, and its pixel value can be a grayscale value. During the conversion of 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 as the pixel matrix unit corresponding to that first pixel. Essentially, a pixel matrix unit is a matrix containing pixel values, with the number of rows and columns representing preset row and column magnification factors, respectively. Thus, the total size of the pixel matrix formed by all the pixel matrix units of the first pixels is the target size. Generating a pixel matrix unit for the first pixel is equivalent to expanding that first pixel. For any first pixel in the original scanned image, its pixel value can be read as the target pixel value. A pixel matrix of size m×n is generated, where this pixel matrix can be an empty matrix or a matrix of all zeros, and each element in this pixel matrix represents a pixel. Then, the element values of all elements in this pixel matrix are set to the target pixel value, thereby obtaining the pixel matrix unit corresponding to the first pixel.
[0038] In this embodiment of the invention, the position coordinates of the first pixel can be used as input parameters of a preset pixel value acquisition function, and then the output of the pixel value acquisition function can be used as the target pixel value. The position coordinates of the first pixel indicate its row and column in the original scanned image. For example, the pixel value acquisition function can be getpixel(z), where z represents the input parameter, and the position coordinates of the first pixel can be represented as (i, j). The original scanned image includes multiple pixel rows and multiple pixel columns. i can be the row identifier of the row in the original scanned image, and j can be the column identifier of the column in the original scanned image. The row identifier can be the row number, and the column identifier can be the column number.
[0039] Then, the parameters (m, n) representing the required matrix size and the target pixel value are used as input parameters to the pixel matrix creation function. By executing the pixel matrix creation function, an m×n pixel matrix is first generated, and then the pixel value of each pixel is set to the target pixel value. Finally, a pixel matrix of size m×n with all elements being the target pixel value is obtained. This matrix is the pixel matrix unit corresponding to the first pixel. For example, the matrix creation function can be the Eigen::Matrix function.
[0040] Assuming the pixel value of the first pixel in the i-th row and j-th column is 175, and m=n=2, the pixel values of the pixels in the generated pixel matrix unit can be:
[0041]
[0042] By generating pixel matrix units for the first pixel, it is equivalent to copying the first pixel m×n times. In this embodiment of the invention, by reading the pixel value of the first pixel as the target pixel value, a pixel matrix of size m×n with all elements being the target pixel value is generated, thus obtaining the pixel matrix units. This allows for convenient expansion of pixels.
[0043] Furthermore, the bitmap matrix unit corresponding to the first pixel is essentially a matrix including pixel values. Therefore, the size of the bitmap matrix unit is the same as the size of the pixel matrix unit corresponding to the first pixel. Correspondingly, the total size of the pixel matrix represented by all bitmap matrix units is also the target size. Therefore, based on the bitmap matrix units, a printable image required for the printing component can be constructed. The final printable image has m times the number of rows of the original scanned image, and n times the number of columns of the original scanned image. For example, taking a scanning component with a DPI of 300 as an example, assuming the width of the original scanned image is W and the height is H, then the final generated printable image will have n × W × 300 columns and m × H × 300 rows.
[0044] Since the scanned image obtained by the scanning component is a grayscale image, while the printing component processes the bitmap, the scanned image can be an eight-bit deep grayscale image, where the pixel value of each pixel occupies eight bits of memory, and the pixel value ranges from 0 to 255. The printable image is a bitmap, where the pixel value of each pixel occupies one bit of memory, and the pixel value can be either 0 or 1. Therefore, halftone processing can be performed on the pixel matrix units to obtain bitmap matrix units. Each bitmap matrix unit can represent a portion of the bitmap. Halftone processing can simulate the visual effect of continuous-tone images. It allows quantizing a continuous-tone image into an image with only a few colors using a limited number of colors, resulting in a visual effect similar to the original image at a certain distance. In this embodiment, halftone processing makes the pixel value of each pixel in the pixel matrix unit either 0 or 1, thus obtaining the bitmap matrix unit. In other words, the final printable image has pixel values of 0 or 1, meaning only black and white are present.
[0045] After obtaining the bitmap matrix units corresponding to all first pixels, the bitmap matrix units corresponding to all first pixels can be placed in their respective positions according to the position of each first pixel, 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 in the i-th row and j-th column, the bitmap matrix unit corresponding to that first pixel is placed in the i-th row and j-th column position. Here, i and j are integers, i∈[1, a], j∈[1, b], and a and b are the number of rows and columns of the original scanned image, respectively. Taking a scanning component DPI of 300 as an example, the number of columns in the original scanned image is W×300, and the number of rows in the original scanned image is H×300.
[0046] In summary, the image processing method provided by this invention obtains a target jitter matrix pre-set for the original scanned image. For any first pixel in the original scanned image, the pixel value of each pixel in a pixel matrix of size m×n is set to the pixel value of the first pixel, resulting in a pixel matrix unit; m and n are preset row magnification and preset column magnification, respectively. Halftone processing is performed on the pixel matrix unit based on the target jitter matrix to obtain the 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 units expanded from each pixel in the original scanned image are directly used as the processing granularity to perform halftone processing on the pixel matrix units, resulting in bitmap matrix units. Finally, a printable image can be formed based on all bitmap matrix units. Since it is not necessary to first use an image magnification algorithm to generate an enlarged scanned image, computational overhead can be reduced and processing speed improved.
[0047] Optionally, in this embodiment of the invention, the target dithering matrix includes multiple pre-divided dithering sub-matrices, and there is no overlap between different dithering sub-matrices. The step of performing halftone processing on the pixel matrix units based on the target dithering matrix may specifically include:
[0048] Step 1031: Select a target dithering submatrix for each second pixel in the pixel matrix unit from the plurality of dithering submatrixes; wherein the second pixel is any pixel in the pixel matrix unit.
[0049] Step 1032: For any second pixel, select the element whose position coordinates match the position coordinates of the first pixel from the target jitter sub-matrix of the second pixel, and use it as the target element.
[0050] Step 1033: Based on the element value of the target element and the pixel value of the second pixel, perform binarization processing on the pixel value of the second pixel.
[0051] In this embodiment of the invention, the second pixel refers to any pixel included in the pixel matrix unit. For example, in the aforementioned pixel matrix unit, the four elements of the pixel matrix unit constitute four second pixels, each with a pixel value of 175. The target dithering matrix is divided into multiple parts, each representing a dithering submatrix. Based on the position of the dithering submatrix in the target dithering matrix and the position of the second pixel in the pixel matrix unit, a target dithering submatrix is selected for the second pixel.
[0052] Optionally, in this embodiment of the invention, the number of the plurality of dithering sub-matrices can be the same as the number of second pixels in the pixel matrix unit. The step of selecting a target dithering sub-matrice from the plurality of dithering sub-matrices for each second pixel in the pixel matrix unit can specifically include: step 1031a, for any second pixel, selecting a target dithering sub-matrice from the plurality of dithering sub-matrices according to the position information of the second pixel; wherein, the target dithering sub-matrices are different for different second pixels.
[0053] In this embodiment of the invention, the number of dithering sub-matrices can be m×n, such that the number of dithering sub-matrices is the same as the number of second pixels included in a single pixel matrix unit. This allows different target dithering sub-matrices to be selected for different second pixels, while also avoiding an excessive number of dithering sub-matrices that would lead to unnecessary resource waste. By setting the number of dithering sub-matrices for each second pixel and selecting different target dithering sub-matrices for different second pixels, the invention avoids the use of the same dithering sub-matrices in multiple second pixels derived from the same first pixel. This prevents unnatural image effects caused by repeated use of dithering matrices, thereby ensuring the effectiveness of subsequent image processing.
[0054] In one implementation, the position information of the second pixel includes the row identifier and column identifier of the second pixel in the pixel matrix unit. That is, the position information of the second pixel can represent the row and column of the second pixel in the pixel matrix unit. The position information of the dithering submatrix can represent the row and column of the dithering submatrix in the target dithering matrix. The position information of the dithering submatrix can include the row identifier and column identifier of the dithering submatrix in the target dithering matrix. Specifically, step 1031a can include: for any dithering submatrix among the plurality of dithering submatrixes, if the row identifier and column identifier of the dithering submatrix in the target dithering matrix are the same as the row identifier and column identifier included in the position information of the second pixel, then the dithering submatrix is determined as the target dithering submatrix of the second pixel.
[0055] Accordingly, when the number of jitter sub-matrices is the same as the number of second pixels in the pixel matrix unit, the target jitter matrix includes multiple rows and multiple columns of jitter sub-matrices. Using the jitter sub-matrices as the division granularity, the target jitter matrix includes m rows and n columns of jitter sub-matrices. The target jitter matrix is obtained by dividing the original jitter matrix. Figure 2 This is a schematic diagram of a division provided by an embodiment of the present invention, such as... Figure 2As shown, (A) represents the original jitter matrix before partitioning (specific element values are not shown in the figure), and (B) represents the target jitter matrix obtained after partitioning. At the jitter submatrix partitioning granularity, the target jitter matrix obtained after partitioning includes 4 rows and 4 columns, totaling 16 jitter submatrices. In (B), one square represents one jitter submatrix, and each jitter submatrix itself includes 16 elements. Figure 2 Not shown in the image.
[0056] Let (p, q) represent the position information of the second pixel, where p represents the row number of the second pixel in the pixel matrix unit, and q represents the column number of the second pixel in the pixel matrix unit. Then, the dithering submatrix of the p-th row and q-th column can be determined as the target dithering submatrix of the second pixel. Here, p and q are integers, p∈[1, m], q∈[1, n]. That is, in this embodiment of the invention, the dithering submatrix with the same position information as the second pixel can be used as the target dithering submatrix of the second pixel. In this implementation, the target dithering submatrix can be selected for the second pixel by comparing the row and column identifiers, which has high selection efficiency.
[0057] Of course, when the number of jitter sub-matrices is less than m×n, there may be cases where the value of p exceeds the number of rows in the target jitter matrix's jitter sub-matrices, and the value of q exceeds the number of columns in the target jitter matrix's jitter sub-matrices. Accordingly, if p exceeds the number of rows in the target jitter matrix's jitter sub-matrices, a modulo operation is performed based on p and the number of rows in the target jitter matrix's jitter sub-matrices; that is, the remainder when p is divided by the number of rows in the target jitter matrix's jitter sub-matrices is determined and recorded as p'. If q exceeds the number of columns in the target jitter matrix's jitter sub-matrices, a modulo operation is performed based on q and the number of columns in the target jitter matrix's jitter sub-matrices; that is, the remainder when q is divided by the number of columns in the target jitter matrix's jitter sub-matrices is determined and recorded as q'. If the value of p exceeds the number of rows in the target jitter matrix's jitter sub-matrices, and q exceeds the number of columns in the target jitter matrix's jitter sub-matrices, then the jitter sub-matrices in the p'th row and q'th column are determined as the target jitter sub-matrices for that second pixel. If only the value of p exceeds the number of rows in the jitter submatrix of the target jitter matrix, then the jitter submatrix in row p' and column q is determined as the target jitter submatrix for that second pixel. If only q exceeds the number of columns in the jitter submatrix of the target jitter matrix, then the jitter submatrix in row p and column q' is determined as the target jitter submatrix for that second pixel. In this way, the modulo operation ensures that a target jitter submatrix is selected for each second pixel.
[0058] In another implementation, the position information of the second pixel can represent the quadrant in which the second pixel is located. The position information of the dithering submatrix can represent the quadrant in which the dithering submatrix is located. Accordingly, for any second pixel, a dithering submatrix whose quadrant is consistent with that of the second pixel can be selected as the target dithering submatrix for that second pixel.
[0059] Optionally, in this embodiment of the invention, the pixel matrix unit is a matrix of the same type with a matrix order of 2, and the plurality of dithering sub-matrices include dithering sub-matrices corresponding to different quadrants. Here, a matrix of the same type refers to a matrix with the same number of rows and columns, and the matrix order represents the number of rows / columns of the matrix of the same type. A pixel matrix unit is a matrix of the same type with a matrix order of 2, indicating that a first pixel point is expanded into 4 points, that is, the pixel matrix unit is a 2×2 matrix. Further, the quadrant corresponding to the dithering sub-matrices is the quadrant in which the dithering sub-matrices are located. The plurality of dithering sub-matrices may include a dithering sub-matrice corresponding to the upper left quadrant (i.e., the second quadrant), a dithering sub-matrice corresponding to the upper right quadrant (i.e., the first quadrant), a dithering sub-matrice corresponding to the lower left quadrant (i.e., the third quadrant), and a dithering sub-matrice corresponding to the lower right quadrant (i.e., the fourth quadrant). This allows the division of the dithering sub-matrices to better suit the needs of the copying scenario.
[0060] The above-mentioned selection of a target dithering sub-matrix for the second pixel from the plurality of dithering sub-matrixes based on the position information of the second pixel may specifically include:
[0061] Step 1031a1: Divide the second pixel points included in the pixel matrix unit into different quadrants.
[0062] Step 1031a2: Select the jitter sub-matrix from the plurality of jitter sub-matrixes whose quadrant is the same as that of the second pixel point, and use it as the target jitter sub-matrix for the second pixel point.
[0063] In this embodiment of the invention, the pixel matrix unit includes four pixels located at different positions. Accordingly, the center of the pixel matrix unit can be used as the origin to establish a two-dimensional coordinate system. For example, an X-axis can be established along the horizontal direction, with the direction from left to right as the positive direction of the X-axis, and a Y-axis can be established along the vertical direction, with the direction from top to bottom as the positive direction of the Y-axis. Figure 3 This is another schematic diagram of the division provided by an embodiment of the present invention, such as... Figure 3 As shown, the four second pixels are assigned to the upper left quadrant, upper right quadrant, lower left quadrant, and lower right quadrant, respectively. Correspondingly, the position information of these four second pixels can be: upper left quadrant, upper right quadrant, lower left quadrant, and lower right quadrant, respectively. Alternatively, they can be set to: second quadrant, first quadrant, third quadrant, and fourth quadrant, respectively. Figure 3The example uses the case where all second pixels in the pixel matrix unit have a pixel value of 8.
[0064] It should be noted that when the number of second pixels in a pixel matrix unit exceeds four, the pixel matrix unit can be divided into coordinate systems multiple times until each quadrant contains only one second pixel. For example, assuming the pixel matrix unit is 16×16, starting from the top left corner of the pixel matrix unit, a 2×2 square matrix within the unit can be used as a dividing unit. The center of this dividing unit can be used as the origin to establish a two-dimensional coordinate system, thereby dividing the four second pixels in this square matrix into different quadrants. The next dividing unit is then divided in the same way until all second pixels in the pixel matrix unit have been divided.
[0065] Furthermore, the jitter sub-matrix corresponding to the upper left quadrant can be used as the target jitter sub-matrix for the second pixel in the upper left quadrant, the jitter sub-matrix corresponding to the upper right quadrant can be used as the target jitter sub-matrix for the second pixel in the upper right quadrant, the jitter sub-matrix corresponding to the lower left quadrant can be used as the target jitter sub-matrix for the second pixel in the lower left quadrant, and the jitter sub-matrix corresponding to the lower right quadrant can be used as the target jitter sub-matrix for the second pixel in the lower right quadrant. That is, in this embodiment of the invention, the original first pixel is equivalent to being regarded as four pixels with the same pixel value divided into four quadrants, each corresponding to a jitter sub-matrix in the aforementioned four quadrants.
[0066] In this embodiment of the invention, the target dithering submatrix for the second pixel is conveniently determined by dividing the second pixel into different quadrants and selecting the dithering submatrix whose quadrant is the same as that of the second pixel from among multiple dithering submatrixes.
[0067] Furthermore, for any first pixel, when processing the second pixel (i.e., the second pixel included in the pixel matrix unit corresponding to the first pixel) expanded from the first pixel, let (i, j) represent the position coordinates of the first pixel. The element in the i-th row and j-th column of the target jitter sub-matrix of the second pixel can be selected as the target element corresponding to the second pixel. Each second pixel in the pixel matrix unit corresponding to the first pixel is also an element in the i-th row and j-th column of its respective target jitter sub-matrix, serving as the target element. Thus, for the pixels expanded from the pixel in the i-th row and j-th column (i.e., all second pixels in the pixel matrix unit generated based on the pixel in the i-th row and j-th column), elements in the same row and column of their respective target jitter sub-matrix are compared, i.e., values at the same coordinate positions are selected as target elements for comparison in subsequent processes. This ensures the regularity of the processing to a certain extent and avoids the problem of uncontrollable image texture after processing.
[0068] In this context, the elements of the jitter submatrix are called members, and the element values are called member values. It should be noted that when the size of the target jitter submatrix is smaller than the size of the original scanned image, there may be cases where i is greater than the number of rows in the target jitter submatrix and j is greater than the number of columns. Accordingly, if i is greater than the number of rows, a modulo operation is performed based on i and the number of rows, and this remainder is denoted as i'. If j is greater than the number of columns, a modulo operation is performed based on j and the number of columns, and this remainder is denoted as j'. If i is greater than the number of rows and j is greater than the number of columns, then the element in the i'th row and j'th column of the target jitter submatrix is determined as the target element of the second pixel. If only i is greater than the number of rows, then the element in the i'th row and j'th column of the target jitter submatrix is determined as the target element of the second pixel. If only j is greater than the number of columns in the target dithering submatrix, then the element in the i-th row and j'-th column of the target dithering submatrix is determined as the target element for that second pixel. In this way, the modulo operation ensures that a target element is selected for each second pixel. For example, Figure 4 This is a schematic diagram of an original scanned image provided in an embodiment of the present invention, such as... Figure 4 As shown, the original scanned image can be an 8×8 matrix. Figure 5 This is a schematic diagram of a dithering submatrix provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the number of rows and columns of the jitter submatrix itself is 4, and the number of rows and columns of the jitter submatrix is less than 8, that is, the size of the target jitter submatrix is smaller than the size of the original scanned image.
[0069] Furthermore, binarization can be performed based on the relationship between the element value of the target element and the pixel value of the second pixel. Binarization refers to setting the pixel value of the second pixel to either 0 or 1.
[0070] In this embodiment of the invention, a target dithering sub-matrix is selected for each second pixel in the pixel matrix unit. Elements whose position coordinates match those of the first pixel are selected from the target dithering sub-matrix of the second pixel as target elements. Finally, binarization is performed based on the element values of the target elements and the pixel values of the second pixels. Thus, by using the target dithering sub-matrix, the resulting bitmap pixel units are visually smoother and more natural, thereby ensuring the visual effect of the final printable image.
[0071] Optionally, the target jitter matrix in this embodiment of the invention can be set through the following steps:
[0072] Step S21: Generate an original jitter matrix of a specified size, and adjust the element values of each element in the original jitter matrix according to a preset discard precision.
[0073] Step S22: Divide the adjusted original jitter matrix into multiple jitter sub-matrices, which are used as the target jitter matrix.
[0074] In this embodiment of the invention, a raw dither matrix of a specified size can be generated based on a preset initial value matrix and a preset matrix recursion algorithm. The raw dither matrix can be an ordered dither matrix. The dither matrix can serve as a template for image processing. Based on the grayscale values of pixels in the processed image, the dither matrix generates corresponding changes through a specific algorithm, thereby improving image quality or achieving specific visual effects. Ordered dither matrices are widely used in products from major printer manufacturers due to their ability to produce good image effects and high processing speed. Ordered dither matrices can be divided into two types: dispersed and clustered. The preset initial value matrix and matrix recursion algorithm can be used to generate a dispersed ordered dither matrix.
[0075] For example, the initial value matrix can be a 2×2 matrix, denoted by M1, where M1 can be:
[0076]
[0077] The matrix recursion algorithm can be expressed as:
[0078] Mn+1=
[0079] Here, the value of Un is 1, allowing the initial value matrix to be input into the matrix recursion formula, iterating to obtain ordered dithering matrices of different sizes. An ordered dithering matrix of a corresponding size can be generated based on a preset specified size, serving as the original dithering matrix. This specified size can be pre-set by the developers; for example, the processing speed and quality when processing with dithering matrices of different sizes can be pre-tested, and the specified size can be selected based on these factors. Processing quality characterizes the loss of image detail; greater loss of image detail results in poorer processing quality. A size that balances both processing quality and speed can be selected as the specified size to balance algorithm speed and image detail loss.
[0080] For example, the specified size can be 8×8. Accordingly, M1 can be first used as input to the matrix recursion formula to obtain M2. Then, M2 can be used as input to the matrix recursion formula to obtain M3. M3 is the 8×8 original dithering matrix. Since the initial value matrix is 2×2, the order of the generator formula for the original dithering matrix is 2, and the original dithering matrix is generated by superimposing the initial value matrix. Therefore, the order of the generated original dithering matrix is a power of 2, i.e., 2, 4, 8, 16, 32… By completely superimposing the generator formula, the integrity of the final generated original dithering matrix can be ensured, thereby ensuring the subsequent processing effect. Accordingly, this embodiment of the invention can be applied to extended scenarios where m=n=powers of 2. In this way, the extended size is more in line with the characteristics of the dithering matrix itself, thereby ensuring the processing effect of halftone processing using the dithering matrix. Of course, in practical applications, only the generative part can be used. For example, half of the generative can be used to generate an original jitter matrix of size 2 times s, where s is a positive integer. This embodiment of the invention does not limit this.
[0081] It should be noted that the element values in the calculated original dithering matrix can be adjusted to improve its image processing effect. For example, since the original dithering matrix contains a maximum value of 255, binarizing a pixel with a value of 255 (i.e., a white pixel) would result in its value being set to 0, effectively turning it into a black pixel. Therefore, the maximum value in the original dithering matrix can be lowered, for example, by changing 255 to 248, to avoid abnormal black pixels. Furthermore, the minimum value of 0 in the original dithering matrix can be increased, for example, by changing it to 1, to avoid abnormal white pixels.
[0082] Furthermore, the dithering submatrix can be pre-processed by segmentation, rotation, mirroring, and weighted averaging to obtain a processed dithering submatrix. Segmentation improves the texture irregularity of the final bitmap. Rotation and mirroring allow the dithering submatrix to make more distinctions among similar gray levels. Mirroring involves swapping the dithering submatrix front-to-back or top-to-bottom, while rotation involves rotating it by 90, 180, or 270 degrees. Weighted averaging is generally used in areas with large color differences; for example, the variance of color values or element values compared to surrounding element values can be used as weights to perform weighted averaging on image edges. Then, the processing effect of the processed dithering submatrix is tested, for example, to check the reasonableness of the values in the bitmap generated using the processed dithering submatrix. If the processed dithering submatrix shows better performance, it is then set for the all-in-one device.
[0083] Furthermore, the preset truncation precision can be a pre-set number of bits to discard, and the specific value of the preset truncation precision can be predefined by the developers. The range of element values in the generated original jitter matrix is 0~255 (i.e., 2^35). 8 This means that the element value of a single point occupies eight bits of memory, which is an eight-bit binary number. This eight-bit binary number directly corresponds to the element value. Therefore, the data weight decreases sequentially from high to low. Correspondingly, in scenarios where detail requirements are not high, some low bits can be considered as noise. For example, the lower 2 bits can be considered as noise, and the preset truncation precision is set to 2. The higher the preset truncation precision, the greater the degree of detail loss. A preset truncation precision of 0 indicates that no truncation is performed. Adjusting the preset truncation precision can change the value range of the elements in the original jitter matrix. Let x represent the number of bits to truncate, then by adjusting the value range of the elements in the original jitter matrix, the range is 0~2. 8-x Specifically, for any element value in the generated original jitter matrix, that element value can be adjusted to: element value / 2. x .
[0084] Furthermore, the center of the adjusted original dither matrix can be used as the 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 submatrix corresponding to that quadrant. The method for establishing the two-dimensional coordinate system for the original dither matrix is consistent with the aforementioned method for establishing the two-dimensional coordinate system for the pixel matrix unit. For example, Figure 6 This is another schematic diagram of division provided by an embodiment of the present invention, such as... Figure 6 As shown, for an 8×8 original jitter matrix, it can be divided into four jitter sub-matrices as the target jitter matrix. In this embodiment of the invention, the original jitter matrix is divided into four parts corresponding to the four quadrants from the center. This division method is more in line with the recursive relationship of the matrix recursion algorithm. Alternatively, in another implementation, the original jitter matrix can be divided into... Figure 2 As shown, it is divided into m rows of dithering submatrixes and n columns of dithering submatrixes.
[0085] In this embodiment of the invention, adjusting the element values of each element in the original jitter matrix according to a preset discard precision can reduce the number of bits in the element values of the final generated target jitter matrix, 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 computation when continuing to use the target jitter matrix and improving the efficiency of subsequent processing.
[0086] Optionally, in this embodiment of the 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:
[0087] Step 1033a: Determine the recovery coefficient according to the discard precision of the element values in the target jitter submatrix.
[0088] Step 1033b: Based on the recovery coefficient and the element value of the target element, generate the recovered element value.
[0089] Step 1033c: If the pixel value of the second pixel is greater than the recovered element value, set the pixel value of the second pixel to 1.
[0090] Step 1033d: If the pixel value of the second pixel is not greater than the recovered element value, set the pixel value of the second pixel to 0.
[0091] In this embodiment of the invention, the discard precision of the element values in the target jitter sub-matrix is the aforementioned preset discard precision, and the recovered element values can be regarded as the original values without discard precision. Specifically, when the preset discard precision is not 0, 2 can be used as the original values without discard precision. x As the recovery coefficient, the product of the recovery coefficient and the element value of the target element is calculated, and this product is used as the recovered element value. If the preset discard precision is 0, 1 can be used as the recovery coefficient; that is, if the preset discard precision is 0, the element value of the target element is directly used as the recovered element value.
[0092] For example, taking x=2, for the second pixel in the second quadrant obtained by expanding the first pixel in the first row and first column, the element value in the first row and first column of the corresponding dithering submatrix in the second quadrant can be multiplied by 4 to obtain the recovered element value. The pixel value of the second pixel is compared with the recovered element value. If the pixel value of the second pixel is greater than the recovered element value, the pixel value of the second pixel is set to 1. Otherwise, the pixel value of the second pixel is set to 0. By traversing the first pixel in the original scanned image through the target dithering matrix, a printable image is finally obtained. With m=n=2, the size of the original scanned image is 8×8. Figure 7 This is a schematic diagram of a printable image provided in an embodiment of the present invention, such as... Figure 7 As shown, after traversing the first pixel of the original scanned image, a bitmap of size 16×16 is finally obtained. It should be noted that... Figures 2-7 The size of the bounding box containing each pixel in the matrix shown is for illustrative purposes only and does not represent the actual size of a single pixel.
[0093] In this embodiment of the invention, the restoration coefficient is first determined according to the discard precision of the element values in the target jitter sub-matrix. Based on the restoration coefficient and the element value of the target element, the restored element value is generated. Then, based on the 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, which ensures the accuracy of the binarization process.
[0094] In existing technologies, image magnification is used to transform a scanned image into an enlarged image with m times the original number of rows and n times the original number of columns. Image magnification refers to the process of converting a low-resolution image into a high-resolution image, aiming to maintain or improve the visual effect. Essentially, image magnification is an interpolation process; that is, without changing the original image's pixel values, it increases the image size by interpolating pixels at sub-pixel positions. Specifically, existing technologies often use bilinear interpolation algorithms for image magnification. Linear interpolation assumes that the changes in a phenomenon are linear and uniform, so it can use a two-point linear equation for linear interpolation. Linear interpolation uses a first-order polynomial interpolation function. The interpolation error at the interpolation nodes is zero. In this algorithm, the value of an unknown quantity is determined by connecting two known quantities with a straight line. Bilinear interpolation extends this interpolation method to two dimensions. It generates the gray value of the unknown pixel by using the gray values of known neighboring pixels, thereby reproducing an image with higher resolution from the original image.
[0095] Because interpolation algorithms require traversing all pixels of the entire image for floating-point operations, they are inefficient, computationally intensive, and computationally expensive. When the number of rows / columns in the image is not an integer multiple (e.g., when the number of rows is odd), the last row may lack pixels suitable for interpolation. This can result in the last row or column not being the correct original data, leading to boundary issues. Furthermore, interpolation algorithms include image downsizing, which is not used in copying scenarios but increases the processing resources required, thus wasting resources.
[0096] Furthermore, in existing technologies, halftone processing can only be performed after image magnification is completed. That is, a single algorithm only solves a single function; after image magnification is achieved using linear interpolation, a halftone processing algorithm can be used to convert the magnified scanned image into a printable image. Since data exchange between algorithms also incurs overhead, existing technologies have high overall computational overhead, long computation time, and slow scanned image processing speed. For example, assuming the required target size is 16×16, for an 8×8 original scanned image, existing technologies first need to expand the 8×8 original scanned image to a 16×16 scanned image using linear interpolation. Then, a dithering matrix of the same size as the target size is used to directly overlay the 16×16 dithering matrix onto the 16×16 scanned image, setting pixels with dithering matrix element values greater than the corresponding position to 1, and vice versa.
[0097] The image processing method provided in this embodiment of the invention can be implemented as an algorithm. Accordingly, this image processing algorithm processes the original scanned image to obtain a larger, halftone-processed printable image. This eliminates data exchange between different algorithms, reduces data transfer, and shortens the computational data flow. Simultaneously, it simplifies the image processing steps, reduces overall computational overhead and time, and thus improves the processing speed of scanned images. This image processing algorithm belongs to the printing algorithm used in all-in-one printers.
[0098] Furthermore, in this embodiment of the invention, expansion is achieved by copying a single pixel from the original scanned image multiple times, and all expanded points are derived from the original scanned image. Therefore, boundary issues are avoided, and since linear interpolation algorithms are not required, other problems caused by using linear interpolation algorithms for image magnification are avoided. Moreover, using a dithering submatrix to process the pixel matrix units expanded from a single pixel avoids the limitation of having to use a dithering matrix of the same size as the target, resulting in greater flexibility.
[0099] Reference Figure 8 The diagram shows a block diagram of an image processing apparatus provided by an embodiment of the present invention, such as... Figure 8 As shown, the image processing device may specifically include:
[0100] The acquisition module 201 is used to acquire the target jitter matrix that is pre-set for the original scanned image.
[0101] The generation module 202 is used to, for any first pixel in the original scanned image, set the pixel value of each pixel in a pixel matrix of size m×n to the pixel value of the first pixel to obtain a pixel matrix unit; where m and n are preset row magnification factor and preset column magnification factor, respectively.
[0102] The first processing module 203 is used to perform halftone processing on the pixel matrix unit based on the target dithering matrix to obtain the bitmap matrix unit corresponding to the first pixel.
[0103] The second processing module 204 is used to assemble a printable image corresponding to the original scanned image based on the bitmap matrix units corresponding to all the first pixels in the original scanned image.
[0104] Optionally, the target jitter matrix includes multiple pre-divided jitter sub-matrices, and there is no overlap between different jitter sub-matrices; the first processing module 203 is specifically used for:
[0105] From the plurality of dithering sub-matrices, a target dithering sub-matrix is selected for each second pixel in the pixel matrix unit; wherein, the second pixel is any pixel in the pixel matrix unit;
[0106] For any second pixel, select the element whose position coordinates match the position coordinates of the first pixel from the target jitter sub-matrix of the second pixel, and use it as the target element;
[0107] 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.
[0108] Optionally, the number of the plurality of dithering sub-matrices is the same as the number of second pixels in the pixel matrix unit;
[0109] The first processing module 203 is further used for:
[0110] For any second pixel, a target dithering submatrix is selected from the plurality of dithering submatrixes according to the position information of the second pixel;
[0111] The target jitter sub-matrix is different for different second pixels.
[0112] Optionally, the pixel matrix unit is a matrix of the same type with a matrix order of 2, the position information of the second pixel is used to characterize the quadrant in which the second pixel is located, and the plurality of dithering sub-matrices include dithering sub-matrices corresponding to different quadrants;
[0113] The first processing module 203 is further used for:
[0114] The second pixel points included in the pixel matrix unit are respectively divided into different quadrants;
[0115] Select the jitter submatrix that corresponds to the quadrant in which the second pixel is located from the plurality of jitter submatrixes, and use it as the target jitter submatrix for the second pixel.
[0116] Optionally, the position information of the second pixel includes the row identifier of the row in which the second pixel is located and the column identifier of the column in which it is located in the pixel matrix unit;
[0117] The first processing module 203 is further used for:
[0118] For any of the plurality of jitter sub-matrices, if the row identifier and column identifier of the jitter sub-matrice in the target jitter matrix are the same as the row identifier and column identifier included in the position information of the second pixel, then the jitter sub-matrice is determined as the target jitter sub-matrice of the second pixel.
[0119] Optionally, the first processing module 203 is further configured to:
[0120] The recovery coefficient is determined according to the discard precision of the element values in the target jitter submatrix;
[0121] Based on the recovery coefficient and the element value of the target element, the recovered element value is generated;
[0122] If the pixel value of the second pixel is greater than the recovered element value, the pixel value of the second pixel is set to 1;
[0123] If the pixel value of the second pixel is not greater than the recovered element value, the pixel value of the second pixel is set to 0.
[0124] Optionally, the target jitter matrix is set through the following module:
[0125] The third processing module is used to generate an original jitter matrix of a specified size and adjust the element values of each element in the original jitter matrix according to a preset discarding precision.
[0126] The partitioning module is used to divide the adjusted original jitter matrix into multiple jitter sub-matrices, which serve as the target jitter matrix.
[0127] In summary, the image processing apparatus provided in this embodiment of the invention obtains a target jitter matrix pre-set for the original scanned image. For any first pixel in the original scanned image, the pixel value of each pixel in a pixel matrix of size m×n is set to the pixel value of the first pixel, resulting in a pixel matrix unit; m and n are preset row magnification and preset column magnification, respectively. Halftone processing is performed on the pixel matrix unit based on the target jitter matrix to obtain the 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. Thus, by directly using the pixel matrix units expanded from each pixel in the original scanned image as the processing granularity, halftone processing is performed on the pixel matrix units to obtain bitmap matrix units. Finally, a printable image can be formed based on all bitmap matrix units. Since it is not necessary to first use an image magnification algorithm to generate an enlarged scanned image, computational overhead can be reduced and processing speed improved.
[0128] Reference Figure 9 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. For example... Figure 9 As shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus.
[0129] The processor, the memory, and the communication interface communicate with each other via the communication bus; the memory stores at least one executable instruction, which causes the processor to execute the image processing method of the aforementioned embodiment. The executable instructions can form a program.
[0130] This invention provides a machine-readable medium storing instructions that, when executed by one or more processors, enable the processors to perform the image processing method described in the foregoing embodiments.
[0131] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0132] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0133] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where the application is located, and with the authorization granted by the owner of the relevant device.
[0134] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0135] These computer program instructions may also be stored in a computer-readable storage medium capable of directing a computer or other programmable data processing terminal device to operate in a predictive manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0137] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.
[0138] Finally, it should be noted that in this paper, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0139] Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0140] The foregoing has provided a detailed description of an image processing method, an image processing apparatus, an electronic device, and one or more readable media provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. An image processing method, characterized by, The method comprises: obtaining a target dithering matrix preset for an original scan image; the target dithering matrix comprises a plurality of dithering sub-matrices obtained by pre-division, and there is no overlapping part between different dithering sub-matrices; for any first pixel point in the original scan image, setting pixel values of each pixel point in a pixel matrix with a size of m*n to be a pixel value of the first pixel point, to obtain a pixel matrix unit; the m and the n are respectively a preset row magnification and a preset column magnification; selecting a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the plurality of 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 with a position coordinate matching a position coordinate of the first pixel point from the target dithering sub-matrix of the second pixel point as a target element; based on an element value of the target element and a pixel value of the second pixel point, performing binaryzation processing on the pixel value of the second pixel point to obtain a bitmap matrix unit corresponding to the first pixel point; based on the bitmap matrix units corresponding to all first pixel points in the original scan image, forming a printable image corresponding to the original scan image.
2. The method of claim 1, wherein, The number of the plurality of dithering sub-matrices is the same as the number of the 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 plurality of dithering sub-matrices comprises: for any second pixel point, selecting a target dithering sub-matrix for the second pixel point from the plurality of dithering sub-matrices according to position information of the second pixel point; wherein the target dithering sub-matrices of different second pixel points are different.
3. The method of claim 2, wherein, 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 a quadrant in which the second pixel point is located, and the plurality of dithering sub-matrices comprise dithering sub-matrices corresponding to different quadrants; the selecting a target dithering sub-matrix for the second pixel point from the plurality of dithering sub-matrices according to the position information of the second pixel point comprises: dividing the second pixel points included in the pixel matrix unit into different quadrants respectively; selecting a dithering sub-matrix corresponding to a same quadrant as the quadrant in which the second pixel point is located from the plurality of dithering sub-matrices as the target dithering sub-matrix of the second pixel point.
4. The method of claim 2, wherein, The position information of the second pixel point comprises a row identifier of a row in which the second pixel point is located in the pixel matrix unit and a column identifier of a column in which the second pixel point is located; the selecting a target dithering sub-matrix for the second pixel point from the plurality of dithering sub-matrices according to the position information of the second pixel point comprises: for any dithering sub-matrix in the plurality of dithering sub-matrices, if a row identifier of a row in which the dithering sub-matrix is located in the target dithering matrix and a column identifier of a column in which the dithering sub-matrix is located are the same as the row identifier and the column identifier included in the position information of the second pixel point, the dithering sub-matrix is determined as the target dithering sub-matrix of the second pixel point.
5. The method of claim 1, wherein, The binarization processing of the pixel value of the second pixel point based on the element value of the target element and the pixel value of the second pixel point comprises: determining a recovery coefficient according to the discard precision of the element value in the target dithering sub-matrix; generating a recovered element value based on the recovery coefficient and the element value of the target element; in the case that the pixel value of the second pixel point is greater than the recovered element value, setting the pixel value of the second pixel point as 1; in the case that the pixel value of the second pixel point is not greater than the recovered element value, setting the pixel value of the second pixel point as 0.
6. The method according to any one of claims 1 to 5, characterized in that, The target dithering matrix is set by the following manner: generating an original dithering matrix of a specified size, and adjusting the element value of each element in the original dithering matrix according to a preset discard precision; dividing the adjusted original dithering matrix into a plurality of dithering sub-matrices as the target dithering matrix.
7. An image processing apparatus characterized by comprising: The device comprises: an acquisition module configured to acquire a target dithering matrix pre-set for an original scan image; the target dithering matrix comprises a plurality of dithering sub-matrices pre-divided, and there is no overlapping part between different dithering sub-matrices; a generation module configured to, for any first pixel point in the original scan image, set the pixel value of each pixel point in a pixel matrix of m×n size as the pixel value of the first pixel point to obtain a pixel matrix unit; m and n are respectively a preset row magnification and a preset column magnification; a first processing module configured to select a target dithering sub-matrix for each second pixel point in the pixel matrix unit from the plurality of dithering sub-matrices; wherein the second pixel point is any pixel point in the pixel matrix unit; for any second pixel point, an element with a position coordinate matching the position coordinate of the first pixel point is selected from the target dithering sub-matrix of the second pixel point as a target element; a binarization processing of the pixel value of the second pixel point is performed based on the element value of the target element and the pixel value of the second pixel point to obtain a bitmap matrix unit corresponding to the first pixel point; a second processing module configured to compose a printable image corresponding to the original scan image based on the bitmap matrix units respectively corresponding to all first pixel points in the original scan image.
8. An electronic device, comprising: comprise: a processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface complete communication with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions make the processor execute the method in any one of claims 1 to 6.
9. One or more machine readable media having instructions, recorded thereon, that if executed by a machine cause the machine to: instructions stored thereon, which when executed by one or more processors, cause the processors to perform the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Image resolution expansion processing method and device and control terminal
CN113724138A
Image processing method and device and storage medium
CN120020858A