Halftoning method, apparatus, device, printing system, and storage medium
By combining an ordered dithering matrix and an error diffusion algorithm, the problem of noise affecting print quality in halftone processing is solved, achieving higher quality image printing results.
Patent Information
- Application Number
- CN202411894335.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-12-20
AI Technical Summary
In existing technologies, halftone processing adds noise that affects print quality, causing image details in high-precision scenes to be masked by jitter noise, thus affecting image quality.
An ordered dithering process based on an ordered dithering matrix is used to perform ordered dithering on the image, the threshold range of the pixels is determined, and the quantization error is diffused to the adjacent pixels through an error diffusion algorithm to update the grayscale value and finally generate a halftone image.
It reduces noise, preserves more subtle image details, and improves image printing quality.
Smart Images

Figure CN119766938B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more particularly to a halftone method, apparatus, device, printing system, and storage medium. Background Technology
[0002] Halftone processing converts a continuous-tone image into an image composed of dots of different sizes and spacings so that it can be reproduced on printing or display devices.
[0003] In related technologies, noise is added during halftone processing to mask quantization errors, resulting in additional noise in the final output signal. Although this noise is usually random and difficult to detect, it can affect printing quality in certain high-precision scenarios, and subtle image details may be masked by jitter noise, thus affecting the quality of the printed image. Summary of the Invention
[0004] The main objective of this application is to provide a halftone method, apparatus, device, printing system, and storage medium, which aims to solve the technical problem in the related art where the added noise affects the print quality during halftone processing.
[0005] To achieve the above objectives, this application provides a halftone method, the halftone method comprising:
[0006] The first image is subjected to ordered jitter processing based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image.
[0007] The pixels of the first image are traversed, and the halftone value and quantization error of the traversed pixels are determined based on the gray value of the traversed pixels and the threshold range.
[0008] The quantization error is propagated to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixel;
[0009] Based on the threshold range of the remaining pixels traversed and the updated grayscale value, the halftone value of the remaining pixels of the first image is determined.
[0010] A halftone map corresponding to the first image is generated based on the halftone values of all pixels.
[0011] In one embodiment, the step of performing ordered jitter processing on the first image based on an ordered jitter matrix to obtain the threshold range of each pixel in the first image includes:
[0012] The correction parameters are calculated based on the pixel coordinates of the pixel and the ordered jitter matrix;
[0013] The threshold range of the pixel is calculated based on the correction parameters and the original threshold for error diffusion.
[0014] In one embodiment, the step of calculating the correction parameters based on the pixel coordinates of the pixel and the ordered jitter matrix includes:
[0015] The ordered jitter threshold is calculated based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion threshold.
[0016] The correction parameter is obtained by correcting the ordered jitter threshold based on the blue noise impact factor.
[0017] In one embodiment, the step of calculating the ordered jitter threshold based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion threshold includes:
[0018] Determine the order of the ordered jitter matrix;
[0019] The element coordinates are obtained by taking the remainder of the pixel coordinates with respect to the order.
[0020] The elements in the ordered jitter matrix are determined based on the element coordinates, and the elements are the data at the element coordinates in the ordered jitter matrix;
[0021] The ordered jitter threshold is obtained by taking the remainder of the element with respect to the original error diffusion threshold.
[0022] In one embodiment, the threshold interval includes at least three threshold sub-intervals divided by at least two intermediate thresholds, each of the at least three threshold sub-intervals corresponding to at least three halftone values. Determining the halftone value and quantization error of the traversed pixels based on the grayscale value of the traversed pixels and the threshold interval includes:
[0023] Based on the relationship between the gray values of the traversed pixels and the at least three threshold sub-intervals, the target threshold sub-interval is determined;
[0024] Obtain the halftone value corresponding to the target threshold sub-interval, and determine it as the halftone value of the traversed pixel;
[0025] The quantization error is calculated based on the grayscale values of the traversed pixels and the lower limit of the target threshold sub-interval.
[0026] In one embodiment, the step of spreading the quantization error to the neighboring pixels of the traversed pixel to update the grayscale values of the neighboring pixels includes:
[0027] Obtain the error diffusion matrix, and determine the neighboring pixels of the traversed pixels for error diffusion based on the error diffusion matrix, as well as the diffusion weight of each neighboring pixel;
[0028] Based on the quantization error and the diffusion weight, the error value of each of the adjacent pixels is calculated;
[0029] The original grayscale values of the adjacent pixels are summed with the error value to obtain the updated grayscale values of the adjacent pixels.
[0030] In one embodiment, before the step of performing ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image, the method further includes:
[0031] The second image is sequentially divided into multiple sub-images, including 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 by the preset number of rows of pixels. 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 multiple sub-images includes:
[0033] The number of segmentation rows is determined based on the total number of pixel rows in the second image and the number of sub-images;
[0034] The first sub-image is obtained by segmenting the head or tail of the second image based on the number of segmentation rows.
[0035] Based on the starting or ending pixel row of the first sub-image, a preset number of rows of pixels, and the number of segmentation rows, the second image is segmented sequentially to obtain a second sub-image adjacent to the first sub-image and the remaining second sub-images.
[0036] In one embodiment, after obtaining the halftone images corresponding to each of the sub-images, the halftone method further includes:
[0037] The halftone images corresponding to all the sub-images are synthesized to obtain the 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] The arrangement order of the halftone images is determined, and two adjacent halftone images are respectively the first halftone image and the second halftone image;
[0040] The second halftone image is cropped to remove a preset number of rows of pixels that overlap with the first halftone image.
[0041] Based on the stated arrangement order, the cropped halftone image and the uncropped halftone image are stitched together to obtain the halftone image corresponding to the second image.
[0042] In addition, to achieve the above objectives, this application also provides a halftone device, comprising:
[0043] The ordered jitter processing module is used to perform ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image;
[0044] The first determining module is used to traverse the pixels of the first image and determine the halftone value and quantization error of the traversed pixels based on the gray value of the traversed pixels and the threshold range.
[0045] The error diffusion module diffuses the quantization error to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixels.
[0046] The second determining module determines the halftone values of the remaining pixels in the first image based on the threshold range of the remaining pixels traversed and the updated grayscale values.
[0047] The generation module generates a halftone map corresponding to the first image based on the halftone values of all pixels.
[0048] In addition, to achieve the above objectives, this application also provides a computer device, the computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the halftone method as described above.
[0049] In addition, to achieve the above objectives, this application also provides an inkjet printing device, which includes a processor and a printhead. The processor is used to acquire a halftone map obtained based on the steps of the halftone method described above, and to control the printhead to print an image based on the halftone map.
[0050] In addition, to achieve the above objectives, this 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 acquire the first image and perform halftone processing on the first image based on the halftone method described above, obtaining a halftone map, and then sending it to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone map; or,
[0052] The host computer is used to acquire the 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 map, and print the first image based on the halftone map.
[0053] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a computer program implementing the halftone method, the computer program implementing the halftone method being executed by a processor to implement the steps of the halftone method as described above.
[0054] This application provides a halftone method. First, an ordered dithering process is applied to a first image based on an ordered dithering matrix to obtain a threshold range for each pixel in the first image. Then, the pixels of the first image are traversed, and based on the grayscale values of the traversed pixels and the threshold ranges, the halftone values and quantization errors of the traversed pixels are determined. The quantization error is propagated to the neighboring pixels of the traversed pixels to update the grayscale values of the neighboring pixels. Based on the threshold ranges of the remaining traversed pixels and the updated grayscale values, the halftone values of the remaining pixels in the first image are determined. Based on the halftone values of all pixels, a halftone image corresponding to the first image is generated. In other words, each pixel in this application has a dynamic threshold range, and the quantization error is propagated to neighboring pixels to update their grayscale values. After the error is propagated, the grayscale value of each pixel is compared with its dynamic threshold range to determine the corresponding halftone value. By combining ordered dithering and error propagation, noise is reduced, and more subtle image details are preserved, thereby improving image printing quality. Attached Figure Description
[0055] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0056] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 This is a flowchart illustrating steps S10-S50 in one embodiment of the halftone method of this application.
[0058] Figure 2This is a flowchart illustrating steps S111-S112 in one embodiment of the halftone method of this application;
[0059] Figure 3 This is a schematic diagram of the overall process provided in one embodiment of the halftone method of this application;
[0060] Figure 4 This is a schematic diagram of segmenting a first image provided in one embodiment of the halftone method of this application;
[0061] Figure 5 This is a schematic diagram of the traversal method provided in one embodiment of the halftone method of this application;
[0062] Figure 6 This is a schematic diagram illustrating the error propagation to adjacent pixels in one embodiment of the halftone method of this application.
[0063] Figure 7 This is a schematic diagram of a merged halftone image provided in one embodiment of the halftone method of this application;
[0064] Figure 8 This is a comparison image of a halftone example provided in one embodiment of the halftone method of this application;
[0065] Figure 9 This is a comparison image of another halftone example provided in one embodiment of the halftone method of this application;
[0066] Figure 10 This is a schematic diagram of the hardware structure involved in the computer device embodiments of this application;
[0067] Figure 11 This is a schematic diagram of the hardware structure involved in the printing system embodiment of this application;
[0068] Figure 12 This is a schematic diagram of the hardware structure involved in the halftone device embodiment of this application;
[0069] Figure 13 This is a schematic diagram of the structure of an inkjet printing device according to some embodiments of this application.
[0070] Explanation of icon 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 jitter processing module 1201; first determination module 1202; error diffusion module 1203; second determination module 1204; generation module 1205.
[0072] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0073] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0074] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0075] Currently, the principle of error diffusion algorithms is to process each pixel of an image one by one, comparing the brightness value of the current pixel with a threshold to determine its output color. Then, the processing error of the current pixel—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 takes into account the errors of previous pixels, resulting in a more uniform tone across the entire image. This can produce a relatively smooth halftone effect, but it involves relatively high computational costs and is slow to process.
[0076] The main solution of this application is as follows: First, an ordered dithering process is performed on a first image based on an ordered dithering matrix to obtain a threshold range for each pixel in the first image; the pixels of the first image are traversed, and based on the grayscale values of the traversed pixels and the threshold ranges, the halftone values and quantization errors of the traversed pixels are determined; the quantization error is propagated to the neighboring pixels of the traversed pixels to update the grayscale values of the neighboring pixels; based on the threshold ranges of the remaining traversed pixels and the updated grayscale values, the halftone values of the remaining pixels in the first image are determined; based on the halftone values of all pixels, a halftone map corresponding to the first image is generated.
[0077] In this application, each pixel has a dynamic threshold range, and the quantization error is propagated to adjacent pixels to update the grayscale value of adjacent pixels. After the error is propagated, the grayscale value of each pixel is compared with its dynamic threshold range to determine the halftone value corresponding to the pixel. By combining ordered dithering and error propagation, noise is reduced and more subtle image details can be preserved, thereby improving the image printing quality.
[0078] It should be noted that the execution subject of the halftone method in this embodiment can be a host computer, or a computer device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, or tablet, or an inkjet printing device capable of the above functions, or a printing system, or a halftone device. This embodiment does not specifically limit it in this way. The following uses the host computer of the inkjet printing device as the execution subject as an example to describe this embodiment and the following embodiments. The inkjet printing device as the execution subject is similar and will not be described in detail here.
[0079] Based on this, one embodiment of this application proposes a halftone method, please refer to... Figure 1 The halftone method includes steps S10 to S50:
[0080] Step S10: Perform ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image.
[0081] In this embodiment, the ordered dithering matrix is a matrix with a specific arrangement of element values. Its size and element values can be preset according to actual needs, and different ordered dithering matrices will produce different halftone effects. In this scheme, it is used to determine a threshold range for pixels. The threshold range is a specific numerical range. In one embodiment, the threshold range has a first threshold and a second threshold, and the threshold range is divided into three threshold sub-ranges based on the first and second thresholds. The threshold range is used to determine the halftone value of the pixel.
[0082] As an optional implementation, for each pixel, the threshold range of each pixel is determined based on the pixel coordinates, the ordered jitter matrix, and the original threshold for error diffusion.
[0083] For example, for a first pixel, a first threshold is determined based on its first pixel coordinates, ordered jitter matrix, and first error diffusion original threshold. Then, a second threshold is determined based on the first pixel coordinates, ordered jitter matrix, and second error diffusion original threshold. Based on the first threshold and the second threshold, three threshold sub-intervals can be determined, which are then combined into a threshold interval.
[0084] As an optional implementation, for each pixel in the first image, its corresponding threshold range can be determined by mapping its position information in the first image to an ordered dithering matrix. For example, assuming the ordered dithering matrix is of size M*N, and the pixel is (x, y), where x and y are the row and column coordinates of the pixel in the first image, the pixel's position coordinates in the first image will correspond to a certain element or combination of elements in the ordered dithering matrix. Based on this correspondence and the characteristics of the ordered dithering matrix, the threshold range for that pixel can be determined. Determining this threshold range involves scaling and offsetting matrix element values to adapt to the characteristics of the image pixels and the requirements of halftone processing.
[0085] As an optional implementation, the threshold range for each pixel is determined by combining an ordered dithering matrix and an error diffusion algorithm. When the error diffusion is third-order diffusion, the threshold range includes a first threshold and a second threshold, with the first threshold being the left endpoint and the second threshold being the right endpoint. Alternatively, in the threshold range, 0 is the left endpoint, the second threshold is the right endpoint, and the first threshold is between 0 and the second threshold. When the error diffusion is fourth-order diffusion, the threshold range includes a first threshold, a second threshold, and a third threshold, where 0 is the left endpoint, the third threshold is the right endpoint, the second threshold is greater than the third threshold, and the second threshold is less than the third threshold; the first threshold is less than the second threshold. Error diffusion processing is an image processing method. It primarily spreads the error generated by processing the current pixel to surrounding unprocessed pixels, making the image tone more uniform. This application uses third-order diffusion as an example for illustration; the principles of fourth-order, fifth-order, and higher-order diffusion are similar and will not be elaborated here. Third-order diffusion indicates that two different levels of thresholds are involved in the processing.
[0086] Step S20: Traverse the pixels of the first image, and determine the halftone value and quantization error of the traversed pixels based on the grayscale value of the traversed pixels and the threshold range.
[0087] In this embodiment, traversal refers to sequentially visiting each pixel in the first image according to a certain order, ensuring that each pixel is processed accordingly. Halftone values are quantized values used in halftone processing to represent a pixel's value at a limited number of color or grayscale levels. Halftone values are determined by a threshold range, allowing the original information of the pixel to be converted into a halftone representation, thereby simulating the visual effect of the first image using a limited number of colors or grayscale levels. Quantization error can be the difference between the pixel's grayscale value and either the first or second threshold within the threshold range. This difference can propagate to neighboring pixels to change their grayscale values.
[0088] As an optional implementation, starting from the top left corner of the first image, pixels are selected sequentially 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 selected as the current pixel, then the pixel in the first row and second column is selected, and so on, until all pixels of the entire first image have been traversed.
[0089] As an optional implementation, each pixel in the first image is accessed sequentially from left to right, top to bottom, or other predetermined traversal order. For each traversed pixel, its original brightness, grayscale value, or other relevant attribute value is compared with a first threshold or a second threshold within a threshold range. The halftone value of the pixel is determined based on the comparison result. For example, if the grayscale value of a pixel falls within a certain threshold range, its halftone value is set to a specific value corresponding to that range. Then, the difference between the halftone value and the first or second threshold is calculated, and the difference result is used as the quantization error.
[0090] Step S30: The quantization error is spread to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixel.
[0091] In this embodiment, adjacent pixels are determined based on the traversed pixels and according to preset rules.
[0092] As an optional implementation, when the current traversal method is from left to right, adjacent pixels are determined by ranking the pixels to the right, next, bottom left, and bottom right based on the traversed pixel. When the current traversal method is from right to left, adjacent pixels are determined by ranking the pixels to the left, next, bottom left, and bottom right based on the traversed pixel. After determining adjacent pixels, the quantization error is propagated to adjacent pixels to update their grayscale values.
[0093] Step S40: Based on the threshold range of the remaining pixels traversed and the updated grayscale value, determine the halftone value of the remaining pixels of the first image.
[0094] Step S50: Based on the halftone values of all pixels, generate the halftone map corresponding to the first image.
[0095] In this embodiment, the halftone value of each pixel in the first image is updated to the corresponding pixel position. In this way, all pixels in the first image have a defined halftone value, thus forming a new image, namely a halftone image. This process completes the conversion from the second image to a halftone image.
[0096] For example, in an inkjet printer, to print a first image, the photo size is 5000*3000 pixels. When processing the image, the printer first uses a landscape photo as the first image. Then, for each pixel in the image, an ordered dithering matrix stored internally by the printer is used to determine a threshold range. For the pixel at coordinates (100, 200) in the first image, the printer maps it to an element or combination of elements in the ordered dithering matrix based on its relative position in the sub-image. A specific algorithm, combining the value of this element or combination of elements with the pixel's original color information, determines the threshold range for that pixel. For example, the threshold range might have two thresholds of 128 and 255; this threshold range is used to subsequently determine the pixel's halftone value to determine its color representation after halftone processing. This operation is performed for each pixel in the first image. After determining the threshold range, the inkjet printer begins traversing the pixels in the first image. For the first image, starting from the top-left pixel, it visits pixels in a left-to-right, top-to-bottom order. For example, if a pixel with a grayscale value of 70 is accessed, its corresponding halftone value is determined based on the position of the grayscale value within a threshold range. For each pixel in the entire sub-image, its grayscale value is compared with the threshold range in this way to determine the halftone value. In this way, the first image is converted from the original landscape photograph into a halftone image. For instance, the sky, which originally had continuously changing colors, is presented with a limited number of colors or grayscale levels after this process, making it more suitable for printing. Finally, the first image is printed based on the halftone image, providing the user with a high-quality landscape photograph.
[0097] This application first performs ordered dithering processing on a first image based on an ordered dithering matrix to obtain the threshold range of each pixel in the first image; it then traverses the pixels of the first image and determines the halftone value and quantization error of the traversed pixels based on the grayscale value of the traversed pixels and the threshold range; it then spreads the quantization error to the neighboring pixels of the traversed pixels to update the grayscale value of the neighboring pixels; based on the threshold range of the remaining traversed pixels and the updated grayscale value, it determines the halftone value of the remaining pixels in the first image; and based on the halftone values of all pixels, it generates a halftone image corresponding to the first image. In other words, this application has a dynamic threshold range for each pixel, allowing each pixel to be compared with its dynamic threshold range after error propagation, thus determining a more flexible quantization error. This solves the technical problem that continuous propagation and accumulation of errors in the image leads to a decrease in image contrast, thereby affecting the visual effect of the image, and achieves the technical effect of improving image contrast.
[0098] Based on any embodiment, in one possible embodiment of this application, step S10 includes steps S11-S12:
[0099] Step S11: Calculate the correction parameters based on the pixel coordinates of the pixel and the ordered jitter matrix.
[0100] In this embodiment, pixel coordinates refer to the coordinate information of a pixel in the first or second sub-image, typically including row and column coordinates. This positional information is crucial for determining the correction parameters, as pixels at different positions have different mapping relationships within the ordered jitter matrix. The correction parameter is used to adjust the threshold range; it is calculated based on the pixel's mapping result in the ordered jitter matrix, and its value varies depending on the pixel's position, thus providing a personalized threshold adjustment basis for each pixel.
[0101] As an alternative implementation, pixel coordinates are substituted into an ordered jitter matrix to determine the value of the ordered jitter matrix, and then the correction parameters are determined based on the value.
[0102] Optionally, refer to Figure 2 Step S11 includes steps S111-S112:
[0103] Step S111: Calculate the ordered jitter threshold based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion threshold.
[0104] As an optional implementation, the pixel coordinates are substituted into the ordered jitter matrix to determine the value of the ordered jitter matrix, and then the ordered jitter threshold is determined based on the value and the original error diffusion threshold.
[0105] As another optional implementation, the order of the ordered jitter matrix is determined; the pixel coordinates are moduloed by the order to obtain element coordinates; the elements in the ordered jitter matrix are determined based on the element coordinates; and the elements are moduloed by the original error diffusion threshold to obtain the ordered jitter threshold.
[0106] For example, the order of the ordered jitter matrix is obtained. For each pixel that is traversed, its pixel coordinates are determined, which are divided into the first horizontal coordinate and the first column coordinate. Then, the first horizontal coordinate is modulo the order to obtain the second horizontal coordinate. The first column coordinate is modulo the order to obtain the second column coordinate. The second horizontal coordinate and the second column coordinate are used as the element coordinates in the ordered jitter matrix. The corresponding element is determined in the ordered jitter matrix based on the element coordinates. The original error diffusion threshold is calculated by taking the remainder of the element, and the ordered jitter threshold is obtained.
[0107] Step S112: Correct the ordered jitter threshold based on the blue noise influence 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 original threshold for error diffusion.
[0109] As an alternative implementation, the product of the ordered jitter threshold and the blue noise influence factor is used as the correction parameter.
[0110] Step S12: Calculate the threshold range of the pixel based on the correction parameters and the original threshold for error diffusion.
[0111] In this embodiment, the initial error diffusion threshold is a basic threshold parameter pre-set in the error diffusion algorithm, providing a basic range for determining the threshold interval. In third-order error diffusion, there are two initial error diffusion thresholds. By combining the correction coefficient, a threshold interval that better reflects the characteristics of each pixel can be obtained. The threshold interval is a numerical range containing the first threshold and the second threshold, used for subsequent determination of the halftone value of the pixel.
[0112] As an optional implementation, for each original error diffusion threshold, a correction parameter is determined based on the pixel position, the ordered jitter matrix, the original error diffusion threshold, and the blue noise influence factor. Then, the sum of the correction parameter and the original error diffusion threshold is used as the corrected error diffusion threshold. Since there are two original error diffusion thresholds, two error diffusion thresholds are calculated: a first threshold and a second threshold. A threshold interval is then formed based on the first and second thresholds.
[0113] For example, the two endpoints of the threshold interval are the first threshold and the second threshold.
[0114] For example, 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 range from 0 to the first threshold forms the first threshold sub-interval, the range from the first threshold to the second threshold forms the second threshold sub-interval, and the range from the second threshold to infinity or 255 forms the third threshold sub-interval. The first threshold sub-interval, the second threshold sub-interval, and the third threshold sub-interval then constitute the threshold interval.
[0115] For example, the calculation formula is shown below;
[0116] T = t + F[x%8][y%8]%t × m
[0117] Where T is the calculated error diffusion threshold, (x,y) represents the pixel coordinates of the input pixel; F is the Bayer ordered jitter matrix with blue noise characteristics; t is the original error diffusion threshold, and the two original thresholds t for third-order error diffusion are 64 and 192; m is the blue noise influence factor, with a value range of (0~1), % refers to the remainder calculation, A%B refers to the remainder when A is divided by B. F[x%8][y%8] represents the element with coordinates (x%8,y%8) in the matrix, F[x%8][y%8]%t represents the remainder of the element with respect to t, the closer m is to 0, the closer the error diffusion threshold is to the original fixed value, the closer m is to 1, the closer the error diffusion threshold is to the jitter threshold.
[0118] As an example, a Bayer ordered jitter matrix:
[0119]
[0120] As an example, the blue noise impact factor is 0.4.
[0121] Substituting 64 into the formula, we obtain the first threshold T1 = 64 + F[x%8][y%8]%64 × 0.4.
[0122] Substituting 192 into the formula, we get the second threshold T2 = 192 + F[x%8][y%8]%192 × 0.4.
[0123] For example, the currently traversed pixel has coordinates (12, 17). Therefore, 12 modulo 8 equals 4, and 17 modulo 8 equals 1. Thus, the element with coordinates (4, 1) in matrix F is taken as F(4, 1), resulting in a value of 60. Substituting this value into the calculation formula, we obtain the first threshold T1 = 64 + 60% 64 × 0.4 = 64 + 24 = 88, and the second threshold T2 = 192 + 60% 192 × 0.4 = 192 + 24 = 216.
[0124] By employing an ordered dithering matrix to improve the error threshold in error diffusion, each pixel has a dynamic threshold range when determining its halftone value. This, combined with ordered dithering and the improved error diffusion algorithm, reduces large-grain artifacts in the image to small-grain artifacts, thereby improving image quality.
[0125] Based on any embodiment, in one possible embodiment of this application, step S20 includes steps S21-S23:
[0126] Step S21: Determine the target threshold sub-interval based on the relationship between the gray values of the traversed pixels 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 each of the at least three threshold sub-intervals corresponds to at least three halftone values. Within all the threshold sub-intervals, by comparing the grayscale value of the currently traversed pixel with the threshold sub-interval, the specific threshold sub-interval into which the grayscale value of the pixel ultimately falls is determined. The halftone value corresponding to the pixel will then be determined based on this interval.
[0128] First, obtain the grayscale value of the currently traversed pixel. Then, compare this grayscale value with each pre-defined threshold sub-interval to determine which sub-interval it falls into. 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; and 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 determined by comparison that it falls into Interval 1. Therefore, Interval 1 is the target threshold sub-interval corresponding to this pixel.
[0129] Step S22: Obtain the halftone value corresponding to the target threshold sub-interval, and use it as the halftone value for determining the traversed pixel.
[0130] In this embodiment, after determining the target threshold sub-interval, 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, if 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, then 1 is used as the halftone value of the currently traversed pixel.
[0131] As an optional implementation, inkjet printing has three states: 0, no printing (denoted by 'a'); 1, small print (denoted by 'b'); and 3, large print (denoted by 'd'). Therefore, there are three halftone values: 0, 1, and 3. Within these three threshold sub-intervals, the range from 0 to the first threshold forms the first threshold sub-interval, the range from the first threshold to the second threshold forms the second threshold sub-interval, and the range from the second threshold to infinity or 255 forms the third threshold sub-interval. 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: Calculate the quantization error based on the grayscale values of the traversed pixels and the lower limit 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 sub-interval are obtained. The quantization error is obtained by subtracting the lower limit of the target threshold sub-interval from the grayscale value of the pixel. For example, if the grayscale value of the current pixel is 80 and its target threshold sub-interval lower limit is 0, then the quantization error = 80 - 0 = 80.
[0134] For example, an electronic image of an artwork needs to be printed using an inkjet printer. This printer uses the halftone processing method described above to control the inkjet volume for better printing results. First, the image is converted to grayscale, resulting in a first image in pixel matrix form, with an image size of 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 encountered, its grayscale value is 60. The predefined threshold intervals and sub-intervals are as follows: Interval 1 (lower limit 0, upper limit 80); Interval 2 (lower limit 81, upper limit 160); Interval 3 (lower limit 161, upper limit 255). The pixel's grayscale value of 60 falls within Interval 1, so Interval 1 is the target threshold sub-interval for this pixel. According to the correspondence, Interval 1 corresponds to a halftone value of 0, so the halftone value of this pixel is determined to be 0. Subtracting the lower limit value of 0 in Interval 1 from the pixel's grayscale value of 60 yields a quantization error of 60 - 0 = 60. Next, this quantization error is propagated according to a predetermined error propagation rule, such as to adjacent pixels on the right, bottom, lower left, and lower right, updating the grayscale values of these adjacent pixels. This process continues, iterating through other pixels until the entire image is processed, resulting in a halftone image. Finally, the inkjet printer performs inkjet printing based on the halftone values of the pixels: no inkjet when the halftone value is 0 (labeled a), a small inkjet when the halftone value is 1 (labeled b), and a large inkjet when the halftone value is 3 (labeled d). This results in the same image as the first image being printed on paper. Furthermore, the halftone processing optimizes inkjet volume control, improving print quality.
[0135] In this embodiment, the halftone value and quantization error of a pixel are determined by using a threshold sub-interval, which effectively realizes halftone processing of the image and improves the visual effect of the image in a specific printing scenario.
[0136] Based on any embodiment, in one possible embodiment of this application, step S30 includes steps S31-S33:
[0137] Step S31: Obtain the error diffusion matrix, and determine the neighboring pixels of the traversed pixels for error diffusion based on the error diffusion matrix, as well as the diffusion weight of each neighboring pixel.
[0138] In this embodiment, the error diffusion matrix is a predefined matrix used to determine which neighboring pixels the quantization error of the current pixel is diffused to during halftone processing, and the proportion of error received by each neighboring pixel, i.e., the diffusion weight. The elements in the matrix typically represent the error diffusion distribution relationship between neighboring pixels at different locations relative to the current pixel. Diffusion weight: Each element in the error diffusion matrix corresponds to a diffusion weight of a neighboring pixel, representing the proportion of the quantization error of the current pixel allocated to that neighboring pixel. For example, a diffusion weight of 0.3 for a neighboring pixel indicates that 30% of the quantization error of the current pixel will be allocated to that pixel. The total weight is typically 1 or close to 1 to ensure that the quantization error is distributed and diffused within a reasonable range, avoiding excessive impact on image quality.
[0139] As an optional implementation, the error diffusion matrix, such as the Floyd-Steinberg matrix, has its size and element values determined according to the characteristics and requirements of the halftone algorithm to achieve reasonable diffusion of image errors, ensuring that the image maintains good visual quality after quantization processing. First, the error diffusion matrix is obtained from the preset data used by the halftone processing algorithm. For example, during forward scanning, the forward scanning matrix is used to diffuse errors to the currently traversed pixel and then to its four adjacent pixels. The elements in the matrix represent the weights of the errors inherited by adjacent pixels: the element at coordinates (1,2) in the matrix represents the current pixel.
[0140]
[0141] Negative direction scan matrix:
[0142]
[0143] For the currently traversed pixel, its neighboring pixels are determined according to the matrix. Assuming the current pixel's coordinates are (x, y), the diffusion weight of the pixel to its right (x, y+1) is 1 / 16, the diffusion weight of the pixel to its lower right is 7 / 16, the diffusion weight of the pixel below it (x+1, y) is 5 / 16, the diffusion weight of the pixel to its lower left (x+1, y-1) is 3 / 16, and the diffusion weight of the pixel to its lower right (x+1, y+1) is 1 / 16. These neighboring pixels and their corresponding diffusion weights will be used for subsequent error value calculation and grayscale value update.
[0144] Step S32: Calculate the error value of each of the adjacent pixels based on 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 w of each adjacent pixel are known to be... i(i represents the coordinates of different adjacent pixels). For example, for the adjacent pixels 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; 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; Error value E of the lower pixel (x+1, y) (x,y+1) =E×w (x,y+1) =20×5 / 16=25 / 4; 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: Sum the original gray values of the adjacent pixels with the error value to obtain the updated gray values of the adjacent pixels.
[0147] In this embodiment, the original grayscale value is the grayscale value of each adjacent pixel before it receives the quantization error diffusion of the current pixel. It reflects the original brightness and darkness information of the pixel in the image. By adding the original grayscale value to the assigned error value, the updated grayscale value is obtained, thereby adjusting the grayscale value of adjacent pixels according to the quantization error of the current pixel, and gradually realizing halftone processing and tone optimization of the image.
[0148] As an optional implementation, let the original grayscale value of the adjacent pixel (x+1, y) be G. (x+1,y) Then its updated grayscale 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 pixels (x+1,y+1), (x,y+1), and (x-1,y+1), their original gray values are added to the calculated error values to obtain updated gray values. This completes the gray value update operation for these adjacent pixels, so that when traversing other pixels in the future, halftone processing and error diffusion can continue based on the updated gray values until all pixels in the entire image have been processed.
[0149] For example, consider a 3×3 grayscale image with the following pixel grayscale values: Assume the currently visited pixel is (3,5), with a grayscale value of 120. After determining its halftone value and quantization error in the previous steps, assume the quantization error E = 30. Use the Floyd-Steinberg error diffusion matrix described above 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, the updated grayscale value newG (3,6) =150 + 105 / 8 = 1305 / 8 ≈ 163.125. Pixel (4, 6) in the lower right corner: Original grayscale value G (4,6) =180, diffusion weight w (4,6) =1 / 16, error value E (4,6) =30 × 1 / 16 = 15 / 8, the updated grayscale value newG (4,6) =180 + 15 / 8 = 1455 / 8 ≈ 181.875. Pixel (4,5) at the bottom: Original grayscale value G (4,5) =200, diffusion weight w (4,5) =5 / 16, error value E (4,5) =30×5 / 16=75 / 8, the updated grayscale value newG (4,5) =200 + 75 / 8 = 1675 / 8 ≈ 209.375. The bottom left pixel (4,4): original grayscale value G (4,4) =100 (assuming 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, the updated grayscale value newG (4,4) =100+45 / 8=845 / 8≈105.625. This completes the diffusion of the quantization error of the current pixel (3,5) to neighboring pixels and the update of the grayscale values of neighboring pixels. Then, continue to traverse other pixels in the image and repeat the above error diffusion and grayscale value update steps until the halftone processing of the entire image is completed.
[0150] By spreading the error to neighboring pixels to update the grayscale values of neighboring pixels, the grayscale value of each pixel is dynamically changed, thereby improving the accuracy of halftone values.
[0151] Based on any embodiment, in one possible embodiment of this application, before step S10, the halftone method includes:
[0152] Step A1: The second image is sequentially divided into multiple sub-images, the multiple sub-images including a first sub-image and at least one second sub-image, the second sub-image having a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlapping the preset number of rows of pixels, the first image including the first sub-image and the at least one second sub-image.
[0153] In this embodiment, the second image refers to the second image that needs to undergo halftone processing. It has various formats and sources, contains a large number of pixels, and each pixel has specific attributes such as brightness and color. These pixels are arranged in rows and columns to form the entire image, with the image size represented as R rows and C columns. The preset number is a pre-set fixed value, which is the number of more rows of pixels in the second sub-image than the first sub-image.
[0154] In this embodiment, the image is divided according to the number of rows. Specifically, the total number of rows in the image is divided into multiple sub-images according to a specific row count parameter. The first sub-image and the second sub-image are different parts divided from the second image using a preset method. The first sub-image is one of these sub-images, and its row count is the number of division rows. There is at least one second sub-image, and the row count of each second sub-image is the number of division rows plus a preset number.
[0155] As an optional implementation, for a second image with R rows and C columns, it is divided into N sub-images, with a preset number of p, where p > 1. The first sub-image takes the first K rows of the image, i.e., rows 1 to K. For the second sub-image, the first sub-image starts from row K-p+1 and extends to row 2K; the second sub-image starts from row 2*K-p+1 and extends to row 3*K, and so on, with the (N-1)th sub-image starting from row (N-1)*S-p+1 and extending to row N*S. This divides the entire image into N sub-images, with adjacent sub-images overlapping by p pixels.
[0156] Therefore, after determining the first image as the first sub-image and at least one second sub-image, the divided first sub-image and all second sub-images are simultaneously fed into the processing unit. For each sub-image, halftone processing is performed using the corresponding ordered dithering matrix. For example, for a specific sub-image, the processing unit determines the output color or brightness of that pixel in the halftone image based on the corresponding position of each pixel in the ordered dithering matrix and the value of the matrix elements, thereby converting the entire sub-image into the target image. Parallel processing can significantly improve processing speed. By combining the ordered dithering matrix and error diffusion to process the first and second sub-images, at least two target images are determined.
[0157] Since the second image is sequentially divided into multiple sub-images, including a first sub-image and at least one second sub-image, the relevant steps of the halftone method embodiment above can be performed on each sub-image, i.e., parallel processing is performed on each sub-image, improving processing efficiency. Simultaneously, the second sub-image has a preset number of rows of pixels more than the first sub-image, and adjacent sub-images overlap by the preset number of rows of pixels. That is, for each second sub-image, when determining the halftone value of each pixel, the pixels in the first preset number of rows are repeated from the previous sub-image. For pixels in the preset number + 1 rows, their grayscale values have undergone several error diffusions, for example, 10 error propagations F. (i,j) =(7 / 16) 10 *f (i,j) =0.000257*f (i,j) Its deviation rate approaches zero, making the determined halftone values more accurate.
[0158] Based on any of the above embodiments, in an optional embodiment of this application, step S10 includes:
[0159] Step S11: Determine the number of segmentation rows based on the total number of pixel rows in the second image and the number of sub-images.
[0160] In this embodiment, the number of sub-images is the total number of images in the first and second sub-images. The total number of pixel rows refers to the number of rows formed by pixels in the vertical direction of the second image, which determines the height information of the image and is an important dimension of the image size. The number of segmented rows is a value calculated based on a preset number and the number of pixel rows in the first image, and is used to determine the number of rows in the first sub-image.
[0161] The number of segmentation rows is determined using a specific calculation method, taking into account a preset number and the number of pixel rows in the first image. For example, it can be determined by dividing the number of pixel rows in the first image by a value related to the preset number, or by determining it based on some mathematical relationship between the preset number and the number of pixel rows in the image.
[0162] As an optional implementation, the number of sub-images after segmentation is determined. A preset number is the number of more pixel rows in the second sub-image compared to the first sub-image. The number of segmentation rows in the first sub-image is determined based on the number of pixel rows in the first image, the number of sub-images after segmentation, and the preset number. Specifically, the number of segmentation rows * the number of sub-images = the total number of pixel rows in the second image. The number of pixel rows in the first sub-image is the number of segmentation rows, and the number of pixel rows in 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 number of segmentation rows to obtain the first sub-image.
[0164] In this embodiment, the first sub-image is the first sub-image divided from the first image. It is part of the entire halftone processing process and will be used subsequently as the second sub-image. Figure 1 It participates in the processing to generate the final halftone map.
[0165] Based on the calculated number of segmentation rows K, starting from the beginning or end of the first image, select the first K rows of pixels to form the first sub-image. For example, if the number of segmentation rows = 200, then the first sub-image is the image portion composed 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 beginning of the second image, the end of the first sub-image overlaps with the beginning of the first second sub-image by a predetermined number of rows of pixels. If the first sub-image starts from the end of the second image, the beginning of the first sub-image overlaps with the end of the first second sub-image by a predetermined number of rows of pixels.
[0167] Step S13: Based on the starting or ending pixel row of the first sub-image, a preset number of rows of pixels, and the number of segmentation rows, the second image is segmented sequentially to obtain a second sub-image adjacent to the first sub-image and the remaining second sub-images.
[0168] In this embodiment, if the first sub-image starts from the beginning of the second image, the second sub-image is segmented starting from the terminating pixel row of the first sub-image. If the first sub-image starts from the end of the second image, the second sub-image is segmented starting from the terminating pixel row of the first sub-image.
[0169] When forming the second subimage, starting from the first second subimage, if it is the first second subimage after the first subimage, it is constructed by adding the pixels corresponding to the subsequent number of rows from the end of the first subimage. For example, if the preset number is 10 and the number of rows is 200, the first subimage is rows 1 to 200 of the second image. If it is the first second subimage, it is constructed by selecting rows from the 191st row to the 400th row of the second image; if it is the next second subimage, it is constructed by selecting rows from the last ten rows of the previous second subimage, i.e., the 391st row of the entire second image, to the 600th row, and so on, until the entire second image is processed, resulting in the first subimage and all the second subimages.
[0170] After sub-image segmentation, the halftone processing unit of the printing device performs parallel halftone processing on the first and second sub-images based on an ordered dithering matrix. After processing, the target images are merged, and the printing device accurately sprays ink onto the printing paper based on the merged halftone image data, producing a high-quality halftone image that allows users to obtain exquisite printed works. This method improves printing efficiency while ensuring print quality through reasonable image segmentation and parallel processing.
[0171] Based on any of the above embodiments, in an optional embodiment of this application, after step S40, the following is included:
[0172] Step S50: Combine the halftone images corresponding to all sub-images to obtain the 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 halftone method steps described in the above embodiment are performed on each sub-image obtained from the division of 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] A subimage is created by dividing the second image into multiple smaller regions during processing. Subimage division enables parallel processing, reduces computational complexity, or allows operation according to specific image structures and algorithm requirements. Each subimage contains a subset of pixels and, after the preceding halftone processing steps, has its own corresponding halftone image. In this embodiment, the subimages are the first subimage and at least one second subimage.
[0175] After determining the halftone images of the first sub-image and each second sub-image, all the halftone images are synthesized according to the order in which the sub-images were segmented to obtain the halftone image of the second image.
[0176] Optionally, step S50 includes steps S51 to S53.
[0177] Step S51: Determine the arrangement order of each halftone image, with two adjacent halftone images being the first halftone image and the second halftone image, respectively.
[0178] In this embodiment, the halftone images are arranged in a specific order because the second image is divided into multiple sub-images and each is processed with halftone. These sub-images need to be arranged in a particular 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 according to other preset rules. The first and second halftone images are two adjacent halftone images. For ease of description, the halftone image processed first or appearing earlier in the arrangement 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 stitching.
[0179] As an optional implementation, firstly, 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 and halftone processed in a top-to-bottom order, then the arrangement order of the halftone images should also be top-to-bottom. When processing adjacent halftone images, it is determined which one is the first halftone image and which one is the second halftone image, so that the overlapping parts can be cropped and stitched together later.
[0180] Step S52: Crop the second halftone image to remove 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 predetermined number of rows of pixels overlapping the first halftone image and the second halftone image is obtained. Based on this information, the region in the second halftone image that needs to be cropped is determined, for example, a predetermined number of rows of pixels in the head. An image cropping algorithm or related function is used to remove these pixels from the first halftone image. For example, if the second halftone image is an image represented by a two-dimensional pixel matrix, by modifying the range of row numbers in the matrix, the matrix rows corresponding to the predetermined number of rows of pixels in the head are deleted, thereby obtaining the cropped first halftone image.
[0182] As an optional implementation, the second sub-image has a predetermined number of rows of pixels more than the first sub-image, and adjacent sub-images overlap by this predetermined number of rows of pixels. That is, for each second sub-image, when determining the halftone value of each pixel, the first predetermined number of rows of pixels are repeated from the previous sub-image. For pixels in the predetermined number + 1 rows, their grayscale values have undergone several error propagation steps, for example, 10 error propagations, resulting in a deviation rate approaching zero, making the determined halftone values more accurate. Therefore, during cropping, the halftone image of the first sub-image does not need to be cropped. For each halftone image corresponding to a second sub-image, the two adjacent halftone images are determined as the first halftone image and the second halftone image, respectively, according to the order of the second image from beginning to end; then, the first predetermined number of rows of pixels in the second halftone image are cropped. For second sub-images adjacent to the first sub-image, the first predetermined number of rows of pixels in their halftone images are directly cropped.
[0183] As another optional implementation, if the sub-images are arranged in the following order: starting from the tail of the second image as the first sub-image, and from tail to head as the first sub-image, the first second sub-image, the second second sub-image, and so on. For example, if the first second sub-image and the second second sub-image are adjacent sub-images, then the first second sub-image corresponds to the first halftone image, and the second second sub-image corresponds to the second halftone image. Due to the order of error propagation, a predetermined number of rows of pixels at the tail of the second halftone image are cropped.
[0184] Step S53: Based on the arrangement order, the cropped halftone image and the uncropped halftone image are spliced together to obtain the halftone image corresponding to the second image.
[0185] In this embodiment, splicing involves connecting the cropped halftone image and the uncropped halftone image in a predetermined order to form a complete image. This image is the halftone image corresponding to the second image, and its visual effect should be consistent with the expected result of the second image after halftone processing. Furthermore, there should be no obvious gaps or discontinuities at the splicing point.
[0186] As an alternative implementation, the cropped first halftone image is stitched together with the uncropped second halftone image according to the previously determined halftone image arrangement order. This is achieved using an image stitching algorithm or related library functions. For example, if using the Python image processing library Pillow, a new image object is created with a size equal to the halftone image size of the synthesized second image. Then, the pixel data of the cropped first halftone image and the pixel data of the uncropped second halftone image are sequentially copied to their respective positions in the new image object, completing the stitching operation. This process is repeated, processing all adjacent halftone images sequentially, until the halftone images corresponding to all sub-images have been stitched together, ultimately obtaining the complete halftone image corresponding to the second image.
[0187] Optionally, the halftone images corresponding to all sub-images are synthesized to obtain the halftone image corresponding to the second image. 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 overlapping with the first halftone image are weighted and summed with the halftone values of the corresponding overlapping pixels in the first halftone image to obtain the updated halftone values.
[0188] For example, the first halftone image consists of pixels in rows 191 to 300 of the second image, and the second halftone image consists of pixels in rows 291 to 400 of the second image. When the first and second halftone images are combined, the overlapping portion consists of pixels in rows 291 to 300 of the second image. Therefore, a first weight corresponding to the first halftone image and a second weight corresponding to the second halftone image are determined. Then, for pixels in the overlapping portion, their halftone value 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, thus obtaining the halftone value of that pixel.
[0189] In this way, all target images are merged into a halftone image corresponding to the first image. Then, the printing device prints according to this halftone image, which can output a landscape painting with a high-quality halftone effect, accurately restoring the color levels and details in the original landscape painting.
[0190] For example, to help understand the technical concept or principle of the halftone method after combining any of the above embodiments, please refer to Figure 3 , Figure 3 A simplified flowchart of a halftone method is provided below:
[0191] First, obtain the total number of pixel rows and a preset number (i.e., the number of more pixel rows in the second sub-image than the first sub-image) of the second image, and determine the number of sub-images. 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 in the second image. The number of segmentation rows is calculated based on this relationship, and then the second image is segmented from either the head or tail to obtain the first sub-image. If starting from the head, the first sub-image consists of the first K rows of pixels; if starting from the tail, it consists of the last K rows of pixels. The first sub-image and the first second sub-image will have a preset number of overlapping rows of pixels, the overlapping position depending 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 ending pixel row of the first sub-image, counting backwards by the preset number of rows of pixels, and selects pixels corresponding to the subsequent segmentation rows. If the first sub-image starts from the tail of the second image, the first second sub-image starts from the beginning pixel row of the first sub-image, and selects pixels corresponding to the subsequent segmentation rows. The subsequent second sub-images are segmented in the same way. Each second sub-image has a preset number of overlapping rows of pixels with the previous sub-image, until the entire second image is segmented, resulting in the first sub-image and all the second sub-images.
[0192] For each sub-image, including the first and second sub-images, correction parameters are calculated based on the pixel coordinates and ordered jitter matrix of the pixels in the sub-image. The specific steps are as follows: First, calculate the ordered jitter threshold based on the pixel coordinates, ordered jitter matrix, and original error diffusion threshold. Then, correct this threshold based on the blue noise impact factor to obtain the correction parameters. Based on the correction parameters and the original error diffusion threshold, calculate the threshold interval for each pixel. The threshold interval includes at least three threshold sub-intervals divided based on at least two intermediate thresholds. Traverse the pixels in the sub-image, and determine the target threshold sub-interval based on the relationship between the pixel's grayscale value and at least three threshold sub-intervals within the threshold interval. Obtain the halftone value corresponding to the target threshold sub-interval as the halftone value of the pixel, and calculate the quantization error based on the pixel's grayscale value and the lower limit of the target threshold sub-interval. Obtain the error diffusion matrix, and determine the neighboring pixels for error diffusion of the traversed pixels and the diffusion weight of each neighboring pixel based on this matrix. Calculate the error value of each neighboring pixel based on the quantization error and diffusion weight, and then sum the original grayscale value and the error value of the neighboring pixels to obtain the updated grayscale value of the neighboring pixels. Based on the threshold range of the remaining pixels traversed and the updated grayscale values, the halftone values of the remaining pixels in the sub-image are determined, thus obtaining the halftone image corresponding to each sub-image.
[0193] Because adjacent sub-images overlap by a predetermined number of rows of pixels, during merging, the pixels in the header of all second sub-images are deleted within this predetermined number of rows. Then, the first sub-image and all second sub-images are sequentially stitched together 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, printing a high-quality halftone image, allowing users to obtain exquisite printed works. Throughout the process, by dividing the second image into sub-images and processing each sub-image in parallel, processing efficiency is improved. Simultaneously, techniques such as ordered dithering matrices and error diffusion ensure the quality of halftone processing, enabling the final printed image to effectively simulate the visual effect of the second image within a limited range of color or grayscale levels, meeting users' needs for high-quality image printing.
[0194] Reference Figure 4 The second image is divided into N sub-images, each containing one first sub-image and at least one second sub-image. The number of rows is set to K, with a preset quantity of 10 rows. The first sub-image consists of rows 1 to K, the first second sub-image consists of rows K-9 to 2K, and so on. Each second sub-image has 10 more rows than the first sub-image. Because the error of the current pixel is propagated 10 times, the error value approaches 0. For example, for the pixel in row i and column j, F(i,j) is the final value of the error propagation, which is F after 10 error propagations. (i,j) =(7 / 16) 10 *f (i,j) =0.000257*f (i,j) Therefore, when the error diffusion algorithm is improved by parallelization, the image needs to be segmented upwards by 10 more rows.
[0195] Given an image with R rows and C columns, divide it into N sub-images. The R rows are further divided into one K-row and N-1 K+10-row sub-images. The first sub-image contains pixels from row 1 to row K, the second sub-image contains pixels from row K-9 to row 2*K, and the Nth sub-image contains pixels from row (N-1)*K-9 to row N*K, where N*K = R. After segmentation, each sub-image is processed in parallel. For each sub-image, the threshold range for each pixel is calculated using the following formula:
[0196] T = t + F[x%8][y%8]%t × m
[0197] Where (x,y) represents the pixel position of the input image, i.e., pixel coordinates; F is a Bayer ordered jitter matrix with blue noise characteristics; t is the original threshold for error diffusion, and the two t thresholds for third-order error diffusion are 64 and 192; m is the blue noise influence factor, with a value range of (0~1), for example, 0.4. Then, T1 corresponding to t threshold 64 and T2 corresponding to t threshold 192 are determined. Then, three threshold sub-intervals are formed based on 0, T1, T2, and 255, serving as the threshold intervals.
[0198] Optionally, the blue noise impact factor can 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 blue-green algae impact factor can be any value between 0 and 1, and can be reasonably set according to actual needs.
[0199] After determining the threshold range for each pixel, traverse each pixel according to the preset traversal method, referring to... Figure 5 The default traversal method is a serpentine raster scan. The serpentine raster scan has a positive and a negative direction for each row; that is, the positive direction is set from left to right. For example, the current row is scanned from left to right to the last column, and then the next row is scanned from right to left to the first column, and so on. During error propagation, the Floyd matrix is used for the positive direction, and the FloydNegative matrix is used for the negative direction.
[0200] During the traversal, the halftone value of the current pixel is calculated: 0 (no spray a), 1 (small spray, represented by b), 3 (large spray, represented by d); the halftone processing of the pixel in row x and column y is based on the formula:
[0201]
[0202] We obtain the halftone values h(x,y), G (x,y) T1 and T2 represent the grayscale value of the current pixel; T1 and T2 are the first and second thresholds within the threshold interval, respectively. Therefore, the halftone value determination formula is a piecewise function: if the grayscale value is less than or equal to the first threshold, the halftone value is determined to be 0; if the grayscale value is greater than the first threshold and less than or equal to the second threshold, the halftone value is determined to be 1; and if the grayscale value is greater than the second threshold, the halftone value is determined to be 3.
[0203] Substituting 64 into the formula, we obtain the first threshold T1 = 64 + F[x%8][y%8]%64 × 0.4.
[0204] Substituting 192 into the formula, we obtain the second threshold T2 = 192 + F[x%8][y%8]%192 × 0.4. After determining the halftone value of the current pixel, we determine the quantization error E of the current pixel. (x,y) The calculation formula is:
[0205]
[0206] Reference Figure 6 Then, the quantization error is diffused 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] Where newG is the updated grayscale value. That is, for each adjacent pixel, the updated grayscale value is its original grayscale value + diffusion weight * quantization error.
[0212] Each pixel is traversed using the method described above, and its halftone value is determined. After traversing all pixels, the halftone image corresponding to each sub-image is determined. (Refer to...) Figure 7 Then, the halftone images of each sub-image are merged 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, based on the arrangement order, the updated target images are combined to determine the halftone image corresponding to the first image.
[0213] Reference Figure 8 , Figure 8 This is a comparison example of halftone images before and after processing using the halftone method in this embodiment. The left side shows the halftone image after ordered dithering, and the right side shows the halftone image after processing using the halftone method in this embodiment. It is clear that the halftone image obtained in this embodiment can reduce noise and preserve details. Ordered dithering reduces low-frequency noise, improves error diffusion, and preserves more subtle image details, thereby improving image quality. (Refer to...) Figure 9 , Figure 9 This is a comparison example of halftone images before and after processing by the halftone method in this embodiment. The left side is the halftone image after ordered dithering, and the right side is the halftone image after processing by the halftone method in this embodiment. It is obvious that the ordered dithering algorithm has large grain artifacts in solid color blocks, while the halftone image obtained in this embodiment reduces the large grain artifacts to small grain artifacts through ordered dithering and improved error diffusion algorithm, thereby improving image quality.
[0214] This application provides a computer device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the halftone method in Embodiment 1 above.
[0215] The following is for reference. Figure 10 The diagram illustrates a structural schematic of a computer device suitable for implementing the embodiments of this application. The computer device in the embodiments of this application may include, but is not limited to, computers, mobile phones, tablets, etc., or inkjet printing devices, which are not listed here. Figure 10 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this application.
[0216] like Figure 10 As shown, the computer device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the computer device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the computer device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows computer devices with various systems, it should be understood that it is not required to implement or possess all of the systems shown. More or fewer systems may be implemented alternatively.
[0217] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0218] The computer device provided in this application, employing the halftone method described in the above embodiments, can solve the technical problem that the continuous transmission and accumulation of errors in an image leads to a decrease in image contrast, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer device provided in this application are the same as those of the computer device provided in the above embodiments, and other technical features of this computer device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0219] It should be understood that the various parts disclosed in this application can be implemented using 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 suitable manner in one or more embodiments or examples.
[0220] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0221] This application provides a printing system, referring to... Figure 11 This includes host computers and inkjet printing equipment;
[0222] The host computer is used to acquire 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 map, which is then sent to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone map; or,
[0223] The host computer is used to acquire the 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 in any of the above embodiments to obtain a halftone map, and print the first image based on the halftone map.
[0224] This application provides a halftone device, with reference to... Figure 12 The halftone device 1200 includes: an ordered jitter processing module 1201, a first determination module 1202, an error diffusion module 1203, a second determination module 1204, and a generation module 1205.
[0225] The ordered jitter processing module 1201 is used to perform ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image.
[0226] The first determining module 1202 is used to traverse the pixels of the first image and determine the halftone value and quantization error of the traversed pixels based on the gray value of the traversed pixels and the threshold range.
[0227] The error diffusion module 1203 is used to diffuse the quantization error to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixel.
[0228] The second determining module 1204 is used to determine the halftone value of the remaining pixels of the first image based on the threshold range of the remaining pixels traversed and the updated gray value.
[0229] The generation module 1205 is used to generate a halftone map corresponding to the first image based on the halftone values of all pixels.
[0230] The ordered jitter processing module 1201 is further configured to calculate correction parameters based on the pixel coordinates of the pixel and the ordered jitter matrix; and to calculate the threshold range of the pixel based on the correction parameters and the original error diffusion threshold.
[0231] The ordered jitter processing module 1201 is further configured to calculate the ordered jitter threshold based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion 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 further configured to determine the order of the ordered jitter matrix; take the remainder of the pixel coordinates with respect to the order to obtain element coordinates; determine the elements in the ordered jitter matrix based on the element coordinates, wherein the elements are the data at the element coordinates in the ordered jitter matrix; and take the remainder of the elements with respect to the original error diffusion threshold to obtain the ordered jitter threshold.
[0233] The first determining module 1202 is further configured to determine a target threshold sub-interval based on the relationship between the grayscale value of the traversed pixel 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; and calculate the quantization error based on the grayscale value of the traversed pixel and the lower limit value of the target threshold sub-interval.
[0234] The error diffusion module 1203 is further configured to obtain an error diffusion matrix, and determine the neighboring pixels of the traversed pixels for error diffusion based on the error diffusion matrix, as well as the diffusion weight of each neighboring pixel; calculate the error value of each neighboring pixel according to the quantization error and the diffusion weight; and sum the original grayscale value of the neighboring pixel with the error value to obtain the updated grayscale value of the neighboring pixel.
[0235] The halftone device further includes a segmentation module for sequentially segmenting the second image into multiple sub-images. 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 by the preset number of rows of pixels. The first sub-image and the at least one second sub-image are both the first image.
[0236] The segmentation module is used to determine the number of segmentation rows based on the total number of pixel rows in the second image and the number of sub-images; to segment the head or tail of the second image based on the number of segmentation rows to obtain the first sub-image; and to segment the second image sequentially based on the starting or ending pixel row of the first sub-image, a preset number of pixel rows, and the number of segmentation rows to obtain a second sub-image adjacent to the first sub-image and the remaining second sub-images.
[0237] The halftone device further includes a merging module for merging the halftone images corresponding to all the sub-images to obtain the halftone image corresponding to the second image.
[0238] The merging module is used to determine the arrangement order of the halftone images, wherein two adjacent halftone images are respectively the first halftone image and the second halftone image; the second halftone image is cropped to remove a preset number of rows of pixels that overlap with the first halftone image; and the cropped halftone image and the uncropped halftone image are stitched together based on the arrangement order to obtain the halftone image corresponding to the second image.
[0239] Please see Figure 13This application embodiment also provides an inkjet printing device 200, which includes a processor 230 and a printhead 212. The processor 230 is used to acquire a halftone map of the image to be printed generated based on the halftone method described in any of the above embodiments, and then control the printhead 212 to print the image to be printed based on the halftone map.
[0240] Furthermore, referring to Figure 13 In some embodiments, the inkjet printing device 200 specifically includes:
[0241] The printing assembly 210 includes a slide rail 211 and a print head 212, wherein the print head 212 is slidably disposed on the slide rail 211.
[0242] Memory 220, wherein the memory stores computer program products that can be executed by a processor;
[0243] Processor 230 is configured to acquire a halftone map 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 ink jetting of the print head based on the halftone map to print the image to be printed.
[0244] The inkjet printing device 200 can receive a halftone image of the image to be printed generated based on the halftone method described in any of the above embodiments; or generate a halftone image of the image to be printed based on the halftone method described in any of the above embodiments.
[0245] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to perform the halftone method in the above embodiments.
[0246] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. 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 conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0247] The aforementioned computer-readable storage medium may be included in a computer device or may exist independently and not assembled into a computer device.
[0248] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a computer device, cause the computer device to: perform ordered dithering processing on a first image based on an ordered dithering matrix to obtain a threshold range for each pixel in the first image; traverse the pixels of the first image and, based on the grayscale values of the traversed pixels and the threshold ranges, determine the halftone values and quantization errors of the traversed pixels; propagate the quantization error to the neighboring pixels of the traversed pixels to update the grayscale values of the neighboring pixels; and, based on the threshold ranges of the remaining traversed pixels and the updated grayscale values, determine the halftone values of the remaining pixels in the first image to obtain a halftone map corresponding to the first image.
[0249] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0250] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0251] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0252] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described halftone method. This addresses the technical problem that the continuous propagation and accumulation of errors in an image leads to reduced image contrast, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the halftone method provided in the above embodiments, and will not be repeated here.
[0253] This application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the halftone method described above.
[0254] The computer program product provided in this application can solve the technical problem that the continuous propagation and accumulation of errors in an image leads to a decrease in image contrast, thereby affecting the visual effect of the image. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiments of this application are the same as the beneficial effects of the halftone method provided in the above embodiments, and will not be repeated here.
[0255] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A halftone method, characterized in that, The halftone method includes: The first image is subjected to ordered jitter processing based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image. The pixels of the first image are traversed, and the halftone value and quantization error of the traversed pixels are determined based on the gray value of the traversed pixels and the threshold range. The quantization error is propagated to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixel; Based on the threshold range of the remaining pixels traversed and the updated grayscale value, the halftone value of the remaining pixels of the first image is determined. A halftone map corresponding to the first image is generated based on the halftone values of all pixels.
2. The halftone method as described in claim 1, characterized in that, The step of performing ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image includes: The correction parameters are calculated based on the pixel coordinates of the pixel and the ordered jitter matrix; The threshold range of the pixel is calculated based on the correction parameters and the original threshold for error diffusion.
3. The halftone method as described in claim 2, characterized in that, The step of calculating the correction parameters based on the pixel coordinates of the pixel and the ordered jitter matrix includes: The ordered jitter threshold is calculated based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion threshold. The correction parameter is obtained by correcting the ordered jitter threshold based on the blue noise impact factor.
4. The halftone method as described in claim 3, characterized in that, The step of calculating the ordered jitter threshold based on the pixel coordinates of the pixel, the ordered jitter matrix, and the original error diffusion threshold includes: Determine the order of the ordered jitter matrix; The element coordinates are obtained by taking the remainder of the pixel coordinates with respect to the order. The elements in the ordered jitter matrix are determined based on the element coordinates, and the elements are the data at the element coordinates in the ordered jitter matrix; The ordered jitter threshold is obtained by taking the remainder of the element with respect to the original error diffusion threshold.
5. The halftone method as described in claim 1, characterized in that, The threshold interval includes at least three threshold sub-intervals divided by at least two intermediate thresholds, each of the at least three threshold sub-intervals corresponding to at least three halftone values. Determining the halftone value and quantization error of the traversed pixels based on the grayscale value of the traversed pixels and the threshold interval includes: Based on the relationship between the gray values of the traversed pixels and the at least three threshold sub-intervals, the target threshold sub-interval is determined; Obtain the halftone value corresponding to the target threshold sub-interval, and determine it as the halftone value of the traversed pixel; The quantization error is calculated based on the grayscale values of the traversed pixels and the lower limit of the target threshold sub-interval.
6. The halftone method as described in claim 1, characterized in that, The step of spreading the quantization error to the neighboring pixels of the traversed pixels to update the grayscale values of the neighboring pixels includes: Obtain the error diffusion matrix, and determine the neighboring pixels of the traversed pixels for error diffusion based on the error diffusion matrix, as well as the diffusion weight of each neighboring pixel; Based on the quantization error and the diffusion weight, the error value of each of the adjacent pixels is calculated; The original grayscale values of the adjacent pixels are summed with the error value to obtain the updated grayscale values of the adjacent pixels.
7. The halftone method according to any one of claims 1 to 6, characterized in that, Before the step of performing ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image, the method further includes: The second image is sequentially divided into multiple sub-images, including 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 by the preset number of rows of pixels. The first sub-image and the at least one second sub-image are both the first image.
8. The halftone method as described in claim 7, characterized in that, The step of sequentially dividing the second image into multiple sub-images includes: The number of segmentation rows is determined based on the total number of pixel rows in the second image and the number of sub-images; The first sub-image is obtained by segmenting the head or tail of the second image based on the number of segmentation rows. Based on the starting or ending pixel row of the first sub-image, a preset number of rows of pixels, and the number of segmentation rows, the second image is segmented sequentially to obtain a second sub-image adjacent to the first sub-image and the remaining second sub-images.
9. The halftone method as described in claim 7, characterized in that, After obtaining the halftone images corresponding to each of the sub-images, the halftone method further includes: The halftone images corresponding to all the sub-images are synthesized to obtain the halftone image corresponding to the second image.
10. The halftone method as described in claim 9, characterized in that, The step of synthesizing the halftone images corresponding to all sub-images to obtain the halftone image corresponding to the second image includes: The arrangement order of the halftone images is determined, and two adjacent halftone images are respectively the first halftone image and the second halftone image; The second halftone image is cropped to remove a preset number of rows of pixels that overlap with the first halftone image. Based on the stated arrangement order, the cropped halftone image and the uncropped halftone image are stitched together to obtain the halftone image corresponding to the second image.
11. A halftone device, characterized in that, include: The ordered jitter processing module is used to perform ordered jitter processing on the first image based on the ordered jitter matrix to obtain the threshold range of each pixel in the first image; The first determining module is used to traverse the pixels of the first image and determine the halftone value and quantization error of the traversed pixels based on the gray value of the traversed pixels and the threshold range. An error diffusion module is used to diffuse the quantization error to the neighboring pixels of the traversed pixel to update the grayscale value of the neighboring pixels. The second determining module is used to determine the halftone values of the remaining pixels of the first image based on the threshold range of the remaining pixels traversed and the updated gray values. The generation module is used to generate a halftone map corresponding to the first image based on the halftone values of all pixels.
12. A computer device, characterized in that, The computer device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the halftone method as described in any one of claims 1 to 10.
13. An inkjet printing device, characterized in that, The inkjet printing device includes a processor and a printhead, the processor being configured to acquire a halftone map obtained based on the steps of the halftone method as described in any one of claims 1 to 10, and to control the printhead to print an image based on the halftone map.
14. A printing system, characterized in that, The printing system includes a host computer and an inkjet printer; The host computer is used to acquire a first image and perform halftone processing on the first image based on the halftone method as described in any one of claims 1 to 10, obtaining a halftone map and sending it to the inkjet printing device; the inkjet printing device is used to print the first image based on the halftone map; or, The host computer is used to acquire the 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 as described in any one of claims 1 to 10 to obtain a halftone map, and print the first image based on the halftone map.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the halftone method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Generation of dither matrix
CN101830114A
Image processing device, printing device, image processing method, and image processing program
CN102689503A