A method and device for dividing a plane of a three-dimensional rendering gradient multi-order plane
By using a planar segmentation method for gradient multi-level planes in 3D rendering, the 3D rendering algorithm is optimized, the amount of computational data is reduced, the computational efficiency and image processing accuracy are improved, and flexible multi-layer gradient effects are achieved, solving the problem of long rendering time in existing technologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 深圳鼎匠科技有限公司
- Filing Date
- 2024-09-12
- Publication Date
- 2026-04-17
AI Technical Summary
Existing 3D image rendering technologies have high algorithm complexity and large computational load, resulting in long rendering times and limiting the application scenarios of real-time rendering technology.
A planar segmentation method using gradient multi-level planes in 3D rendering is adopted, including grayscale conversion, 3D projection, pixel grouping, vertex determination, intersection connection, segmentation processing, and gradient color rendering, thereby optimizing the 3D rendering algorithm.
It reduces the amount of computational data, improves the computational efficiency and image processing accuracy of 3D rendering, achieves flexible multi-layer gradient effects, and optimizes the storage and rendering process of 3D models.
Smart Images

Figure CN119444766B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method and apparatus for plane segmentation of a three-dimensional rendering gradient multi-level plane. Background Technology
[0002] With the rapid development of computer graphics, 3D image rendering technology has become an indispensable core technology in many fields such as visual arts, game design, film and television production, and architectural design. However, existing 3D image rendering technologies still face many challenges and shortcomings in practical applications. Among them, current real-time 3D rendering technology relies on complex algorithms and massive amounts of data, resulting in high algorithmic difficulty and enormous computational load. For large-scale or high-resolution 3D scenes, the rendering time can be very long, limiting the application scenarios of real-time rendering technology. Therefore, it is particularly important to propose a corresponding solution to the technical problems of high rendering algorithm complexity, large computational load, and low rendering efficiency in existing 3D rendering technologies. Summary of the Invention
[0003] This invention provides a planar segmentation method and apparatus for three-dimensional rendering of gradient multi-level planes, which can help reduce the amount of computational data in three-dimensional rendering, optimize the algorithm of three-dimensional rendering technology, and improve the computational efficiency of three-dimensional rendering.
[0004] To address the aforementioned technical problems, the first aspect of this invention discloses a method for plane segmentation in three-dimensional rendering of gradient multi-level planes, the method comprising:
[0005] A preset first image processing is performed on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion.
[0006] According to preset pixel grouping conditions, the first image processing result is subjected to second image processing to obtain a second image processing result corresponding to the first image processing result. The second image processing includes three-dimensional projection and pixel grouping. The second image processing result includes multiple triangular facets.
[0007] Perform third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets. The third image processing includes determining the vertices of each triangular facet, determining the intersection point between the plane containing each triangular facet and a preset cross section, and connecting the intersection points.
[0008] For the non-triangular portion of the third image processing result, a fourth image processing is performed according to the pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result. The fourth image processing includes segmentation processing, classification processing, and gradient color rendering. The fourth image processing result includes a target rendered image corresponding to the target image.
[0009] As an optional implementation, in the first aspect of the present invention, the step of performing second image processing on the first image processing result according to preset pixel grouping conditions to obtain a second image processing result corresponding to the first image processing result includes:
[0010] A three-dimensional model is constructed, and a three-dimensional coordinate system matching the three-dimensional model is established; the first image processing result includes a grayscale image corresponding to the target image, and the three-dimensional coordinate system has the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis; the first axis and the second axis are on the same base plane, and the third axis is perpendicular to the base plane;
[0011] The first image processing result is projected onto the three-dimensional coordinate system to obtain a three-dimensional projection result corresponding to the first image processing result; the three-dimensional projection result is composed of multiple three-dimensional pixels; the three-dimensional projection result includes a three-dimensional projection image corresponding to the grayscale image and a two-dimensional perspective image, the two-dimensional perspective image being obtained by projecting all the three-dimensional pixels onto the base plane;
[0012] For all the three-dimensional pixels in the two-dimensional view image, pixel division is performed to obtain multiple quadrilaterals. Each quadrilateral is composed of four three-dimensional pixels, and all the quadrilaterals do not overlap.
[0013] For each quadrilateral, calculate the diagonal distance between any two diagonal pixels in the quadrilateral, and select a target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to a preset pixel grouping requirement. Connect the two diagonal pixels corresponding to the target diagonal distance to obtain the diagonal connection result corresponding to the quadrilateral. The diagonal pixels are the three-dimensional pixels located at the diagonal positions in any quadrilateral.
[0014] The diagonal connection results corresponding to all the quadrilaterals are determined as the second image processing result corresponding to the first image processing result.
[0015] As an optional implementation, in the first aspect of the present invention, selecting the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to a preset pixel grouping requirement includes:
[0016] Based on the grayscale value corresponding to each diagonal pixel, the pixel attribute of the diagonal pixel is determined. The pixel attribute includes a negative value attribute or a positive value attribute. When the pixel attribute of the diagonal pixel is a negative value attribute, the diagonal pixel is below the base plane in the three-dimensional projection image. When the pixel attribute of the diagonal pixel is a positive value attribute, the diagonal pixel is in or above the base plane in the three-dimensional projection image.
[0017] Two diagonal pixels with the same pixel attributes in the quadrilateral are defined as a first pixel pair, and two diagonal pixels with different pixel attributes in the quadrilateral are defined as a second pixel pair; and the quadrilateral includes a first diagonal distance and a second diagonal distance;
[0018] When the quadrilateral satisfies the preset first grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance;
[0019] When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined to be the target diagonal distance;
[0020] Specifically, the quadrilateral satisfies the first grouping condition by simultaneously containing both the first pixel pair and the second pixel pair; the second grouping condition is the opposite of the first grouping condition.
[0021] As an optional implementation, in a first aspect of the invention, performing third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets includes:
[0022] Determine the target cross section and its corresponding plane equation, wherein the target cross section is the base plane or a plane parallel to the base plane;
[0023] For each of the triangular facets in the second image processing result, the vertex coordinates corresponding to each triangle vertex in the triangular facet are determined according to the set fixed-point function;
[0024] Based on the plane equation and the vertex coordinates corresponding to each of the triangle vertices in the triangular facet, the coordinates of the two target intersection points between the target cross section and the triangular facet are calculated. Then, the two target intersection points are connected to obtain the intersection point connection result corresponding to the triangular facet.
[0025] The connection results of the intersection points corresponding to all the triangle facets and all the target intersection points are determined as the third image processing result.
[0026] As an optional implementation, in the first aspect of the present invention, the step of performing fourth image processing on the non-triangular portion of the third image processing result according to the pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result includes:
[0027] For the non-triangular parts in the third image processing result, segmentation processing is performed according to the pixel grouping conditions until it is determined that the third image processing result is composed of the triangular facets, and a segmentation processing result corresponding to the third image processing result is obtained.
[0028] For all the triangular facets in the segmentation result, based on the target cross section, each triangular facet above the target cross section is divided into a first facet, and each triangular facet below the target cross section is divided into a second facet;
[0029] Generate multiple first closed surfaces based on all the first surfaces, generate multiple second closed surfaces based on all the second surfaces, and determine all the first closed surfaces and all the second closed surfaces as target closed surfaces;
[0030] According to the preset rendering method, gradient color rendering is performed on each of the target closed surfaces to obtain the gradient color rendering result corresponding to each of the target closed surfaces, which is used as the fourth image processing result.
[0031] As an optional implementation, in the first aspect of the present invention, the step of performing gradient color rendering on each of the target closed surfaces according to a preset rendering method to obtain a gradient color rendering result corresponding to each of the target closed surfaces includes:
[0032] Obtain the two-dimensional projection of each target closed surface on the base plane, the two-dimensional projection of the surface includes a first sub-surface projection corresponding to each first closed surface and a second sub-surface projection corresponding to each second closed surface;
[0033] According to the preset first color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each of the first sub-surface projections to obtain the first rendering result corresponding to each of the first sub-surface projections;
[0034] According to the preset second color system, with the counterclockwise direction as the rendering direction, the gradient color rendering is performed on each second sub-surface projection to obtain the second rendering result corresponding to each second sub-surface projection;
[0035] All the first rendering results and all the second rendering results are determined as gradient color rendering results.
[0036] As an optional implementation, in the first aspect of the invention, calculating the diagonal distance between any two diagonal pixels in each quadrilateral includes:
[0037] For each quadrilateral, determine the three-dimensional coordinates corresponding to each three-dimensional pixel in the quadrilateral, and at the same time, determine two three-dimensional pixels in the quadrilateral that are located at opposite corners as a pair of diagonal pixels, and each pair of diagonal pixels includes two diagonal pixels.
[0038] For each pair of diagonal pixels in each quadrilateral, the distance between the two diagonal pixels in the pair is calculated according to a preset two-point distance formula, thus obtaining the diagonal distance between the two diagonal pixels in the pair.
[0039] A second aspect of the present invention discloses a planar segmentation device for rendering gradient multi-level planes in three dimensions, the device comprising:
[0040] The first image processing module is used to perform a preset first image processing on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion.
[0041] The second image processing module is used to perform second image processing on the first image processing result according to preset pixel grouping conditions, so as to obtain a second image processing result corresponding to the first image processing result. The second image processing includes three-dimensional projection and pixel grouping, and the second image processing result includes multiple triangular facets.
[0042] The third image processing module is used to perform third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets. The third image processing includes determining the vertices of each triangular facet, determining the intersection point between the plane containing each triangular facet and a preset cross section, and connecting the intersection points.
[0043] The fourth image processing module is used to perform fourth image processing on the non-triangular parts of the third image processing result according to the pixel grouping conditions, so as to obtain a fourth image processing result corresponding to the third image processing result. The fourth image processing includes segmentation processing, classification processing, and gradient color rendering. The fourth image processing result includes a target rendered image corresponding to the target image.
[0044] As an optional implementation, in a second aspect of the present invention, the second image processing module performs second image processing on the first image processing result according to preset pixel grouping conditions to obtain a second image processing result corresponding to the first image processing result. Specifically, this includes:
[0045] A three-dimensional model is constructed, and a three-dimensional coordinate system matching the three-dimensional model is established; the first image processing result includes a grayscale image corresponding to the target image, and the three-dimensional coordinate system has the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis; the first axis and the second axis are on the same base plane, and the third axis is perpendicular to the base plane;
[0046] The first image processing result is projected onto the three-dimensional coordinate system to obtain a three-dimensional projection result corresponding to the first image processing result; the three-dimensional projection result is composed of multiple three-dimensional pixels; the three-dimensional projection result includes a three-dimensional projection image corresponding to the grayscale image and a two-dimensional perspective image, the two-dimensional perspective image being obtained by projecting all the three-dimensional pixels onto the base plane;
[0047] For all the three-dimensional pixels in the two-dimensional view image, pixel division is performed to obtain multiple quadrilaterals. Each quadrilateral is composed of four three-dimensional pixels, and all the quadrilaterals do not overlap.
[0048] For each quadrilateral, calculate the diagonal distance between any two diagonal pixels in the quadrilateral, and select a target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to a preset pixel grouping requirement. Connect the two diagonal pixels corresponding to the target diagonal distance to obtain the diagonal connection result corresponding to the quadrilateral. The diagonal pixels are the three-dimensional pixels located at the diagonal positions in any quadrilateral.
[0049] The diagonal connection results corresponding to all the quadrilaterals are determined as the second image processing result corresponding to the first image processing result.
[0050] As an optional implementation, in a second aspect of the present invention, the method by which the second image processing module selects the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to preset pixel grouping requirements specifically includes:
[0051] Based on the grayscale value corresponding to each diagonal pixel, the pixel attribute of the diagonal pixel is determined. The pixel attribute includes a negative value attribute or a positive value attribute. When the pixel attribute of the diagonal pixel is a negative value attribute, the diagonal pixel is below the base plane in the three-dimensional projection image. When the pixel attribute of the diagonal pixel is a positive value attribute, the diagonal pixel is in or above the base plane in the three-dimensional projection image.
[0052] Two diagonal pixels with the same pixel attributes in the quadrilateral are defined as a first pixel pair, and two diagonal pixels with different pixel attributes in the quadrilateral are defined as a second pixel pair; and the quadrilateral includes a first diagonal distance and a second diagonal distance;
[0053] When the quadrilateral satisfies the preset first grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance;
[0054] When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined to be the target diagonal distance;
[0055] Specifically, the quadrilateral satisfies the first grouping condition by simultaneously containing both the first pixel pair and the second pixel pair; the second grouping condition is the opposite of the first grouping condition.
[0056] As an optional implementation, in a second aspect of the invention, the third image processing module performs third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets, specifically including:
[0057] Determine the target cross section and its corresponding plane equation, wherein the target cross section is the base plane or a plane parallel to the base plane;
[0058] For each of the triangular facets in the second image processing result, the vertex coordinates corresponding to each triangle vertex in the triangular facet are determined according to the set fixed-point function;
[0059] Based on the plane equation and the vertex coordinates corresponding to each of the triangle vertices in the triangular facet, the coordinates of the two target intersection points between the target cross section and the triangular facet are calculated. Then, the two target intersection points are connected to obtain the intersection point connection result corresponding to the triangular facet.
[0060] The connection results of the intersection points corresponding to all the triangle facets and all the target intersection points are determined as the third image processing result.
[0061] As an optional implementation, in the second aspect of the present invention, the fourth image processing module performs fourth image processing on the non-triangular portions of the third image processing result according to the pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result, specifically including:
[0062] For the non-triangular parts in the third image processing result, segmentation processing is performed according to the pixel grouping conditions until it is determined that the third image processing result is composed of the triangular facets, and a segmentation processing result corresponding to the third image processing result is obtained.
[0063] For all the triangular facets in the segmentation result, based on the target cross section, each triangular facet above the target cross section is divided into a first facet, and each triangular facet below the target cross section is divided into a second facet;
[0064] Generate multiple first closed surfaces based on all the first surfaces, generate multiple second closed surfaces based on all the second surfaces, and determine all the first closed surfaces and all the second closed surfaces as target closed surfaces;
[0065] According to the preset rendering method, gradient color rendering is performed on each of the target closed surfaces to obtain the gradient color rendering result corresponding to each of the target closed surfaces, which is used as the fourth image processing result.
[0066] As an optional implementation, in the second aspect of the present invention, the fourth image processing module performs gradient color rendering on each of the target closed surfaces according to a preset rendering method, and obtains a gradient color rendering result corresponding to each of the target closed surfaces in a specific manner including:
[0067] Obtain the two-dimensional projection of each target closed surface on the base plane, the two-dimensional projection of the surface includes a first sub-surface projection corresponding to each first closed surface and a second sub-surface projection corresponding to each second closed surface;
[0068] According to the preset first color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each of the first sub-surface projections to obtain the first rendering result corresponding to each of the first sub-surface projections;
[0069] According to the preset second color system, with the counterclockwise direction as the rendering direction, the gradient color rendering is performed on each second sub-surface projection to obtain the second rendering result corresponding to each second sub-surface projection;
[0070] All the first rendering results and all the second rendering results are determined as gradient color rendering results.
[0071] As an optional implementation, in a second aspect of the present invention, the method by which the second image processing module calculates the diagonal distance between any two diagonal pixels in each quadrilateral specifically includes:
[0072] For each quadrilateral, determine the three-dimensional coordinates corresponding to each three-dimensional pixel in the quadrilateral, and at the same time, determine two three-dimensional pixels in the quadrilateral that are located at opposite corners as a pair of diagonal pixels, and each pair of diagonal pixels includes two diagonal pixels.
[0073] For each pair of diagonal pixels in each quadrilateral, the distance between the two diagonal pixels in the pair is calculated according to a preset two-point distance formula, thus obtaining the diagonal distance between the two diagonal pixels in the pair.
[0074] A third aspect of the present invention discloses another planar segmentation device for rendering gradient multi-level planes in three dimensions, the device comprising:
[0075] Memory containing executable program code;
[0076] A processor coupled to the memory;
[0077] The processor calls the executable program code stored in the memory to execute the planar segmentation method for three-dimensional rendering of gradient multi-level planes disclosed in the first aspect of the present invention.
[0078] The fourth aspect of the present invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the planar segmentation method for three-dimensional rendering of gradient multi-level planes disclosed in the first aspect of the present invention.
[0079] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0080] This invention provides a planar segmentation method for three-dimensional rendering of gradient multi-level planes. The method includes: performing a preset first image processing on an acquired target image to obtain a first image processing result corresponding to the target image, wherein the first image processing includes at least grayscale conversion; performing a second image processing on the first image processing result according to preset pixel grouping conditions to obtain a second image processing result corresponding to the first image processing result, wherein the second image processing includes three-dimensional projection and pixel grouping, and the second image processing result includes multiple triangular facets; performing a third image processing on each triangular facet in the second image processing result to obtain a third image processing result corresponding to all triangular facets, wherein the third image processing includes determining the vertices of each triangular facet, determining the intersection points between the plane containing each triangular facet and a preset cross section, and connecting the intersection points; performing a fourth image processing on the non-triangular parts in the third image processing result according to pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result, wherein the fourth image processing includes segmentation processing, classification processing, and gradient color rendering; and the fourth image processing result includes a target rendered image corresponding to the target image. As can be seen, by implementing this invention, after acquiring the target image to be processed, the target image can be automatically converted into a grayscale image, thereby removing color interference present in the target image and reducing the amount of data processing required for the target image, which is beneficial to improving the computational efficiency when processing the target image in subsequent steps. Then, the first image processing result is rendered in three dimensions through a set three-dimensional projection. Compared with operating directly on a two-dimensional image, using three-dimensional processing technology has higher image processing efficiency and better image processing effect. Simultaneously, pixel grouping is set to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to pixel grouping) in the three-dimensional model can further refine the surface structure of the three-dimensional model corresponding to the second image processing, and also helps to optimize the storage and rendering process of the three-dimensional model, further improving the three-dimensional... The model's processing efficiency is improved. Then, using a preset cross-section as a reference, the intersection points of each triangular facet in the second image processing result are determined and connected. Through the set third image processing, the boundary points on the segmentation plane (preset cross-section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on the triangular facets of different categories, improving the accuracy of subsequent image processing of different categories of triangular facets. Finally, through the set segmentation processing, classification processing, and gradient color rendering, multi-layered custom gradient effects can be generated using a very small amount of vertex space without changing the real-time rendering gradient colors and the three-dimensional shape of each triangular facet, improving the flexibility and accuracy of obtaining multi-level gradient images. Attached Figure Description
[0081] To more clearly illustrate the technical solutions in the embodiments of the present invention, 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 the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0082] Figure 1 This is a flowchart illustrating a planar segmentation method for three-dimensional rendering of gradient multi-level planes disclosed in an embodiment of the present invention;
[0083] Figure 2 This is a flowchart illustrating another method for plane segmentation in three-dimensional rendering of gradient multi-level planes disclosed in an embodiment of the present invention.
[0084] Figure 3 This is a schematic diagram of the structure of a planar segmentation device for three-dimensional rendering of gradient multi-level planes disclosed in an embodiment of the present invention;
[0085] Figure 4 This is a schematic diagram of another planar segmentation device for three-dimensional rendering of gradient multi-level planes disclosed in an embodiment of the present invention;
[0086] Figure 5 This is a schematic diagram illustrating the operational effect of a second image processing method disclosed in an embodiment of the present invention;
[0087] Figure 6 This is a schematic diagram illustrating the operational effect of another second image processing method disclosed in an embodiment of the present invention;
[0088] Figure 7 This is a schematic diagram of the two-dimensional and three-dimensional effects of the segmentation processing result corresponding to the third image processing result disclosed in an embodiment of the present invention;
[0089] Figure 8 This is a schematic diagram of two-dimensional and three-dimensional effects corresponding to a target closed surface disclosed in an embodiment of the present invention;
[0090] Figure 9 This is a schematic diagram of the operation of performing gradient color rendering on each target closed surface disclosed in an embodiment of the present invention. Detailed Implementation
[0091] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0092] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.
[0093] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0094] This invention discloses a planar segmentation method and apparatus for three-dimensional rendering of gradient multi-level planes. After acquiring the target image to be processed, the method automatically converts the target image into a grayscale image to remove color interference and reduce the amount of data processing required for the target image, thereby improving the computational efficiency of subsequent target image processing. Then, a three-dimensional projection is used to realize the three-dimensional representation of the first image processing result. Compared with direct operation on a two-dimensional image, the three-dimensional processing technology has higher image processing efficiency and better image processing effect. Simultaneously, pixel grouping is set to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to pixel grouping) in the three-dimensional model can further refine the surface structure of the three-dimensional model corresponding to the second image processing, and also helps to optimize the storage and rendering process of the three-dimensional model. The process further improves the model processing efficiency of the 3D model. Then, using a preset cross-section as a reference, the intersection points of each triangular facet in the second image processing result are determined and connected. Through a set third image processing step, the boundary points on the segmentation plane (preset cross-section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on groups of triangular facets of different categories, improving the accuracy of subsequent image processing of different categories of triangular facets. Finally, through the set segmentation processing, classification processing, and gradient color rendering, multi-layered custom gradient effects can be generated using a very small amount of vertex space without changing the real-time rendering gradient colors and the 3D shape of each triangular facet, improving the flexibility and accuracy of obtaining multi-level gradient images. These are explained in detail below.
[0095] Example 1
[0096] Please see Figure 1 , Figure 1 This is a flowchart illustrating a planar segmentation method for three-dimensional rendering of gradient multi-level planes disclosed in an embodiment of the present invention. Figure 1 The described planar segmentation method for 3D rendering of gradient multi-level planes can be applied to planar segmentation devices for 3D rendering of gradient multi-level planes, and the embodiments of the present invention are not limited thereto. Figure 1 As shown, the planar segmentation method for 3D rendering gradient multi-level planes can include the following operations:
[0097] 101. Perform a preset first image processing on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion.
[0098] In this embodiment of the invention, before performing a preset first image processing on the acquired target image in step 101, the method further includes:
[0099] Determine whether the target image is a grayscale image. If the determination result is no, trigger step 101. If the determination result is yes, update the target image to the first image processing result and trigger step 102.
[0100] In this embodiment of the invention, when the processing space corresponding to the target image is RGB space, the grayscale conversion formula corresponding to the grayscale conversion is specifically as follows:
[0101] G = 0.299·I r +0.587·I g +0.114·I b
[0102] Among them, I r I g I b These are the R, G, and B channel images in the RGB space, respectively, with G corresponding to the grayscale image after grayscale conversion of the target image.
[0103] When the processing space corresponding to the target image is YUV space, the grayscale conversion formula is as follows:
[0104] G = I_y
[0105] Where I_y is the Y channel in the YUV space.
[0106] 102. Based on the preset pixel grouping conditions, perform second image processing on the first image processing result to obtain the second image processing result corresponding to the first image processing result.
[0107] In this embodiment of the invention, the second image processing includes three-dimensional projection and pixel grouping, and the second image processing result includes multiple triangular facets.
[0108] 103. Perform third image processing on each triangular facet in the second image processing result to obtain the third image processing result corresponding to all triangular facets.
[0109] In this embodiment of the invention, the third image processing includes determining the vertices of each triangular facet, determining the intersection points between the plane containing each triangular facet and a preset cross section, and connecting the intersection points;
[0110] 104. For the non-triangular parts in the third image processing result, perform the fourth image processing according to the pixel grouping conditions to obtain the fourth image processing result corresponding to the third image processing result.
[0111] In this embodiment of the invention, the fourth image processing includes segmentation processing, classification processing, and gradient color rendering; the result of the fourth image processing includes a target rendered image corresponding to the target image.
[0112] It is evident that implementation Figure 1 The described planar segmentation method for 3D rendering with gradient multi-level planes automatically converts the target image to grayscale after acquisition, removing color interference and reducing the amount of data processing required, thus improving computational efficiency in subsequent target image processing. Then, a 3D projection is used to realize the 3D representation of the first image processing result. Compared to direct manipulation on a 2D image, 3D processing technology offers higher image processing efficiency and better image processing effects. Furthermore, pixel grouping is used to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to pixel grouping) in the 3D model further refines the surface structure of the 3D model corresponding to the second image processing, and also optimizes the storage and rendering process of the 3D model. The process first improves the efficiency of model processing for the 3D model. Then, using a preset cross-section as a reference, the intersection points of each triangular facet in the second image processing result are determined and connected. Through the set third image processing, the boundary points on the segmentation plane (preset cross-section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on the triangular facets of different categories, which improves the accuracy of subsequent image processing of triangular facets of different categories. Finally, through the set segmentation processing, classification processing and gradient color rendering, multi-layered custom gradient effects can be generated by using a very small amount of vertex space without changing the real-time rendering gradient color of each triangular facet and the 3D shape of the curved surface. This improves the flexibility and accuracy of processing and rendering multi-level gradient images.
[0113] In an optional embodiment, step 102, which involves performing second image processing on the first image processing result according to preset pixel grouping conditions to obtain the second image processing result corresponding to the first image processing result, specifically includes:
[0114] Construct a 3D model, and then establish a 3D coordinate system that matches the 3D model; the first image processing result includes a grayscale image corresponding to the target image. The 3D coordinate system has the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis; the first axis and the second axis are on the same base plane, and the third axis is perpendicular to the base plane;
[0115] The first image processing result is projected onto a three-dimensional coordinate system to obtain a three-dimensional projection result corresponding to the first image processing result; the three-dimensional projection result consists of multiple three-dimensional pixels; the three-dimensional projection result includes a three-dimensional projection image corresponding to the grayscale image and a two-dimensional view image, which is obtained by projecting all three-dimensional pixels onto a base plane;
[0116] For all three-dimensional pixels in a two-dimensional image, perform pixel partitioning to obtain multiple quadrilaterals. Each quadrilateral is composed of four three-dimensional pixels, and all quadrilaterals do not overlap.
[0117] For each quadrilateral, calculate the diagonal distance between any two diagonal pixels in the quadrilateral, and select the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to the preset pixel grouping requirements. Connect the two diagonal pixels corresponding to the target diagonal distance as the diagonal connection result corresponding to the quadrilateral. The diagonal pixels are the three-dimensional pixels located at the diagonal positions in any quadrilateral.
[0118] The result of connecting the diagonals of all quadrilaterals is determined as the second image processing result corresponding to the first image processing result.
[0119] In this optional embodiment, the aforementioned three-dimensional coordinate system uses the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis. In practical applications, the length of the grayscale image is used as the x-axis, the width of the grayscale image as the y-axis, and the grayscale value of the grayscale image as the z-axis. Correspondingly, the base plane refers to the plane with a z-axis coordinate of 0 in the three-dimensional coordinate system.
[0120] In this optional embodiment, please refer to Figure 5 , Figure 5 This is a schematic diagram illustrating the operation effect of a second image processing method disclosed in an embodiment of the present invention. The above-described method performs pixel division on all three-dimensional pixels in a two-dimensional image, resulting in multiple quadrilaterals, as shown in the diagram. Figure 5As shown in the left-hand diagram; furthermore, by connecting the two diagonal pixels corresponding to the diagonal distance from the target, the final image processing result is shown in the diagram below. Figure 5 As shown in the diagram on the right.
[0121] In this optional embodiment, it should be noted that, Figure 5 In the attached diagrams on the left and right, the solid lines indicate areas within or above the foundation plane, while the dashed lines indicate areas below the foundation plane.
[0122] As can be seen, in this optional embodiment, the three-dimensional projection of the first image processing result is realized. Compared with operating directly on the two-dimensional image, the three-dimensional processing technology has higher image processing efficiency and better image processing effect. At the same time, the pixel grouping is set to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to the pixel grouping) in the three-dimensional model can further refine the surface structure of the three-dimensional model corresponding to the second image processing. It is also beneficial to optimize the storage and rendering process of the three-dimensional model, and further improve the model processing efficiency of the three-dimensional model.
[0123] In another optional embodiment, the method of selecting the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to preset pixel grouping requirements specifically includes:
[0124] Based on the grayscale value corresponding to each diagonal pixel, the pixel attribute of that diagonal pixel is determined. The pixel attribute includes negative or positive values. When the pixel attribute of a diagonal pixel is negative, the diagonal pixel is below the base plane in the 3D projection image; when the pixel attribute of a diagonal pixel is positive, the diagonal pixel is in or above the base plane in the 3D projection image.
[0125] Two diagonal pixels with the same pixel attributes in the quadrilateral are defined as the first pixel pair, and two diagonal pixels with different pixel attributes in the quadrilateral are defined as the second pixel pair; and the quadrilateral includes the first diagonal distance and the second diagonal distance;
[0126] When the quadrilateral satisfies the preset first grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance;
[0127] When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined as the target diagonal distance;
[0128] Specifically, the quadrilateral satisfies the first grouping condition by simultaneously having a first pixel pair and a second pixel pair; the second grouping condition is the opposite of the first grouping condition.
[0129] In this optional embodiment, specifically, corresponding to the foregoing description, in the three-dimensional coordinate system, when the pixel attribute of a diagonal pixel is a negative value, it indicates that the z-axis coordinate of the diagonal pixel is negative; when the pixel attribute of a diagonal pixel is a positive value, it indicates that the z-axis coordinate of the diagonal pixel is 0 or positive.
[0130] In this optional embodiment, it should be noted that when the quadrilateral satisfies the preset first grouping condition and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined as the target diagonal distance;
[0131] When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance.
[0132] In this optional embodiment, for the settings of the first grouping condition and the second grouping condition, please refer to [link / reference needed]. Figure 6 , Figure 6 This is a schematic diagram illustrating the operational effect of another second image processing method disclosed in an embodiment of the present invention, such as... Figure 6 As shown in the left figure, in the two-dimensional view plane, the first pixel pair BE and its corresponding first diagonal distance d are included. BE The second pixel pair AF and its corresponding second diagonal distance d AF At this point, the quadrilateral satisfies the preset first grouping condition, and the distance between the first diagonal is less than the distance between the second diagonal (corresponding to d). AF ≥d BE If the first diagonal distance d is selected, then... BE This represents the target diagonal distance. The case where a quadrilateral satisfies the second grouping condition is similar to the case where it satisfies the first grouping condition; please refer to [link / reference needed]. Figure 6 This will not be elaborated upon here.
[0133] As can be seen, in this optional embodiment, the pixel attributes of each diagonal pixel can be automatically determined based on the grayscale value of each diagonal pixel, and then the target diagonal distance can be accurately determined based on the different grouping conditions met by each quadrilateral, thereby improving the accuracy of determining the target diagonal distance and its corresponding group of diagonal pixels.
[0134] In this optional embodiment, the method for calculating the diagonal distance between any two diagonal pixels in each quadrilateral specifically includes:
[0135] For each quadrilateral, determine the three-dimensional coordinates of each three-dimensional pixel in the quadrilateral, and at the same time, determine two three-dimensional pixels at opposite corners of the quadrilateral as a pair of diagonal pixels, with each pair of diagonal pixels including two diagonal pixels.
[0136] For each pair of diagonal pixels in each quadrilateral, the distance between the two diagonal pixels in the pair is calculated according to the preset two-point distance formula, thus obtaining the diagonal distance between the two diagonal pixels in the pair.
[0137] In this optional embodiment, the formula for the distance between the two points is as follows:
[0138]
[0139] Where d is the diagonal distance between two diagonal pixels; and the pixel coordinates of a set of diagonal pixels are (x1, y1, z1) and (x2, y2, z2).
[0140] As can be seen, in this optional embodiment, the distance calculation formula introduced by this setting introduces the calculation of the gray value of the third dimension of the three-dimensional pixel, which improves the calculation accuracy of the distance between two three-dimensional pixels (diagonal pixels).
[0141] In yet another optional embodiment, the method of performing third image processing on each triangular facet in the second image processing result to obtain a third image processing result corresponding to all triangular facets specifically includes:
[0142] Determine the target cross section and its corresponding plane equation. The target cross section is the base plane or a plane parallel to the base plane.
[0143] For each triangular facet in the second image processing result, the vertex coordinates corresponding to each triangle vertex in the triangular facet are determined according to the set fixed-point function;
[0144] Based on the plane equation and the vertex coordinates of each triangle vertex in the triangular facet, the coordinates of the two target intersection points between the target section and the triangular facet are calculated. Then, the two target intersection points are connected to obtain the intersection point connection result corresponding to the triangular facet.
[0145] The result of connecting the intersection points of all triangular facets and determining all target intersection points is the third image processing result.
[0146] In this optional embodiment, the plane equation corresponding to the target cross-section is: α·x + β·y + γ·z + δ = 0, and the function F(x, y, z) = α·x + β·y + γ·z + δ is defined; point A = (x A y A , z A ), B=(xB, yB, zB), E=(x E y E , z E Then Q = (x) Q y Q, z Q ), R = (x R y R , z R ); where points A, B, and C are the three vertices of any triangular facet; Q and R are the intersection points of the triangular facet and the target cross section; α, β, γ, and δ in the plane equation are equation coefficients, which are calculated by combining the coordinates of three coplanar, non-collinear 3D pixel points selected in the actual application scenario with the plane equation.
[0147] Furthermore, the formula for calculating point Q among these two intersection points is as follows:
[0148]
[0149] The formula for calculating point R among these two intersection points is as follows:
[0150]
[0151] As can be seen, in this optional embodiment, based on the preset cross section, the intersection point determination and connection of each triangular facet in the second image processing result are performed. Through the set third image processing, the boundary points on the segmentation plane (preset cross section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on the triangular facets of different categories, which improves the accuracy of subsequent image processing of triangular facets of different categories.
[0152] Example 2
[0153] Please see Figure 2 , Figure 2 This is a flowchart illustrating another method for planar segmentation of a gradient multi-level plane in 3D rendering, as disclosed in an embodiment of the present invention. Figure 2 The described planar segmentation method for 3D rendering of gradient multi-level planes can be applied to planar segmentation devices for 3D rendering of gradient multi-level planes, and the embodiments of the present invention are not limited thereto. Figure 2 As shown, the planar segmentation method for 3D rendering gradient multi-level planes can include the following operations:
[0154] 201. Perform a preset first image processing on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion.
[0155] 202. Based on the preset pixel grouping conditions, perform second image processing on the first image processing result to obtain the second image processing result corresponding to the first image processing result.
[0156] 203. Perform third image processing on each triangular facet in the second image processing result to obtain the third image processing result corresponding to all triangular facets.
[0157] In this embodiment of the invention, the third image processing includes determining the vertices of each triangular facet, determining the intersection points between the plane containing each triangular facet and a preset cross section, and connecting the intersection points.
[0158] 204. For the non-triangular parts in the third image processing result, perform segmentation processing according to the pixel grouping conditions until it is determined that the third image processing result is composed of triangular facets, and obtain the segmentation processing result corresponding to the third image processing result.
[0159] In this embodiment of the invention, the third image processing result obtained through steps 201-203 is not directly processed to obtain a third image processing result that includes all triangular facets after performing triangular facet segmentation. Therefore, it is necessary to set up this segmentation process step to convert all polygons in the third image processing result into triangular facets that are easier to process later.
[0160] In the embodiments of this invention, please refer to Figure 7 , Figure 7 This is a schematic diagram of the two-dimensional and three-dimensional effects of the segmentation processing result corresponding to the third image processing result disclosed in an embodiment of the present invention, as shown below. Figure 7 As shown, Figure 7 The left side of the middle section shows a two-dimensional representation of the segmentation result. Figure 7 The image on the right side of the middle section shows the 3D rendering of the segmentation result.
[0161] 205. For all triangular facets in the segmentation result, using the target cross section as a reference, each triangular facet above the target cross section is divided into a first facet, and each triangular facet below the target cross section is divided into a second facet.
[0162] 206. Generate multiple first closed surfaces based on all first surfaces, generate multiple second closed surfaces based on all second surfaces, and determine all first closed surfaces and all second closed surfaces as target closed surfaces.
[0163] In the embodiments of this invention, please refer to Figure 8 , Figure 8 This is a schematic diagram of the two-dimensional and three-dimensional effects corresponding to a target closed surface disclosed in an embodiment of the present invention; as shown below. Figure 8 As shown, Figure 8 The two pictures above Figure 8 The image on the lower right shows the 2D rendering of all target closed surfaces. Figure 8 The image on the lower left shows a 3D rendering of all target closed surfaces.
[0164] 207. According to the preset rendering method, perform gradient color rendering on each target closed surface to obtain the gradient color rendering result corresponding to each target closed surface, which is used as the fourth image processing result.
[0165] For further descriptions of steps 201-203 in this embodiment of the invention, please refer to the other specific descriptions of steps 101-103 in Embodiment 1. These descriptions will not be repeated in this embodiment of the invention.
[0166] It is evident that implementation Figure 2 The described planar segmentation method for rendering multi-level gradient planes in 3D, through segmentation processing, classification processing, and gradient color rendering, can generate multi-layered custom gradient effects by using a very small amount of vertex space without changing the real-time rendering gradient colors of individual triangle faces or the 3D shape of curved surfaces. This improves the flexibility and accuracy of the rendered multi-level gradient images.
[0167] In an optional embodiment, see [link to relevant documentation] Figure 9 , Figure 9 This is a schematic diagram illustrating the operation of performing gradient color rendering on each target closed surface as disclosed in an embodiment of the present invention; for example... Figure 9 As shown, the method described above, which performs gradient color rendering on each target closed surface according to a preset rendering method to obtain the gradient color rendering result corresponding to each target closed surface, specifically includes:
[0168] Obtain the two-dimensional projection of each target closed surface on the base plane. The two-dimensional projection includes the first sub-surface projection corresponding to each first closed surface and the second sub-surface projection corresponding to each second closed surface.
[0169] According to the preset first color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each first sub-surface projection to obtain the first rendering result corresponding to each first sub-surface projection;
[0170] According to the preset second color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each second sub-surface projection to obtain the second rendering result corresponding to each second sub-surface projection;
[0171] All first rendering results and all second rendering results are determined as gradient color rendering results.
[0172] As can be seen, in this optional embodiment, by setting segmentation processing, classification processing, and gradient color rendering, it is possible to generate multi-layered custom gradient effects by using a very small amount of vertex space without changing the real-time rendering gradient colors of individual triangle faces and the three-dimensional shape of the curved surface. This improves the flexibility and accuracy of processing and rendering multi-level gradient images.
[0173] Example 3
[0174] Please see Figure 3 , Figure 3 This is a schematic diagram of a planar segmentation device for rendering a multi-level gradient plane in three-dimensional rendering, as disclosed in an embodiment of the present invention. The planar segmentation device can be a planar segmentation terminal, equipment, system, or server for rendering a multi-level gradient plane in three-dimensional rendering. The server can be a local server, a remote server, or a cloud server (also known as a cloud-based server). When the server is not a cloud server, it can communicate with the cloud server; this embodiment of the present invention does not impose any limitations. Figure 3 As shown, the planar segmentation device for rendering gradient multi-level planes in 3D rendering may include a first image processing module 301, a second image processing module 302, a third image processing module 303, and wherein:
[0175] The first image processing module 301 is used to perform a preset first image processing on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion.
[0176] The second image processing module 302 is used to perform second image processing on the first image processing result according to the preset pixel grouping conditions, so as to obtain a second image processing result corresponding to the first image processing result. The second image processing includes three-dimensional projection and pixel grouping, and the second image processing result includes multiple triangular facets.
[0177] The third image processing module 303 is used to perform third image processing on each triangular facet in the second image processing result to obtain a third image processing result corresponding to all triangular facets. The third image processing includes determining the vertices of each triangular facet, determining the intersection point between the plane containing each triangular facet and the preset cross section, and connecting the intersection points.
[0178] The fourth image processing module 304 is used to perform fourth image processing on the non-triangular parts of the third image processing result according to the pixel grouping conditions, so as to obtain the fourth image processing result corresponding to the third image processing result. The fourth image processing includes segmentation processing, classification processing and gradient color rendering; the fourth image processing result includes the target rendering image corresponding to the target image.
[0179] It is evident that implementation Figure 3The described 3D rendering gradient multi-level plane segmentation device, after acquiring the target image to be processed, can automatically convert the target image into a grayscale image, thereby removing color interference in the target image and reducing the amount of data processing required for the target image, which is beneficial to improving the computational efficiency of subsequent target image processing. Then, through a set 3D projection, the first image processing result is rendered in 3D. Compared with operating directly on a 2D image, using 3D processing technology has higher image processing efficiency and better image processing effect. Simultaneously, pixel grouping is set to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to pixel grouping) in the 3D model can further refine the surface structure of the 3D model corresponding to the second image processing, and also helps to optimize the storage and rendering process of the 3D model. The process first improves the efficiency of model processing for the 3D model. Then, using a preset cross-section as a reference, the intersection points of each triangular facet in the second image processing result are determined and connected. Through the set third image processing, the boundary points on the segmentation plane (preset cross-section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on the triangular facets of different categories, which improves the accuracy of subsequent image processing of triangular facets of different categories. Finally, through the set segmentation processing, classification processing and gradient color rendering, multi-layered custom gradient effects can be generated by using a very small amount of vertex space without changing the real-time rendering gradient color of each triangular facet and the 3D shape of the curved surface. This improves the flexibility and accuracy of processing and rendering multi-level gradient images.
[0180] In an optional embodiment, the second image processing module 302 performs second image processing on the first image processing result according to preset pixel grouping conditions, and the specific method for obtaining the second image processing result corresponding to the first image processing result includes:
[0181] Construct a 3D model, and then establish a 3D coordinate system that matches the 3D model; the first image processing result includes a grayscale image corresponding to the target image. The 3D coordinate system has the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis; the first axis and the second axis are on the same base plane, and the third axis is perpendicular to the base plane;
[0182] The first image processing result is projected onto a three-dimensional coordinate system to obtain a three-dimensional projection result corresponding to the first image processing result; the three-dimensional projection result consists of multiple three-dimensional pixels; the three-dimensional projection result includes a three-dimensional projection image corresponding to the grayscale image and a two-dimensional view image, which is obtained by projecting all three-dimensional pixels onto a base plane;
[0183] For all three-dimensional pixels in a two-dimensional image, perform pixel partitioning to obtain multiple quadrilaterals. Each quadrilateral is composed of four three-dimensional pixels, and all quadrilaterals do not overlap.
[0184] For each quadrilateral, calculate the diagonal distance between any two diagonal pixels in the quadrilateral, and select the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to the preset pixel grouping requirements. Connect the two diagonal pixels corresponding to the target diagonal distance as the diagonal connection result corresponding to the quadrilateral. The diagonal pixels are the three-dimensional pixels located at the diagonal positions in any quadrilateral.
[0185] The result of connecting the diagonals of all quadrilaterals is determined as the second image processing result corresponding to the first image processing result.
[0186] As can be seen, in this optional embodiment, the three-dimensional projection of the first image processing result is realized. Compared with operating directly on the two-dimensional image, the three-dimensional processing technology has higher image processing efficiency and better image processing effect. At the same time, the pixel grouping is set to process the first image processing result into multiple triangular facets. Performing triangle grouping (corresponding to the pixel grouping) in the three-dimensional model can further refine the surface structure of the three-dimensional model corresponding to the second image processing. It is also beneficial to optimize the storage and rendering process of the three-dimensional model, and further improve the model processing efficiency of the three-dimensional model.
[0187] In another optional embodiment, the second image processing module 302 selects the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to preset pixel grouping requirements, specifically including:
[0188] Based on the grayscale value corresponding to each diagonal pixel, the pixel attribute of that diagonal pixel is determined. The pixel attribute includes negative or positive values. When the pixel attribute of a diagonal pixel is negative, the diagonal pixel is below the base plane in the 3D projection image; when the pixel attribute of a diagonal pixel is positive, the diagonal pixel is in or above the base plane in the 3D projection image.
[0189] Two diagonal pixels with the same pixel attributes in the quadrilateral are defined as the first pixel pair, and two diagonal pixels with different pixel attributes in the quadrilateral are defined as the second pixel pair; and the quadrilateral includes the first diagonal distance and the second diagonal distance;
[0190] When the quadrilateral satisfies the preset first grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance;
[0191] When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined as the target diagonal distance;
[0192] Specifically, the quadrilateral satisfies the first grouping condition by simultaneously having a first pixel pair and a second pixel pair; the second grouping condition is the opposite of the first grouping condition.
[0193] As can be seen, in this optional embodiment, the pixel attributes of each diagonal pixel can be automatically determined based on the grayscale value of each diagonal pixel, and then the target diagonal distance can be accurately determined based on the different grouping conditions met by each quadrilateral, thereby improving the accuracy of determining the target diagonal distance and its corresponding group of diagonal pixels.
[0194] In this optional embodiment, the second image processing module 302 calculates the diagonal distance between any two diagonal pixels in each quadrilateral in the following specific ways:
[0195] For each quadrilateral, determine the three-dimensional coordinates of each three-dimensional pixel in the quadrilateral, and at the same time, determine two three-dimensional pixels at opposite corners of the quadrilateral as a pair of diagonal pixels, with each pair of diagonal pixels including two diagonal pixels.
[0196] For each pair of diagonal pixels in each quadrilateral, the distance between the two diagonal pixels in the pair is calculated according to the preset two-point distance formula, thus obtaining the diagonal distance between the two diagonal pixels in the pair.
[0197] As can be seen, in this optional embodiment, the distance calculation formula introduced by this setting introduces the calculation of the gray value of the third dimension of the three-dimensional pixel, which improves the calculation accuracy of the distance between two three-dimensional pixels (diagonal pixels).
[0198] In another optional embodiment, the third image processing module 303 performs third image processing on each triangular facet in the second image processing result to obtain the third image processing result corresponding to all triangular facets. Specifically, this includes:
[0199] Determine the target cross section and its corresponding plane equation. The target cross section is the base plane or a plane parallel to the base plane.
[0200] For each triangular facet in the second image processing result, the vertex coordinates corresponding to each triangle vertex in the triangular facet are determined according to the set fixed-point function;
[0201] Based on the plane equation and the vertex coordinates of each triangle vertex in the triangular facet, the coordinates of the two target intersection points between the target section and the triangular facet are calculated. Then, the two target intersection points are connected to obtain the intersection point connection result corresponding to the triangular facet.
[0202] The result of connecting the intersection points of all triangular facets and determining all target intersection points is the third image processing result.
[0203] As can be seen, in this optional embodiment, based on the preset cross section, the intersection point determination and connection of each triangular facet in the second image processing result are performed. Through the set third image processing, the boundary points on the segmentation plane (preset cross section) are supplemented, thereby generating triangular facets of different categories on both sides of the plane (corresponding to the third image processing result). Then, precise matching processing is performed on the triangular facets of different categories, which improves the accuracy of subsequent image processing of triangular facets of different categories.
[0204] In another optional embodiment, the fourth image processing module 304 performs fourth image processing on the non-triangular portions of the third image processing result according to pixel grouping conditions, and obtains the fourth image processing result corresponding to the third image processing result in the following specific ways:
[0205] For the non-triangular parts in the third image processing result, segmentation processing is performed according to the pixel grouping conditions until it is determined that the third image processing result is composed of triangular facets, and the segmentation processing result corresponding to the third image processing result is obtained.
[0206] For all triangular facets in the segmentation result, based on the target cross section, each triangular facet above the target cross section is divided into a first facet, and each triangular facet below the target cross section is divided into a second facet.
[0207] Generate multiple first closed surfaces based on all first surfaces, generate multiple second closed surfaces based on all second surfaces, and determine all first closed surfaces and all second closed surfaces as target closed surfaces;
[0208] According to the preset rendering method, gradient color rendering is performed on each target closed surface to obtain the gradient color rendering result corresponding to each target closed surface, which is used as the fourth image processing result.
[0209] As can be seen, in this optional embodiment, by setting segmentation processing, classification processing, and gradient color rendering, it is possible to generate multi-layered custom gradient effects by using a very small amount of vertex space without changing the real-time rendering gradient colors of individual triangle faces and the three-dimensional shape of the curved surface. This improves the flexibility and accuracy of processing and rendering multi-level gradient images.
[0210] In this optional embodiment, the fourth image processing module 304 performs gradient color rendering on each target closed surface according to a preset rendering method, and the specific method for obtaining the gradient color rendering result corresponding to each target closed surface includes:
[0211] Obtain the two-dimensional projection of each target closed surface on the base plane. The two-dimensional projection includes the first sub-surface projection corresponding to each first closed surface and the second sub-surface projection corresponding to each second closed surface.
[0212] According to the preset first color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each first sub-surface projection to obtain the first rendering result corresponding to each first sub-surface projection;
[0213] According to the preset second color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each second sub-surface projection to obtain the second rendering result corresponding to each second sub-surface projection;
[0214] All first rendering results and all second rendering results are determined as gradient color rendering results.
[0215] As can be seen, in this optional embodiment, by setting segmentation processing, classification processing, and gradient color rendering, it is possible to generate multi-layered custom gradient effects by using a very small amount of vertex space without changing the real-time rendering gradient colors of individual triangle faces and the three-dimensional shape of the curved surface. This improves the flexibility and accuracy of processing and rendering multi-level gradient images.
[0216] Example 4
[0217] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of another planar segmentation device for three-dimensional rendering gradient multi-level planes disclosed in an embodiment of the present invention. Figure 5 As shown, the planar segmentation device for 3D rendering gradient multi-level planes may include:
[0218] Memory 401 storing executable program code;
[0219] Processor 402 coupled to memory 401;
[0220] The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the planar segmentation method for three-dimensional rendering of gradient multi-level planes described in Embodiment 1 or Embodiment 2 of the present invention.
[0221] Example 5
[0222] This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute the steps in the planar segmentation method for three-dimensional rendering of gradient multi-level planes described in Embodiment 1 or Embodiment 2 of this invention.
[0223] Example 6
[0224] This invention discloses a computer program product, which includes a non-transitory computer storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the planar segmentation method for rendering gradient multi-level planes in three-dimensional rendering as described in Embodiment 1 or Embodiment 2.
[0225] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0226] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0227] Finally, it should be noted that the planar segmentation method and apparatus for three-dimensional rendering of gradient multi-level planes disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for plane segmentation in 3D rendering of gradient multi-level planes, characterized in that, The method includes: A preset first image processing is performed on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion. According to preset pixel grouping conditions, the first image processing result is subjected to second image processing to obtain a second image processing result corresponding to the first image processing result. The second image processing includes three-dimensional projection and pixel grouping. The second image processing result includes multiple triangular facets. Perform third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets. The third image processing includes determining the vertices of each triangular facet, determining the intersection point between the plane containing each triangular facet and a preset cross section, and connecting the intersection points. For the non-triangular portion of the third image processing result, a fourth image processing is performed according to the pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result. The fourth image processing includes segmentation processing, classification processing, and gradient color rendering. The fourth image processing result includes a target rendered image corresponding to the target image.
2. The method of claim 1, wherein, The step of performing second image processing on the first image processing result according to preset pixel grouping conditions to obtain a second image processing result corresponding to the first image processing result includes: A three-dimensional model is constructed, and a three-dimensional coordinate system matching the three-dimensional model is established; the first image processing result includes a grayscale image corresponding to the target image, and the three-dimensional coordinate system has the length of the grayscale image as the first axis, the width of the grayscale image as the second axis, and the grayscale value of the grayscale image as the third axis; the first axis and the second axis are on the same base plane, and the third axis is perpendicular to the base plane; The first image processing result is projected onto the three-dimensional coordinate system to obtain a three-dimensional projection result corresponding to the first image processing result; the three-dimensional projection result is composed of multiple three-dimensional pixels; the three-dimensional projection result includes a three-dimensional projection image corresponding to the grayscale image and a two-dimensional perspective image, the two-dimensional perspective image being obtained by projecting all the three-dimensional pixels onto the base plane; For all the three-dimensional pixels in the two-dimensional view image, pixel division is performed to obtain multiple quadrilaterals. Each quadrilateral is composed of four three-dimensional pixels, and all the quadrilaterals do not overlap. For each quadrilateral, calculate the diagonal distance between any two diagonal pixels in the quadrilateral, and select a target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to a preset pixel grouping requirement. Connect the two diagonal pixels corresponding to the target diagonal distance to obtain the diagonal connection result corresponding to the quadrilateral. The diagonal pixels are the three-dimensional pixels located at the diagonal positions in any quadrilateral. The diagonal connection results corresponding to all the quadrilaterals are determined as the second image processing result corresponding to the first image processing result.
3. The method of claim 2, wherein the three-dimensional rendering of the planar section of the gradual multi-order planar surface is performed by: The step of selecting the target diagonal distance from the two diagonal distances corresponding to the quadrilateral according to the preset pixel grouping requirements includes: Based on the grayscale value corresponding to each diagonal pixel, the pixel attribute of the diagonal pixel is determined. The pixel attribute includes a negative value attribute or a positive value attribute. When the pixel attribute of the diagonal pixel is a negative value attribute, the diagonal pixel is below the base plane in the three-dimensional projection image. When the pixel attribute of the diagonal pixel is a positive value attribute, the diagonal pixel is in or above the base plane in the three-dimensional projection image. Two diagonal pixels with the same pixel attributes in the quadrilateral are defined as a first pixel pair, and two diagonal pixels with different pixel attributes in the quadrilateral are defined as a second pixel pair; and the quadrilateral includes a first diagonal distance and a second diagonal distance; When the quadrilateral satisfies the preset first grouping condition, and the first diagonal distance is greater than or equal to the second diagonal distance, the second diagonal distance is determined as the target diagonal distance; When the quadrilateral satisfies the preset second grouping condition, and the first diagonal distance is less than the second diagonal distance, the first diagonal distance is determined to be the target diagonal distance; Specifically, the quadrilateral satisfies the first grouping condition by simultaneously containing both the first pixel pair and the second pixel pair; the second grouping condition is the opposite of the first grouping condition.
4. The method of claim 2 or 3, wherein, The step of performing third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets includes: Determine the target cross section and its corresponding plane equation, wherein the target cross section is the base plane or a plane parallel to the base plane; For each of the triangular facets in the second image processing result, the vertex coordinates corresponding to each triangle vertex in the triangular facet are determined according to the set fixed-point function; Based on the plane equation and the vertex coordinates corresponding to each of the triangle vertices in the triangular facet, the coordinates of the two target intersection points between the target cross section and the triangular facet are calculated. Then, the two target intersection points are connected to obtain the intersection point connection result corresponding to the triangular facet. The connection results of the intersection points corresponding to all the triangle facets and all the target intersection points are determined as the third image processing result.
5. The planar segmentation method for three-dimensional rendering of gradient multi-level planes according to claim 4, characterized in that, The non-triangular portion of the third image processing result is processed according to the pixel grouping conditions to obtain a fourth image processing result corresponding to the third image processing result, including: For the non-triangular parts in the third image processing result, segmentation processing is performed according to the pixel grouping conditions until it is determined that the third image processing result is composed of the triangular facets, and a segmentation processing result corresponding to the third image processing result is obtained. For all the triangular facets in the segmentation result, based on the target cross section, each triangular facet above the target cross section is divided into a first facet, and each triangular facet below the target cross section is divided into a second facet; Generate multiple first closed surfaces based on all the first surfaces, generate multiple second closed surfaces based on all the second surfaces, and determine all the first closed surfaces and all the second closed surfaces as target closed surfaces; According to the preset rendering method, gradient color rendering is performed on each of the target closed surfaces to obtain the gradient color rendering result corresponding to each of the target closed surfaces, which is used as the fourth image processing result.
6. The method of claim 5, wherein the three-dimensional rendering of the planar partitioning of the gradual multi-order planar surface is performed by: The step of performing gradient color rendering on each of the target closed surfaces according to a preset rendering method to obtain a gradient color rendering result corresponding to each of the target closed surfaces includes: Obtain the two-dimensional projection of each target closed surface on the base plane, the two-dimensional projection of the surface includes a first sub-surface projection corresponding to each first closed surface and a second sub-surface projection corresponding to each second closed surface; According to the preset first color system, with the counterclockwise direction as the rendering direction, gradient color rendering is performed on each of the first sub-surface projections to obtain the first rendering result corresponding to each of the first sub-surface projections; According to the preset second color system, with the counterclockwise direction as the rendering direction, the gradient color rendering is performed on each second sub-surface projection to obtain the second rendering result corresponding to each second sub-surface projection; All the first rendering results and all the second rendering results are determined as gradient color rendering results.
7. The method of claim 2 or 3, wherein, For each quadrilateral, the calculation of the diagonal distance between any two diagonal pixels in the quadrilateral includes: For each quadrilateral, determine the three-dimensional coordinates corresponding to each three-dimensional pixel in the quadrilateral, and at the same time, determine two three-dimensional pixels in the quadrilateral that are located at opposite corners as a pair of diagonal pixels, and each pair of diagonal pixels includes two diagonal pixels. For each pair of diagonal pixels in each quadrilateral, the distance between the two diagonal pixels in the pair is calculated according to a preset two-point distance formula, thus obtaining the diagonal distance between the two diagonal pixels in the pair.
8. A planar segmentation device for rendering gradient multi-level planes in three-dimensional rendering, characterized in that, The device includes: The first image processing module is used to perform a preset first image processing on the acquired target image to obtain a first image processing result corresponding to the target image. The first image processing includes at least grayscale conversion. The second image processing module is used to perform second image processing on the first image processing result according to preset pixel grouping conditions, so as to obtain a second image processing result corresponding to the first image processing result. The second image processing includes three-dimensional projection and pixel grouping, and the second image processing result includes multiple triangular facets. The third image processing module is used to perform third image processing on each of the triangular facets in the second image processing result to obtain a third image processing result corresponding to all the triangular facets. The third image processing includes determining the vertices of each triangular facet, determining the intersection point between the plane containing each triangular facet and a preset cross section, and connecting the intersection points. The fourth image processing module is used to perform fourth image processing on the non-triangular parts of the third image processing result according to the pixel grouping conditions, so as to obtain a fourth image processing result corresponding to the third image processing result. The fourth image processing includes segmentation processing, classification processing, and gradient color rendering. The fourth image processing result includes a target rendered image corresponding to the target image.
9. A planar segmentation device for rendering gradient multi-level planes in three-dimensional rendering, characterized in that, The device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the planar segmentation method for three-dimensional rendering of gradient multi-level planes as described in any one of claims 1-7.
10. A computer storage medium, characterized in that The computer storage medium stores computer instructions, which, when invoked, are used to execute the planar segmentation method for three-dimensional rendering of gradient multi-level planes as described in any one of claims 1-7.
Citation Information
Patent Citations
Reconstruction method of two-dimensional tangent plane of three-dimensional model, mobile terminal and electronic equipment
CN110458949A
Image rendering method and device
CN112184575A