Thermal printing method and related apparatus

By replacing the dark pixels at the edge of dark blocks with light pixels in a thermal printer and using the residual heat for secondary heating, the problem of red bleed around dark patterns is solved, achieving a clearer printing effect.

CN120792353APending Publication Date: 2025-10-17ZHUHAI QUIN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510963731.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

热敏打印机在打印深色图案时,深色图案周围出现红色晕染,打印效果不佳。

Method used

By replacing the dark pixels at the edge of the dark blocks in the image to be printed with light pixels, the residual heat generated when heating the dark pixels is used to heat the light pixels a second time, making them darker, thereby reducing red bleed.

Benefits of technology

It effectively reduces red bleed and improves printing effects, especially the clarity of black edges, and reduces the red bleed width by 40%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120792353A_ABST
    Figure CN120792353A_ABST
Patent Text Reader

Abstract

The invention provides a thermal printing method and a related device, and relates to the technical field of printers, and the method comprises the steps: replacing a first pixel value of a pixel point at a target color block contour in a to-be-printed image with a second pixel value, and obtaining a first target image; the red channel value of the first pixel value is smaller than the red channel value of the second pixel value; and controlling a thermal printer to print the first target image. According to the scheme, red shading can be effectively reduced, and the printing effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of printers, and in particular to a thermal printing method and related device. BACKGROUND

[0002] A thermal printer is a device that prints based on thermal paper. A semiconductor heating element is installed on the print head of the thermal printer. After the heating element is heated, it contacts the thermal printing paper to produce a chemical reaction and color development, thereby printing the desired pattern.

[0003] Currently, when a thermal printer prints a dark color pattern, red halo appears around the dark color pattern, and the printing effect is poor. SUMMARY

[0004] Embodiments of the present application provide a thermal printing method and related device for reducing red halo and improving printing effect.

[0005] In a first aspect, embodiments of the present application provide a thermal printing method, comprising:

[0006] replacing a first pixel value of a pixel point at an outline of a target color block in a to-be-printed image with a second pixel value to obtain a first target image; the red channel value of the first pixel value is less than the red channel value of the second pixel value;

[0007] controlling a thermal printer to print the first target image.

[0008] In some embodiments, before the replacing the first pixel value of the pixel point at the outline of the target color block in the to-be-printed image with the second pixel value, the method further comprises:

[0009] performing color space conversion on the to-be-printed image to obtain a second target image;

[0010] constructing a mask of the target color block based on a preset color threshold;

[0011] determining the target color block from the second target image according to the mask.

[0012] In some embodiments, the replacing the first pixel value of the pixel point at the outline of the target color block in the to-be-printed image with the second pixel value to obtain the first target image comprises:

[0013] extracting an outline of the target color block;

[0014] replacing a first pixel value of a pixel point of the outline of the target color block with a second pixel value to determine a target outline of the target color block;

[0015] merge the target contour with the second target image to obtain the first target image.

[0016] In some embodiments, the replacing the first pixel value of the pixel point of the contour of the target color block with the second pixel value comprises:

[0017] For any point on the contour of the target color block, if the point includes at least two pixel points, the first pixel value of at least one pixel point is replaced with the second pixel value in the direction from the outside of the contour to the inside of the contour.

[0018] In some embodiments, the extracting the contour of the target color block comprises:

[0019] obtaining the gradient amplitude and the gradient direction of the target color block;

[0020] comparing the gradient amplitude of each pixel in the target color block along the gradient direction, if the gradient amplitude of the current pixel is not a local maximum value, the amplitude is set to zero to generate a thinned edge candidate region;

[0021] segmenting and connecting the edges of the thinned edge candidate region to determine the contour of the target color block.

[0022] In some embodiments, after the contour of the target color block is determined, the method comprises:

[0023] obtaining a predefined graph kernel;

[0024] performing an inflation operation on the contour of the target color block according to the graph kernel to expand the contour of the target color block.

[0025] In some embodiments, the controlling the thermal printer to print the first target image comprises:

[0026] generating a print data stream according to the first target image;

[0027] encrypting the print data stream, and sending the encrypted print data stream to the thermal printer, so that the thermal printer prints the first target image according to the encrypted print data stream.

[0028] In a second aspect, the embodiments of the present application provide a thermal printing device, comprising:

[0029] a processing module configured to replace a first pixel value of a pixel point at a target color block contour in a to-be-printed image with a second pixel value to obtain a first target image; the red channel value of the first pixel value is less than the red channel value of the second pixel value.

[0030] a control module configured to control a thermal printer to print the first target image.

[0031] In a third aspect, the present application provides an electronic device, comprising: a processor, a transceiver, and a memory; the processor is in communication connection with the transceiver and the memory respectively;

[0032] The memory is configured to store a computer program; the transceiver is configured to communicate with an external device; and the processor is configured to execute the computer program to implement the method of any one of the first aspect.

[0033] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of any one of the first aspect.

[0034] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which is executed by a processor to implement the method of any one of the first aspect.

[0035] The thermal printing method and related device provided by the embodiments of the present application replace the first pixel value of the pixel point at the target color block contour in the image to be printed with a second pixel value to obtain a first target image; the red channel value of the first pixel value is less than the red channel value of the second pixel value; and the thermal printer is controlled to print the first target image. The above scheme replaces the dark color pixel point at the edge of the dark color block in the image to be printed with a light color pixel point, uses the afterheat generated when the dark color pixel point is heated to heat the light color pixel point again, so that the light color pixel point becomes darker, thereby effectively reducing red dyeing and improving the printing effect. BRIEF DESCRIPTION OF DRAWINGS

[0036] Figure 1 A scene schematic diagram provided by the embodiments of the present application;

[0037] Figure 2 A flowchart of a thermal printing method provided by the embodiments of the present application Figure 1 ;

[0038] Figure 3 A schematic diagram of pixel replacement provided by the embodiments of the present application;

[0039] Figure 4 A schematic diagram of a black color block provided by the embodiments of the present application;

[0040] Figure 5 A flowchart of a thermal printing method provided by the embodiments of the present application Figure 1 ;

[0041] Figure 6 A schematic diagram of a color block pixel point provided by the embodiments of the present application;

[0042] Figure 7 A structural schematic diagram of a heat-sensitive printing device provided by an embodiment of the present application is shown in FIG. 1.

[0043] Figure 8 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 2. DETAILED DESCRIPTION

[0044] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the scope of protection of the present application.

[0045] In the embodiments of the present application, the terms “first”, “second”, and the like are used to distinguish the same items or similar items with basically the same functions and effects, and do not limit the sequence. Those of ordinary skill in the art can understand that the terms “first”, “second”, and the like do not limit the quantity and execution sequence, and the terms “first”, “second”, and the like also do not necessarily mean different.

[0046] It should be noted that in the embodiments of the present application, the words “exemplary” or “for example” are used to represent examples, illustrations, or descriptions. Any embodiment or design solution described as “exemplary” or “for example” in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design solutions. Rather, the words “exemplary” or “for example” are used to present the relevant concepts in a specific manner.

[0047] A heat-sensitive printer is a device for printing based on heat-sensitive paper, which contains a special chemical coating that changes color when heated by a heat source. The heat-sensitive printer is provided with a semiconductor heating element on the print head. After the print head is heated and contacts the heat-sensitive printing paper, the desired pattern can be printed on the heat-sensitive paper.

[0048] At present, when the heat-sensitive printer prints a deep color block (such as black), red halo appears around the deep color block, and the printing effect is poor.

[0049] The inventor has found that the reason for the red halo is that when heating the pixel points at the edge of the deep color block, the residual heat generated by the heat-sensitive print head inevitably diffuses to the surrounding area through conduction and radiation, causing the surrounding heat-sensitive layer to undergo a chemical reaction due to low heat, resulting in red color.

[0050] To solve the above problems, the embodiment of the present application provides a thermal printing method and related device, by replacing the dark color pixel points at the edge of the dark color block in the image to be printed with light color pixel points, using the residual heat generated when heating the dark color pixel points to heat the light color pixel points again, so that they become darker, thereby effectively reducing red dyeing and improving the printing effect.

[0051] The technical solutions of the present application and how the technical solutions of the present application solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be implemented independently, or can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments.

[0052] Figure 1 An application scenario provided by the embodiment of the present application is shown in FIG. 1, which includes an electronic device 1 and a thermal printer 2. The electronic device 1 and the thermal printer 2 can be connected by wired or wireless means. Figure 1

[0053] When the electronic device 1 obtains the image to be printed, it can convert the image to be printed into a print data stream and send the print data stream to the thermal printer 2. After receiving the print data stream, the thermal printer 2 can execute the printing process and print the image on the thermal paper.

