Image processing method and device

Through the coordinate offset processing of the original image and superimposed with the prospecting material image, the problem of a single special effect image style in existing technologies is solved, the rich and interesting special effect image processing effect is achieved, and the user experience is improved.

CN117745519BActive Publication Date: 2025-01-28XINGIN INFORMATION TECH (WUHAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211556689.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-06
Publication Date
2025-01-28
Estimated Expiration
2042-12-06

AI Technical Summary

Technical Problem

The existing technology has a single style in special effects image processing and cannot provide rich special effects image experience. The user's image special effects processing experience needs to be improved.

Method used

Through the shift of coordinates based on the original image, combined with foreground material images for superposition processing, target images are generated, and the special effect image processing of the original image is achieved. Specific steps include determining the coordinate migration, the coordinate offset of the original image, and the superposition of the image of the foreground material to generate the target image.

Benefits of technology

The special effect image of the original image is realized, the richness and interest of special effects images are improved, and the user's image special effect processing experience is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117745519B_ABST
    Figure CN117745519B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an image processing method and device. The method includes: determining the coordinate offset of the original image based on the image size of the original image and the image parameters of the replacement image; performing coordinate offset on each pixel point in the original image based on the coordinate offset to obtain an offset image; superimposing the offset image with the foreground material image to obtain a target image, and matching the foreground image of the target image with the foreground material image. The embodiment of the present application can conveniently and quickly provide a special effect image of the original image, and improve the richness and interest of the special effect image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image processing method and device. Background Art

[0002] With the continuous development of terminal devices, users' demand for the shooting experience of terminal devices is also increasing. In particular, after a user uses a terminal device to shoot an image, the image can be processed with special effects and the processing results are presented to the user. However, the style of the special effect images obtained by the current special effect processing method is relatively single, and it is impossible to provide users with rich special effect images. The image special effect processing experience based on the user side needs to be further improved. Summary of the invention

[0003] The embodiments of the present application provide an image processing method and device, which can conveniently and quickly provide a special effect image of the original image and improve the richness and interest of the special effect image.

[0004] On the one hand, an embodiment of the present application provides an image processing method, the method comprising:

[0005] Determining a coordinate offset of the original image based on an image size of the original image and an image parameter of the replaced image;

[0006] Performing coordinate shifting on each pixel point in the original image based on the coordinate shift amount to obtain a shifted image;

[0007] The offset image is superimposed with the foreground material image to obtain a target image, and the foreground image of the target image is matched with the foreground material image.

[0008] In one embodiment, the coordinate offset includes a horizontal coordinate offset and a vertical coordinate offset; and the method for determining the coordinate offset of any pixel point in the original image includes:

[0009] Determining a horizontal coordinate offset of any pixel point in the original image based on an image width of the original image and a pixel value of a corresponding pixel point in the replaced image;

[0010] Based on the image height of the original image and the pixel value of the corresponding pixel in the replaced image, the longitudinal coordinate offset of any pixel in the original image is determined.

[0011] In one embodiment, determining the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image includes:

[0012] Acquire a preconfigured lateral offset parameter, where the lateral offset parameter is used to characterize a lateral offset degree of the original image;

[0013] Determine the lateral coordinate offset of any pixel point in the original image based on the lateral offset parameter, the image width of the original image and the pixel value of the corresponding pixel point in the replaced image;

[0014] The determining the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image comprises:

[0015] Acquire a preconfigured longitudinal offset parameter, where the longitudinal offset parameter is used to characterize a longitudinal offset degree of the original image;

[0016] The longitudinal coordinate offset of any pixel point in the original image is determined based on the longitudinal offset parameter, the image height of the original image and the pixel value of the corresponding pixel point in the replaced image.

[0017] In one embodiment, determining the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image includes:

[0018] Determine the horizontal coordinate offset of any pixel point in the original image in any channel based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel;

[0019] The determining the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image comprises:

[0020] Based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image in the any channel, the longitudinal coordinate offset of any pixel point in the original image in the any channel is determined.

[0021] In one embodiment, the method further comprises:

[0022] Performing directional blur processing on the original image to obtain a blurred image;

[0023] Based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed to obtain a region enhanced image;

[0024] The step of superimposing the offset image with the foreground material image to obtain a target image includes:

[0025] The region enhanced image is superimposed on the foreground material image to obtain the target image.

[0026] In one embodiment, the mask image based on the original image is used to perform a mixed superposition process on the blurred image and the offset image to obtain an enhanced image, including:

[0027] Taking the transparency of any pixel in the mask image as a blending factor, a blending and superposition process is performed on the corresponding pixel in the blurred image and the corresponding pixel in the offset image to obtain a pixel value of the corresponding pixel in the regional enhanced image;

[0028] The regional enhanced image is obtained based on the pixel value of each pixel point in the enhanced image.

[0029] In one embodiment, the method further comprises:

[0030] determining a region of interest of the offset image;

[0031] A mask image of the original image is acquired, wherein a transparent area of ​​the mask image matches a non-interest area of ​​the offset image, and a non-transparent area of ​​the mask image matches a region of interest of the offset image.

[0032] In one embodiment, the method further comprises:

[0033] The target image and the brightness enhanced material image are superimposed to obtain a brightness enhanced image.

[0034] In one embodiment, superimposing the target image and the brightness enhanced material image to obtain the brightness enhanced image includes:

[0035] Based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image, obtaining the brightness value of the corresponding pixel in the brightness enhanced image;

[0036] The brightness enhanced image is obtained based on the pixel value of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

[0037] On the other hand, an embodiment of the present application provides an image processing device, the image processing device comprising:

[0038] A determination unit, configured to determine a coordinate offset of the original image based on an image size of the original image and an image parameter of the replacement image;

[0039] A coordinate shifting unit, used for performing coordinate shifting on each pixel point in the original image based on the coordinate shifting amount to obtain a shifted image;

[0040] The superposition processing unit is used to perform superposition processing on the offset image and the foreground material image to obtain a target image, wherein the foreground image of the target image matches the foreground material image.

[0041] On the other hand, an embodiment of the present application provides a computer device, including a processor, a storage device, and a communication interface, wherein the processor, the storage device, and the communication interface are connected to each other, wherein the storage device is used to store a computer program that supports the computer device to execute the above method, the computer program includes program instructions, and the processor is configured to call the program instructions to perform the following steps:

[0042] Determining a coordinate offset of the original image based on an image size of the original image and an image parameter of the replaced image;

[0043] Performing coordinate shifting on each pixel point in the original image based on the coordinate shift amount to obtain a shifted image;

[0044] The offset image is superimposed with the foreground material image to obtain a target image, and the foreground image of the target image is matched with the foreground material image.

[0045] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the image processing method described in any of the above aspects.

[0046] On the other hand, an embodiment of the present application provides a computer product, which includes a computer program, and the computer program is suitable for being loaded by a processor and executing the image processing method described in any one of the above aspects.

[0047] In the embodiment of the present application, the coordinate offset of the original image is determined based on the image size of the original image and the image parameters of the replacement image, and then the coordinate offset of each pixel in the original image is performed based on the coordinate offset to obtain an offset image, which can control the original image to achieve a distorted effect, and the distorted image is the offset image. Then, the offset image is superimposed with the foreground material image to obtain a target image, and the foreground image of the target image is matched with the foreground material image, and then a distorted image with the foreground material added can be obtained, which is the special effect image of the original image. For example, when the foreground material image is a plastic material, the target image obtained by the embodiment of the present application can present the effect of plastic deformation. For another example, when the foreground material image is a snowflake material, the target image obtained by the embodiment of the present application can present the effect of snowflakes flying. Based on this, the embodiment of the present application can conveniently and quickly provide a special effect image of the original image, and improve the richness and fun of the special effect image. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 It is a flowchart of an image processing method provided in an embodiment of the present application;

[0050] Figure 2 is a flowchart of another image processing method provided in an embodiment of the present application;

[0051] Figure 3a is a schematic diagram of an original image provided in an embodiment of the present application;

[0052] Figure 3b is a schematic diagram of a replacement image provided in an embodiment of the present application;

[0053] Figure 3c is a schematic diagram of an offset image provided in an embodiment of the present application;

[0054] Figure 3d is a schematic diagram of a blurred image provided by an embodiment of the present application;

[0055] Figure 3e is a schematic diagram of a mask image provided in an embodiment of the present application;

[0056] Figure 3f is a schematic diagram of a region enhanced image provided by an embodiment of the present application;

[0057] Figure 3g is a schematic diagram of a foreground material image provided by an embodiment of the present application;

[0058] Figure 3h is a schematic diagram of a target image provided in an embodiment of the present application;

[0059] Figure 3i is a schematic diagram of a brightness enhanced material image provided by an embodiment of the present application;

[0060] Figure 3j is a schematic diagram of a brightness enhanced image provided by an embodiment of the present application;

[0061] Figure 4 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;

[0062] Figure 5It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0064] The image processing method provided in the embodiment of the present application can be applied in an image processing device, and the image processing device can be installed or integrated in a computer device, and the computer device can include a terminal device or a server, etc. For example, the computer device can display an image processing interface. When a user wants to obtain a special effect image of an original image, the user can submit the original image in the image processing interface, and then the computer device can determine the coordinate offset of the original image based on the image size of the original image and the image parameters of the replacement image, and coordinately offset each pixel point in the original image based on the coordinate offset to obtain an offset image, and superimpose the offset image with the foreground material image to obtain a target image, which is the special effect image of the original image. Optionally, the computer device can display the target image in the image processing interface so that the user can browse the target image intuitively. Optionally, the replacement image and / or the foreground material image can be selected by the user in the image library, and the target images obtained based on different replacement maps and / or different foreground material images are different, and the special effects presented by different target images are also different.

[0065] In an exemplary scenario, it is assumed that the computer device includes a terminal device, and the terminal device is equipped with an image acquisition device. The terminal device can acquire an original image through the image acquisition device, and then determine the coordinate offset of the original image based on the image size of the original image and the image parameters of the replacement image, and perform coordinate offset on each pixel in the original image based on the coordinate offset to obtain a shifted image, and superimpose the shifted image with the foreground material image to obtain a target image. The image acquisition device may include a camera or an infrared sensor, etc. Optionally, after the terminal device acquires the original image through the image acquisition device, it can detect whether an image processing instruction is received. If the image processing instruction is received, the coordinate offset of the original image is determined based on the image size of the original image and the image parameters of the replacement image, and the coordinate offset is performed on each pixel in the original image based on the coordinate offset to obtain a shifted image, and the shifted image is superimposed with the foreground material image to obtain a target image. Exemplarily, the image processing instruction may be submitted by a user. Optionally, the original image may be obtained by the terminal device from a memory, or downloaded by the terminal device through the Internet, which is not specifically limited by the embodiments of the present application.

[0066] In another exemplary scenario, the server can obtain the original image, determine the coordinate offset of the original image based on the image size of the original image and the image parameters of the replacement image, perform coordinate offset on each pixel in the original image based on the coordinate offset to obtain an offset image, and superimpose the offset image with the foreground material image to obtain a target image. Optionally, the original image can be obtained by the server from a memory, or downloaded by the server via the Internet, or received by the server from a terminal device, which is not limited by the embodiments of the present application. In the case where the original image is sent by the terminal device to the server, the server superimposes the offset image with the foreground material image to obtain the target image, and then sends the target image to the terminal device so that the terminal device displays the target image.

[0067] See also Figure 1 , Figure 1 is a flowchart of an image processing method provided in an embodiment of the present application, and the image processing method can be executed by a computer device; Figure 1 The image processing scheme shown includes but is not limited to steps S101 to S103, wherein:

[0068] S101, determining a coordinate offset of the original image based on an image size of the original image and image parameters of the replaced image.

[0069] In a specific implementation, the image size of the original image may include the image width and image height of the original image. The image parameters of the replaced image may include the pixel values ​​of each pixel in the replaced image. In the case where the replaced image is a grayscale image, the pixel values ​​of each pixel in the replaced image in each channel are the same, so the image parameters of the replaced image may include the pixel values ​​of each pixel in the replaced image in any channel. In the case where the replaced image is a color image, the pixel values ​​of each pixel in the replaced image in each channel are different, so the image parameters of the replaced image may include the pixel values ​​of each pixel in the replaced image in each channel.

[0070] Optionally, the coordinate offset may include a horizontal coordinate offset and a vertical coordinate offset. Based on this, the method for determining the coordinate offset of any pixel point in the original image may include: determining the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image, and determining the vertical coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image. For example, the computer device may determine the horizontal coordinate offset of the pixel point located in the mth row and nth column of the original image based on the image width of the original image and the phase velocity of the pixel point located in the mth row and nth column of the replacement image, and determine the vertical coordinate offset of the pixel point located in the mth row and nth column of the original image based on the image height of the original image and the pixel value of the pixel point located in the mth row and nth column of the replacement image. Wherein, m and n are both positive integers.

[0071] In one implementation, when the replacement image is a grayscale image, the pixel values ​​of each pixel in the replacement image in each channel are the same, so the image parameters of the replacement image may include the pixel values ​​of each pixel in the replacement image in any channel.

[0072] Optionally, the method for determining the lateral coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replaced image may include: obtaining a preconfigured lateral offset parameter, the lateral offset parameter being used to characterize the degree of lateral offset of the original image, and determining the lateral coordinate offset of any pixel point in the original image based on the lateral offset parameter, the image width of the original image and the pixel value of the corresponding pixel point in the replaced image.

[0073] The larger the pre-configured lateral offset parameter is, the greater the lateral offset of the original image is. In other words, the offset image obtained by performing coordinate offset on each pixel point in the original image based on the coordinate offset has a greater lateral distortion relative to the original image.

[0074] Exemplarily, the horizontal coordinate offset of any pixel point in the original image can be calculated by the following formula (1).

[0075] vec2(x / 720.0*image_width / 720.0)*m(1)

[0076] Among them, x represents the preconfigured lateral offset parameter, image_width represents the image width of the original image, and m represents the pixel value of the corresponding pixel point in any channel of the replacement image.

[0077] Optionally, a method for determining the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replaced image may include: obtaining a preconfigured longitudinal offset parameter, the longitudinal offset parameter being used to characterize the degree of longitudinal offset of the original image, and determining the longitudinal coordinate offset of any pixel point in the original image based on the longitudinal offset parameter, the image height of the original image and the pixel value of the corresponding pixel point in the replaced image.

[0078] The larger the pre-configured longitudinal offset parameter is, the greater the longitudinal offset of the original image is. In other words, the offset image obtained by performing coordinate offset on each pixel point in the original image based on the coordinate offset has a greater longitudinal distortion relative to the original image.

[0079] Exemplarily, the longitudinal coordinate offset of any pixel point in the original image can be calculated using the following formula (2).

[0080] vec2(y / 1280.0*image_height / 1280.0)*m(2)

[0081] Among them, y represents the preconfigured longitudinal offset parameter, image_height represents the image height of the original image, and m represents the pixel value of the corresponding pixel point in any channel of the replacement image.

[0082] The preconfigured lateral offset parameter and / or longitudinal offset parameter in the embodiment of the present application may be set by the computer device or by the user. For example, the computer device may display an image processing interface, and when the user wants to configure the lateral offset parameter and / or longitudinal offset parameter, the preconfigured lateral offset parameter and / or longitudinal offset parameter may be submitted in the image processing interface, and the computer device may then obtain the preconfigured lateral offset parameter and / or longitudinal offset parameter.

[0083] In another implementation, when the replacement image is a color image, the pixel values ​​of each pixel in the replacement image in each channel are different, so the image parameters of the replacement image may include the pixel values ​​of each pixel in the replacement image in each channel.

[0084] Optionally, the method of determining the horizontal coordinate offset of any pixel in the original image based on the image width of the original image and the pixel value of the corresponding pixel in the replacement image may include: determining the horizontal coordinate offset of any pixel in the original image in any channel based on the image width of the original image and the pixel value of the corresponding pixel in the replacement image in any channel. For example, the computer device may determine the horizontal coordinate offset of any pixel in the original image in the R channel based on the image width of the original image and the pixel value of the corresponding pixel in the replacement image in the R channel. The computer device may determine the horizontal coordinate offset of any pixel in the original image in the G channel based on the image width of the original image and the pixel value of the corresponding pixel in the replacement image in the G channel. The computer device may determine the horizontal coordinate offset of any pixel in the original image in the B channel based on the image width of the original image and the pixel value of the corresponding pixel in the replacement image in the B channel.

[0085] In the embodiment of the present application, based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel, the method for determining the horizontal coordinate offset of any pixel point in the original image in any channel can refer to the above formula (1). In this embodiment, m in the above formula (1) can represent the pixel value of the corresponding pixel point in the replacement image in the corresponding channel.

[0086] Optionally, the method of determining the longitudinal coordinate offset of any pixel in the original image based on the image height of the original image and the pixel value of the corresponding pixel in the replacement image may include: determining the longitudinal coordinate offset of any pixel in the original image in any channel based on the image height of the original image and the pixel value of the corresponding pixel in the replacement image in any channel. For example, the computer device may determine the longitudinal coordinate offset of any pixel in the original image in the R channel based on the image height of the original image and the pixel value of the corresponding pixel in the replacement image in the R channel. The computer device may determine the longitudinal coordinate offset of any pixel in the original image in the G channel based on the image height of the original image and the pixel value of the corresponding pixel in the replacement image in the G channel. The computer device may determine the longitudinal coordinate offset of any pixel in the original image in the B channel based on the image height of the original image and the pixel value of the corresponding pixel in the replacement image in the B channel.

[0087] In the embodiment of the present application, based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel, the method for determining the longitudinal coordinate offset of any pixel point in the original image in any channel can refer to the above formula (2). In this embodiment, m in the above formula (2) can represent the pixel value of the corresponding pixel point in the replacement image in the corresponding channel.

[0088] S102, performing coordinate shifting on each pixel point in the original image based on the coordinate shifting amount to obtain a shifted image.

[0089] In one implementation, the computer device may perform a horizontal coordinate shift on each pixel in the original image based on the horizontal coordinate offset to obtain a candidate image, and perform a vertical coordinate shift on each pixel in the candidate image based on the vertical coordinate offset to obtain an offset image. Specifically, the computer device may traverse each pixel in the original image, perform a horizontal coordinate shift on the currently traversed pixel in the original image based on the horizontal coordinate offset of the currently traversed pixel in the original image, until the traversal is completed to obtain the candidate image. Then, the computer device may traverse each pixel in the original image, perform a vertical coordinate shift on the currently traversed pixel in the candidate image based on the vertical coordinate offset of the currently traversed pixel in the original image, until the traversal is completed to obtain an offset image.

[0090] In another implementation, the computer device may perform a longitudinal coordinate shift on each pixel in the original image based on the longitudinal coordinate offset to obtain a candidate image, and perform a transverse coordinate shift on each pixel in the candidate image based on the transverse coordinate offset to obtain an offset image. Specifically, the computer device may traverse each pixel in the original image, and perform a longitudinal coordinate shift on the currently traversed pixel in the original image based on the longitudinal coordinate offset of the currently traversed pixel in the original image until the traversal is completed to obtain the candidate image. Then, the computer device may traverse each pixel in the original image, and perform a transverse coordinate shift on the currently traversed pixel in the candidate image based on the transverse coordinate offset of the currently traversed pixel in the original image until the traversal is completed to obtain an offset image.

[0091] S103, superimposing the offset image with the foreground material image to obtain a target image, and matching the foreground image of the target image with the foreground material image.

[0092] In one implementation, a computer device can perform directional blur processing on an original image to obtain a blurred image, perform mixed superposition processing on the blurred image and an offset image based on a mask image of the original image to obtain a regional enhanced image, and superimpose the regional enhanced image with a foreground material image to obtain a target image.

[0093] In one example, based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed to obtain the enhanced image. The method may include: taking the transparency of any pixel in the mask image as a mixing factor, mixing and superimposing the corresponding pixel in the blurred image and the corresponding pixel in the offset image to obtain the pixel value of the corresponding pixel in the regional enhanced image, and obtaining the regional enhanced image based on the pixel value of each pixel in the enhanced image.

[0094] Optionally, the mask image may be fixed, that is, the key area in the original image is assumed to be the central area, then the central area in the mask image is opaque, and the non-central area is transparent. For example, when the original image is a person image or an animal image, the key area is usually the central area, then the mask image may be fixed, that is, the central area of ​​the mask image is opaque, and the non-central area is transparent.

[0095] Optionally, the mask image may also be adaptively adapted to the original image, that is, the determined mask image may be different if the original image is different. In a specific implementation, the computer device may determine the region of interest of the offset image, obtain the mask image of the original image, and the transparent area of ​​the mask image matches the region of non-interest of the offset image, and the non-transparent area of ​​the mask image matches the region of interest of the offset image. For example, the transparent area of ​​the mask image is the same as the region of non-interest of the offset image, or the overlapping area of ​​the transparent area of ​​the mask image and the region of non-interest of the offset image accounts for a greater proportion than the first preset ratio threshold. For another example, the non-transparent area of ​​the mask image is the same as the region of interest of the offset image, or the overlapping area of ​​the non-transparent area of ​​the mask image and the region of interest of the offset image accounts for a greater proportion than the second preset ratio threshold.

[0096] In one implementation, after the computer device performs superposition processing on the offset image and the foreground material image to obtain the target image, the computer device may superimpose the target image and the brightness-enhanced material image to obtain the brightness-enhanced image.

[0097] In one example, a computer device superimposes the target image and the brightness enhanced material image to obtain a brightness enhanced image in a manner that may include: obtaining the brightness value of the corresponding pixel in the brightness enhanced image based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image; obtaining the brightness enhanced image based on the pixel values ​​of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

[0098] In an embodiment of the present application, the coordinate offset of the original image is determined based on the image size of the original image and the image parameters of the replaced image, and the coordinates of each pixel in the original image are offset based on the coordinate offset to obtain an offset image, and the offset image is superimposed on the foreground material image to obtain a target image. This can conveniently and quickly provide a special effects image of the original image and improve the richness and interest of the special effects image.

[0099] See also Figure 2 , Figure 2 is a flowchart of another image processing method provided in an embodiment of the present application; Figure 2 The image processing scheme shown includes but is not limited to steps S201 to S206, wherein:

[0100] S201, determining a coordinate offset of the original image based on an image size of the original image and image parameters of the replaced image.

[0101] S202, performing coordinate shifting on each pixel point in the original image based on the coordinate shifting amount to obtain a shifted image.

[0102] The steps S201 and S202 in the embodiment of the present application can refer to the relevant descriptions of the steps S101 and S102 in the above embodiment, and will not be described in detail in the embodiment of the present application.

[0103] by Figure 3a to Figure 3c Taking the schematic diagram of the image shown in FIG. 3 as an example, 3a may be the original image, 3b may be the replacement image, and the offset image obtained by performing coordinate shifting on the original image based on the replacement image may be as shown in FIG. Figure 3c shown.

[0104] S203, performing directional blur processing on the original image to obtain a blurred image.

[0105] Optionally, the directional blurring process for the original image may include any of the following: blurring the original image in the horizontal direction to obtain a horizontally blurred image, and then blurring the horizontally blurred image in the vertical direction to obtain a blurred image. Alternatively, blurring the original image in the vertical direction to obtain a vertically blurred image, and then blurring the vertically blurred image in the horizontal direction to obtain a blurred image. Alternatively, blurring the original image in the horizontal direction to obtain a blurred image. Alternatively, blurring the original image in the vertical direction to obtain a blurred image. Alternatively, blurring the original image in the vertical direction to obtain a blurred image.

[0106] For example, the step size of the horizontal blur in the embodiment of the present application can be x / image_width, and the number of iterations can be _Iterat ion. The step size and the number of iterations can be set by the computer device or the user. For example, x is 3, image_width is the width of the picture, and _Iterat ion is 9.

[0107] For example, the step size of the vertical blur in the embodiment of the present application can be y / image_height, and the number of iterations can be _Iterat ion. The step size and the number of iterations can be set by the computer device or the user. For example, the value of y is 3, image_height is the height of the picture, and _Iterat ion is 9.

[0108] by Figure 3d Taking the schematic diagram of the image shown in FIG. 1 as an example, the blurred image obtained by performing directional blurring on the original image can be shown in 3D.

[0109] S204, based on the mask image of the original image, performing mixed superposition processing on the blurred image and the offset image to obtain a region enhanced image.

[0110] Based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed to obtain the enhanced image. The method may include: taking the transparency of any pixel point in the mask image as a mixing factor, mixing and superimposing the corresponding pixel point in the blurred image and the corresponding pixel point in the offset image to obtain the pixel value of the corresponding pixel point in the regional enhanced image, and obtaining the regional enhanced image based on the pixel value of each pixel point in the enhanced image.

[0111] Exemplarily, the computer device may perform mixed superposition processing on the blurred image and the offset image by using the following formula (3) to obtain an enhanced image.

[0112] mix(l astPass,srcCo lor,maskCo lor.a) = l astPass*(1–maskCo lor.a)+srcCo lor*maskCo lor.a(3)

[0113] Among them, firstPass represents the blurred image, srcColor represents the offset image, and maskColor.a represents the transparency of each pixel in the mask image. For example, assuming that the transparency of the pixel located in the first row and first column in the mask image is 1, that is, the pixel located in the first row and first column in the mask image is opaque, then the pixel value of the pixel located in the first row and first column in the superimposed image is the pixel value of the pixel located in the first row and first column in the original image. Assuming that the transparency of the pixel located in the first row and first column in the mask image is 0, that is, the pixel located in the first row and first column in the mask image is transparent, then the pixel value of the pixel located in the first row and first column in the superimposed image is the pixel value of the pixel located in the first row and first column in the blurred image.

[0114] by Figure 3e and Figure 3f Taking the schematic diagram of the image shown in FIG. 3e as an example, 3e may be a mask image. Based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed, and the obtained region enhanced image can be shown as follows. Figure 3f shown.

[0115] S205, superimposing the region enhanced image and the foreground material image to obtain a target image.

[0116] The computer device can use the foreground material image as the foreground image of the regional enhanced image, and superimpose the regional enhanced image and the foreground material image to obtain a target image. The foreground material image can be configured by the computer device or configured by the user. For example, the computer device can display an image processing interface, and the user wants to specify the foreground material image as the foreground image of the target image. Then the user can submit the foreground material image in the image processing interface, and then the computer device superimposes the regional enhanced image and the foreground material image to obtain the target image. Exemplarily, the foreground material image submitted by the user can be selected by the user in the image library.

[0117] by Figure 3g and Figure 3h Taking the schematic diagram of the image shown in FIG. 3 as an example, 3g may be the foreground material image, and the region enhanced image and the foreground material image are superimposed to obtain a target image as shown in FIG. Figure 3h shown.

