Method for improving contrast ratio of engraved image for laser engraving system
Through the combination of ITU-R BT.2100 standard and cumulative distribution function, the limitations of laser engraving technology in high-contrast image processing are solved, and the contrast and details are significantly improved, and the image contrast and detail performance in the prior art are solved. Poor problem.
Patent Information
- Application Number
- CN202411026029.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-12
AI Technical Summary
Existing laser engraving technology is difficult to achieve the expected engraving effect when processing complex images and rich in detail, especially in the processing of high-contrast images, where image contrast and details are poor.
The ITU-R BT.2100 standard is used for grayscale processing, and the extreme values are excluded through the grayscale conversion formula, and the image histogram equalization is performed. The cumulative distribution function is used to remap the grayscale value of each pixel to cover 5 to 5. 250 grayscale range, thereby enhancing the overall and local contrast of the image.
It significantly improves the overall contrast and detailed performance of the image, makes the image clearer, avoids the impact of extreme values on the overall effect, and improves the quality and accuracy of laser engraving.
Smart Images

Figure CN118941480A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of industrial production fixtures, in particular to a method for improving the contrast of engraved images in a laser engraving system. Background Art
[0002] As we all know, laser engraving machine is a kind of equipment based on CNC technology and laser as processing medium. The physical transformation of the processing material melting and gasification under the irradiation of laser engraving can make laser engraving achieve the purpose of processing. Among them, the image of the engraving machine can be directly engraved in proportion according to the input image file. When working specifically, it is necessary to perform corresponding processing on the image file.
[0003] At present, the existing laser engraving technology usually relies on simple grayscale conversion and laser power adjustment when processing images. Although this method can achieve image engraving to a certain extent, it still has great limitations in processing complex images and details, and the engraving effect is difficult to achieve the expected effect, especially when processing high-contrast and detailed images, the engraving effect presented is not good.
[0004] Therefore, in order to improve the engraving effect, a more effective image processing method is needed to optimize the quality and accuracy of laser engraving. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, an object of the present invention is to provide a method for improving the contrast of an engraved image in a laser engraving system.
[0006] In order to achieve the above object, the present invention adopts the following technical solution: A method for improving the contrast of an engraved image in a laser engraving system comprises the following steps: S1. The user uploads the image file to be engraved through the system interface, and the system receives and verifies the image format for identification; S2, after identifying the image file, grayscale it using the ITU-R BT.2100 standard, access each pixel in the image, and transform it to obtain a grayscale image with grayscale values in pixels; S3, excluding the grayscale values obtained according to the grayscale conversion formula, taking 0.02-0.98 as the grayscale value range, excluding extreme values outside 0.02-0.98, and then performing image histogram equalization processing; S4, determine the statistical interval, and perform statistics on the probability of occurrence of each gray value, and form a histogram based on the statistical structure, and obtain the corresponding cumulative occurrence times between different gray values; S5. Obtain the cumulative distribution probability by calculation: , where P(i) represents the cumulative distribution probability of grayscale greater than i, CDF(i) represents the cumulative grayscale greater than i, and N represents the total statistical samples, that is, the total number of pixels in the image that belong to the interval [5,250]; S6. Obtain the mapped gray value P' through the following formula: , P(i) represents the cumulative distribution probability of the original gray level i, P hight Indicates grayscale value 250, P low Indicates grayscale value 5; Through the above mapping formula, each gray value i in the original image is remapped to a new gray value P' to generate a balanced image, thereby enhancing the overall contrast and detail performance of the image.
[0007] Preferably, in step S2, after grayscale conversion using the ITU-R BT.2100 standard, the grayscale conversion formula is: Gray=R*0.333+G*0.333+B*0.333. R, G, and B in the formula are the parameters corresponding to red, green, and blue in each pixel respectively. Relying on this formula, each pixel in the image is accessed and transformed to obtain a grayscale image with pixels as units and grayscale values.
[0008] Preferably, in step S4, the following formula is used: Low=(L-1)*0.02 Hight=(L-1)*0.98 Among them, L=256 grayscales, and after rounding to the nearest integer, the required statistical interval is: [5,250]; The probability of occurrence of each gray value is counted by the cumulative distribution function, and a histogram is formed by the statistical structure to obtain the corresponding cumulative occurrence times between different gray values; The cumulative distribution function is calculated as: , Among them, P(j) represents the frequency of gray value j, and j represents the gray value for frequency statistics.
[0009] Due to the adoption of the above scheme, in the processing process of the present invention, the gray value of each pixel is remapped according to the cumulative distribution function (CDF). The mapped gray value covers the gray range of 5 to 250, so that the contrast between pixels of different gray levels is significantly enhanced. At the same time, in the histogram equalization process, the gray values with higher frequencies in the original image are dispersed to more gray levels, so that more details in the image can be expressed. And by redistributing the gray values within a specific interval, the histogram equalization avoids the influence of extreme values in the image on the overall effect. This processing not only improves the overall contrast of the image, but also enhances the contrast of the local area, making the image clearer. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 It is a grayscale image with grayscale values according to an embodiment of the present invention.
[0011] Figure 2 The embodiment of the present invention Figure 1 Schematic diagram of the final statistical results of the 9 small square values.
[0012] Figure 3 The embodiment of the present invention Figure 1 The new grayscale image after histogram equalization.
[0013] Figure 4 is a distribution diagram of the number of pixels in gray levels according to an embodiment of the present invention.
[0014] Figure 5 , Figure 6 It is a schematic diagram of the effect comparison after equalization of an actual image in an embodiment of the present invention. DETAILED DESCRIPTION
[0015] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0016] like Figures 1 to 6 As shown, this embodiment provides a method for improving the contrast of an engraved image in a laser engraving system, comprising the following steps: S1. The user uploads the image file to be engraved through the system interface, and the system receives and verifies the image format for identification; S2, after identifying the image file, grayscale it using the ITU-R BT.2100 standard, access each pixel in the image, and transform it. The grayscale conversion formula is: Gray=R*0.333+G*0.333+B*0.333, where R, G, and B are the parameters corresponding to red, green, and blue in each pixel. Based on this formula, each pixel in the image is accessed and transformed to obtain a grayscale image with grayscale values in pixels, such as Figure 1 shown.
[0017] S3, excluding the grayscale value obtained according to the grayscale conversion formula, taking 0.02-0.98 as the grayscale value range, excluding extreme values (i.e. very bright or very dark pixels) outside 0.02-0.98, and then performing image histogram equalization processing; S4. Determine the statistical interval, By the following formula: Low=(L-1)*0.02 Hight=(L-1)*0.98 Among them, L=256 grayscales, and after rounding to the nearest integer, the required statistical interval is: [5,250]; The probability of occurrence of each gray value is counted by the cumulative distribution function, and a histogram is formed by the statistical structure to obtain the corresponding cumulative occurrence times between different gray values; The cumulative distribution function is calculated as: Where P(j) represents the frequency of gray value j, and j represents the gray value for frequency statistics; For example, suppose Figure 1 The square is a 3*3 grayscale image. It is known that there are 256 grayscale values in total. To count the frequency of this 3x3 grayscale image, 256 positions can be used, and the corresponding serial number of each position ranges from 0 to 255. Check the values of these 9 small squares and put them into the corresponding positions. Then the final statistical result is as follows Figure 2 At the same time, it can be expressed in the form of serial number corresponding to quantity: Serial number 0 66 99 125 222 255 quantity 1 1 2 1 3 1 S5. Obtain the cumulative distribution probability by calculation: , where P(i) represents the cumulative distribution probability of grayscale greater than i, CDF(i) represents the cumulative grayscale greater than i, and N represents the total number of samples, that is, the total number of pixels in the image that belong to the interval [5,250]. Since only the values between numbers 5 and 250 need to be counted, the statistical results are as follows: Serial number accumulation Cumulative distribution probability 0 1 66 0+1=1 1 / 7=0.143 99 1+2=3 3 / 7=0.429 125 3+1=4 4 / 7=0.571 222 4+3=7 7 / 7=1.0 255 1 According to the statistical results, there are a total of 7 small squares between 5 and 250.
[0018] S6. Obtain the mapped gray value P' through the following formula: , P(i) represents the cumulative distribution probability of the original gray level i, P hight Indicates grayscale value 250, P low Indicates grayscale value 5; Through the above mapping formula, each gray value i in the original image is remapped to a new gray value P' to generate a balanced image, thereby enhancing the overall contrast and detail performance of the image, as shown in the following table: Original grayscale value (serial number) Cumulative distribution probability New grayscale value (rounded) 0 66 1 / 7=0.143 245*0.143+5=40.035=40 99 3 / 7=0.429 245*0.429+5=110.105=110 125 4 / 7=0.571 245*.571+5=144.894=145 222 7 / 7=1.0 245*1+5=250 255 After the above grayscale mapping, a new grayscale image is finally obtained after histogram equalization, such as Figure 3 shown.
[0019] In addition, the above is only a processing description for a 3*3 grayscale image. When implementing other definitions, the following corresponding descriptions are given: Assume that the grayscale of the original image is 0 to L-1, and the number of pixels of each grayscale value is n i , i = 0, 1,..., L-1, L is the total number of gray levels, usually 256.
[0020] Then the histogram of the original image can be expressed as: P (i) =n i , Apply the above formula, by scanning the entire image, for each pixel, its gray value is used as the index, and the corresponding n is increased. i Finally, we get the distribution of the number of pixels at all gray levels, such as Figure 4 shown.
[0021] Figure 4 In the figure, the horizontal axis represents the grayscale change, and the vertical axis represents the total number of pixels for that specific grayscale; the left side of the horizontal axis represents the dark area, the middle represents the middle grayscale value, and the right side represents the bright area. The vertical axis represents the size of the area captured in each area (total number of pixels).
[0022] Therefore, a histogram for a very dark image will have most of its data points located on the left and center of the graph.
[0023] Conversely, for a very bright image with few dark areas and / or shadows, the majority of its histogram data points will be located to the right and center of the graph.
[0024] For histogram equalization: The system then counts the number of pixels at each gray level in the image to form an initial histogram.
[0025] Calculate the cumulative histogram: accumulate the number of pixels in the initial histogram to obtain the cumulative histogram. Here, interval accumulation is used, the grayscale range is [5,250], and the accumulation formula is: .
[0026] Finally, grayscale value mapping is performed: according to the cumulative histogram, the grayscale value of each pixel is mapped to a new grayscale value to generate a balanced image.
[0027] , Where m = 5, n = 250, ∈ 0...255 interval, and m <n。
[0028] P' represents the gray value after mapping, i represents the original gray value, Si represents the cumulative number of pixels, and Sm represents the value equal to m in the cumulative histogram, that is, the total pixels belonging to the interval [m,n].
[0029] Through the above steps, each gray value i in the original image is remapped to a new gray value P', generating an interval-equalized image, such as Figure 5 and Figure 6 As shown in the figure, after interval histogram equalization, the image contrast and details are significantly improved.
[0030] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for improving the contrast of an engraved image in a laser engraving system, Features: The following steps are involved: S1. The user uploads the image file to be engraved through the system interface, and the system receives and verifies the image format for identification; S2, after identifying the image file, grayscale it using the ITU-R BT.2100 standard, access each pixel in the image, and transform it to obtain a grayscale image with grayscale values in pixels; S3, excluding the grayscale values obtained according to the grayscale conversion formula, taking 0.02-0.98 as the grayscale value range, excluding extreme values outside 0.02-0.98, and then performing image histogram equalization processing; S4, determine the statistical interval, and perform statistics on the probability of occurrence of each gray value, and form a histogram based on the statistical structure, and obtain the corresponding cumulative occurrence times between different gray values; S5. Obtain the cumulative distribution probability by calculation: , where P(i) represents the cumulative distribution probability of grayscale greater than i, CDF(i) represents the cumulative grayscale greater than i, and N represents the total statistical samples, that is, the total number of pixels in the image that belong to the interval [5,250]; S6. Obtain the mapped gray value P' through the following formula: , P(i) represents the cumulative distribution probability of the original gray level i, P hight Indicates grayscale value 250, P low Indicates grayscale value 5; Through the above mapping formula, each gray value i in the original image is remapped to a new gray value P' to generate a balanced image, thereby enhancing the overall contrast and detail performance of the image.
2. A method for improving the contrast of an engraved image in a laser engraving system as claimed in claim 1, Features: In step S2, after grayscale conversion using the ITU-R BT.2100 standard, the grayscale conversion formula is: Gray=R*0.333+G*0.333+B*0.
333. R, G, and B in the formula are the parameters corresponding to red, green, and blue in each pixel respectively. Relying on this formula, each pixel in the image is accessed and transformed to obtain a grayscale image with pixels as units and grayscale values.
3. A method for improving the contrast of an engraved image in a laser engraving system as claimed in claim 2, Features: In step S4, the following formula is used: Low=(L-1)*0.02 Hight=(L-1)*0.98 Among them, L=256 grayscales, and after rounding to the nearest integer, the required statistical interval is: [5,250]; The probability of occurrence of each gray value is counted by the cumulative distribution function, and a histogram is formed by the statistical structure to obtain the corresponding cumulative occurrence times between different gray values; The cumulative distribution function is calculated as: , Among them, P(j) represents the frequency of gray value j, and j represents the gray value for frequency statistics.