[0054] The electronic device can be implemented in various forms. For example, the electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a desktop computer, etc. The type of the electronic device is not limited in the embodiment of the present application.

[0055] Based on the application scenario shown in FIG. 1, the thermal printing method provided by the embodiment of the present application will be described in detail below taking the electronic device as an example. Figure 1

[0056] A flowchart of the thermal printing method provided by the embodiment of the present application is shown in FIG. 2, which includes the following steps: Figure 2 Figure 2 S201, replace the first pixel value of the pixel point at the target color block contour in the image to be printed with a second pixel value to obtain a first target image.

[0057] In some embodiments, the target color block can refer to a dark color block in the image to be printed, for example, a black color block.

[0058] In some embodiments, the target color block can refer to a dark color block in the image to be printed, for example, a black color block.

[0059] ​​The pixel value can refer to color or brightness information contained by each pixel. In an RGB image, the pixel value of each pixel point is composed of channel values of three channels of red (R), green (G), and blue (B), and each channel value ranges from 0 to 255. For example, the pixel value of a black pixel point is (0, 0, 0), and the pixel value of a red pixel point is (255, 0, 0).

[0060] In some embodiments, when the electronic device obtains an image to be printed, the electronic device can process the image to determine a target color block included in the image. After determining the target color block, the electronic device can perform contour recognition on the target color block, extract the contour (also referred to as an edge) of the target color block, and replace the first pixel value of the pixel points constituting the contour with a second pixel value to obtain a first target image. The red channel value (R value) of the first pixel value is less than the red channel value of the second pixel value.

[0061] For example, taking the target color block as a black color block, the electronic device can use a preset black threshold to identify the black color block from the image based on the pixel values of the pixel points in the image.

[0062] After identifying the black color block, the electronic device can use a preset contour recognition algorithm (such as a Canny algorithm, a Sobel algorithm, etc.) to extract the contour of the black color block, and the first pixel value of the pixel points constituting the contour of the black color block is (0, 0, 0). After determining the contour of the black color block, the first pixel value of the pixel points constituting the contour of the black color block can be replaced with a second pixel value to obtain a first target image. The second pixel value is used to indicate that the corresponding pixel point is a light color pixel point, such as red, orange, etc. That is, as shown in FIG. 1, the black color block in the original image to be printed is changed to a black color block with a red contour through replacement of the pixel value. Figure 3

[0063] S202, controlling the thermal printer to print the first target image.

[0064] In some embodiments, the electronic device can use a preset printing algorithm to convert the first target image into a print data stream, and send the print data stream to the thermal printer, so that the thermal printer prints the first target image based on the print data stream.

[0065] For example, the electronic device can convert the first target image into a print data stream through raster image processing. The specific implementation manner in which the thermal printer prints the first target image based on the print data stream can refer to the implementation manner in the prior art, which will not be described here.

[0066] The black color block with a red contour in the first target image is as shown in FIG. 1.​Figure 4 As shown, when printing the first target image, the thermal printing can use high temperature to heat the black pixel points therein to display black on the thermal paper, and use low temperature to heat the red pixel points to display red on the thermal paper. When heating the black pixel points adjacent to the red pixel points, the residual heat generated by the thermal print head diffuses to the red pixel points through conduction and radiation, and the red pixel points are secondarily heated, so that the red displayed on the thermal paper becomes black, thereby maintaining the size of the printed black color block unchanged, reducing the red halo of the edge of the black color block, and improving the printing effect.

[0067] The thermal printing method provided by the embodiment of the present application comprises the following steps: obtaining a first target image by replacing a first pixel value of a pixel point at a target color block contour in a to-be-printed image with a second pixel value; the red channel value of the first pixel value is less than the red channel value of the second pixel value; and printing the first target image by using a thermal printer. In the above scheme, the dark color pixel point at the edge of the dark color block in the to-be-printed image is replaced with a light color pixel point, and the light color pixel point is secondarily heated by using the residual heat generated when the dark color pixel point is heated, so that the light color pixel point becomes dark, thereby effectively reducing the red halo and improving the printing effect.

[0068] On the basis of the above embodiment, the thermal printing method provided by the embodiment of the present application is further described.

[0069] Figure 5 The flowchart of another thermal printing method provided by the embodiment of the present application is shown as follows. Figure 5 As shown, the method comprises the following steps.