[0118] S206, superimposing the target image and the brightness enhanced material image to obtain a brightness enhanced image.

[0119] The computer device superimposes the target image and the brightness enhanced material image to obtain the brightness enhanced image in a manner that may include: obtaining the brightness value of the corresponding pixel in the brightness enhanced image based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image; obtaining the brightness enhanced image based on the pixel values ​​of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

[0120] Exemplarily, the computer device may superimpose the target image and the brightness-enhanced material image by the following formula (4) to obtain a brightness-enhanced image.

[0121] If A<=0.5, then C=2.0*A*B; if A>0.5, then C=1.0–2.0*(1.0-A)*(1.0–B)(4)

[0122] Wherein, A represents the brightness value of each pixel in the target image, B represents the brightness value of each pixel in the brightness-enhanced material image, and C represents the brightness value of each pixel in the brightness-enhanced image. For example, the brightness value of the pixel located in the first row and first column in the brightness-enhanced image can be obtained according to the brightness value of the pixel located in the first row and first column in the target image and the brightness value of the pixel located in the first row and first column in the brightness-enhanced material image.

[0123] by Figure 3i and Figure 3j Taking the schematic diagram of the image shown in FIG. 3 as an example, 3i can be a brightness enhanced material image. The target image and the brightness enhanced material image are superimposed, and the brightness enhanced image obtained can be shown as follows. Figure 3j shown.

[0124] In the embodiment of the present application, the original image is subjected to directional blur processing to obtain a blurred image, and based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed to obtain a regional enhanced image, and the non-central area can be shielded by a mask mask (that is, achieved by the mask image), and the surrounding area is blurred by the blurred image, so that the central area of ​​the offset image is more prominent. In addition, the target image and the brightness enhanced material image are superimposed to obtain a brightness enhanced image, which can brighten the effect of the central area.

[0125] An embodiment of the present application further provides a computer storage medium, in which program instructions are stored. When the program instructions are executed, they are used to implement the corresponding methods described in the above embodiments.

[0126] See also Figure 4 , Figure 4 It is a structural schematic diagram of an image processing device provided in an embodiment of the present application.

[0127] In one implementation of the image processing device of the embodiment of the present application, the image processing device includes the following structure.

[0128] A determination unit 401, configured to determine a coordinate offset of the original image based on an image size of the original image and an image parameter of the replacement image;

[0129] A coordinate shifting unit 402, configured to perform coordinate shifting on each pixel point in the original image based on the coordinate shifting amount to obtain a shifted image;

[0130] The superposition processing unit 403 is used to perform superposition processing on the offset image and the foreground material image to obtain a target image, wherein the foreground image of the target image matches the foreground material image.

[0131] In one embodiment, the coordinate offset includes a horizontal coordinate offset and a vertical coordinate offset; and the method for determining the coordinate offset of any pixel point in the original image includes:

[0132] Determining a horizontal coordinate offset of any pixel point in the original image based on an image width of the original image and a pixel value of a corresponding pixel point in the replaced image;

[0133] Based on the image height of the original image and the pixel value of the corresponding pixel in the replaced image, the longitudinal coordinate offset of any pixel in the original image is determined.

[0134] In one embodiment, the determining unit 401 determines the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0135] Acquire a preconfigured lateral offset parameter, where the lateral offset parameter is used to characterize a lateral offset degree of the original image;

[0136] Determine the lateral coordinate offset of any pixel point in the original image based on the lateral offset parameter, the image width of the original image and the pixel value of the corresponding pixel point in the replacement image;

[0137] The determining unit 401 determines the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0138] Acquire a preconfigured longitudinal offset parameter, where the longitudinal offset parameter is used to characterize a longitudinal offset degree of the original image;

[0139] The longitudinal coordinate offset of any pixel point in the original image is determined based on the longitudinal offset parameter, the image height of the original image and the pixel value of the corresponding pixel point in the replaced image.

[0140] In one embodiment, the determining unit 401 determines the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0141] Determine the horizontal coordinate offset of any pixel point in the original image in any channel based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel;

[0142] The determining unit 401 determines the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0143] Based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image in the any channel, the longitudinal coordinate offset of any pixel point in the original image in the any channel is determined.

[0144] In one embodiment, the image processing apparatus may further include a directional blurring unit 404;

[0145] A directional blurring unit 404 is used to perform directional blurring processing on the original image to obtain a blurred image;

[0146] The superposition processing unit 403 is further used to perform mixed superposition processing on the blurred image and the offset image based on the mask image of the original image to obtain a region enhanced image;

[0147] When the overlay processing unit 403 performs overlay processing on the offset image and the foreground material image to obtain the target image, the overlay processing unit 403 includes:

[0148] The region enhanced image is superimposed on the foreground material image to obtain the target image.

[0149] In one embodiment, the overlay processing unit 403 performs mixed overlay processing on the blurred image and the offset image based on the mask image of the original image to obtain an enhanced image, including:

[0150] Taking the transparency of any pixel in the mask image as a blending factor, a blending and superposition process is performed on the corresponding pixel in the blurred image and the corresponding pixel in the offset image to obtain a pixel value of the corresponding pixel in the regional enhanced image;

[0151] The regional enhanced image is obtained based on the pixel value of each pixel point in the enhanced image.

[0152] In one embodiment, the determination unit 401 is further used to determine the region of interest of the offset image; obtain a mask image of the original image, wherein a transparent region of the mask image matches a region of non-interest of the offset image, and a non-transparent region of the mask image matches a region of interest of the offset image.

