Image processing method and device, storage medium and electronic device
By acquiring and utilizing height maps for image rotation, the problem of traditional drawing tools being unable to create 3D effects is solved, enabling efficient and low-cost image drawing, suitable for creating complex graphics in game art products.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-01-31
- Publication Date
- 2026-06-19
AI Technical Summary
Traditional image drawing tools cannot create 3D effects. Manual drawing is costly and time-consuming. Graphics production is complex, especially in game art products where there are many material details and complex structures, resulting in low drawing efficiency.
By obtaining the height map of the image to be drawn, rotating the image using preset rotation information, determining the target pixel points based on the height map and the rotated image, and drawing the target image, the manual drawing steps are reduced.
It improves image rendering efficiency, reduces costs, and simplifies the production process of complex graphics, especially in game art products, reducing the reliance on technical art skills.
Smart Images

Figure CN116258839B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more specifically, to an image processing method, apparatus, storage medium, and electronic device. Background Technology
[0002] Currently, when drawing complex graphics, the tilting of the character often causes the decorative items they carry to tilt. Traditional transformation tools cannot create a 3D effect, while manual drawing requires additional time and a certain level of artistic skill, resulting in high production costs. Furthermore, in traditional game art production, objects have many material details and complex structures, making drawing them time-consuming.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] At least some embodiments of the present invention provide an image processing method, apparatus, storage medium, and electronic device to at least solve the technical problem of low efficiency in image rendering in the related art.
[0005] According to one embodiment of the present invention, an image processing method is provided, comprising: acquiring a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; rotating the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; determining a target pixel corresponding to each second pixel among the plurality of first pixels based on the drawn image, the height map, and the rotated image; and drawing the rotated image based on the target pixel corresponding to each second pixel to obtain a target image.
[0006] Optionally, obtaining the height map of the drawn image includes: obtaining image information of each first pixel in the drawn image; determining a preset basic shape based on the contour information of the drawn image; determining a preset height map corresponding to the preset basic shape; and obtaining the height map based on the product of the image information of each first pixel and the preset height map.
[0007] Optionally, a height map is obtained based on the product of the image information of each first pixel and a preset height map, including: determining the color information of each first pixel based on the image information of each first pixel in the drawn image; performing a conversion process on the color information of each first pixel to obtain the brightness information of each first pixel; performing a conversion process on the image information of each first pixel to obtain the brightness information of each first pixel; and obtaining a height map based on the product of the brightness information of each first pixel and the preset height map.
[0008] Optionally, determining the target pixel corresponding to each second pixel among multiple first pixels based on the drawn image, height map, and rotated image includes: determining the first plane where the rotated image is located; constructing a ray corresponding to each second pixel based on preset points and each second pixel in the rotated image; determining the target point on the ray corresponding to each second pixel; controlling the target point to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, obtaining the intersection position of the target point of each second pixel and the height map; and determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0009] Optionally, the target point is controlled to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map. This includes: controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point; determining whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtaining a comparison result; in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continuing to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point in the ray; in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determining the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel with the height map.
[0010] Optionally, the target point is controlled to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point, including: obtaining the difference between a preset value and the cosine value of the target angle; and controlling the target point to descend step by step along the ray based on the difference to obtain the height information of the target point.
[0011] Optionally, the drawn image is rotated according to preset rotation information to obtain a rotated image, including: determining the rectangular coordinate system corresponding to the drawn image; determining the first preset axis and rotation angle corresponding to the rectangular coordinate system based on the preset rotation information; and controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0012] Optionally, the rotating image is drawn based on the target pixel corresponding to each second pixel to obtain the target image, including: acquiring the pixel value corresponding to the target pixel corresponding to each second pixel; filling each second pixel based on the pixel value corresponding to the target pixel corresponding to each second pixel to obtain the target image.
[0013] According to one embodiment of the present invention, an image processing apparatus is also provided, comprising: an acquisition module, configured to acquire a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; a rotation module, configured to rotate the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; a determination module, configured to determine a target pixel corresponding to each second pixel among the plurality of first pixels based on the drawn image, the height map, and the rotated image; and a drawing module, configured to draw the rotated image based on the target pixel corresponding to each second pixel to obtain a target image.
[0014] Optionally, the acquisition module includes: an acquisition unit for acquiring image information of each first pixel in the drawn image; a first determination unit for determining a preset basic shape based on the contour information of the drawn image; a second determination unit for determining a preset height map corresponding to the preset basic shape; and a third determination unit for obtaining a height map based on the product of the image information of each first pixel and the preset height map.
[0015] Optionally, the third determining unit includes: a first determining subunit, used to determine the color information of each first pixel based on the image information of each first pixel in the drawn image; a first conversion subunit, used to convert the color information of each first pixel based on a preset formula to obtain the brightness information of each first pixel; a first conversion subunit, used to convert the image information of each first pixel based on a preset conversion formula to obtain the brightness information of each first pixel; and a second determining subunit, used to obtain a height map based on the product of the brightness information of each first pixel and a preset height map.
[0016] Optionally, the determining module includes: a fourth determining unit for determining the first plane where the rotated image is located; a constructing unit for constructing a ray corresponding to each second pixel based on a preset point and each second pixel in the rotated image; a fifth determining unit for determining a target point on the ray corresponding to each second pixel; a controlling unit for controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thereby obtaining the intersection position of the target point of each second pixel with the height map; and a sixth determining unit for determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0017] Optionally, the control unit includes: a first control subunit, configured to control a target point to descend stepwise along a ray based on the target angle between the ray of each second pixel and the first plane, thereby obtaining the height information of the target point; a judgment subunit, configured to judge whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtain a comparison result; an execution subunit, configured to, in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continue to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane, thereby obtaining the height information of the target point in the ray; and a third determination subunit, configured to, in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determine the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel and the height map.
[0018] Optionally, the control unit includes: an acquisition subunit for acquiring the difference between a preset value and the cosine of the angle between the target and the target; and a second control subunit for controlling the target point to descend stepwise along the ray based on the difference, thereby obtaining the height information of the target point.
[0019] Optionally, the rotation module includes: a seventh determining unit for determining the Cartesian coordinate system corresponding to the drawn image; an eighth determining unit for determining the first preset axis and rotation angle corresponding to the Cartesian coordinate system based on preset rotation information; and a rotation unit for controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0020] Optionally, the drawing module includes: a acquisition unit for acquiring the pixel value corresponding to the target pixel point for each second pixel point; and a filling unit for filling each second pixel point based on the pixel value corresponding to the target pixel point for each second pixel point to obtain the target image.
[0021] According to one embodiment of the present invention, a non-volatile storage medium is also provided, wherein a computer program is stored in the non-volatile storage medium, and the computer program is configured to execute the image processing method described in any of the above claims when running.
[0022] According to one embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the image processing method described in any of the preceding claims.
[0023] In at least some embodiments of the present invention, a height map of a drawn image is obtained, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; the drawn image is rotated according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; a target pixel corresponding to each second pixel among the plurality of first pixels is determined based on the drawn image, the height map, and the rotated image; the rotated image is drawn based on the target pixel corresponding to each second pixel to obtain a target image. It is readily apparent that after obtaining the height map, the drawn image and the rotated image can be correlated in position using the height map, thereby using the first pixels of the drawn image to determine the second pixels of the rotated image and obtain the target pixel, and then using the target pixel to draw to obtain the target image. This allows the user to obtain the target image without redrawing, improving work efficiency and reducing drawing costs, thereby solving the technical problem of low efficiency in image drawing in related technologies. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0025] Figure 1 This is a hardware structure block diagram of a mobile terminal for an image processing method according to an embodiment of the present invention.
[0026] Figure 2 This is a flowchart of an image processing method based on existing technology;
[0027] Figure 3a It is a schematic diagram of a complex image that needs to be drawn;
[0028] Figure 3b It is a schematic diagram of the desired angle and perspective effect;
[0029] Figure 3c It is a schematic diagram of a pre-drawn complex image;
[0030] Figure 4 This is a flowchart of an image processing method according to one embodiment of the present invention;
[0031] Figure 5 This is a preset height map according to one embodiment of the present invention;
[0032] Figure 6 This is a height information map of an image drawn according to one embodiment of the present invention;
[0033] Figure 7 This is a height map according to one embodiment of the present invention;
[0034] Figure 8 This is a schematic diagram of a predetermined point intersecting with a first plane according to one embodiment of the present invention;
[0035] Figure 9 This is a schematic diagram of a target included angle according to one embodiment of the present invention;
[0036] Figure 10 This is a schematic diagram of target point movement according to one embodiment of the present invention;
[0037] Figure 11 This is a schematic diagram of a ray descent according to one embodiment of the present invention;
[0038] Figure 12 This is a structural block diagram of a device according to one embodiment of the present invention;
[0039] Figure 13 This is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0040] 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 should fall within the scope of protection of the present invention.
[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0042] According to one embodiment of the present invention, an embodiment of an image processing method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0043] This method embodiment can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smartphone (such as an Android phone, iOS phone, etc.), tablet computer, PDA, mobile Internet Device (MID), PAD, game console, and other terminal devices. Figure 1 This is a hardware structure block diagram of a mobile terminal for an image processing method according to an embodiment of the present invention. For example... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a central processing unit (CPU), graphics processing unit (GPU), digital signal processing (DSP) chip, microprocessor (MCU), programmable logic device (FPGA), neural network processor (NPU), tensor processor (TPU), artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data are also shown. Optionally, the mobile terminal may further include a transmission device 106 for communication functions, an input / output device 108, and a display device 110. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0044] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the image processing method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the aforementioned image processing method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0045] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0046] The inputs in input / output device 108 can come from multiple human interface devices (HIDs). Examples include keyboards and mice, gamepads, and other dedicated game controllers (such as steering wheels, fishing rods, dance mats, and remote controls). Some HIDs, in addition to providing input functions, can also provide output functions, such as force feedback and vibration from gamepads, and audio output from controllers.
[0047] Display device 110 may be, for example, a head-up display (HUD), a touchscreen liquid crystal display (LCD), and a touch display (also referred to as a "touchscreen" or "touch display"). The LCD allows a user to interact with the user interface of the mobile terminal. In some embodiments, the mobile terminal has a graphical user interface (GUI), which allows the user to interact with the GUI by touching and / or gesturing on a touch-sensitive surface. Optional human-computer interaction functions include: creating web pages, drawing, word processing, creating electronic documents, playing games, video conferencing, instant messaging, sending and receiving emails, a call interface, playing digital video, playing digital music, and / or web browsing, etc. Executable instructions for performing the above human-computer interaction functions are configured / stored in one or more processor-executable computer program products or readable storage media.
[0048] In related technologies, drawing rotated graphics requires manually creating objects at different angles, a complex process. Figure 2 This is a flowchart of an image processing method based on existing technology, such as... Figure 2 As shown, it can generally be summarized into the following steps:
[0049] Step S202: Draw the front part.
[0050] Step S204: Determine the desired angle and perspective effect.
[0051] Step S206: Draw the front view of the prop according to the perspective structure based on the perspective view.
[0052] Figure 3a It is a schematic diagram of a complex image that needs to be drawn, such as... Figure 3a As shown, the front part of the image can be drawn first. Figure 3b It is a schematic diagram of the desired angle and perspective effect, such as Figure 3b As shown, the desired angle can be set to rotate 15 degrees to the right. Figure 3c It is a schematic diagram of a pre-drawn complex image, such as... Figure 3c As shown, complex frontal images can be drawn according to perspective structure based on perspective effects.
[0053] The methods used in these related technologies are time-consuming and require personnel with a certain level of technical and artistic skill. In traditional game art production, objects have numerous material details and complex structures. Therefore, using these methods for graphic design results in extremely high production costs.
[0054] Figure 4 This is a flowchart of an image processing method according to one embodiment of the present invention, such as... Figure 4 As shown, the method includes the following steps:
[0055] Step S402: Obtain the height map of the drawn image, wherein the drawn image includes multiple first pixels, and the height map is used to represent the height information of each first pixel in the drawn image.
[0056] The images mentioned above can be images from the game scene that need to be drawn. Optionally, the images can be characters, items, tools, etc. in the game, such as masks, clothing patterns, etc.
[0057] The height map described above can include the brightness of each location within the drawn image, where the height of the image represents the brightness of the color at each location. Optionally, the drawn image can be illuminated by the same beam of light, and the height of each location can be determined based on the degree of light reflection from bright to dark at different locations in the drawn image. Brighter locations have higher heights than darker locations. The light source can be X-rays, ordinary white light, etc., and the type of light is not limited here. Optionally, a corresponding detection model can also be used to detect the brightness of the image's colors to obtain the height map of the drawn image.
[0058] In one optional embodiment, the height of an object in a height map can be obtained by establishing a coordinate system in three-dimensional space, with the origin of the coordinate system as the reference, the z-axis pointing downwards as the direction, and the z-axis as the numerical value. For example, if the brightness of a certain position in the drawn image is high, then the height of that position in the three-dimensional image under illumination can be on the same horizontal plane as the coordinate axis. If the brightness of another position in the drawn image is moderate, then the coordinate of that position in the three-dimensional image can be concave downwards along the z-axis. Specifically, the brightness of different positions in the drawn image can be represented by specific numerical values. For example, the height of a certain position on the same horizontal plane as the coordinate axis can be represented by the value 0, and the brightness of another position in the drawn image is moderate, and the coordinate of that position is concave downwards along the z-axis can be represented by the value -1.
[0059] The first pixel mentioned above can be the color information of each position of the object contained in the drawn image. Specifically, the specific pixel value can be determined according to the color lookup table (Red Green Blue, abbreviated as RGB).
[0060] The height information of the first pixel mentioned above can be used to represent the brightness information of each position of an object in the drawn image.
[0061] In another optional embodiment, the drawn image can be illuminated with light, and a corresponding height map can be obtained based on the degree of light reflection by the drawn image. Optionally, the height of brighter areas under the same light beam can be set to a larger value, and the height of darker areas under the same light beam can be set to a smaller value. Optionally, the drawn image can also be captured by a camera, and the height values of different locations in the drawn image can be determined based on the color intensity of different positions in the captured image, wherein the height value of lighter areas is greater than the height value of darker areas, thereby obtaining a height map of the drawn image. Optionally, the brightness information of the image's colors can also be converted into corresponding height values using a conversion function, thereby obtaining a height map of the drawn image, wherein the conversion function can be used to convert the brightness of the image's colors into specific height values.
[0062] Optionally, after obtaining the height map, each position in the drawn image can be mapped to each position in the image obtained after rotating the drawn image. The pixel value of the first pixel at each position in the drawn image can be determined as the pixel value of the same position in the image obtained after rotating the drawn image, thereby reducing the workload of artists and further improving the efficiency of drawing images from all angles.
[0063] Step S404: Rotate the drawn image according to the preset rotation information to obtain a rotated image, wherein the rotated image includes multiple second pixels.
[0064] The aforementioned preset rotation information can be used to represent information such as the rotation angle and direction of the drawn image. The preset rotation information can be set according to requirements; for example, it can be set to rotate 15 degrees to the right or 30 degrees to the left.
[0065] The aforementioned rotated image can be an image obtained by rotating the drawn image according to preset rotation information. The rotated image does not contain the specific pixel value of each position in the image.
[0066] The aforementioned multiple second pixels can be used to represent the color pixel value at each position of the image contained in the rotated image, wherein the second pixel may not contain a specific pixel value.
[0067] In one optional embodiment, the positions of the rotated image and the drawn image can be mapped using a height map, thereby determining the pixel value of the first pixel in the drawn image as the pixel value of the second pixel at the same position in the rotated image. This can be achieved by having the same ray pass through both the drawn image and the rotated image simultaneously, and determining the positional correspondence between them based on the height map. Alternatively, the drawn image and the rotated image can be placed in the same coordinate system, with the origin determined on the rotation axis. Based on the coordinate information and rotation angle, the positional correspondence between the drawn image and the rotated image can be mathematically calculated, thereby determining the pixel values of multiple second pixels based on the positional correspondence.
[0068] Step S406: Based on the drawn image, height map and rotated image, determine the target pixel point corresponding to each second pixel point among multiple first pixel points.
[0069] The target pixel mentioned above can be a pixel in the drawn image that represents the same position as the rotated image, where the target pixel can include the pixel value of that point.
[0070] In one optional embodiment, a coordinate system can be established, and the drawn image can be fixed on the coordinate plane with one edge of the drawn image coinciding with the y-axis. Then, the drawn image is rotated around the y-axis by a preset rotation angle to obtain a rotated image. Simultaneously, light is used to illuminate the drawn image and the rotated image to obtain a height map corresponding to the drawn image. Optionally, three intersection points of the light ray with the drawn image, the rotated image, and the height map can be obtained. Optionally, the first pixel point at the intersection point of the light ray and the height map, perpendicular to the drawn image, can be determined as the target pixel point, and the pixel value of the target pixel point can be determined as the pixel value of the intersection point of the light ray and the rotated image.
[0071] In another alternative embodiment, a mathematical model can be established and a mathematical algorithm can be used to directly correspond the image positions of the drawn image and the rotated image, thereby determining the pixel values in the drawn image as the pixel values at the same position in the rotated image.
[0072] Furthermore, by establishing a correspondence between the drawn image and the rotated image in terms of image position, it is possible to obtain the pixel values of the rotated image without manually redrawing it, thereby greatly improving work efficiency and reducing the cost of image drawing.
[0073] Step S408: Draw the rotated image based on the target pixel corresponding to each second pixel to obtain the target image.
[0074] The target image mentioned above can be a rotated image containing pixel values.
[0075] In one optional embodiment, the position in the rotated image where the pixel value needs to be obtained can be determined first, and the corresponding position in the drawn image at the same position can be determined. Optionally, the pixel at the corresponding position in the drawn image can be determined as the target pixel, and the pixel value corresponding to the target pixel can be determined as the pixel value at the position in the rotated image where the pixel value needs to be obtained. Optionally, the above steps can be repeated until the pixel values at all positions in the rotated image are determined, and the rotated graphic is drawn according to the pixel values to obtain the target image.
[0076] In at least some embodiments of the present invention, a height map of a drawn image is obtained, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; the drawn image is rotated according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; a target pixel corresponding to each second pixel among the plurality of first pixels is determined based on the drawn image, the height map, and the rotated image; the rotated image is drawn based on the target pixel corresponding to each second pixel to obtain a target image. It is readily apparent that after obtaining the height map, the drawn image and the rotated image can be correlated in position using the height map, thereby using the first pixels of the drawn image to determine the second pixels of the rotated image and obtain the target pixel, and then using the target pixel to draw to obtain the target image. This allows the user to obtain the target image without redrawing, improving work efficiency and reducing drawing costs, thereby solving the technical problem of low efficiency in image drawing in related technologies.
[0077] Optionally, obtaining the height map of the drawn image includes: obtaining image information of each first pixel in the drawn image; determining a preset basic shape based on the contour information of the drawn image; determining a preset height map corresponding to the preset basic shape; and obtaining the height map based on the product of the image information of each first pixel and the preset height map.
[0078] The image information described above can be used to represent the information of the first pixel in the drawn image. The image information may include, but is not limited to, the position information of the first pixel and the pixel value corresponding to the first pixel.
[0079] The aforementioned contour information is used to represent the contour of the object depicted in the drawn image.
[0080] The aforementioned preset basic shape can be a shape that closely resembles the objects contained in the drawn image. Optionally, the preset basic shape can be set by the user, such as a sphere, a hexahedron, etc. Optionally, if the drawn image is a mask, the preset basic shape can be set to a circle; if the drawn image is a honeycomb, the preset basic shape can be set to a hexagon.
[0081] The aforementioned preset height map can be used to represent the color and brightness of a preset basic shape.
[0082] In one optional embodiment, the drawn image can be first divided to obtain multiple first pixels at different locations in the drawn image. Optionally, after obtaining multiple first pixels, the pixel values of the multiple first pixels can be obtained based on their color information. Further, a preset basic shape can be determined based on the approximate outline of the image contained in the drawn image. For example, if the drawn image is a kite, the outline information of the drawn image can be considered as the object being close to a rhombus, so the preset basic shape can be a rhombus.
[0083] Furthermore, after determining the preset basic shape, the preset basic shape of the drawn graphic can be converted into a preset height map using a transformation model or corresponding transformation formula. Figure 5 This is a preset height map according to one embodiment of the present invention, such as... Figure 5 As shown, when the preset base shape is a circle, the preset height map obtained under lighting can be a circle whose brightness gradually decreases from the center to the edges. Optionally, the image information of the first pixel can be multiplied with the preset height map to obtain a height map with details.
[0084] Optionally, a height map is obtained based on the product of the image information of each first pixel and a preset height map, including: determining the color information of each first pixel based on the image information of each first pixel in the drawn image; performing a conversion process on the color information of each first pixel to obtain the brightness information of each first pixel; performing a conversion process on the image information of each first pixel to obtain the brightness information of each first pixel; and obtaining the height map based on the product of the brightness information of each first pixel and the preset height map.
[0085] The color information mentioned above can be the color of the first pixel, for example, the first pixel is red, or the first pixel is green.
[0086] In one optional embodiment, the color information of each first pixel can be converted based on the preset formula Height(color)=color·(0.299,0.587,0.114) to obtain the brightness information of each first pixel. Optionally, the preset formula is not limited to this.
[0087] Where Height represents height, color represents color, and 0.299, 0.587, and 0.114 are specific height values. Optionally, preset formulas can be used to convert color and image information into height information. Figure 6 This is a height information map of an image drawn according to one embodiment of the present invention, such as... Figure 6As shown, the contour information of the drawn image can be converted into height information using a preset formula, thereby determining the brightness information of each first pixel in the drawn image. Figure 6 The image can be seen to contain the outline information of the image and the brightness of different positions.
[0088] In another optional embodiment, the color information and image information of each first pixel can be converted using a preset formula to obtain a height information diagram of the drawn image. Optionally, after obtaining the image information of the first pixel and the preset height map, the obtained image information of the first pixel and the preset height map can be multiplied to obtain a height map. Figure 7 This is a height map according to one embodiment of the present invention, such as... Figure 7 As shown, the height map obtained after multiplication contains detailed texture information of the graphics contained in the drawn image.
[0089] Optionally, determining the target pixel corresponding to each second pixel among multiple first pixels based on the drawn image, height map, and rotated image includes: determining the first plane where the rotated image is located; constructing a ray corresponding to each second pixel based on preset points and each second pixel in the rotated image; determining the target point on the ray corresponding to each second pixel; controlling the target point to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, obtaining the intersection position of the target point of each second pixel and the height map; and determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0090] The first plane mentioned above can be the plane where the rotated image is located.
[0091] The aforementioned preset point can be a light source point or the starting point of a ray. Optionally, a light ray can be emitted from the preset point and pass through the rotating image to determine the height information corresponding to multiple second pixel points on the rotating image. The preset point can be the location of the virtual camera.
[0092] The target point mentioned above can descend step by step along the ray. Optionally, when the ray passes through the rotated image, the height of the target point on the ray can be calculated, and the target point can be controlled to descend step by step along the ray according to the height of the target point until the target point reaches the position recorded in the height map. Figure 8 This is a schematic diagram of the intersection of a preset point and a first plane according to one embodiment of the present invention, as shown below. Figure 8 As shown, a light beam can be emitted from a preset point and pass through the rotating image.
[0093] The aforementioned target angle can be the angle between the ray and the first plane. Figure 9 This is a schematic diagram of a target included angle according to one embodiment of the present invention, such as... Figure 9 As shown, when the ray passes through the first plane, there is a certain angle between it and the first plane.
[0094] In one optional embodiment, the target point on the ray can be controlled to descend step by step along the ray until the target point reaches the same height in the height map. Optionally, a perpendicular line can be drawn from the intersection point to the drawing image, and the first pixel point at the position perpendicular to the intersection point and the drawing image can be determined as the target pixel point. The pixel value of the target pixel point can be determined as the pixel value at the intersection point of the ray and the rotated image.
[0095] Optionally, the target point is controlled to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map. This includes: controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point; determining whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtaining a comparison result; in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continuing to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point in the ray; in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determining the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel with the height map.
[0096] The height information of the target point mentioned above can be the height information of the target point at different time points during the ray descent process.
[0097] Figure 10 This is a schematic diagram of target point movement according to one embodiment of the present invention, such as... Figure 10 As shown, the descent height of the ray can be monitored in real time during the descent process. The height information of the target point is compared with the height information in the height map to determine whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map. If they are inconsistent, it means that the target point has not yet touched the height map, and the descent needs to continue. If they are consistent, it means that the height information of the target point corresponding to each second pixel is consistent with the height information in the height map. Therefore, the current position of the target point corresponding to the second pixel can be determined as the intersection point of the ray and the height map for each second pixel. Furthermore, the pixel value of the current position of the target point corresponding to the second pixel can be determined through this position.
[0098] Optionally, the target point is controlled to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point, including: obtaining the difference between a preset value and the cosine value of the target angle; and controlling the target point to descend step by step along the ray based on the difference to obtain the height information of the target point.
[0099] The above preset values can be set by the user, for example, setting the preset value to 1, but are not limited to this.
[0100] Figure 11 This is a schematic diagram of a ray descent according to one embodiment of the present invention, such as... Figure 11 As shown, the drawn image can be placed on the xy plane with the z-axis set to 0, and the camera looking towards the -z-axis. The drawn image is then rotated based on rotation information. Optionally, after rotating the drawn image, for any point on this plane, there exists a line A, which is the vector from the camera to that point. Simultaneously, a tangent space exists for this plane, containing three standard vectors: the tangent, normal, and bitangent at that point on the plane, forming a Cartesian coordinate system. That is, vector A can be transformed into this tangent space. Optionally, the cosine of the target angle can be calculated within this Cartesian coordinate system and used as a parameter for each ray descent. This parameter is then subtracted from a preset value until the target point contacts the height map.
[0101] Optionally, the drawn image is rotated according to preset rotation information to obtain a rotated image, including: determining the rectangular coordinate system corresponding to the drawn image; determining the first preset axis and rotation angle corresponding to the rectangular coordinate system based on the preset rotation information; and controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0102] The first preset axis mentioned above can be the rotation axis for drawing the image.
[0103] In one optional embodiment, after obtaining preset rotation information, the drawn image can be rotated based on the rotation axis and rotation angle in the preset rotation information to obtain a rotated image. Taking the X-axis of the Cartesian coordinate system as an example, when the first rotation axis is the X-axis of the Cartesian coordinate system, the drawn image can be rotated along the X-axis of the Cartesian coordinate system.
[0104] Optionally, the rotating image is drawn based on the target pixel corresponding to each second pixel to obtain the target image, including: acquiring the pixel value corresponding to the target pixel corresponding to each second pixel; filling each second pixel based on the pixel value corresponding to the target pixel corresponding to each second pixel to obtain the target image.
[0105] In one optional embodiment, after obtaining the target pixel, the pixel value of the target pixel can be collected and determined as the pixel value of the corresponding second pixel. Optionally, the second pixel can be filled using the pixel value until each second pixel is filled, thereby obtaining a target image with color.
[0106] Furthermore, by using the above method, only the drawn image and the desired 3D angle are required to obtain the rotated target image, thereby reducing the image production time and the product production cycle, which in turn increases the output during working hours and reduces production costs.
[0107] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, 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 is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0108] This embodiment also provides an apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the terms "unit" and "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0109] Figure 12 This is a structural block diagram of a device according to one embodiment of the present invention. As shown in the figure, the device includes:
[0110] The acquisition module 1202 is used to acquire the height map of the drawn image, wherein the drawn image includes multiple first pixels, and the height map is used to represent the height information of each first pixel in the drawn image.
[0111] The rotation module 1204 is used to rotate the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes multiple second pixels.
[0112] The determination module 1206 is used to determine the target pixel point corresponding to each second pixel point among a plurality of first pixel points based on the drawn image, height map and rotated image.
[0113] The drawing module 1208 is used to draw the rotated image based on the target pixel corresponding to each second pixel to obtain the target image.
[0114] Optionally, the acquisition module includes: an acquisition unit for acquiring image information of each first pixel in the drawn image; a first determination unit for determining a preset basic shape based on the contour information of the drawn image; a second determination unit for determining a preset height map corresponding to the preset basic shape; and a third determination unit for obtaining a height map based on the product of the image information of each first pixel and the preset height map.
[0115] Optionally, the third determining unit includes: a first determining subunit, used to determine the color information of each first pixel based on the image information of each first pixel in the drawn image; a first conversion subunit, used to convert the color information of each first pixel to obtain the brightness information of each first pixel; a first conversion subunit, used to convert the image information of each first pixel to obtain the brightness information of each first pixel; and a second determining subunit, used to obtain a height map based on the product of the brightness information of each first pixel and a preset height map.
[0116] Optionally, the determining module includes: a fourth determining unit for determining the first plane where the rotated image is located; a constructing unit for constructing a ray corresponding to each second pixel based on a preset point and each second pixel in the rotated image; a fifth determining unit for determining a target point on the ray corresponding to each second pixel; a controlling unit for controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thereby obtaining the intersection position of the target point of each second pixel with the height map; and a sixth determining unit for determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0117] Optionally, the control unit includes: a first control subunit, configured to control a target point to descend stepwise along a ray based on the target angle between the ray of each second pixel and the first plane, thereby obtaining the height information of the target point; a judgment subunit, configured to judge whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtain a comparison result; an execution subunit, configured to, in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continue to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane, thereby obtaining the height information of the target point in the ray; and a third determination subunit, configured to, in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determine the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel and the height map.
[0118] Optionally, the control unit includes: an acquisition subunit for acquiring the difference between a preset value and the cosine of the angle between the target and the target; and a second control subunit for controlling the target point to descend stepwise along the ray based on the difference, thereby obtaining the height information of the target point.
[0119] Optionally, the rotation module includes: a seventh determining unit for determining the Cartesian coordinate system corresponding to the drawn image; an eighth determining unit for determining the first preset axis and rotation angle corresponding to the Cartesian coordinate system based on preset rotation information; and a rotation unit for controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0120] Optionally, the drawing module includes: a acquisition unit for acquiring the pixel value corresponding to the target pixel point for each second pixel point; and a filling unit for filling each second pixel point based on the pixel value corresponding to the target pixel point for each second pixel point to obtain the target image.
[0121] It should be noted that the above-mentioned units and modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but not limited to these: all the above-mentioned units and modules are located in the same processor; or, the above-mentioned units and modules are located in different processors in any combination.
[0122] Embodiments of the present invention also provide a non-volatile storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0123] Optionally, in this embodiment, the aforementioned non-volatile storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0124] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0125] Optionally, in this embodiment, the non-volatile storage medium can be configured to store a computer program for performing the following steps: obtaining a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; rotating the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; determining a target pixel corresponding to each second pixel among the plurality of first pixels based on the drawn image, the height map, and the rotated image; and drawing the rotated image based on the target pixel corresponding to each second pixel to obtain a target image.
[0126] Optionally, obtaining the height map of the drawn image includes: obtaining image information of each first pixel in the drawn image; determining a preset basic shape based on the contour information of the drawn image; determining a preset height map corresponding to the preset basic shape; and obtaining the height map based on the product of the image information of each first pixel and the preset height map.
[0127] Optionally, a height map is obtained based on the product of the image information of each first pixel and a preset height map, including: determining the color information of each first pixel based on the image information of each first pixel in the drawn image; performing a conversion process on the color information of each first pixel to obtain the brightness information of each first pixel; performing a conversion process on the image information of each first pixel to obtain the brightness information of each first pixel; and obtaining the height map based on the product of the brightness information of each first pixel and the preset height map.
[0128] Optionally, determining the target pixel corresponding to each second pixel among multiple first pixels based on the drawn image, height map, and rotated image includes: determining the first plane where the rotated image is located; constructing a ray corresponding to each second pixel based on preset points and each second pixel in the rotated image; determining the target point on the ray corresponding to each second pixel; controlling the target point to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, obtaining the intersection position of the target point of each second pixel and the height map; and determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0129] Optionally, the target point is controlled to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map. This includes: controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point; determining whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtaining a comparison result; in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continuing to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point in the ray; in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determining the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel with the height map.
[0130] Optionally, the target point is controlled to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point, including: obtaining the difference between a preset value and the cosine value of the target angle; and controlling the target point to descend step by step along the ray based on the difference to obtain the height information of the target point.
[0131] Optionally, the drawn image is rotated according to preset rotation information to obtain a rotated image, including: determining the rectangular coordinate system corresponding to the drawn image; determining the first preset axis and rotation angle corresponding to the rectangular coordinate system based on the preset rotation information; and controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0132] Optionally, the rotating image is drawn based on the target pixel corresponding to each second pixel to obtain the target image, including: acquiring the pixel value corresponding to the target pixel corresponding to each second pixel; filling each second pixel based on the pixel value corresponding to the target pixel corresponding to each second pixel to obtain the target image.
[0133] In this embodiment, a method for image processing is provided in a non-volatile storage medium. The method involves obtaining a height map of a drawn image, where the drawn image includes multiple first pixels, and the height map represents the height information of each first pixel in the drawn image; rotating the drawn image according to preset rotation information to obtain a rotated image, where the rotated image includes multiple second pixels; determining a target pixel corresponding to each second pixel among the multiple first pixels based on the drawn image, the height map, and the rotated image; and drawing the rotated image based on the target pixel corresponding to each second pixel to obtain a target image. It is noteworthy that after obtaining the height map, the drawn image and the rotated image can be correlated in terms of position, thereby using the first pixels of the drawn image to determine the second pixels of the rotated image and obtain the target pixel. Then, the target pixel is used to draw the target image, thus allowing the user to obtain the target image without redrawing, improving work efficiency and reducing drawing costs, thereby solving the technical problem of low efficiency in image drawing in related technologies.
[0134] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the method according to the embodiments of the present invention.
[0135] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of the present invention can also be implemented as a program product comprising program code, which, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this embodiment according to various exemplary embodiments of the present invention.
[0136] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In the embodiments of the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0137] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0138] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0139] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0140] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0141] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0142] Obtain a height map of the drawn image, wherein the drawn image includes multiple first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; rotate the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes multiple second pixels; determine the target pixel corresponding to each second pixel among the multiple first pixels based on the drawn image, the height map, and the rotated image; draw the rotated image based on the target pixel corresponding to each second pixel to obtain the target image.
[0143] Optionally, obtaining the height map of the drawn image includes: obtaining image information of each first pixel in the drawn image; determining a preset basic shape based on the contour information of the drawn image; determining a preset height map corresponding to the preset basic shape; and obtaining the height map based on the product of the image information of each first pixel and the preset height map.
[0144] Optionally, a height map is obtained based on the product of the image information of each first pixel and a preset height map, including: determining the color information of each first pixel based on the image information of each first pixel in the drawn image; performing a conversion process on the color information of each first pixel to obtain the brightness information of each first pixel; performing a conversion process on the image information of each first pixel to obtain the brightness information of each first pixel; and obtaining the height map based on the product of the brightness information of each first pixel and the preset height map.
[0145] Optionally, determining the target pixel corresponding to each second pixel among multiple first pixels based on the drawn image, height map, and rotated image includes: determining the first plane where the rotated image is located; constructing a ray corresponding to each second pixel based on preset points and each second pixel in the rotated image; determining the target point on the ray corresponding to each second pixel; controlling the target point to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, obtaining the intersection position of the target point of each second pixel and the height map; and determining the target pixel corresponding to each second pixel from multiple first pixels based on the intersection position.
[0146] Optionally, the target point is controlled to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map. This includes: controlling the target point to descend stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point; determining whether the height information of the target point corresponding to each second pixel is consistent with the height information in the height map, and obtaining a comparison result; in response to the existence of a discrepancy between the height information of the target point corresponding to each second pixel and the height information in the height map, continuing to execute the step of descending stepwise along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point in the ray; in response to the consistency between the height information of the target point corresponding to each second pixel and the height information in the height map, determining the current position of the target point corresponding to each second pixel as the intersection position of the ray of each second pixel with the height map.
[0147] Optionally, the target point is controlled to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane to obtain the height information of the target point, including: obtaining the difference between a preset value and the cosine value of the target angle; and controlling the target point to descend step by step along the ray based on the difference to obtain the height information of the target point.
[0148] Optionally, the drawn image is rotated according to preset rotation information to obtain a rotated image, including: determining the rectangular coordinate system corresponding to the drawn image; determining the first preset axis and rotation angle corresponding to the rectangular coordinate system based on the preset rotation information; and controlling the drawn image to rotate along the preset axis based on the rotation angle to obtain a rotated image.
[0149] Optionally, the rotating image is drawn based on the target pixel corresponding to each second pixel to obtain the target image, including: acquiring the pixel value corresponding to the target pixel corresponding to each second pixel; filling each second pixel based on the pixel value corresponding to the target pixel corresponding to each second pixel to obtain the target image.
[0150] In this embodiment of the electronic device, an image processing method is provided. The method involves acquiring a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map represents the height information of each first pixel in the drawn image; rotating the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; determining a target pixel corresponding to each second pixel among the plurality of first pixels based on the drawn image, the height map, and the rotated image; and drawing the rotated image based on the target pixel corresponding to each second pixel to obtain a target image. It is readily apparent that after obtaining the height map, the drawn image and the rotated image can be correlated in position using the height map, thereby determining the second pixels of the rotated image using the first pixels of the drawn image and obtaining the target pixel. The target image is then drawn using the target pixel, thus allowing the user to obtain the target image without redrawing, improving work efficiency and reducing drawing costs, thereby solving the technical problem of low efficiency in image drawing in related technologies.
[0151] Figure 13 This is a schematic diagram of an electronic device according to an embodiment of the present invention. Figure 13 As shown, the electronic device 1300 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0152] like Figure 13As shown, the electronic device 1300 is presented in the form of a general-purpose computing device. The components of the electronic device 1300 may include, but are not limited to: at least one processor 1310, at least one memory 1320, a bus 1330 connecting different system components (including memory 1320 and processor 1310), and a display 1340.
[0153] The memory 1320 stores program code that can be executed by the processor 1310, causing the processor 1310 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of the present invention.
[0154] The memory 1320 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 13201 and / or cache memory 13202, and may further include read-only memory (ROM) 13203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0155] In some instances, memory 1320 may also include programs / utilities 13204 having a set (at least one) of program modules 13205, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 1320 may further include memory remotely located relative to processor 1310, which can be connected to electronic device 1300 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0156] Bus 1330 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 1310, or a local bus using any of the various bus structures.
[0157] The display 1340 may be, for example, a touch screen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 1300.
[0158] Optionally, the electronic device 1300 can also communicate with one or more external devices 1400 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 1300, and / or any device that enables the electronic device 1300 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 1350. Furthermore, the electronic device 1300 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via the network adapter 1360. Figure 13 As shown, network adapter 1360 communicates with other modules of electronic device 1300 via bus 1330. It should be understood that, although... Figure 13 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 1300, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0159] The aforementioned electronic device 1300 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply, and / or a camera.
[0160] Those skilled in the art will understand that Figure 13 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 1300 may also include components that are more... Figure 13 The more or fewer components shown, or having the same Figure 1 Different configurations are shown. The memory 1320 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the image processing method in this embodiment of the invention. The processor 1310 executes various functional applications and data processing by running the computer program stored in the memory 1320, thereby implementing the aforementioned image processing method.
[0161] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0162] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0163] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0164] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0165] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0166] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0167] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. An image processing method, characterized in that, The method includes: Obtain a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; The drawn image is rotated according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; Determine the first plane in which the rotated image is located; Construct a ray corresponding to each second pixel point based on the preset point and each second pixel point in the rotated image; Determine the target point on the ray corresponding to each second pixel; Based on the target angle between the ray of each second pixel and the first plane, the target point is controlled to descend step by step along the ray until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map; Based on the intersection position, determine the target pixel corresponding to each second pixel from the plurality of first pixels; The rotated image is drawn based on the target pixel corresponding to each second pixel to obtain the target image.
2. The method according to claim 1, characterized in that, Obtain the height map of the drawn image, including: Obtain the image information of each first pixel in the drawn image; The preset basic shape is determined based on the contour information of the drawn image; Determine the preset height map corresponding to the preset basic shape; The height map is obtained by multiplying the image information of each first pixel point with the preset height map.
3. The method according to claim 2, characterized in that, The height map is obtained by multiplying the image information of each first pixel point with the preset height map, including: The color information of each first pixel is determined based on the image information of each first pixel in the drawn image; The color information of each first pixel is converted to obtain the brightness information of each first pixel. The image information of each first pixel is transformed to obtain the brightness information of each first pixel; The height map is obtained by multiplying the brightness information of each first pixel point with the preset height map.
4. The method according to claim 1, characterized in that, Based on the target angle between the ray of each second pixel and the first plane, the target point is controlled to descend step by step along the ray until the target point of each second pixel intersects with the height map, thus obtaining the intersection position of the target point of each second pixel with the height map, including: Based on the target angle between the ray of each second pixel and the first plane, the target point is controlled to descend step by step along the ray to obtain the height information of the target point; Determine whether the height information of the target point corresponding to each second pixel point is consistent with the height information in the height map, and obtain the comparison result; In response to the inconsistency between the height information of the target point corresponding to each second pixel and the height information in the height map, the step of stepping down the target point of the ray based on the target angle between the ray of each second pixel and the first plane is continued to obtain the height information of the target point in the ray. In response to the fact that the height information of the target point corresponding to each second pixel point is consistent with the height information in the height map, the current position of the target point corresponding to each second pixel point is determined to be the intersection position of the ray of each second pixel point and the height map.
5. The method according to claim 4, characterized in that, Based on the target angle between the ray of each second pixel and the first plane, the target point is controlled to descend step by step along the ray to obtain the height information of the target point, including: Obtain the difference between the preset value and the cosine of the angle between the target angle and the target angle. Based on the difference, the target point is controlled to descend step by step along the ray to obtain the height information of the target point.
6. The method according to claim 1, characterized in that, The drawn image is rotated according to preset rotation information to obtain a rotated image, including: Determine the Cartesian coordinate system corresponding to the drawn image; Based on the preset rotation information, determine the first preset axis and rotation angle corresponding to the Cartesian coordinate system; The image is rotated along the preset axis based on the rotation angle to obtain the rotated image.
7. The method according to claim 1, characterized in that, The rotated image is drawn based on the target pixel corresponding to each second pixel to obtain the target image, including: Collect the pixel value corresponding to the target pixel point corresponding to each second pixel point; The target image is obtained by filling each second pixel with the pixel value corresponding to the target pixel corresponding to each second pixel.
8. An image processing apparatus, characterized in that, The device includes: An acquisition module is used to acquire a height map of a drawn image, wherein the drawn image includes a plurality of first pixels, and the height map is used to represent the height information of each first pixel in the drawn image; A rotation module is used to rotate the drawn image according to preset rotation information to obtain a rotated image, wherein the rotated image includes a plurality of second pixels; A determining module is used to determine a first plane where the rotated image is located; construct a ray corresponding to each second pixel based on a preset point and each second pixel in the rotated image; determine a target point on the ray corresponding to each second pixel; control the target point to descend step by step along the ray based on the target angle between the ray of each second pixel and the first plane until the target point of each second pixel intersects with the height map, obtaining the intersection position of the target point of each second pixel and the height map; and determine the target pixel corresponding to each second pixel from the plurality of first pixels based on the intersection position. The drawing module is used to draw the rotated image based on the target pixel corresponding to each second pixel to obtain the target image.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the image processing method according to any one of claims 1 to 7 when run by a processor.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the image processing method according to any one of claims 1 to 7.