[0070] S501, obtaining a to-be-printed image.

[0071] In some embodiments, the electronic device can obtain the to-be-printed image from the outside or the inside.

[0072] For example, the electronic device can read the to-be-printed image from the internal image library based on the instruction of the user. Alternatively, the electronic device can receive the to-be-printed image transmitted by the user in a wired (such as a storage medium) or wireless (such as Bluetooth, WiFi, etc.) manner. Alternatively, the electronic device can download the to-be-printed image from the outside (such as the Internet) in response to the instruction of the user. The embodiment of the present application does not limit the way in which the electronic device obtains the to-be-printed image.

[0073] S502, determining a target color block from the to-be-printed image.

[0074] In some embodiments, after the electronic device obtains the image to be printed, the electronic device can perform color space conversion on the image to obtain a second target image. For example, the electronic device converts the image to an HSV image. The HSV image refers to an image in which each color is represented by hue (H), saturation (S), and value (V). The specific implementation of converting the image to an HSV image is similar to the implementation in the prior art, and thus will not be described here.

[0075] In some embodiments, after obtaining the second target image, the electronic device can construct a mask of the target color block based on a preset color threshold. The mask is an array or matrix with the same shape as the original data (usually an image or a matrix), and the elements of the mask are used to control the operation on the original data. It is essentially a screening or filtering mechanism that determines whether an element is retained, modified, or discarded by combining the element of the original data with the corresponding element of the mask.

[0076] For example, taking a black color block as the target color block, the preset color threshold can be (H: 0-180, S: 0-80, V: 0-127), and the electronic device can use a preset function (such as the cv2.inRange function) to create a mask based on the color threshold. The function generates a binary image based on the color threshold, and the pixel values that meet the threshold range are 255, and the pixel values that do not meet the threshold range are 0.

[0077] In some embodiments, after obtaining the mask, the electronic device can extract the target color block from the second target image based on the mask. For example, the electronic device can take the intersection of the pixel points corresponding to the mask and the pixel points of the second target image as the pixel points corresponding to the target color block.

[0078] S503, extract the contour of the target color block.

[0079] In some embodiments, the electronic device can use a preset contour recognition algorithm (such as the Canny algorithm, the Sobel algorithm, etc.) to extract the contour of the black color block.

[0080] For example, taking the Canny algorithm as an example, after the electronic device determines the target color block, the electronic device can use a Gaussian filter to smooth the target color block to reduce the interference of noise on contour detection.

[0081] The electronic device calculates the gradients (Gx and Gy) of the target color block in the horizontal and vertical directions using the Sobel operator to obtain the gradient amplitude and the gradient direction .

[0082] The gradient amplitudes of each pixel are compared along the gradient direction. If the gradient amplitude of the current pixel is not a local maximum value, the amplitude is set to zero to generate a refined edge candidate region. A high threshold (strong edge) and a low threshold (weak edge) are set. Pixels higher than the high threshold are marked as strong edges, pixels lower than the low threshold are discarded, and pixels between the two thresholds are marked as weak edges. It is checked whether the weak edge pixels are connected to the strong edge pixels. If connected, the weak edge pixels are retained as edges. Otherwise, the weak edge pixels are removed. Finally, the contour of the black color block is obtained.

[0083] S504, using a predefined kernel to dilate the contour of the target color block.

[0084] In some embodiments, in morphology, a kernel can be referred to as a structuring element, which is a geometric shape defined in the image space, used for various morphological operations on the image, such as dilation operation, erosion operation, etc. For example, the kernel can be a non-rectangular kernel.

[0085] In some embodiments, the electronic device can obtain a predefined kernel from the outside or the inside, and use the kernel to dilate the contour of the target color block to expand the contour of the target color block. The dilation operation is to align the origin of the structuring element with each pixel point in the image. If any pixel value in the region covered by the structuring element is greater than or equal to a certain threshold (for a binary image, usually any pixel value in the region covered by the structuring element is 1), the pixel point becomes 1 in the dilated image; otherwise, the pixel point remains unchanged in the dilated image.

[0086] For example, after obtaining the predefined kernel, the electronic device can use a constructor (such as the cv2.dilate function) to dilate the contour of the target color block based on the kernel to obtain the expanded contour of the target color block. By expanding the contour of the target color block, the target color block can be better distinguished from other color blocks.

[0087] It should be understood that the step S504 is an optional step.

[0088] S505, replacing the first pixel value of the pixel point at the contour with a second pixel value to obtain a target contour.

[0089] In some embodiments, for any point (position) on the contour of the target color block, the point can be composed of one or more pixel points. If the point is composed of one pixel point, the first pixel value of the pixel point is replaced with a second pixel value to obtain a target contour.

[0090] If the point includes at least two pixel points (such as Figure 6As shown, the point A on the contour includes two pixel points A1 and A2, and in the direction from the outside of the contour to the inside of the contour, the first pixel value of at least one pixel point is replaced by the second pixel value. That is, if only the first pixel value of one pixel point is replaced, the first pixel value of the outermost pixel point is replaced (for example, the first pixel value of the pixel point A1 is replaced by the second pixel value of the pixel point A2). Figure 6 As shown, the first pixel value of the pixel point A1 is replaced.

[0091] It should be understood that for any point on the contour of the target color block, at least two pixel points are included, and when the pixel value of the pixel point is replaced, the number of pixel points that are specifically replaced can be set according to actual needs, and the embodiments of the present application do not limit this.

[0092] In some embodiments, for any point on the contour of the target color block, a plurality of pixel points (such as greater than or equal to 3) are included, and when the pixel value of the pixel point is replaced, the pixel value of 1-3 outermost pixel points can be replaced.

[0093] S506, merging the target contour and the second target image to obtain the first target image.

[0094] In some embodiments, after obtaining the target contour, in the second target image, the pixel points of the target contour are used to replace the pixel points at the corresponding positions to obtain the first target image. For example, taking the pixel points of the target contour as red pixel points as an example, the target contour can be a red layer, and the black color block in the second target image can be a black layer. The red layer and the black image can be unified into one layer.

[0095] S507, controlling the thermal printer to print the first target image.

[0096] In some embodiments, the electronic device can use a preset printing algorithm to convert the first target image into a print data stream, and send the print data stream to the thermal printer, so that the thermal printer prints the first target image based on the print data stream.

[0097] In some embodiments, after the electronic device converts the first target image into a print data stream, the electronic device can encrypt the print data stream, and send the encrypted print data stream to the thermal printer. To improve the security in the data transmission process. It should be understood that after the thermal printer receives the encrypted print data stream, the thermal printer can use a key previously negotiated with the electronic device to decrypt the encrypted print data stream.

[0098] In some embodiments, the print data stream is in the format of: a start frame - picture size (width*height) - print data stream; wherein the start frame is used to identify the beginning of the data stream, a key signal for the thermal printer to identify the arrival of the image data packet, the picture size is used to indicate how large the image arriving at the thermal printer is, and the print data stream contains the actual image pixel information.

[0099] In some embodiments, after the thermal printer obtains the print data stream, the print data stream can be converted into data that can support printing by the print head, and the print head is heated.

[0100] In summary, the thermal printing method provided by the embodiments of the present application replaces the dark color pixel points at the edges of the dark color blocks in the image to be printed with light color pixel points, uses the residual heat generated when the dark color pixel points are heated to heat the light color pixel points again, so that they become darker, thereby controlling the excess heat radiation as much as possible within the dark color block area, which can effectively reduce red bleeding and improve the printing effect. Tests show that the width of the red bleeding at the edge of the black color is reduced by 40% by using the method of the embodiments of the present application, and a clearer printing effect at the edge is achieved.

[0101] On the basis of the above-mentioned embodiments, the embodiments of the present application further provide a thermal printing device, which is applied to the electronic device in any of the above-mentioned embodiments.

[0102] Figure 7 The structure diagram of the thermal printing device 70 provided by the embodiments of the present application is shown in FIG. 7, which includes: Figure 7

[0103] The processing module 701 is configured to replace the first pixel value of the pixel points at the target block contour in the image to be printed with a second pixel value to obtain a first target image; the red channel value of the first pixel value is less than the red channel value of the second pixel value.

[0104] The control module 702 is configured to control the thermal printer to print the first target image.

[0105] In some embodiments, the processing module 701 is further configured to perform color space conversion on the image to be printed to obtain a second target image; construct a mask of the target block based on a preset color threshold; and determine the target block from the second target image according to the mask.

[0106] In some embodiments, the processing module 701 is further configured to extract the contour of the target block; replace the first pixel value of the pixel points at the contour of the target block with a second pixel value to determine a target contour of the target block; and combine the target contour with the second target image to obtain the first target image.

[0107] ​In some embodiments, the processing module 701 is further configured to, for any point on the contour of the target color block, if the point comprises at least two pixel points, replace the first pixel value of the at least one pixel point with the second pixel value in a direction from outside to inside of the contour.

[0108] In some embodiments, the processing module 701 is further configured to obtain a gradient magnitude and a gradient direction of the target color block; compare the gradient magnitude of each pixel in the target color block along the gradient direction, if the gradient magnitude of the current pixel is not a local maximum value, set the magnitude to zero to generate a thinned edge candidate region; and perform segmentation and edge connection on the thinned edge candidate region to determine the contour of the target color block.

[0109] In some embodiments, the processing module 701 is further configured to obtain a predefined graph kernel; and perform an inflation operation on the contour of the target color block according to the graph kernel to expand the contour of the target color block.

[0110] In some embodiments, the processing module 701 is further configured to generate a print data stream according to the first target image; perform encryption processing on the print data stream, and send the encrypted print data stream to the thermal printer, so that the thermal printer prints the first target image according to the encrypted print data stream.

[0111] The thermal printing device provided by the embodiments of the present application can perform the thermal printing method of any of the above embodiments, and has similar principles and technical effects, which will not be described here.

[0112] It should be noted that the division of each module of the above device is only a logical functional division, and all or part of the modules can be integrated into one physical entity, or can be physically separated. These modules can all be implemented in the form of software called by a processing element; or all be implemented in the form of hardware; or some modules are implemented in the form of software called by a processing element, and some modules are implemented in the form of hardware. Each module can be a separate processing element, or can be integrated in a chip of the above device, in addition, the functions of each module can be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. In addition, all or part of these modules can be integrated together, or can be independently implemented. The processing element here can be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each module can be completed by the integrated logic circuit of hardware or the instruction of software in the processing element.

[0113] The embodiments of the present application also provide an electronic device.

[0114] Figure 8A structural schematic diagram of the electronic device 80 provided in the embodiments of the present application is shown in FIG. 8. As shown in FIG. 8, the electronic device can include a transceiver 801, a processor 802, and a memory 803. Figure 8

[0115] The processor 802 executes computer-executed instructions stored in the memory, so that the processor 802 performs the solutions in the above-described embodiments. The processor 802 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; and can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.

[0116] The memory 803 is connected with the processor 802 through a system bus and completes mutual communication. The memory 803 is configured to store computer program instructions.

[0117] The transceiver 801 can perform receiving and sending of data and instructions.

[0118] Optionally, the electronic device 80 can further include a communication interface 804, so that the communication interface 803 can communicate with external or internal devices, and the external device can be a client (for example, a mobile phone or a tablet computer). In a specific implementation, if the communication interface 804, the memory 803, and the processor 802 are independently implemented, the communication interface 804, the memory 803, and the processor 802 can be connected with each other through a bus and complete mutual communication.

[0119] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus. The transceiver is configured to implement communication between the database access device and other computers (for example, a client, a read-write library, and a read-only library). The memory can include a random access memory (RAM), and can also include a non-volatile memory.

[0120] Optionally, in a specific implementation, if the communication interface 804, the memory 803, and the processor 802 are integrated on a chip, the communication interface 804, the memory 803, and the processor 802 can complete communication through an internal interface. ​

[0121] The embodiment of the present application further provides a chip for running instructions, which is used for executing the technical solutions in the above embodiments.

[0122] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the technical solutions in the above embodiments, and the implementation principles and technical effects are similar, and thus are not described here.

[0123] In a possible implementation manner, the computer readable medium can include a random access memory (RAM), a read-only memory (ROM), a compact disc read-only memory (CD-ROM) or other optical disk memories, a magnetic disk memory or other magnetic storage devices, or any other medium targeted at carrying or storing the required program codes in the form of instructions or data structures, and can be accessed by the computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, a server or other remote source using a coaxial cable, an optical fiber cable, a twisted pair, a digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, the optical fiber cable, the twisted pair, the DSL or the wireless technology (such as infrared, radio and microwave) is included in the definition of the medium. As used herein, the disk and the optical disk include a compact disc, a laser disc, an optical disc, a digital versatile disc (DVD), a floppy disk and a Blu-ray disc, in which the disk usually magnetically reproduces data, and the optical disk optically reproduces data with a laser. The combination of the above should also be included in the scope of the computer readable medium.

[0124] The embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is executed by a processor to realize the technical solutions in the above embodiments, and the implementation principles and technical effects are similar, and thus are not described here.

[0125] In the specific implementation of the terminal device or the server, it should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor, or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as hardware processor execution, or executed by a combination of hardware and software modules in the processor.

[0126] Those skilled in the art can understand that all or part of the steps of any of the method embodiments described above can be completed by hardware related to program instructions. The foregoing program can be stored in a computer readable storage medium, and when the program is executed, all or part of the steps of the method embodiments described above are executed.

[0127] When the technical solutions of the present application are realized in the form of software and sold or used as products, they can be stored in a computer readable storage medium. Based on this understanding, all or part of the technical solutions of the present application can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a computer program or a number of instructions. The computer software product makes a computer device (which can be a personal computer, a server, a network device, or a similar electronic device) execute all or part of the steps of the method described in the embodiments of the present application.

[0128] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a combination of a series of actions, but those skilled in the art should know that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to optional embodiments, and the actions and modules involved are not necessarily necessary for the present application.

[0129] It should be further noted that, although the various steps in the flowchart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps may be performed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but may be performed at different times. The execution order of these sub-steps or stages is not necessarily to be performed in sequence, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0130] It should be understood that the above-described device embodiments are merely illustrative, and the device of the present application may also be implemented in other ways. For example, the division of units / modules in the above-described embodiments is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0131] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present application may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules.

