CN113362319A - Laser printing method and device based on image processing, laser printer and computer readable storage medium - Google Patents
Laser printing method and device based on image processing, laser printer and computer readable storage medium Download PDFInfo
- Publication number
- CN113362319A CN113362319A CN202110745169.XA CN202110745169A CN113362319A CN 113362319 A CN113362319 A CN 113362319A CN 202110745169 A CN202110745169 A CN 202110745169A CN 113362319 A CN113362319 A CN 113362319A
- Authority
- CN
- China
- Prior art keywords
- image
- sub
- region
- gray
- printing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012545 processing Methods 0.000 title claims abstract description 103
- 238000000034 method Methods 0.000 title claims abstract description 50
- 238000007648 laser printing Methods 0.000 title claims abstract description 42
- 238000003860 storage Methods 0.000 title claims abstract description 14
- 238000007639 printing Methods 0.000 claims abstract description 37
- 238000004590 computer program Methods 0.000 claims description 12
- 238000004422 calculation algorithm Methods 0.000 claims description 7
- 238000005260 corrosion Methods 0.000 claims description 5
- 230000007797 corrosion Effects 0.000 claims description 5
- 238000010146 3D printing Methods 0.000 abstract description 14
- 238000005286 illumination Methods 0.000 description 15
- 230000003628 erosive effect Effects 0.000 description 11
- 238000010586 diagram Methods 0.000 description 5
- 238000009826 distribution Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000005530 etching Methods 0.000 description 3
- 230000000877 morphologic effect Effects 0.000 description 3
- 238000005457 optimization Methods 0.000 description 3
- 239000000853 adhesive Substances 0.000 description 2
- 230000001070 adhesive effect Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 230000010339 dilation Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 239000006185 dispersion Substances 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000009776 industrial production Methods 0.000 description 1
- 238000010147 laser engraving Methods 0.000 description 1
- 238000011430 maximum method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000012255 powdered metal Substances 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 230000035945 sensitivity Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000016776 visual perception Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/20—Image enhancement or restoration by the use of local operators
- G06T5/30—Erosion or dilatation, e.g. thinning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/194—Segmentation; Edge detection involving foreground-background segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
- G06T2207/10012—Stereo images
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20021—Dividing image into blocks, subimages or windows
Abstract
The application relates to a laser printing method and device based on image processing, a laser printer and a computer readable storage medium, comprising: and carrying out gray level processing on the image to be printed to generate a gray level image corresponding to the image to be printed. And (4) aiming at different areas in the gray level image, carrying out binarization processing on the different areas by adopting different thresholds to generate a binarization image. Generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a geocode instruction. Different areas in the gray level image are subjected to binarization processing by adopting different thresholds, so that the foreground and the background can be well distinguished in the obtained binarization image. Finally, a printing file is generated according to the binary image, and laser 3D printing is carried out on the binary image based on the printing file, so that the quality of laser printing 3D is improved.
Description
Technical Field
The present application relates to the field of laser printing technologies, and in particular, to a laser printing method and apparatus, a laser printer, and a computer-readable storage medium based on image processing.
Background
With the continuous development of the economic society and the scientific technology, the laser printer gradually goes into industrial production and daily life of people, and the working life of people is greatly changed.
The laser 3D printer is also called a three-dimensional printer, is used for laser printing or laser engraving, and is a machine adopting a rapid forming technology. The laser 3D printer is a printer that manufactures a three-dimensional object by printing a layer-by-layer adhesive material using a special adhesive material such as wax, powdered metal, or plastic based on a digital model file.
The traditional method aims at poor quality images, such as images with uneven illumination. By adopting the laser 3D printer, the quality of the three-dimensional object manufactured based on the image with poor quality is worse, and the requirement of people on the 3D printing quality cannot be met.
Disclosure of Invention
The embodiment of the application provides a laser printing method and device based on image processing, a laser printer and a computer readable storage medium, aiming at an image with poor quality, the printing quality of laser printing can be improved.
In one embodiment, there is provided a laser printing method based on image processing, applied to a laser printer, the method including:
carrying out gray level processing on an image to be printed to generate a gray level image corresponding to the image to be printed;
carrying out binarization processing on different areas in the gray level image by adopting different thresholds to generate a binarization image;
generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a Gcode instruction.
In one embodiment, the generating a binary image by performing binarization processing on different regions in the grayscale image by using different threshold values includes:
dividing the gray level image into different sub-areas by adopting a sliding window with a preset size;
and aiming at each sub-region, performing binarization processing on the sub-region by adopting a threshold value corresponding to the sub-region to generate a binarized image.
In one embodiment, the performing, for each of the sub-regions, binarization processing on the sub-region by using a threshold corresponding to the sub-region to generate a binarized image includes:
calculating the mean square error of the gray values corresponding to all pixel points in each subarea;
and carrying out binarization processing on the sub-region by adopting the mean square error to generate a binarization image.
In one embodiment, the binarizing the sub-region by using the mean square error to generate a binarized image includes:
calculating the mean value of the gray values corresponding to all the pixel points in the sub-region to generate the average gray value of the sub-region;
and aiming at each pixel point in the sub-region, carrying out binarization processing on the gray value of the pixel point according to the gray value of the pixel point, the average gray value of the sub-region and the mean square error to generate a binarization image.
In one embodiment, the binarizing processing the gray value of the pixel point according to the gray value of the pixel point, the average gray value of the sub-region, and the mean square error to generate a binarized image includes:
aiming at each pixel point in the sub-region, judging whether the square difference between the gray value of the pixel point and the average gray value of the sub-region is greater than or equal to the mean square difference of a preset multiple; the preset multiple is less than or equal to 3;
if so, setting the gray value of the pixel point as a first value; if not, setting the gray value of the pixel point as a second value; the first value is a gray value corresponding to black, and the second value is a gray value corresponding to white;
and generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points.
In one embodiment, the preset multiple is equal to 2.
In one embodiment, the generating a print file from the binarized image comprises:
carrying out corrosion treatment on the binary image to generate a corroded binary image;
and generating a printing file by adopting a Gcode algorithm based on the corroded binary image.
In one embodiment, an image processing-based laser printing apparatus includes:
the gray image generation module is used for carrying out gray processing on an image to be printed and generating a gray image corresponding to the image to be printed;
the binarization processing module is used for carrying out binarization processing on different areas in the gray level image by adopting different thresholds so as to generate a binarization image;
the printing file generating module is used for generating a printing file according to the binary image and carrying out laser printing on the binary image based on the printing file; the print file includes a Gcode instruction.
A laser printer comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to carry out the steps of the above method.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method as above.
The laser printing method and device based on image processing, the laser printer and the computer readable storage medium perform gray level processing on the image to be printed to generate a gray level image corresponding to the image to be printed. And (4) aiming at different areas in the gray level image, carrying out binarization processing on the different areas by adopting different thresholds to generate a binarization image. Generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a geocode instruction.
In the traditional method, a fixed threshold value is adopted to carry out binarization processing on an image during laser 3D printing, so that a binarized image is obtained. However, for an image with poor image quality, a binarized image obtained by performing binarization processing by using a fixed threshold value cannot well distinguish a foreground from a background. According to the method and the device, different thresholds are adopted for different areas in the gray level image to carry out binarization processing on the different areas so as to generate a binarization image. Because the difference of the gray values of different areas in the image with poor image quality is large, different areas in the gray image are subjected to binarization processing by adopting different thresholds, so that the foreground and the background can be well distinguished in the obtained binarized image. Finally, a printing file is generated according to the binary image, and laser 3D printing is carried out on the binary image based on the printing file, so that the quality of the laser 3D printing is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram of an embodiment of an application environment of a laser printing method based on image processing;
FIG. 2 is a flow diagram of a method for laser printing based on image processing in one embodiment;
fig. 3 is a flowchart of a method for generating a binarized image by binarizing different regions in the grayscale image in fig. 2 by using different thresholds;
FIG. 4 is a schematic view of a sliding window in one embodiment;
FIG. 5 is a flowchart of a method for generating a binarized image by performing binarization processing on sub-regions by using threshold values corresponding to the sub-regions in FIG. 3 for each sub-region;
FIG. 6 is a flowchart illustrating a method for generating a binarized image by performing binarization on sub-regions using mean square error in one embodiment;
FIG. 7 is a schematic illustration of an erosion core in one embodiment;
FIG. 8 is a block diagram of an embodiment of a laser printing apparatus based on image processing;
fig. 9 is a schematic view of the internal structure of the laser printer according to one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another.
The traditional method aims at poor quality images, such as images with uneven illumination. By adopting the laser 3D printer, the quality of the three-dimensional object manufactured based on the image with poor quality is worse, and the requirement of people on the 3D printing quality cannot be met.
In order to solve the technical problem, the application provides a new laser printing method, and different areas in a gray level image are subjected to binarization processing by adopting different thresholds so as to generate a binarization image. Because the difference of the gray values of different areas in the image with poor image quality is large, different areas in the gray image are subjected to binarization processing by adopting different thresholds, so that the foreground and the background can be well distinguished in the obtained binarized image. Finally, a printing file is generated according to the binary image, and laser 3D printing is carried out on the binary image based on the printing file, so that the quality of the laser 3D printing is improved.
As shown in fig. 1, fig. 1 is a diagram illustrating an application scenario of a laser printing method based on image processing in an embodiment. The application environment includes a terminal 120 and a laser 3D printer 140, and the laser 3D printer 140 receives an image to be printed transmitted by the terminal 120. The laser 3D printer 140 performs gray processing on an image to be printed, and generates a gray image corresponding to the image to be printed; carrying out binarization processing on different areas by adopting different thresholds aiming at the different areas in the gray level image to generate a binarization image; generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a geocode instruction. The laser 3D printer 140 may be a black and white laser 3D printer or a color laser 3D printer, which is not specifically limited in this embodiment of the application.
Fig. 2 is a flowchart of a laser printing method based on image processing in an embodiment, and as shown in fig. 2, a laser printing method is provided and applied to a laser 3D printer. The method includes the following steps 220 through 260.
And step 220, performing gray level processing on the image to be printed to generate a gray level image corresponding to the image to be printed.
First, the terminal transmits an image to be printed (original image) to the laser printer, and the laser printer receives the image to be printed transmitted by the terminal. Then, the laser printer performs gradation processing on the image to be printed, and generates a gradation image corresponding to the image to be printed.
The gray scale processing is to make the pixel values of the three color components R, G, B corresponding to each pixel in the original image be the same, and since the value range of the pixel values is [0, 255], the gray scale levels are only 256, that is, each pixel value in the gray scale image can only represent 256 gray scale values. The following 3 methods can be adopted to perform the gray processing on the image to be printed:
among them, the first method is the Maximum method (Maximum): that is, when R ═ G ═ B ═ Max (R, G, B) is subjected to gradation processing by the maximum value method, the luminance of the resultant gradation image becomes high.
The second method is the Average method (Average): that is, when R ═ G ═ B ═ R + G + B)/3 is subjected to gradation processing by an average value method, the luminance of the obtained gradation image is soft.
The third method is Weighted Average method (Weighted Average): that is, R ═ G ═ B ═ wr ═ R + wg ═ G + wb ═ B, where wr, wg, and wb are weighted values corresponding to R, G, B, respectively. When the weights R, G, B have different values, different gray-scale images can be formed. Since the human eye has the highest sensitivity to green, the second to red and the lowest to blue, when wg > wr > wb, the gray image generated is more suitable for the visual perception of the human eye. Therefore, generally, wr is 30%, wg is 59%, and wb is 11%, and the gradation of the image is most appropriate. For example, the conversion formula of the gradation processing employed in the present application is: grey is 0.299R + 0.587G + 0.114B. Where, gray denotes a gray value obtained after the gray processing. Of course, the present application does not specifically limit the conversion formula of the gradation processing.
And carrying out gray level processing on each pixel point in the image to be printed to obtain a converted gray value. A gray image corresponding to the image to be printed is constructed based on the converted gray values.
And 240, performing binarization processing on different areas in the gray level image by adopting different thresholds to generate a binarized image.
In the process of actually shooting an image, the illumination of the shot image is not uniform due to the illumination non-uniformity in the environment, and therefore, the image quality is poor. Common phenomenon of uneven illumination, including dark illumination on one side of an image and bright illumination on the other side; the illumination of the center of the image is dark, and the illumination of the periphery of the image is bright; the illumination of the center on the image is relatively bright, the illumination of the periphery is relatively dark, and the like, which is not particularly limited in this application. The phenomenon of uneven illumination exists on the image, and the effect of laser printing is affected.
For an image with uneven illumination, the foreground (object) is assumed to be bright and the background is assumed to be dark. At this time, if the conventional method is adopted, that is, only one fixed threshold (binarization critical value) is used for carrying out binarization processing on the image, the foreground and the background cannot be accurately distinguished due to uneven illumination on the image, so that the pixels actually belonging to the background are wrongly divided into the foreground, and the pixels actually belonging to the foreground are divided into the foreground. Therefore, the accuracy of the binarized image obtained by binarizing the image with the fixed threshold is low.
Aiming at an image with uneven illumination, different areas in a gray level image are binarized by adopting different thresholds to generate a binarized image. The gray value of the bright area in the gray image is larger, and the gray value of the dark area is smaller. Therefore, a larger threshold value is adopted to carry out binarization processing on a bright area in the gray level image, and a smaller threshold value is adopted to carry out binarization processing on a dark area in the gray level image, namely, the dynamic threshold value is adopted to carry out binarization processing on the gray level image. Therefore, the foreground and the background in the gray level image can be accurately distinguished, and the accuracy of the obtained binary image is improved.
Step 260, generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a geocode instruction.
After the binary processing is carried out on the gray level image by adopting the dynamic threshold value to generate the binary image, the image optimization processing can be carried out on the binary image, and the accuracy of the binary image is improved. The image optimization process may include performing morphological operations on the binary image, such as erosion, dilation, opening operation, closing operation, and the like, and this is not particularly limited in the present application.
The etching operation, as its name implies, etches the edge of the object. The protruding points on the periphery of the image can be etched by the etching operation. The dilation operation is the opposite of the erosion operation, in that the contours of the image are dilated, by which prominent points on the periphery of the image can be connected and extended outward. The opening operation is to perform the erosion operation and then the expansion operation on the image. The opening operation is performed to enlarge cracks and low density regions, eliminate small objects, and perform the opening operation without changing the area of the boundary of a larger object when the opening operation is performed to smooth the boundary. The close operation is to perform the expansion operation and then the erosion operation on the image. The closing operation is performed to eliminate the small black hole, highlight the darker area than the original outline area, and connect the two areas to form a connected domain.
Then, a print file is generated based on the binarized image after the optimization processing, wherein the print file includes a Gcode instruction. Finally, the binary image can be laser printed on paper based on the printing file.
In the embodiment of the application, different areas in the gray level image are binarized by different thresholds to generate a binarized image. Because the difference of the gray values of different areas in the image with poor image quality is large, different areas in the gray image are subjected to binarization processing by adopting different thresholds, so that the foreground and the background can be well distinguished in the obtained binarized image. Finally, a printing file is generated according to the binary image, and laser 3D printing is carried out on the binary image based on the printing file, so that the quality of the laser 3D printing is improved.
In one embodiment, as shown in fig. 3, in step 240, performing binarization processing on different regions in the grayscale image by using different threshold values to generate a binarized image, including:
in step 244, for each sub-region, a threshold value corresponding to the sub-region is used to perform binarization processing on the sub-region, thereby generating a binarized image.
Fig. 4 is a schematic diagram of a sliding window (sliding window for short) in an embodiment. The horizontal axis direction of the gray image is evenly divided into n equal parts, and the vertical axis direction of the gray image is evenly divided into m equal parts. In this way, the grayscale image is divided into m × n sliding windows of a preset size. Here, two adjacent sliding windows do not have a common area therebetween, and in other implementations of the present embodiment, two adjacent sliding windows may have a common-sized area therebetween.
The gray scale image is assumed to include a first edge and a second edge, and the side length of the first edge is larger than that of the second edge. Then, the length and width of the sliding window of the preset size may be set to 1/32 of the first side of the gray image. For example, for a 1080 × 1920 gray scale image, 1/32 on the long side (1920) of the gray scale image is selected as the length and width of the sliding window, i.e. 60 × 60 gray scale values are included in the sliding window. Of course, the size of the sliding window is not specifically limited in this application.
After the sliding window size is determined, the sliding window may be moved to divide the grayscale image into a plurality of sub-regions. And aiming at each sub-region, performing binarization processing on the sub-region by adopting a threshold value corresponding to the sub-region to generate a binarization image. The threshold corresponding to each sub-region may be calculated based on all gray values in the sub-region, and therefore, the threshold corresponding to each sub-region may be different. In this way, different threshold values can be adopted to carry out binarization processing on the sub-regions respectively to generate a binarized image.
In the embodiment of the application, different threshold values are adopted for binarization processing aiming at different areas in the gray level image, and when the binary image is generated, the gray level image can be uniformly divided into different sub-areas by adopting a sliding window mode. Then, for each sub-region, a threshold value corresponding to the sub-region may be used to perform binarization processing on the sub-region, thereby generating a binarized image. Based on the uniformly divided sub-regions, different threshold values are respectively adopted for binarization processing, and the foreground and the background can be well distinguished in the obtained binarized image. Finally, a printing file is generated according to the binary image, and laser 3D printing is carried out on the binary image based on the printing file, so that the quality of the laser 3D printing is improved.
In one embodiment, as shown in fig. 5, step 244, for each sub-region, performing binarization processing on the sub-region by using a threshold corresponding to the sub-region, and generating a binarized image, includes:
244a, calculating the mean square error of the gray values corresponding to all the pixel points in the subareas aiming at each subarea;
and 244b, performing binarization processing on the sub-region by using the mean square error to generate a binarized image.
After the gray level image is uniformly divided into different sub-regions by adopting a sliding window mode through the steps, the mean square error of the gray level values corresponding to all the pixel points in the sub-regions is calculated aiming at each sub-region. The mean square error is also referred to as the standard deviation, which reflects the degree of dispersion of a data set. The formula for calculating the mean square error of the gray values corresponding to all the pixel points in the sub-region is as follows:
wherein n represents the sub-region including n pixel points, sigma represents the mean square error of the gray value of n pixel points, and xiRepresents the gray value of the ith pixel point,and expressing the average value of the gray values of n pixel points in the sub-region.
After the mean square error of the gray values corresponding to all the pixel points in the sub-region is calculated, the sub-region is subjected to binarization processing by adopting the mean square error, and a binarization image is generated. Specifically, the sub-region may be binarized based on a relationship between a gray value corresponding to each pixel point in the sub-region and the mean square error.
In the embodiment of the application, the mean square error can reflect the discrete degree of a data set, so that the mean square error of the gray values corresponding to all pixel points in the sub-region is calculated for each sub-region, the sub-region is subjected to binarization processing by adopting the mean square error to generate a binarization image, and the foreground and the background can be well distinguished in the obtained binarization image.
In one embodiment, the binarization processing is performed on the sub-region by using the mean square error to generate a binarized image, and the binarization processing comprises the following steps:
calculating the mean value of the gray values corresponding to all the pixel points in the sub-region to generate the average gray value of the sub-region;
and aiming at each pixel point in the sub-region, carrying out binarization processing on the gray value of the pixel point according to the gray value of the pixel point, the average gray value and the mean square error of the sub-region, and generating a binarization image.
Specifically, when the sub-region is binarized by using the mean square error, and a binarized image is generated, first, the mean value of the gray values corresponding to all the pixel points in the sub-region is calculated, and the average gray value of the sub-region is generatedThen, for each pixel point in the sub-region, the gray value of the pixel point is binarized according to the gray value of the pixel point, the average gray value and the mean square error of the sub-region, so as to generate a binary image.
Wherein, in generating the binarized image, as shown in fig. 6, steps 620-660 are included, wherein,
Specifically, the area is 99.74% in the normal distribution, i.e., (μ -3 σ, μ +3 σ). Wherein μ is a position parameter of the normal distribution, describing a central tendency position of the normal distribution. Therefore, the preset multiple is set to be less than or equal to 3, and optionally, the preset multiple is 2, and then whether the square difference between the gray value of the pixel point and the average gray value of the sub-region is greater than or equal to the mean square difference of the preset multiple may be determined according to the following formula:
wherein n represents that the sub-area comprises n pixel points,mean square error, x, representing the gray values of n pixelsiRepresents the gray value of the ith pixel point,and expressing the average value of the gray values of n pixel points in the sub-region.
If the square difference between the gray value of the pixel point and the average gray value of the sub-region is greater than or equal to the mean square difference of the preset multiple, the pixel point is indicated as a foreground, and therefore the gray value of the pixel point is set to be a first value, namely the gray value corresponding to black.
If the square difference between the gray value of the pixel point and the average gray value of the sub-region is not greater than or equal to the mean square difference of the preset multiple, the pixel point is indicated as the background, and therefore the gray value of the pixel point is set to be a second value, namely the gray value corresponding to the white color.
And step 680, generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points.
And finally, configuring a first value or a second value for each pixel point on the gray level image, and generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points.
In the embodiment of the application, whether the square difference between the gray value of the pixel point and the average gray value of the sub-region is larger than or equal to the mean square difference of the preset multiple or not is judged for each pixel point in the sub-region. If so, setting the gray value of the pixel point as a first value; if not, setting the gray value of the pixel point as a second value; the first value is a gray value corresponding to black, and the second value is a gray value corresponding to white. And generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points. Since the mean square error can reflect the discrete degree of a data set, the mean square error is adopted to carry out binarization processing on the sub-region to generate a binarized image, and the foreground and the background can be well distinguished in the obtained binarized image.
In one embodiment, generating a print file from the binarized image comprises:
carrying out corrosion treatment on the binary image to generate a corroded binary image;
and generating a printing file by adopting a Gcode algorithm based on the corroded binary image.
Specifically, the erosion processing is one of basic morphological operations, and can eliminate boundary points of an image, shrink the image inwards along the boundary, and remove elements smaller than a specified structure, thereby realizing functions of noise removal, element segmentation and the like.
In the erosion process, a kernel (structural element) is generally used to scan an image to be eroded pixel by pixel, and an erosion result is determined according to the relationship of the kernel (structural element). FIG. 7 is a schematic illustration of an erosion core in one embodiment. Morphological operations such as erosion operations are performed on a pixel-by-pixel basis, where each determined point is the point corresponding to the center point of the structural element. If the kernel (structural element) is completely in the foreground of the image, the pixel point in the corrosion result image used by the central point of the structural element is processed into the gray value corresponding to the foreground. If the kernel (structural element) is not completely in the foreground (may be partially absent or may be completely absent) on the image, processing the pixel point in the corrosion result corresponding to the central point of the kernel (structural element) as the gray value corresponding to the background. In this way, the binarized image is subjected to the etching process to generate an etched binarized image.
And then, generating a printing file by adopting a Gcode algorithm based on the corroded binary image. Specifically, a Gcode command is generated by adopting a Gcode algorithm, wherein the Gcode command is a command which can be understood by the 3D printer firmware, and the Gcode command is stored in a Gcode file. Subsequently, the laser printer can perform laser printing on the binary image based on the print file.
In the embodiment of the application, the binary image is corroded to generate the corroded binary image, so that the accuracy of the binary image can be further improved. And then, generating a printing file by adopting a Gcode algorithm based on the corroded binary image. Finally, the laser printer can perform laser 3D printing on the binarized image based on the print file. Finally, the quality of laser 3D printing is improved.
In one embodiment, as shown in fig. 8, there is provided an image processing based laser printing apparatus 800, the apparatus comprising:
a gray image generation module 820, configured to perform gray processing on an image to be printed, and generate a gray image corresponding to the image to be printed;
a binarization processing module 840, configured to perform binarization processing on different regions in the grayscale image by using different thresholds, so as to generate a binarized image;
a print file generation module 860, configured to generate a print file according to the binarized image, and perform laser printing on the binarized image based on the print file; the print file includes a geocode instruction.
In one embodiment, the binarization processing module 840 is further configured to divide the grayscale image into different sub-regions by using a sliding window with a preset size; and aiming at each sub-region, performing binarization processing on the sub-region by adopting a threshold value corresponding to the sub-region to generate a binarization image.
In an embodiment, the binarization processing module 840 is further configured to calculate, for each sub-region, a mean square error of the gray values corresponding to all the pixel points in the sub-region; and carrying out binarization processing on the sub-region by adopting mean square error to generate a binarization image.
In an embodiment, the binarization processing module 840 is further configured to calculate an average value of gray values corresponding to all pixel points in the sub-region, and generate an average gray value of the sub-region; and aiming at each pixel point in the sub-region, carrying out binarization processing on the gray value of the pixel point according to the gray value of the pixel point, the average gray value and the mean square error of the sub-region, and generating a binarization image.
In an embodiment, the binarization processing module 840 is further configured to determine, for each pixel point in the sub-region, whether a square difference between a gray value of the pixel point and an average gray value of the sub-region is greater than or equal to a mean square difference of a preset multiple; the preset multiple is less than or equal to 3;
if so, setting the gray value of the pixel point as a first value; if not, setting the gray value of the pixel point as the gray value; the first value is a gray value corresponding to black, and the second value is a gray value corresponding to white;
and generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points.
In one embodiment, the preset multiple is equal to 2.
In one embodiment, the print file generating module 860 is further configured to perform erosion processing on the binary image to generate an eroded binary image; and generating a printing file by adopting a Gcode algorithm based on the corroded binary image.
The division of each module in the laser printing apparatus based on image processing is only for illustration, and in other embodiments, the laser printing apparatus may be divided into different modules as needed to complete all or part of the functions of the laser printing apparatus.
Fig. 9 is a schematic view of the internal structure of the laser printer according to one embodiment. As shown in fig. 9, the laser printer includes a processor and a memory connected by a system bus. Wherein the processor is used for providing calculation and control capability and supporting the operation of the whole laser printer. The memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The computer program can be executed by a processor for implementing an image processing-based laser printing method provided in the following embodiments. The internal memory provides a cached execution environment for the operating system computer programs in the non-volatile storage medium.
The implementation of each module in the laser printing apparatus provided in the embodiments of the present application may be in the form of a computer program. The computer program may be run on a laser printer. Program modules comprising the computer program may be stored on a memory of the laser printer. Which when executed by a processor, performs the steps of the method described in the embodiments of the present application.
The embodiment of the application also provides a computer readable storage medium. One or more non-transitory computer-readable storage media containing computer-executable instructions that, when executed by one or more processors, cause the processors to perform the steps of the image processing-based laser printing method.
A computer program product containing instructions which, when run on a laser printer, cause the laser printer to perform a laser printing method based on image processing.
Any reference to memory, storage, database, or other medium used by embodiments of the present application may include non-volatile and/or volatile memory. Suitable non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A method of laser printing based on image processing, the method comprising:
carrying out gray level processing on an image to be printed to generate a gray level image corresponding to the image to be printed;
carrying out binarization processing on different areas in the gray level image by adopting different thresholds to generate a binarization image;
generating a printing file according to the binary image, and carrying out laser printing on the binary image based on the printing file; the print file includes a Gcode command.
2. The method according to claim 1, wherein the generating a binarized image by performing binarization processing with different threshold values for different regions in the grayscale image comprises:
dividing the gray level image into different sub-areas by adopting a sliding window with a preset size;
and aiming at each sub-region, performing binarization processing on the sub-region by adopting a threshold value corresponding to the sub-region to generate a binarized image.
3. The method according to claim 2, wherein the generating a binarized image by binarizing each of the sub-regions by using a threshold corresponding to the sub-region comprises:
calculating the mean square error of the gray values corresponding to all pixel points in each subarea;
and carrying out binarization processing on the sub-region by adopting the mean square error to generate a binarization image.
4. The method according to claim 3, wherein the binarizing the sub-region by using the mean square error to generate a binarized image comprises:
calculating the mean value of the gray values corresponding to all the pixel points in the sub-region to generate the average gray value of the sub-region;
and aiming at each pixel point in the sub-region, carrying out binarization processing on the gray value of the pixel point according to the gray value of the pixel point, the average gray value of the sub-region and the mean square error to generate a binarization image.
5. The method according to claim 4, wherein the generating a binarized image by binarizing the gray value of each pixel point in the sub-region according to the gray value of the pixel point, the average gray value of the sub-region and the mean square error comprises:
aiming at each pixel point in the sub-region, judging whether the square difference between the gray value of the pixel point and the average gray value of the sub-region is greater than or equal to the mean square difference of a preset multiple; the preset multiple is less than or equal to 3;
if so, setting the gray value of the pixel point as a first value; if not, setting the gray value of the pixel point as a second value; the first value is a gray value corresponding to black, and the second value is a gray value corresponding to white;
and generating a binary image based on the pixel points and the first values or the second values corresponding to the pixel points.
6. The method according to claim 5, characterized in that said preset multiple is equal to 2.
7. The method according to claim 1, wherein said generating a print file from said binarized image comprises:
carrying out corrosion treatment on the binary image to generate a corroded binary image;
and generating a printing file by adopting a Gcode algorithm based on the corroded binary image.
8. An image processing-based laser printing apparatus, comprising:
the gray image generation module is used for carrying out gray processing on an image to be printed and generating a gray image corresponding to the image to be printed;
the binarization processing module is used for carrying out binarization processing on different areas in the gray level image by adopting different thresholds so as to generate a binarization image;
the printing file generating module is used for generating a printing file according to the binary image and carrying out laser printing on the binary image based on the printing file; the print file includes a Gcode instruction.
9. A laser printer comprising a memory and a processor, the memory having stored thereon a computer program, wherein the computer program, when executed by the processor, causes the processor to perform the steps of the image processing based laser printing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the image-processing-based laser printing method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110745169.XA CN113362319A (en) | 2021-06-30 | 2021-06-30 | Laser printing method and device based on image processing, laser printer and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110745169.XA CN113362319A (en) | 2021-06-30 | 2021-06-30 | Laser printing method and device based on image processing, laser printer and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113362319A true CN113362319A (en) | 2021-09-07 |
Family
ID=77537802
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110745169.XA Pending CN113362319A (en) | 2021-06-30 | 2021-06-30 | Laser printing method and device based on image processing, laser printer and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113362319A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114882146A (en) * | 2022-07-06 | 2022-08-09 | 深圳市国人光速科技有限公司 | Image hollowing processing method and device for jet printing, computer equipment and storage medium |
Citations (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04330867A (en) * | 1991-05-02 | 1992-11-18 | Minolta Camera Co Ltd | Image processor |
US20020131646A1 (en) * | 2001-03-14 | 2002-09-19 | Fujitsu Limited | Image processing apparatus |
US6577762B1 (en) * | 1999-10-26 | 2003-06-10 | Xerox Corporation | Background surface thresholding |
CN101021905A (en) * | 2006-02-15 | 2007-08-22 | 中国科学院自动化研究所 | File image binaryzation method |
US20100054585A1 (en) * | 2008-09-03 | 2010-03-04 | Jean-Pierre Guillou | Text localization for image and video OCR |
CN102855617A (en) * | 2011-07-01 | 2013-01-02 | 中国科学院深圳先进技术研究院 | Method and system for processing adaptive images |
JP2013171469A (en) * | 2012-02-21 | 2013-09-02 | Fujitsu Ltd | Image processing apparatus, binarization threshold calculation method, and computer program |
CN105447491A (en) * | 2014-07-25 | 2016-03-30 | 北京大学深圳研究生院 | Signboard image binaryzation method and device |
CN106723241A (en) * | 2017-01-09 | 2017-05-31 | 浙江大学 | A kind of 3D portraits food Method of printing |
CN106886987A (en) * | 2017-03-23 | 2017-06-23 | 重庆大学 | A kind of train license plate binary image interfusion method |
CN106991753A (en) * | 2017-04-07 | 2017-07-28 | 深圳怡化电脑股份有限公司 | A kind of image binaryzation method and device |
CN108509819A (en) * | 2018-03-07 | 2018-09-07 | 中山大学 | A kind of Quick Response Code binarization method even for uneven illumination |
CN108510499A (en) * | 2018-02-08 | 2018-09-07 | 河南师范大学 | A kind of carrying out image threshold segmentation method and device based on fuzzy set and Otsu |
CN108961260A (en) * | 2017-05-26 | 2018-12-07 | 阿里巴巴集团控股有限公司 | Image binaryzation method and device, computer storage medium |
CN109711284A (en) * | 2018-12-11 | 2019-05-03 | 江苏博墨教育科技有限公司 | A kind of test answer sheet system intelligent recognition analysis method |
CN109712158A (en) * | 2018-11-23 | 2019-05-03 | 山东航天电子技术研究所 | A kind of infrared small target catching method based on target background pixel statistical restraint |
CN110502194A (en) * | 2019-07-19 | 2019-11-26 | 广州奔想智能科技有限公司 | A kind of text printing method, system and storage medium |
CN110648284A (en) * | 2019-08-02 | 2020-01-03 | 中山市奥珀金属制品有限公司 | Image processing method and device for uneven illumination |
CN111161174A (en) * | 2019-12-20 | 2020-05-15 | 陈斯雅 | Blood vessel model establishing method and device, computer equipment and storage medium |
CN111523341A (en) * | 2020-04-03 | 2020-08-11 | 青岛进化者小胖机器人科技有限公司 | Binaryzation method and equipment for two-dimensional code image |
CN111583157A (en) * | 2020-05-13 | 2020-08-25 | 杭州睿琪软件有限公司 | Image processing method, system and computer readable storage medium |
CN111986222A (en) * | 2020-08-21 | 2020-11-24 | 国网宁夏电力有限公司营销服务中心(国网宁夏电力有限公司计量中心) | Intelligent electric meter chip image binarization processing method based on self-adaptive mixed threshold value |
CN112016564A (en) * | 2020-10-27 | 2020-12-01 | 恒银金融科技股份有限公司 | Method for calculating optimal binarization threshold value at lower case amount of financial bill |
CN112163443A (en) * | 2020-10-20 | 2021-01-01 | 汪金玲 | Code scanning method, code scanning device and mobile terminal |
CN112677487A (en) * | 2020-12-30 | 2021-04-20 | 上海联泰科技股份有限公司 | Control method and control system for 3D printing and 3D printing equipment |
-
2021
- 2021-06-30 CN CN202110745169.XA patent/CN113362319A/en active Pending
Patent Citations (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04330867A (en) * | 1991-05-02 | 1992-11-18 | Minolta Camera Co Ltd | Image processor |
US6577762B1 (en) * | 1999-10-26 | 2003-06-10 | Xerox Corporation | Background surface thresholding |
US20020131646A1 (en) * | 2001-03-14 | 2002-09-19 | Fujitsu Limited | Image processing apparatus |
CN101021905A (en) * | 2006-02-15 | 2007-08-22 | 中国科学院自动化研究所 | File image binaryzation method |
US20100054585A1 (en) * | 2008-09-03 | 2010-03-04 | Jean-Pierre Guillou | Text localization for image and video OCR |
CN102855617A (en) * | 2011-07-01 | 2013-01-02 | 中国科学院深圳先进技术研究院 | Method and system for processing adaptive images |
JP2013171469A (en) * | 2012-02-21 | 2013-09-02 | Fujitsu Ltd | Image processing apparatus, binarization threshold calculation method, and computer program |
CN105447491A (en) * | 2014-07-25 | 2016-03-30 | 北京大学深圳研究生院 | Signboard image binaryzation method and device |
CN106723241A (en) * | 2017-01-09 | 2017-05-31 | 浙江大学 | A kind of 3D portraits food Method of printing |
CN106886987A (en) * | 2017-03-23 | 2017-06-23 | 重庆大学 | A kind of train license plate binary image interfusion method |
CN106991753A (en) * | 2017-04-07 | 2017-07-28 | 深圳怡化电脑股份有限公司 | A kind of image binaryzation method and device |
CN108961260A (en) * | 2017-05-26 | 2018-12-07 | 阿里巴巴集团控股有限公司 | Image binaryzation method and device, computer storage medium |
CN108510499A (en) * | 2018-02-08 | 2018-09-07 | 河南师范大学 | A kind of carrying out image threshold segmentation method and device based on fuzzy set and Otsu |
CN108509819A (en) * | 2018-03-07 | 2018-09-07 | 中山大学 | A kind of Quick Response Code binarization method even for uneven illumination |
CN109712158A (en) * | 2018-11-23 | 2019-05-03 | 山东航天电子技术研究所 | A kind of infrared small target catching method based on target background pixel statistical restraint |
CN109711284A (en) * | 2018-12-11 | 2019-05-03 | 江苏博墨教育科技有限公司 | A kind of test answer sheet system intelligent recognition analysis method |
CN110502194A (en) * | 2019-07-19 | 2019-11-26 | 广州奔想智能科技有限公司 | A kind of text printing method, system and storage medium |
CN110648284A (en) * | 2019-08-02 | 2020-01-03 | 中山市奥珀金属制品有限公司 | Image processing method and device for uneven illumination |
CN111161174A (en) * | 2019-12-20 | 2020-05-15 | 陈斯雅 | Blood vessel model establishing method and device, computer equipment and storage medium |
CN111523341A (en) * | 2020-04-03 | 2020-08-11 | 青岛进化者小胖机器人科技有限公司 | Binaryzation method and equipment for two-dimensional code image |
CN111583157A (en) * | 2020-05-13 | 2020-08-25 | 杭州睿琪软件有限公司 | Image processing method, system and computer readable storage medium |
CN111986222A (en) * | 2020-08-21 | 2020-11-24 | 国网宁夏电力有限公司营销服务中心(国网宁夏电力有限公司计量中心) | Intelligent electric meter chip image binarization processing method based on self-adaptive mixed threshold value |
CN112163443A (en) * | 2020-10-20 | 2021-01-01 | 汪金玲 | Code scanning method, code scanning device and mobile terminal |
CN112016564A (en) * | 2020-10-27 | 2020-12-01 | 恒银金融科技股份有限公司 | Method for calculating optimal binarization threshold value at lower case amount of financial bill |
CN112677487A (en) * | 2020-12-30 | 2021-04-20 | 上海联泰科技股份有限公司 | Control method and control system for 3D printing and 3D printing equipment |
Non-Patent Citations (5)
Title |
---|
DLIVEROL30914: ""基于局部阈值化的图像二值化"", 《必应HTTPS://BLOG.CSDN.NET/DLIVEROL30914/ARTICLE/DETAILS/101636271》, 1 March 2017 (2017-03-01) * |
YU HE等: ""An Improved Sauvola Approach on QR Code Image Binarization"", 《IEEE》, 19 December 2019 (2019-12-19) * |
倪晶: ""低质量激光防伪码识别及其系统实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》, 15 February 2019 (2019-02-15) * |
张洁玉;: "基于图像分块的局部阈值二值化方法", 计算机应用, no. 03 * |
李艺杰;邹坤霖;孙炜;王耀南;梁桥康;: "基于Sauvola算法和神经网络的图像自适应二值化方法", 测控技术, no. 08 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114882146A (en) * | 2022-07-06 | 2022-08-09 | 深圳市国人光速科技有限公司 | Image hollowing processing method and device for jet printing, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107392858B (en) | Image highlight area processing method and device and terminal equipment | |
JP4416406B2 (en) | Improved speckle algorithm for grayscale images | |
CN110390643B (en) | License plate enhancement method and device and electronic equipment | |
Singh et al. | Advanced image processing using opencv | |
CN111783795B (en) | Method, device, equipment and medium for converting image into laser scanning path | |
CN104966092A (en) | Image processing method and device | |
CN109522768A (en) | The recognition methods of QR code and device | |
CN113362319A (en) | Laser printing method and device based on image processing, laser printer and computer readable storage medium | |
CN115909353A (en) | Image binarization processing method and device | |
US10742845B2 (en) | Image processing apparatus identifying pixel which satisfies specific condition and performing replacement process on pixel value of identified pixel | |
CN108921869B (en) | Image binarization method and device | |
CN110930358B (en) | Solar panel image processing method based on self-adaptive algorithm | |
JP2006180376A (en) | Image processing apparatus | |
CN110147765B (en) | Image processing method and device | |
CN114550173A (en) | Image preprocessing method and device, electronic equipment and readable storage medium | |
CN112307923A (en) | Partitioned expression migration method and system | |
CN109426770B (en) | Iris identification method | |
CN115631198A (en) | Crack detection method and device for glass display screen and computer equipment | |
CN107292840B (en) | Image restoration method and device, computer-readable storage medium and terminal | |
CN112052859B (en) | License plate accurate positioning method and device in free scene | |
JP2019145940A (en) | Image processing apparatus, image processing method, and program | |
US11100355B1 (en) | Document image content protection in the context of noise reduction | |
CN114723728A (en) | Method and system for detecting CD line defects of silk screen of glass cover plate of mobile phone camera | |
RU2520407C1 (en) | Method and system of text improvement at digital copying of printed documents | |
CN112508024A (en) | Intelligent identification method for embossed seal font of electrical nameplate of transformer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |