3D printing processing method, computer equipment and readable storage medium
Through edge detection and grayscale threshold determination methods, the color information of 3D embossed photo printing is automatically set, which solves the problem of manual settings introducing errors and improves printing efficiency and accuracy.
Patent Information
- Application Number
- CN202411745521.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-05-06
AI Technical Summary
During the 3D embossed photo printing process, manually setting the color values of different layers can easily introduce errors, affecting the accuracy of the finished product.
By performing edge detection on the target image, the grayscale distribution information of the target pixel is determined, and the target grayscale threshold is determined based on this, and the printing color information of each pixel is automatically determined.
Improve the efficiency and accuracy of the printing process of relief images and improve the printing effect of relief images.
Smart Images

Figure CN119941876A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of 3D printing, and in particular to a 3D printing processing method, a computer device and a readable storage medium. Background Art
[0002] 3D relief printing is an advanced printing technology that can create a sculpture effect with a sense of concave and convex, so that the printed pattern or text is not only three-dimensional visually, but also smooth to the touch and delicate in color.
[0003] When printing relief photos, professional software is used to convert the original photo into a grayscale image, that is, a black and white photo. This step ensures that each pixel in the photo has only one brightness value, which is convenient for subsequent conversion into the height information of the relief. Furthermore, the height of the relief is allocated according to the brightness value of the grayscale image, that is, the brightness value of the grayscale image is layered. Usually, the brighter area will be converted into the raised part of the relief, and the darker area will be converted into the sunken part of the relief. Then the software will generate a three-dimensional model. Finally, a 3D printer is used to print the relief photo layer by layer according to the generated three-dimensional model.
[0004] In the related art, different color values of different layers are set by users based on experience, and manual setting may introduce errors, affecting the accuracy of the final printed product. Summary of the invention
[0005] In view of this, the present application provides a 3D printing processing method, a computer device and a readable storage medium, which improve the efficiency and accuracy of black and white relief photo printing processing.
[0006] In a first aspect, an embodiment of the present application provides a 3D printing processing method, comprising:
[0007] Acquire a target image to be printed;
[0008] Performing edge detection processing on the target image to determine target pixels corresponding to edge contours in the target image;
[0009] Determining a target grayscale threshold according to the grayscale distribution information of the target pixel;
[0010] For each pixel in the target image, the printing color information of the pixel is determined based on the target grayscale threshold and the grayscale value of the pixel.
[0011] In a second aspect, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be executed on the processor, and when the programs or instructions are executed by the processor, the steps of the method of the first aspect are implemented.
[0012] In a third aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.
[0013] In the embodiment of the present application, a target image to be printed is obtained, and edge detection processing is performed on the target image to obtain target pixels corresponding to the edge contour in the target image. According to the grayscale distribution information of the target pixels corresponding to the edge contour, a target grayscale threshold is determined, and the target grayscale threshold can reflect the main brightness characteristics of the target image and is used to determine the printing color of the printing layer corresponding to each pixel of the target image. Furthermore, based on the grayscale value of each pixel in the target image, the printing color information of each pixel is determined to automatically determine the printing color of the pixel.
[0014] In the embodiment of the present application, a target grayscale threshold is determined by grayscale distribution information of target pixels corresponding to edge contours in a target image, and the printing color of each pixel is automatically determined based on the target grayscale threshold, thereby improving the efficiency and accuracy of relief image printing processing and improving the printing effect of the relief image.
[0015] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 A schematic diagram showing a flow chart of a 3D printing processing method according to an embodiment of the present application is shown;
[0018] Figure 2 A schematic diagram showing statistical processing of data distribution in an embodiment of the present application is shown;
[0019] Figure 3 A schematic diagram showing the image processing process of an embodiment of the present application;
[0020] Figure 4 A structural block diagram of a computer device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0022] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0023] The following is a detailed description of the 3D printing processing method, computer device and readable storage medium provided in the embodiments of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0024] The present application embodiment provides a 3D printing processing method, such as Figure 1 As shown, the method includes:
[0025] S101, obtaining a target image to be printed.
[0026] In some implementation schemes of the present application, the target image to be printed can be obtained by reading it locally or through a network.
[0027] In some embodiments of the present application, a target image to be printed is obtained, and the target image can be a color picture. In a color picture, each pixel is usually composed of values of three color channels: red (R), green (G), and blue (B). These three values together determine the color of the pixel.
[0028] In some other embodiments of the present application, a target image to be printed is obtained. The target image may be a grayscale image obtained by performing grayscale processing on a color image.
[0029] S102, performing edge detection processing on the target image to determine target pixels corresponding to edge contours in the target image.
[0030] In this step, edge detection is performed on the target image to determine the edge contour in the target image. The edge contour is the boundary of different objects in the target image. The object can be things, people, animals, etc. in the image, including the sky, rivers, people, vases, bouquets, cats, cars, etc. The edge is generally the position where the gray value in the image changes sharply. Through edge detection, the edge information in the target image can be displayed, making the main contours and structures in the target image clearer. Further, the pixel corresponding to the edge contour is determined as the target pixel.
[0031] In one embodiment of the present application, edge detection processing is performed on a target image to determine target pixels corresponding to edge contours in the target image, including:
[0032] Perform grayscale processing on the target image to obtain a target grayscale image;
[0033] Calculate the gradient amplitude of the pixel of the target grayscale image, where the gradient amplitude represents the degree of change of the grayscale value of the pixel;
[0034] The target pixel is determined based on the pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold.
[0035] In this embodiment, the target image is gray-scaled to obtain a target gray-scale image. That is, each pixel in the color target image is converted from a state containing color information to a state containing only brightness information to obtain a target gray-scale image. In the target gray-scale image, each pixel has only one brightness value (i.e., gray-scale value), and this brightness value is calculated based on the values of the corresponding pixel in the color target image in the three color channels of red, green, and blue. For example, the average value of the pixel in the color target image in the three color channels of red, green, and blue, or the weighted average value of the three color channel values, etc., is calculated to obtain the brightness value of the pixel. Based on the calculated brightness value of each pixel, a new image is generated, and this image is the target gray-scale image.
[0036] After obtaining the target grayscale image, edge detection processing is performed on the target grayscale image to determine the target pixel.
[0037] It is understandable that, in some other embodiments, the target image may also be a grayscale image, and the target pixel is determined by directly acquiring the target image and performing edge detection processing on the target image.
[0038] In one embodiment, the grayscale image is subjected to edge detection processing by the Sobel edge detection algorithm, and the Sobel operator includes two groups of 3×3 convolution kernels, i.e., filters, which are used to detect edges in the horizontal direction and the vertical direction, respectively. These two convolution kernels are convolved with each 3×3 pixel region in the target grayscale image to calculate the horizontal gradient (Gx) and vertical gradient (Gy) of the region, and the magnitude of the gradient reflects the degree of change of the grayscale value of the region. After obtaining the horizontal gradient and the vertical gradient, the square root of the sum of the squares of the two gradients, i.e., the Euclidean distance, is calculated to obtain the gradient amplitude, or the absolute values of the horizontal gradient and the vertical gradient are summed to obtain the gradient amplitude, which represents the degree of change of the grayscale value of the pixel.
[0039] The calculated gradient magnitude is compared with a preset threshold value. If the gradient magnitude of a pixel is less than the preset threshold value, it is determined that the pixel does not belong to an edge contour. If the gradient magnitude of a pixel is greater than or equal to the preset threshold value, it is determined that the pixel belongs to an edge contour. Thus, the target pixel corresponding to the edge contour in the target image is obtained.
[0040] Through the above processing method, edge information can be effectively extracted from the target grayscale image.
[0041] In one embodiment of the present application, determining a target pixel according to pixels in a target grayscale image whose gradient magnitude is greater than or equal to a preset threshold value includes:
[0042] Extract pixels whose gradient magnitude is greater than or equal to a preset threshold value in the target grayscale image;
[0043] Image enhancement processing is performed on pixels whose gradient amplitude is greater than or equal to a preset threshold to obtain target pixels after image enhancement processing.
[0044] In this embodiment, image enhancement processing is performed on pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold, thereby enhancing edge information in the target grayscale image and making the edge contour more prominent or smoother.
[0045] In one embodiment, the pixel enhancement processing may be a power operation on the pixel, which is a nonlinear transformation, that is, a power operation. The distribution of pixel values is changed by performing a power operation on the pixel values, thereby affecting the visual effect of the image.
[0046] In one embodiment, the power operation of pixels in the target grayscale image can be implemented by the following formula:
[0047] s=c×r a
[0048] Among them, s is the output pixel value, r is the input pixel value, c is the coefficient, c is usually 1 to preserve the original range of pixel values, and a is the power index, which determines the effect of the power transformation. a can be greater than 1 or between 0 and 1. When the power index is greater than 1, the bright area, that is, the pixels with higher pixel values, will become brighter, and the dark area, that is, the pixels with lower pixel values, will become darker. This change helps to enhance the contrast of the target image and make the edges more prominent. When the power index is between 0 and 1, the difference between the bright area and the dark area will decrease, which can make the edge smoother and reduce the sharpness of the edge.
[0049] In the embodiment of the present application, by performing a power operation on the pixels in the edge area obtained after edge detection, the edge details in the image can be magnified, the edge contrast can be enhanced, and the noise pixels can be reduced, thereby ensuring the accuracy of the subsequent printing color determined based on the pixels in the edge area.
[0050] It can be understood that, in some other embodiments, determining the target pixel based on the pixels in the target grayscale image whose gradient amplitude is greater than or equal to the preset threshold may also include: extracting the pixels in the target grayscale image whose gradient amplitude is greater than or equal to the preset threshold; taking the pixels with gradient amplitude greater than or equal to the preset threshold as the target pixels, that is, not performing enhancement processing on the pixels in the target grayscale image whose gradient amplitude is greater than or equal to the preset threshold, which is not limited to the specific application.
[0051] S103, determining a target grayscale threshold according to the grayscale distribution information of the target pixel.
[0052] In this step, a target grayscale threshold is determined according to the grayscale distribution information of the target pixel, and the target grayscale threshold can be used to determine the printing color information of the pixel.
[0053] In one embodiment of the present application, determining a target grayscale threshold according to grayscale distribution information of a target pixel includes:
[0054] Perform data distribution statistics on the grayscale values of all target pixels to determine the grayscale distribution information corresponding to the target pixels;
[0055] According to the grayscale distribution information, the grayscale information of the pixel concentration area corresponding to the target pixel is determined, and the target grayscale threshold is determined according to the grayscale information.
[0056] In this embodiment, data distribution statistics are processed on the grayscale values of all target pixels to obtain grayscale distribution information corresponding to the target pixels, and then the pixel concentration area in the target pixels is determined based on the grayscale distribution information. The pixel concentration area may refer to an area with more pixels in the distribution of grayscale values, and then the target grayscale threshold is determined based on the grayscale information of the pixel concentration area.
[0057] By analyzing the gray value distribution of the target pixel, the target gray threshold is automatically determined, and then the pixel is automatically divided into colors based on the target gray threshold to achieve automatic determination of the printing color.
[0058] By analyzing the grayscale value distribution of the target pixels, and determining the edge contours corresponding to each object in the target image based on the distribution, and automatically determining the target grayscale threshold based on the grayscale value of the target pixel corresponding to the edge contour, and then automatically dividing the pixels into colors based on the target grayscale threshold, the printed 3D image can match the edge grayscale information of different objects in the image to determine the appropriate target grayscale threshold, and automatically recommend printing colors based on the target grayscale threshold to ensure the clarity of the image printing contour. At the same time, the printing color recommendation is specifically adapted to the actual grayscale distribution of each target image, thereby improving the recommendation accuracy and the universality of photo printing, and improving image printing performance.
[0059] In one embodiment, data distribution statistics processing is performed on the grayscale values of all target pixels to determine the grayscale distribution information corresponding to the target pixels, including:
[0060] Performing histogram statistics on the grayscale values of all target pixels to obtain histogram statistical information, which includes the grayscale value and the number of pixels corresponding to each grayscale value;
[0061] The histogram statistical information is subjected to curve fitting to obtain a grayscale distribution curve, which is the grayscale distribution information corresponding to the target pixel.
[0062] In this embodiment, the grayscale values of all target pixels are histogrammed to obtain histogram statistical information, for example, the histogram statistical information is a grayscale value bar graph, wherein the first coordinate axis, i.e., the X-axis, represents the grayscale value, and the second coordinate axis, i.e., the Y-axis, represents the number of pixels corresponding to the grayscale value. Further, the histogram statistical information is curve-fitted to obtain a grayscale distribution curve, for example, the histogram statistical information is fitted with a preset polynomial function to obtain a grayscale distribution curve, the grayscale distribution curve is the grayscale distribution information corresponding to the target pixel, and the preset polynomial function may include a cubic polynomial function, a quartic polynomial function, etc.
[0063] For example, Figure 2 As shown, the gray value histogram is subjected to a fourth-order polynomial function y=b0+b1×x+b2×x 2 +b3×x 3 +b4×x 4A grayscale distribution curve L is obtained by fitting, wherein the first coordinate axis of the grayscale distribution curve L, i.e., the X-axis, represents the grayscale value, and the second coordinate axis, i.e., the Y-axis, represents the number of pixels corresponding to the grayscale value. It should be noted that the preset polynomial function is preferably a quartic polynomial function, which can ensure the accuracy of fitting, especially when there are many data points and the distribution is complex, and at the same time will not increase too much calculation amount, thereby ensuring the processing speed.
[0064] In another embodiment, data distribution statistics processing is performed on the grayscale values of all target pixels to determine the grayscale distribution information corresponding to the target pixels, including: performing histogram statistics on the grayscale values of all target pixels to obtain histogram statistics information, and determining the grayscale distribution information corresponding to the target pixels based on the histogram statistics information. That is, histogram statistics are performed on the grayscale values of all target pixels to obtain histogram statistics information, and the histogram statistics information is used as the grayscale distribution information corresponding to the target pixels, thereby improving data processing efficiency.
[0065] In yet another embodiment, data distribution statistics processing is performed on the grayscale values of all target pixels to determine the grayscale distribution information corresponding to the target pixels, including: curve fitting is performed on the grayscale values of all target pixels to obtain a grayscale distribution curve, and the grayscale distribution information corresponding to the target pixels is determined according to the grayscale distribution curve. That is, the grayscale values of all target pixels are directly curve fitted to obtain a grayscale distribution curve, and the grayscale distribution curve is used as the grayscale distribution information corresponding to the target pixels, thereby improving data processing efficiency.
[0066] In another embodiment, data distribution statistics processing is performed on the grayscale values of all target pixels to determine the grayscale distribution information corresponding to the target pixels, including: performing data distribution statistics processing based on a constructed machine learning model, and after inputting the grayscale values of all target pixels, outputting the grayscale distribution information corresponding to the target pixels.
[0067] In the embodiment of the present application, the grayscale value of the target pixel and the number of pixels corresponding to each grayscale value can be obtained through grayscale distribution information, which reflects the grayscale distribution of the target pixel corresponding to the edge contour in the target image.
[0068] In one embodiment of the present application, determining the grayscale information of the pixel concentration area corresponding to the target pixel according to the grayscale distribution information, and determining the target grayscale threshold according to the grayscale information includes:
[0069] Determine the pixel concentration area of the target pixel according to the grayscale distribution information;
[0070] The maximum grayscale value corresponding to each pixel concentration area is set as the target grayscale threshold.
[0071] In this embodiment, at least one pixel concentration area of the target pixel is determined according to the grayscale distribution information, the maximum grayscale value of each pixel concentration area is determined, and the maximum grayscale value is set as the target grayscale threshold. For example, if the grayscale distribution information is a grayscale distribution curve, the pixel concentration area is the area corresponding to the peak of the grayscale distribution curve, and the maximum grayscale value of the area corresponding to the peak in the grayscale distribution curve is set as the target grayscale threshold, wherein the grayscale distribution curve includes at least one peak, and each peak corresponds to a pixel concentration area.
[0072] For example, Figure 2 As shown, the pixel concentration areas are areas a1 and a2 corresponding to the peaks of the grayscale distribution curve, and the maximum grayscale value x1 corresponding to area a1 and the maximum grayscale value x2 corresponding to area a2 are set as target grayscale thresholds.
[0073] In the embodiment of the present application, the pixel concentration area of the target pixel is determined according to the grayscale distribution information, and the maximum grayscale value corresponding to each pixel concentration area is used as the target grayscale threshold, so that the target grayscale threshold is the grayscale value of the target image with a large number of pixels, representing a more significant or more common grayscale level in the target image, and the target grayscale threshold can reflect the main brightness characteristics of the target image. The division of printing colors based on the target grayscale threshold can ensure the accuracy of color division.
[0074] S104: for each pixel in the target image, determine the printing color information of the pixel based on the target grayscale threshold and the grayscale value of the pixel.
[0075] In this step, based on the target grayscale threshold and the grayscale value of each pixel in the target image, the printing color information of each pixel is determined to automatically determine the printing color of the pixel.
[0076] In one embodiment of the present application, determining the printing color information of a pixel based on a target grayscale threshold and a grayscale value of the pixel includes:
[0077] Based on the gray value of the pixel, determining the printing layer corresponding to the pixel, the printing layer comprising at least one;
[0078] Based on the target grayscale threshold and the grayscale value corresponding to each printing layer, the printing color information of each printing layer corresponding to the pixel is determined.
[0079] In this embodiment, for each pixel, the printing layer corresponding to the pixel is determined based on the grayscale value of the pixel, and the printing color of each printing layer corresponding to the pixel is determined based on the target grayscale threshold and the grayscale value corresponding to each printing layer. Printing parameters including the printing layer and the printing color of each printing layer are obtained in the above manner. Subsequently, the 3D printer can print based on these printing parameters to form protrusions and depressions of different heights and colors, thereby presenting a relief effect and obtaining a relief photo.
[0080] In one embodiment of the present application, determining the printing layer corresponding to a pixel based on the grayscale value of the pixel includes:
[0081] According to the gray value of the pixel and the preset model layer number of the target image, calculate the initial value of the layer number corresponding to the pixel;
[0082] If the initial value of the number of layers is an integer, the initial value of the number of layers is used as the number of printing layers corresponding to the pixel; and / or, if the initial value of the number of layers is not an integer, the initial value of the number of layers is rounded up or down to determine the number of printing layers corresponding to the pixel.
[0083] The formula for calculating the initial value of the number of layers is: M'=[(N-(P-1)) / (Q-(P-1))]×M, where M' is the initial value of the number of layers, N is the grayscale value of the pixel, M is the preset model number of layers, P is the lower limit of the pixel grayscale value of the target image, and Q is the upper limit of the pixel grayscale value of the target image.
[0084] In this embodiment, the initial value of the number of layers M' is calculated according to the gray value of the pixel and the number of preset model layers of the target image, according to the calculation formula of the initial value of the number of layers: M'=[(N-(P-1)) / (Q-(P-1))]×M. If the initial value of the number of layers obtained is an integer, the initial value of the number of layers is used as the number of layers of the printing layer corresponding to the pixel; if the initial value of the number of layers is not an integer, the initial value of the number of layers is rounded up or down to obtain an integer, and the integer is used as the number of layers of the printing layer corresponding to the pixel.
[0085] The embodiment of the present application can automatically calculate the number of printing layers corresponding to a pixel, thereby improving the accuracy of setting the number of printing layers.
[0086] In one embodiment of the present application, the target grayscale threshold is at least one; based on the target grayscale threshold and the grayscale value corresponding to each printing layer, determining the printing color information of each printing layer corresponding to the pixel includes:
[0087] Determine at least two grayscale value intervals and interval colors corresponding to each grayscale value interval according to at least one target grayscale threshold;
[0088] The printing color information of the pixel is determined according to the inclusion relationship between the grayscale value corresponding to each printing layer in the pixel and the grayscale value interval.
[0089] In this embodiment, at least two grayscale value intervals are divided by at least one target grayscale threshold, and the interval color corresponding to each grayscale value interval is set, that is, one grayscale value interval corresponds to one interval color. It is determined in which grayscale value interval the grayscale value corresponding to each printing layer of the pixel is included, and the printing color information of each printing layer of the pixel is determined according to the interval color corresponding to the grayscale value interval.
[0090] The embodiment of the present application can divide the grayscale value interval according to the determined target grayscale threshold, and automatically determine the printing color of the pixel printing layer according to the interval color of the grayscale value interval into which the grayscale value falls. Compared with the solution of manually setting the printing color of the printing layer in the related art, the solution of the present application is more accurate and more efficient.
[0091] In one embodiment of the present application, at least two grayscale value intervals and interval colors corresponding to each grayscale value interval are determined according to at least one target grayscale threshold, including:
[0092] Determining at least two grayscale value intervals according to at least one target grayscale threshold;
[0093] According to the grayscale value interval and the preset grayscale information corresponding to the preset color, the interval color corresponding to the grayscale value interval is determined, and the interval color is any one of the preset colors.
[0094] In this embodiment, at least two grayscale value intervals are divided by at least one target grayscale threshold, and a preset color is assigned to each grayscale value interval according to the preset grayscale information corresponding to the preset color as the interval color. The preset color can be a set fixed color, such as white, gray, black, etc., and can be assigned to the grayscale value interval as the interval color according to the preset grayscale information of the preset color. For example, according to the preset grayscale information of white, it is assigned to the first grayscale value interval as the interval color, and according to the preset grayscale information of black, it is assigned to the second grayscale value interval as the interval color. The preset color can also be multiple or all colors in the color space. The color space can be understood as a color bar or a color ring, etc. The color space includes multiple colors from the beginning to the end, and these colors form a transition and gradient effect. According to the preset grayscale information of color space A, all colors in color space A can be assigned to the first grayscale value interval as the interval color, and according to the preset grayscale information of color space B, all colors in color space B can be assigned to the second grayscale value interval as the interval color. By allocating the color space to the gray value interval as the interval color, the interval color corresponding to the gray value interval is a transitional and gradual color, thereby improving the richness of the printed color.
[0095] In one embodiment of the present application, determining the interval color corresponding to the gray value interval according to the gray value interval and the preset gray information corresponding to the preset color includes:
[0096] For any grayscale value interval, each preset grayscale information is compared with the grayscale value interval to determine the target preset grayscale information that falls within the grayscale value interval;
[0097] The preset color corresponding to the target preset grayscale information is used as the interval color corresponding to the grayscale value interval.
[0098] In this embodiment, for any gray value interval, the preset gray information corresponding to each preset color is compared with the gray value interval to determine the target preset gray information falling into the gray value interval, and the preset color corresponding to the target preset gray information is used as the interval color corresponding to the gray value interval. For example, the preset colors include white, gray, and black, and the gray value interval includes a first gray value interval and a second gray value interval. For the first gray value interval, the preset gray information of white, the preset gray information of gray, and the preset gray information of black are respectively compared with the first gray value interval. If the preset gray information of white is within the first gray value interval, white is used as the interval color of the first gray value interval; for the second gray value interval, the preset gray information of white, the preset gray information of gray, and the preset gray information of black are respectively compared with the second gray value interval. If the preset gray information of black is within the second gray value interval, black is used as the interval color of the second gray value interval.
[0099] In addition to using the preset color corresponding to the target preset grayscale information falling within the grayscale value interval as the interval color corresponding to the grayscale value interval, in one embodiment, the preset grayscale information can also be assigned to different grayscale value intervals according to the size relationship of each preset grayscale information. For example, the preset colors include b1, b2, and b3, and the grayscale values of b1, b2, and b3 increase in sequence. The grayscale value interval includes a first grayscale value interval, a second grayscale value interval, and a third grayscale value interval, and the grayscale values corresponding to the first grayscale value interval, the second grayscale value interval, and the third grayscale value interval increase in sequence. If the grayscale value of the preset color is compared with the grayscale value interval, the grayscale values of b1 and b2 fall within the first grayscale value interval, and the grayscale value of b3 falls within the second grayscale value interval. However, b1, b2, and b3 can be assigned to grayscale value intervals from small to large in order of grayscale values as interval colors, that is, color b1 is used as the interval color of the first grayscale value interval, color b2 is used as the interval color of the second grayscale value interval, and color b3 is used as the interval color of the third grayscale value interval.
[0100] When determining the printing color information of a pixel based on the inclusion relationship between the grayscale value and the grayscale value interval corresponding to each printing layer in the pixel, if the pixel corresponds to 2 printing layers, and the 2 printing layers are determined to fall within the same grayscale value interval based on the grayscale value, then the 2 printing layers of this pixel are printed with the interval color corresponding to the grayscale value interval, and the 2 printing layers are the same color. If the pixel corresponds to 4 printing layers, and the first 2 printing layers of the 4 printing layers are determined to fall within the first grayscale value interval based on the grayscale value, then the first 2 printing layers of this pixel are printed with the interval color corresponding to the first grayscale value interval, and the first 2 printing layers are the same color. If the last 2 printing layers of the 4 printing layers are determined to fall within the second grayscale value interval based on the grayscale value, then the last 2 printing layers of this pixel are printed with the interval color corresponding to the second grayscale value interval, and the last 2 printing layers are the same color.
[0101] The embodiment of the present application can automatically assign interval colors to each grayscale value interval, thereby automatically determining the printing color of the pixel according to the interval color corresponding to the grayscale value interval corresponding to the grayscale value of each printed layer of the pixel, thereby improving the accuracy and efficiency of printing color determination.
[0102] In one embodiment of the present application, Figure 3 As shown, the target image G0 to be printed is obtained, and the target image G0 is gray-processed to obtain the target gray-scale image G1. The gradient amplitude of the pixels of the target gray-scale image G1 is calculated, and the pixels whose gradient amplitude is greater than or equal to the preset threshold are extracted as the target pixels S, and the target pixels S are image-enhanced to obtain the target pixels S' after image enhancement.
[0103] Further, according to the grayscale distribution information of the target pixel S', the target grayscale threshold is determined, for example, the determined target grayscale thresholds are: 140 and 180. If the pixel grayscale value of the target image G0 is between 100-199, that is, the lower limit of the pixel grayscale value is 100, and the upper limit of the pixel grayscale value is 199, then based on the two target grayscale thresholds, three grayscale value intervals will be divided: 100-139, 140-179 and 180-199. The preset colors include white, gray and black. According to the preset grayscale information corresponding to the preset colors, the interval color corresponding to the interval 100-139 is black, the interval color corresponding to the interval 140-179 is gray, and the interval color corresponding to the interval 180-199 is white.
[0104] The preset model layer number corresponding to the target image is 10 layers. According to the gray value of each pixel, the number of layers corresponding to the pixel is calculated. For example, for a pixel with a gray value of 105, the number of layers to be printed for the pixel is [(105-99) / (199-99)]×10=0.6. Then, according to the rounding up method, 1 can be used as the layer thickness corresponding to the pixel. In addition, the interval corresponding to the gray value of 105 is the interval 100-139, and the printing color is black, so the pixel prints 1 layer of black model.
[0105] In the embodiment of the present application, a target grayscale threshold is determined by grayscale distribution information of target pixels corresponding to edge contours in a target image, and the printing color of each pixel is automatically determined based on the target grayscale threshold, thereby improving the efficiency and accuracy of relief image printing processing and improving the printing effect of the relief image.
[0106] The embodiment of the present application further provides a computer device, wherein the computer device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, or an extended reality device with a computing processing unit, wherein the extended reality device includes but is not limited to a 3D printer, and the extended reality device can be an integrated extended reality device built into the computing processing unit, or a split extended reality device externally connected to the computing processing unit. When the extended reality device is a 3D printer, it can be an integrated extended reality device built into the computing processing unit, or a split extended reality device externally connected to the computing processing unit.
[0107] like Figure 4 As shown, the computer device 400 includes a processor 401 and a memory 402. The memory 402 stores programs or instructions that can be run on the processor 401. When the program or instruction is executed by the processor 401, the various steps of the above-mentioned 3D printing processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The processor 401 can be understood as the above-mentioned computing processing unit, and the memory 402 is not limited to being internally or externally connected to the computer device 400.
[0108] The memory 402 can be used to store software programs and various data. The memory 402 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 402 may include a volatile memory or a non-volatile memory, or the memory 402 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 402 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0109] The processor 401 may include one or more processing units; optionally, the processor 401 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 401.
[0110] The embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned 3D printing processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0111] The present application also provides the following embodiments:
[0112] Embodiment 1, a 3D printing processing method, comprising:
[0113] Acquire a target image to be printed;
[0114] Performing edge detection processing on the target image to determine target pixels corresponding to edge contours in the target image;
[0115] Determining a target grayscale threshold according to the grayscale distribution information of the target pixel;
[0116] For each pixel in the target image, the printing color information of the pixel is determined based on the target grayscale threshold and the grayscale value of the pixel.
[0117] Embodiment 2, based on embodiment 1, determining the target grayscale threshold according to the grayscale distribution information of the target pixel includes:
[0118] Performing data distribution statistics processing on the grayscale values of all the target pixels to determine the grayscale distribution information corresponding to the target pixels;
[0119] The grayscale information of the pixel concentration area corresponding to the target pixel is determined according to the grayscale distribution information, and the target grayscale threshold is determined according to the grayscale information.
[0120] Embodiment 3, based on embodiment 2, performing data distribution statistics processing on the grayscale values of all the target pixels to determine the grayscale distribution information corresponding to the target pixels includes:
[0121] Performing histogram statistics on the grayscale values of all the target pixels to obtain histogram statistical information, wherein the histogram statistical information includes the grayscale value and the number of pixels corresponding to each grayscale value;
[0122] A curve fitting is performed on the histogram statistical information to obtain a grayscale distribution curve, where the grayscale distribution curve is the grayscale distribution information corresponding to the target pixel.
[0123] Embodiment 4, based on embodiment 2, determining the grayscale information of the pixel concentration area corresponding to the target pixel according to the grayscale distribution information, and determining the target grayscale threshold according to the grayscale information, includes:
[0124] Determining a pixel concentration area of the target pixel according to the grayscale distribution information;
[0125] The maximum grayscale value corresponding to each pixel concentration area is set as the target grayscale threshold.
[0126] Embodiment 5, based on embodiment 1, determining the printing color information of the pixel based on the target grayscale threshold and the grayscale value of the pixel includes:
[0127] Based on the grayscale value of the pixel, determining a printing layer corresponding to the pixel, the printing layer comprising at least one;
[0128] Based on the target grayscale threshold and the grayscale value corresponding to each of the printing layers, the printing color information of each of the printing layers corresponding to the pixel is determined.
[0129] Embodiment 6, based on embodiment 5, determining the printing layer corresponding to the pixel based on the grayscale value of the pixel includes:
[0130] Calculate the initial value of the number of layers corresponding to the pixel according to the gray value of the pixel and the preset number of model layers of the target image;
[0131] If the initial value of the number of layers is an integer, the initial value of the number of layers is used as the number of the printing layer corresponding to the pixel;
[0132] If the initial value of the number of layers is not an integer, the initial value of the number of layers is rounded up or down to determine the number of printing layers corresponding to the pixel.
[0133] Embodiment 7, based on Embodiment 5, the target grayscale threshold is at least one; and determining the printing color information of each printing layer corresponding to the pixel based on the target grayscale threshold and the grayscale value corresponding to each printing layer comprises:
[0134] Determine at least two grayscale value intervals and interval colors corresponding to each of the grayscale value intervals according to at least one of the target grayscale thresholds;
[0135] The printing color information of the pixel is determined according to the inclusion relationship between the grayscale value corresponding to each of the printing layers in the pixel and the grayscale value interval.
[0136] Example 8, based on Example 6,
[0137] The formula for calculating the initial value of the number of layers is: M'=[(N-(P-1)) / (Q-(P-1))]×M, wherein M' is the initial value of the number of layers, N is the grayscale value of the pixel, M is the number of layers of the preset model, P is the lower limit value of the pixel grayscale value of the target image, and Q is the upper limit value of the pixel grayscale value of the target image.
[0138] Embodiment 9, based on Embodiment 7, determining at least two gray value intervals and interval colors corresponding to each gray value interval according to at least one of the target gray value thresholds includes:
[0139] Determining at least two grayscale value intervals according to at least one of the target grayscale thresholds;
[0140] According to the grayscale value interval and the preset grayscale information corresponding to the preset color, the interval color corresponding to the grayscale value interval is determined, and the interval color is any one of the preset colors.
[0141] Embodiment 10, based on embodiment 9, determining the interval color corresponding to the gray value interval according to the gray value interval and the preset gray information corresponding to the preset color, includes:
[0142] For any of the grayscale value intervals, each of the preset grayscale information is compared with the grayscale value interval to determine the target preset grayscale information that falls within the grayscale value interval;
[0143] The preset color corresponding to the target preset grayscale information is used as the interval color corresponding to the grayscale value interval.
[0144] Embodiment 11, based on any one of embodiments 1 to 10, performing edge detection processing on the target image to determine the target pixel corresponding to the edge contour in the target image includes:
[0145] Performing grayscale processing on the target image to obtain the target grayscale image;
[0146] Calculating the gradient magnitude of a pixel of the target grayscale image, wherein the gradient magnitude represents a degree of change of the grayscale value of the pixel;
[0147] The target pixel is determined according to the pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold.
[0148] Embodiment 12, based on embodiment 11, determining the target pixel according to the pixel whose gradient amplitude in the target grayscale image is greater than or equal to a preset threshold, comprises:
[0149] Extracting pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold;
[0150] Image enhancement processing is performed on pixels whose gradient amplitude is greater than or equal to a preset threshold to obtain target pixels after image enhancement processing.
[0151] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A 3D printing processing method, characterized in that: include: Acquire a target image to be printed; Performing edge detection processing on the target image to determine target pixels corresponding to edge contours in the target image; Determining a target grayscale threshold according to the grayscale distribution information of the target pixel; For each pixel in the target image, the printing color information of the pixel is determined based on the target grayscale threshold and the grayscale value of the pixel.
2. The 3D printing processing method according to claim 1, characterized in that: Determining a target grayscale threshold according to the grayscale distribution information of the target pixel includes: Performing data distribution statistics processing on the grayscale values of all the target pixels to determine the grayscale distribution information corresponding to the target pixels; The grayscale information of the pixel concentration area corresponding to the target pixel is determined according to the grayscale distribution information, and the target grayscale threshold is determined according to the grayscale information.
3. The 3D printing method according to claim 2, characterized in that: The performing of data distribution statistical processing on the grayscale values of all the target pixels to determine the grayscale distribution information corresponding to the target pixels comprises: performing histogram statistics on the grayscale values of all the target pixels to obtain histogram statistical information, wherein the histogram statistical information comprises the grayscale value and the number of pixels corresponding to each grayscale value; performing curve fitting on the histogram statistical information to obtain a grayscale distribution curve, wherein the grayscale distribution curve is the grayscale distribution information corresponding to the target pixels; and / or; The method of determining the grayscale information of the pixel concentration area corresponding to the target pixel according to the grayscale distribution information, and determining the target grayscale threshold according to the grayscale information, includes: determining the pixel concentration area of the target pixel according to the grayscale distribution information; and setting the maximum grayscale value corresponding to each of the pixel concentration areas as the target grayscale threshold.
4. The 3D printing method according to claim 1, characterized in that: The step of determining the printing color information of the pixel based on the target grayscale threshold and the grayscale value of the pixel comprises: Based on the grayscale value of the pixel, determining a printing layer corresponding to the pixel, the printing layer comprising at least one; Based on the target grayscale threshold and the grayscale value corresponding to each of the printing layers, the printing color information of each of the printing layers corresponding to the pixel is determined.
5. The 3D printing method according to claim 4, characterized in that: The determining the printing layer corresponding to the pixel based on the gray value of the pixel comprises: calculating an initial value of the number of layers corresponding to the pixel according to the gray value of the pixel and the number of preset model layers of the target image; if the initial value of the number of layers is an integer, using the initial value of the number of layers as the number of the printing layer corresponding to the pixel; if the initial value of the number of layers is not an integer, rounding up or rounding down the initial value of the number of layers to determine the number of the printing layer corresponding to the pixel; and / or; There is at least one target grayscale threshold; determining the printing color information of each printing layer corresponding to the pixel based on the target grayscale threshold and the grayscale value corresponding to each printing layer includes: determining at least two grayscale value intervals and the interval color corresponding to each grayscale value interval according to at least one target grayscale threshold; determining the printing color information of the pixel according to the inclusion relationship between the grayscale value corresponding to each printing layer in the pixel and the grayscale value interval.
6. The 3D printing method according to claim 5, characterized in that: The determining the printing layer corresponding to the pixel based on the gray value of the pixel comprises: calculating an initial value of the number of layers corresponding to the pixel according to the gray value of the pixel and the number of preset model layers of the target image; if the initial value of the number of layers is an integer, using the initial value of the number of layers as the number of the printing layer corresponding to the pixel; if the initial value of the number of layers is not an integer, rounding up or rounding down the initial value of the number of layers to determine the number of the printing layer corresponding to the pixel; The formula for calculating the initial value of the number of layers is: M'=[(N-(P-1)) / (Q-(P-1))]×M, wherein M' is the initial value of the number of layers, N is the grayscale value of the pixel, M is the number of layers of the preset model, P is the lower limit value of the pixel grayscale value of the target image, and Q is the upper limit value of the pixel grayscale value of the target image.
7. The 3D printing method according to claim 5, characterized in that: There is at least one target grayscale threshold; determining the printing color information of each printing layer corresponding to the pixel based on the target grayscale threshold and the grayscale value corresponding to each printing layer includes: determining at least two grayscale value intervals and interval colors corresponding to each grayscale value interval according to at least one target grayscale threshold; determining the printing color information of the pixel according to the inclusion relationship between the grayscale value corresponding to each printing layer in the pixel and the grayscale value interval, wherein: Determining at least two grayscale value intervals and interval colors corresponding to each grayscale value interval according to at least one of the target grayscale thresholds includes: determining at least two grayscale value intervals according to at least one of the target grayscale thresholds; determining interval colors corresponding to the grayscale value intervals according to the grayscale value intervals and preset grayscale information corresponding to preset colors, wherein the interval colors are any one of the preset colors; or; The method of determining at least two grayscale value intervals and interval colors corresponding to each grayscale value interval based on at least one of the target grayscale thresholds includes: determining at least two grayscale value intervals based on at least one of the target grayscale thresholds; determining the interval color corresponding to the grayscale value interval based on the grayscale value interval and preset grayscale information corresponding to the preset color, wherein the interval color is any one of the preset colors; the method of determining the interval color corresponding to the grayscale value interval based on the grayscale value interval and preset grayscale information corresponding to the preset color includes: for any of the grayscale value intervals, comparing each of the preset grayscale information with the grayscale value interval to determine the target preset grayscale information that falls within the grayscale value interval; and using the preset color corresponding to the target preset grayscale information as the interval color corresponding to the grayscale value interval.
8. The 3D printing method according to any one of claims 1 to 7, characterized in that: The step of performing edge detection on the target image to determine the target pixel corresponding to the edge contour in the target image includes: performing grayscale processing on the target image to obtain the target grayscale image; calculating the gradient amplitude of the pixel of the target grayscale image, wherein the gradient amplitude represents the degree of change of the grayscale value of the pixel; and determining the target pixel according to the pixel in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold value; or; The method of performing edge detection processing on the target image to determine the target pixels corresponding to the edge contour in the target image includes: performing grayscale processing on the target image to obtain the target grayscale image; calculating the gradient amplitude of the pixels of the target grayscale image, wherein the gradient amplitude represents the degree of change of the grayscale value of the pixel; determining the target pixels based on the pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold; determining the target pixels based on the pixels in the target grayscale image whose gradient amplitude is greater than or equal to a preset threshold includes: extracting the pixels in the target grayscale image whose gradient amplitude is greater than or equal to the preset threshold; performing image enhancement processing on the pixels whose gradient amplitude is greater than or equal to the preset threshold to obtain the target pixels after image enhancement processing.
9. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction running on the processor, and when the program or instruction is executed by the processor, the steps of the 3D printing processing method according to any one of claims 1 to 8 are implemented.
10. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the 3D printing processing method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Image processing method and device, electronic equipment and storage medium
CN121166046A