A method and system for processing image data of a printing terminal
By binarizing, slicing and compressing printed images, the problem of insufficient transmission rate when printing images is solved, efficient transmission and high-quality printing are achieved, costs are reduced, and printing efficiency is improved.
Patent Information
- Application Number
- CN202310440830.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-23
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-04-23
AI Technical Summary
In the existing technology, when printing pictures, due to the slow transmission rate of the peripheral interface, the printing speed cannot meet expectations, which affects the printing quality and user experience, and the method of increasing the cost will increase the cost.
By binarizing, slicing and compressing the image to be printed, smaller data blocks are selected for packet transmission, a simple decompression algorithm is used to decompress the image at the printing terminal, and a conventional low-speed data transmission interface is used to transmit the data.
It improves the transmission speed and print quality of print data, reduces costs, ensures data security, and can print while transmitting, avoiding waiting, and improving printing efficiency.
Smart Images

Figure CN116610272B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a method and system for processing image data of a printing terminal. Background Art
[0002] The printing terminal receives the printing data through various interfaces, such as USB, serial port, Bluetooth, etc. After data processing, it is transmitted to the print head and controls the motor to print characters. When printing pictures, because the picture-type printing data describes all the dot matrix data of a picture, the data volume of the picture-type printing data is larger than that of the non-picture-type printing data. For example, if each line has 576 dots, 72 bytes of data size is required to print a complete dot line. If the printing speed of the printer needs to reach 60 mm / s, 34560 bytes (72*60*8) of data volume is required per second, that is, an effective data transmission rate of 276480 bps (34560*8).
[0003] However, due to the slow transmission rate of some peripheral interfaces (especially Bluetooth interfaces), the expected printing speed cannot be achieved when printing pictures. There are currently three solutions to solve this problem:
[0004] (1) The desired printing speed can be met by printing while receiving data. However, this method is prone to data interruption and thus causes jamming, which ultimately affects the printing quality.
[0005] (2) The method of receiving data before printing is adopted to meet the expected printing speed. This method requires the configuration of a large-capacity RAM, which leads to increased costs. In addition, there is also the problem of long waiting time for users.
[0006] (3) By using more and higher-configuration peripheral ICs to increase the interface data transmission speed and meet the expected printing speed, this method will greatly increase the cost. Summary of the invention
[0007] In order to overcome the shortcomings of the prior art, the present invention provides a method and system for processing image data of a printing terminal, which is used to solve the technical problems that when the prior method prints images, in order to meet the expected printing speed, the printing quality is affected, the user experience is reduced, and the cost is greatly increased, thereby achieving the purpose of effectively improving the transmission speed while ensuring the printing quality and user experience, and not significantly increasing the cost.
[0008] To solve the above problems, the technical solution adopted by the present invention is as follows:
[0009] A method for processing terminal image data for printing comprises the following steps:
[0010] Obtaining a picture to be printed, and binarizing the picture to be printed to obtain a black and white picture;
[0011] Slicing the black-and-white picture to form a plurality of data blocks;
[0012] Running a compression algorithm on the plurality of data blocks to obtain compressed data blocks;
[0013] Determining whether the size of each compressed data block is smaller than the size of the original data block;
[0014] If yes, the compressed data block is used as the data block to be transmitted;
[0015] If not, the original data block is used as the data block to be transmitted;
[0016] The data blocks to be transmitted are packaged and then transmitted to the printing terminal.
[0017] As a preferred embodiment of the present invention, when the image to be printed is binarized to obtain a black and white image, it includes:
[0018] Performing grayscale processing on the image to be printed to obtain a corresponding grayscale image;
[0019] Compare the grayscale value of each pixel in the grayscale image with a preset binary conversion value;
[0020] If the grayscale value is less than the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 0; if the grayscale value is greater than or equal to the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 255;
[0021] After completing the adjustment of the grayscale values of all the pixels, the black and white image is finally obtained;
[0022] Wherein, when grayscale processing is performed on the image to be printed, it includes:
[0023] Obtain the grayscale values of all pixels in the image to be printed, and obtain a grayscale value set, which is the grayscale image, as shown in Formula 1:
[0024]
[0025] Where R, G, and B represent the values of the red, green, and blue channels respectively.
[0026] As a preferred embodiment of the present invention, when comparing the grayscale value of each pixel in the grayscale image with a preset binary conversion value, it includes:
[0027] Each pixel in the grayscale image is scanned from left to right and from top to bottom using the Floyd-Steinberg dithering algorithm.
[0028] As a preferred implementation manner of the present invention, when the black-and-white picture is sliced to form a plurality of data blocks, it includes:
[0029] A slicing step is performed, wherein the slicing step comprises:
[0030] Finding pixel points with a pixel value of 0 in the black-and-white image to obtain a data graph;
[0031] Obtain pixel points corresponding to multiple ordinates under the same abscissa in the data graph, and further obtain a pixel point with a ordinate in the middle position;
[0032] Connect the pixel points whose ordinates are in the middle in sequence to obtain a smooth data curve;
[0033] Using a data trend analysis method to segment the smooth data curve into a plurality of smooth curve segments, mapping the boundary points of the smooth curve segments onto the black-and-white image, and slicing the black-and-white image according to the mapping results to obtain the plurality of data blocks;
[0034] After completing the slicing step, randomly select a data block, further obtain the number of data points contained in the data block, and compare the number of data points with the preset number of data points;
[0035] If the number of data points contained in the data block is less than or equal to the preset number of data points, then stop executing the slicing step;
[0036] If the number of data points contained in the data block is greater than the preset number of data points, the slicing step continues to be performed.
[0037] As a preferred embodiment of the present invention, when obtaining a data graph, it includes:
[0038] Draw the data graph C = [c1, c2, ...., c m ], where m represents the number of data points with a pixel value of 0, and after removing the border and all annotations of the data graph, it is saved in a picture format to obtain an initial data graph;
[0039] The size of the initial data graph is obtained, and the size of the initial data graph is reduced to obtain the data graph, as shown in Formula 2 and Formula 3:
[0040]
[0041]
[0042] Wherein, z1 and z2 are the sizes of the data graph, M is the reduction ratio, and l1 and l2 are the sizes of the initial data graph.
[0043] As a preferred implementation manner of the present invention, when obtaining the plurality of data blocks, it includes:
[0044] All boundary points of each smooth curve segment are obtained, and corresponding vectors are generated, as shown in Formula 4:
[0045] C′=[c′1,c′2,...,c′ m ] Τ (4);
[0046] In the formula, C′ is the set of all boundary points, c′ m are all boundary points of each of the smooth curve segments;
[0047] Map all the boundary points one by one onto the black-and-white image to obtain a number of boundary division points, as shown in Formula 5:
[0048]
[0049] In the formula, c m are the several boundary dividing points, l1 is the length of the initial data graph, and z1 is the length of the data graph;
[0050] The black-and-white image is sliced according to the plurality of boundary division points to obtain the plurality of data blocks.
[0051] As a preferred implementation of the present invention, when the compression algorithm is run on the plurality of data blocks, it includes:
[0052] Running a compression algorithm on the plurality of data blocks according to a unit data protocol to obtain the compressed data blocks;
[0053] The compressed data block includes a data header, data content and data length.
[0054] As a preferred implementation manner of the present invention, when the data block to be transmitted is packaged, it includes:
[0055] Acquire all the compressed data blocks in the data blocks to be transmitted, and further obtain the number and checksum of the compressed data blocks;
[0056] Packaging according to all the compressed data blocks, the number of the compressed data blocks and the checksum;
[0057] Acquire all the original data blocks in the data block to be transmitted, and further obtain the number and checksum of the original data blocks;
[0058] Packaging is performed according to all the original data blocks, the number of the original data blocks and the checksum.
[0059] As a preferred implementation manner of the present invention, when obtaining the checksum of the compressed data block and the original data block, it includes:
[0060] A CRC algorithm is used to obtain the checksum of the compressed data block and the original data block.
[0061] A system for processing image data of a printing terminal, comprising:
[0062] Binarization unit: used for obtaining a picture to be printed, and binarizing the picture to be printed to obtain a black and white picture;
[0063] Slicing unit: used for slicing the black and white picture to form a number of data blocks;
[0064] Compression unit: used for running a compression algorithm on the plurality of data blocks to obtain compressed data blocks;
[0065] Transmission unit: used to determine whether the size of each compressed data block is smaller than the size of the original data block; if so, the compressed data block is used as the data block to be transmitted; if not, the original data block is used as the data block to be transmitted; after packaging the data block to be transmitted, it is transmitted to the printing terminal.
[0066] Compared with the prior art, the present invention has the following beneficial effects:
[0067] (1) After the printing data is processed by the processing method provided by the present invention, the printing terminal only needs to use a simple decompression algorithm to decompress the processed data after receiving the data, and the simple decompression algorithm is suitable for running on a conventional single-chip microcomputer, so that the printing terminal can complete the data decompression in a relatively short time;
[0068] (2) The processing method provided by the present invention can effectively improve the transmission speed of printing data, and can still cooperate with high-speed printing even when facing a large amount of printing data;
[0069] (3) The processing method provided by the present invention has high data security during transmission and is not easily lost;
[0070] (4) The compression algorithm provided by the present invention can compress data by up to 256 times, thereby greatly improving the transmission speed of printed data;
[0071] (5) The processing method of the present invention can print while transmitting without waiting, further improving the printing efficiency;
[0072] (6) When the data processed by the processing method of the present invention is transmitted, no additional hardware configuration is required, and a conventional low-speed data transmission interface can be sufficient, thereby effectively saving costs.
[0073] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 - is a schematic diagram of a compressed data block according to an embodiment of the present invention;
[0075] Figure 2 - is a schematic diagram of the packetized data to be transmitted according to an embodiment of the present invention;
[0076] Figure 3 - is a flow chart of data transmission and printing according to an embodiment of the present invention;
[0077] Figure 4 - is a step diagram of a method for processing printing terminal image data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0078] The method for processing the printing terminal image data provided by the present invention is as follows: Figure 4 As shown, the following steps are included:
[0079] Step S1: Obtain a picture to be printed, and binarize the picture to be printed to obtain a black and white picture;
[0080] Step S2: Slice the black and white image to form a number of data blocks;
[0081] Step S3: running a compression algorithm on a number of data blocks to obtain compressed data blocks;
[0082] Step S4: determining whether the size of each compressed data block is smaller than the size of the original data block; if so, taking the compressed data block as the data block to be transmitted; if not, taking the original data block as the data block to be transmitted;
[0083] Step S5: Packaging the data block to be transmitted and transmitting it to the printing terminal.
[0084] In the above step S1, when the image to be printed is binarized to obtain a black and white image, it includes:
[0085] Grayscale the image to be printed to obtain a corresponding grayscale image;
[0086] Compare the grayscale value of each pixel in the grayscale image with the preset binary conversion value;
[0087] If the grayscale value is less than the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 0; if the grayscale value is greater than or equal to the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 255;
[0088] After completing the adjustment of the grayscale values of all pixels, a black and white image is finally obtained;
[0089] Among them, when grayscale processing is performed on the image to be printed, it includes:
[0090] Get the grayscale values of all pixels in the image to be printed, and get a grayscale value set, which is a grayscale image. Specifically, it is shown in formula 1:
[0091]
[0092] Where R, G, and B represent the values of the red, green, and blue channels respectively.
[0093] Furthermore, when comparing the grayscale value of each pixel in the grayscale image with the preset binary conversion value, it includes:
[0094] Use the Floyd-Steinberg dithering algorithm to scan each pixel in the grayscale image from left to right and from top to bottom.
[0095] Furthermore, in the above step S1, in order to improve the accuracy of the printed data and thus improve the printing quality, the present application may also introduce Gaussian filtering to reduce noise on the black and white image while satisfying the transmission speed, as shown in Formula 6:
[0096]
[0097] Where (λ,o) is the coordinate of the center point, θ 2 is the variance.
[0098] In the above step S2, when the black and white picture is sliced to form a plurality of data blocks, it includes:
[0099] Perform a slicing step, which includes:
[0100] Find the pixel points with a pixel value of 0 in the black and white image and obtain a data graph;
[0101] Obtain pixel points corresponding to multiple ordinates under the same abscissa in the data graph, and further obtain the pixel point with the ordinate in the middle position;
[0102] Connect the pixel points whose ordinates are in the middle in sequence to obtain a smooth data curve;
[0103] The smooth data curve is divided into several smooth curve segments by using the data trend analysis method, and the boundary points of the smooth curve segments are mapped onto the black-and-white image, and the black-and-white image is sliced according to the mapping results to obtain several data blocks;
[0104] After completing the slicing step, a data block is randomly selected, and the number of data points contained in the data block is further obtained, and the number of data points is compared with the preset number of data points;
[0105] If the number of data points contained in the data block is less than or equal to the preset number of data points, the slicing step is stopped;
[0106] If the number of data points contained in the data block is greater than the preset number of data points, continue to execute the slicing step.
[0107] Further, when a data graph is obtained, it includes:
[0108] Draw a data graph C = [c1, c2, ...., c m ], where m represents the number of data points with a pixel value of 0, and after removing the border and all annotations of the data graph, it is saved in a picture format to obtain the initial data graph;
[0109] The size of the initial data graph is obtained, and the size of the initial data graph is reduced to obtain a data graph, as shown in Formula 2 and Formula 3:
[0110]
[0111]
[0112] Where z1 and z2 are the sizes of the data graph, M is the reduction ratio, and l1 and l2 are the sizes of the initial data graph.
[0113] Furthermore, when a plurality of data blocks are obtained, including:
[0114] Obtain all boundary points of each smooth curve segment and generate corresponding vectors, as shown in Formula 4:
[0115] C′=[c′1,c′2,...,c′ m ] Τ (4);
[0116] In the formula, C′ is the set of all boundary points, c′ m are all the boundary points of each smooth curve segment;
[0117] Map all boundary points to the black and white image one by one to obtain several boundary division points, as shown in Formula 5:
[0118]
[0119] In the formula, c m are several boundary dividing points, l1 is the length of the initial data graph, and z1 is the length of the data graph;
[0120] According to several boundary points, the black and white image is sliced to obtain several data blocks.
[0121] Specifically, the slicing steps provided by the present invention can meet the requirements of accurate segmentation of images under different data volumes. The general slicing method is only suitable for segmentation of images with small data volumes. When applied to the segmentation of images with large data volumes, it is difficult to obtain accurate segmentation results. Data blocks may have data overlap and data loss, etc., which results in the subsequent transmission of data blocks to the printing device for printing. Although the transmission speed is improved, the printing quality is affected. The present application is a solution proposed for large data volumes and slow transmission speeds, so the problem of accurate segmentation of large data volume images must be solved. The above slicing steps can meet the requirements of accurate segmentation of images with small data volumes as well as accurate segmentation of images with large data volumes. At the same time, the operation is simple and the segmentation is fast, which ensures the data transmission speed and printing quality.
[0122] In the above step S3, when the compression algorithm is run on a number of data blocks, it includes:
[0123] Running a compression algorithm on a number of data blocks according to a unit data protocol to obtain compressed data blocks;
[0124] The compressed data block includes a data header, data content and data length.
[0125] Furthermore, the data content is the original data, and the data length indicates the number of times the data is repeated.
[0126] Specifically, the compressed data block is as follows: Figure 1 As shown, the following is an example of the unit data protocol:
[0127] The data header is 00: the data content is 4 bits, which is the original data, and the data length is 10 bits, which indicates the number of times the data is repeated. The maximum data size that can be expressed by this compression is: 4*2^10=4096 bits, which is 512 bytes of data, and the compressed data only takes 2 bytes, and the compression ratio is 256;
[0128] The data header is 01: the data content is 12 bits, which is the original data, and the data length is 2 bits, which indicates the number of times the data is repeated. The maximum data size that can be expressed by this compression is: 12*2^2=48 bits, which is 6 bytes of data, and the compressed data only takes 2 bytes, and the compression ratio is 3;
[0129] The data header is 10: the data content is 8 bits, which is the original data, and the data length is 4 bits, which indicates the number of times the data is repeated. The maximum data size that can be expressed by this compression is: 8*2^4=128 bits, that is, 16 bytes of data, and the compressed data only takes up 2 bytes, and the compression ratio is 8;
[0130] The data header is 11: the data content is 11 bits, which is the original data, and the data length is 1 bit, which indicates the number of times the data is repeated. The maximum data size that can be expressed by this compression is: 11*2^1=22 bits, which is 2.75 bytes of data, and the compressed data only takes up 2 bytes, with a compression ratio of 1.375.
[0131] In the above step S4, the present invention compares the compressed data block with the original data block and selects a smaller data block for packaging, thereby obtaining a better transmission speed.
[0132] In the above step S5, when the data block to be transmitted is packaged, it includes:
[0133] Obtain all compressed data blocks in the data blocks to be transmitted, and further obtain the number and checksum of the compressed data blocks;
[0134] Packing is performed according to all compressed data blocks, the number of compressed data blocks and the checksum;
[0135] Obtain all original data blocks in the data block to be transmitted, and further obtain the number and checksum of the original data blocks;
[0136] Packaging is performed based on all original data blocks, the number of original data blocks and the checksum.
[0137] Specifically, the data to be transmitted after packetization is as follows: Figure 2 As shown, the meanings of each protocol header are as follows:
[0138] 00: data is not compressed;
[0139] 01: Data compression;
[0140] 10: Reserved;
[0141] 11: Reserved.
[0142] Furthermore, when obtaining the checksum of the compressed data block and the original data block, it includes:
[0143] The CRC algorithm is used to obtain the checksum of the compressed data block and the original data block.
[0144] Specifically, the present invention adds a verification method to the data block, thereby ensuring the accuracy of the data block during the transmission process and achieving high-quality printing.
[0145] In the above step S5, when transmitting the print data to the printing terminal, the APP or the host computer transmits the data to the printing terminal through an interface such as Bluetooth, serial port, USB, etc.; the printing terminal decompresses the data according to the agreed protocol, and the image can be restored for printing, as shown in the following example. Figure 3 shown.
[0146] The printing terminal picture data processing system provided by the present invention comprises: a binarization unit, a slicing unit, a compression unit and a transmission unit.
[0147] The binarization unit is used to obtain the image to be printed, and binarize the image to be printed to obtain a black and white image.
[0148] The slicing unit is used to slice the black and white image into several data blocks.
[0149] The compression unit is used to run a compression algorithm on a number of data blocks to obtain compressed data blocks;
[0150] The transmission unit is used to determine whether the size of each compressed data block is smaller than the size of the original data block; if so, the compressed data block is used as the data block to be transmitted; if not, the original data block is used as the data block to be transmitted; after the data block to be transmitted is packaged, it is transmitted to the printing terminal.
[0151] Compared with the prior art, the present invention has the following beneficial effects:
[0152] (1) After the printing data is processed by the processing method provided by the present invention, the printing terminal only needs to use a simple decompression algorithm to decompress the processed data after receiving the data, and the simple decompression algorithm is suitable for running on a conventional single-chip microcomputer, so that the printing terminal can complete the data decompression in a relatively short time;
[0153] (2) The processing method provided by the present invention can effectively improve the transmission speed of printing data, and can still cooperate with high-speed printing even when facing a large amount of printing data;
[0154] (3) The processing method provided by the present invention has high data security during transmission and is not easily lost;
[0155] (4) The compression algorithm provided by the present invention can compress data by up to 256 times, thereby greatly improving the transmission speed of printed data;
[0156] (5) The processing method of the present invention can print while transmitting without waiting, further improving the printing efficiency;
[0157] (6) When the data processed by the processing method of the present invention is transmitted, no additional hardware configuration is required, and a conventional low-speed data transmission interface can be sufficient, thereby effectively saving costs.
[0158] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A method for processing image data of a printing terminal, characterized in that: The following steps are involved: Obtaining a picture to be printed, and binarizing the picture to be printed to obtain a black and white picture; Slicing the black-and-white picture to form a plurality of data blocks; Running a compression algorithm on the plurality of data blocks to obtain compressed data blocks; Determining whether the size of each compressed data block is smaller than the size of the original data block; If yes, the compressed data block is used as the data block to be transmitted; If not, the original data block is used as the data block to be transmitted; Packaging the data block to be transmitted and transmitting it to the printing terminal; Wherein, when the image to be printed is binarized to obtain a black and white image, it includes: Performing grayscale processing on the image to be printed to obtain a corresponding grayscale image; Compare the grayscale value of each pixel in the grayscale image with a preset binary conversion value; If the grayscale value is less than the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 0; if the grayscale value is greater than or equal to the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 255; After completing the adjustment of the grayscale values of all the pixels, the black and white image is finally obtained; Wherein, when grayscale processing is performed on the image to be printed, it includes: Obtain the grayscale values of all pixels in the image to be printed, and obtain a grayscale value set, which is the grayscale image, as shown in Formula 1: In the formula, R, G, and B represent the values of the red, green, and blue channels respectively; When comparing the grayscale value of each pixel in the grayscale image with a preset binary conversion value, it includes: Scan each pixel in the grayscale image from left to right and from top to bottom using the Floyd-Steinberg dithering algorithm; After getting the black and white picture, it also includes: Gaussian filtering is introduced to reduce noise in black and white images. The specific formula is shown in Formula 6: Where (λ,ο) is the coordinate of the center point, θ 2 is the variance; When the compression algorithm is run on the plurality of data blocks, it includes: running the compression algorithm on the plurality of data blocks according to the unit data protocol to obtain the compressed data blocks; The compressed data block includes a data header, data content and data length, wherein the data content is the original data, and the data length indicates the number of times the data is repeated; The printing terminal decompresses the data according to the agreed protocol, and can restore the image for printing; When the data header is 00, the data content is 4 bits, the data length is 10 bits, the maximum data size that can be expressed by this compression is 512 bytes, the compressed data only takes 2 bytes, and the compression ratio is 256; Wherein, when the black-and-white picture is sliced to form a plurality of data blocks, it includes: A slicing step is performed, wherein the slicing step comprises: Finding pixel points with a pixel value of 0 in the black-and-white image to obtain a data graph; Obtain pixel points corresponding to multiple ordinates under the same abscissa in the data graph, and further obtain a pixel point with a ordinate in the middle position; Connect the pixel points whose ordinates are in the middle in sequence to obtain a smooth data curve; Using a data trend analysis method to segment the smooth data curve into a plurality of smooth curve segments, mapping boundary points of the smooth curve segments onto the black-and-white image, and slicing the black-and-white image according to the mapping results to obtain the plurality of data blocks; After completing the slicing step, randomly select a data block, further obtain the number of data points contained in the data block, and compare the number of data points with the preset number of data points; If the number of data points contained in the data block is less than or equal to the preset number of data points, then stop executing the slicing step; If the number of data points included in the data block is greater than the preset number of data points, continue to execute the slicing step; When the data block to be transmitted is packaged, it includes: Acquire all the compressed data blocks in the data blocks to be transmitted, and further obtain the number and checksum of the compressed data blocks; Packaging according to all the compressed data blocks, the number of the compressed data blocks and the checksum; Acquire all the original data blocks in the data block to be transmitted, and further obtain the number and checksum of the original data blocks; Packaging according to all the original data blocks, the number of the original data blocks and the checksum; The protocol header is used to distinguish whether the data to be transmitted after packetization has been compressed.
2. The method for processing printing terminal image data according to claim 1, characterized in that: When a data graph is obtained, it includes: Draw the data graph C = [c1, c2, ...., c m ], where m represents the number of data points with a pixel value of 0, and after removing the border and all annotations of the data graph, it is saved in a picture format to obtain an initial data graph; The size of the initial data graph is obtained, and the size of the initial data graph is reduced to obtain the data graph, as shown in Formula 2 and Formula 3: Wherein, z1 and z2 are the sizes of the data graph, M is the reduction ratio, and l1 and l2 are the sizes of the initial data graph.
3. The method for processing printing terminal image data according to claim 2, characterized in that: When obtaining the plurality of data blocks, it includes: All boundary points of each smooth curve segment are obtained, and corresponding vectors are generated, as shown in Formula 4: C′=[c1′,c′2,...,c′ m ] Τ (4); In the formula, C′ is the set of all boundary points, c′ m are all boundary points of each of the smooth curve segments; Map all the boundary points one by one onto the black-and-white image to obtain a number of boundary division points, as shown in Formula 5: In the formula, c m are the several boundary dividing points, l1 is the length of the initial data graph, and z1 is the length of the data graph; The black-and-white image is sliced according to the plurality of boundary division points to obtain the plurality of data blocks.
4. The method for processing printing terminal image data according to claim 1, characterized in that: When obtaining the checksum of the compressed data block and the original data block, it includes: A CRC algorithm is used to obtain the checksum of the compressed data block and the original data block.
5. A system for processing image data of a printing terminal, characterized in that: include: Binarization unit: used for obtaining a picture to be printed, and binarizing the picture to be printed to obtain a black and white picture; Slicing unit: used for slicing the black and white picture to form a number of data blocks; Compression unit: used for running a compression algorithm on the plurality of data blocks to obtain compressed data blocks; Transmission unit: used to determine whether the size of each compressed data block is smaller than the size of the original data block; If yes, the compressed data block is used as the data block to be transmitted; If not, the original data block is used as the data block to be transmitted; Packaging the data block to be transmitted and transmitting it to the printing terminal; Wherein, when the image to be printed is binarized to obtain a black and white image, it includes: Performing grayscale processing on the image to be printed to obtain a corresponding grayscale image; Compare the grayscale value of each pixel in the grayscale image with a preset binary conversion value; If the grayscale value is less than the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 0; if the grayscale value is greater than or equal to the preset binary conversion value, the grayscale value corresponding to the pixel point is adjusted to 255; After completing the adjustment of the grayscale values of all the pixels, the black and white image is finally obtained; Wherein, when grayscale processing is performed on the image to be printed, it includes: Obtain the grayscale values of all pixels in the image to be printed, and obtain a grayscale value set, which is the grayscale image, as shown in Formula 1: In the formula, R, G, and B represent the values of the red, green, and blue channels respectively; When comparing the grayscale value of each pixel in the grayscale image with a preset binary conversion value, it includes: Scan each pixel in the grayscale image from left to right and from top to bottom using the Floyd-Steinberg dithering algorithm; After getting the black and white picture, it also includes: Gaussian filtering is introduced to reduce noise in black and white images. The specific formula is shown in Formula 6: Where (λ,ο) is the coordinate of the center point, θ 2 is the variance; When the compression algorithm is run on the plurality of data blocks, it includes: running the compression algorithm on the plurality of data blocks according to the unit data protocol to obtain the compressed data blocks; The compressed data block includes a data header, data content and data length, wherein the data content is the original data, and the data length indicates the number of times the data is repeated; The printing terminal decompresses the data according to the agreed protocol, and can restore the image for printing; When the data header is 00, the data content is 4 bits, the data length is 10 bits, the maximum data size that can be expressed by this compression is 512 bytes, the compressed data only takes 2 bytes, and the compression ratio is 256; Wherein, when the black-and-white picture is sliced to form a plurality of data blocks, it includes: A slicing step is performed, wherein the slicing step comprises: Finding pixel points with a pixel value of 0 in the black-and-white image to obtain a data graph; Obtain pixel points corresponding to multiple ordinates under the same abscissa in the data graph, and further obtain a pixel point with a ordinate in the middle position; Connect the pixel points whose ordinates are in the middle in sequence to obtain a smooth data curve; Using a data trend analysis method to segment the smooth data curve into a plurality of smooth curve segments, mapping boundary points of the smooth curve segments onto the black-and-white image, and slicing the black-and-white image according to the mapping results to obtain the plurality of data blocks; After completing the slicing step, randomly select a data block, further obtain the number of data points contained in the data block, and compare the number of data points with the preset number of data points; If the number of data points contained in the data block is less than or equal to the preset number of data points, then stop executing the slicing step; If the number of data points included in the data block is greater than the preset number of data points, continue to execute the slicing step; When the data block to be transmitted is packaged, it includes: Acquire all the compressed data blocks in the data blocks to be transmitted, and further obtain the number and checksum of the compressed data blocks; Packaging according to all the compressed data blocks, the number of the compressed data blocks and the checksum; Acquire all the original data blocks in the data block to be transmitted, and further obtain the number and checksum of the original data blocks; Packaging according to all the original data blocks, the number of the original data blocks and the checksum; The protocol header is used to distinguish whether the data to be transmitted after packetization has been compressed.
