Image processing method, device, electronic device and storage medium
By acquiring and processing the initial texture coordinates of the image, determining its target offset at each moment, and generating a dynamic distorted image, the problems of poor authenticity and large calculation amount in the prior art are solved, real-time dynamic effects and resource savings are achieved, and it is suitable for mobile terminals.
Patent Information
- Application Number
- CN202111481178.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2041-12-06
AI Technical Summary
In the prior art, the image distortion effect is poor, dynamic distorted images cannot be automatically generated, and the calculation amount is large, and it is not suitable for mobile deployment.
By obtaining the initial texture coordinates, determining its target offset at each moment, using a cosine function or texture sampling function to process the fluctuation velocity and pixel distortion periods, generating the target texture coordinates and generating a dynamic distorted image.
Real-time simulation of dynamic fluctuations is achieved, improving the authenticity and attractiveness of images, saving computing resources, and suitable for mobile deployment.
Smart Images

Figure CN114187167B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device, electronic device, and storage medium. Background Art
[0002] In image processing, various cool special effects can enhance the tension of video effects, among which simulation is a relatively good direction. In the process of simulation, it is often necessary to distort the image to obtain an aesthetically pleasing image.
[0003] In related technologies, designers usually need to use professional drawing software to achieve image distortion effects. The process is cumbersome, the distortion effect is less realistic, and it cannot automatically generate dynamic distorted images. In addition, the simulation methods in related technologies usually have a large amount of computation, cannot simulate dynamic effects in real time, and are not suitable for deployment on mobile terminals.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0005] The embodiments of the present disclosure provide an image processing method, an image processing device, an electronic device, a computer-readable storage medium, and a computer program product, which can simulate the image effect of dynamic fluctuations in real time, thereby improving the realism and attractiveness of the picture; and the method is simple to implement, can save computing resources, and improve computing efficiency, so that it can be deployed on a mobile terminal.
[0006] An embodiment of the present disclosure provides an image processing method, comprising: obtaining initial texture coordinates of an image to be processed; determining a target offset of the initial texture coordinates at each moment; determining a target texture coordinate at each moment based on the initial texture coordinates and the target offset at each moment; generating a target warped image at each moment based on the target texture coordinates at each moment; and generating a target dynamic warped image based on the target warped image at each moment.
[0007] In some exemplary embodiments of the present disclosure, the initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and the first direction in which the initial texture coordinates in the first direction are located is perpendicular to the second direction in which the initial texture coordinates in the second direction are located; wherein, the step of determining the target offset of the initial texture coordinates at each moment includes: obtaining a fluctuation speed and a pixel distortion period, wherein the fluctuation speed is a parameter for controlling the degree of motion of the image to be processed, and the pixel distortion period is a parameter for controlling the number of sine waves in a target dynamically distorted image generated based on the image to be processed; using a cosine function to process the fluctuation speed, the pixel distortion period and the initial texture coordinates in the target direction to determine the target offset at each moment; wherein the initial texture coordinates in the target direction are the initial texture coordinates in the first direction or the initial texture coordinates in the second direction.
[0008] In some exemplary embodiments of the present disclosure, the step of determining the target texture coordinates at each moment based on the initial texture coordinates and the target offset at each moment includes: obtaining a pixel distortion amplitude, a coordinated adjustment parameter, and a target direction vector, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, the coordinated adjustment parameter is a parameter for adjusting the granularity of the pixel distortion amplitude, and the target direction vector is a vector for adjusting the initial texture coordinates in the first direction and the initial texture coordinates in the second direction; determining the target texture coordinates at each moment based on the target offset, the pixel distortion amplitude, the coordinated adjustment parameter, the target direction vector, and the initial texture coordinates.
[0009] In some exemplary embodiments of the present disclosure, the step of determining the target offset of the initial texture coordinates at each moment includes: obtaining a Perlin noise image; processing the Perlin noise image and the initial texture coordinates using a texture sampling function to determine the target offset of the initial texture coordinates at each moment.
[0010] In some exemplary embodiments of the present disclosure, a texture sampling function is used to process a Perlin noise image and initial texture coordinates, and the step of determining a target offset of the initial texture coordinates at each moment includes: obtaining a first-layer sampling offset and a second-layer sampling offset, and a first weight of the first-layer offset, wherein the first-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the second time, and the first weight of the first-layer offset is a parameter for regulating the weight of the first-layer offset; using the texture sampling function to process the Perlin noise image, the initial texture coordinates, and the first-layer sampling offset to obtain the first-layer offset at each moment; using the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second-layer sampling offset, the first-layer offset and its first weight to determine the target offset at each moment.
[0011] In some exemplary embodiments of the present disclosure, the steps of using a texture sampling function to process a Perlin noise image, initial texture coordinates, a second-layer sampling offset vector, and a first-layer offset and a first weight thereof to determine a target offset at each moment include: obtaining a third-layer sampling offset and a second weight of the second-layer offset, wherein the third-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the third time, and the second weight of the second-layer offset is a parameter for regulating the weight of the second-layer offset; using a texture sampling function to process the Perlin noise image, initial texture coordinates, the second-layer sampling offset, and the first-layer offset and a first weight thereof to obtain the second-layer offset corresponding to each moment; using a texture sampling function to process the Perlin noise image, initial texture coordinates, the third-layer sampling offset, and the second-layer offset and a second weight thereof to determine the target offset at each moment.
[0012] In some exemplary embodiments of the present disclosure, the initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction; wherein, the steps of using a texture sampling function to process the Perlin noise image, the initial texture coordinates, and the first layer sampling offset to determine the first layer offset at each moment include: determining the aspect ratio of the image to be processed, the time weight of the first layer, and the first moment; determining a first intermediate coordinate vector based on the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; determining a second intermediate coordinate vector based on the time weight of the first layer and the first moment; determining a target intermediate coordinate vector based on the first intermediate coordinate vector and the second intermediate coordinate vector; and using a texture sampling function to process the Perlin noise image and the target intermediate coordinate vector to obtain the first layer offset at the first moment.
[0013] In some exemplary embodiments of the present disclosure, the step of determining the target texture coordinates at each moment based on the initial texture coordinates and the target offset at each moment includes: obtaining a pixel distortion amplitude and a coordinated adjustment parameter, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, and the coordinated adjustment parameter is a parameter for adjusting the granularity of the pixel distortion amplitude; determining the target texture coordinates at each moment based on the target offset, the pixel distortion amplitude, the coordinated adjustment parameter, and the initial texture coordinates.
[0014] An embodiment of the present disclosure provides an image processing device, comprising: an acquisition module configured to acquire initial texture coordinates of an image to be processed; a determination module configured to determine a target offset of the initial texture coordinates at each moment; the determination module further configured to obtain target texture coordinates at each moment based on the initial texture coordinates and the target offset at each moment; a generation module configured to generate a target warped image at each moment based on the target texture coordinates at each moment; and the generation module further configured to generate a target dynamic warped image based on the target warped image at each moment.
[0015] In some exemplary embodiments of the present disclosure, the initial texture coordinates include first-direction initial texture coordinates and second-direction initial texture coordinates, and the first direction where the first-direction initial texture coordinates are located is perpendicular to the second direction where the second-direction initial texture coordinates are located; the acquisition module is further configured to execute acquisition of the fluctuation speed and the pixel distortion period, wherein the fluctuation speed is a parameter for controlling the degree of motion of the image to be processed, and the pixel distortion period is a parameter for controlling the number of sine waves in the target dynamic distortion image generated according to the image to be processed; the determination module is further configured to execute processing of the fluctuation speed, the pixel distortion period and the target direction initial texture coordinates using a cosine function to determine the target offset at each moment; wherein the target direction initial texture coordinates are the first-direction initial texture coordinates or the second-direction initial texture coordinates.
[0016] In some exemplary embodiments of the present disclosure, the acquisition module is further configured to execute acquisition of pixel distortion amplitude, collaborative adjustment parameters and target direction vector, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, the collaborative adjustment parameters are parameters for adjusting the granularity of the pixel distortion amplitude, and the target direction vector is a vector for adjusting the initial texture coordinates in the first direction and the initial texture coordinates in the second direction; the determination module is further configured to execute determination of the target texture coordinates at each moment based on the target offset, pixel distortion amplitude, collaborative adjustment parameters, target direction vector and initial texture coordinates at each moment.
[0017] In some exemplary embodiments of the present disclosure, the acquisition unit is further configured to acquire a Perlin noise image; the determination module is further configured to process the Perlin noise image and the initial texture coordinates using a texture sampling function to determine the target offset of the initial texture coordinates at each moment.
[0018] In some exemplary embodiments of the present disclosure, the acquisition module is further configured to acquire a first-layer sampling offset and a second-layer sampling offset, as well as a first weight of the first-layer offset, wherein the first-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the second time, and the first weight of the first-layer offset is a parameter for regulating the weight of the first-layer offset; the determination module is further configured to execute processing of the Perlin noise image, the initial texture coordinates, and the first-layer sampling offset using a texture sampling function to determine the first-layer offset at each moment; the determination module is further configured to execute processing of the Perlin noise image, the initial texture coordinates, the second-layer sampling offset, the first-layer offset and its first weight using a texture sampling function to determine the target offset at each moment.
[0019] In some exemplary embodiments of the present disclosure, the acquisition module is further configured to acquire a third-layer sampling offset and a second weight of the second-layer offset, wherein the third-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the third time, and the second weight of the second-layer offset is a parameter for regulating the weight of the second-layer offset; the determination module is further configured to execute the use of a texture sampling function to process the Perlin noise image, the initial texture coordinates, the second-layer sampling offset, and the first-layer offset and its first weight to determine the second-layer offset corresponding to each moment; the determination module is further configured to execute the use of a texture sampling function to process the Perlin noise image, the initial texture coordinates, the third-layer sampling offset, and the second-layer offset and its second weight to determine the target offset at each moment.
[0020] In some exemplary embodiments of the present disclosure, the initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and each moment includes a first moment; the acquisition module is also configured to acquire the aspect ratio of the image to be processed and the time weight of the first layer; the determination module is also configured to determine the first intermediate coordinate vector based on the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; the determination module is also configured to determine the second intermediate coordinate vector based on the time weight of the first layer and the first moment; the determination module is also configured to determine the target intermediate coordinate vector based on the first intermediate coordinate vector and the second intermediate coordinate vector; the determination module is also configured to process the Perlin noise image and the target intermediate coordinate vector using a texture sampling function to determine the first layer offset at the first moment.
[0021] In some exemplary embodiments of the present disclosure, the acquisition unit is further configured to acquire pixel distortion amplitude and collaborative adjustment parameters, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, and the collaborative adjustment parameter is a parameter for adjusting the granularity of the pixel distortion amplitude; the determination module is further configured to determine the target texture coordinates at each moment based on the target offset, pixel distortion amplitude, collaborative adjustment parameters and initial texture coordinates at each moment.
[0022] An embodiment of the present disclosure provides an electronic device, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement any of the above-mentioned image processing methods.
[0023] An embodiment of the present disclosure provides a computer-readable storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can perform any of the above-mentioned image processing methods.
[0024] An embodiment of the present disclosure provides a computer program product, a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, any of the above-mentioned image processing methods is implemented.
[0025] In the technical solutions provided by some embodiments of the present disclosure, the target offset of the initial texture coordinates at each moment can be determined, and the target texture coordinates can be obtained based on the target offset, thereby simply and efficiently obtaining the target distorted image and the target dynamically distorted image. This method can simulate the effect of dynamic fluctuations in real time, improving the realism and attractiveness of the image, thereby enhancing the user experience and increasing user stickiness. In addition, this method is simple to implement, can save computing resources, and improve computing efficiency, making it suitable for deployment on mobile devices.
[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0028] Figure 1 The figure is a flowchart of an image processing method according to an exemplary embodiment.
[0029] Figure 2is a schematic diagram of an image to be processed according to an example.
[0030] Figure 3 is a schematic diagram of a target distorted image according to an example.
[0031] Figure 4 FIG. 4 is a schematic diagram of another target distorted image according to an example.
[0032] Figure 5 is a schematic diagram of another image to be processed according to an example.
[0033] Figure 6 FIG. 1 is a schematic diagram of a target distorted image at a certain moment according to an example.
[0034] Figure 7 is a flowchart of another image processing method according to an exemplary embodiment.
[0035] Figure 8 is a flowchart of another image processing method according to an exemplary embodiment.
[0036] Figure 9 is a schematic diagram of another image to be processed according to an example.
[0037] Figure 10 is a schematic diagram of a Perlin noise image according to an example.
[0038] Figure 11 FIG. 4 is a schematic diagram of another target distorted image according to an example.
[0039] Figure 12 is a block diagram of an image processing apparatus according to an exemplary embodiment.
[0040] Figure 13 It is a schematic structural diagram showing an electronic device suitable for implementing the exemplary embodiments of the present disclosure according to an exemplary embodiment. DETAILED DESCRIPTION
[0041] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be embodied in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art. Like reference numerals in the drawings represent like or similar parts, and thus repetitive description thereof will be omitted.
[0042] The features, structures or characteristics described in the present disclosure may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0043] The accompanying drawings are merely schematic illustrations of the present disclosure. Identical reference numerals in the drawings denote identical or similar components, and thus their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in at least one hardware module or integrated circuit, or in different networks and / or processor devices and / or microcontroller devices.
[0044] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all content and steps, nor must they be executed in the order described. For example, some steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0045] In this specification, the terms "a", "an", "the", "said" and "at least one" are used to indicate the presence of at least one element / component / etc.; the terms "comprising", "including" and "having" are used to express open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first", "second" and "third" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0046] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
[0047] Figure 1 is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 As shown, the image processing method may include the following steps.
[0048] In step S110 , initial texture coordinates of the image to be processed are obtained.
[0049] In the embodiment of the present disclosure, the images to be processed may include but are not limited to images taken by users, images downloaded from websites, images displayed on application software, etc.
[0050] Figure 2 is a schematic diagram of an image to be processed according to an example.
[0051] In the embodiment of the present disclosure, for example, it is possible to obtain Figure 2 The texture coordinates of the image to be processed are used as initial texture coordinates.
[0052] In an exemplary embodiment, the initial texture coordinates may include first-direction initial texture coordinates and second-direction initial texture coordinates, and a first direction where the first-direction initial texture coordinates are located is perpendicular to a second direction where the second-direction initial texture coordinates are located.
[0053] For example, the first direction initial texture coordinates may be horizontal direction texture coordinates, and the second direction initial texture coordinates may be vertical direction texture coordinates.
[0054] In step S120, the target offset of the initial texture coordinates at each moment is determined.
[0055] In the embodiment of the present disclosure, the target offset of the initial texture coordinates of the image to be processed at each moment can be determined respectively.
[0056] The target offset can be in numerical form or in vector form.
[0057] In the embodiment of the present disclosure, the target offset of the initial texture coordinates of the image to be processed at each moment can be determined respectively.
[0058] In the embodiments of the present disclosure, each moment may include one or more moments, such as a first moment, a second moment, etc. In the following examples, the target offset at the first moment is determined, thereby determining the target texture coordinates at the first moment. The processing methods for other moments are similar to those for the first moment, and are not further described in this disclosure.
[0059] The time may be a real time or the time when a computer program is running, which is not limited in the present disclosure.
[0060] In the embodiment of the present disclosure, a cosine function may be used to determine the target offset of the initial texture coordinates at the first moment, or a texture sampling function may be used to determine the target offset of the initial texture coordinates at the first moment.
[0061] In step S130 , target texture coordinates at each moment are determined based on the initial texture coordinates and the target offset at each moment.
[0062] In the embodiment of the present disclosure, the target offset at each moment may be superimposed on the initial texture coordinates to obtain the target texture coordinates at each moment.
[0063] In the disclosed embodiment, if the target offset is in numerical form, the target offset can be processed using a target direction vector and then superimposed on the initial texture coordinates, wherein the dimension of the target direction vector is the same as the dimension of the initial texture coordinates.
[0064] In the disclosed embodiment, if the target offset is in vector form, the target offset can be directly added to the initial texture coordinates, or the target offset can be processed using the pixel distortion amplitude and the coordinated adjustment parameter before being added to the initial texture coordinates.
[0065] The pixel distortion amplitude can be used to control the overall motion trend of the image. The larger the pixel distortion amplitude is, the greater the distortion degree of the target distorted image is.
[0066] In step S140 , a target warped image at each moment is generated according to the target texture coordinates at each moment.
[0067] In the embodiment of the present disclosure, taking the first moment as an example, the image to be processed may be sampled according to the target texture coordinates at the first moment to generate the target distorted image at the first moment.
[0068] Figure 3 is a schematic diagram of a target distorted image according to an example.
[0069] Figure 4 FIG. 4 is a schematic diagram of another target distorted image according to an example.
[0070] In the embodiment of the present disclosure, the target distorted image at the first moment can be as follows: Figure 3 or Figure 4 As shown, it can be seen that Figure 3 The target distorted image shown is natural and beautiful, reminiscent of the rippling water scene in nature. Figure 4 The target distorted image shown is harmonious, regular, and has a mathematical beauty, reminiscent of the waves.
[0071] Specifically, the image to be processed may be sampled according to the target texture coordinates at the first moment to obtain output color values, and the output color values may be rendered to corresponding pixel points to obtain the target distorted image at the first moment.
[0072] In step S150 , a target dynamic distorted image is generated based on the target distorted images at each moment.
[0073] In the embodiment of the present disclosure, a target distorted image at a first moment, a target distorted image at a second moment, ..., may be spliced in chronological order to generate a target dynamic distorted image.
[0074] For example, using the above method Figure 5The image to be processed is processed as shown in Figure 6 The target distorted image at a certain moment is shown, based on two or more images such as Figure 6 The target warped images at different moments shown can generate target dynamic warped images.
[0075] In the disclosed embodiment, the generated target dynamic distorted image can be displayed on the client for users to watch; the generated target dynamic distorted image can also be used in live broadcast software or video playback software for users to watch, which can improve user experience and increase user stickiness.
[0076] The image processing method provided by the disclosed embodiments can determine the target offset of the initial texture coordinates at each moment and obtain the target texture coordinates based on the target offset, thereby simply and efficiently obtaining the target distorted image and the target dynamically distorted image. This method can simulate the effects of dynamic fluctuations in real time, improving the realism and appeal of the image, thereby enhancing the user experience and increasing user engagement. Furthermore, the method is simple to implement, can save computing resources, and improve computational efficiency, making it suitable for deployment on mobile devices.
[0077] In addition, in some embodiments of the present disclosure, the method can quickly calculate the target offset using a cosine function or a texture sampling function, saving device resources, so that it can be deployed on a mobile terminal and can also run efficiently on devices with limited CPU and GPU capabilities.
[0078] Figure 7 is a flowchart of another image processing method according to an exemplary embodiment. Figure 9 As shown, the image processing method may include the following steps.
[0079] In step S710, initial texture coordinates of the image to be processed are obtained.
[0080] In the embodiment of the present disclosure, for example, Figure 2 or Figure 5 The image to be processed is shown.
[0081] In step S720, the fluctuation speed and the pixel distortion period are obtained.
[0082] In the embodiment of the present disclosure, the fluctuation speed is a parameter used to control the degree of motion of the image to be processed, wherein the fluctuation speed can be used as the frequency of the following cosine function. The greater the fluctuation speed, the more intense the image motion. The pixel distortion period is a parameter used to control the number of sine waves in the target dynamic distortion image generated based on the image to be processed, that is, the pixel distortion period can control the number of sine waves in the image. The greater the image distortion period, the more sine waves appear in the image.
[0083] For example, the value of the fluctuation speed (speed) can be 1, 3, 4, 9, etc., and the value of the pixel distortion period (distortionIntensity) can be 8, 9, 12, 15, etc. For example, the value of the fluctuation speed is 3 and the pixel distortion period is 12.
[0084] In practical applications, those skilled in the art may also set the values of the fluctuation speed and the pixel distortion period according to actual conditions, and this disclosure does not limit this.
[0085] In step S730, the cosine function is used to process the fluctuation speed, the pixel distortion period and the initial texture coordinates of the target direction to determine the target offset at each moment.
[0086] The target direction initial texture coordinates are the first direction initial texture coordinates or the second direction initial texture coordinates.
[0087] In the embodiment of the present disclosure, the first direction initial texture coordinates may be horizontal direction initial texture coordinates, and the second direction initial texture coordinates may be vertical direction initial texture coordinates.
[0088] Taking the first moment as an example, in the embodiment of the present disclosure, the fluctuation speed can be used as the frequency of the cosine function, and the first moment can be used as the time (time) of the cosine function. The initial phase (initial phase) of the cosine function is determined according to the initial horizontal texture coordinate (uv.x) or the initial vertical texture coordinate (uv.y) and the pixel distortion period. The target offset (dist) at the first moment is obtained through the cosine function. The formula can be:
[0089] dist=cos(speed×time-abs(1.0-uv.x)×distortionIntensity) (1)
[0090] Among them, cos represents the cosine function, abs represents the absolute value function, dist represents the target offset, speed represents the fluctuation speed, time represents time, uv.x represents the initial texture coordinate in the horizontal direction, and distortionIntensity represents the pixel distortion period.
[0091] Alternatively, the formula could be:
[0092] dist=cos(speed×time-abs(1.0-uv.y)×distortionIntensity) (2)
[0093] Among them, uv.y represents the initial texture coordinate in the horizontal direction.
[0094] The method for obtaining the target offset at other moments is similar to the method for obtaining the target offset at the first moment, and will not be described in detail herein.
[0095] In the embodiment of the present disclosure, the cosine function can be used to simply and efficiently determine the target offset of the initial texture coordinates of the image to be processed at each moment, thereby determining the target texture coordinates based on the target offset to achieve the effect of simulating dynamic waves. This method uses the cosine function to quickly calculate the target offset, saving device resources, and can thus be deployed on a mobile terminal.
[0096] In step S740 , the pixel distortion amplitude, the coordinated adjustment parameter, and the target direction vector are obtained.
[0097] In the embodiment of the present disclosure, the pixel distortion amplitude is a parameter used to regulate the offset range of the initial texture coordinates of the image to be processed, that is, the pixel distortion amplitude can regulate the offset range of the texture coordinates of each pixel in the image to be processed; the collaborative adjustment parameter is a parameter used to adjust the granularity of the pixel distortion amplitude, that is, the collaborative adjustment parameter can be a preset constant to facilitate the adjustment of the pixel distortion amplitude; the target direction vector is a vector used to adjust the initial texture coordinates in the first direction and the initial texture coordinates in the second direction, wherein the target direction vector can be a two-dimensional vector, used to adjust the initial texture coordinates in the first direction and the initial texture coordinates in the second direction, respectively.
[0098] For example, the value of the coordinated adjustment parameter (distortionAmount) can be 0.001, 0.01, 0.1, etc., and the value of the pixel distortion amplitude (power) can be 7, 8.2, 10, etc. For example, the value of the coordinated adjustment parameter is 0.01, and the value of the pixel distortion amplitude is 8.2.
[0099] For example, the target direction vector can be vec2(0.0,1.0), vec2(1.0,0.0), vec2(0.5,0.5), vec2(0.6,0.4), or vec2(0.6,0.8). The first dimension of the target direction vector can be used to adjust the horizontal initial texture coordinates, and the second dimension of the target direction vector can be used to adjust the vertical initial texture coordinates.
[0100] In practical applications, those skilled in the art may also set the pixel distortion amplitude, collaborative adjustment parameters, and target direction vector according to actual conditions, and this disclosure does not limit this.
[0101] In step S750, the target texture coordinates at each moment are determined according to the target offset, pixel distortion amplitude, cooperative adjustment parameter, target direction vector and initial texture coordinates at each moment.
[0102] Taking the first moment as an example, in the embodiment of the present disclosure, the target offset, pixel distortion period, and collaborative adjustment parameter at the first moment can be multiplied together, then multiplied by the target direction vector, and then added to the initial texture coordinates to obtain the target texture coordinates at the first moment. The formula can be:
[0103]
[0104] in, represents the target texture coordinates, represents the initial texture coordinates, represents the target direction vector, where and are two-dimensional vectors.
[0105] Among them, the pixel distortion period, the coordinated adjustment parameter and the target direction vector can all be adjusted according to actual conditions.
[0106] In the embodiment of the present disclosure, the target texture coordinates can be determined based on the target offset of the image to be processed at each moment determined using the cosine function, thereby generating a target distorted image, which can achieve the effect of simulating dynamic waves. This method can quickly generate a target dynamic distorted image, save device resources, and can be deployed on a mobile terminal.
[0107] In step S760 , a target warped image at each moment is generated according to the target texture coordinates at each moment.
[0108] In the embodiment of the present disclosure, the target texture coordinates at each moment can be generated. Figure 4 Or as Figures 6 to 8 The target distortion images at various moments are shown.
[0109] In step S770 , a target dynamic distorted image is generated based on the target distorted images at each moment.
[0110] Figure 7 In the embodiment shown, Figure 1 The same steps in the embodiment shown can be seen in Figure 1 The textual description of the illustrated embodiments will not be repeated in this disclosure.
[0111] The image processing method provided by the embodiments of the present disclosure can use the cosine function to simply and efficiently distort and liquefy the processed image, achieving the effect of simulating dynamic waves, and obtaining a target distorted image and a target dynamic distorted image that are harmonious, regular, and mathematically beautiful, reminiscent of the scene of undulating waves. In addition, this method can quickly calculate the target offset using the cosine function, saving device resources, and thus can be deployed on mobile devices. Moreover, it can also run efficiently on devices with limited CPU and GPU capabilities.
[0112] Figure 8 is a flowchart of another image processing method according to an exemplary embodiment. Figure 10 As shown, the image processing method may include the following steps.
[0113] In step S810, initial texture coordinates of the image to be processed are obtained.
[0114] Figure 9 is a schematic diagram of another image to be processed according to an example.
[0115] In the embodiment of the present disclosure, for example, Figure 2 or Figure 9 The image to be processed is shown.
[0116] In step S820 , a Perlin noise image is acquired.
[0117] Among them, Perlin noise refers to the natural noise generation algorithm invented by Ken Perlin.
[0118] In the embodiment of the present disclosure, the Perlin noise image may be processed by a texture sampling function to obtain a target offset of the initial texture coordinates.
[0119] Figure 10 is a schematic diagram of a Perlin noise image according to an example.
[0120] In the embodiment of the present disclosure, for example, Figure 10 The Perlin noise image shown is a color image. It should be noted that the Perlin noise image can be in color.
[0121] In step S830, the Perlin noise image and the initial texture coordinates are processed using a texture sampling function to determine target offsets of the initial texture coordinates at various moments.
[0122] In the disclosed embodiment, a texture sampling function (eg, texture2D) may be used to process the Perlin noise image and the initial texture coordinates, and a color sampling value of the Perlin noise image at the initial texture coordinates may be obtained, which may be used as a target offset.
[0123] The image processing method provided by the embodiment of the present disclosure can use the texture sampling function to simply and efficiently determine the target offset of the initial texture coordinates of the image to be processed at each moment, thereby determining the target texture coordinates based on the target offset to achieve the effect of simulating dynamic waves. This method uses the texture sampling function to quickly calculate the target offset, saving device resources, and can thus be deployed on a mobile terminal.
[0124] In an exemplary embodiment, the steps of using a texture sampling function to process the Perlin noise image and the initial texture coordinates to obtain the target offset of the initial texture coordinates at each moment may include: obtaining the first-layer sampling offset and the second-layer sampling offset, and the first weight of the first-layer offset; using the texture sampling function to process the Perlin noise image, the initial texture coordinates, and the first-layer sampling offset to determine the first-layer offset at each moment; using the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second-layer sampling offset, the first-layer offset and its first weight to determine the target offset at each moment.
[0125] In the embodiment of the present disclosure, the first-layer sampling offset is a parameter used to control the position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter used to control the position offset when sampling the Perlin noise image for the second time, and the third-layer sampling offset is a parameter used to control the position offset when sampling the Perlin noise image for the third time. The first weight of the first-layer offset is a parameter used to control the weight of the first-layer offset, and the second weight of the second-layer offset is a parameter used to control the weight of the second-layer offset.
[0126] The following description will be made by taking the example of obtaining the target offset by processing the texture sampling function twice, but the present disclosure is not limited thereto.
[0127] In the embodiment of the present disclosure, a sampling offset vector sampleoff may be set. The sampling offset vector may be a two-dimensional vector, each dimension of which may represent a sampling offset of each layer.
[0128] For example, the sampling offset vector is set to vec2(1.2, 1.35), vec2(1.05, 1.1), vec2(1.38, 1.25), etc. Taking the sampling offset vector as vec2(1.2, 1.1) as an example, the first layer sampling offset can be 1.2, and the second layer sampling offset can be 1.1.
[0129] In the embodiment of the present disclosure, a weight of each layer offset may be set. For example, the first weight of the first layer offset is 0.65.
[0130] Taking the first moment as an example, in the embodiment of the present disclosure, the Perlin noise image, initial texture coordinates and first-layer sampling offset can be input into the texture sampling function (for example, texture2D) to obtain the first-layer offset at the first moment; the Perlin noise image, initial texture coordinates, second-layer sampling offset, and first-layer offset and its first weight can be input into the texture2D function to obtain the target offset at the first moment.
[0131] The image processing method provided by the embodiment of the present disclosure uses a texture sampling function to sample the Perlin operation image twice or more, which can make the target offset obtained by sampling more discrete and random, thereby making the obtained target distorted image more discrete and random, and the dynamic effect more realistic.
[0132] In an exemplary embodiment, the steps of using a texture sampling function to process a Perlin noise image, initial texture coordinates, a second-layer sampling offset vector, and a first-layer offset and its first weight to determine a target offset at each moment may include: obtaining a third-layer sampling offset and a second weight of the second-layer offset; using a texture sampling function to process a Perlin noise image, initial texture coordinates, a second-layer sampling offset, and a first-layer offset and its first weight to determine the second-layer offset corresponding to each moment; using a texture sampling function to process a Perlin noise image, initial texture coordinates, a third-layer sampling offset, and a second-layer offset and its second weight to determine the target offset at each moment.
[0133] The following description will be made by taking the example of obtaining the target offset through three-times texture sampling function processing, but the present disclosure is not limited thereto.
[0134] In the embodiment of the present disclosure, a sampling offset vector sampleoff may be set. The sampling offset vector may be a three-dimensional vector, each dimension of which may represent a sampling offset of each layer.
[0135] For example, the sampling offset vector is set to: vec3(1.2, 1.1, 1.23), vec3(1.05, 1.1, 1.33), vec3(1.2, 1.35, 1.23), etc. Taking the sampling offset vector as vec3(1.2, 1.1, 1.23) as an example, the first layer sampling offset can be 1.2, the second layer sampling offset can be 1.1, and the third layer sampling offset can be 1.23.
[0136] In the embodiment of the present disclosure, a weight of each layer offset may be set, and the weight may be 0.5, 0.65, 0.1, 0.2, 0.8, etc. For example, the first weight of the first layer offset is 0.65, and the second weight of the second layer offset is 0.01.
[0137] In the embodiment of the present disclosure, the more times the above-mentioned iterative process is performed, the more discrete and random the generated target distorted image is, and the more realistic the effect of simulating water ripple fluctuations is.
[0138] Taking the first moment as an example, in the embodiment of the present disclosure, the Perlin noise image, the initial texture coordinates and the first layer sampling offset can be input into the texture2D function to obtain the first layer offset at the first moment; the Perlin noise image, the initial texture coordinates, the second layer sampling offset, and the first layer offset and its first weight can be input into the texture2D function to obtain the second layer offset at the first moment; the Perlin noise image, the initial texture coordinates, the third layer sampling offset, and the second layer offset and its second weight can be input into the texture2D function to obtain the target offset at the first moment.
[0139] The image processing method provided by the embodiment of the present disclosure uses a texture sampling function to sample the Perlin operation image three or more times, which can make the target offset obtained by sampling more discrete and random, thereby making the obtained target distorted image more discrete and random, and the dynamic effect more realistic.
[0140] In an exemplary embodiment, the steps of using a texture sampling function to process a Perlin noise image, initial texture coordinates, and a first layer sampling offset to determine the first layer offset at each moment may include: obtaining the aspect ratio of the image to be processed and the time weight of the first layer; determining a first intermediate coordinate vector based on the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; determining a second intermediate coordinate vector based on the time weight of the first layer and the first moment; determining a target intermediate coordinate vector based on the first intermediate coordinate vector and the second intermediate coordinate vector; using a texture sampling function to process the Perlin noise image and the target intermediate coordinate vector to determine the first layer offset at the first moment to obtain the first layer offset at each moment.
[0141] The following description will be made by taking the first layer offset at the first moment as an example.
[0142] In the embodiment of the present disclosure, a time weight vector timeHelp may be set. The time weight vector may be a three-dimensional vector, each dimension of which may represent the time weight of each layer.
[0143] For example, the time weight vector is set to vec3(0.1, 0.1, 0.1), vec3(0.2, 0.2, 0.2), vec3(0.1, 0.3, 0.2), etc. Taking the sampling offset vector as vec3(0.1, 0.1, 0.1) as an example, the time weight of the first layer, the time weight of the second layer, and the time weight of the third layer can all be 0.1.
[0144] It should be noted that the time weight of each layer can be the same or different, and this disclosure does not impose any restrictions on this.
[0145] In the embodiment of the present disclosure, the width and height of the image to be processed may be acquired, thereby obtaining the aspect ratio of the image to be processed.
[0146] The width of the image to be processed may be 360, 720, 1280, etc., and the height of the image to be processed may be 640, 1280, 2560, etc.
[0147] For example, if the image to be processed is an image displayed on a mobile phone, the aspect ratio of the image to be processed can also be the aspect ratio of the mobile phone screen. For example, if the screen is 720*1280, the aspect ratio of the image to be processed can be: 720 / 1280.
[0148] In the embodiment of the present disclosure, the aspect ratio of the image to be processed and the initial texture coordinates in the first direction can be multiplied as the horizontal coordinate of the first intermediate coordinate vector, and the first layer sampling offset and the initial texture coordinates in the second direction can be multiplied as the vertical coordinate of the first intermediate coordinate vector.
[0149] In the disclosed embodiment, the time weight of the first layer (timeHelp.x) and the first moment (time1) can be multiplied, and the result of the multiplication can be converted into a second intermediate coordinate vector; the first intermediate coordinate vector and the second intermediate coordinate vector can be added as the target intermediate coordinate vector.
[0150] In the embodiment of the present disclosure, the Perlin noise image (noiseTexture) can be used as the first input parameter of the texture2D function, and the target intermediate coordinate vector can be used as the second input parameter of the texture2D function. The output of the texture2D function is the first layer offset (noise1) at the first moment. The formula can be:
[0151]
[0152] in, Represents the first intermediate coordinate vector, where its horizontal coordinate can be the aspect ratio of the image to be processed, and its vertical coordinate can be the first layer sampling offset (e.g. 1.2). Represents the second intermediate coordinate vector, whose horizontal and vertical coordinates are the product of the first layer time weight and the first moment, texture2D represents the texture sampling function, Indicates the first layer offset.
[0153] In the embodiment of the present disclosure, when the image to be processed is a rectangle, the image to be processed can be converted into a square by uv*vec2(ratio,1.2) processing, that is, multiplying the initial texture coordinates in the horizontal direction by the aspect ratio, and multiplying the initial texture coordinates in the vertical direction by the sampling offset can make the result more discrete and random.
[0154] The steps of using the texture sampling function to obtain the second layer offset and the third layer offset at each moment are similar to the steps of obtaining the first layer offset at each moment. The specific formula can be:
[0155]
[0156]
[0157] in, Indicates the second layer offset, represents the third layer offset (can also represent the target offset). In formula (5), Represents the first intermediate coordinate vector in the second sampling process. Its horizontal coordinate can be the aspect ratio of the image to be processed, and its vertical coordinate can be the second layer sampling offset (for example, 1.1). represents the second intermediate coordinate vector in the second sampling process, whose horizontal and vertical coordinates are the product of the second layer time weight and the first moment; in formula (6), Represents the first intermediate coordinate vector in the third sampling process. Its horizontal coordinate can be the aspect ratio of the image to be processed, and its vertical coordinate can be the second layer sampling offset (for example, 1.23). It represents the second intermediate coordinate vector in the third sampling process, and its horizontal and vertical coordinates are the product of the third layer time weight and the first moment.
[0158] In the embodiment of the present disclosure, unlike the first-layer iteration process, in the second-layer iteration process and the third-layer iteration process, after the first intermediate coordinate vector and the second intermediate coordinate vector are added, they are added to the product of the offset of the previous layer and its weight to obtain the target intermediate coordinate vector.
[0159] The image processing method provided by the embodiment of the present disclosure can make the offset of each layer obtained by sampling more random by setting the time weight and sampling offset of each layer, thereby making the target offset obtained by sampling more discrete and random.
[0160] In step S840 , the pixel distortion amplitude and the collaborative adjustment parameter are obtained.
[0161] In the embodiment of the present disclosure, the pixel distortion amplitude is a parameter used to adjust the offset range of the initial texture coordinates of the image to be processed, and the coordinated adjustment parameter is a parameter used to adjust the granularity of the pixel distortion amplitude.
[0162] In step S850, target texture coordinates are determined according to the target offset, pixel distortion amplitude, collaborative adjustment parameters, and initial texture coordinates at each moment.
[0163] Taking the first moment as an example, in the embodiment of the present disclosure, the target offset (noise), pixel distortion period and collaborative adjustment parameter at the first moment can be multiplied, and then added to the initial texture coordinates to obtain the target texture coordinates at the first moment.
[0164] The pixel distortion period and the coordinated adjustment parameters can be adjusted according to actual conditions.
[0165] In the embodiment of the present disclosure, the target texture coordinates can be determined based on the target offset of the image to be processed at each moment determined using the texture sampling function, thereby generating a target distorted image, which can achieve the effect of simulating dynamic waves. This method can quickly generate a target dynamic distorted image, save device resources, and can thus be deployed on a mobile terminal.
[0166] In step S860 , a target warped image at each moment is generated according to the target texture coordinates at each moment.
[0167] Figure 11 FIG. 4 is a schematic diagram of another target distorted image according to an example.
[0168] In the embodiment of the present disclosure, the following texture coordinates can be generated according to the target texture coordinates at each moment: Figure 3 or Figure 11 The target distortion images at various moments are shown.
[0169] In step S870 , a target dynamic distorted image is generated based on the target distorted images at each moment.
[0170] Figure 8 In the embodiment shown, Figure 1 or Figure 7 The same steps in the embodiment shown can be seen in Figure 1 or Figure 7 The textual description of the illustrated embodiments will not be repeated in this disclosure.
[0171] The image processing method provided by the embodiment of the present disclosure can use a texture sampling function to simply and efficiently distort and liquefy the image to be processed, thereby achieving the effect of simulating dynamic water ripples, and obtaining a natural and beautiful target distorted image and a target dynamic distorted image, which can be reminiscent of the scene of rippling water in nature. In addition, the more times the above-mentioned iterative process is performed, the more discrete and random the generated target distorted image is, and the more realistic the effect of simulating water ripples is. In addition, the method can use a texture sampling function to quickly calculate the target offset, saving device resources, so that it can be deployed on a mobile terminal. Moreover, it can also run efficiently on devices with limited CPU and GPU capabilities.
[0172] Figure 12 FIG. 1 is a block diagram of an image processing apparatus according to an exemplary embodiment. Figure 12 , the device 1200 may include an acquisition module 1210 , a determination module 1220 and a generation module 1230 .
[0173] Among them, the acquisition module 1210 can be configured to obtain the initial texture coordinates of the image to be processed; the determination module 1220 can be configured to determine the target offset of the initial texture coordinates at each moment; the determination module 1220 can also be configured to obtain the target texture coordinates at each moment based on the initial texture coordinates and the target offset at each moment; the generation module 1230 can be configured to generate the target warped image at each moment based on the target texture coordinates at each moment; the generation module 1230 can also be configured to generate the target dynamic warped image based on the target warped image at each moment.
[0174] In some exemplary embodiments of the present disclosure, the initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and the first direction in which the initial texture coordinates in the first direction are located is perpendicular to the second direction in which the initial texture coordinates in the second direction are located; the acquisition module can also be configured to execute acquisition of the fluctuation speed and the pixel distortion period, wherein the fluctuation speed is a parameter for controlling the degree of motion of the image to be processed, and the pixel distortion period is a parameter for controlling the number of sine waves in the target dynamic distortion image generated according to the image to be processed; the determination module can also be configured to execute processing of the fluctuation speed, the pixel distortion period and the target direction initial texture coordinates using a cosine function to determine the target offset at each moment; wherein the target direction initial texture coordinates are the first direction initial texture coordinates or the second direction initial texture coordinates.
[0175] In some exemplary embodiments of the present disclosure, the acquisition module can also be configured to execute acquisition of pixel distortion amplitude, collaborative adjustment parameters and target direction vector, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, the collaborative adjustment parameters are parameters for adjusting the granularity of the pixel distortion amplitude, and the target direction vector is a vector for adjusting the initial texture coordinates of the first direction and the initial texture coordinates of the second direction; the determination module can also be configured to execute determination of the target texture coordinates at each moment based on the target offset, pixel distortion amplitude, collaborative adjustment parameters, target direction vector and initial texture coordinates at each moment.
[0176] In some exemplary embodiments of the present disclosure, the acquisition unit may also be configured to acquire a Perlin noise image; the determination module may also be configured to process the Perlin noise image and the initial texture coordinates using a texture sampling function to determine the target offset of the initial texture coordinates at each moment.
[0177] In some exemplary embodiments of the present disclosure, the acquisition module can also be configured to acquire a first-layer sampling offset and a second-layer sampling offset, as well as a first weight of the first-layer offset, wherein the first-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter for regulating the position offset when sampling the Perlin noise image for the second time, and the first weight of the first-layer offset is a parameter for regulating the weight of the first-layer offset; the determination module can also be configured to execute the use of a texture sampling function to process the Perlin noise image, the initial texture coordinates, and the first-layer sampling offset to determine the first-layer offset at each moment; the determination module can also be configured to execute the use of a texture sampling function to process the Perlin noise image, the initial texture coordinates, the second-layer sampling offset, the first-layer offset and its first weight to determine the target offset at each moment.
[0178] In some exemplary embodiments of the present disclosure, the acquisition module can also be configured to acquire a third-layer sampling offset and a second weight of the second-layer offset, wherein the third-layer sampling offset is a parameter for regulating the position offset when sampling the Berlin noise image for the third time, and the second weight of the second-layer offset is a parameter for regulating the weight of the second-layer offset; the determination module can also be configured to execute the use of a texture sampling function to process the Berlin noise image, the initial texture coordinates, the second-layer sampling offset, and the first-layer offset and its first weight to determine the second-layer offset corresponding to each moment; the determination module can also be configured to execute the use of a texture sampling function to process the Berlin noise image, the initial texture coordinates, the third-layer sampling offset, and the second-layer offset and its second weight to determine the target offset at each moment.
[0179] In some exemplary embodiments of the present disclosure, the initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and each moment includes a first moment; the acquisition module can also be configured to acquire the aspect ratio of the image to be processed and the time weight of the first layer; the determination module can also be configured to determine the first intermediate coordinate vector based on the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; the determination module can also be configured to determine the second intermediate coordinate vector based on the time weight of the first layer and the first moment; the determination module can also be configured to determine the target intermediate coordinate vector based on the first intermediate coordinate vector and the second intermediate coordinate vector; the determination module can also be configured to process the Perlin noise image and the target intermediate coordinate vector using a texture sampling function to determine the first layer offset at the first moment.
[0180] In some exemplary embodiments of the present disclosure, the acquisition unit may further be configured to acquire pixel distortion amplitude and collaborative adjustment parameters, wherein the pixel distortion amplitude is a parameter for regulating the offset range of the initial texture coordinates of the image to be processed, and the collaborative adjustment parameter is a parameter for adjusting the granularity of the pixel distortion amplitude; the determination module may further be configured to determine the target texture coordinates at each moment based on the target offset, pixel distortion amplitude, collaborative adjustment parameters, and initial texture coordinates at each moment.
[0181] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0182] Refer to the following Figure 13 13 to describe the electronic device 1300 according to this embodiment of the present disclosure. Figure 13 The electronic device 1300 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0183] like Figure 13 As shown, electronic device 1300 is implemented as a general-purpose computing device. Components of electronic device 1300 may include, but are not limited to, the aforementioned at least one processing unit 1310, the aforementioned at least one storage unit 1320, a bus 1330 connecting various system components (including storage unit 1320 and processing unit 1310), and a display unit 1340.
[0184] The storage unit stores program codes, which can be executed by the processing unit 1310, so that the processing unit 1310 performs the steps of various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 1310 can perform the following steps: Figure 1 In step S110 shown in FIG, initial texture coordinates of the image to be processed are obtained; in step S120, target offsets of the initial texture coordinates at each moment are determined; in step S130, target texture coordinates at each moment are obtained based on the initial texture coordinates and the target offsets at each moment; in step S140, target warped images at each moment are generated based on the target texture coordinates at each moment; and in step S150, target dynamic warped images are generated based on the target warped images at each moment.
[0185] For example, electronic devices can achieve Figure 1 The steps shown.
[0186] The storage unit 1320 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 1321 and / or a cache memory unit 1322 , and may further include a read-only memory unit (ROM) 1323 .
[0187] The storage unit 1320 may also include a program / utility 1324 having a set (at least one) of program modules 1325, such program modules 1325 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0188] Bus 1330 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0189] Electronic device 1300 may also communicate with one or more external devices 1370 (e.g., a keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 1300, and / or any device that enables electronic device 1300 to communicate with one or more other computing devices (e.g., a router, modem, etc.). Such communication may occur via input / output (I / O) interface 1350. Furthermore, electronic device 1300 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via network adapter 1360. As shown, network adapter 1360 communicates with other modules of electronic device 1300 via bus 1330. It should be understood that, although 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.
[0190] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0191] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, wherein the instructions are executable by a processor of the device to perform the above method. Alternatively, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, or the like.
[0192] In an exemplary embodiment, a computer program product is further provided, including a computer program / instruction, which implements the image processing method in the above embodiment when the computer program / instruction is executed by a processor.
[0193] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0194] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that: include: Get the initial texture coordinates of the image to be processed; Determining target offsets of the initial texture coordinates at various moments; Determining target texture coordinates at each moment based on the initial texture coordinates and the target offset at each moment; Generate the target distorted image at each moment according to the target texture coordinates at each moment; Generate a target dynamic distorted image according to the target distorted image at each moment; The initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, wherein a first direction in which the initial texture coordinates in the first direction are located is perpendicular to a second direction in which the initial texture coordinates in the second direction are located; wherein the step of determining the target offset of the initial texture coordinates at each moment includes: Acquiring a fluctuation speed and a pixel distortion period, wherein the fluctuation speed is a parameter for controlling the degree of motion of the image to be processed, and the pixel distortion period is a parameter for controlling the number of sine waves in the target dynamic distortion image generated based on the image to be processed; Using a cosine function to process the fluctuation speed, the pixel distortion period and the initial texture coordinates of the target direction to determine the target offset at each moment; The target direction initial texture coordinates are the first direction initial texture coordinates or the second direction initial texture coordinates.
2. The image processing method according to claim 1, wherein: The step of determining the target texture coordinates at each moment according to the initial texture coordinates and the target offset at each moment comprises: Obtaining a pixel warp amplitude, a coordinated adjustment parameter, and a target direction vector, wherein the pixel warp amplitude is a parameter for regulating an offset range of initial texture coordinates of the image to be processed, the coordinated adjustment parameter is a parameter for adjusting a granularity of the pixel warp amplitude, and the target direction vector is a vector for adjusting the initial texture coordinates in the first direction and the initial texture coordinates in the second direction; The target texture coordinates at each moment are determined according to the target offset at each moment, the pixel distortion amplitude, the collaborative adjustment parameter, the target direction vector, and the initial texture coordinates.
3. The image processing method according to claim 1, wherein: The step of determining the target offset of the initial texture coordinates at each moment further includes: Get Perlin noise image; The Perlin noise image and the initial texture coordinates are processed using a texture sampling function to determine a target offset of the initial texture coordinates at each moment.
4. The image processing method according to claim 3, wherein: The step of using a texture sampling function to process the Perlin noise image and the initial texture coordinates and determining a target offset of the initial texture coordinates at each moment comprises: Obtaining a first-layer sampling offset and a second-layer sampling offset, and a first weight of the first-layer offset, wherein the first-layer sampling offset is a parameter used to control a position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter used to control a position offset when sampling the Perlin noise image for the second time, and the first weight of the first-layer offset is a parameter used to control the weight of the first-layer offset; Processing the Perlin noise image, the initial texture coordinates, and the first layer sampling offset using the texture sampling function to obtain the first layer offset at each moment; The texture sampling function is used to process the Perlin noise image, the initial texture coordinates, the second layer sampling offset, and the first layer offset and its first weight to determine a target offset at each moment.
5. The image processing method according to claim 4, characterized in that The step of using the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second layer sampling offset vector, and the first layer offset and its first weight to determine the target offset at each moment includes: Obtaining a third-layer sampling offset and a second weight of the second-layer offset, wherein the third-layer sampling offset is a parameter used to control a position offset when sampling the Perlin noise image for the third time, and the second weight of the second-layer offset is a parameter used to control a weight of the second-layer offset; Using the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second layer sampling offset, and the first layer offset and its first weight, to obtain the second layer offset corresponding to each moment; The texture sampling function is used to process the Perlin noise image, the initial texture coordinates, the third layer sampling offset, and the second layer offset and its second weight to determine a target offset at each moment.
6. The image processing method according to claim 4, wherein: The initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and each moment includes a first moment; wherein the step of using the texture sampling function to process the Perlin noise image, the initial texture coordinates, and the first layer sampling offset to determine the first layer offset at each moment includes: Obtaining the aspect ratio of the image to be processed and the time weight of the first layer; Determining a first intermediate coordinate vector according to the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; determining a second intermediate coordinate vector according to the time weight of the first layer and the first moment; determining a target intermediate coordinate vector according to the first intermediate coordinate vector and the second intermediate coordinate vector; The Perlin noise image and the target intermediate coordinate vector are processed using the texture sampling function to determine a first layer offset at the first moment.
7. The image processing method according to claim 3, wherein: The step of determining the target texture coordinates at each moment according to the initial texture coordinates and the target offset at each moment comprises: Acquiring a pixel distortion amplitude and a coordinated adjustment parameter, wherein the pixel distortion amplitude is a parameter for regulating an offset range of initial texture coordinates of the image to be processed, and the coordinated adjustment parameter is a parameter for adjusting a granularity of the pixel distortion amplitude; The target texture coordinates at each moment are determined according to the target offset at each moment, the pixel distortion amplitude, the collaborative adjustment parameter, and the initial texture coordinates.
8. An image processing device, characterized in that: include: An acquisition module is configured to acquire initial texture coordinates of an image to be processed; a determination module configured to determine a target offset of the initial texture coordinates at each moment; The determining module is further configured to obtain target texture coordinates at each moment according to the initial texture coordinates and the target offset at each moment; A generating module is configured to generate a target warped image at each moment according to the target texture coordinates at each moment; The generating module is further configured to generate a target dynamic distorted image based on the target distorted image at each moment; The initial texture coordinates include a first direction initial texture coordinate and a second direction initial texture coordinate, wherein a first direction where the first direction initial texture coordinate is located is perpendicular to a second direction where the second direction initial texture coordinate is located; The acquisition module is further configured to acquire a fluctuation speed and a pixel distortion period, wherein the fluctuation speed is a parameter for controlling the degree of motion of the image to be processed, and the pixel distortion period is a parameter for controlling the number of sine waves in the target dynamic distortion image generated according to the image to be processed; The determination module is further configured to process the fluctuation speed, the pixel distortion period and the initial texture coordinates of the target direction using a cosine function to determine the target offset at each moment; The target direction initial texture coordinates are the first direction initial texture coordinates or the second direction initial texture coordinates.
9. The image processing device according to claim 8, wherein The acquisition module is further configured to acquire a pixel warp amplitude, a coordinated adjustment parameter, and a target direction vector, wherein the pixel warp amplitude is a parameter for regulating an offset range of initial texture coordinates of the image to be processed, the coordinated adjustment parameter is a parameter for regulating a granularity of the pixel warp amplitude, and the target direction vector is a vector for regulating the initial texture coordinates in the first direction and the initial texture coordinates in the second direction; The determination module is further configured to determine the target texture coordinates at each moment according to the target offset at each moment, the pixel distortion amplitude, the coordinated adjustment parameter, the target direction vector, and the initial texture coordinates.
10. The image processing device according to claim 8, wherein The acquisition unit is further configured to acquire a Perlin noise image; The determination module is further configured to process the Perlin noise image and the initial texture coordinates using a texture sampling function to determine a target offset of the initial texture coordinates at each moment.
11. The image processing device according to claim 10, wherein The acquisition module is further configured to acquire a first-layer sampling offset and a second-layer sampling offset, and a first weight of the first-layer offset, wherein the first-layer sampling offset is a parameter used to adjust a position offset when sampling the Perlin noise image for the first time, the second-layer sampling offset is a parameter used to adjust a position offset when sampling the Perlin noise image for the second time, and the first weight of the first-layer offset is a parameter used to adjust a weight of the first-layer offset; The determining module is further configured to process the Perlin noise image, the initial texture coordinates, and the first layer sampling offset using the texture sampling function to determine the first layer offset at each moment; The determination module is further configured to use the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second layer sampling offset, and the first layer offset and its first weight to determine the target offset at each moment.
12. The image processing device according to claim 11, wherein The acquisition module is further configured to acquire a third-layer sampling offset and a second weight of the second-layer offset, wherein the third-layer sampling offset is a parameter for adjusting a position offset when sampling the Perlin noise image for the third time, and the second weight of the second-layer offset is a parameter for adjusting a weight of the second-layer offset; The determining module is further configured to use the texture sampling function to process the Perlin noise image, the initial texture coordinates, the second layer sampling offset, and the first layer offset and its first weight to determine the second layer offset corresponding to each moment; The determination module is further configured to use the texture sampling function to process the Perlin noise image, the initial texture coordinates, the third layer sampling offset, and the second layer offset and its second weight to determine the target offset at each moment.
13. The image processing device according to claim 11, wherein The initial texture coordinates include initial texture coordinates in a first direction and initial texture coordinates in a second direction, and each moment includes a first moment; The acquisition module is further configured to acquire the aspect ratio of the image to be processed and the time weight of the first layer; The determining module is further configured to determine a first intermediate coordinate vector according to the aspect ratio of the image to be processed, the initial texture coordinates in the first direction, the first layer sampling offset, and the initial texture coordinates in the second direction; The determining module is further configured to determine a second intermediate coordinate vector based on the time weight of the first layer and the first moment; The determining module is further configured to determine a target intermediate coordinate vector based on the first intermediate coordinate vector and the second intermediate coordinate vector; The determination module is further configured to process the Perlin noise image and the target intermediate coordinate vector using the texture sampling function to determine the first layer offset at the first moment.
14. The image processing device according to claim 10, wherein The acquisition unit is further configured to acquire a pixel warp amplitude and a coordinated adjustment parameter, wherein the pixel warp amplitude is a parameter for regulating an offset range of initial texture coordinates of the image to be processed, and the coordinated adjustment parameter is a parameter for regulating a granularity of the pixel warp amplitude; The determination module is further configured to determine the target texture coordinates at each moment according to the target offset at each moment, the pixel distortion amplitude, the collaborative adjustment parameter, and the initial texture coordinates.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the executable instructions to implement the image processing method according to any one of claims 1 to 7. 16 . A computer-readable storage medium, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image processing method according to claim 1 .
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Game image processing method, device thereof and equipment and storage medium
CN111097169A