Image processing method, electronic device, and storage medium
By using the center of gravity of the target object as the center for image filling and cropping in the customized AI-generated relief technology, the problem of adaptability of irregular bases is solved, the adaptation of relief models and 2.5D effect are realized, and the visual performance of reliefs is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHASING DREAM TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2026-02-25
- Publication Date
- 2026-05-29
Smart Images

Figure CN122115537A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of 3D printing technology, and more specifically to an image processing method, an electronic device, and a computer-readable storage medium. Background Technology
[0002] In related technologies, customized AI-generated relief technology typically leverages the generative capabilities of large generative models to directly generate relief models that meet the requirements based on the input image.
[0003] However, when generating relief models, this solution has limited adaptability to the shape of the base, making it difficult to meet the customization needs of irregularly shaped bases and affecting the final presentation effect of the relief model. Summary of the Invention
[0004] This application provides an image processing method, apparatus, electronic device, and storage medium, which can solve at least one of the above-mentioned technical problems.
[0005] In a first aspect, embodiments of this application provide an image processing method, the method comprising: Using the center of gravity of the target object in the image to be printed as the center, the edges of the image to be printed are filled to generate a filled image. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. Using the center of gravity of the target object as the center, the filled image is cropped to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio. Extract the depth information of each pixel in the cropped image, and determine the printing height information of each pixel based on the depth information of each pixel.
[0006] Secondly, embodiments of this application provide an image processing apparatus, the apparatus comprising: The filling module is used to fill the edges of the image to be printed with the center of gravity of the target object as the center to generate a filled image. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. The cropping module is used to crop the filled image with the center of gravity of the target object as the center to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio. The determination module is used to extract the depth information of each pixel of the cropped image and determine the printing height information of each pixel based on the depth information of each pixel.
[0007] Thirdly, embodiments of this application provide an electronic device, including: Memory, processor, and display; The memory is used to store one or more computer instructions; The processor is used to execute one or more computer instructions to implement the image processing method as described in any of the above embodiments.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program adapted for loading by a processor to perform the image processing method as described in any of the above embodiments.
[0009] The image processing method provided in this application fills the edges of the image to be printed with the center of gravity of the target object as the center, generating a filled image. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. This ensures that the shape of the filled image matches the printing base, improves the adaptability of the relief model's base shape, and achieves the effect that the target object is always located at the center of the printed image. The filled image is then cropped with the center of gravity of the target object as the center to obtain a cropped image with the preset aspect ratio. In the cropped image, the target object occupies a large proportion. Cropping at a preset ratio can reduce redundant areas in the image, maximize the proportion of the target object in the resulting cropped image, achieve the image preprocessing effect of centering the target object and ensuring sufficient proportion, avoid under-cropping or over-cropping, balance the need to maximize the proportion of the target object and prevent the target object from exceeding the base range, and improve the visual effect when the relief is presented; finally, the depth information of each pixel in the cropped image is extracted, and the printing height information of each pixel is determined based on the depth information of each pixel. The difference in depth information between each pixel is restored by the printing height information of the relief, and the sense of layering of the cropped image is restored by the height dimension, realizing the 2.5D effect of the relief. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram illustrating an application scenario of an image processing system provided in an embodiment of this application. Figure 2 A schematic flowchart of the image processing method provided in the embodiments of this application; Figure 3-6 This is a schematic diagram of a scene for the image processing method provided in an embodiment of this application; Figure 7 This is a schematic diagram of the modules of an image processing apparatus provided in an embodiment of this application. Detailed Implementation
[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0013] First, some of the nouns or terms that appear in the description of the embodiments of this application are explained as follows: 3D printing, also known as additive manufacturing technology (AM), is a technology that manufactures solid parts by adding materials layer by layer based on three-dimensional CAD data.
[0014] Before detailing the implementation methods of this application, related technologies will be further introduced.
[0015] 3D relief models, a widely used type of 3D model product, are commonly found in items such as refrigerator magnets, badges, and commemorative medals. They are created by carving parts of an object onto a base plate of a specific shape, thus presenting a 2.5D visual effect. Before the widespread application of AI technology, the production of 3D relief models mainly relied on manual carving and mold-making processes. While this process could achieve complex and intricate model details, it had significant efficiency limitations; it was not only time-consuming and labor-intensive but also difficult to adapt to frequently changing customized production needs. Against this backdrop, AI-based automatic relief model generation technology emerged.
[0016] In related technologies, customized AI-generated relief sculpture technology mainly falls into two mainstream implementation paths. The first path is based on machine vision algorithms, which extracts and estimates depth information from user-provided customized images, and then uses this depth information as a basis to automatically carve the surface of a base with a specific shape, ultimately forming a relief sculpture model. The second path leverages the generation capabilities of generative large models to directly generate a relief sculpture model that meets the requirements from the input image, eliminating the need for intermediate depth information estimation. Both of these technical solutions, to a certain extent, break through the limitations of traditional manual craftsmanship, realize the automated generation of relief sculpture models, and provide a feasible path for customized production.
[0017] However, both technical approaches have significant limitations in practical applications. The first approach, based on machine vision algorithms, suffers from insufficient precision and accuracy in depth estimation, leading to a polarization in the quality of the generated relief surface: either the low resolution of depth estimation results in insufficient detail in the model's undulations, lacking a sense of three-dimensionality; or the deviation in depth estimation causes an uneven relief surface, severely impacting the product's texture. The second approach, based on generative large models, struggles to guarantee adaptability and cost control. Because the training data for generative large models contains a low proportion of 2.5D relief-related data, the stability of generating relief models with specific styles is insufficient, making it difficult to meet refined customization needs. Furthermore, the computational resources and time costs required to call generative large models are significantly higher than traditional machine vision algorithms, hindering large-scale application. In addition, these two types of technical solutions have common shortcomings, namely, limited adaptability of the base shape, mostly only supporting simple regular shapes such as round and square bases, and unable to meet the customization needs of irregularly shaped bases; and the cropping processing of foreground patterns in user-customized images is not perfect, making it difficult to ensure that all important foreground elements are completely preserved, thus affecting the final presentation effect of the relief model.
[0018] To address the aforementioned problems, this application provides an image processing method, apparatus, storage medium, device, and program product. Specifically, the image processing method of this application can be executed by an electronic device, which may be a printer, terminal, or server. The printer may be a 3D printer. The terminal may be a smartphone, tablet, laptop, smart TV, wearable smart device, smart vehicle terminal, etc. The terminal may also include a client, which may be a software client, browser client, instant messaging client, or mini-program. The server may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0019] For example, when this image processing method is applied to a printer or terminal device, the printer or terminal device may include a display screen, a processor, and a memory. The display screen is used to display the image to be printed, a stereolithographic model, etc. For example, the image data of the filled image obtained after filling the image to be printed can be output to the display screen, thereby displaying the filled image, etc., on the display screen. The processor can be used to control the display of the image to be printed, the filled image, etc., on the display screen, the generation of the stereolithographic model, etc. The memory can be used to store image parameters, image data, etc. The display screen can also be used to receive user input operations (e.g., input of a preset aspect ratio, etc.), and the processor responds to the input. The terminal device can display the image to be displayed to the user in various ways, such as rendering it on the terminal device's display screen, or presenting it through holographic projection.
[0020] For example, when this image processing method runs on a server, it can be implemented based on a cloud imaging system. A cloud imaging system is based on cloud computing and uses a server cluster as its computing core. It includes servers and client devices. The storage and execution of the image processing method are completed on the server. The presentation of the image to be printed, the infill image, etc., is completed on the client. The client is mainly used to receive input operations and display the interface and images. For example, the client can be a display device with data transmission capabilities, such as a mobile terminal, television, computer, PDA, personal digital assistant, head-mounted display device, etc., but the terminal device for image data processing is the server in the cloud. During 3D printing, the user operates the client to send instructions to the server. The server processes the image to be printed according to the instructions, encodes and compresses the image data, returns it to the client via the network, and finally, the client decodes it to determine the printing height of each pixel.
[0021] It should be noted that, in the embodiments of this application, the executing entity of the image processing method can be a terminal device, a server, or both a terminal device and a server. The terminal device can be a local terminal device or a client device in the aforementioned cloud service. The image processing method of this application embodiment can also be executed by a client installed on it. This application embodiment does not limit the type of executing entity.
[0022] For example, in conjunction with the above description, Figure 1An image processing system 1000 for implementing an image processing method, according to an embodiment of this application, is illustrated. The image processing system 1000 may include at least one terminal 1001, at least one server 1002, at least one database 1003, and a network. The user-held terminal 1001 can connect to different servers via the network. The terminal is any device with computing hardware capable of supporting and executing software application tools corresponding to image processing.
[0023] In the aforementioned image processing system 1000, the terminal 1001 is used to display images, while adjustments to the image to be printed can be performed on the server 1002. The terminal 1001 can transmit data such as the image to be printed and the preset aspect ratio to the server 1002 via the network. The server 1002 adjusts the image to be printed according to the received data and sends the adjusted cropped image and print height information to the terminal 1001, so that the terminal 1001 can display the adjusted cropped image sent by the server 1002 to the user.
[0024] In possible application scenarios, different terminals 1001 may be served by different servers 1002. Therefore, in order to distinguish the servers 1002 corresponding to different terminals 1001, the embodiments of this application will use the terms "first" and "second" to describe them. In fact, the servers 1002 corresponding to different terminals 1001 can be the same server 1002. Therefore, without distinguishing between "first" and "second", it can be understood that terminals 1001 located in the same image processing scenario and processing different images are served by the same server 1002.
[0025] Furthermore, when the image processing system 1000 includes multiple terminals, multiple servers, and multiple networks, different terminals can connect to each other through different networks and servers. The network can be a wireless network or a wired network; for example, wireless networks include wireless local area networks (WLAN), local area networks (LAN), cellular networks, 2G networks, 3G networks, 4G networks, 5G networks, etc. Additionally, different terminals can also connect to other terminals or servers using their own Bluetooth networks or hotspot networks. Moreover, the system 1000 can include multiple databases, which are associated with different servers, and can continuously store information related to images, image parameters, 3D models, etc., in the databases while different users are performing multi-user processing online.
[0026] It should be noted that, Figure 1The schematic diagram of the image processing system shown is merely an example. The image processing system 1000 described in this application embodiment is intended to more clearly illustrate the technical solutions of this application embodiment and does not constitute a limitation on the technical solutions provided in this application embodiment. As those skilled in the art will know, with the evolution of image processing systems and the emergence of new business scenarios, the technical solutions provided in this application embodiment are also applicable to similar technical problems.
[0027] It should be noted that the triggering and input operations mentioned in the subsequent detailed description of the image processing method provided in the embodiments of this application can all include triggering and input operations performed by the user through fingers or by controlling a medium such as a mouse, keyboard, or stylus. The specific medium used can be determined based on the type of computer device. For example, when the computer device is a touchscreen device such as a mobile phone, tablet, or game console, the player can operate on the touchscreen using any suitable object or accessory such as a finger or stylus. When the terminal device is a non-touchscreen terminal device such as a desktop computer or laptop, the player can operate using external devices such as a mouse or keyboard.
[0028] The technical solution of this application will be described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0029] Please see Figure 2 , Figure 2 This is a flowchart illustrating the image processing method provided in an embodiment of this application. It should be noted that the steps shown may be executed in a different logical order than those shown in the flowchart. For ease of explanation, the image processing method is applied to a 3D printer (or computer device). The 3D printer includes a processor, a display screen, and a memory, wherein the memory stores one or more computer instructions, the processor executes one or more computer instructions, and the display screen displays an image. The image processing method can be implemented by steps 011 to 013, which are described in detail below.
[0030] Step 011: Using the center of gravity of the target object in the image to be printed as the center, fill the edges of the image to be printed to generate a fill image. The aspect ratio of the fill image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the fill image.
[0031] The image to be printed can be a two-dimensional image that the user expects to be converted into a three-dimensional model through 3D printing technology (e.g., a photograph, illustration, etc.).
[0032] The target object can be the content that needs to be highlighted in the image to be printed, such as a person, an animal, or a logo.
[0033] The centroid position can be the geometric center coordinates obtained by calculating the image area occupied by the target object in the image to be printed. For example, it can be determined by judging the centroid based on the pixels included in the target object.
[0034] The filling image can be an image generated by adding pixels to the edges of the image to be printed (padding operation). The filling process does not change the image content of the image to be printed, but only changes the aspect ratio of the image to be printed so that the aspect ratio of the filling image is the same as the preset aspect ratio, thereby adapting to the needs of the printing base.
[0035] Please refer to Figure 3 The preset aspect ratio can be the ratio of the width to the height of the rectangular bounding box that can wrap around the front of the printing base. The front is the plane on which the image to be printed is printed. The preset aspect ratio can be determined according to the actual shape of the base (including regular-shaped bases and irregular-shaped bases).
[0036] The printing base can be a carrier for supporting the embossed raised structure for printing, and can include regular shapes such as circles and squares or any irregular shapes such as hearts.
[0037] Specifically, the target object in the image to be printed can be obtained, and its center of gravity can be calculated based on the pixels it occupies. Then, using the center of gravity of the target object as the center, edge filling is performed on the image to be printed. The aspect ratio of the resulting filled image is the same as the preset aspect ratio, thus ensuring that the filled image matches the shape of the printing base, improving the adaptability of the relief model, and ensuring that the target object is always centered in the printed image. It is understandable that since the aspect ratio of the printing base determines the carrying capacity of the printed relief image, if the aspect ratio of the filled image to be printed is inconsistent with the bounding box of the base, it may cause the target object to be stretched or deformed or have missing edges during subsequent projection or trimming, affecting the printing effect. Furthermore, by using the center of gravity of the target object as the center, it is also ensured that the target object is centered in the printed relief, avoiding offset during printing to fit the base. In other words, filling with the center of gravity of the target object prevents the target object from shifting off the center of the base during subsequent adjustments, ensuring the integrity of the target object. In addition, the padding operation can provide sufficient background redundancy for subsequent iterations of cropping / padding, avoiding the cropping of effective pixels of the target object due to adjustments.
[0038] Step 012: Using the center of gravity of the target object as the center, crop the filled image to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio.
[0039] The preset ratio can be adaptively set by the user based on the type and content of the target object, the preset aspect ratio, the shape of the base, etc. When the proportion of the target object in the cropped image is greater than the preset ratio, it can be considered that the target object, without exceeding the range of the base, fills the relief or meets the user's needs in terms of the degree of filling the relief, thus making the visual effect of the relief full.
[0040] Specifically, the filling image can be cropped using the center of gravity of the target object as the center, ensuring that the aspect ratio of the cropped image remains the preset aspect ratio. This allows the cropped image to still fit the base, and the printed cropped image on the base still achieves the effect of the target object being centered on the base (i.e., after the user provides a custom input image, the image and base adaptation design can be completed automatically without manual intervention). Furthermore, in the cropped image, the proportion of the target object in the cropped image is greater than the preset ratio. Cropping can reduce redundant areas in the image, maximize the proportion of the target object in the resulting cropped image, and achieve the image preprocessing effect of centering the target object and ensuring sufficient proportion. This avoids under-cropping or over-cropping, balancing the need to maximize the proportion of the target object and prevent the target object from exceeding the base range, thus improving the visual effect when the relief is presented.
[0041] Step 013: Extract the depth information of each pixel in the cropped image, and determine the printing height information of each pixel based on the depth information of each pixel.
[0042] The depth information can be the three-dimensional depth value corresponding to each pixel in the cropped image.
[0043] The printing height information can be quantified data obtained by converting the depth information, used to quantify the height of the relief. This determines the degree of protrusion of each pixel at its corresponding position on the base.
[0044] Specifically, after obtaining the cropped image, the depth information of each pixel in the cropped image can be extracted using methods such as convolutional neural networks. The depth information is then mapped to printing height information. The difference in depth information between each pixel is restored by the printing height information of the relief (presented as relief protrusion). The sense of layering of the cropped image is restored by the height dimension, achieving a 2.5D effect.
[0045] Thus, by filling the edges of the image to be printed with the center of gravity of the target object as the center, a filled image is generated. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. This ensures that the shape of the filled image matches the printing base, improves the adaptability of the relief model, and achieves the effect that the target object is always located in the center of the printed image. The filled image is then cropped with the center of gravity of the target object as the center, resulting in a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio, allowing for cropping... To reduce redundant areas in the image and maximize the proportion of the target object in the obtained cropped image, the image preprocessing effect of centering the target object and ensuring sufficient proportion is achieved, avoiding under-cropping or over-cropping, balancing the need to maximize the proportion of the target object and prevent the target object from exceeding the base range, and improving the visual effect when the relief is presented; finally, the depth information of each pixel in the cropped image is extracted, and the printing height information of each pixel is determined based on the depth information of each pixel. The difference in depth information between each pixel is restored by the printing height information of the relief, and the sense of layering of the cropped image is restored by the height dimension, realizing the 2.5D effect of the relief.
[0046] In some embodiments, the image processing method further includes: Step 014: Obtain the original image; Step 015: Extract the target object from the original image to generate a foreground mask, which is used to mark the set of pixels in the original image that belong to the target object; Step 016: Based on the foreground mask, crop the original image to generate the image to be printed.
[0047] The original image can be an image material provided directly by the user that has not undergone preprocessing (such as cutout, cropping, or scaling). The original image includes the target object (such as people, animals, or markers) and the background (such as scene clutter or background color).
[0048] The foreground mask can be a binarized image, generated by retaining the pixel values corresponding to the target object in the original image (i.e., valid pixels) and modifying the background pixel values outside the target object to a preset threshold (e.g., 0) (i.e., invalid pixels). The foreground mask can be a set of pixels in the original image that belong to the target object, used to distinguish the foreground image (including the target object) from the background image.
[0049] The image to be printed can be a set of pixels containing the target object extracted from the original image based on the pixel marking range of the foreground mask (or an image in which the pixel proportion of the target object is greater than a preset pixel proportion threshold).
[0050] Specifically, the original image serves as the data source for generating the image to be printed. Users can acquire original image data in formats such as JPG and PNG through interaction with electronic devices (e.g., uploading the original image via a display screen or importing it from a server). Image segmentation techniques are then used to identify pixel differences between the target object's pixels and the background pixels in the original image. A foreground mask is generated using binary marking to define the pixel range of the target object, avoiding issues such as abnormal embossing caused by foreground and background confusion, which can affect printing quality. For example, alpha-matting techniques (including but not limited to the OpenCVGraph-Cut algorithm and various alpha-matting neural network models) can be used to mark pixels belonging to the target object as valid pixels and background pixels as invalid pixels, resulting in a foreground mask that only marks the set of pixels belonging to the target object. Using the foreground mask as a filtering criterion, the image region enclosed by the pixels corresponding to the target object is extracted from the original image. For example, valid pixels are determined based on the foreground mask, and the minimum bounding rectangle of all valid pixels is used as the cropping range. A cropping operation is then performed on the original image according to this range, resulting in the image to be printed, reducing subsequent data processing.
[0051] It should be noted that the image to be printed can also be the original image. That is, the original image can be directly filled and then cropped multiple times to remove the background pixels, resulting in a cropped image in which the proportion of the target object is greater than the preset ratio.
[0052] In some implementations, step 011: filling the edges of the image to be printed, centered on the centroid of the target object, to generate a filled image, includes: Step 0111: Obtain the centroid pixels corresponding to the centroid position of the target object in the image to be printed; Step 0112: Calculate the target resolution based on the preset aspect ratio and the resolution of the image to be printed; Step 0113: Fill the edges of the image to be printed with the centroid pixel as the center to generate a filled image. The resolution of the filled image is the target resolution.
[0053] When the resolution of the fill image is the target resolution, the aspect ratio of the fill image and the aspect ratio of the base can be adapted during printing.
[0054] Specifically, after determining the centroid pixel, the centroid pixel is used as the filling reference. First, the center position of the target object is determined through the centroid pixel to avoid image offset during filling. Then, according to the preset aspect ratio and the resolution of the image to be printed, the target resolution of the filled image with the size adapted to the base is determined through proportional conversion. Finally, with the centroid pixel as the center, at least one edge of the image to be printed is filled so that the resolution of the filled image after filling is the target resolution. While not changing the main content of the target object, size adaptation is achieved through the supplement of edge pixels, providing an image basis for subsequent iterative scaling to maximize the foreground ratio and solving the problems of poor adaptability between the image to be printed and the base and foreground offset. For example, after obtaining the preset aspect ratio (assumed to be a:b, where a is the width and b is the height), first obtain the original resolution of the image to be printed (assumed to be W0*H0, where W0 is the width and H0 is the height). First, calculate the target resolution according to the preset aspect ratio (assumed to be W1*H1, where W1 is the width, H1 is the height, and W1:H1 = a:b). For example, in the case of W0 / H0 < a / b, the target height H1 = H0 is determined, and the target width W1 = H0*(a / b). In the case of W0 / H0 > a / b, the target width W1 = W0 is determined, and the target height H1 = W0*(b / a). In this way, the target resolution W1*H1 can be obtained. Then, with the centroid pixel (assumed pixel coordinates are (x0, y0)) as the center, an edge padding operation is performed on the image to be printed. During the padding process, pixels are supplemented on at least one edge of the image to be printed without changing the content and details of the target object of the image until the resolution of the image is the target resolution and the centroid pixel is still at the center position of the image, thereby obtaining the filled image.
[0055] In some embodiments, step 012: With the centroid position of the target object as the center, the filled image is cropped to obtain a cropped image with an aspect ratio of the preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset proportion, including: Step 0121: According to the preset cropping ratio and the target resolution of the filled image, calculate the cropping resolution of the cropped image; Step 0122: With the centroid position of the target object as the center, crop the edges of the filled image so that the aspect ratio of the filled image after cropping is the preset aspect ratio; Step 0123: In the case where the proportion of the target object in the filled image after cropping is less than the preset proportion and the distance between the pixel of any target object and the target base pixel is less than the preset threshold, re-enter the step of calculating the cropping resolution of the cropped image according to the preset cropping ratio and the target resolution of the filled image, where the target base pixel is the pixel with the closest distance to the pixel of the target object among each base pixel corresponding to the base. Step 0124: If the proportion of the target object in the cropped filled image is greater than a preset ratio, or the distance between the pixel of a target object and the pixel of the target base is greater than a preset threshold, the filled image obtained after the previous cropping is determined as the cropped image.
[0056] The preset cropping ratio can be a pre-defined proportional scaling factor (e.g., 1.2, 1.1, 1, 0.9, 0.8, etc.), which can be used to enlarge or reduce the size of the cropped image as a whole, thereby achieving the effect of enlarging the proportion of the target object while avoiding exceeding the base.
[0057] The cropping resolution can be the pixel size of the cropped image, while its aspect ratio remains the preset horizontal and vertical aspect ratio.
[0058] The preset ratio can be the minimum percentage threshold (e.g., 80%, 85%, 90%, 95%) of the target object in the entire cropped image to ensure that the target object can fill the relief surface as much as possible.
[0059] Among them, the base pixel is the pixel mapping point of the front vertex of the base in the image projection, which can be used to determine whether the target object exceeds the base. There are multiple pixel mapping points of the front vertex of the base in the image projection. By calculating the distance between any pixel of the target object and each base pixel, and comparing the various distances, the base pixel with the smallest distance is determined as the target base pixel (i.e., the nearest base pixel).
[0060] The preset threshold can be a pre-defined distance threshold used to determine whether the pixels of the target object exceed the pixels of the base, thus preventing the target object from projecting beyond the base boundary. For example, if the distance between the pixels of the target object and the nearest base pixel is greater than the preset threshold, then the pixels of the target object are considered to exceed the base.
[0061] Specifically, taking the cropped image as an example, the cropping resolution can be determined first by calculating the ratio based on the preset cropping ratio and the target resolution of the filled image. This ensures that the aspect ratio of the cropped image still matches the aspect ratio of the base. Next, cropping is performed with the center of gravity as the center, ensuring the target object remains centered. Then, the proportion of the target object or whether the target object extends beyond the base edge is verified in the cropped intermediate image. If the proportion of the target object in the intermediate image is less than the preset ratio (this can be considered as the target object not fully filling the entire base after printing), and any pixel of the target object... If the distance between the target object and the nearest base pixel is less than a preset threshold (it can be assumed that after the intermediate image is printed, the projection point of any pixel of the target object on the base is within the range of the base, and the target object can be further enlarged), the cropping size can be recalculated and cropped again until the proportion of the target object in the intermediate image is greater than the preset ratio or the distance between a pixel of a target object and the nearest base pixel is greater than the preset threshold, it can be assumed that the target object may exceed the edge of the base and cannot guarantee integrity when the relief printed based on the cropped image is printed. Therefore, the filling image obtained after the last cropping is determined as the cropping graphic.
[0062] For example, you can first obtain a preset cropping ratio (let's say 1.1) and the target resolution of the fill image. Multiply the width and height of the cropping ratio and the target resolution respectively; the resulting cropping resolution is the resolution of the intermediate image. Then, using the center position of the target object as the center, crop the edges of the fill image according to the cropping resolution to increase the proportion of the target object in the image. Next, calculate the proportion of the target object in the intermediate image and the distance between each pixel of the target object and the nearest base pixel. For example, please refer to [link to relevant documentation]. Figure 3The intermediate image is orthogonally projected onto the rectangular bounding box of the front of the relief base. Within the two-dimensional plane of the base's front, a kdtree-accelerated algorithm is used to find the nearest base pixel for each projected pixel of the target object and records this nearest distance. If the nearest distance of any pixel is less than a preset threshold, it can be considered that the target object, after projection, does not exceed the range of the vertices of the base's front. The target object can be further enlarged. Therefore, the cropped image can be recalculated according to a preset cropping ratio to further enlarge the proportion of the target object. The above projection, nearest neighbor calculation, and cropping operations are iteratively repeated until a nearest distance exceeds the threshold, at which point the iteration stops, and the filled image before the last iteration is returned as the cropped image. Conversely, if a nearest distance exceeds the threshold in the first calculation, it means that the target object, after projection, exceeds the range of the vertices of the base's front. The target object needs to be reduced, so a proportionally scaled padding image is used to reduce the proportion of the foreground in the image. The above projection, nearest neighbor calculation, and padding operations are iteratively repeated until all nearest distances are less than the threshold, at which point the iteration stops, and the filled image obtained from the last iteration is returned. The filled image is then used as the cropped image.
[0063] In some implementations, step 013: determining the printing height information of each pixel based on the depth information of each pixel, including: Step 0131: Perform depth extraction on the cropped image to determine the depth information of each pixel in the cropped image; Step 0132: Determine the printing height information corresponding to each pixel based on the preset mapping relationship between depth information and printing height information.
[0064] The depth information can be the three-dimensional depth value corresponding to the pixel obtained after extracting the depth of the cropped image. It can be presented in the form of a depth map. For example, pixels that are visually close to the image have small depth values, while pixels that are visually far away have large depth values.
[0065] Alternatively, the depth values corresponding to each pixel of the cropped image can be obtained through a depth extraction model, and the depth values can be aggregated into a depth map D based on the pixel location (for example, see [link to relevant documentation]). Figure 4 , Figure 4 An example depth map is shown, taking the extraction of depth information from a cropped image with a cat as the target object. Here, grayscale values correspond to depth values. Since the depth map D is characterized by smaller values for near objects and larger values for distant objects, it needs to be normalized to the range [0,1] and then inverted, D' = 1 - D, so that values are larger for near objects and smaller for distant objects, serving as the height values for the convexity. Therefore, the normalized depth map D' corresponds to the depth information of each pixel in the cropped image.
[0066] The mapping relationship between the preset depth information and the printing height information can be a pre-defined conversion rule that converts the depth information into printing height information that meets the requirements of relief carving.
[0067] The printing height information can be quantized data obtained by converting the depth information through a preset mapping relationship, which determines the protrusion height of the relief base corresponding to each pixel of the cropped image.
[0068] Specifically, a pre-trained depth extraction model (such as a convolutional neural network or attention mechanism model) can be used to extract the depth of each pixel in the cropped image to obtain the depth information of each pixel constituting the target object. Then, through a preset mapping relationship between the depth information and the printing height information, the depth information is adapted to the relief carving requirements, thereby converting the depth information into printing height information that fits the printing requirements. The depth extraction model can be a model that can output the depth values corresponding to each pixel based on the two-dimensional image (cropped image). The training process of the depth extraction model can be as follows: Cropped image samples and corresponding label information are obtained. The label information includes the label depth information (depth value) of each pixel in the cropped image. The cropped image samples are then input into the depth extraction model for training, outputting training depth information. The depth extraction model is adjusted based on the loss value between the label depth information and the training depth information until the depth extraction model converges.
[0069] It is understandable that by using preset, unified mapping rules to convert depth information into printable height information, the scale differences between the original depth information are eliminated, and the depth information is transformed into height information that can be directly used for carving. This provides accurate and objective depth data as a benchmark for height information generation, thereby overcoming the problem of limited accuracy and precision of existing depth estimation.
[0070] In some implementations, step 013: determining the printing height information of each pixel based on the depth information of each pixel, including: Step 0133: Extract the normal vector of the cropped image to determine the normal vector information of each pixel in the cropped image; Step 0132: Based on the preset mapping relationship between depth information and print height information, determine the print height information corresponding to each pixel, including: Step 01321: Determine the basic printing height information corresponding to each pixel based on the preset mapping relationship between depth information and printing height information; Step 01322: Adjust the printing base height information according to the normal vector information of each pixel, and determine the adjusted printing base height information as the printing height information of each pixel.
[0071] Among them, the normal vector information can be the three-dimensional surface normal vector direction data corresponding to the pixel, which can be presented in the form of a normal vector map, reflecting the spatial orientation characteristics of the surface of each pixel of the target object in the image.
[0072] Optionally, the normal vector directions corresponding to each pixel on the cropped image can be integrated into a single normal vector map N according to the pixel position (for example, see [link to relevant documentation]). Figure 5 , Figure 5 An example is shown of the normal vector map of a cropped image with a cat as the target object, where the RGB values of the pixels correspond to the normal vector directions. In order to eliminate noise in the normal vector prediction process, the normal vector map N can be blurred (for example, it can be at least one of Gaussian smoothing, Laplace smoothing, etc.) (the normal vector direction corresponding to the pixel is fused and calculated based on the normal vector direction of each pixel adjacent to the pixel) to obtain an optimized normal vector map N', making the normal vector prediction result smoother. The normal vector map N' is the normal vector information.
[0073] It is understandable that, in order to improve the accuracy of depth and normal vector prediction, the RGB values (and / or grayscale values) of the original color image can be changed to convert the color image into a black and white image, thereby improving the accuracy of depth and normal vector prediction.
[0074] The basic height information for printing can be the height data of pixels obtained by converting depth information and preset mapping relationships.
[0075] The printing height information can be the quantitative data of printing height obtained by adjusting the normal vector information based on the basic printing height information. While retaining the undulation characteristics of near and far reflected by the depth information, it combines the surface orientation characteristics reflected by the normal vector information to ensure printing accuracy.
[0076] Optionally, step 01322: Adjust the printing base height information according to the normal vector information of each pixel, and determine the adjusted printing base height information as the printing height information of each pixel, including: Step 01323: Based on the target normal vector information corresponding to the target pixel, iteratively adjust the printing base height information so that the adjusted target pixel normal vector information matches the target normal vector information.
[0077] While the normal vector information of a single pixel in a cropped image can characterize surface orientation, relying solely on it to adjust the printing base height information can easily lead to localized unevenness and discontinuous orientation on the relief surface. In contrast, the normal vector information of adjacent pixels reflects the continuous spatial orientation characteristics of the target object's surface. Therefore, by fusing the normal vector information of a single pixel with its four adjacent pixels (e.g., the four pixels above, below, left, and right of a pixel), the target normal vector information of that pixel can be determined. This eliminates single-pixel prediction noise and yields a target normal vector information that more closely matches the real surface. Subsequently, using this target normal vector information as a benchmark, the printing base height information is iteratively adjusted. Through subtle corrections to the printing height information, the actual normal vector direction of the adjusted pixel matches the target normal vector information, resulting in a printed relief surface with continuous and smooth orientation, and details that closely resemble the real features of the target object.
[0078] Specifically, a pre-trained normal vector extraction model (such as a convolutional neural network or attention mechanism model) can be used to predict the 3D surface normal vector direction of each pixel in the cropped image, thereby obtaining the 3D surface normal vector information corresponding to each pixel. The training process of the normal vector extraction model can be as follows: Cropped image samples and corresponding label information are obtained, including the label normal vector information (normal vector direction) of each pixel in the cropped image; the cropped image samples are then input into the normal vector extraction model for training, outputting training normal vector information; the normal vector extraction model is adjusted based on the loss value between the label normal vector information and the training normal vector information until the normal vector extraction model converges.
[0079] It should be noted that the normal vector extraction model and the depth extraction model can be of the same origin (the same depth model can be used to simultaneously extract depth and normal vectors). For example, by setting a sample set with labeled depth and normal vector information, the model can be trained so that it can output depth and normal vector information based on the input cropped image. In the relief generation process, since no large generative model needs to be called, a pre-trained extraction model is used only for predicting depth and surface normal vector information. This significantly reduces the number of parameters compared to a large generative model, greatly reducing the time and computational costs required for generation. Since depth information alone cannot reflect the surface texture or guarantee the overall undulating and layered effect of the relief, a method is first used to obtain depth information (depth map D'). Based on the mapping relationship between depth information and print height information, the basic print height information corresponding to each pixel is determined. Next, the normal vector information of each pixel in the cropped image is obtained (normal vector map N'). Based on the basic print height information, the height of each pixel is iteratively adjusted so that the normal vector direction of the adjusted pixel is consistent with the normal vector direction corresponding to the pixel in normal vector map N'. The adjusted basic print height information is then determined as the print height information of each pixel.
[0080] More specifically, the depth map D' can be orthogonally projected onto the bounding box region on the front of the base, establishing a positional correspondence between the vertices of the base's 2D projection plane and the pixels of the depth map N'. Next, for each vertex i, the nearest depth information is queried in the projected depth map D'. Based on the mapping relationship between depth information and print height information, this depth information is mapped to print height information, thereby determining the corresponding print base height information for the pixel. Then, the normal map N' is orthogonally projected onto the bounding box region on the front of the base, establishing a positional correspondence between the vertices of the base's 2D projection plane and the pixels of the normal map N'. Next, for each vertex i, the normal vector direction of the nearest pixel (i.e., the target normal vector information) is found in the projected normal map N', and this direction is denoted as Ti, which is the ideal surface orientation of the vertex. Given the printed base height information, each vertex has a corresponding initial normal vector direction. This can be achieved using various algorithms, including but not limited to PyTorch, TensorFlow frameworks, CPU-based gradient descent optimization algorithms (such as MATLAB optimization toolkits and C++ numerical optimization libraries like ensmallen), and gradient backpropagation (e.g., at least one of Adam, SGD, LBFGS, AdaGrad, etc.). Based on the printed base height information, the height of each vertex i is iteratively adjusted. After each adjustment, the actual normal vector direction Ti' of that vertex is calculated, and the matching degree between Ti and Ti' is determined using the loss function ∑i(1-TiTi'). This process continues until iteration t or the loss function converges, at which point the normal vector information of the target pixel is considered to match the target normal vector information. During gradient backpropagation, it is crucial to strictly limit the printed base height information of the vertices to be greater than or equal to 0 to avoid situations where the base vertices are concave (the relief only has convexity, not concavity).
[0081] In some implementations, the method further includes: Step 017: Using the preset printing plane of the printing base as the horizontal reference plane, generate a 3D model based on the printing height information of each pixel; Step 018: Adjust the printing height information of pixels outside the target object in the cropped image to a preset printing threshold, and adjust the 3D model according to the preset printing threshold to generate a stereolithography model.
[0082] The preset printing base can be a pre-defined physical base material used to create a three-dimensional relief model. 3D printing can be achieved by stacking consumables on the printing plane of the printing base.
[0083] The stereolithography model can be a stereo model file (such as STL format). The height variation of the three-dimensional model is determined by the height value represented by the printing base height information. The 3D printer can perform 3D printing based on the stereolithography model.
[0084] The horizontal reference plane can be a three-dimensional horizontal reference plane set with the physical plane of the front of the printing base as the reference (for example, it can correspond to the plane where the bounding box on the front of the base is located). The height value of the horizontal reference plane is 0, which is the starting point for measuring the height of the relief. Printing height information, printing height basic information, etc. are all calibrated relative to this plane.
[0085] The three-dimensional model can be a relief three-dimensional digital model generated by mapping the printing height information of each pixel of the cropped image to the corresponding spatial position of the base, based on a horizontal reference plane.
[0086] The preset printing threshold can be 0, 1, 2, etc. For example, when the preset printing threshold is 0, the printing height information of pixels outside the target object is adjusted to 0. The resulting stereolithography model restores the vertex positions of all the relief front located outside the foreground projection range of the image, ensuring that only the target object protrudes during printing, and avoiding abnormal protrusions or depressions caused by the normal vector prediction error at the junction of the target object and the background.
[0087] Specifically, the pixel plane of the cropped image can be spatially matched with the physical plane of the front of the printing base. Taking the horizontal reference plane of the base as the starting point in the vertical direction, the printing height information of each pixel is used as the protrusion height perpendicular to the horizontal reference plane and mapped to the corresponding spatial coordinate point of the base to generate a three-dimensional model, thereby transforming the two-dimensional pixel height information into a three-dimensional digital model structure.
[0088] This involves uniformly scaling the printing height information of all raised areas, for example, scaling it to 1 / 5 to 1 / 50 of the actual width of the base, ensuring that the initial embossed raised areas are within a reasonable range. Since the 3D model still contains pixel height information of the background area of the cropped image, directly using it for processing would result in abnormal background protrusions and difficulty in highlighting the target object (foreground). Therefore, the printing height information of pixels outside the target object can be adjusted to a preset printing threshold (taking a preset printing threshold of 0 as an example) to restore and optimize the 3D model, retaining only the effective raised height of the target object, thereby generating a stereolithographic model. This stereolithographic model conforms to the requirement that only the foreground target object protrudes during printing, ensuring accuracy and detail during printing. For example, please refer to... Figure 6 , Figure 6 An illustrative cross-sectional view of a relief product obtained by printing a stereolithography model is shown. With the printing base as a reference, the center of the relief product is matched with the center of the target object in the foreground image. The printing height information of the pixels outside the target object is adjusted to a preset printing threshold (assuming it is 1), while the pixels of the target object retain the printing height information. By stacking consumables on the printing base in this way, a relief product with the target object centered and protruding can be obtained.
[0089] In some implementations, the stereolithography model can be UV-unwrapped using 3D processing libraries including but not limited to Blender and Open3D; the model can be rasterized using GPU-accelerated rendering frameworks including but not limited to NVDiffrast and textured according to UV coordinates, and color mapping can be used to achieve the desired printing effect.
[0090] All of the above technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
[0091] To facilitate better implementation of the image processing method of this application embodiment, this application embodiment also provides an image processing apparatus 300. Please refer to the figure, which is a schematic structural diagram of the image processing apparatus 300 provided in this application embodiment. The image processing apparatus 300 may include: The filling module 301 is used to fill the edges of the image to be printed with the center of gravity of the target object as the center to generate a filling image. The aspect ratio of the filling image is the same as the preset aspect ratio of the printing base and the center of gravity of the target object is located at the center of the filling image. The cropping module 302 is used to crop the filled image with the center of gravity of the target object as the center to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio. The determination module 303 is used to extract the depth information of each pixel in the cropped image and determine the printing height information of each pixel based on the depth information of each pixel.
[0092] The image processing device can be integrated into a terminal or server that has storage and a processor and thus computing power, or the image processing device can be the terminal or server itself.
[0093] The apparatus has been described above from the perspective of functional modules in conjunction with the accompanying drawings. These functional modules can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method implementation in this application can be completed by the integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application can be directly manifested as being executed by a hardware encoding processor, or by a combination of hardware and software modules in the encoding processor. Optionally, the software module can be located in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps in the above method implementation.
[0094] Optionally, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0095] The figure is a schematic diagram of the structure of a computer device provided in an embodiment of this application. This computer device can be a terminal or a server. As shown, the computer device includes a processor with one or more processing cores, a memory with one or more computer-readable storage media, and a computer program stored in the memory and executable on the processor. The processor and the memory are electrically connected. Those skilled in the art will understand that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0096] The processor is the control center of a computer device. It connects various parts of the computer device through various interfaces and lines. By running or loading software programs and / or modules stored in memory, and calling data stored in memory, it performs various functions of the computer device and processes data, thereby processing the computer device as a whole.
[0097] In this embodiment of the application, the processor in the computer device loads the instructions corresponding to the processes of one or more computer programs into the memory according to the following steps, and the processor runs the computer programs stored in the memory to realize various functions: Using the center of gravity of the target object in the image to be printed as the center, the edges of the image to be printed are filled to generate a filled image. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. Using the center of gravity of the target object as the center, the filled image is cropped to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio. Extract the depth information of each pixel in the cropped image, and determine the printing height information of each pixel based on the depth information of each pixel.
[0098] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0099] This application also provides a computer-readable storage medium for storing a computer program. This computer-readable storage medium can be applied to a computer device, and the computer program causes the computer device to execute the corresponding processes in the image processing methods of the embodiments of this application; for the sake of brevity, further details are omitted here.
[0100] This application also provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding process in the image processing method of this application embodiment. For brevity, further details are omitted here.
[0101] This application also provides a computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding process in the image processing method of this application. For brevity, further details are omitted here.
[0102] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0103] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0104] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0105] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the interrelationships or direct associations or communication connections shown or discussed may be through some interfaces; indirect associations or communication connections between apparatuses or units may be electrical, mechanical, or other forms.
[0106] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0107] In addition, the functional units in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0108] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer or a server) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0109] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image processing method, characterized in that, include: Using the center of gravity of the target object in the image to be printed as the center, the edges of the image to be printed are filled to generate a filled image. The aspect ratio of the filled image is the same as the preset aspect ratio of the printing base, and the center of gravity of the target object is located at the center of the filled image. Using the center of gravity of the target object as the center, the filled image is cropped to obtain a cropped image with a preset aspect ratio. In the cropped image, the proportion of the target object is greater than the preset ratio. Extract the depth information of each pixel in the cropped image, and determine the printing height information of each pixel based on the depth information of each pixel.
2. The image processing method according to claim 1, characterized in that, The method further includes: Obtain the original image; The target object is extracted from the original image to generate a foreground mask, which is used to mark the set of pixels in the original image that belong to the target object; Based on the foreground mask, the original image is cropped to generate the image to be printed.
3. The image processing method according to claim 1 or 2, characterized in that, The step of filling the edges of the image to be printed, centered on the centroid of the target object, to generate a filled image includes: Obtain the centroid pixel corresponding to the centroid position of the target object in the image to be printed; Calculate the target resolution based on the preset aspect ratio and the resolution of the image to be printed; Centered on the centroid pixel, the edges of the image to be printed are filled to generate the filled image, the resolution of which is the target resolution.
4. The image processing method according to any one of claims 1-3, characterized in that, The step of cropping the filled image with the center of gravity of the target object as the center to obtain a cropped image with a preset aspect ratio, wherein the target object occupies a larger proportion in the cropped image than the preset ratio, includes: The cropping resolution of the cropped image is calculated based on the preset cropping ratio and the target resolution of the filled image; Using the center of gravity of the target object as the center, the edges of the filling image are cropped so that the aspect ratio of the cropped filling image is the preset aspect ratio; If the proportion of the target object in the cropped filling image is less than a preset ratio, and the distance between any pixel of the target object and the pixel of the target base is less than a preset threshold, the step of calculating the cropping resolution of the cropped image based on the preset cropping ratio and the target resolution of the filling image is entered again. Here, the target base pixel is the pixel that is closest to the pixel of the target object among all the base pixels corresponding to the base. If, in the cropped filled image, the proportion of the target object is greater than a preset proportion, or the distance between a pixel of a target object and a pixel of the target base is greater than a preset threshold, the filled image obtained after the previous cropping is determined as the cropped image.
5. The image processing method according to claim 1, characterized in that, Determining the printing height information of each pixel based on the depth information of each pixel includes: Depth extraction is performed on the cropped image to determine the depth information of each pixel in the cropped image; Based on the preset mapping relationship between depth information and printing height information, the printing height information corresponding to each pixel is determined.
6. The image processing method according to claim 5, characterized in that, Determining the printing height information of each pixel based on the depth information of each pixel includes: Normal vectors are extracted from the cropped image to determine the normal vector information of each pixel in the cropped image; The step of determining the printing height information corresponding to each pixel based on the preset mapping relationship between depth information and printing height information includes: Based on the preset mapping relationship between depth information and printing height information, the printing base height information corresponding to each pixel is determined; Based on the normal vector information of each pixel, the printing base height information of each pixel is adjusted, and the adjusted printing base height information is determined as the printing height information of each pixel.
7. The image processing method according to claim 6, characterized in that, The adjustment of the printing base height information based on the normal vector information of each pixel includes: Based on the target normal vector information corresponding to the target pixel, the printing base height information is iteratively adjusted so that the adjusted target pixel normal vector information matches the target normal vector information.
8. The image processing method according to claim 1, 5, 6 or 7, characterized in that, Also includes: Using the preset printing plane of the printing base as the horizontal reference plane, a three-dimensional model is generated based on the printing height information of each pixel. The printing height information of pixels located outside the target object in the cropped image is adjusted to a preset printing threshold, and the three-dimensional model is adjusted according to the preset printing threshold to generate a stereolithography model.
9. An electronic device, characterized in that, include: Memory, processor, and display; The memory is used to store one or more computer instructions; The processor is used to execute one or more computer instructions to implement the image processing method as described in any one of claims 1-8.
10. A computer-readable storage medium storing one or more computer instructions thereon, characterized in that, The instruction is executed by the processor to implement the image processing method as described in any one of claims 1-8.