[0132] If an integrated unit / module is implemented in hardware, the hardware may be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.

[0133] If the integrated units / modules are implemented in the form of software program modules and sold or used as independent products, they can be stored in a computer readable memory. Based on this understanding, the technical solutions of the present application or the entire or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of a software product. The computer software product is stored in a memory and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned memory includes: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.

[0134] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0135] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that: they can still modify the technical solutions recorded in the above embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A thermal printing method, characterized in that: include: Replacing a first pixel value of a pixel point at an outline of a target color block in an image to be printed with a second pixel value to obtain a first target image; The red channel value of the first pixel value is less than the red channel value of the second pixel value; The thermal printer is controlled to print the first target image.

2. The method according to claim 1, characterized in that Before replacing the first pixel value of the pixel point at the outline of the target color block in the image to be printed with the second pixel value, the method further includes: Performing color space conversion on the image to be printed to obtain a second target image; Constructing a mask of the target color block based on a preset color threshold; The target color block is determined from the second target image according to the mask.

3. The method according to claim 2, characterized in that The step of replacing the first pixel value of a pixel point at the outline of a target color block in the image to be printed with the second pixel value to obtain a first target image includes: Extracting the outline of the target color block; Replacing a first pixel value of a pixel point of the outline of the target color block with a second pixel value to determine a target outline of the target color block; The object outline is combined with the second object image to obtain the first object image.

