Image dimension conversion method
By determining the target pixel information and three-dimensional pixel point coordinates of the two-dimensional image, connecting and stacking to form a three-dimensional image, the problem of inaccurate two-dimensional image conversion in the prior art is solved, and efficient and accurate three-dimensional image generation is achieved.
Patent Information
- Application Number
- CN202411062455.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-11-26
AI Technical Summary
In the prior art, the conversion of two-dimensional images to three-dimensional images requires manual calibration, which is time-consuming and labor-intensive and easily overlooks details, resulting in inaccurate conversion.
By acquiring the two-dimensional image and the expected three-dimensional image thickness, the target pixel information and the three-dimensional pixel point coordinates are determined, and the plane figures are connected to form and stacked to achieve the conversion of two-dimensional image to three-dimensional image.
It improves the efficiency and accuracy of image dimension conversion, reduces the time and errors of artificial calibration, and ensures the detail fidelity of the three-dimensional image.
Smart Images

Figure CN119027306A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing technology, and in particular to an image dimension conversion method. Background Art
[0002] With the development of technology, three-dimensional images can display more image details than two-dimensional images, and at the same time allow users to more intuitively experience the three-dimensional patterns in three-dimensional images.
[0003] At present, all the plane patterns in the two-dimensional image to be converted are usually calibrated manually, and the plane patterns are rotated along the generatrix to obtain a three-dimensional image.
[0004] However, this method of manually calibrating and rotating to determine the three-dimensional image requires manual calibration, which is time-consuming and labor-intensive, and there is also the possibility of inaccurate calibration. In addition, obtaining a three-dimensional image by rotation will ignore some details in the plane pattern during the rotation process, and it is impossible to obtain an accurate three-dimensional image corresponding to the two-dimensional image. Summary of the invention
[0005] The embodiment of the present invention provides an image dimension conversion method to accurately and conveniently convert a two-dimensional image into a three-dimensional image, thereby improving the efficiency and accuracy of image dimension conversion.
[0006] In a first aspect, an embodiment of the present invention provides an image dimension conversion method, including:
[0007] Acquire a target two-dimensional image to be converted and an expected three-dimensional image thickness; the expected three-dimensional image thickness is a thickness value in a preset direction of a target coordinate system;
[0008] Determine target pixel information of a target pattern in the target two-dimensional image, and determine target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information;
[0009] Determining target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates;
[0010] By connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates, a plurality of plane figures corresponding to the target pattern are obtained;
[0011] A target three-dimensional image corresponding to the target two-dimensional image is obtained by stacking a plurality of plane graphics corresponding to the target pattern.
[0012] Optionally, the method further includes: obtaining each row of pixels in the target two-dimensional image by dividing the candidate pixel points in the target two-dimensional image by rows; obtaining a row pixel sequence corresponding to each row of pixels by arranging the horizontal coordinates of each candidate pixel points in each row of pixels in ascending or descending order; the elements in the row pixel sequence include the coordinates and pixel values of the candidate pixel points; based on each row pixel sequence and a preset background pixel value, determining the target sequence segment corresponding to each row pixel, and using each of the target sequence segments as the target pixel information corresponding to the target pattern.
[0013] Optionally, the method further comprises: determining the coordinates of the target two-dimensional pixel point to be converted in each row of pixels based on the first element and the last element of each target sequence segment in the target pixel information.
[0014] Optionally, the method further includes: determining a sequence segment to be selected in each row of pixel sequences based on each row of pixel sequences and a preset background pixel value; and determining a target sequence segment corresponding to each row of pixels from the sequence segments to be selected based on the number of elements in the sequence segments to be selected.
[0015] Optionally, the method further includes: averaging the desired three-dimensional image thickness to obtain two vertical coordinates; and determining target three-dimensional pixel point coordinates corresponding to the target pattern based on the target two-dimensional pixel point coordinates and the two vertical coordinates.
[0016] Optionally, the method further includes: determining route index data of four target three-dimensional pixel points corresponding to the same target sequence segment based on a drawing method of a triangle primitive; and connecting the target three-dimensional pixel points based on the route index data to obtain a plurality of plane graphics corresponding to the target pattern.
[0017] Optionally, the method further includes: acquiring size information of the target two-dimensional image; determining texture coordinates corresponding to the target three-dimensional pixel points based on the target three-dimensional pixel point coordinates and the size information; and performing texture rendering on the target three-dimensional image based on the texture coordinates corresponding to each target three-dimensional pixel point to obtain a rendered three-dimensional image.
[0018] Optionally, the method also includes: among the two target three-dimensional pixel points obtained by converting the target two-dimensional pixel point, the target three-dimensional pixel point with a larger vertical coordinate value is a first three-dimensional pixel point, and the target three-dimensional pixel point with a smaller vertical coordinate value is a second three-dimensional pixel point; based on the coordinates of the first three-dimensional pixel point and the size information, determining the first texture coordinates corresponding to the first three-dimensional pixel point; based on the image width value in the size information, the expected three-dimensional image thickness and the first texture coordinates, determining the second texture coordinates corresponding to the second three-dimensional pixel point.
[0019] Optionally, the method also includes: determining a first horizontal grain coordinate based on a ratio between a horizontal coordinate in the first three-dimensional pixel point coordinate and an image width value in the size information; determining a first vertical grain coordinate based on a ratio between a vertical coordinate in the first three-dimensional pixel point coordinate and an image height value in the size information; and determining a first texture coordinate corresponding to the first three-dimensional pixel point based on the first horizontal grain coordinate and the first vertical grain coordinate.
[0020] Optionally, the method also includes: determining the first horizontal grain coordinate in the first texture coordinate as the second horizontal grain coordinate of a second three-dimensional pixel point having the same horizontal coordinate as the first three-dimensional pixel point and the same horizontal coordinate; determining the vertical grain difference based on the ratio between the expected three-dimensional image thickness and the image width value in the size information; determining the second vertical grain coordinate of the second three-dimensional pixel point based on the difference between the first vertical grain coordinate in the first texture coordinate and the vertical grain difference; determining the second texture coordinate corresponding to the second three-dimensional pixel point based on the second horizontal grain coordinate and the second vertical grain coordinate of the second three-dimensional pixel point.
[0021] In a second aspect, an embodiment of the present invention further provides an image dimension conversion device, the device comprising:
[0022] A target two-dimensional image acquisition module, used to acquire a target two-dimensional image to be converted and an expected three-dimensional image thickness; the expected three-dimensional image thickness is a thickness value in a preset direction of a target coordinate system;
[0023] a target two-dimensional pixel point coordinate determination module, used to determine target pixel information of a target pattern in the target two-dimensional image, and determine target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information;
[0024] a target three-dimensional pixel point coordinate determination module, configured to determine the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates;
[0025] a plane graphic determination module, configured to obtain a plurality of plane graphics corresponding to the target pattern by connecting target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates;
[0026] The target three-dimensional image determination module is used to obtain a target three-dimensional image corresponding to the target two-dimensional image by stacking a plurality of plane graphics corresponding to the target pattern.
[0027] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0028] one or more processors;
[0029] A memory for storing one or more programs;
[0030] When the one or more programs are executed by the one or more processors, the one or more processors implement the image dimension conversion method provided by any embodiment of the present invention.
[0031] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements an image dimension conversion method as provided in any embodiment of the present invention.
[0032] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements an image dimension conversion method as provided in any embodiment of the present invention.
[0033] The technical solution of the embodiment of the present invention obtains a target two-dimensional image to be converted and an expected three-dimensional image thickness; determines target pixel information of a target pattern in the target two-dimensional image, and determines the target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information; determines the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates; obtains a plurality of plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates; and stacks the plurality of plane figures corresponding to the target pattern, thereby accurately and conveniently converting the target two-dimensional image into a target three-dimensional image, thereby improving the efficiency and accuracy of image dimension conversion.
[0034] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 is a flow chart of an image dimension conversion method provided by Embodiment 1 of the present invention;
[0037] Figure 2 is a flow chart of an image dimension conversion method provided by Embodiment 2 of the present invention;
[0038] Figure 3 is an example diagram of target two-dimensional pixel point coordinates in a target two-dimensional image involved in Embodiment 2 of the present invention;
[0039] Figure 4 This is an example diagram of a method for drawing a triangle primitive involved in the second embodiment of the present invention;
[0040] Figure 5 is a flowchart of an image dimension conversion method provided by Embodiment 3 of the present invention;
[0041] Figure 6 is a structural schematic diagram of an image dimension conversion device provided by a fourth embodiment of the present invention;
[0042] Figure 7 It is a schematic diagram of the structure of an electronic device for implementing the image dimension conversion method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0044] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] Embodiment 1
[0046] Figure 1 A flowchart of an image dimension conversion method is provided for the first embodiment of the present invention. This embodiment is applicable to the case of converting a two-dimensional image into a three-dimensional image. The method can be performed by an image dimension conversion device. The image dimension conversion device can be implemented in the form of hardware and / or software. The image dimension conversion device can be configured in an electronic device. Figure 1 As shown, the method includes:
[0047] S110 , obtaining a target two-dimensional image to be converted and a desired three-dimensional image thickness.
[0048] The expected three-dimensional image thickness is the thickness value in the preset direction of the target coordinate system. The expected three-dimensional image thickness may refer to the thickness value that the user expects the plane pattern in the target two-dimensional image to reach. The target coordinate system may refer to a three-dimensional space coordinate system. The preset direction may refer to the direction along the longitudinal axis (z-axis) in the target coordinate system. The target two-dimensional image may contain a plane pattern to be converted, i.e., a target pattern.
[0049] Specifically, the two-dimensional image input by the user is used as the target two-dimensional image to be converted, and the desired three-dimensional image thickness input by the user is obtained. If the user does not input the desired three-dimensional image thickness, the preset default thickness is used as the desired three-dimensional image thickness.
[0050] It should be noted that the embodiments of the present invention can also be applied to multiple languages or rendering application programming interfaces (Application Programming Interface, API), such as Opengles, Direct3D or C++. Taking Opengles as an example, before obtaining the target two-dimensional image to be converted and the desired three-dimensional image thickness, the Opengles environment can be initialized.
[0051] S120: Determine target pixel information of a target pattern in a target two-dimensional image, and determine target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information.
[0052] The target pixel information may refer to the pixel information corresponding to the pixel points constituting the target pattern. The target pixel information may represent the position of the target pattern in the target coordinate system and the pixel values contained in the target pattern. The target two-dimensional pixel point coordinates may refer to the two-dimensional coordinates corresponding to the pixel points at the edge or contour of the target pattern.
[0053] Specifically, image recognition is performed on the target two-dimensional image to remove the background and obtain the target pattern. The pixel value corresponding to each pixel in the target pattern is determined from the target two-dimensional image, and the pixel coordinates corresponding to each pixel in the target pattern are determined using the position coordinates of the target pattern in the target coordinate system. The pixel value and pixel coordinates corresponding to each pixel in the target pattern are used to form the target pixel information. Edge data extraction is performed on the target pixel information to obtain the target two-dimensional pixel coordinates corresponding to the pixel located at the edge of the target pattern.
[0054] S130 : Determine target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates.
[0055] Among them, the coordinate values of the pixel point in the target three-dimensional pixel point coordinates in the target coordinate system are all non-zero. When an object is obtained by 3D rendering, the vertex data of the object is required. The target three-dimensional pixel point coordinates can be understood as vertex data.
[0056] Specifically, the two vertical coordinates are determined using the expected three-dimensional image thickness, and the coordinate value difference between the two vertical coordinates must be the same as the expected three-dimensional image thickness. For example, if the expected three-dimensional image thickness is 50, the two vertical coordinates can be 10 and 60, or 30 and 80. The two vertical coordinates are added to the target two-dimensional pixel point coordinates to obtain two target three-dimensional pixels and the target three-dimensional pixel point coordinates corresponding to each target three-dimensional pixel point.
[0057] On the basis of the above technical solution, "determining the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates" may include: equally dividing the expected three-dimensional image thickness to obtain two vertical coordinates; determining the target three-dimensional pixel point coordinates corresponding to the target pattern based on the target two-dimensional pixel point coordinates and the two vertical coordinates.
[0058] Specifically, the desired 3D image thickness is averaged to obtain two vertical coordinates. If the desired 3D image thickness is 50, the two vertical coordinates are -25 and 25. The two vertical coordinates are added to the target 2D pixel coordinates to obtain two target 3D pixels and the target 3D pixel coordinates corresponding to each target 3D pixel, thereby quickly determining the vertical coordinates based on a unified standard, thereby quickly determining the target 3D pixel coordinates, and further improving the efficiency of image dimension conversion.
[0059] S140 , obtaining a plurality of plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates.
[0060] Herein, the plane figure may refer to a figure in each xy plane.
[0061] Specifically, target three-dimensional pixel points of the same target pattern in the same xy plane are connected in pairs to obtain a plane figure in the same xy plane, thereby obtaining a plurality of plane figures corresponding to the target pattern.
[0062] S150 , obtaining a target three-dimensional image corresponding to the target two-dimensional image by stacking a plurality of plane graphics corresponding to the target pattern.
[0063] The target three-dimensional image includes a three-dimensional target object obtained by converting the target pattern.
[0064] Specifically, a plurality of plane graphics corresponding to the target pattern are stacked in order in ascending or descending order of the ordinate (y-axis) to obtain a target three-dimensional image corresponding to the target two-dimensional image.
[0065] The technical solution of the embodiment of the present invention obtains a target two-dimensional image to be converted and an expected three-dimensional image thickness; determines target pixel information of a target pattern in the target two-dimensional image, and determines the target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information; determines the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates; obtains multiple plane graphics corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates; and stacks the multiple plane graphics corresponding to the target pattern, thereby accurately and conveniently converting the target two-dimensional image into a target three-dimensional image, thereby improving the efficiency and accuracy of image dimension conversion.
[0066] Embodiment 2
[0067] Figure 2 This is a flowchart of an image dimension conversion method provided in the second embodiment of the present invention. Based on the above embodiments, this embodiment describes in detail the process of determining the target pixel information of the target pattern in the target two-dimensional image and determining the coordinates of the target two-dimensional pixel points to be converted. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here. Figure 2 As shown, the method includes:
[0068] S210: Acquire a target two-dimensional image to be converted and a desired three-dimensional image thickness.
[0069] The expected three-dimensional image thickness is a thickness value in a preset direction of the target coordinate system.
[0070] S220 , obtaining pixels in each row of the target two-dimensional image by dividing the pixels to be selected in the target two-dimensional image by rows.
[0071] The pixels to be selected may refer to all pixels of the target two-dimensional image, and the row pixels may refer to a set of pixels corresponding to each row in the target two-dimensional image.
[0072] Specifically, each candidate pixel is traversed row by row starting from the upper left corner of the target two-dimensional image, and the position coordinates of the candidate pixel are recorded, and a pixel set is formed using all the candidate pixel points in each row, thereby obtaining each row of pixels in the target two-dimensional image.
[0073] S230 , obtaining a row pixel sequence corresponding to each row pixel by arranging the horizontal coordinates of each candidate pixel point in each row pixel in ascending order or descending order.
[0074] The elements in the row pixel sequence include the coordinates and pixel values of the pixels to be selected. The elements in the row pixel sequence can be arranged in order according to the size of the horizontal coordinate.
[0075] S240 . Determine a target sequence segment corresponding to each row of pixels based on each row of pixel sequences and a preset background pixel value, and use each target sequence segment as target pixel information corresponding to a target pattern.
[0076] The preset background pixel value may refer to a pixel value corresponding to a preset background. For example, the background may be, but is not limited to, a pattern in a target two-dimensional image that is not subjected to three-dimensional conversion. A target sequence segment may refer to a pixel sequence that only contains a target pattern. A row pixel sequence may contain at least one target sequence segment or may not contain any target sequence segment.
[0077] Specifically, the elements in each row pixel sequence are screened using the preset background pixel value, and the obtained elements with continuous coordinates are combined into a target sequence segment corresponding to each row pixel, and each target sequence segment is used as the target pixel information corresponding to the target pattern.
[0078] For example, two for loops can be used to traverse each pixel point from the upper left corner, with the horizontal right direction as the +X direction and the vertical downward direction as the +Y direction. As long as the pixel value of the candidate pixel point is found to be different from the preset background pixel value, the candidate pixel point is retained, and the retained candidate pixel points with continuous coordinates form a target sequence segment.
[0079] On the basis of the above technical solution, "determining the target sequence segment corresponding to each row of pixels based on each row of pixel sequences and the preset background pixel value" may include: determining the sequence segment to be selected in each row of pixel sequences based on each row of pixel sequences and the preset background pixel value; determining the target sequence segment corresponding to each row of pixels from the sequence segment to be selected based on the number of elements in the sequence segment to be selected.
[0080] The sequence segment to be selected may refer to a sequence segment obtained by preliminary screening using a preset background pixel value.
[0081] Specifically, the elements in each row pixel sequence are screened using the preset background pixel value to obtain a sequence segment to be selected in each row pixel sequence. If the number of elements in the sequence segment to be selected is less than or equal to the preset number of elements (such as 1), the sequence segment to be selected is eliminated. If the number of elements in the sequence segment to be selected is greater than the preset number of elements (such as 1), the sequence segment to be selected is determined as the target sequence segment of the row pixel.
[0082] S250 , based on the first element and the last element of each target sequence segment in the target pixel information, determine the coordinates of the target two-dimensional pixel point to be converted in each row of pixels.
[0083] in, Figure 3 An example diagram of the coordinates of a target two-dimensional pixel point in a target two-dimensional image is given. Figure 3 , the "3D" in the image is the target pattern, and the pattern other than the target pattern in the target two-dimensional image is the background. The horizontal line in the figure represents a row of pixels. Point a and point b are the two target two-dimensional pixel points corresponding to the first target sequence segment in the row of pixels. Point c and point d are the two target two-dimensional pixel points corresponding to the second target sequence segment in the row of pixels. Point e and point f are the two target two-dimensional pixel points corresponding to the third target sequence segment in the row of pixels. Point g and point h are the two target two-dimensional pixel points corresponding to the fourth target sequence segment in the row of pixels.
[0084] Specifically, the coordinates of the first element and the last element of each target sequence segment in the target pixel information are used to determine the coordinates of two target two-dimensional pixel points to be converted in the row of pixels where the target sequence segment is located.
[0085] Exemplarily, the process of determining the coordinates of the target two-dimensional pixel point may also include: in each row of pixels, when traversing along the x-axis direction, the traversal may be started from the candidate pixel point with the minimum x-coordinate value. When the first candidate pixel point whose pixel value is different from the preset background pixel value is detected, the candidate pixel point may be marked as the starting point (the pixel point corresponding to the first element), and the traversal may continue. Whenever the candidate pixel point with the same pixel value as the preset background pixel value is detected, the previous pixel point of the candidate pixel point is marked as the end point (the pixel point corresponding to the last element), and the starting point and the end point are used as a set of target two-dimensional pixel point coordinates corresponding to the same target sequence segment. Reset the starting point and the end point, and continue to traverse to determine the new starting point and the end point, and repeat this process until the entire target two-dimensional image is traversed row by row to obtain all the target two-dimensional pixel point coordinates corresponding to the target two-dimensional image.
[0086] S260 : Determine target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates.
[0087] S270 , obtaining a plurality of plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates.
[0088] On the basis of the above technical solution, "obtaining multiple plane graphics corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates" may include: determining the route index data of four target three-dimensional pixel points corresponding to the same target sequence segment based on the drawing method of the triangle primitive; connecting the target three-dimensional pixel points based on the route index data to obtain multiple plane graphics corresponding to the target pattern.
[0089] The primitive may refer to a graphics output primitive, which is also a function used to describe various graphics elements in a graphics software package. The triangle primitive may refer to a way of drawing graphics using a triangle graphic. Figure 4 This figure shows an example of how to draw a triangle primitive. Figure 4 , A, B, C, and D are target 3D pixel points. If you want to draw rectangle ABCD, you can first draw triangle ABD, and then draw triangle ADC, so as to achieve the drawing of rectangle ABCD. Among them, path AB, path BD, path DA, path AD, path DC, and path CA are the route index data corresponding to the target 3D pixel points A, B, C, and D.
[0090] Specifically, the four target 3D pixel points corresponding to the same target sequence segment are path-connected in a triangle primitive drawing manner, and the route index data of the four target 3D pixel points corresponding to each target sequence segment is determined. The target 3D pixel points are connected according to the route index data, thereby obtaining multiple plane figures corresponding to the target pattern, thereby improving the efficiency of determining the plane figures and further improving the efficiency of image dimension conversion.
[0091] It should be noted that when accurate vertex data (target three-dimensional pixel point coordinates) and route index data are obtained, a 3D object corresponding to the target pattern can be rendered in the 3D scene.
[0092] S280 , obtaining a target three-dimensional image corresponding to the target two-dimensional image by stacking a plurality of plane graphics corresponding to the target pattern.
[0093] The technical solution of the embodiment of the present invention obtains each row of pixels in the target two-dimensional image by dividing the candidate pixel points in the target two-dimensional image by rows; obtains the row pixel sequence corresponding to each row of pixels by arranging the horizontal coordinates of each candidate pixel points in each row of pixels in ascending or descending order; determines the target sequence segment corresponding to each row of pixels based on each row of pixel sequence and a preset background pixel value, and uses each target sequence segment as the target pixel information corresponding to the target pattern, and determines the coordinates of the target two-dimensional pixel points to be converted in each row of pixels based on the first element and the last element of each target sequence segment in the target pixel information, so that the pixel value can be used to accurately determine the target pixel information corresponding to each pattern in different two-dimensional images, and then accurately determine the coordinates of the target two-dimensional pixel points to be converted in each row of pixels, thereby further improving the accuracy of image dimensional conversion.
[0094] It should be noted that when using rendering libraries such as Opengles or Direct3D to render 3D models, if you only know a 2D picture, but need to render the objects in the 2D picture into a 3D scene with thickness, or if you need to render 2D text into 3D text, you can use the technical solution in the embodiments of the present application to achieve this.
[0095] Embodiment 3
[0096] Figure 5 This is a flowchart of an image dimension conversion method provided in Embodiment 3 of the present invention. Based on the above embodiments, this embodiment describes in detail the process of determining the texture coordinates for texture rendering of the target three-dimensional image. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here. Figure 5 As shown, the method includes:
[0097] S510: Acquire a target two-dimensional image to be converted and a desired three-dimensional image thickness.
[0098] The expected three-dimensional image thickness is a thickness value in a preset direction of the target coordinate system.
[0099] S520: Determine target pixel information of a target pattern in a target two-dimensional image, and determine target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information.
[0100] S530 : Determine target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates.
[0101] S540 , obtaining a plurality of plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates.
[0102] S550 , obtaining a target three-dimensional image corresponding to the target two-dimensional image by stacking a plurality of plane graphics corresponding to the target pattern.
[0103] S560: Obtain size information of the target two-dimensional image.
[0104] The size information includes the image width and image height of the target two-dimensional image.
[0105] S570 : Determine the texture coordinates corresponding to the target three-dimensional pixel point based on the target three-dimensional pixel point coordinates and size information.
[0106] Among them, texture can make 3D objects more realistic. Texture coordinates can be composed of data in two directions, u and v. The horizontal texture coordinate can be represented by u. The value of u can be the coordinate value of the horizontal texture coordinate. The vertical texture coordinate can be represented by v. The value of v can be the coordinate value of the vertical texture coordinate.
[0107] Specifically, the horizontal grain coordinate u corresponding to the target three-dimensional pixel point coordinate is determined by the ratio between the horizontal coordinate (x value) of the target three-dimensional pixel point coordinate and the image width. The vertical grain coordinate v1 to be selected corresponding to the target three-dimensional pixel point coordinate is determined by the ratio between the vertical coordinate (y value) of the target three-dimensional pixel point coordinate and the image height. The vertical grain compensation value v2 corresponding to the target three-dimensional pixel point coordinate is determined by the ratio between the vertical coordinate (z value) of the target three-dimensional pixel point coordinate and the image width, and the sum of the vertical grain coordinate to be selected and the vertical grain compensation value is used as the vertical grain coordinate v corresponding to the target three-dimensional pixel point coordinate, thereby determining the texture coordinate (u, v) corresponding to the target three-dimensional pixel point based on the vertical grain coordinate u and the vertical grain coordinate v.
[0108] On the basis of the above technical solution, "determining the texture coordinates corresponding to the target three-dimensional pixel point based on the target three-dimensional pixel point coordinates and size information" may include: determining the first texture coordinates corresponding to the first three-dimensional pixel point based on the first three-dimensional pixel point coordinates and size information; determining the second texture coordinates corresponding to the second three-dimensional pixel point based on the image width value in the size information, the expected three-dimensional image thickness and the first texture coordinates.
[0109] Among the two target three-dimensional pixel points obtained by converting the target two-dimensional pixel point, the target three-dimensional pixel point with a larger vertical coordinate value is the first three-dimensional pixel point, and the target three-dimensional pixel point with a smaller vertical coordinate value is the second three-dimensional pixel point. For example, the target two-dimensional pixel point (150,150) is converted to obtain the first three-dimensional pixel point (150,150,15) and the second three-dimensional pixel point (150,150,-15).
[0110] Specifically, taking the size information of 300×300 as an example, based on the ratio (0.5) between the horizontal coordinate (150) in the first three-dimensional pixel point coordinate and the image width value (300) in the size information, the first horizontal grain coordinate (0.5) is determined; based on the ratio (0.5) between the vertical coordinate (150) in the first three-dimensional pixel point coordinate and the image height value (300) in the size information, the first vertical grain coordinate (0.5) is determined; based on the first horizontal grain coordinate (0.5) and the first vertical grain coordinate (0.5), the first texture coordinate (0.5, 0.5) corresponding to the first three-dimensional pixel point is determined.
[0111] Specifically, following the above example, the first horizontal grain coordinate (0.5) in the first texture coordinate is determined as the second horizontal grain coordinate (0.5) of the second three-dimensional pixel point having the same horizontal coordinate as the first three-dimensional pixel point and the same horizontal coordinate; based on the ratio (0.1) between the expected three-dimensional image thickness (30) and the image width value (300) in the size information, the vertical grain difference (0.1) is determined; based on the difference (0.4) between the first vertical grain coordinate (0.5) in the first texture coordinate and the vertical grain difference (0.1), the second vertical grain coordinate (0.4) of the second three-dimensional pixel point is determined; based on the second horizontal grain coordinate (0.5) and the second vertical grain coordinate (0.4) of the second three-dimensional pixel point, the second texture coordinate (0.5, 0.4) corresponding to the second three-dimensional pixel point is determined.
[0112] On the basis of the above technical solution, "determining the first texture coordinates corresponding to the first three-dimensional pixel point based on the first three-dimensional pixel point coordinates and the size information" may include: determining the first horizontal texture coordinates based on the ratio between the horizontal coordinates in the first three-dimensional pixel point coordinates and the image width value in the size information; determining the first vertical texture coordinates based on the ratio between the vertical coordinates in the first three-dimensional pixel point coordinates and the image height value in the size information; determining the first texture coordinates corresponding to the first three-dimensional pixel point based on the first horizontal texture coordinates and the first vertical texture coordinates.
[0113] The first horizontal coordinate may refer to the coordinate value of the horizontal coordinate corresponding to the first three-dimensional pixel point, and the first vertical coordinate may refer to the coordinate value of the vertical coordinate corresponding to the first three-dimensional pixel point.
[0114] Specifically, the horizontal coordinate in the first three-dimensional pixel point coordinate is divided by the image width value in the size information, and the division result is determined as the first horizontal grain coordinate. The vertical coordinate in the first three-dimensional pixel point coordinate is divided by the image height value in the size information, and the division result is determined as the first vertical grain coordinate. The first horizontal grain coordinate and the first vertical grain coordinate are used to form the first texture coordinate corresponding to the first three-dimensional pixel point.
[0115] On the basis of the above technical solution, "determining the second texture coordinate corresponding to the second three-dimensional pixel point based on the image width value in the size information, the expected three-dimensional image thickness and the first texture coordinate" may include: determining the first horizontal grain coordinate in the first texture coordinate as the second horizontal grain coordinate of the second three-dimensional pixel point that is the same as the horizontal coordinate of the first three-dimensional pixel point and has the same horizontal coordinate; determining the vertical grain difference based on the ratio between the expected three-dimensional image thickness and the image width value in the size information; determining the second vertical grain coordinate of the second three-dimensional pixel point based on the difference between the first vertical grain coordinate in the first texture coordinate and the vertical grain difference; determining the second texture coordinate corresponding to the second three-dimensional pixel point based on the second horizontal grain coordinate and the second vertical grain coordinate of the second three-dimensional pixel point.
[0116] The second horizontal coordinate may refer to the coordinate value of the horizontal coordinate corresponding to the second three-dimensional pixel point, and the second vertical coordinate may refer to the coordinate value of the vertical coordinate corresponding to the second three-dimensional pixel point.
[0117] Specifically, the first horizontal grain coordinate in the first texture coordinate is determined as the second horizontal grain coordinate of the second three-dimensional pixel point having the same horizontal coordinate as the first three-dimensional pixel point and the same horizontal coordinate. The desired three-dimensional image thickness is divided by the image width value in the size information, and the division result is determined as the vertical grain difference. The first vertical grain coordinate in the first texture coordinate is subtracted from the vertical grain difference, and the subtraction result is determined as the second vertical grain coordinate of the second three-dimensional pixel point. The second horizontal grain coordinate and the second vertical grain coordinate of the second three-dimensional pixel point are used to form the second texture coordinate corresponding to the second three-dimensional pixel point.
[0118] S580 , performing texture rendering on the target three-dimensional image based on the texture coordinates corresponding to each target three-dimensional pixel point to obtain a rendered three-dimensional image.
[0119] For example, when accurate vertex data (target three-dimensional pixel coordinates), route index data and texture coordinates are obtained, a realistic 3D object corresponding to the target pattern can be rendered in a 3D scene. Use open source libraries, such as the Open Asset Import Library (Assimp library) that supports reading multiple model resources and use vertex data, route index data and texture coordinates to generate corresponding multiple types of 3D models. Such as .obj, .fbx, .dae and other file types.
[0120] The technical solution of the embodiment of the present invention can, after obtaining the target three-dimensional image corresponding to the target two-dimensional image, obtain the size information of the target two-dimensional image, and accurately determine the texture coordinates corresponding to the target three-dimensional pixel points based on the target three-dimensional pixel point coordinates and the size information, thereby realizing texture rendering of the target three-dimensional image based on the texture coordinates corresponding to each target three-dimensional pixel point, obtaining a rendered three-dimensional image, and improving the accuracy of three-dimensional image texture rendering.
[0121] The following is an embodiment of an image dimension conversion device provided by an embodiment of the present invention. The device and the image dimension conversion methods of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the image dimension conversion device, please refer to the embodiment of the above-mentioned image dimension conversion method.
[0122] Embodiment 4
[0123] Figure 6 This is a schematic diagram of the structure of an image dimension conversion device provided by Embodiment 4 of the present invention. Figure 6As shown, the device includes: a target two-dimensional image acquisition module 610, a target two-dimensional pixel point coordinate determination module 620, a target three-dimensional pixel point coordinate determination module 630, a plane figure determination module 640 and a target three-dimensional image determination module 650.
[0124] Among them, the target two-dimensional image acquisition module 610 is used to obtain the target two-dimensional image to be converted and the expected three-dimensional image thickness; the expected three-dimensional image thickness is the thickness value in the preset direction of the target coordinate system; the target two-dimensional pixel point coordinate determination module 620 is used to determine the target pixel information of the target pattern in the target two-dimensional image, and determine the target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information; the target three-dimensional pixel point coordinate determination module 630 is used to determine the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates; the plane figure determination module 640 is used to obtain multiple plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates; the target three-dimensional image determination module 650 is used to obtain the target three-dimensional image corresponding to the target two-dimensional image by stacking the multiple plane figures corresponding to the target pattern.
[0125] The technical solution of the embodiment of the present invention obtains a target two-dimensional image to be converted and an expected three-dimensional image thickness; determines target pixel information of a target pattern in the target two-dimensional image, and determines the target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information; determines the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates; obtains multiple plane graphics corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates; and stacks the multiple plane graphics corresponding to the target pattern, thereby accurately and conveniently converting the target two-dimensional image into a target three-dimensional image, thereby improving the efficiency and accuracy of image dimension conversion.
[0126] Based on the above technical solution, the target two-dimensional pixel point coordinate determination module 620 may include:
[0127] A row pixel determination submodule is used to obtain each row pixel in the target two-dimensional image by segmenting the selected pixel points in the target two-dimensional image by row;
[0128] The row pixel sequence determination submodule is used to obtain a row pixel sequence corresponding to each row pixel by arranging the horizontal coordinates of each pixel point to be selected in each row pixel in ascending order or descending order; the elements in the row pixel sequence include the coordinates and pixel values of the pixel point to be selected;
[0129] The target pixel information determination submodule is used to determine the target sequence segment corresponding to each row of pixels based on each row of pixel sequences and a preset background pixel value, and use each target sequence segment as the target pixel information corresponding to the target pattern.
[0130] Based on the above technical solution, the target two-dimensional pixel point coordinate determination module 620 may include:
[0131] The target two-dimensional pixel point coordinate determination submodule is used to determine the target two-dimensional pixel point coordinates to be converted in each row of pixels based on the first element and the last element of each target sequence segment in the target pixel information.
[0132] On the basis of the above technical solution, the target pixel information determination submodule is specifically used to: determine the sequence segment to be selected in each row of pixel sequences based on each row of pixel sequences and the preset background pixel value; and determine the target sequence segment corresponding to each row of pixels from the sequence segment to be selected based on the number of elements in the sequence segment to be selected.
[0133] Based on the above technical solution, the target three-dimensional pixel point coordinate determination module 630 is specifically used to: evenly divide the desired three-dimensional image thickness to obtain two vertical coordinates; and determine the target three-dimensional pixel point coordinates corresponding to the target pattern based on the target two-dimensional pixel point coordinates and the two vertical coordinates.
[0134] On the basis of the above technical solution, the plane graphics determination module 640 is specifically used to: determine the route index data of four target three-dimensional pixel points corresponding to the same target sequence segment based on the drawing method of the triangle primitive; connect the target three-dimensional pixel points based on the route index data to obtain multiple plane graphics corresponding to the target pattern.
[0135] On the basis of the above technical solution, the device also includes:
[0136] A size information determination module, used to obtain size information of a target two-dimensional image;
[0137] A texture coordinate determination module, used to determine the texture coordinates corresponding to the target three-dimensional pixel point based on the target three-dimensional pixel point coordinates and size information;
[0138] The three-dimensional image texture rendering module is used to perform texture rendering on the target three-dimensional image based on the texture coordinates corresponding to each target three-dimensional pixel point to obtain a rendered three-dimensional image.
[0139] On the basis of the above technical solution, among the two target three-dimensional pixel points obtained by converting the target two-dimensional pixel point, the target three-dimensional pixel point with a larger vertical coordinate value is the first three-dimensional pixel point, and the target three-dimensional pixel point with a smaller vertical coordinate value is the second three-dimensional pixel point;
[0140] The texture coordinate determination module may include:
[0141] A first texture coordinate determination submodule, used to determine a first texture coordinate corresponding to the first three-dimensional pixel point based on the first three-dimensional pixel point coordinates and size information;
[0142] The second texture coordinate determination submodule is used to determine the second texture coordinate corresponding to the second three-dimensional pixel point based on the image width value in the size information, the expected three-dimensional image thickness and the first texture coordinate.
[0143] On the basis of the above technical solution, the first texture coordinate determination submodule is specifically used to: determine the first horizontal grain coordinate based on the ratio between the horizontal coordinate in the first three-dimensional pixel point coordinate and the image width value in the size information; determine the first vertical grain coordinate based on the ratio between the vertical coordinate in the first three-dimensional pixel point coordinate and the image height value in the size information; determine the first texture coordinate corresponding to the first three-dimensional pixel point based on the first horizontal grain coordinate and the first vertical grain coordinate.
[0144] On the basis of the above technical solution, the second texture coordinate determination submodule is specifically used to: determine the first horizontal grain coordinate in the first texture coordinate as the second horizontal grain coordinate of the second three-dimensional pixel point that is the same as the horizontal coordinate of the first three-dimensional pixel point and has the same horizontal coordinate; determine the vertical grain difference based on the ratio between the expected three-dimensional image thickness and the image width value in the size information; determine the second vertical grain coordinate of the second three-dimensional pixel point based on the difference between the first vertical grain coordinate in the first texture coordinate and the vertical grain difference; determine the second texture coordinate corresponding to the second three-dimensional pixel point based on the second horizontal grain coordinate and the second vertical grain coordinate of the second three-dimensional pixel point.
[0145] The image dimension conversion device provided in the embodiment of the present invention can execute the image dimension conversion method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the image dimension conversion method.
[0146] It is worth noting that in the above-mentioned embodiment of image dimension conversion, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0147] Embodiment 5
[0148] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0149] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0150] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0151] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as an image dimension conversion method.
[0152] In some embodiments, the image dimension conversion method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the image dimension conversion method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the image dimension conversion method in any other appropriate manner (e.g., by means of firmware).
[0153] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0154] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0155] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0156] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0157] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0158] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0159] An embodiment of the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the image dimension conversion method provided in any embodiment of the present application.
[0160] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect through the Internet). The program product and the image dimension conversion method disclosed in each embodiment of the present application belong to the same inventive concept, so it will not be repeated here.
[0161] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0162] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for image dimension conversion, It is characterized in that include: Acquire a target two-dimensional image to be converted and an expected three-dimensional image thickness; the expected three-dimensional image thickness is a thickness value in a preset direction of a target coordinate system; Determine target pixel information of a target pattern in the target two-dimensional image, and determine target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information; Determining target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates; By connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates, a plurality of plane figures corresponding to the target pattern are obtained; A target three-dimensional image corresponding to the target two-dimensional image is obtained by stacking a plurality of plane graphics corresponding to the target pattern.
2. The method according to claim 1, It is characterized in that The determining target pixel information of the target pattern in the target two-dimensional image includes: By dividing the selected pixel points in the target two-dimensional image by rows, pixels in each row in the target two-dimensional image are obtained; By arranging the horizontal coordinates of each pixel point to be selected in each row of pixels in ascending order or descending order, a row pixel sequence corresponding to each row of pixels is obtained; the elements in the row pixel sequence include the coordinates and pixel values of the pixel point to be selected; Based on each row pixel sequence and the preset background pixel value, a target sequence segment corresponding to each row pixel is determined, and each of the target sequence segments is used as target pixel information corresponding to the target pattern.
3. The method according to claim 1, It is characterized in that The step of determining the target two-dimensional pixel point coordinates to be converted from the target two-dimensional image based on the target pixel information includes: Based on the first element and the last element of each target sequence segment in the target pixel information, the coordinates of the target two-dimensional pixel point to be converted in each row of pixels are determined.
4. The method according to claim 2, It is characterized in that The step of determining the target sequence segment corresponding to each row of pixels based on each row of pixel sequences and a preset background pixel value comprises: Determine a sequence segment to be selected in each row pixel sequence based on each row pixel sequence and a preset background pixel value; A target sequence segment corresponding to each row of pixels is determined from the sequence segments to be selected based on the number of elements in the sequence segments to be selected.
5. The method according to claim 1, It is characterized in that The step of determining the target three-dimensional pixel point coordinates corresponding to the target pattern based on the expected three-dimensional image thickness and the target two-dimensional pixel point coordinates includes: Equally divide the desired three-dimensional image thickness to obtain two vertical coordinates; Based on the target two-dimensional pixel point coordinates and the two vertical coordinates, the target three-dimensional pixel point coordinates corresponding to the target pattern are determined.
6. The method according to claim 1, It is characterized in that The method of obtaining a plurality of plane figures corresponding to the target pattern by connecting the target three-dimensional pixel points corresponding to the target three-dimensional pixel point coordinates includes: Determine route index data of four target three-dimensional pixel points corresponding to the same target sequence segment based on the drawing method of the triangle primitive; The target three-dimensional pixel points are connected based on the route index data to obtain a plurality of plane graphics corresponding to the target pattern.
7. The method according to claim 1, It is characterized in that The method further comprises: Get the size information of the target two-dimensional image; Determining texture coordinates corresponding to the target three-dimensional pixel point based on the target three-dimensional pixel point coordinates and the size information; The target three-dimensional image is texture rendered based on the texture coordinates corresponding to each target three-dimensional pixel point to obtain a rendered three-dimensional image.
8. The method according to claim 7, It is characterized in that Of the two target three-dimensional pixel points obtained by converting the target two-dimensional pixel point, the target three-dimensional pixel point with a larger vertical coordinate value is the first three-dimensional pixel point, and the target three-dimensional pixel point with a smaller vertical coordinate value is the second three-dimensional pixel point; The determining, based on the target three-dimensional pixel point coordinates and the size information, the texture coordinates corresponding to the target three-dimensional pixel point includes: Determining first texture coordinates corresponding to the first three-dimensional pixel point based on the first three-dimensional pixel point coordinates and the size information; Based on the image width value in the size information, the expected three-dimensional image thickness and the first texture coordinates, a second texture coordinate corresponding to the second three-dimensional pixel point is determined.
9. The method according to claim 8, It is characterized in that The determining, based on the first three-dimensional pixel point coordinates and the size information, a first texture coordinate corresponding to the first three-dimensional pixel point includes: Determine a first horizontal stripe coordinate based on a ratio between a horizontal coordinate in the first three-dimensional pixel point coordinate and an image width value in the size information; Determine a first vertical grain coordinate based on a ratio between a vertical coordinate in the first three-dimensional pixel point coordinate and an image height value in the size information; A first texture coordinate corresponding to a first three-dimensional pixel point is determined based on the first horizontal texture coordinate and the first vertical texture coordinate.
10. The method according to claim 8, It is characterized in that The determining, based on the image width value in the size information, the expected three-dimensional image thickness, and the first texture coordinate, a second texture coordinate corresponding to the second three-dimensional pixel point includes: Determine a first horizontal texture coordinate in the first texture coordinates as a second horizontal texture coordinate of a second three-dimensional pixel point having the same horizontal coordinate as the first three-dimensional pixel point; Determine a vertical grain difference based on a ratio between an expected three-dimensional image thickness and an image width value in the size information; Determine a second vertical grain coordinate of the second three-dimensional pixel based on a difference between a first vertical grain coordinate in the first texture coordinates and the vertical grain difference; A second texture coordinate corresponding to the second three-dimensional pixel point is determined based on the second horizontal texture coordinate and the second vertical texture coordinate of the second three-dimensional pixel point.
