Halftone method, device and equipment, printing system and storage medium
By using ordered jitter matrix and error diffusion technology in halftone processing, the problem of noise affecting print quality is solved, and higher image print quality is achieved.
Patent Information
- Application Number
- CN202411894335.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-20
AI Technical Summary
In the related art, halftone processing affects the printing quality due to the added noise, resulting in image details being masked by jitter noise, affecting image quality.
The image is subjected to an ordered jitter processing based on the ordered jitter matrix, and the threshold interval of each pixel point is determined, and the quantization error is diffused to adjacent pixel points through error diffusion to update its grayscale value, and finally a halftone map is generated.
By reducing noise, retaining more image details and improving image print quality, the problem of noise affecting print quality is solved.
Smart Images

Figure CN119766938A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a halftone method, device, equipment, printing system and storage medium. Background Art
[0002] Halftoning is the process of converting a continuous tone image into an image composed of dots of varying sizes and spacing for reproduction by printing or display devices.
[0003] In the related art, noise is added during the halftone processing to cover up the quantization error, resulting in additional noise in the final output signal. Although this noise is usually random and not easily noticeable, it can affect the printing effect in some high-precision scenes, and subtle image details may be covered up by the jitter noise, thus affecting the quality of the printed image. Summary of the invention
[0004] The main purpose of the present application is to provide a halftone method, device, equipment, printing system and storage medium, aiming to solve the technical problem in the related art that the halftone processing affects the printing quality due to the added noise.
[0005] To achieve the above object, the present application provides a halftone method, the halftone method comprising:
[0006] Performing ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image;
[0007] Traversing the pixels of the first image, and determining the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold interval;
[0008] Diffusion of the quantization error to the neighboring pixel points of the traversed pixel point, so as to update the grayscale value of the neighboring pixel points;
[0009] Determine halftone values of remaining pixels of the first image based on the threshold intervals and updated grayscale values of the remaining pixels traversed;
[0010] Based on the halftone values of all pixels, a halftone image corresponding to the first image is generated.
[0011] In one embodiment, the step of performing ordered dithering processing on the first image based on the ordered dithering matrix to obtain a threshold range of each pixel in the first image includes:
[0012] Calculating correction parameters according to the pixel coordinates of the pixel point and the ordered dither matrix;
[0013] The threshold interval of the pixel point is calculated according to the correction parameter and the original error diffusion threshold.
[0014] In one embodiment, the step of calculating the correction parameter according to the pixel coordinates of the pixel point and the ordered dither matrix includes:
[0015] Calculating an ordered dithering threshold value according to the pixel coordinates of the pixel point, the ordered dithering matrix and the error diffusion original threshold value;
[0016] The ordered jitter threshold is corrected based on the blue noise impact factor to obtain the correction parameter.
[0017] In one embodiment, the step of calculating the ordered dithering threshold according to the pixel coordinates of the pixel point, the ordered dithering matrix and the error diffusion original threshold comprises:
[0018] Determining the order of the ordered dither matrix;
[0019] Taking the modulus of the pixel coordinates with respect to the order to obtain element coordinates;
[0020] Determine an element in the ordered jitter matrix based on the element coordinates, the element being data at the element coordinates in the ordered jitter matrix;
[0021] The ordered dithering threshold is obtained by taking the modulus of the element with respect to the error diffusion original threshold.
[0022] In one embodiment, the threshold interval includes at least three threshold sub-intervals divided by at least two intermediate thresholds, the at least three threshold sub-intervals respectively correspond to at least three halftone values, and determining the halftone value and quantization error of the traversed pixel point based on the grayscale value of the traversed pixel point and the threshold interval includes:
[0023] Determine a target threshold subinterval based on a relationship between the grayscale value of the traversed pixel point and the at least three threshold subintervals;
[0024] Obtaining a halftone value corresponding to the target threshold subinterval, and determining it as the halftone value of the traversed pixel point;
[0025] The quantization error is calculated based on the grayscale value of the traversed pixel point and the lower limit value of the target threshold sub-interval.
[0026] In one embodiment, the step of diffusing the quantization error to adjacent pixels of the traversed pixel to update the grayscale values of the adjacent pixels includes:
[0027] Acquire an error diffusion matrix, and determine the neighboring pixel points for error diffusion of the traversed pixel point and the diffusion weight of each of the neighboring pixel points based on the error diffusion matrix;
[0028] Calculating an error value of each of the adjacent pixels according to the quantization error and the diffusion weight;
[0029] The original grayscale values of the adjacent pixels and the error value are summed to obtain updated grayscale values of the adjacent pixels.
[0030] In one embodiment, before the step of performing ordered dithering processing on the first image based on the ordered dithering matrix to obtain the threshold interval of each pixel in the first image, the method further includes:
[0031] The second image is divided into multiple sub-images in sequence, wherein the multiple sub-images include a first sub-image and at least one second sub-image, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, and the first sub-image and the at least one second sub-image are both the first image.
[0032] In one embodiment, the step of sequentially dividing the second image into a plurality of sub-images includes:
[0033] Determine the number of segmentation rows based on the total number of pixel rows of the second image and the number of the sub-images;
[0034] Segmenting the head or tail of the second image based on the segmentation line number to obtain the first sub-image;
[0035] Based on the starting pixel row or the ending pixel row of the first sub-image, the preset number of rows of pixels, and the number of segmentation rows, the second image is segmented in sequence to obtain the second sub-image adjacent to the first sub-image and the rest of the second sub-image.
[0036] In one embodiment, after obtaining the halftone images corresponding to the sub-images, the halftone method further includes:
[0037] The halftone images corresponding to all the sub-images are synthesized to obtain a halftone image corresponding to the second image.
[0038] In one embodiment, the step of synthesizing the halftone images corresponding to all sub-images to obtain the halftone image corresponding to the second image includes:
[0039] Determine an arrangement order of the halftone images, wherein two adjacent halftone images are respectively a first halftone image and a second halftone image;
[0040] Cropping the second halftone image to crop a preset number of rows of pixels in the second halftone image that overlap with the first halftone image;
[0041] The cropped portion of the halftone image and the uncropped portion of the halftone image are spliced based on the arrangement order to obtain a halftone image corresponding to the second image.
[0042] In addition, to achieve the above-mentioned purpose, the present application also provides a halftone device, comprising:
[0043] An ordered dithering processing module, used to perform ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image;
[0044] A first determination module, configured to traverse the pixels of the first image, and determine the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold interval;
[0045] An error diffusion module, diffusing the quantization error to adjacent pixels of the traversed pixel point, so as to update the grayscale value of the adjacent pixel point;
[0046] A second determination module determines the halftone values of the remaining pixels of the first image based on the threshold intervals and updated grayscale values of the remaining pixels traversed;
[0047] A generating module generates a halftone image corresponding to the first image based on the halftone values of all pixels.
[0048] In addition, to achieve the above-mentioned purpose, the present application also provides a computer device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the halftoning method as described above.
[0049] In addition, to achieve the above-mentioned purpose, the present application also provides an inkjet printing device, which includes a processor and a print head, and the processor is used to obtain a halftone image obtained based on the steps of the halftone method as described above, and control the print head to print an image based on the halftone image.
[0050] In addition, to achieve the above-mentioned purpose, the present application also provides a printing system, characterized in that the printing system includes a host computer and an inkjet printing device;
[0051] The host computer is used to obtain a first image, and perform halftone processing on the first image based on the halftone method as described above, to obtain a halftone image and send it to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone image; or,
[0052] The host computer is used to obtain a first image and send the first image to the inkjet printing device; the inkjet printing device is used to perform halftone processing on the first image based on the halftone method described above to obtain a halftone image, and print the first image based on the halftone image.
[0053] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a computer program for implementing the halftoning method is stored, and the computer program for implementing the halftoning method is executed by a processor to implement the steps of the halftoning method as described above.
[0054] The present application provides a halftone method, which first performs an orderly dithering process on a first image based on an orderly dithering matrix to obtain a threshold interval of each pixel in the first image; traverses the pixels of the first image, and determines the halftone value and quantization error of the traversed pixel based on the grayscale value of the traversed pixel and the threshold interval; diffuses the quantization error to the adjacent pixels of the traversed pixel to update the grayscale value of the adjacent pixel; determines the halftone value of the remaining pixels of the first image based on the threshold interval and the updated grayscale value of the remaining pixels traversed, and generates a halftone map corresponding to the first image based on the halftone values of all pixels. That is, in the present application, each pixel has a dynamic threshold interval, and the quantization error is diffused to the adjacent pixels to update the grayscale value of the adjacent pixels, and the grayscale value of each pixel after the error is transferred is compared with its dynamic threshold interval to determine the halftone value corresponding to the pixel. By combining orderly dithering and error diffusion, noise is reduced, and more subtle image details can be retained, thereby improving image printing quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0057] Figure 1 This is a flow chart of steps S10-S50 in an embodiment of the halftone method of the present application;
[0058] Figure 2This is a flow chart of steps S111-S112 in an embodiment of the halftone method of the present application;
[0059] Figure 3 This is a schematic diagram of the overall process provided in an embodiment of the halftone method of the present application;
[0060] Figure 4 A schematic diagram of segmenting a first image provided in an embodiment of a halftone method of the present application;
[0061] Figure 5 A schematic diagram of a traversal method provided in an embodiment of the halftone method of the present application;
[0062] Figure 6 This is a schematic diagram of error diffusion to adjacent pixels provided in an embodiment of the halftone method of the present application;
[0063] Figure 7 A schematic diagram of a halftone image obtained by merging provided in an embodiment of a halftone method of the present application;
[0064] Figure 8 A comparison diagram of a halftone example provided in an embodiment of the halftone method of the present application;
[0065] Fig. 9 This is another halftone example comparison diagram provided in an embodiment of the halftone method of the present application;
[0066] Fig.10 A schematic diagram of the hardware structure involved in the computer device embodiment of the present application;
[0067] Fig.11 This is a schematic diagram of the hardware structure involved in the printing system embodiment of this application;
[0068] Fig.12 A schematic diagram of the hardware structure involved in the halftone device embodiment of the present application;
[0069] Fig.13 This is a schematic diagram of the structure of an inkjet printing device involved in some embodiments of the present application.
[0070] Description of Figure Numbers:
[0071] Printing system 1000; host computer 100; inkjet printing device 200; printing component 210; slide rail 211; print head 212; processor 230; memory 220; halftone device 1200; ordered dithering processing module 1201; first determining module 1202; error diffusion module 1203; second determining module 1204; generating module 1205.
[0072] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0073] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0074] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0075] At present, the principle of the error diffusion algorithm is to process the pixels of the image one by one, compare the brightness value of the current pixel with a threshold, and determine its output color. Then, the processing error of the current pixel, that is, the difference between the actual brightness value and the brightness value corresponding to the output color, is diffused to the surrounding unprocessed pixels. In this way, the processing of subsequent pixels will take into account the error of the previous pixels, so that the tone of the entire image is more uniform. It can produce a relatively smooth halftone effect, but the amount of calculation is relatively large and the processing speed is slow.
[0076] The main solution of the present application is: to perform orderly dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image; to traverse the pixels of the first image, and to determine the halftone value and quantization error of the traversed pixels based on the grayscale value of the traversed pixels and the threshold interval; to diffuse the quantization error to the adjacent pixels of the traversed pixels to update the grayscale value of the adjacent pixels; to determine the halftone value of the remaining pixels of the first image based on the threshold interval and the updated grayscale value of the remaining traversed pixels; and to generate a halftone map corresponding to the first image based on the halftone values of all pixels.
[0077] In the present application, each pixel has a dynamic threshold interval, and the quantization error is diffused to adjacent pixels to update the grayscale value of the adjacent pixels. The grayscale value of each pixel after the error is transferred is compared with its dynamic threshold interval to determine the halftone value corresponding to the pixel. By combining ordered dithering and error diffusion, noise is reduced and more subtle image details can be retained, thereby improving image printing quality.
[0078] It should be noted that the execution subject of the halftone method of this embodiment can be a host computer, or a computer device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, a tablet, etc., or an inkjet printing device that can realize the above functions, or a printing system, or a halftone device. This embodiment does not make specific limitations on this. The following takes the host computer of the inkjet printing device as an example of the execution subject to illustrate this embodiment and the following embodiments. The inkjet printing device as the execution subject is similar and will not be repeated here.
[0079] Based on this, an embodiment of the present application proposes a halftone method, please refer to Figure 1 The halftone method comprises steps S10 to S50:
[0080] Step S10: performing ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image.
[0081] In this embodiment, the ordered dither matrix is a matrix with a specific element value arrangement. Its size and element values can be preset according to actual needs. Different ordered dither matrices will produce different halftone effects. In this solution, it is used to determine the threshold interval for the pixel. The threshold interval is a specific range of values. In one embodiment, the threshold interval has a first threshold and a second threshold. The threshold interval is divided into three threshold sub-intervals based on the first threshold and the second threshold. The threshold interval is used to determine the halftone value of the pixel.
[0082] As an optional implementation manner, for each pixel point, a threshold range of each pixel point is determined based on the pixel coordinates, the ordered dither matrix and the error diffusion original threshold.
[0083] Exemplarily, for the first pixel point, the first threshold corresponding to the first pixel point is determined based on its first pixel coordinates, the ordered jitter matrix and the first error diffusion original threshold, and then the second threshold corresponding to the first pixel point is determined based on the first pixel coordinates, the ordered jitter matrix and the second error diffusion original threshold, and then three threshold sub-intervals can be determined based on the first threshold and the second threshold, and then combined into a threshold interval.
[0084] As an optional implementation, for each pixel in the first image, its corresponding threshold interval can be determined by mapping its position information in the first image with the ordered jitter matrix. For example, assuming that the ordered jitter matrix is M*N in size, the pixel is (x, y), x and y are the row and column coordinates of the pixel in the first image, respectively, and the position coordinates of the pixel in the first image will correspond to an element or a combination of elements in the ordered jitter matrix. According to this correspondence and the characteristics of the ordered jitter matrix, the threshold interval of the pixel can be determined. The determination of this threshold interval involves operations such as scaling and offsetting of matrix element values to adapt to the characteristics of image pixels and halftone processing requirements.
[0085] As an optional implementation, the threshold interval of each pixel point is determined in combination with an ordered jitter matrix and an error diffusion algorithm. When the error diffusion is a third-order diffusion, the threshold interval includes a first threshold and a second threshold, the first threshold is the left endpoint of the threshold interval, and the second threshold is the right endpoint of the threshold interval. Or in the threshold interval, 0 is the left endpoint of the threshold interval, the second threshold is the right endpoint of the threshold interval, and the first threshold is between 0 and the second threshold. When the error diffusion is a fourth-order diffusion, the threshold interval includes a first threshold, a second threshold, and a third threshold, wherein 0 is the left endpoint of the threshold interval, the third threshold is the right endpoint of the threshold interval, the second threshold is greater than the third threshold, and the second threshold is less than the third threshold, and the first threshold is less than the second threshold. Error diffusion processing is a method for image processing. Error diffusion processing is mainly to diffuse the error generated by the current pixel processing to the surrounding unprocessed pixels to make the image tone more uniform. This application takes the third-order diffusion as an example for explanation. The principles of the fourth-order diffusion, the fifth-order diffusion or more-order diffusion are similar and will not be repeated here. The third-order diffusion means that there are two different levels of thresholds involved in the processing process.
[0086] Step S20 , traversing the pixels of the first image, and determining the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold range.
[0087] In this embodiment, traversal refers to accessing each pixel in the first image in a certain order to ensure that each pixel is processed accordingly. The halftone value is a quantized value used to represent a pixel at a limited color or gray level in halftone processing. The halftone value is determined by a threshold interval so that the original information of the pixel can be converted into a halftone representation, thereby achieving a visual effect of simulating the first image with limited colors or grayscales. The quantization error can be the difference between the gray value of the pixel and the first threshold or the second threshold in the threshold interval, and this difference can be diffused to adjacent pixels to change the gray value of the adjacent pixels.
[0088] As an optional implementation, starting from the upper left corner of the first image, pixels are selected in order from left to right and from top to bottom as the current pixel. For example, for a first image, whose pixels are arranged in rows and columns, the pixel in the first row and first column is first selected as the current pixel, and after processing, the pixel in the first row and second column is selected, and so on, until all the pixels in the entire first image are traversed.
[0089] As an optional implementation, each pixel in the first image is accessed in sequence from left to right, from top to bottom or other predetermined traversal order. For the traversed pixel, its original brightness, grayscale value or other related attribute value is compared with the first threshold value or the second threshold value in the threshold interval. The halftone value of the pixel is determined according to the comparison result. For example, if the grayscale value of the pixel falls within a certain threshold interval, its halftone value is set to a specific value corresponding to the interval. Then, a difference is made between the halftone value and the first threshold value or the second threshold value, and the difference result is used as a quantization error.
[0090] Step S30: diffuse the quantization error to adjacent pixels of the traversed pixel to update the grayscale values of the adjacent pixels.
[0091] In this embodiment, the adjacent pixel points are pixel points determined according to a preset rule based on the traversed pixel points.
[0092] As an optional implementation, when the current traversal mode is from left to right, the adjacent pixel points are based on the traversed pixel points, the first right, the next, the lower left, and the lower right pixel points. When the current traversal mode is from right to left, the adjacent pixel points are determined based on the traversed pixel points, the first left, the next, the lower left, and the lower right pixel points. After determining the adjacent pixel points, the quantization error is diffused to the adjacent pixel points to update the grayscale value of the adjacent pixel points.
[0093] Step S40: determining the halftone values of the remaining pixels of the first image based on the threshold intervals and updated grayscale values of the remaining pixels traversed.
[0094] Step S50: generating a halftone image corresponding to the first image based on the halftone values of all pixels.
[0095] In this embodiment, the halftone value determined for each pixel in the first image is updated to the corresponding pixel position. In this way, all pixels in the first image have a determined halftone value, thereby forming a new image, i.e., a halftone image. This process completes the conversion from the second image to the halftone image.
[0096] Exemplarily, in an inkjet printing device, a first image is to be printed, and the photo size is 5000*3000 pixels. When processing the image, the printing device first uses the landscape photo as the first image. Then, for each pixel in the image, the threshold interval is determined using the ordered jitter matrix stored in the device. For the pixel with coordinates (100, 200) in the first image, the printing device maps it to an element or a combination of elements in the ordered jitter matrix according to its relative position in the sub-image. Through a specific algorithm, the threshold interval of the pixel is determined by combining the value of this element or the combination of elements and the original color information of the pixel. For example, the two thresholds in the threshold interval are 128 and 255 respectively, and this threshold interval is used to subsequently determine the halftone value of the pixel to determine its color performance after halftone processing. Such an operation is performed for each pixel in the first image. After determining the threshold interval, the inkjet printing device starts to traverse the pixels in the first image. For the first image, starting from the pixel in the upper left corner, access is performed in order from left to right and from top to bottom. For example, when a pixel is accessed, its grayscale value is 70. According to the position of the grayscale value in the threshold interval, its corresponding halftone value is determined. For each pixel in the entire sub-image, its grayscale value is compared with the threshold interval in this way to determine the halftone value. In this way, the first image is converted from the original landscape photo to the halftone image. For example, the sky part, which originally has continuously changing colors, is presented in limited colors or grayscale levels after this process, which is more suitable for the output of the printing device. Finally, the first image is printed based on the halftone image to output high-quality landscape photos for the user.
[0097] The present application first performs an ordered dithering process on a first image based on an ordered dithering matrix to obtain a threshold interval for each pixel in the first image; traverses the pixels of the first image, and determines the halftone value and quantization error of the traversed pixel based on the grayscale value of the traversed pixel and the threshold interval; diffuses the quantization error to the adjacent pixels of the traversed pixel to update the grayscale value of the adjacent pixel; determines the halftone value of the remaining pixels of the first image based on the threshold interval and updated grayscale value of the remaining traversed pixel; generates a halftone map corresponding to the first image based on the halftone values of all the pixels, that is, in the present application, each pixel has a dynamic threshold interval, so that each pixel is compared with its dynamic threshold interval after the error is transmitted, so as to determine a more flexible quantization error, thereby solving the technical problem that the continuous transmission and accumulation of errors in the image will lead to a decrease in the contrast of the image, thereby affecting the visual effect of the image, and achieving the technical effect of improving the contrast of the image.
[0098] Based on any embodiment, in a possible embodiment of the present application, step S10 includes steps S11-S12:
[0099] Step S11, calculating correction parameters according to the pixel coordinates of the pixel points and the ordered dither matrix.
[0100] In this embodiment, pixel coordinates refer to the coordinate information of the pixel point in the first sub-image or the second sub-image, usually including row coordinates and column coordinates. This position information is an important basis for determining the correction parameter, because pixels at different positions have different mapping relationships in the ordered jitter matrix. The correction parameter is a parameter used to adjust the threshold interval. It is calculated based on the mapping result of the pixel point in the ordered jitter matrix. Its value will vary with the different positions of the pixel point, thereby providing a personalized threshold adjustment basis for each pixel point.
[0101] As an optional implementation, the pixel coordinates are substituted into the ordered dither matrix, the value of the ordered dither matrix is determined, and then the correction parameter is determined according to the value.
[0102] Optionally, refer to Figure 2 , step S11, including steps S111-S112:
[0103] Step S111, calculating an ordered dithering threshold according to the pixel coordinates of the pixel point, the ordered dithering matrix and an error diffusion original threshold.
[0104] As an optional implementation, the pixel coordinates are substituted into the ordered dither matrix to determine the value of the ordered dither matrix, and then the ordered dither threshold is determined according to the value and the original threshold of the error diffusion.
[0105] As another optional implementation, the order of the ordered dither matrix is determined; the pixel coordinates are modulo the order to obtain element coordinates; the elements in the ordered dither matrix are determined based on the element coordinates; the elements are modulo the error diffusion original threshold to obtain the ordered dither threshold.
[0106] Exemplarily, the order of the ordered jitter matrix is obtained, and for the traversed pixel points, the pixel coordinates are determined, which are divided into a first horizontal coordinate and a first column coordinate; then the first horizontal coordinate is modulo the order to obtain a second horizontal coordinate, and the order is modulo the first column coordinate to obtain the second column coordinate; the second horizontal coordinate and the second column coordinate are used as element coordinates in the ordered jitter matrix, and the corresponding element is determined in the ordered jitter matrix according to the element coordinates; the original error diffusion threshold is modulo calculated according to the element to obtain an ordered jitter threshold.
[0107] Step S112: correcting the ordered jitter threshold based on the blue noise impact factor to obtain the correction parameter.
[0108] In this embodiment, the blue noise impact factor is a coefficient used to adjust the weight between the correction parameter and the error diffusion original threshold.
[0109] As an optional implementation manner, the product of the ordered jitter threshold and the blue noise impact factor is used as the correction parameter.
[0110] Step S12, calculating the threshold interval of the pixel point according to the correction parameter and the original error diffusion threshold.
[0111] In this embodiment, the error diffusion original threshold is a basic threshold parameter pre-set in the error diffusion algorithm, which provides a basic range for determining the threshold interval. In the third-order error diffusion, there are two error diffusion original thresholds. After combining the correction coefficient, a threshold interval that better meets the characteristics of each pixel can be obtained. The threshold interval is a numerical range including the first threshold and the second threshold, which is used to subsequently determine the halftone value of the pixel.
[0112] As an optional implementation, for each error diffusion original threshold, a correction parameter is determined according to the pixel position of the pixel point, the ordered jitter matrix, the error diffusion original threshold, and the blue noise influence factor, and then the sum of the correction parameter and the error diffusion original threshold is used as the corrected error diffusion threshold. Since there are two error diffusion original thresholds, two error diffusion thresholds are calculated, namely the first threshold and the second threshold. Then, a threshold interval is formed according to the first threshold and the second threshold.
[0113] Exemplarily, two endpoints of the threshold interval are a first threshold and a second threshold.
[0114] Exemplarily, the threshold interval includes at least three threshold sub-intervals divided based on at least two intermediate thresholds. That is, the first threshold is less than the second threshold, the first threshold sub-interval is composed of 0 to the first threshold, the second threshold sub-interval is composed of the first threshold to the second threshold, and the third threshold sub-interval is from the second threshold to infinity or 255. Then the first threshold sub-interval, the second threshold sub-interval, and the third threshold sub-interval are used as the threshold interval.
[0115] Exemplarily, the calculation formula is as follows:
[0116] T=t+F[x%8][y%8]%t×m
[0117] Among them, T is the calculated error diffusion threshold, (x, y) represents the pixel coordinates of the input pixel point; F is the Bayer ordered dither matrix with blue noise characteristics; t is the original error diffusion threshold, and the two original thresholds t of the third-order error diffusion are 64 and 192; m is the blue noise influence factor, and the value range is (0-1), % refers to the remainder calculation, and A%B refers to the remainder of A divided by B. F[x%8][y%8] represents the element with coordinates (x%8, y%8) in the matrix, and F[x%8][y%8]%t means that the element is modulo t. The closer the value of m is to 0, the closer the error diffusion threshold is to the original fixed value, and the closer m is to 1, the closer the error diffusion threshold is to the dither threshold.
[0118] As an example, a Bayer ordered dither matrix:
[0119]
[0120] As an example, the blue noise impact factor is 0.4.
[0121] Then, substituting 64 into the formula, we obtain the first threshold value T1=64+F[x%8][y%8]%64×0.4.
[0122] Substituting 192 into the formula, we obtain the second threshold value T2=192+F[x%8][y%8]%192×0.4.
[0123] For example, the pixel point currently traversed has a pixel coordinate of (12, 17), so 12 modulo 8 is 4, and 17 modulo 8 is 1. Therefore, the element with coordinates (4, 1) in matrix F is taken, that is, F(4, 1), and the value is 60. Then this value is substituted into the calculation formula to obtain the first threshold value T1=64+60%64×0.4=64+24=88, and the second threshold value T2=192+60%192×0.4=192+24=216.
[0124] Since the error threshold in error diffusion is improved by an ordered dithering matrix, each pixel has a dynamic threshold interval when determining the halftone value, and then the large particle artifacts in the image are reduced to small particle artifacts through ordered dithering and improved error diffusion algorithm, thereby improving the image quality.
[0125] Based on any embodiment, in a possible embodiment of the present application, step S20 includes steps S21-S23:
[0126] Step S21: determining a target threshold sub-interval based on the relationship between the grayscale value of the traversed pixel point and the at least three threshold sub-intervals.
[0127] In this embodiment, the threshold interval includes at least three threshold sub-intervals divided based on at least two intermediate thresholds, and the at least three threshold sub-intervals correspond to at least three halftone values respectively. Among all the threshold sub-intervals, by comparing the grayscale value of the currently traversed pixel with them, the grayscale value of the pixel finally falls into the specific threshold sub-interval, and the halftone value corresponding to the pixel will be determined based on this interval later.
[0128] First, get the grayscale value of the currently traversed pixel. Then, compare the grayscale value with each pre-set threshold sub-interval in turn to determine which threshold sub-interval it falls in. For example, suppose there are three threshold sub-intervals: Interval 1 has a lower limit of 0 and an upper limit of 88, Interval 2 has a lower limit of 89 and an upper limit of 216, Interval 3 has a lower limit of 217 and an upper limit of 255. If the grayscale value of the current pixel is 80, it can be seen from the comparison that it falls in Interval 1, so Interval 1 is the target threshold sub-interval corresponding to this pixel.
[0129] Step S22, obtaining a halftone value corresponding to the target threshold sub-interval and using it as the halftone value for determining the traversed pixel point.
[0130] In this embodiment, after the target threshold sub-interval is determined, the halftone value corresponding to the target threshold sub-interval is found according to the pre-established correspondence table between the threshold sub-interval and the halftone value. For example, the previously determined target threshold sub-interval is interval 2, and the halftone value corresponding to interval 2 is recorded as 1 in the correspondence table. This correspondence is pre-set according to the specific halftone processing algorithm and requirements, so 1 is used as the halftone value of the pixel point currently traversed.
[0131] As an optional implementation, there are three states of inkjet: 0, no inkjet, indicated by a; 1, small inkjet, indicated by b; 3, large inkjet, indicated by d. Then there are three halftone values, 0, 1 and 3. Among the three threshold sub-intervals, the first threshold sub-interval is composed of 0 to the first threshold, the second threshold sub-interval is composed of the first threshold to the second threshold, and the third threshold sub-interval is from the second threshold to infinity or 255. The first threshold sub-interval corresponds to a halftone value of 0, the second threshold sub-interval corresponds to a halftone value of 1, and the third threshold sub-interval corresponds to a halftone value of 3.
[0132] Step S23, calculating the quantization error based on the grayscale value of the traversed pixel point and the lower limit value of the target threshold sub-interval.
[0133] In this embodiment, the grayscale value of the currently traversed pixel and the lower limit of the previously determined target threshold subinterval are obtained, and the lower limit of the target threshold subinterval is subtracted from the grayscale value of the pixel, and the result is the quantization error. For example, if the current pixel grayscale value is 80 and the lower limit of the target threshold subinterval is 0, then the quantization error = 80-0 = 80.
[0134] For example, an electronic image of an art painting needs to be printed by an inkjet printing device, and the device uses the above-mentioned halftone processing method to control the inkjet amount to achieve a better printing effect. First, the image is converted into a grayscale image to obtain a first image in the form of a pixel matrix, and the image size is assumed to be 2000×1500 pixels. Then, the pixels in the image are traversed from left to right and from top to bottom for halftone processing. For the first pixel traversed, its grayscale value is 60. It is known that the divided threshold intervals and subintervals are as follows: interval 1 (lower limit value is 0, upper limit value is 80); interval 2 (lower limit value is 81, upper limit value is 160); interval 3 (lower limit value is 161, upper limit value is 255). The grayscale value of the pixel point 60 falls within interval 1, so interval 1 is the target threshold subinterval of this pixel point. According to the corresponding relationship, the halftone value corresponding to interval 1 is 0, so the halftone value of the pixel point is determined to be 0. Subtract the lower limit value of interval 1 0 from the pixel point grayscale value 60, and the quantization error is 60-0=60. Next, the quantization error is diffused according to the established error diffusion rules, such as to the adjacent pixels to the right, below, left and right, and the grayscale values of the adjacent pixels are updated. Then, other pixels are traversed until the entire image is processed to obtain a halftone image. Finally, the inkjet printing device performs inkjet operation according to the halftone value of the pixel. When the halftone value is 0, no inkjet is applied (marked as a), when the halftone value is 1, a small inkjet is applied (marked as b), and when the halftone value is 3, a large inkjet is applied (marked as d), thereby presenting the first image on the paper. The halftone processing optimizes the control of the inkjet amount and improves the printing quality.
[0135] In this embodiment, the threshold sub-interval is used to determine the halftone value and quantization error of the pixel point, which effectively realizes the halftone processing of the image and improves the visual effect of the image in a specific printing scene.
[0136] Based on any embodiment, in a possible embodiment of the present application, step S30 includes steps S31-S33:
[0137] Step S31, obtaining an error diffusion matrix, and determining the neighboring pixel points for error diffusion of the traversed pixel point and the diffusion weight of each of the neighboring pixel points based on the error diffusion matrix.
[0138] In this embodiment, the error diffusion matrix is a predefined matrix used to determine which adjacent pixels the quantization error of the current pixel is diffused to and the proportion of the error received by each adjacent pixel, i.e., the diffusion weight, during the halftone processing process. The elements in the matrix usually represent the error diffusion distribution relationship between adjacent pixels at different positions relative to the current pixel. Diffusion weight: Each element in the error diffusion matrix corresponds to the diffusion weight of an adjacent pixel, which represents the proportion of the quantization error of the current pixel allocated to the adjacent pixel. For example, the diffusion weight of an adjacent pixel is 0.3, indicating that 30% of the quantization error of the current pixel will be allocated to the pixel. The sum of the weights is usually 1 or close to 1 to ensure that the quantization error is distributed and diffused within a reasonable range to avoid excessive impact on image quality.
[0139] As an optional implementation, the size and element values of the error diffusion matrix, such as the Floyd-Steinberg matrix, are determined according to the characteristics and requirements of the halftone algorithm to achieve reasonable diffusion of image errors so that the image can still maintain a good visual effect after quantization. First, the error diffusion matrix is obtained from the preset data used by the halftone processing algorithm. For example, when scanning in the positive direction, the error diffusion uses the positive direction scanning matrix to diffuse to the currently traversed pixel point and to the four adjacent pixel points. The elements in the matrix are the weights of the errors inherited by the adjacent pixel points: the element with coordinates (1,2) in the matrix represents the current pixel point.
[0140]
[0141] Scan the matrix in the negative direction:
[0142]
[0143] For the pixel currently traversed, its neighboring pixels are determined according to the matrix. Assuming that the coordinates of the current pixel are (x, y), the diffusion weight of the pixel to its right (x, y+1) is 7 / 16, the diffusion weight of the pixel below (x+1, y) is 5 / 16, the diffusion weight of the pixel below (x+1, y) is 3 / 16, and the diffusion weight of the pixel below (x+1, y-1) is 1 / 16. These neighboring pixels and the corresponding diffusion weights will be used for the subsequent calculation of error values and the update of grayscale values.
[0144] Step S32: calculating the error value of each of the adjacent pixels according to the quantization error and the diffusion weight.
[0145] In this embodiment, the quantization error of the current pixel is known to be E, and the diffusion weights of each adjacent pixel are known to be w. i(i represents different adjacent pixel coordinates). For example, for the adjacent pixel mentioned above, if the quantization error E=20, then the error value E of the right pixel (x, y+1) is (x+1,y) =E×w (x+1,y) =20×7 / 16=35 / 4; the error value E of the lower right pixel (x+1, y+1) (x+1,y) =E×w (x+1,y+1) =20×1 / 16=5 / 4; the error value E of the lower pixel (x+1, y) (x,y+1) =E×w (x,y+1) =20×5 / 16=25 / 4; the error value E of the lower left pixel (x+1, y-1) (x-1,y+1) =E×w (x-1,y+1) =20×3 / 16=15 / 4.
[0146] Step S33, summing the original grayscale value of the adjacent pixel point and the error value to obtain the updated grayscale value of the adjacent pixel point.
[0147] In this embodiment, the original grayscale value is the grayscale value of the adjacent pixel before receiving the quantization error diffusion of the current pixel, which reflects the original brightness information of the pixel in the image. The updated grayscale value is obtained by adding the original grayscale value to the assigned error value, so that the grayscale value of the adjacent pixel is adjusted according to the quantization error of the current pixel, and the halftone processing and tone optimization of the image are gradually realized.
[0148] As an optional implementation, assume that the original grayscale value of the adjacent pixel (x+1, y) is G (x+1,y) , then its updated gray value newG (x+1,y) =G(x+1,y)+E(x+1,y). For example, if G (x+1,y) =100, E (x+1,y) =35 / 4, then newG (x+1,y) =100+35 / 4=435 / 4. Similarly, for other adjacent pixel points (x+1, y+1), (x, y+1), (x-1, y+1), the original grayscale values of each pixel are added to the calculated error value to obtain the updated grayscale value, and the grayscale value update operation of these adjacent pixel points is completed, so that when traversing other pixel points in the future, the halftone processing and error diffusion are continued based on the updated grayscale value until all the pixel points of the entire image are processed.
[0149] For example, there is a grayscale image of size 3×3, and the grayscale values of the pixels are as follows: Assume that the currently traversed pixel is (3,5), and its grayscale value is 120. After the previous steps, its halftone value and quantization error are determined. Assume that the quantization error E=30. Use the above Floyd-Steinberg error diffusion matrix for error diffusion. Right pixel (3,6): original grayscale value G (1,2) =150, diffusion weight w (3,6) =7 / 16, error value E (3,6) =30×7 / 16=105 / 8, updated gray value newG (3,6) =150+105 / 8=1305 / 8≈163.125. Lower right pixel (4,6): original grayscale value G (4,6) =180, diffusion weight w (4,6) =1 / 16, error value E (4,6) =30×1 / 16=15 / 8, updated gray value newG (4,6) =180+15 / 8=1455 / 8≈181.875. Pixel point (4,5) below: original grayscale value G (4,5) =200, diffusion weight w (4,5) =5 / 16, error value E (4,5) =30×5 / 16=75 / 8, updated gray value newG (4,5) =200+75 / 8=1675 / 8≈209.375. Lower left pixel (4,4): original grayscale value G (4,4) =100 (assuming that the grayscale value of pixels outside the image boundary is 100), diffusion weight w (4,4) =3 / 16, error value E (4,4) =30×3 / 16=45 / 8, updated gray value newG (4,4) =100+45 / 8=845 / 8≈105.625. In this way, the diffusion of the quantization error of the current pixel (3,5) to the adjacent pixels and the update of the grayscale values of the adjacent pixels are completed. Then, other pixels in the image are traversed, and the above error diffusion and grayscale value update steps are repeated until the halftone processing of the entire image is completed.
[0150] Since the error is diffused to adjacent pixels to update the grayscale values of adjacent pixels, the dynamic change of the grayscale value of each pixel is achieved, thereby improving the accuracy of the halftone value.
[0151] Based on any embodiment, in a possible embodiment of the present application, before step S10, the halftone method includes:
[0152] Step A1, divide the second image into multiple sub-images in sequence, the multiple sub-images include a first sub-image and at least one second sub-image, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, and the first image includes the first sub-image and the at least one second sub-image.
[0153] In this embodiment, the second image refers to a second image that needs to be half-toned, which has various formats and sources, includes a large number of pixels, each pixel has its own specific brightness, color and other attributes, and these pixels are arranged in rows and columns to form the entire image, and the image size is represented by R rows and C columns. The preset number is a pre-set fixed value, which is the number of pixel rows that the second sub-image has more than the first sub-image.
[0154] In an embodiment, the image is divided according to the number of rows. Specifically, the total number of rows of the image is divided into a plurality of sub-images according to a specific number of rows parameter. The first sub-image and the second sub-image are different parts divided from the second image in a preset manner. The first sub-image is one of the sub-images, and the number of rows is the number of segmentation rows. There is at least one second sub-image, and the number of rows of each second sub-image is the number of segmentation rows plus the preset number.
[0155] As an optional implementation, for a second image with R rows and C columns, it is divided into N segmentation images, and the preset number is determined to be p, where p>1. Among them, the first sub-image takes the first K rows of the image, that is, the 1st row to the Kth row. For the second sub-image, the first second sub-image starts from the K-p+1th row and takes to the 2Kth row; the second second sub-image starts from the 2*K-p+1th row and takes to the 3*Kth row, and so on. The N-1th second sub-image starts from the (N-1)*S-p+1th row and takes to the N*Sth row. In this way, the entire image is divided into N sub-images and adjacent sub-images have overlapping parts, overlapping p pixel rows.
[0156] Therefore, after determining that the first image is a first sub-image and at least one second sub-image, the divided first sub-image and all second sub-images are sent to the processing unit at the same time, and for each sub-image, the corresponding ordered dither matrix is used to perform halftone processing. For example, for a specific sub-image, the processing unit determines the output color or brightness of the pixel in the halftone image according to the corresponding position of each pixel in the sub-image in the corresponding ordered dither matrix and the value of the matrix element, thereby converting the entire sub-image into a target image. Through parallel processing, the processing speed can be significantly improved. The first sub-image and the second sub-image are processed in combination with the ordered dither matrix and error diffusion to determine at least two target images.
[0157] Since the second image is sequentially divided into a plurality of sub-images, the plurality of sub-images include the first sub-image and at least one second sub-image, the relevant steps of the above halftone method embodiment can be implemented for each sub-image, that is, each sub-image is processed in parallel to improve processing efficiency. At the same time, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, that is, for each second sub-image, the halftone value of each pixel is determined, and the first preset number of rows of pixels are repeated with the previous sub-image, and for the preset number + 1 rows of pixels, their grayscale values have undergone several times of error diffusion, for example, 10 times of error conduction F (i,j) =(7 / 16) 10 *f (i,j) =0.000257*f (i,j) , its deviation rate approaches zero, making the determined halftone value more accurate.
[0158] Based on any of the above embodiments, in an optional embodiment of the present application, step S10 includes:
[0159] Step S11, determining the number of segmentation rows based on the total number of pixel rows of the second image and the number of the sub-images.
[0160] In this embodiment, the number of sub-images is the total number of images of the first sub-image and the second sub-image. The total number of pixel rows refers to the number of rows formed by pixel points of the second image in the vertical direction, which determines the height information of the image and is an important dimension of the image size. The number of segmentation rows is a value calculated based on the preset number and the number of pixel rows of the first image, and is used to determine the number of rows of the first sub-image.
[0161] The number of segmentation rows is determined by using a preset number and pixel rows of the first image in a specific calculation method, for example, by dividing the pixel rows of the first image by a value related to the preset number, or according to a certain mathematical relationship between the preset number and the pixel rows of the image.
[0162] As an optional implementation, the number of images of the sub-images after segmentation is determined, the preset number is the number of pixel rows that the second sub-image has more than the first sub-image, and the number of segmentation rows of the first sub-image is determined according to the number of pixel rows of the first image, the number of images of the sub-images after segmentation, and the preset number. Among them, the number of segmentation rows*the number of sub-images=the total number of pixel rows of the second image. The number of pixel rows of the first sub-image is the number of segmentation rows, and the number of pixel rows of the second sub-image=the number of segmentation rows+the preset number.
[0163] Step S12: segment the head or tail of the second image based on the segmentation line number to obtain the first sub-image.
[0164] In this embodiment, the first sub-image is the first sub-image divided from the first image, which is part of the entire halftone processing process and will be processed by the second sub-image later. Figure 1 They are processed together to generate the final halftone image.
[0165] According to the calculated number of segmentation lines K, starting from the head or tail of the first image, the first K rows of pixels are selected to form the first sub-image. For example, if the number of segmentation lines = 200, the first sub-image is the image portion consisting of the first 200 rows of pixels of the first image.
[0166] It should be noted that if the first sub-image starts from the head of the second image, the tail of the first sub-image overlaps with the head of the first second sub-image by a preset number of rows of pixels. If the first sub-image starts from the tail of the second image, the head of the first sub-image overlaps with the tail of the first second sub-image by a preset number of rows of pixels.
[0167] Step S13, based on the starting pixel row or the ending pixel row of the first sub-image, the preset number of rows of pixels, and the number of segmentation rows, the second image is segmented in sequence to obtain a second sub-image adjacent to the first sub-image and the rest of the second sub-image.
[0168] In this embodiment, if the first sub-image starts from the head of the second image, the second sub-image is segmented from the end pixel row of the first sub-image. If the first sub-image starts from the end pixel row of the second image, the second sub-image is segmented from the end pixel row of the first sub-image.
[0169] When forming the second sub-image, starting from the first second sub-image, if it is the first second sub-image after the first sub-image, it is composed of a preset number of rows of pixels at the end of the first sub-image, plus the pixels corresponding to the number of subsequent segmented rows. For example, the preset number is 10, the number of segmented rows is 200, and the first sub-image is rows 1 to 200 of the second image. If it is the first second sub-image, starting from row 191 of the second image, select row 400 of the second image to form the first second sub-image; if it is the next second sub-image, starting from the last ten rows of the end of the previous second sub-image, that is, row 391 of the entire second image, select row 600 to form the next second sub-image, and so on, until the entire second image is processed to obtain the first sub-image and all second sub-images.
[0170] After completing the sub-image division, the halftone processing unit of the printing device will perform parallel halftone processing on the first sub-image and the second sub-image based on the ordered dither matrix. After the processing is completed, the target images are merged, and finally the printing device accurately sprays ink onto the printing paper according to the merged halftone image data, and prints out a painting image with high-quality halftone effect, allowing users to obtain exquisite printed works. This method improves printing efficiency through reasonable image segmentation and parallel processing while ensuring printing quality.
[0171] Based on any of the above embodiments, in an optional embodiment of the present application, after step S40, the following steps are included:
[0172] Step S50, synthesizing the halftone images corresponding to all sub-images to obtain a halftone image corresponding to the second image.
[0173] In this embodiment, before synthesizing the halftone images corresponding to all sub-images to obtain the halftone image corresponding to the second image, the steps of the halftone method in the above embodiment are performed on each sub-image obtained by dividing the second image to determine the halftone image corresponding to each sub-image. Then, the halftone images of all sub-images are synthesized to obtain the halftone image corresponding to the second image.
[0174] When processing the second image, the sub-image is divided into a plurality of smaller regions, which are sub-images. Sub-image division can realize parallel processing, reduce computational complexity, or perform operations according to specific image structures and algorithm requirements. Each sub-image contains some pixels, and after the previous halftone processing steps, each has a corresponding halftone image. That is, the sub-images in this embodiment are the first sub-image and at least one second sub-image.
[0175] After the halftone images of the first sub-image and each of the second sub-images are determined, all the halftone images are synthesized according to the order in which the sub-images are divided to obtain the halftone image of the second image.
[0176] Optionally, step S50 includes steps S51 to S53.
[0177] Step S51 : determining the arrangement order of the halftone images, wherein two adjacent halftone images are respectively a first halftone image and a second halftone image.
[0178] In this embodiment, the arrangement order of the halftone images is due to the fact that the second image is divided into a plurality of sub-images and halftone processing is performed separately. The halftone images corresponding to these sub-images need to be arranged in a specific order in order to correctly synthesize the halftone image corresponding to the second image. This order is usually related to the division order of the sub-images in the second image, such as from left to right, from top to bottom, or an order determined according to other preset rules. The first halftone image and the second halftone image are two adjacent halftone images. In order to facilitate the description of the processing process, the halftone image that is processed first or in the front of the arrangement order is called the first halftone image, and the latter is called the second halftone image. During the synthesis process, their overlapping parts need to be processed to achieve seamless splicing.
[0179] As an optional implementation, first, the arrangement order of the halftone images is determined according to the sub-image division method of the second image. For example, if the second image is divided into sub-images in a top-to-bottom order and half-tone processed, then the arrangement order of the halftone images should also be from top to bottom. When processing adjacent halftone images, it is clear which one is the first halftone image and which one is the second halftone image, so as to perform subsequent cropping and splicing operations of the overlapping parts.
[0180] Step S52: cropping the second halftone image to crop a preset number of rows of pixels in the first halftone image that overlap with the second halftone image.
[0181] In this embodiment, information about a preset number of rows of pixels overlapping the first halftone image and the second halftone image is obtained. Based on this information, the area to be cropped in the second halftone image is determined, for example, the preset number of rows of pixels in the head. This part of the pixels in the first halftone image is removed using an image cropping algorithm or a related function. For example, if the second halftone image is an image represented by a two-dimensional pixel matrix, the matrix rows corresponding to the preset number of rows of pixels in the head are deleted by modifying the row number range of the matrix, thereby obtaining the cropped first halftone image.
[0182] As an optional implementation, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, that is, for each second sub-image, the halftone value of each pixel is determined, and the first preset number of rows of pixels are repeated with the previous sub-image. For the preset number + 1 rows of pixels, their grayscale values have undergone several times of error diffusion, for example, after 10 times of error conduction, their deviation rate approaches zero, making the determined halftone value more accurate. Therefore, when cropping, the halftone image of the first sub-image does not need to be cropped. For each halftone image corresponding to the second sub-image, the two adjacent halftone images are determined to be the first halftone image and the second halftone image according to the order from the beginning to the end of the second image; then the preset number of rows of pixels at the head of the second halftone image are cropped. For the second sub-image adjacent to the first sub-image, the preset number of rows of pixels at the head of its halftone image are directly cropped.
[0183] As another optional implementation, if the sub-images are arranged in the order of starting from the tail of the second image as the first sub-image, and from the tail to the head as the first sub-image, the first second sub-image, the second second sub-image, etc. For example, if the first second sub-image and the second second sub-image are adjacent sub-images, the first second sub-image corresponds to the first halftone image, and the second second sub-image corresponds to the second halftone image, then due to the order of error diffusion, a preset number of rows of pixels at the tail of the second halftone image are cropped.
[0184] Step S53 , splicing the cropped partial halftone image and the uncropped partial halftone image based on the arrangement order to obtain a halftone image corresponding to the second image.
[0185] In this embodiment, stitching is to connect the cropped halftone image and the uncropped halftone image in a determined arrangement order to form a complete image. This image is the halftone image corresponding to the second image. Its visual effect should be consistent with the expected result after the second image is processed by halftone, and there should be no obvious gaps or discontinuities at the stitching.
[0186] As an optional implementation, the cropped first halftone image is spliced with the uncropped second halftone image according to the previously determined arrangement order of the halftone images. This is implemented using an image splicing algorithm or a related library function. For example, if Python's image processing library Pillow is used, a new image object is created whose size is the size of the halftone image corresponding to the synthesized second image, and then the pixel data of the cropped first halftone image and the pixel data of the uncropped second halftone image are copied to the corresponding positions of the new image object in sequence to complete the splicing operation. This process is repeated, and all adjacent halftone images are processed in sequence until the halftone images corresponding to all sub-images are spliced, and finally a complete halftone image corresponding to the second image is obtained.
[0187] Optionally, the halftone images corresponding to all sub-images are synthesized to obtain a halftone image corresponding to the second image, and the arrangement order of the halftone images can also be determined. After two adjacent halftone images are respectively the first halftone image and the second halftone image, for each second halftone image, the halftone values of the pixels of the overlapping part with the first halftone image and the halftone values corresponding to the overlapping pixels in the first halftone image are weightedly summed to obtain an updated halftone value.
[0188] Exemplarily, the first halftone image is the pixel points of the 191st to 300th rows of the second image, and the second halftone image is the pixel points of the 291st to 400th rows of the second image. When the first halftone image and the second halftone image are synthesized, the overlapping portion is the pixel points of the 291st to 300th rows of the second image. Therefore, the first weight corresponding to the first halftone image and the second weight corresponding to the second halftone image are determined, and then for the pixel points of the overlapping portion, the halftone value thereof is the first halftone value in the first halftone image multiplied by the first weight, plus the second halftone value in the second halftone image multiplied by the second weight, thereby obtaining the halftone value of the pixel point.
[0189] In this way, all target images are merged into a halftone image corresponding to the first image, and then the printing device prints according to this halftone image, which can output a landscape painting with high-quality halftone effect, accurately restoring the color levels and details in the original landscape painting.
[0190] For example, in order to help understand the technical concept or technical principle of the halftone method after any of the above embodiments are combined, please refer to Figure 3 , Figure 3 A brief flowchart of the half-toning method is provided as follows:
[0191] First, the total number of pixel rows of the second image and the preset number, that is, the number of pixel rows that the second sub-image has more than the first sub-image, are obtained, and the number of sub-images is determined. These parameters will be used to calculate the number of segmentation rows, where the number of segmentation rows*the number of sub-images=the total number of pixel rows of the second image. The number of segmentation rows is calculated according to the above relationship, and then the first sub-image is segmented from the head or tail of the second image based on the number of segmentation rows to obtain the first sub-image. If starting from the head, the first sub-image is the image part composed of the first K rows of pixels; if starting from the tail, it is the image part composed of the last K rows of pixels. And the first sub-image and the first second sub-image will have a preset number of rows of pixels overlapping, and the overlapping position depends on the selection position of the first sub-image. If the first sub-image starts from the head of the second image, the first second sub-image starts from the end pixel row of the first sub-image and reverses the preset number of rows of pixels, and selects the pixel points corresponding to the subsequent number of segmentation rows; if the first sub-image starts from the tail of the second image, the first second sub-image starts from the starting pixel row of the first sub-image and selects the pixel points corresponding to the subsequent number of segmentation rows. The subsequent second sub-images are analogous to each other, and each second sub-image has a preset number of rows of overlapping pixels with the previous sub-image, until the segmentation of the entire second image is completed to obtain the first sub-image and all the second sub-images.
[0192] For each sub-image, including the first sub-image and the second sub-image, the correction parameter is calculated according to the pixel coordinates of the pixel points in the sub-image and the ordered dither matrix. The specific steps are: firstly, the ordered dither threshold is calculated according to the pixel coordinates, the ordered dither matrix and the original threshold value of the error diffusion, and then the threshold is corrected based on the blue noise impact factor to obtain the correction parameter. According to the correction parameter and the original threshold value of the error diffusion, the threshold interval of the pixel point is calculated, and the threshold interval includes at least three threshold sub-intervals divided based on at least two intermediate thresholds. The pixel points in the sub-image are traversed, and the target threshold sub-interval is determined based on the relationship between the grayscale value of the pixel point and at least three threshold sub-intervals in the threshold interval. The halftone value corresponding to the target threshold sub-interval is obtained as the halftone value of the pixel point, and the quantization error is calculated based on the grayscale value of the pixel point and the lower limit value of the target threshold sub-interval. The error diffusion matrix is obtained, and the adjacent pixel points for error diffusion of the traversed pixel point and the diffusion weight of each adjacent pixel point are determined based on the matrix. According to the quantization error and the diffusion weight, the error value of each adjacent pixel point is calculated, and then the original grayscale value and the error value of the adjacent pixel point are summed to obtain the updated grayscale value of the adjacent pixel point. Based on the threshold intervals of the remaining pixel points traversed and the updated grayscale values, the halftone values of the remaining pixel points in the sub-image are determined, thereby obtaining a halftone image corresponding to each sub-image.
[0193] Since adjacent sub-images have a preset number of overlapping rows of pixels, when merging, the preset number of rows of pixels at the head of all second sub-images are deleted, and then the first sub-image and all second sub-images are spliced in order to obtain the halftone image corresponding to the second image. The printing device accurately sprays ink onto the printing paper based on the merged halftone image data to print out a painting image with high-quality halftone effect, allowing users to obtain exquisite printed works. In the whole process, the processing efficiency is improved by dividing the second image into sub-images and processing each sub-image in parallel. At the same time, the quality of halftone processing is guaranteed by using technical means such as ordered dither matrix and error diffusion, so that the final printed image can better simulate the visual effect of the second image under limited color or grayscale levels, meeting the user's demand for high-quality image printing.
[0194] Reference Figure 4 , divide the second image into N sub-images, including a first sub-image and at least one second sub-image. Determine the number of segmentation rows to be K rows, and the preset number is 10 rows. Then the first sub-image is from the 1st row to the Kth row, the first second sub-image is from the K-9th row to the 2Kth row, and so on. The number of rows with pixels in each second sub-image is 10 more than the first sub-image. Because the error of the current pixel point diffuses 10 times, the error value approaches 0. For example, for the pixel in the i-th row and j-th column, F(i,j) is the final value of the error conduction. After 10 times of error conduction, F (i,j) =(7 / 16) 10 *f (i,j) =0.000257*f (i,j) , then when the error diffusion algorithm is improved in parallel, the image needs to be split into 10 rows at most.
[0195] Suppose the image is R rows and C columns, the image is divided into N sub-images, and the R row is divided into 1K rows and N-1K+10 rows. The first sub-image is the pixels from the 1st row to the Kth row, the second sub-image is the pixels from the K-9th row to the 2*Kth row, and the Nth sub-image is the pixels from the (N-1)*K-9th row to the N*Kth row, where N*K=R. After the sub-images are divided, each sub-image is processed in parallel. For each sub-image, the threshold interval of each pixel is calculated according to the following formula:
[0196] T=t+F[x%8][y%8]%t×m
[0197] Among them, (x, y) represents the pixel position of the input image, that is, the pixel coordinates; F is the Bayer ordered dither matrix with blue noise characteristics; t is the original threshold of error diffusion, and the two t thresholds of the third-order error diffusion are 64 and 192; m is the blue noise influence factor, with a value range of (0 to 1), for example, 0.4. Then, T1 corresponding to the t threshold of 64 and T2 corresponding to the t threshold of 192 are determined respectively. Then, three threshold sub-intervals are formed according to 0, T1, T2, and 255 as the threshold interval.
[0198] Optionally, the value of the blue noise impact factor may also be 0.1, 0.2, 0.3, 0.5, 0.6, 0.7, 0.8, 0.9, etc. That is, the value of the cyanobacteria impact factor may be any value between 0 and 1, and may be reasonably set according to actual needs.
[0199] After determining the threshold range of each pixel, traverse each pixel according to the preset traversal method, referring to Figure 5 , where the preset traversal mode is serpentine raster scanning. Serpentine raster scanning has positive and negative directions for each row, that is, the positive direction is set from left to right. For example, the current row scans from left to right to the last column, and then the next row scans from right to left to the first column, and so on. In error diffusion, the Floyd matrix is used in the positive direction and the FloydNegative matrix is used in the negative direction.
[0200] During the traversal process, the halftone value of the current pixel is calculated, 0 (no spray, represented by a), 1 (small spray, represented by b), 3 (large spray, represented by d); the halftone processing of the pixel in the xth row and the yth column is performed according to the formula:
[0201]
[0202] Get the halftone value h(x,y), G (x,y) is the gray value of the current pixel; T1, T2, namely the first threshold and the second threshold in the threshold interval. Therefore, the formula for determining the halftone value is a piecewise function. If the gray value is less than or equal to the first threshold, the halftone value is determined to be 0. If the gray value is greater than the first threshold and less than or equal to the second threshold, the halftone value is determined to be 1. If the gray value is greater than the second threshold, the halftone value is determined to be 3.
[0203] Then, substituting 64 into the formula, we obtain the first threshold value T1=64+F[x%8][y%8]%64×0.4.
[0204] Substituting 192 into the formula, we get the second threshold value T2 = 192 + F [x% 8] [y% 8] % 192 × 0.4. After determining the halftone value of the current pixel, determine the quantization error E of the current pixel. (x,y) , the calculation formula is:
[0205]
[0206] Reference Figure 6 , and then diffuse the quantization error to the adjacent pixels corresponding to the current pixel. The diffusion formula is:
[0207] newG(x,y+1)=G(x,y+1)+7 / 16*E(x,y)
[0208] newG(x+1,y-1)=G(x+1,y-1)+3 / 16*E(x,y)
[0209] newG(x+1,y)=G(x+1,y)+5 / 16*E(x,y)
[0210] newG(x+1,y+1)=G(x+1,y+1)+1 / 16*E(x,y)
[0211] Among them, newG is the updated gray value. That is, for each adjacent pixel, its updated gray value is its original gray value + diffusion weight * quantization error.
[0212] According to the above method, each pixel is traversed and its halftone value is determined. After traversing all the pixels, the halftone image corresponding to each sub-image is determined. Figure 7 , and then merge the halftone images of each sub-image to obtain the halftone image corresponding to the second image. The merging method is to crop the pixels of the first 10 rows of the target image corresponding to the second sub-image; then combine the updated target image based on the arrangement order to determine the halftone image corresponding to the first image.
[0213] Reference Figure 8 , Figure 8 This is a comparison example of the halftone image before and after the halftone method of this embodiment is processed. The left side is the halftone image after the ordered dithering process, and the right side is the halftone image after the halftone method of this embodiment is processed. It can be clearly seen that the halftone image obtained by this embodiment can reduce noise and retain details. The ordered dithering reduces low-frequency noise and improves error diffusion to retain more subtle image details, thereby improving image quality. Fig. 9 , Fig. 9 This is a comparison example of the halftone image before and after being processed by the halftone method of this embodiment. The left side is the halftone image after ordered dithering, and the right side is the halftone image after being processed by the halftone method of this embodiment. It can be clearly seen that the ordered dithering algorithm has large particle artifacts in the pure color blocks, while the halftone image obtained in this embodiment reduces the large particle artifacts to small particle artifacts through ordered dithering and improved error diffusion algorithm, thereby improving image quality.
[0214] The present application provides a computer device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the halftoning method in the above-mentioned embodiment 1.
[0215] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer device suitable for implementing the embodiment of the present application. The computer device in the embodiment of the present application may include but is not limited to a computer, a mobile phone, a tablet, etc., and may also be an inkjet printing device, which are not listed here one by one. Fig.10 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0216] like Fig.10 As shown, the computer device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the computer device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the computer device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a computer device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0217] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0218] The computer device provided by the present application adopts the halftone method in the above embodiment, which can solve the technical problem that the continuous transmission and accumulation of errors in the image will lead to a decrease in the contrast of the image, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer device provided by the present application are the same as those of the computer device provided by the above embodiment, and other technical features in the computer device are the same as those disclosed in the method of the previous embodiment, which will not be repeated here.
[0219] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0220] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0221] The present application provides a printing system, referring to Fig.11 , including a host computer and inkjet printing equipment;
[0222] The host computer is used to obtain a first image, and perform halftone processing on the first image based on the halftone method in any of the above embodiments to obtain a halftone image and send it to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone image; or,
[0223] The host computer is used to obtain a first image and send the first image to the inkjet printing device; the inkjet printing device is used to halftone the first image based on the halftone method in any of the above embodiments to obtain a halftone image, and print the first image based on the halftone image.
[0224] The present application provides a halftone device, referring to Fig.12 The halftone device 1200 includes: an ordered dithering processing module 1201 , a first determining module 1202 , an error diffusion module 1203 , a second determining module 1204 and a generating module 1205 .
[0225] An ordered dithering processing module 1201 is used to perform ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image;
[0226] A first determination module 1202, configured to traverse the pixels of the first image, and determine the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold interval;
[0227] The error diffusion module 1203 is used to diffuse the quantization error to the neighboring pixel points of the traversed pixel point to update the grayscale value of the neighboring pixel points;
[0228] A second determination module 1204 is used to determine the halftone values of the remaining pixels of the first image based on the threshold intervals and updated grayscale values of the remaining pixels traversed;
[0229] The generating module 1205 is configured to generate a halftone image corresponding to the first image based on the halftone values of all pixels.
[0230] The ordered dither processing module 1201 is further used to calculate a correction parameter according to the pixel coordinates of the pixel point and the ordered dither matrix; and to calculate a threshold interval of the pixel point according to the correction parameter and the original error diffusion threshold.
[0231] The ordered jitter processing module 1201 is further used to calculate an ordered jitter threshold according to the pixel coordinates of the pixel point, the ordered jitter matrix and the error diffusion original threshold; and to correct the ordered jitter threshold based on the blue noise influence factor to obtain the correction parameter.
[0232] The ordered jitter processing module 1201 is also used to determine the order of the ordered jitter matrix; take the modulus of the pixel coordinates with the order to obtain element coordinates; determine the elements in the ordered jitter matrix based on the element coordinates, and the elements are the data at the element coordinates in the ordered jitter matrix; take the modulus of the element with the error diffusion original threshold to obtain the ordered jitter threshold.
[0233] The first determination module 1202 is further used to determine the target threshold sub-interval based on the relationship between the grayscale value of the traversed pixel point and the at least three threshold sub-intervals; obtain the halftone value corresponding to the target threshold sub-interval, and determine it as the halftone value of the traversed pixel point; calculate the quantization error based on the grayscale value of the traversed pixel point and the lower limit value of the target threshold sub-interval.
[0234] The error diffusion module 1203 is also used to obtain an error diffusion matrix, and determine the adjacent pixel points for error diffusion of the traversed pixel points and the diffusion weight of each of the adjacent pixel points based on the error diffusion matrix; calculate the error value of each of the adjacent pixel points according to the quantization error and the diffusion weight; sum the original grayscale value of the adjacent pixel points and the error value to obtain the updated grayscale value of the adjacent pixel points.
[0235] The halftone device also includes a segmentation module, which is used to segment the second image into multiple sub-images in sequence, wherein the multiple sub-images include a first sub-image and at least one second sub-image, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, and the first sub-image and the at least one second sub-image are both the first image.
[0236] A segmentation module is used to determine the number of segmentation rows based on the total number of pixel rows of the second image and the number of sub-images; segment the head or tail of the second image based on the number of segmentation rows to obtain the first sub-image; and segment the second image in sequence based on the starting pixel row or the ending pixel row of the first sub-image, a preset number of rows of pixels, and the number of segmentation rows to obtain a second sub-image adjacent to the first sub-image and the rest of the second sub-images.
[0237] The halftone device further includes a merging module, which is used to synthesize the halftone images corresponding to all the sub-images to obtain a halftone image corresponding to the second image.
[0238] A merging module is used to determine the arrangement order of each of the halftone images, where two adjacent halftone images are respectively the first halftone image and the second halftone image; cropping the second halftone image to crop out a preset number of rows of pixels in the second halftone image that overlap with the first halftone image; and splicing the cropped partial halftone image and the uncropped partial halftone image based on the arrangement order to obtain a halftone image corresponding to the second image.
[0239] See also Fig.13The embodiment of the present application also provides an inkjet printing device 200, which includes a processor 230 and a print head 212. The processor 230 is used to obtain a halftone image of the image to be printed generated based on the halftone method described in any of the above embodiments, and then control the print head 212 to print the image to be printed based on the halftone image.
[0240] Further, refer to Fig.13 In some embodiments, the inkjet printing device 200 specifically includes:
[0241] A printing assembly 210, the printing assembly comprising a slide rail 211 and a print head 212, wherein the print head 212 is slidably disposed on the slide rail 211;
[0242] A memory 220, wherein a computer program product executable by a processor is stored in the memory;
[0243] Processor 230, the processor is used to obtain a halftone image of the image to be printed generated by the halftone method described in any of the above embodiments, and then control the print head to move on the slide rail and control the inkjet of the print head based on the halftone image to print out the image to be printed.
[0244] The inkjet printing device 200 may receive a halftone image of an image to be printed generated based on the halftone method described in any of the above embodiments; or generate a halftone image of an image to be printed based on the halftone method described in any of the above embodiments.
[0245] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the halftoning method in the above-mentioned embodiment.
[0246] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0247] The computer-readable storage medium may be included in the computer device; or may exist independently without being installed in the computer device.
[0248] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by a computer device, the computer device: performs orderly dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image; traverses the pixels of the first image, and determines the halftone value and quantization error of the traversed pixel based on the grayscale value of the traversed pixel and the threshold interval; diffuses the quantization error to the adjacent pixels of the traversed pixel to update the grayscale value of the adjacent pixel; determines the halftone value of the remaining pixels of the first image based on the threshold interval and the updated grayscale value of the remaining traversed pixel, and obtains a halftone map corresponding to the first image.
[0249] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0250] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0251] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0252] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned halftone method, and can solve the technical problem that the continuous transmission and accumulation of errors in the image will lead to a decrease in the contrast of the image, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the halftone method provided by the above-mentioned embodiment, and will not be repeated here.
[0253] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the above-mentioned halftoning method when executed by a processor.
[0254] The computer program product provided by the present application can solve the technical problem that the continuous transmission and accumulation of errors in an image will lead to a decrease in the contrast of the image, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the halftone method provided by the above embodiment, and will not be repeated here.
[0255] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A half-toning method, characterized in that The half-toning method includes: Performing ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image; Traversing the pixels of the first image, and determining the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold interval; Diffusion of the quantization error to the neighboring pixel points of the traversed pixel point, so as to update the grayscale value of the neighboring pixel points; Determine halftone values of remaining pixels of the first image based on the threshold intervals and updated grayscale values of the remaining pixels traversed; Based on the halftone values of all pixels, a halftone image corresponding to the first image is generated.
2. The half-toning method according to claim 1, wherein: The step of performing orderly dithering processing on the first image based on the ordered dithering matrix to obtain the threshold interval of each pixel point in the first image includes: Calculating correction parameters according to the pixel coordinates of the pixel point and the ordered dither matrix; The threshold interval of the pixel point is calculated according to the correction parameter and the original error diffusion threshold.
3. The half-toning method according to claim 2, wherein: The step of calculating the correction parameter according to the pixel coordinates of the pixel point and the ordered dither matrix comprises: Calculating an ordered dithering threshold value according to the pixel coordinates of the pixel point, the ordered dithering matrix and the error diffusion original threshold value; The ordered jitter threshold is corrected based on the blue noise impact factor to obtain the correction parameter.
4. The half-toning method according to claim 3, wherein: The step of calculating the ordered dithering threshold according to the pixel coordinates of the pixel point, the ordered dithering matrix and the error diffusion original threshold comprises: Determining the order of the ordered dither matrix; Taking the modulus of the pixel coordinates with respect to the order to obtain element coordinates; Determine an element in the ordered jitter matrix based on the element coordinates, the element being data at the element coordinates in the ordered jitter matrix; The ordered dithering threshold is obtained by taking the modulus of the element with respect to the error diffusion original threshold.
5. The half-toning method according to claim 1, wherein: The threshold interval includes at least three threshold sub-intervals divided by at least two intermediate thresholds, the at least three threshold sub-intervals respectively correspond to at least three halftone values, and determining the halftone value and quantization error of the traversed pixel point based on the grayscale value of the traversed pixel point and the threshold interval includes: Determine a target threshold subinterval based on a relationship between the grayscale value of the traversed pixel point and the at least three threshold subintervals; Obtaining a halftone value corresponding to the target threshold subinterval, and determining it as the halftone value of the traversed pixel point; The quantization error is calculated based on the grayscale value of the traversed pixel point and the lower limit value of the target threshold sub-interval.
6. The half-toning method according to claim 1, wherein: The step of diffusing the quantization error to adjacent pixels of the traversed pixel to update the grayscale values of the adjacent pixels comprises: Acquire an error diffusion matrix, and determine the neighboring pixel points for error diffusion of the traversed pixel point and the diffusion weight of each of the neighboring pixel points based on the error diffusion matrix; Calculating an error value of each of the adjacent pixels according to the quantization error and the diffusion weight; The original grayscale values of the adjacent pixels and the error value are summed to obtain updated grayscale values of the adjacent pixels.
7. The half-toning method according to any one of claims 1 to 6, characterized in that: Before the step of performing ordered dithering processing on the first image based on the ordered dithering matrix to obtain the threshold interval of each pixel point in the first image, the method further includes: The second image is divided into multiple sub-images in sequence, wherein the multiple sub-images include a first sub-image and at least one second sub-image, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap the preset number of rows of pixels, and the first sub-image and the at least one second sub-image are both the first image.
8. The half-toning method according to claim 7, wherein: The step of sequentially dividing the second image into a plurality of sub-images comprises: Determine the number of segmentation rows based on the total number of pixel rows of the second image and the number of the sub-images; Segmenting the head or tail of the second image based on the segmentation line number to obtain the first sub-image; Based on the starting pixel row or the ending pixel row of the first sub-image, the preset number of rows of pixels, and the number of segmentation rows, the second image is segmented in sequence to obtain the second sub-image adjacent to the first sub-image and the rest of the second sub-image.
9. The half-toning method according to claim 7, wherein: After obtaining the halftone images corresponding to the sub-images, the halftone method further includes: The halftone images corresponding to all the sub-images are synthesized to obtain a halftone image corresponding to the second image.
10. The half-toning method according to claim 9, wherein: The step of synthesizing the halftone images corresponding to all the sub-images to obtain the halftone image corresponding to the second image includes: Determine an arrangement order of the halftone images, wherein two adjacent halftone images are respectively a first halftone image and a second halftone image; Cropping the second halftone image to crop a preset number of rows of pixels in the second halftone image that overlap with the first halftone image; The cropped portion of the halftone image and the uncropped portion of the halftone image are spliced based on the arrangement order to obtain a halftone image corresponding to the second image.
11. A half-tone device, characterized in that: include: An ordered dithering processing module, used to perform ordered dithering processing on the first image based on an ordered dithering matrix to obtain a threshold interval of each pixel in the first image; A first determination module, configured to traverse the pixels of the first image, and determine the halftone value and quantization error of the traversed pixels based on the grayscale values of the traversed pixels and the threshold interval; An error diffusion module, used for diffusing the quantization error to adjacent pixels of the traversed pixel point, so as to update the grayscale value of the adjacent pixel point; A second determination module, configured to determine halftone values of remaining pixel points of the first image based on the threshold intervals and updated grayscale values of the remaining pixel points traversed; A generating module is used to generate a halftone image corresponding to the first image based on the halftone values of all pixels.
12. A computer device, characterized in that: The computer device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the halftoning method according to any one of claims 1 to 10.
13. An inkjet printing device, characterized in that: The inkjet printing device comprises a processor and a print head, wherein the processor is used to obtain a halftone image obtained based on the steps of the halftone method according to any one of claims 1 to 10, and control the print head to print an image based on the halftone image.
14. A printing system, characterized in that: The printing system includes a host computer and an inkjet printing device; The host computer is used to obtain a first image, and perform halftone processing on the first image based on the halftone method described in any one of claims 1 to 10 to obtain a halftone image and send it to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone image; or, The host computer is used to obtain a first image and send the first image to the inkjet printing device; the inkjet printing device is used to perform halftone processing on the first image based on the halftone method described in any one of claims 1 to 10 to obtain a halftone image, and print the first image based on the halftone image.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the halftoning method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Generation of dither matrix
CN101830114A
Image processing device, printing device, image processing method, and image processing program
CN102689503A
Grayscale image halftone method and device, equipment and storage medium
CN110910305A
Halftone image generation method and image processing system and computer program product thereof
US20130307867A1