A simple grayscale representation method for thermal printers
By performing binary data mapping and grayscale grading on grayscale images of thermal printers, the problem that existing thermal printers cannot adjust grayscale levels is solved, printing quality and flexibility are improved, and printing effects that meet different needs are met.
Patent Information
- Application Number
- CN202410896966.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Existing thermal printers cannot achieve grayscale adjustment, resulting in low print quality. In particular, home and office thermal printers have deficiencies in grayscale adjustment.
By mapping the grayscale values of the pixels of the grayscale image into binary data, and adjusting the printer's travel distance and grayscale target value range, the grayscale image is graded and the error is evenly distributed to adjacent pixels to generate multiple grayscale levels. Print data to achieve precise printing of each pixel.
The printing quality is improved, making the grayscale image have a more obvious grayscale sense. The grayscale level can be flexibly adjusted according to the needs to meet different printing quality requirements. There is no need to replace the high-quality print head, and it can only be adjusted through software.
Smart Images

Figure CN118426720B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of thermal printers, and in particular to a simple grayscale representation method for thermal printers. Background Art
[0002] The existing thermal print heads have two outputs for a certain dot, one is to output white without heating, and the other is to output black with heating, so as to print a receipt with black and white content. This printing method has been widely used in business. However, the current printing can only adjust the grayscale of the entire board, but not the grayscale of a certain dot. Because the structure of the thermal print head is to heat and print multiple dots in one row at the same time, the grayscale depth of the printed content in one row is the same.
[0003] Traditional thermal printing can only print black and white binary images, and cannot achieve grayscale levels, which affects the printing quality. Some professional thermal printers use high-resolution print heads and complex grayscale mapping algorithms to achieve grayscale printing, but the cost is high and difficult to popularize.
[0004] However, home and office-grade thermal printers cannot adjust the grayscale level according to printing needs to solve the problem of unclear grayscale levels and low print quality during the printing process. Summary of the invention
[0005] The purpose of the present invention is to provide a simple grayscale representation method for a thermal printer to solve the above-mentioned background problems.
[0006] The purpose of the present invention can be achieved through the following technical solutions:
[0007] A simple grayscale representation method for a thermal printer includes: step 1: obtaining a print image and loading it; and generating a grayscale image from the loaded image;
[0008] Step 2: Adjust the printing travel distance corresponding to each line of printing data to 1 / N of the standard travel distance; N is a positive integer; then the upper machine position maps the grayscale value of each pixel of the grayscale image to N-bit binary data;
[0009] Step 3: Classify the grayscale image value range to obtain N+1 grayscale levels;
[0010] Step 4: Map each pixel value in the grayscale image to obtain the mapped grayscale value of each pixel value and mark it as Y (i,j) ; Where (i, j) is the coordinate of the pixel point in the grayscale image coordinates;
[0011] Step 5: Take the coordinate point (0,0) in the grayscale image as the starting point, calculate the traversal point error, and mark it as C (i,j); Then the error is evenly distributed to the grayscale values of the adjacent pixel coordinates, and the grayscale value of each pixel in the image is traversed in turn to obtain the updated grayscale value;
[0012] Step 6: Based on the updated grayscale value, the i-line grayscale data is sequentially expanded into N-line printing data;
[0013] Based on the updated grayscale value of the pixel coordinate point, the grayscale printing binary data of each pixel point is obtained and sent to the printer;
[0014] Step 7: The printer receives the i-th line of data, heats up, and travels a distance of 1 / N; and the step 6 is executed repeatedly until printing is completed.
[0015] As a further solution of the present invention: in the step 2, the N-bit binary data represents that the printer moves N times in the process of printing the pixel, and the N moving processes respectively correspond to the N binary bit values in the N-bit binary data; during the printing process, each time the printer moves once, if the binary bit is 1, the pixel is heated in this movement, and if the binary bit is 0, the pixel is not heated in this movement.
[0016] As a further solution of the present invention: in step 3, the grayscale value of each level is marked as H0, H1, H2, ..., H N ; Among them, the grayscale value of H0 is 0.
[0017] As a further solution of the present invention: in step 5, the step of updating the gray value includes:
[0018] F1: Calculate the traversal point error C (i,j) ;
[0019] F2: Get the gray value information of the average pixel coordinates;
[0020] F3: Update and calculate the grayscale values of the averaged pixel coordinates adjacent to the traversal point coordinates.
[0021] As a further solution of the present invention: in F2, the gray value information of the average pixel coordinates includes Y (i+1,j) , Y (i-1,j+1) , Y (i,j+1) and Y (i+1,j+1) .
[0022] As a further solution of the present invention: in F3: by Calculate the updated gray value Yx of the right coordinate of the traversal point (i+1, j) (i+1,j) , where a is the right grayscale coefficient;
[0023] pass Calculate the updated gray value Yx of the left coordinate (i-1, j+1) below the traversal point (i-1,j+1) ; Where b is the lower left grayscale coefficient;
[0024] pass Calculate the updated gray value Yx of the coordinate (i, j+1) below the traversal point (i,j+1) ; Where c is the positive grayscale coefficient;
[0025] pass Calculate the updated gray value Yx of the right coordinate (i+1, j+1) below the traversal point (i+1,j+1) ; Where d is the lower right grayscale coefficient.
[0026] As a further solution of the present invention: in F3, the grayscale coefficients a, b, c and d are preset values, and a+b+c+d=1.
[0027] As a further solution of the present invention: in F1, the calculation method of the traversal point error is:
[0028] Get the gray value Y of the traversal point (i,j) , determine and obtain the gray value Y of the traversal point (i,j) The gray value H in the closest gray level N ,pass Calculate the traversal point error C (i,j) .
[0029] As a further solution of the present invention: in step six, the pixels of each line of the grayscale image are divided into N lines of printing data; and each line of printing data contains binary digits.
[0030] As a further solution of the present invention: in step seven: the binary data of each pixel point is sent to the printer. Each time the printer moves, if the binary data of the point is "1", it is heated and printed, and if it is "0", it is not heated and printed.
[0031] Beneficial effects of the present invention:
[0032] By dividing the travel distance of the printer head and the target grayscale value range of printing, the number of levels of each pixel can be increased during the printing process. The more levels are divided between two adjacent pixels, the clearer the levels between the two adjacent pixels are, making the grayscale image after printing more grayscale and improving the printing quality. At the same time, during the printing process, the grayscale level of the print can be appropriately adjusted according to requirements to better meet different printing needs;
[0033] In addition, when improving printing quality, there is no need to replace a higher quality print head. The printing grayscale level can be flexibly adjusted according to needs through software adjustment to meet different quality requirements. During the grayscale adjustment process, the algorithm is simple and the host computer has little computational complexity, which can be applied to a variety of thermal printing scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The present invention will be further described below in conjunction with the accompanying drawings.
[0035] Figure 1 It is a schematic flow chart of the method of the present invention;
[0036] Figure 2 It is a schematic diagram of a calculation method for updating grayscale values in the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Embodiment 1
[0038] See also Figure 1 and Figure 2 As shown, the present invention is a simple grayscale representation method for a thermal printer, comprising:
[0039] Step 1: Get the print image and load it; and generate a grayscale image from the loaded image;
[0040] Step 2: Adjust the printing travel distance corresponding to each line of printing data to 1 / N of the standard travel distance; N is a positive integer;
[0041] Then the printer maps the grayscale value of each pixel of the grayscale image to N-bit binary data;
[0042] Step 3: Classify the grayscale image value range to obtain N+1 grayscale levels;
[0043] Step 4: Map each pixel value in the grayscale image to obtain the mapped grayscale value of each pixel value and mark it as Y (i,j) ; Where (i, j) is the coordinate of the pixel point in the grayscale image coordinates;
[0044] Step 5: Take the coordinate point (0,0) in the grayscale image as the starting point, calculate the traversal point error, and mark it as C (i,j) ; Then the error is evenly distributed to the grayscale values of the adjacent pixel coordinates, and the grayscale value of each pixel in the image is traversed in turn to obtain the updated grayscale value;
[0045] Including F1: Calculate the traversal point error C (i,j) ;
[0046] F2: Get the gray value information of the average pixel coordinates;
[0047] F3: Update and calculate the grayscale values of the coordinates of the averaged pixel points adjacent to the traversal point coordinates;
[0048] Step 6: Based on the updated grayscale value, the i-line grayscale data is sequentially expanded into N-line printing data;
[0049] Based on the updated grayscale value of the pixel coordinate point, the grayscale printing binary data of each pixel point is obtained and sent to the printer;
[0050] Step 7: The printer receives the i-th line of data, performs heating, and loops through step 6 until printing is completed; the binary data of each pixel is sent to the printer. Each time the printer moves, if the binary data of the pixel is "1", it is heated and printed; if it is "0", it is not heated and printed;
[0051] By grading the travel distance of the printer head and the target grayscale value range of printing, the number of levels of each pixel can be increased during the printing process. The more levels are divided between two adjacent pixels, the clearer the levels between the two adjacent pixels are, making the grayscale image after printing more grayscale and improving the printing quality. At the same time, during the printing process, the grayscale level of the print can be appropriately adjusted as required to better meet the printing quality of different needs. Embodiment 2
[0052] The present invention is a simple grayscale representation method for a thermal printer, comprising:
[0053] S1: Get the printed image and load it; and generate a grayscale image from the loaded image;
[0054] S2: adjusting the printing travel distance corresponding to each line of printing data to 1 / N of the standard travel distance; N is a positive integer;
[0055] Then the upper machine position maps the grayscale value of each pixel of the grayscale image to N-bit binary data; wherein the N-bit binary data represents that the printer moves N times in the process of printing the pixel, and the N moving processes correspond to the N binary bit values in the N-bit binary data respectively; during the printing process, each time the printer moves once, if the binary bit is 1, the pixel is heated in this movement, and if the binary bit is 0, the pixel is not heated in this movement;
[0056] S3: The grayscale image value range is graded to obtain N+1 grayscale levels; that is, in this printing process, the printer heats each row of printing dots N times to present N+1 grayscale levels;
[0057] The grayscale values of each level are marked as H0, H1, H2, ..., H N ; Among them, the gray value of H0 is 0;
[0058] For example, when N is 3, the grayscale is divided into 4 levels, namely 0, 1, 2 and 3. The maximum grayscale value in the grayscale value range is 255, and the minimum grayscale value is 0, which is white and does not need to be printed. At this time, the four grayscale levels are 0, 85, 170 and 255 respectively.
[0059] S4: Map each pixel value in the grayscale image to obtain the mapped grayscale value of each pixel value and mark it as Y (i,j) ; Where (i, j) is the pixel coordinate in the grayscale image coordinates; where i is the row pixel and j is the column pixel;
[0060] S5: Take the coordinate point (0,0) in the grayscale image as the starting point, calculate the traversal point error, and mark it as C (i,j) ; Then the error is evenly distributed to the grayscale values of the adjacent pixel coordinates, and the grayscale value of each pixel in the image is traversed in turn to obtain the updated grayscale value;
[0061] Specifically include:
[0062] S51: Calculate the traversal point error C (i,j) ;
[0063] Get the gray value Y of the traversal point (i,j) , determine and obtain the gray value Y of the traversal point (i,j) The gray value H in the closest gray level N ,pass Calculate the traversal point error C (i,j) ;
[0064] S52: Obtain updated grayscale value information of the average pixel coordinates, including Y (i+1,j) , Y (i-1,j+1) , Y (i,j+1) and Y (i+1,j+1) ;
[0065] It should be noted that the coordinates of the averaged pixel points are the coordinates of the right side, left side below, below and right side below the traversal point, which are (i+1, j), (i-1, j+1), (i, j+1) and (i+1, j+1) respectively;
[0066] S53: Passed Calculate the updated gray value Yx of the right coordinate of the traversal point (i+1, j) (i+1,j) , where a is the right grayscale coefficient;
[0067] pass Calculate the updated gray value Yx of the left coordinate (i-1, j+1) below the traversal point (i-1,j+1) ; Where b is the lower left grayscale coefficient;
[0068] pass Calculate the updated gray value Yx of the coordinate (i, j+1) below the traversal point (i,j+1) ; Where c is the positive grayscale coefficient;
[0069] pass Calculate the updated gray value Yx of the right coordinate (i+1, j+1) below the traversal point (i+1,j+1) ; Where d is the grayscale coefficient of the lower right;
[0070] Among them, the grayscale coefficients a, b, c and d are preset values, and a+b+c+d=1;
[0071] It should be noted that in the grayscale coefficient, a, b, c and d are all preset values. During the calculation process, the staff can set them based on experience, such as "0.44, 0.19, 0.3 and 0.07";
[0072] S6: Based on the updated grayscale value, the i-line grayscale data is sequentially expanded into N-line printing data;
[0073] Based on the updated grayscale value of the pixel coordinate point, the grayscale printing binary data of each pixel point is obtained and sent to the printer;
[0074] The number of bits of binary data is N; the printing distance is 1 / N, so the pixels of each line of grayscale image are divided into N lines of printing data; and each line of printing data contains binary bits;
[0075] For example, when N is 6, the distance the printer travels each time is 1 / 6 of the standard travel distance; at this time, the grayscale value level is 7 levels, namely "0, 42.5, 85, 127.5, 170, 212.5, 255". If the grayscale value of the pixel is close to 85, at this time, any 2 digits of the 6 digits in the binary data are "1", for example, "010100" or "101000", etc. During printing, each pixel is printed twice during the 6-times movement of the printer; if the grayscale value of the pixel is close to 212.5, at this time, any 5 digits of the 6 digits in the binary data are "1", for example, "111110" or "101111", etc., at this time, each pixel is printed 5 times during the 6-times movement of the printer;
[0076] S7: The printer receives the i-th line of data, performs heating, and executes step 6 in a loop until printing is completed:
[0077] Specifically: the binary data of each pixel is sent to the printer. Each time the printer moves, if the binary data of the pixel is "1", it will be heated and printed, if it is "0", it will not be heated and printed; therefore, each pixel can be printed a matching number of times based on the 3-digit number of binary data.
[0078] By dividing the travel distance of the printer head and the target grayscale value range of printing, the number of levels of each pixel can be increased during the printing process. The more levels are divided between two adjacent pixels, the clearer the levels between the two adjacent pixels are, making the grayscale image after printing more grayscale and improving the printing quality. At the same time, during the printing process, the grayscale level of the print can be appropriately adjusted according to requirements to better meet different printing needs;
[0079] In addition, when improving printing quality, there is no need to replace a higher quality print head. The printing grayscale level can be flexibly adjusted according to needs through software adjustment to meet different quality requirements. During the grayscale adjustment process, the algorithm is simple and the host computer has little computational complexity, which can be applied to a variety of thermal printing scenarios. Embodiment 3
[0080] Based on the technical solutions provided in the above embodiments, this example is described with a complete example;
[0081] The details are as follows:
[0082] A1: Get the image to be printed and generate a grayscale image;
[0083] A2: Adjust the printing distance of each line of print data to 1 / 3 of the standard distance; at this time, the gray value of each pixel is mapped to a 3-bit binary data. At this time, the grayscale classification is 4 levels, corresponding to "0, 85, 170, 255" respectively;
[0084] A3: If the pixel grayscale value of the grayscale image is in the format of 3X3 ;
[0085] At this time, the grayscale value of the pixel with coordinate point (0, 0) is processed;
[0086] The original value is 200, and the closest gray level is 170. At this time, the traversal point error is 30;
[0087] A4: At this time, the updated grayscale value on the right side of the traversal point (0, 0) is about 215; the updated grayscale value below is about 204; the updated grayscale value on the right side below is about 200; after calculation at this point;
[0088] In this way, all pixels are processed continuously and updated pixel grayscale values are obtained;
[0089] A5: Regarding the grayscale values of the 3X3 format of the updated grayscale image, the first row is [200, 215, 192];
[0090] Take the first row of pixel grayscale values as an example for printing;
[0091] A6: Divide the grayscale value data of this row into three rows of data, namely: the grayscale value of the first pixel is 200, and the grayscale level closest to it is 170. Therefore, any two bits of the three-digit binary data of this pixel are "1", which means "011, 101 or 110"; the grayscale value of the second pixel is 215, and the grayscale level closest to it is 255. At this time, all three bits of the binary data of this pixel are "1", that is, "111"; the grayscale value of the third pixel is 192, and the grayscale level closest to it is 170. At this time, any two bits of the three-digit binary data of this pixel are "1", which means "011, 101 or 110";
[0092] A7: Send the binary data of each pixel to the printer. Each time the printer moves, if the binary data of the pixel is "1", it will be heated and printed, and if it is "0", it will not be heated and printed. Therefore, each pixel can be printed a matching number of times based on the 3-digit number of binary data.
[0093] Then loop A6 to complete the printing of the entire grayscale image;
[0094] It should be noted that, during the printing process, if it is necessary to finely distinguish and print the pixels in each grayscale image, the number of printer passes can be increased to increase the printing level of each printing point, so that the level of the entire grayscale image is more distinct;
[0095] By dividing the travel distance of the printer head and the printing grayscale target value range into levels, the number of levels of each pixel can be increased during the printing process. The more levels are divided between two adjacent pixels, the clearer the levels between the two adjacent pixels are, so that the grayscale image after printing has a stronger grayscale hierarchy, thereby improving the printing quality. At the same time, during the printing process, the grayscale level of the print can be appropriately adjusted as required to better meet the different needs of the print quality. In addition, when improving the print quality, there is no need to replace a higher quality print head. The print grayscale level can be flexibly adjusted according to the needs through software adjustment to meet different quality requirements. During the grayscale level adjustment process, the algorithm is simple, the host computer has a small amount of calculation, and can be applied to a variety of thermal printing scenarios. Embodiment 4
[0096] An embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus.
[0097] Memory, used to store computer programs;
[0098] The processor is used to execute the program stored in the memory, and implements the following steps:
[0099] Get the print image and load it; generate a grayscale image from the loaded image; adjust the print travel distance corresponding to each line of print data to 1 / N of the standard travel distance; N is a positive integer; then the printer maps the grayscale value of each pixel in the grayscale image to N-bit binary data; classify the grayscale image value range to obtain N+1 grayscale classifications; map each pixel value in the grayscale image to obtain the mapped grayscale value of each pixel value, and mark it as Y (i,j) ; (i, j) is the pixel coordinate in the grayscale image coordinates; the coordinate point (0,0) in the grayscale image is used as the starting point for traversal, and the traversal point error is calculated and marked as C (i,j) ; Then the error is evenly distributed to the grayscale values of the adjacent pixel coordinates, and the grayscale values of each pixel in the image are traversed in turn to obtain the updated grayscale value; Based on the updated grayscale value, the i-row grayscale data is sequentially expanded into N-row printing data; Based on the updated grayscale value of the pixel coordinate point, the grayscale printing binary data of each pixel is obtained; and sent to the printer; The printer receives the i-th row of data, heats it, and executes step six repeatedly until the printing is completed; The binary data of each pixel point is sent to the printer, and each time the printer moves once, if the binary data of the point is "1", it is heated and printed, and if it is "0", it is not heated and printed;
[0100] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc.
[0101] The communication interface is used for communication between the above electronic device and other devices.
[0102] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0103] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0104] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, any one of the above-mentioned simple grayscale representation methods for a thermal printer is implemented.
[0105] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the simple grayscale representation methods for thermal printers in the above embodiments.
[0106] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0107] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0108] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0109] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0110] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0112] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0113] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0114] The above is a detailed description of an embodiment of the present invention, but the content is only a preferred embodiment of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the patent coverage of the present invention.
Claims
1. A simple grayscale representation method for thermal printers. It is characterized in that include: Step 1: Get the print image and load it; and generate a grayscale image from the loaded image; Step 2: Adjust the printing travel distance corresponding to each line of printing data to 1 / N of the standard travel distance; N is a positive integer; then the upper machine position maps the grayscale value of each pixel of the grayscale image to N-bit binary data; In the step 2, the N-bit binary data represents that the printer moves N times in the process of printing the pixel, and the N moving processes correspond to the N binary bit values in the N-bit binary data respectively; during the printing process, each time the printer moves once, if the binary bit is 1, the pixel is heated in this movement, and if the binary bit is 0, the pixel is not heated in this movement; Step 3: Classify the grayscale image value range to obtain N+1 grayscale levels; In step 3, the grayscale value of each level is marked as H 0 , H 1 , H 2 ,…,H N ; Among them, H 0 The gray value of is 0; Step 4: Map each pixel value in the grayscale image to obtain the mapped grayscale value of each pixel value and mark it as Y (i,j) ; Where (i, j) is the coordinate of the pixel point in the grayscale image coordinates; Step 5: Take the coordinate point (0,0) in the grayscale image as the starting point, calculate the traversal point error, and mark it as C (i,j) ; Then the error is evenly distributed to the grayscale values of the adjacent pixel coordinates, and the grayscale values of each pixel in the image are traversed in turn to obtain the updated grayscale value; In the step 5, the step of updating the gray value includes: F1: Calculate the traversal point error C (i,j) ; In F1, the calculation method of the traversal point error is: Get the gray value Y of the traversal point (i,j) , determine and obtain the gray value Y of the traversal point (i,j) The gray value H in the closest gray level N ,pass Calculate the traversal point error C (i,j) ; F2: Get the gray value information of the average pixel coordinates; In F2, the gray value information of the average pixel coordinates includes Y (i+1,j) , Y (i-1,j+1) , Y (i,j+1) and Y (i+1,j+1) ; F3: Update and calculate the grayscale values of the coordinates of the averaged pixel points adjacent to the traversal point coordinates; In F3: Calculate the updated gray value Yx of the right coordinate of the traversal point (i+1, j) (i+1,j) , where a is the right grayscale coefficient; pass Calculate the updated gray value Yx of the left coordinate (i-1, j+1) below the traversal point (i-1,j+1) ; Where b is the lower left grayscale coefficient; pass Calculate the updated gray value Yx of the coordinate (i, j+1) below the traversal point (i,j+1) ; Where c is the positive lower grayscale coefficient; pass Calculate the updated gray value Yx of the right coordinate (i+1, j+1) below the traversal point (i+1,j+1) ; Where d is the grayscale coefficient of the lower right; In F3, the grayscale coefficients a, b, c and d are preset values, and a+b+c+d=1; Step 6: Based on the updated grayscale value, the i-line grayscale data is sequentially expanded into N-line printing data; Based on the updated grayscale value of the pixel coordinate point, the grayscale printing binary data of each pixel point is obtained and sent to the printer; Step 7: The printer receives the i-th line of data, heats up, and travels a distance of 1 / N; and the step 6 is executed repeatedly until printing is completed.
2. A simple grayscale representation method for a thermal printer according to claim 1, It is characterized in that In the step six, the pixels of each line of the grayscale image are divided into N lines of printing data; and each line of printing data contains binary digits.
3. A simple grayscale representation method for a thermal printer according to claim 1, It is characterized in that In the step 7: the binary data of each pixel is sent to the printer. Each time the printer moves, if the binary data of the pixel is "1", it is heated and printed; if it is "0", it is not heated and printed.
Citation Information
Cited By
Thermal printing head and printing method
CN120620883A
Thermal printing device and printing method
CN121200594A
Thermal printing head and printing method
CN121290953A