[0153] In one embodiment, the superposition processing unit 403 is further configured to superimpose the target image and the brightness enhanced material image to obtain a brightness enhanced image.

[0154] In one embodiment, the superposition processing unit 403 superimposes the target image and the brightness enhanced material image to obtain a brightness enhanced image, including:

[0155] Based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image, obtaining the brightness value of the corresponding pixel in the brightness enhanced image;

[0156] The brightness enhanced image is obtained based on the pixel value of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

[0157] In an embodiment of the present application, the coordinate offset of the original image is determined based on the image size of the original image and the image parameters of the replaced image, and the coordinates of each pixel in the original image are offset based on the coordinate offset to obtain an offset image, and the offset image is superimposed on the foreground material image to obtain a target image. This can conveniently and quickly provide a special effects image of the original image and improve the richness and interest of the special effects image.

[0158] See also Figure 5 , Figure 5 1 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device in the embodiment of the present application includes a power supply module and other structures, and includes a processor 501, a storage device 502 and a communication interface 503. The processor 501, the storage device 502 and the communication interface 503 can exchange data, and the processor 501 implements the corresponding multimedia data processing method.

[0159] The storage device 502 may include a volatile memory (volatile memory), such as a random-access memory (RAM); the storage device 502 may also include a non-volatile memory (non-volatile memory), such as a flash memory, a solid-state drive (SSD), etc.; the storage device 502 may also include a combination of the above types of memory.

[0160] The processor 501 may be a central processing unit (CPU). The processor 501 may also be a combination of a CPU and a GPU. In the server, multiple CPUs and GPUs may be included as needed to perform corresponding data processing. In one embodiment, the storage device 502 is used to store program instructions. The processor 501 may call program instructions to implement various methods as described above in the embodiments of the present application.

[0161] In a first possible implementation, the processor 501 of the computer device calls the program instructions stored in the storage device 502 to determine the coordinate offset of the original image based on the image size of the original image and the image parameters of the replaced image, performs coordinate offset on each pixel point in the original image based on the coordinate offset to obtain an offset image, and superimposes the offset image with the foreground material image to obtain a target image, wherein the foreground image of the target image matches the foreground material image.

[0162] In one embodiment, the coordinate offset includes a horizontal coordinate offset and a vertical coordinate offset; and the method for determining the coordinate offset of any pixel point in the original image includes:

[0163] Determining a horizontal coordinate offset of any pixel point in the original image based on an image width of the original image and a pixel value of a corresponding pixel point in the replaced image;

[0164] Based on the image height of the original image and the pixel value of the corresponding pixel in the replaced image, the longitudinal coordinate offset of any pixel in the original image is determined.

[0165] In one embodiment, the processor 501 determines the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0166] Acquire a preconfigured lateral offset parameter, where the lateral offset parameter is used to characterize a lateral offset degree of the original image;

[0167] Determine the lateral coordinate offset of any pixel point in the original image based on the lateral offset parameter, the image width of the original image and the pixel value of the corresponding pixel point in the replacement image;

[0168] The processor 501 determines the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0169] Acquire a preconfigured longitudinal offset parameter, where the longitudinal offset parameter is used to characterize a longitudinal offset degree of the original image;

[0170] The longitudinal coordinate offset of any pixel point in the original image is determined based on the longitudinal offset parameter, the image height of the original image and the pixel value of the corresponding pixel point in the replaced image.

[0171] In one embodiment, the processor 501 determines the horizontal coordinate offset of any pixel point in the original image based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0172] Determine the horizontal coordinate offset of any pixel point in the original image in any channel based on the image width of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel;

[0173] The processor 501 determines the longitudinal coordinate offset of any pixel point in the original image based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image, including:

[0174] Based on the image height of the original image and the pixel value of the corresponding pixel point in the replacement image in the any channel, the longitudinal coordinate offset of any pixel point in the original image in the any channel is determined.

[0175] In one embodiment, the processor 501 is further configured to perform directional blur processing on the original image to obtain a blurred image; based on the mask image of the original image, perform mixed superposition processing on the blurred image and the offset image to obtain a regional enhanced image;

[0176] When the processor 501 performs superposition processing on the offset image and the foreground material image to obtain the target image, the processor 501 includes:

[0177] The region enhanced image is superimposed on the foreground material image to obtain the target image.

[0178] In one embodiment, the processor 501 performs a mixed superposition process on the blurred image and the offset image based on the mask image of the original image to obtain an enhanced image, including:

[0179] Taking the transparency of any pixel in the mask image as a blending factor, a blending and superposition process is performed on the corresponding pixel in the blurred image and the corresponding pixel in the offset image to obtain a pixel value of the corresponding pixel in the regional enhanced image;

[0180] The regional enhanced image is obtained based on the pixel value of each pixel point in the enhanced image.

[0181] In one embodiment, the processor 501 is further used to determine the region of interest of the offset image; obtain a mask image of the original image, wherein a transparent region of the mask image matches a region of non-interest of the offset image, and a non-transparent region of the mask image matches a region of interest of the offset image.

[0182] In one embodiment, the processor 501 is further configured to superimpose the target image and the brightness enhanced material image to obtain a brightness enhanced image.

[0183] In one embodiment, the processor 501 superimposes the target image and the brightness enhanced material image to obtain a brightness enhanced image, including:

[0184] Based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image, obtaining the brightness value of the corresponding pixel in the brightness enhanced image;

[0185] The brightness enhanced image is obtained based on the pixel value of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

