Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a medium for setting the ink amount of a printer based on image processing, which are used for solving the problems that in the prior art, when the color of a large area in an image to be printed is consistent with the color of a printing medium, all pixel points are completely discharged, so that ink is wasted, and the printing cost is increased.
In a first aspect, an embodiment of the present invention provides an ink amount setting method for a printer based on image processing, the method including:
acquiring a color value of a printing medium, and recording the color value as a first color value;
carrying out graying processing on the image to be printed according to the first color value to obtain a first grayscale image;
traversing the first gray scale image to obtain a first gray scale value of each pixel point in the gray scale image;
comparing the first gray value with a set color threshold value to obtain a comparison result;
and setting the ink amount value of the white ink in the white ink channel when the image to be printed is printed according to the comparison result.
Preferably, the performing graying processing on the image to be printed according to the first color value to obtain a grayscale map includes:
obtaining color values corresponding to all pixel points in the image to be printed, and recording the color values as second color values;
acquiring a difference value corresponding to each pixel point according to the first color value and the second color value;
generating an intermediate image according to the difference value corresponding to each pixel point;
and carrying out graying processing on the intermediate image to obtain a corresponding first grayscale image.
Preferably, the first gray value is set as A, the color threshold value is set as T, and when A is larger than or equal to T, the ink quantity value of the white ink in the white ink channel when the image to be printed is as follows:
W=255-A
wherein W is an ink amount value of white ink in a white ink channel when the image to be printed is printed.
Preferably, if a first gray value is a, the color threshold is T, and when a < T, the setting the ink amount value of the white ink in the white ink channel when the image to be printed is printed according to the comparison result includes:
carrying out graying processing on the image to be printed to obtain a second grayscale image;
traversing the second gray scale map to obtain a second gray scale value corresponding to each pixel point in the second gray scale map;
and setting the ink amount value of the white ink in the white ink channel when the image to be printed is printed according to the second gray value.
Preferably, if the second gray value is B, the ink amount of the white ink in the white ink channel when the image to be printed is set according to the second gray value as follows:
W=255-B
wherein W is an ink amount value of white ink in a white ink channel when the image to be printed is printed.
Preferably, the printer further includes a cyan channel, a magenta channel, a yellow channel, and a black channel, and when W is 0, the method further includes:
adjusting the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel of the corresponding pixel point according to the ink value of the white ink channel, so that the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel are as follows:
C=0,M=0,Y=0,K=0
where C is the ink value for the cyan channel, M is the ink value for the magenta channel, Y is the ink value for the yellow channel, and K is the ink value for the black channel.
Preferably, when the color value of a pixel point in the image to be printed is C ═ 0, M ═ 0, Y ═ 0, and K ═ 0, then W ═ 0.
In a second aspect, an embodiment of the present invention provides an ink amount setting apparatus for a printer based on image processing, the apparatus including:
the first color value acquisition module is used for acquiring the color value of the printing medium and recording the color value as the first color value;
the first gray-scale image acquisition module is used for carrying out gray-scale processing on the image to be printed according to the first color value to obtain a first gray-scale image;
the first gray value acquisition module is used for traversing the first gray image to acquire a first gray value of each pixel point in the gray image;
the comparison result acquisition module is used for comparing the first gray value with a set color threshold value to obtain a comparison result;
and the ink amount setting module is used for setting the ink amount of the white ink in the white ink channel when the image to be printed is printed according to the comparison result.
In a third aspect, an embodiment of the present invention provides an ink amount setting apparatus for a printer based on image processing, including: at least one processor, at least one memory, and computer program instructions stored in the memory, which when executed by the processor, implement the method of the first aspect of the embodiments described above.
In a fourth aspect, embodiments of the present invention provide a storage medium having stored thereon computer program instructions, which when executed by a processor, implement the method of the first aspect in the above embodiments.
In summary, in the method, the color value of the printing medium is obtained and compared with the color values of all the pixels in the image to be printed, and the processed image color value is compared with the set color threshold value to obtain the ink amount value of the white ink laid on the bottom of the white ink to be printed at each pixel when the image to be printed is printed, so that not only can part of the ink amount be saved and the printing cost be reduced, but also the ink amount value of the white ink is reasonably set according to the color value of each pixel in the image to be printed instead of directly generating the 100% white ink amount value, so that the printed image has good transition and touch feeling.
Detailed Description
Features and exemplary embodiments of various aspects of the present invention will be described in detail below, and in order to make objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not to be construed as limiting the invention. It will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Referring to fig. 1, in the method for setting an ink amount of a printer based on image processing according to the embodiment of the present invention, the color value of a printing medium is obtained, the color value of the printing medium is compared with the color values of all pixels in an image to be printed, and the processed image color value is compared with a set color threshold value to obtain the ink amount value of white ink laid on the bottom of the white ink to be printed at each pixel when the image to be printed is printed, so that not only can a part of the ink amount be saved and the printing cost be reduced, but also the ink amount value of the white ink is reasonably set according to the color value of each pixel in the image to be printed instead of directly outputting the 100% white ink amount value, so that the printed image has good transition and touch feeling. The method specifically comprises the following steps:
s1, acquiring a color value of the printing medium and recording the color value as a first color value;
specifically, when the color value of the printing medium used by the user is known, the color value input by the user on the image processing interactive interface can be directly obtained; when the user does not know the printing medium used by himselfColor values, color values of the printing medium may be acquired by scanning the printing medium using an image scanner (e.g., eyeone). Wherein, the color value input by the user on the image processing interactive interface or scanned and obtained by the image scanner is reflected differently in different color modes, for example, in the CMYK color mode, the first color value of the printing medium is (C)0、M0、Y0、K0) If in the RGB color mode, the first color value of the print medium is (R)0、G0、B0)。
S2, performing graying processing on the image to be printed according to the first color value to obtain a first gray map;
specifically, in this embodiment, the image to be printed includes a background image and a foreground image, and the color difference between the background image and the printing medium is large, so that the whole image needs to be processed to save ink, to obtain color values of all pixel points in the image to be printed, and then the first color value is subtracted from the color values of all pixel points to obtain an intermediate image, before processing, the first color value needs to be converted into a value that is the same as the color gamut of the pixel points in the image to be printed, and then the intermediate image is processed by graying to obtain a gray image, so that the gray value of each pixel point is a value, unlike the case where each pixel point in the color image in the RGB mode includes R, G, B three values, or the case where each pixel point in the color image in the CMYK mode includes C, M, Y, K four values, the color image cannot be compared in color values, therefore, the image needs to be grayed for color value comparison and data processing. And converting the first color value and the color value of the pixel point in the image to be printed by adopting a color characteristic curve in the printer.
Preferably, when the color value is a color value in an RGB color mode, the conversion formula in the graying processing is:
Gray=R×0.299+G×0.587+B×0.114
wherein Gray represents the Gray value of the pixel or the print medium, and the color value of the pixel or the print medium in the RGB color mode is (R, G, B).
When the color value is the color value in the CMYK color mode, the gray scale conversion formula is:
wherein Gray represents the Gray value of the pixel or the print medium, and the color value of the pixel or the print medium in the CMYK color mode is (C, M, Y, K).
Preferably, referring to fig. 2, the step of performing graying processing on the image to be printed according to the first color value to obtain the first grayscale map includes:
s21, obtaining color values corresponding to all pixel points in the image to be printed, and recording the color values as second color values;
s22, acquiring a difference value corresponding to each pixel point according to the first color value and the second color value;
s23, generating an intermediate image according to the difference value corresponding to each pixel point;
and S24, carrying out graying processing on the intermediate image to obtain a corresponding first grayscale image.
Specifically, the first color value and the second color value are converted into color values in the same color mode, such as color values in a CMYK color mode or color values in a lab color mode, and then the first color value and the second color value are differenced to obtain a difference value of each pixel point corresponding to each color channel, such as in the CMYK color mode, the first color value is: c1=20、M1=60、Y1=50、K1The second color value of a certain pixel point is as follows: c2=10、M2=30、Y2=40、K2If the absolute value of the difference value of the pixel point is 50, the absolute value of the difference value of the pixel point is DeltaC ═ C1-C2|=10、△M=|M1-M2|=30、△Y=|M1-M2|=10、△K=|M1-M2|=20。
Preferably, referring to fig. 3, when the color value in the lab color mode is used for calculation, the specific method for obtaining the color difference value of each pixel point includes the following steps:
s211, obtaining an ICC color conversion curve of the printer;
s212, converting the first color value and the second color value into a corresponding first lab value and a corresponding second lab value according to the ICC color conversion curve;
s213, obtaining the corresponding difference value of each pixel point according to the first lab value and the second lab value.
Specifically, an ICC curve of a color management curve of a printer executing a print job is obtained, the first color value and the second color value are converted into a corresponding first lab value and a corresponding second lab value through the ICC curve, a difference value corresponding to each pixel point is calculated by performing a difference between the second lab value corresponding to each pixel point and the first lab value of the print medium, and a result of the color difference value calculated and obtained by using the lab values is more accurate than a result of the color difference value calculated and obtained in other color modes.
S3, traversing the first gray scale image to obtain a first gray scale value of each pixel point in the gray scale image;
specifically, the existing traversal algorithm is adopted to traverse all the pixel points in the first gray scale map to obtain the first gray scale value of each pixel point.
S4, comparing the first gray value with a set color threshold value to obtain a comparison result;
specifically, the first gray value of each pixel point is compared with a color threshold (for example, the color threshold is 1.5) obtained according to the characteristics of the printer to obtain a comparison result, and the ink discharge condition of each pixel point during printing is determined according to the comparison result.
And S5, setting the ink quantity value of the white ink channel when the image to be printed is printed according to the comparison result.
Specifically, in the embodiment, the white ink channel and the other color channels are parameter names for setting the use condition of the corresponding ink, and the range of the ink amount value of the white ink in the white ink channel is 0 to 100%, wherein the specific data value range of the ink amount value of the ink during printing is set according to different printing devices and use environments, and is a standard for quantifying the ink condition of the pixel point needing to be printed. In this embodiment, a first gray value is set as a, the color threshold is set as T, and when a is greater than or equal to T, the ink amount of the white ink in the white ink channel when the image to be printed is:
W=255-A
wherein W is an ink amount value of white ink of a white ink channel when the image to be printed is printed.
Referring to fig. 4, when a < T, the setting of the ink amount value of the white ink channel when the image to be printed is printed according to the comparison result includes:
s51, carrying out graying processing on the image to be printed to obtain a second grayscale image;
s52, traversing the second gray scale map to obtain a second gray scale value corresponding to each pixel point in the second gray scale map;
and S53, setting the ink amount value of the white ink channel when the image to be printed is printed according to the second gray value.
Specifically, graying a color image to be printed to obtain a gray map, marking the gray map as a second gray map, obtaining a second gray value corresponding to each pixel point in the gray map by adopting the existing traversal algorithm, calculating and obtaining an ink volume value of a printer white ink channel when the image to be printed is printed according to the second gray value, setting the second gray value as B, and setting the ink volume value of the printer white ink channel when the image to be printed is printed according to the second gray value as follows:
W=255-B
wherein W is an ink amount value of white ink of a white ink channel when the image to be printed is printed.
Preferably, the printer further includes a cyan channel, a magenta channel, a yellow channel, and a black channel, and when W is 0, the method further includes:
adjusting the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel of the corresponding pixel point according to the ink value of the white ink channel, so that the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel are as follows:
C=0,M=0,Y=0,K=0
where C is the ink value for the cyan channel, M is the ink value for the magenta channel, Y is the ink value for the yellow channel, and K is the ink value for the black channel.
Specifically, when the ink amount value of the white ink channel obtained by calculation is 0, the color values of the other channels of the printer are also adjusted to be 0, that is, the white ink channel does not discharge ink and the other channels do not discharge ink, and in the present embodiment, when the ink amount values of all the channels corresponding to the pixel points in the image to be printed are 0, the ink amount value of the white ink channel is also zero, that is, C is 0, M is 0, Y is 0, and K is 0, W is 0. The printer may also include a spot color channel, such as a red color channel, a blue color channel, and the like, and when the ink amount value of the white ink channel is zero, the ink amount value of the spot color channel is also zero.
The ink quantity value of the white ink channel of the printer is adjusted according to the comparison result of the color value in the image to be printed and the threshold value, instead of directly setting the ink quantity value of the white ink channel to be 100% according to the traditional method, the waste of the ink quantity is avoided, meanwhile, the ink quantity is set according to the color value instead of directly judging whether ink is not discharged or 100% of the ink is discharged, and therefore the printed image is good in transition and good in touch feeling.
Referring to fig. 5, an embodiment of the present invention provides an ink amount setting apparatus for a printer based on image processing, the apparatus including:
a first color value obtaining module 10, configured to obtain a color value of a printing medium, and record the color value as a first color value;
the first grayscale image obtaining module 20 is configured to process the image to be printed according to the first color value to obtain a first grayscale image;
the first gray value obtaining module 30 is configured to traverse the first gray map to obtain a first gray value of each pixel point in the gray map;
a comparison result obtaining module 40, configured to compare the first gray value with a set color threshold to obtain a comparison result;
and the ink quantity setting module 50 is used for setting the ink quantity value of the white ink channel when the image to be printed is printed according to the comparison result.
Preferably, the first grayscale image obtaining module 20 includes:
the second color value acquisition unit is used for acquiring color values corresponding to all pixel points in the image to be printed and recording the color values as second color values;
the color difference value acquisition unit is used for acquiring the difference value corresponding to each pixel point according to the first color value and the second color value;
the intermediate image generating unit is used for generating an intermediate image according to the difference value corresponding to each pixel point;
and the first gray-scale image acquisition unit is used for carrying out gray-scale processing on the intermediate image to obtain a corresponding first gray-scale image.
Preferably, the first gray value is set as A, the color threshold value is set as T, and when A is larger than or equal to T, the ink quantity value of the white ink channel when the image to be printed is as follows:
W=255-A
wherein W is an ink amount value of a white ink channel of the printer when the image to be printed is printed.
Preferably, assuming that the first gray value is a and the color threshold is T, when a < T, the ink amount setting module 50 includes:
the second gray-scale image acquisition unit is used for carrying out gray-scale processing on the image to be printed to obtain a second gray-scale image;
the second gray value acquisition unit is used for traversing the second gray map to acquire a second gray value corresponding to each pixel point in the second gray map;
and the ink amount value acquisition unit is used for setting the ink amount value of the white ink channel when the image to be printed is printed according to the second gray value.
Preferably, if the second gray value is B, the ink amount value of the white ink in the white ink channel when the image to be printed is set according to the second gray value as follows:
W=255-B
wherein W is an ink amount value of white ink of a white ink channel when the image to be printed is printed.
Preferably, the printer further includes a cyan channel, a magenta channel, a yellow channel, and a black channel, and when W is 0, the method further includes:
adjusting the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel of the corresponding pixel point according to the ink value of the white ink channel, so that the ink values of the cyan channel, the magenta channel, the yellow channel and the black channel are as follows:
C=0,M=0,Y=0,K=0
where C is the ink value for the cyan channel, M is the ink value for the magenta channel, Y is the ink value for the yellow channel, and K is the ink value for the black channel.
Preferably, when the color value of a pixel point in the image to be printed is C ═ 0, M ═ 0, Y ═ 0, and K ═ 0, then W ═ 0.
In addition, the printer ink amount setting method based on image processing described in connection with fig. 1 according to the embodiment of the present invention can be implemented by a printer ink amount setting apparatus based on image processing. Fig. 6 is a schematic diagram showing a hardware configuration of an ink amount setting apparatus for a printer based on image processing according to an embodiment of the present invention.
The printer ink amount setting device based on image processing may include a processor 401 and a memory 402 storing computer program instructions.
Specifically, the processor 401 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured as one or more Integrated circuits implementing embodiments of the present invention.
Memory 402 may include mass storage for data or instructions. By way of example, and not limitation, memory 402 may include a Hard Disk Drive (HDD), floppy Disk Drive, flash memory, optical Disk, magneto-optical Disk, tape, or Universal Serial Bus (USB) Drive or a combination of two or more of these. Memory 402 may include removable or non-removable (or fixed) media, where appropriate. The memory 402 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 402 is a non-volatile solid-state memory. In a particular embodiment, the memory 402 includes Read Only Memory (ROM). Where appropriate, the ROM may be mask-programmed ROM, Programmable ROM (PROM), Erasable PROM (EPROM), Electrically Erasable PROM (EEPROM), electrically rewritable ROM (EAROM), or flash memory or a combination of two or more of these.
The processor 401 reads and executes computer program instructions stored in the memory 402 to implement any of the image processing-based printer ink amount setting methods in the above-described embodiments.
In one example, the image processing-based printer ink amount setting apparatus may further include a communication interface 403 and a bus 410. As shown in fig. 6, the processor 401, the memory 402, and the communication interface 403 are connected via a bus 410 to complete communication therebetween.
The communication interface 403 is mainly used for implementing communication between modules, apparatuses, units and/or devices in the embodiments of the present invention.
The bus 410 includes hardware, software, or both to couple the components of the image processing based printer ink volume setting device to each other. By way of example, and not limitation, a bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hypertransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an infiniband interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a video electronics standards association local (VLB) bus, or other suitable bus or a combination of two or more of these. Bus 410 may include one or more buses, where appropriate. Although specific buses have been described and shown in the embodiments of the invention, any suitable buses or interconnects are contemplated by the invention.
In addition, in conjunction with the printer ink amount setting method based on image processing in the above-described embodiments, embodiments of the present invention may be implemented by providing a computer-readable storage medium. The computer readable storage medium having stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement any of the image processing-based printer ink amount setting methods of the above embodiments.
In summary, in the method, the device, the equipment and the medium for setting the ink amount of the printer based on image processing provided by the embodiments of the present invention, the color value of the printing medium is obtained, and is compared with the color values of all the pixels in the image to be printed, and the processed image color value is compared with the set color threshold value to obtain the ink amount value of the white ink laid on the bottom of the white ink to be printed at each pixel when the image to be printed is printed, so that not only can a part of the ink amount be saved, but also the printing cost is reduced, and the white ink amount is reasonably set according to the color value of each pixel in the image to be printed instead of directly outputting the white ink amount value of 100%, so that the printed image has good transition and good touch feeling.
It should also be noted that the exemplary embodiments mentioned in this patent describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, may be performed in an order different from the order in the embodiments, or may be performed simultaneously.
As described above, only the specific embodiments of the present invention are provided, and it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the module and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. It should be understood that the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the present invention, and these modifications or substitutions should be covered within the scope of the present invention.