Disclosure of Invention
In order to solve the problems in the related art, the present application provides an image data compression method and system applied to an inkjet printer.
The application aims to provide an image data compression method applied to an inkjet printer.
The above object of the present application is achieved by the following technical solutions:
an image data compression method applied to an ink-jet printer is applied to a host of the ink-jet printer and comprises the following steps:
acquiring information to be printed of a specified product and generating an image to be printed according to the information to be printed;
judging whether the information to be printed in the image to be printed is complete or not;
if the image to be printed is complete, scanning the image to be printed and generating original pixel information;
and after confirming the original pixel information, generating a data packet to be printed corresponding to the specified product, and carrying out code spraying printing on the specified product by an ink-jet printer according to the data packet to be printed.
By adopting the technical scheme, the information to be printed of the appointed product is firstly acquired, and then the information to be printed is generated into an image, so that the scanning and the processing are convenient; then judging whether the information to be printed in the image is complete or not, and ensuring that the information printed by the code spraying machine is complete finally; if the information is complete, scanning the image to obtain pixel information, and then confirming the pixel information to generate a data packet; by the mode, the completeness of the information to be printed is ensured, the scanning speed and the scanning efficiency are improved, the working efficiency of the ink jet printer is improved, and the accuracy of the ink jet printer for printing the information is improved.
The application in a preferred example may be further configured that the step of obtaining information to be printed of a specified product includes:
acquiring name information of a specified product;
calling a prestored product information association table from a database; the product information association table comprises product name information, information to be printed of the product and corresponding association information of the product name information and the information to be printed of the product;
and obtaining the information to be printed of the product according to the name information of the product and the product information association table.
By adopting the technical scheme, the name information of the appointed product can be obtained firstly, and then the information to be printed corresponding to the product name can be found according to the preset product information association table; in this way, the accuracy of the information is ensured.
In a preferred example, the method for determining whether the information to be printed in the image to be printed is complete includes:
the image to be printed comprises a plurality of columns of image units;
carrying out image processing and calculation on an image to be printed to obtain a distance value between an edge column image unit and an image edge in the image to be printed;
comparing the distance value to a distance threshold;
if the distance value is larger than the distance threshold value, the information to be printed in the image to be printed is complete information;
and if the distance value is smaller than the distance threshold value, the information to be printed in the image to be printed is incomplete information.
By adopting the technical scheme, the distance between the edge column image unit and the image edge is firstly calculated, then the distance is compared with the threshold value, if the distance is smaller than the threshold value, the edge column image unit is close to the image edge, the information in the image is incomplete at the moment, otherwise, the image is complete; by the mode, the working efficiency of the ink-jet printer is improved, and the accuracy of the printing information of the ink-jet printer is improved.
The present application may be further configured in a preferred example, wherein the step of calculating the distance threshold includes:
acquiring a minimum column spacing and a maximum column spacing between existing image units in an image to be printed;
the distance threshold is the sum of the maximum column spacing and K;
and K is obtained by subtracting the minimum column spacing from the maximum column spacing.
By adopting the technical scheme, the distance threshold is the sum of the maximum row spacing and K of the existing image units in the image to be printed, and K is equal to the maximum row spacing minus the minimum row spacing; by the method, the distance threshold values of all the images are different, and the distance threshold values are calculated according to the actual conditions of all the images, so that the accuracy and the reasonability of judging whether the information in the images is complete or not according to the distance threshold values are ensured.
The present application may be further configured in a preferred example to: the image processing mode comprises image recognition and contour extraction.
The present application may be further configured in a preferred example to: the scanning sequence of the image to be printed is that each image unit is scanned column by column from one end of the image.
The present application may be further configured in a preferred example, that the method of confirming original pixel information includes:
the original pixel information comprises a plurality of pixel points, and the confirmation of the original pixel information is that the pixel points are confirmed one by one;
confirming the color of the pixel points, and calculating the pixel points with the same color;
when a pixel point with different colors is encountered, all pixel points before the pixel point are packaged into a data segment.
The second purpose of the application is to provide an image data compression system applied to an ink jet printer.
The second application purpose of the present application is achieved by the following technical scheme:
an image data compression system applied to an ink jet printer, comprising:
the system comprises an acquisition module, a printing module and a printing module, wherein the acquisition module is used for acquiring information to be printed of a specified product and generating an image to be printed according to the information to be printed;
the judging module is used for judging whether the information to be printed in the image to be printed is complete or not;
the scanning module is used for scanning the image to be printed column by column and generating original pixel information;
and the confirming module is used for generating a data packet to be printed corresponding to the specified product after confirming the original pixel information.
The third purpose of the application is to provide an intelligent terminal.
The third objective of the present application is achieved by the following technical solutions:
an intelligent terminal comprises a memory and a processor, wherein the memory stores computer program instructions of the image data compression method applied to the ink-jet printer, and the computer program instructions can be loaded and executed by the processor.
It is a fourth object of the present application to provide a computer medium capable of storing a corresponding program.
The fourth application purpose of the present application is achieved by the following technical solutions:
a computer readable storage medium storing a computer program which can be loaded by a processor and which can execute any of the above image data compression methods applied to an ink jet printer.
In summary, the present application includes at least one of the following beneficial technical effects:
the method comprises the steps of obtaining an image to be printed by processing information to be printed corresponding to a product, and then judging whether the information in the image is complete or not to ensure the integrity of the information; then scanning the image to obtain pixel information, and generating a data packet for code spraying printing after confirming the pixel information; by the mode, the working efficiency of the ink-jet printer is improved, and the accuracy of the printing information of the ink-jet printer is improved.
Detailed Description
The present embodiment is only for explaining the present application and is not limited to the present application, and those skilled in the art can make modifications without inventive contribution to the present embodiment as needed after reading the present specification, but all of them are protected by patent law within the scope of the claims of the present application.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
The embodiments of the present application will be described in further detail below with reference to the drawings.
The application also provides an image data compression method applied to the inkjet printer, the method is applied to the host of the inkjet printer, and the main flow of the method is described as follows.
As shown in fig. 1:
step S101: and acquiring information to be printed of a specified product and generating an image to be printed according to the information to be printed.
Before the inkjet printer works, the host computer needs to be guaranteed to store information to be printed corresponding to a specified product, wherein the information to be printed comprises information such as the production date of the product, the validity period of the product, logo of a production product company, the serial number of the product, and the bar code of the product.
It is understood that the specific product refers to a product that needs to be subjected to code spraying, and in the embodiment of the application, when an ink-jet printer is used, the name of the product is known.
Since the name of the product is known, after the name information of the specified product is acquired, the pre-stored product information association table is called from the local database, and then the information to be printed of the specified product can be acquired according to the name information of the specified product and the pre-stored product information association table.
It can be understood that before the code spraying work starts, related staff can store related information of a product needing code spraying in a product information association table, then store the product information association table in a local database, when information to be printed of a specified product needs to be acquired, call the product information association table, and then find the information to be printed corresponding to the specified product in the product information association table according to name information of the product.
The product information association table comprises product name information, information to be printed of the product and corresponding association information of the product name information and the information to be printed of the product; for example, if the product name information is "a", the information associated with the product name "a" in the product information association table is the production date "2020, 3 and 15 days", the effective date "2020, 4 and 15 days", the product serial number "8923270232", and the barcode of the product.
It can be understood that the information to be printed corresponding to the product can be called from the product information association table as long as the product name information and the product information association table are obtained.
After the information to be printed is obtained, an image to be printed is generated according to the information to be printed; in the embodiment of the present application, the information to be printed may be converted into the image to be printed by using related software, for example, the above process may be implemented by using software such as PS, which is a common technical means and is not described herein again.
Step S102: and judging whether the information to be printed in the image to be printed is complete or not.
After the image to be printed is obtained, the information in the image to be printed needs to be judged, and although the image to be printed is generated according to the information to be printed, in the process of converting the characters into the pictures, the information is lost due to special conditions, so that the information in the image to be printed needs to be confirmed, and the information to be printed in the image to be printed is ensured to be complete.
In the embodiment of the application, the following method is adopted to judge whether the information to be printed in the image to be printed is complete.
1. And carrying out image processing and calculation on the image to be printed to obtain a distance value between an edge column image unit and an image edge in the image to be printed.
2. Comparing the distance value to a distance threshold.
3. And if the distance value is greater than the distance threshold value, the information to be printed in the image to be printed is complete information.
4. And if the distance value is smaller than the distance threshold value, the information to be printed in the image to be printed is incomplete information.
In the embodiment of the application, each image to be printed comprises a plurality of columns of image units; after the image to be printed is obtained, obtaining all image units in the image to be printed through image recognition, and then obtaining the outline of the edge column image unit in the image and the edge outline of the image through an outline extraction algorithm; then, calculating the distance between the edge column image unit and the image edge to obtain a distance value between the edge column image unit and the image edge; it can be understood that the generated image to be printed is a rectangle, and there is a certain distance between each image unit in the image and the whole frame of the image, if the distance does not meet the requirement, it indicates that the information in the image is incomplete, otherwise, it indicates that the information in the image is complete.
When the distance between the edge column image unit and the image edge is calculated, the shortest distance between the edge column image unit and the image edge is ensured to be calculated; namely, the image edge is regarded as a line segment, the edge column image unit is also regarded as a line segment, the shortest distance between the two line segments is calculated, and then the distance is compared with a preset distance threshold value, so that whether the information in the image to be printed is complete or not is judged.
In the embodiment of the application, because the information to be printed of each product is different, the distance threshold is determined according to the information to be printed of the product, and the distance threshold is different for different products.
The method of calculating the threshold in the practice of the present application is as follows.
Firstly, calculating the minimum column spacing and the maximum column spacing between the existing image units in the image to be printed; then the distance threshold is equal to the sum of the maximum column spacing and K; wherein K is obtained by subtracting the minimum column spacing from the maximum column spacing.
Because the image to be printed is composed of a plurality of columns of image units, and the distances between the image units in different columns are different, firstly, the distance between the edge column image unit and the image edge is ensured to be larger than the maximum column distance; because the maximum column pitch of the existing columns may not be the true maximum column pitch in the image to be printed, which is due to the loss of information in the image, it is necessary to ensure that the distance between the edge column image unit and the image edge is greater than the maximum column pitch, but the distance cannot be much greater than the maximum column pitch, which easily causes the information in the image to be complete, and the result is erroneously judged to be incomplete, so that K exists; the distance threshold is obtained by adding the maximum column pitch and K, and the distance threshold ensures that the two abnormal conditions do not occur.
After the distance value and the distance threshold value are obtained, comparing the distance value and the distance threshold value; if the information to be printed is complete, then go on to step S103; if the information to be printed is incomplete, the inkjet printer host outputs alarm information to remind a worker, so that the integrity and the accuracy of the information to be printed are guaranteed.
Step S103: and scanning the image to be printed and generating original pixel information.
After the image to be printed is judged, the image is scanned after the information in the image to be printed is determined to be complete; it should be noted that, in the embodiment of the present application, the scanning sequence of the image to be printed is to scan each image unit column by column from one end of the image, and in this way, the complete scanning of the image to be printed can be ensured, the situation of information omission does not occur, and the integrity and accuracy of the information to be printed are ensured.
Step S104: and generating a data packet to be printed corresponding to a specified product after confirming the original pixel information.
In the embodiment of the present application, the method of confirming the original pixel information is as follows.
Firstly, color confirmation is carried out on pixel points in original pixel information, and the pixel points with the same color are calculated; when pixels with different colors are encountered, packaging all pixels before the pixel into a data segment; after all the pixel points are packaged into data segments, the data segments are sequentially combined to form a data packet to be printed corresponding to a specified product; and finally, the code spraying machine performs code spraying printing on the specified product according to the data packet to be printed.
The original pixel information can be understood as the pixel information of an image to be printed, and the image is formed by arranging and combining pixels; the original pixel information comprises a plurality of pixel points, and the confirmation of the original pixel information is that the pixel points are confirmed one by one; since the images mentioned in the application are all located in the inkjet printer host, namely in the computer, the images can be understood as computer images; and the minimum image unit in the computer image is a pixel point.
The colors of all the pixel points are different, and the information is formed by combining a plurality of pixel points, so that the continuous pixel points with the same color need to be counted until the pixel points with different colors appear, at this moment, the information which needs to be expressed by the part of the pixel points is completely expressed, and then the part of the pixel points is divided into a data section.
In the embodiment of the application, the data segment length is specified to include two types, one is 8bits, and the other is 16bits; when the continuous counting value is less than 64, using a data segment with the length of 8 bits; when the continuous count value is greater than or equal to 64, a data segment of 16bits is used.
Wherein, for a data segment with a length of 8 bits; the 0 th to 5 th bits are used for representing the number of pixel points with the same color; the sixth bit is 0 and represents a data segment of 8 bits; the seventh bit is 0, which indicates that the pixel value of the data segment is 0, and the seventh bit is 1, which indicates that the pixel value of the data segment is 1.
For a data segment of length 16bits; bits 0-13 are used to indicate the number of pixels of the same color; the fourteenth bit is 1, and is represented as a data segment of 16bits; the fifteenth bit is 0 indicating that the pixel value of the data segment is 0, and the fifteenth bit is 1 indicating that the pixel value of the data segment is 1.
By the mode, the original pixel information is compressed, the image transmission speed of the host of the ink-jet printer is increased, the ink-jet printing speed of the ink-jet printer is increased, the working efficiency of the ink-jet printer is increased, and the production efficiency of a production line is increased.
The application also provides an image data compression system applied to an ink jet printer, and as shown in fig. 2, the image data compression system applied to the ink jet printer comprises an acquisition module 1, a data storage module and a data transmission module, wherein the acquisition module 1 is used for acquiring information to be printed of a specified product and generating an image to be printed according to the information to be printed; the judging module 2 is used for judging whether the information to be printed in the image to be printed is complete or not; the scanning module 3 is used for scanning the image to be printed column by column and generating original pixel information; and the confirming module 4 is used for generating a data packet to be printed corresponding to the specified product after confirming the original pixel information.
In order to better execute the program of the method, the application also provides an intelligent terminal which comprises a memory and a processor.
Wherein the memory may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the above-described image data compression method applied to the inkjet printer, and the like; the storage data area may store data and the like involved in the image data compression method applied to the inkjet printer described above.
A processor may include one or more processing cores. The processor executes the various functions of the present application and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory, invoking data stored in the memory, and so on. The processor may be at least one of an application specific integrated circuit, a digital signal processor, a digital signal processing device, a programmable logic device, a field programmable gate array, a central processing unit, a controller, a microcontroller, and a microprocessor. It is understood that the electronic devices for implementing the above processor functions may be other devices, and the embodiments of the present application are not limited in particular.
The present application also provides a computer-readable storage medium, for example, comprising: a U-disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes. The computer readable storage medium stores a computer program that can be loaded by a processor and executes the above-described image data compression method applied to an ink jet printer.
The foregoing description is only exemplary of the preferred embodiments of the invention and is provided for the purpose of illustrating the general principles of the technology. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the disclosure. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.