[0186] In an embodiment of the present application, the coordinate offset of the original image is determined based on the image size of the original image and the image parameters of the replaced image, and the coordinates of each pixel in the original image are offset based on the coordinate offset to obtain an offset image, and the offset image is superimposed on the foreground material image to obtain a target image. This can conveniently and quickly provide a special effects image of the original image and improve the richness and interest of the special effects image.

[0187] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM). The computer-readable storage medium can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the blockchain node, etc.

[0188] The above disclosure is only part of the embodiments of the present application, which certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiments and making equivalent changes according to the claims of this application are still within the scope of the present invention.

Claims

1. An image processing method, characterized in that: include: Determining a coordinate offset of the original image based on an image size of the original image and an image parameter of the replacement image, wherein the image parameter of the replacement image includes a pixel value of each pixel point in the replacement image, and the coordinate offset includes a horizontal coordinate offset and a vertical coordinate offset; The method for determining the coordinate offset of any pixel point in the original image includes: Acquire a preconfigured lateral offset parameter, where the lateral offset parameter is used to characterize a lateral offset degree of the original image; Determine the lateral coordinate offset of any pixel point in the original image in any channel based on the lateral offset parameter, the image width of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel; Acquire a preconfigured longitudinal offset parameter, where the longitudinal offset parameter is used to characterize a longitudinal offset degree of the original image; Determine the longitudinal coordinate offset of any pixel point in the original image in any channel based on the longitudinal offset parameter, the image height of the original image and the pixel value of the corresponding pixel point in the replacement image in any channel; Based on the horizontal coordinate offset and the vertical coordinate offset of each pixel point in the original image in each channel, coordinate offset is performed on each pixel point in the original image to obtain an offset image; The offset image is superimposed with the foreground material image to obtain a target image, wherein the foreground image of the target image is matched with the foreground material image; The replacement image and / or the foreground material image are selected by a user from an image library.

2. The method according to claim 1, characterized in that The method further comprises: Performing directional blur processing on the original image to obtain a blurred image; Based on the mask image of the original image, the blurred image and the offset image are mixed and superimposed to obtain a region enhanced image; The step of superimposing the offset image with the foreground material image to obtain a target image includes: The region enhanced image is superimposed on the foreground material image to obtain the target image.

3. The method according to claim 2, characterized in that The method of performing a mixed superposition process on the blurred image and the offset image based on the mask image of the original image to obtain an enhanced image includes: Taking the transparency of any pixel in the mask image as a blending factor, a blending and superposition process is performed on the corresponding pixel in the blurred image and the corresponding pixel in the offset image to obtain a pixel value of the corresponding pixel in the regional enhanced image; The regional enhanced image is obtained based on the pixel value of each pixel point in the enhanced image.

4. The method according to claim 2 or 3, characterized in that: The method further comprises: determining a region of interest of the offset image; A mask image of the original image is acquired, wherein a transparent area of ​​the mask image matches a non-interest area of ​​the offset image, and a non-transparent area of ​​the mask image matches a region of interest of the offset image.

5. The method according to claim 1, characterized in that The method further comprises: The target image and the brightness enhanced material image are superimposed to obtain a brightness enhanced image.

6. The method according to claim 5, characterized in that The step of superimposing the target image and the brightness enhanced material image to obtain the brightness enhanced image includes: Based on the brightness value of any pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced material image, obtaining the brightness value of the corresponding pixel in the brightness enhanced image; The brightness enhanced image is obtained based on the pixel value of each pixel in the target image and the brightness value of the corresponding pixel in the brightness enhanced image.

7. An image processing device, characterized in that: The device comprises: A determination unit, configured to determine the coordinate offset of the original image based on the image size of the original image and the image parameters of the replacement image, wherein the image parameters of the replacement image include the pixel values ​​of each pixel in the replacement image, and the coordinate offset includes a horizontal coordinate offset and a vertical coordinate offset; a method for determining the coordinate offset of any pixel in the original image comprises: obtaining a preconfigured horizontal offset parameter, wherein the horizontal offset parameter is used to characterize the horizontal offset degree of the original image; determining the horizontal coordinate offset of any pixel in the original image in any channel based on the horizontal offset parameter, the image width of the original image and the pixel value of the corresponding pixel in the replacement image in any channel; obtaining a preconfigured vertical offset parameter, wherein the vertical offset parameter is used to characterize the vertical offset degree of the original image; determining the vertical coordinate offset of any pixel in the original image in any channel based on the vertical offset parameter, the image height of the original image and the pixel value of the corresponding pixel in the replacement image in any channel; A coordinate shifting unit, configured to perform coordinate shifting on each pixel point in the original image based on the horizontal coordinate shifting amount and the vertical coordinate shifting amount of each pixel point in the original image in each channel, so as to obtain a shifted image; A superposition processing unit, used for superimposing the offset image with the foreground material image to obtain a target image, wherein the foreground image of the target image matches the foreground material image; The replacement image and / or the foreground material image are selected by a user from an image library.

8. A computer device, characterized in that: The computer device includes a processor, a storage device and a communication interface; The storage device is used to store a computer program, wherein the computer program includes program instructions; The processor is configured to call the program instructions to execute the image processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the image processing method according to any one of claims 1 to 6.

10. A computer product, characterized in that: The computer product comprises a computer program, which is suitable for being loaded by a processor and executing the image processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image processing method and device, electronic equipment and computer readable storage medium

    CN112541867A

  • Image processing method and device, electronic equipment and storage medium

    CN114820348A