4. The method according to claim 3, characterized in that The step of replacing the first pixel value of the pixel point of the outline of the target color block with the second pixel value includes: For any point on the outline of the target color block, if the point includes at least two pixels, the first pixel value of at least one pixel is replaced with the second pixel value in the direction from the outside of the outline to the inside of the outline.

5. The method according to claim 3, characterized in that Extracting the outline of the target color block includes: Obtaining the gradient magnitude and gradient direction of the target color block; Comparing the gradient magnitude of each pixel in the target color block along the gradient direction, if the gradient magnitude of the current pixel is not a local maximum, setting its magnitude to zero, and generating a refined edge candidate region; The refined edge candidate region is segmented and edge-connected to determine the outline of the target color block.

6. The method according to claim 5, characterized in that After determining the outline of the target color block, the method includes: Get the predefined kernel; A dilation operation is performed on the outline of the target color block according to the kernel to expand the outline of the target color block.

7. The method according to any one of claims 1 to 6, characterized in that The controlling the thermal printer to print the first target image includes: generating a print data stream according to the first target image; The print data stream is encrypted and sent to the thermal printer, so that the thermal printer prints the first target image according to the encrypted print data stream.

8. An electronic device, characterized in that: include: A processor, a transceiver, and a memory; the processor is communicatively connected to the transceiver and the memory respectively; The memory is used to store computer programs; The transceiver is used to communicate and interact with external devices; The processor is configured to execute the computer program to implement the method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that A computer program is stored thereon, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The computer program comprises a computer program, which implements the method according to any one of claims 1 to 7 when executed by a controller.