Image processing methods and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2026-08-14
AI Technical Summary
用户不仅可以通过视频类APP浏览视频,还可以自己制作并发布视频,用户可为视频增加特效,从而提升了用户参与感,然而,目前的畸变效果并不理想
[0014] This application provides an image processing method and apparatus. In response to a user's trigger operation, the method obtains the screen coordinates of the trigger operation; based on the screen coordinates of the trigger operation, it obtains the coordinates of a trigger pixel on the image to be processed; it obtains a distortion function, wherein the distortion function has a value of 0 at the independent variable 0 and a derivative of 1 at the independent variable 0; and it performs distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function to obtain a distorted image. Since the distortion function satisfies the condition of having a value of 0 at the independent variable 0, it ensures that the trigger pixel does not undergo distortion; and since its derivative is 1 at the independent variable 0, it ensures that the distortion of pixels near the trigger pixel is gradual. Using this distortion function for distortion processing makes the distorted image more closely resemble the effect of a real magnifying glass, improving the realism of the magnified image and greatly enhancing the user experience.
Smart Images

Figure CN115686249B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing, and more particularly to an image processing method and apparatus. Background Technology
[0002] With the development of software development technology, the types of applications (APPs) on mobile terminals are increasing. Among them, video APPs are very popular. Users can not only browse videos through video APPs, but also create and publish their own videos. Users can add special effects to their videos, thereby enhancing user engagement. However, the current distortion effects are not ideal. Summary of the Invention
[0003] This disclosure provides an image processing method and apparatus for improving the realism of distortion effects.
[0004] In a first aspect, this application provides an image processing method, comprising: in response to a user's trigger operation, obtaining the screen coordinates of the trigger operation; obtaining the coordinates of a trigger pixel on an image to be processed based on the screen coordinates of the trigger operation; obtaining a distortion function, wherein the value of the distortion function at the independent variable 0 is 0 and its derivative at the independent variable 0 is 1; and performing distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function to obtain a distorted image.
[0005] Optionally, the distortion function also satisfies at least one of the following conditions: the value of the distortion function at the independent variable 1 is a preset value, the preset value is greater than 0 and less than 1; the derivative of the distortion function is greater than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1; the second derivative of the distortion function is less than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
[0006] Optionally, the step of performing distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function includes: for each pixel in the image to be processed, determining the distance between the trigger pixel and the pixel based on the coordinates of the trigger pixel and the pixel; and determining the color value of the pixel based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function.
[0007] Optionally, determining the color value of the pixel based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function includes: determining the undistorted pixel corresponding to the pixel in the image to be processed based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function; and using the color value of the undistorted pixel corresponding to the pixel in the image to be processed as the color value of the pixel.
[0008] Optionally, the image to be processed is an image in a video; obtaining the distortion function includes: determining a first parameter corresponding to the image to be processed based on the frame number of the image to be processed in the video and a preset mapping relationship, wherein the preset mapping relationship is used to indicate the relationship between the first parameter and the frame number, and the first parameter is the value of the distortion function at the independent variable 1; and determining the distortion function based on the first parameter corresponding to the image to be processed, wherein the distortion function satisfies at least one of the following conditions: the value of the distortion function at the independent variable 0 is 0, the derivative of the distortion function at the independent variable 0 is 1, the derivative of the distortion function is greater than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1, and the second derivative of the distortion function is less than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
[0009] Optionally, the method further includes: establishing the preset mapping relationship, wherein the first parameter and the frame number in the preset mapping relationship are negatively correlated.
[0010] Secondly, this application provides an image processing apparatus, comprising: an acquisition module, configured to acquire screen coordinates of the trigger operation in response to a user's trigger operation; acquire coordinates of a trigger pixel on an image to be processed based on the screen coordinates of the trigger operation; acquire a distortion function, wherein the distortion function has a value of 0 at independent variable 0 and a derivative of 1 at independent variable 0; and a processing module, configured to perform distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function to obtain a distorted image.
[0011] Thirdly, this application provides a computer program product that, when the instructions contained in the computer program product are run on a computer, causes the computer to perform the method provided in the first aspect.
[0012] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the processor causes the processor to implement the method provided in the first aspect above.
[0013] Fifthly, this application provides a terminal device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to implement the method provided in the first aspect by executing the executable instructions.
[0014] This application provides an image processing method and apparatus. In response to a user's trigger operation, the method obtains the screen coordinates of the trigger operation; based on the screen coordinates of the trigger operation, it obtains the coordinates of a trigger pixel on the image to be processed; it obtains a distortion function, wherein the distortion function has a value of 0 at the independent variable 0 and a derivative of 1 at the independent variable 0; and it performs distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function to obtain a distorted image. Since the distortion function satisfies the condition of having a value of 0 at the independent variable 0, it ensures that the trigger pixel does not undergo distortion; and since its derivative is 1 at the independent variable 0, it ensures that the distortion of pixels near the trigger pixel is gradual. Using this distortion function for distortion processing makes the distorted image more closely resemble the effect of a real magnifying glass, improving the realism of the magnified image and greatly enhancing the user experience. Attached Figure Description
[0015] Figure 1 A schematic flowchart of an embodiment of the image processing method provided in this application;
[0016] Figure 2 Triggering operation diagram provided for this application Figure 1 ;
[0017] Figure 3 A schematic diagram of the distortion function provided in this application;
[0018] Figure 4 A schematic flowchart of Embodiment 2 of the image processing method provided in this application;
[0019] Figure 5 A schematic diagram of the image processing apparatus provided in this application;
[0020] Figure 6 A schematic diagram of the hardware structure of the terminal device provided in this application. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] In this application, it should be noted that the terms "first" and "second" are only used for descriptive purposes and should not be construed as indicating or implying relative importance. In addition, "at least one" means one or more, and "multiple" means two or more. "And / or" describes the relationship between associated objects and indicates that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, or B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or its similar expressions refer to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a alone, b alone, c alone, the combination of a and b, the combination of a and c, the combination of b and c, or the combination of a, b, and c, where a, b, and c can be single or multiple.
[0023] This disclosure relates to at least two scenarios. One scenario is to process a single image into an image with a distortion effect. Another scenario is to process each frame of an image in a video into an image with a distortion effect, and the degree of distortion increases or decreases frame by frame. Exemplarily, the above video can be a video captured in real time by a terminal device, a locally saved video uploaded by a user, or a video received by the terminal device from other devices, etc. This disclosure does not limit the way of obtaining the video.
[0024] During the process of processing an image into an image with a distortion effect, distortion processing needs to be performed. Currently, the results of distortion processing are not ideal. Taking a magnifying glass as an example, the distortion of an actual magnifying glass has the following characteristics: there is no distortion at the center point of the magnifying glass, the degree of distortion is smaller closer to the center point, and the degree of distortion is larger farther away from the center point. This application proposes to select a distortion function that can make the distortion effect meet the above characteristics when performing distortion processing on an image, so that the processed image is closer to the image magnified by an actual magnifying glass, thereby enhancing the realism of the image effect.
[0025] The image processing method provided in this application can be executed by a terminal device. The forms of the terminal device include but are not limited to: smart phones, tablet computers, laptop computers, wearable electronic devices, smart home devices, etc. This application does not limit the form of the terminal device. This application will explain the solutions of this application for the above two scenarios respectively.
[0026] The following will specifically describe the technical solutions of this application and how the technical solutions of this application solve the above technical problems with specific embodiments. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0027] Example 1
[0028] For the first scenario, namely, the scenario where a single image is processed into an image with a magnifying glass effect. Figure 1 This is a schematic flowchart of an embodiment of the image processing method provided in this application. Figure 1 As shown, the image processing method provided in this embodiment includes:
[0029] S101. In response to the user's trigger operation, obtain the screen coordinates of the trigger operation.
[0030] In the first scenario, see Figure 2 As shown, the triggering operation can include a user's touch operation on the screen, such as a click, double-click, or swipe. The triggering operation can also be an emoji triggering operation, etc. This application does not limit the specific form of the triggering operation. The screen coordinates of the triggering operation refer to the coordinates of the triggering operation on the terminal device screen.
[0031] S102. Obtain the coordinates of the trigger pixel on the image to be processed based on the screen coordinates of the trigger operation.
[0032] Optionally, after obtaining the screen coordinates of the trigger operation, the screen coordinates of the trigger operation can be matched with the coordinates of each pixel on the image to be processed. The successfully matched pixel is taken as the trigger pixel, and the coordinates of the successfully matched pixel are taken as the coordinates of the trigger pixel.
[0033] S103, Obtain the distortion function.
[0034] By applying distortion functions to the image to be processed, images with distortion effects can be obtained. By obtaining a suitable distortion function, the distortion effect obtained by applying the distortion function can be made to more closely resemble that of a real magnifying glass.
[0035] S104. Based on the coordinates of the trigger pixel and the distortion function, perform distortion processing on the image to be processed to obtain the distorted image.
[0036] Distortion processing of an image essentially involves recalculating the color value of each pixel so that, after each pixel is assigned a new color value, it appears distorted compared to the original image.
[0037] The following describes the process of recalculating the color values of each pixel in the image to be processed:
[0038] For each pixel in the image to be processed, the distance between the trigger pixel and the current pixel is determined based on the coordinates of the trigger pixel and the current pixel. Then, the color value of the pixel is determined based on the coordinates of the trigger pixel, the coordinates of the current pixel, the aforementioned distance, and the distortion function obtained in step S103. The process of calculating the color value of any pixel in the image to be processed is illustrated below using an example. For ease of explanation, this application refers to this pixel as the current pixel.
[0039] When determining the color value of the current pixel, as shown in Formula 1 below, the pre-distortion pixel corresponding to the current pixel in the image to be processed can be determined based on the coordinates of the trigger pixel, the coordinates of the current pixel, the distance between the trigger pixel and the current pixel, and the distortion function obtained in step S103. After obtaining the pre-distortion pixel, the color value of the pre-distortion pixel is used as the color value of the current pixel.
[0040]
[0041] Where uv is the coordinate of the pixel before distortion corresponding to the current pixel in the image to be processed, textureCoordinate is the coordinate of the current pixel, center is the coordinate of the trigger pixel, dis is the distance between the trigger pixel and the current pixel, and f is the distortion function, the variable of which is the distance dis between the trigger pixel and the current pixel.
[0042] By performing the same processing on all pixels in the image to be processed, the updated color values of all pixels can be obtained. After all pixels are assigned updated color values, the distorted image can be obtained.
[0043] As described above, this application aims to find the most suitable distortion function so that the image obtained after distortion processing of the image to be processed using the distortion function is visually closer to the distortion effect of a real magnifying glass.
[0044] Referring to Formula 1 above, if the distortion function is f(x) = x, then uv = textureCoordinate, meaning that the color value of each pixel is still the original color value, and there is no distortion effect. Therefore, f(x) = x can be used as the reference function.
[0045] As described above, the distortion effect of a real magnifying glass has the following characteristics: the center point of the magnifying glass is not distorted; the distortion decreases as the distance from the center point increases; and the distortion increases as the distance from the center point increases. Therefore, the trigger pixel can be considered as the center point of the actual magnifying glass, and the distortion function can be designed to satisfy the following two conditions:
[0046] 1) The value of the distortion function at the independent variable 0 is 0 (f(0) = 0);
[0047] 2) The derivative of the distorted function at the independent variable 0 is 1 (f′(0)=1).
[0048] Condition 1) ensures that the triggered pixel does not undergo distortion, thus preventing pixel shift; condition 2) ensures that the distortion of pixels near the triggered pixel is gradual, avoiding abnormal deformation at the center of the image. Therefore, images obtained by using a distortion function that satisfies both conditions are visually continuous, enhancing the realism of the distortion effect.
[0049] Furthermore, if the distortion function satisfies the above two conditions, and also satisfies the following three conditions, the distorted image can more closely resemble the characteristics of a real magnifying glass:
[0050] 3) The value of the distortion function at the independent variable 1 is a preset value, which is greater than 0 and less than 1 (f(1)=k(0<k<1));
[0051] 4) When the independent variable is greater than or equal to 0 and less than or equal to 1, the derivative of the distorted function is greater than or equal to 0 (f′(x)≥0(0≤x<1)).
[0052] 5) When the independent variable of the distorted function is greater than or equal to 0 and less than or equal to 1, the second derivative is less than or equal to 0 (f″(x)≤0(0≤x<1)).
[0053] Condition 3) above primarily defines the undistorted pixel corresponding to a pixel at a distance of 1 from the trigger pixel as a pixel at a distance of k from the trigger pixel in the image to be processed. Condition 4) above ensures that the distortion function is monotonically increasing, and that the position of each pixel corresponds one-to-one with the position of the undistorted pixel, preventing multiple pixels from using the same RGB value of the undistorted pixel and avoiding visual anomalies caused by image repetition. Condition 5) above ensures that the degree of distortion increases with the distance between the pixel and the trigger pixel, making the pixels farther away from the trigger pixel more distorted, thus making the distorted image closer to the distortion effect of a real magnifying glass.
[0054] Any function that meets the above five conditions can be used as a distortion function for subsequent distortion processing of the image to be processed.
[0055] The following example illustrates this:
[0056] Suppose we choose a quadratic function f(x) = ax 2 To find the distortion function above, we can use +bx+c, and then f(x) = ax. 2 Substituting +bx+c into the five conditions above, we can solve for f(x) = (k-1)x 2+x, the value of k needs to satisfy 0.5≤k≤1.0. For example, if we take k=0.75, we can get the distortion function as: f(x)=(0.75-1)x 2 +x=f(x)=-0.25x 2 +x.
[0057] Alternatively, a sine or logarithmic function can be chosen to find the aforementioned distortion function. The process still involves substituting the general form of the sine or logarithmic function into the five conditions mentioned above. The specific steps are not detailed here. For example, when using a sine function to find the distortion function, the obtained distortion function is:
[0058]
[0059] When using a logarithmic function to find the above distortion function, the obtained distortion function is:
[0060] f(x)=k·log(x+k)-k·log(k)(0<k<1)
[0061] For example, see Figure 3 As shown, Figure 3 Three distortion functions f(x), f1(x), f2(x), and f3(x) are shown. f(x) = x is the baseline function, and f1(x), f2(x), and f3(x) are respectively:
[0062] f1(x)=(k-1)x 2 +x, take k = 0.75
[0063]
[0064] f3(x)=k·log(x+k)-k·log(k), take k=0.75
[0065] It should be noted that, Figure 3 This example uses k=0.75 as an illustration. k can take other values within the corresponding range. For example, for a quadratic function, the range of k is 0.5≤k≤1.0, and k can take any value within this range. Figure 3 This is merely an example and does not constitute a limitation of this application.
[0066] The image processing method provided in this application, in response to a user's trigger operation, obtains the screen coordinates of the trigger operation; then, based on the screen coordinates of the trigger operation, it obtains the coordinates of the trigger pixel on the image to be processed; it obtains a distortion function, which has a value of 0 at the independent variable 0 and a derivative of 1 at the independent variable 0; subsequently, based on the coordinates of the trigger pixel and the distortion function, it performs distortion processing on the image to be processed, obtaining a distorted image. Since the distortion function satisfies the condition that its value is 0 at the independent variable 0, it ensures that the trigger pixel does not undergo distortion, and that its derivative is 1 at the independent variable 0, it ensures that the distortion of pixels near the trigger pixel is gradual. Using this distortion function for distortion processing makes the distorted image more closely resemble the effect of a real magnifying glass, enhancing the realism of the image effect.
[0067] Example 2
[0068] For the second scenario, each frame of the video is processed into an image with distortion effects. Figure 4 This is a schematic flowchart of Embodiment 2 of the image processing method provided in this application. Figure 4 As shown, the image processing method provided in this embodiment includes:
[0069] S401. In response to the user's trigger operation, obtain the screen coordinates of the trigger operation.
[0070] In one possible implementation, the triggering operation can be a user's touch operation on the screen, such as a click, double-click, or swipe. The triggering operation can also be an emoji triggering operation, etc. This disclosure does not limit the specific form of the triggering operation. The screen coordinates of the triggering operation refer to the coordinates of the triggering operation on the terminal device screen.
[0071] Let's take the example of a user creating a video with a magnifying glass distortion effect. When a user captures video on the shooting interface, they can click on a point on the interface. After the terminal device senses the click, it obtains the coordinates of the click, which can be used to determine the subsequent trigger pixels.
[0072] S402. Obtain the coordinates of the trigger pixel on the image to be processed based on the screen coordinates of the trigger operation.
[0073] The image to be processed can be any frame from the video. For the specific implementation of S402, please refer to the above embodiments, and this application will not repeat it here.
[0074] S403. Determine the first parameter corresponding to the image to be processed based on the frame number of the image in the video and the preset mapping relationship. The preset mapping relationship indicates the relationship between the first parameter and the frame number, and the first parameter is the value of the distortion function at independent variable 1.
[0075] S404. Determine the distortion function based on the first parameter corresponding to the image to be processed.
[0076] Similar to the above embodiments, the distortion function in this embodiment also needs to satisfy at least one of the following conditions: the value of the distortion function at the independent variable 0 is 0, the derivative of the distortion function at the independent variable 0 is 1, the derivative of the distortion function is greater than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1, the second derivative of the distortion function is less than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1; and the value of the distortion function at the independent variable 1 is the first parameter.
[0077] The method for obtaining a distortion function that satisfies the above conditions is described in the above embodiments, and will not be repeated here. When the same distortion function is used to distort each frame of the image, the degree of distortion of each frame of the image is the same. In order to meet the requirement of increasing or decreasing the magnification frame by frame in the second scenario, this embodiment proposes to change the degree of distortion of each frame of the image by adjusting the value of k.
[0078] Specifically, any frame in the video can be used as the image to be processed here. The first parameter here is k in the above embodiment. Referring to the description of the above embodiment, the value of k is a range. Taking a quadratic function as an example, the distortion function is f(x) = (k-1)x 2 The distortion degree of the image is denoted by k, where k ≤ 0.5 ≤ k ≤ 1.0. Different values of k result in different degrees of image distortion. Specifically, the larger the value of k, the smaller the distortion. To achieve frame-by-frame increase or decrease in distortion, a correspondence between k values and frame numbers can be established. For example, to increase distortion frame-by-frame, the frame number and k value should be negatively correlated; to decrease distortion frame-by-frame, the frame number and k value should be positively correlated.
[0079] For each frame of the video, when processing the image, the value of k is first determined based on the frame number and the aforementioned correspondence. Substituting the value of k into the corresponding function yields the corresponding distortion function. Taking a quadratic function as an example, assuming that when processing a certain frame, the value of k is found to be 0.5 based on the frame number and the preset mapping relationship, then substituting k = 0.5 into f(x) = (k-1)x 2 Adding x, we can obtain the distortion function f(x) = -0.5x used to process this frame of image. 2 +x, and use the distortion function to process this frame of the image. When processing the next frame of the image, similarly, first find the value of k based on the frame number and the preset mapping relationship. Assuming it is 0.6, then substitute k = 0.6 into f(x) = (k-1)x 2Adding x, we can obtain the distortion function f(x) = -0.4x for processing this frame of image. 2 +x. Therefore, different k values are used when performing distortion processing on different images in the video, resulting in different degrees of distortion for different images and improving the diversity of distortion effects in video scenes.
[0080] S405. Based on the coordinates of the trigger pixel and the distortion function, perform distortion processing on the image to be processed to obtain the distorted image.
[0081] For each frame of image, after obtaining its corresponding distortion function through S404, distortion processing can be performed in the same way as S104 in the above embodiment, so that all images in the video have distortion effects and the degree of distortion changes frame by frame.
[0082] The image processing method provided in this embodiment offers a way to perform distortion processing in video scenes. The method provided in this embodiment can increase or decrease the degree of distortion frame by frame, enhancing the user's enjoyment and experience in video production.
[0083] Figure 5 A schematic diagram of the image processing apparatus provided in this application is shown below. Figure 5 As shown, the image processing apparatus provided in this application includes:
[0084] The acquisition module 501 is used to respond to the user's trigger operation, acquire the screen coordinates of the trigger operation; acquire the coordinates of the trigger pixel on the image to be processed based on the screen coordinates of the trigger operation; and acquire the distortion function, wherein the distortion function has a value of 0 at the independent variable 0 and a derivative of 1 at the independent variable 0.
[0085] The processing module 502 is used to perform distortion processing on the image to be processed according to the coordinates of the trigger pixel and the distortion function to obtain the distorted image.
[0086] Optionally, the distortion function also satisfies at least one of the following conditions: the value of the distortion function at the independent variable 1 is a preset value, the preset value is greater than 0 and less than 1; the derivative of the distortion function is greater than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1; the second derivative of the distortion function is less than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
[0087] Optionally, the processing module 502 is specifically used for:
[0088] For each pixel in the image to be processed, the distance between the trigger pixel and the pixel is determined based on the coordinates of the trigger pixel and the pixel itself; the color value of the pixel is determined based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function.
[0089] Optionally, the processing module 502 is specifically used for:
[0090] Based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function, determine the pixel before distortion corresponding to the pixel in the image to be processed;
[0091] The color value of the pixel before distortion, corresponding to the pixel in the image to be processed, is used as the color value of the pixel.
[0092] Optionally, the image to be processed is an image from a video; the acquisition module 501 is specifically used for:
[0093] Based on the frame number of the image to be processed in the video and a preset mapping relationship, a first parameter corresponding to the image to be processed is determined. The preset mapping relationship indicates the relationship between the first parameter and the frame number. The first parameter is the value of the distortion function at independent variable 1.
[0094] The distortion function is determined based on the first parameter corresponding to the image to be processed.
[0095] The distortion function satisfies at least one of the following conditions: the value of the distortion function at the independent variable 0 is 0, the derivative of the distortion function at the independent variable 0 is 1, the derivative of the distortion function is greater than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1, and the second derivative of the distortion function is less than or equal to 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
[0096] Optionally, the acquisition module 501 is also used for:
[0097] Establish the preset mapping relationship, wherein the first parameter and the frame number in the preset mapping relationship are negatively correlated.
[0098] Figure 5 The image processing apparatus shown can be used to perform the steps in any of the above method embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0099] Figure 6 A schematic diagram of the hardware structure of the terminal device provided in this application. (See attached diagram.) Figure 6 As shown, the terminal device in this embodiment may include:
[0100] Processor 601; and
[0101] Memory 602 is used to store the executable instructions of the processor;
[0102] The processor 601 is configured to implement the steps of any of the above method embodiments by executing the executable instructions. The implementation principle and technical effect are similar, and will not be described again here.
[0103] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of any of the above-described method embodiments. The implementation principle and technical effects are similar, and will not be repeated here.
[0104] This application also provides a program product comprising a computer program stored in a readable storage medium. At least one processor can read the computer program from the readable storage medium. The at least one processor executes the computer program to cause an electronic device to perform the steps of any of the above method embodiments. The implementation principle and technical effects are similar and will not be described again here.
[0105] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0106] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0107] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0108] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0109] It should be understood that the processor described in this application can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. An image processing method, characterized in that, include: In response to a user's trigger operation, obtain the screen coordinates of the trigger operation; Based on the screen coordinates of the trigger operation, obtain the coordinates of the trigger pixel on the image to be processed; Obtain the distortion function, wherein the value of the distortion function at the independent variable 0 is 0, and the derivative of the distortion function at the independent variable 0 is 1; Based on the coordinates of the trigger pixel and the distortion function, the image to be processed is distorted to obtain the distorted image; The distortion function also satisfies the following conditions: the value of the distortion function at the independent variable 1 is a preset value, which is greater than 0 and less than 1; the derivative of the distortion function is greater than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1; the second derivative of the distortion function is less than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
2. The method according to claim 1, characterized in that, The step of performing distortion processing on the image to be processed based on the coordinates of the trigger pixel and the distortion function includes: For each pixel in the image to be processed, the distance between the trigger pixel and the pixel is determined based on the coordinates of the trigger pixel and the coordinates of the pixel. The color value of the pixel is determined based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function.
3. The method according to claim 2, characterized in that, Determining the color value of the pixel based on the coordinates of the trigger pixel, the coordinates of the pixel itself, the distance, and the distortion function includes: Based on the coordinates of the trigger pixel, the coordinates of the pixel, the distance, and the distortion function, determine the pixel before distortion corresponding to the pixel in the image to be processed; The color value of the pixel before distortion, corresponding to the pixel in the image to be processed, is used as the color value of the pixel.
4. The method according to claim 1, characterized in that, The image to be processed is an image from a video; The process of obtaining the distortion function includes: Based on the frame number of the image to be processed in the video and the preset mapping relationship, the first parameter corresponding to the image to be processed is determined. The preset mapping relationship is used to indicate the relationship between the first parameter and the frame number. The first parameter is the value of the distortion function at the independent variable 1. as well as The distortion function is determined based on the first parameter corresponding to the image to be processed. The distortion function satisfies the following conditions: the value of the distortion function at the independent variable 0 is 0, the derivative of the distortion function at the independent variable 0 is 1, the derivative of the distortion function is greater than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1, and the second derivative of the distortion function is less than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
5. The method according to claim 4, characterized in that, The method further includes: Establish the preset mapping relationship, in which the first parameter and the frame number are negatively correlated.
6. An image processing apparatus, characterized in that, include: The acquisition module is used to acquire the screen coordinates of the user's trigger operation in response to the user's trigger operation; Based on the screen coordinates of the trigger operation, obtain the coordinates of the trigger pixel on the image to be processed; obtain the distortion function, wherein the value of the distortion function at the independent variable 0 is 0, and the derivative at the independent variable 0 is 1; The processing module is used to perform distortion processing on the image to be processed according to the coordinates of the trigger pixel and the distortion function to obtain the distorted image; The distortion function also satisfies the following conditions: the value of the distortion function at the independent variable 1 is a preset value, which is greater than 0 and less than 1; the derivative of the distortion function is greater than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1; the second derivative of the distortion function is less than 0 when the independent variable is greater than or equal to 0 and less than or equal to 1.
7. A computer program product, characterized in that, When the instructions contained in the computer program product are run on a computer, the computer causes the computer to perform the method described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the processor causes the processor to perform the method described in any one of claims 1-5.
9. A terminal device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to implement the method of any one of claims 1-5 by executing the executable instructions.
Citation Information
Patent Citations
Fisheye image correction method based on distorted straight slope calculation
CN102156970A
Portable terminal and method of enlarging and displaying contents
CN104898919A