Disclosure of Invention
In order to solve the problems, the invention provides an image liquefaction processing method, an image liquefaction processing device, image liquefaction processing equipment and a storage medium, so that liquefaction operation is completed in a parallel processing mode on the basis of protecting a protection area, so that on one hand, the liquefaction processing time is shortened, the efficiency is improved, and on the other hand, the user experience is improved.
In a first aspect, an embodiment of the present application provides an image liquefaction processing method, including:
determining a protection mask of an image to be processed, covering a protection area of the image to be processed with the protection mask, and dividing the image to be processed into at least a protection area and a non-protection area;
detecting liquefaction operation aiming at the non-protection area, and determining a position characteristic corresponding to the liquefaction operation;
determining at least two pixel points to be processed according to the position characteristics of the liquefaction operation, and performing parallel computation to obtain operation results corresponding to the at least two pixel points to be processed after the liquefaction operation is performed, wherein the operation results at least represent the position characteristics corresponding to the pixel points to be processed after the liquefaction operation is performed;
and judging whether the position characteristics corresponding to the pixel points to be processed represented by the operation results after the liquefaction operation is carried out fall into the protection area or not, and determining whether to execute the operation results or not based on the judgment results so as to avoid the operation results from crossing into the protection area.
In a specific embodiment, the parallel computing to obtain the operation result corresponding to the at least two to-be-processed pixel points after the liquefaction operation is performed includes:
and obtaining the offset corresponding to the pixel points to be processed in parallel, and obtaining the position characteristics corresponding to each pixel point to be processed in the at least two pixel points to be processed after the offset processing is carried out on the pixel point to be processed based on the offset corresponding to the pixel point to be processed.
In a specific embodiment, the method further comprises:
and after determining that the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is carried out falls into the protection region, reducing the offset corresponding to the pixel point to be processed, and judging whether the position characteristic corresponding to the pixel point to be processed after the offset is reduced falls into the protection region again.
In a specific embodiment, the method further comprises:
after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out do not fall into the protection area, executing the operation result; alternatively, the first and second electrodes may be,
and after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out fall into the protection area, shielding the operation result.
In a specific embodiment, the determining a protection mask for an image to be processed includes:
acquiring key point characteristics of an image to be processed, and forming a key point network capable of representing the key point characteristics of the image to be processed;
the method comprises the steps of obtaining key point characteristics of a protection area, generating a protection mask based on a key point network, enabling the generated protection mask to cover the protection area, and dividing an image to be processed into at least the protection area and a non-protection area.
In a specific embodiment, the method further comprises:
detecting copy operation aiming at the protection mask, and acquiring key point characteristics of a protection area corresponding to the protection mask;
and after the pasting operation aiming at the copying operation is detected, forming a new protection mask aiming at the new image to be processed based on the key point characteristics of the protection area corresponding to the protection mask and the key point network of the new image to be processed, wherein the new protection mask can cover the area, matched with the protection area corresponding to the protection mask, in the new image to be processed.
In a second aspect, an embodiment of the present application provides an image processing apparatus, including:
the device comprises a determining unit, a judging unit and a processing unit, wherein the determining unit is used for determining a protection mask of an image to be processed, the protection mask covers a protection area of the image to be processed, and the image to be processed is at least divided into the protection area and a non-protection area;
the detection unit is used for detecting liquefaction operation aiming at the non-protection area and determining a position characteristic corresponding to the liquefaction operation;
the calculation unit is used for determining at least two pixel points to be processed according to the position characteristics of the liquefaction operation, and performing parallel calculation to obtain operation results corresponding to the at least two pixel points to be processed after the liquefaction operation is performed, wherein the operation results at least represent the position characteristics corresponding to the pixel points to be processed after the liquefaction operation is performed;
and the processing unit is used for judging whether the position characteristics corresponding to the pixel points to be processed represented by the operation results after the liquefaction operation is carried out fall into the protection area or not, and determining whether to execute the operation results or not based on the judgment results so as to avoid the operation results from crossing into the protection area.
In a specific embodiment, the computing unit is further configured to:
and obtaining the offset corresponding to the pixel points to be processed in parallel, and obtaining the position characteristics corresponding to each pixel point to be processed in the at least two pixel points to be processed after the offset processing is carried out on the pixel point to be processed based on the offset corresponding to the pixel point to be processed.
In a specific embodiment, the processing unit is further configured to:
and after determining that the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is carried out falls into the protection region, reducing the offset corresponding to the pixel point to be processed, and judging whether the position characteristic corresponding to the pixel point to be processed after the offset is reduced falls into the protection region again.
In a specific embodiment, the processing unit is further configured to:
after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out do not fall into the protection area, executing the operation result; alternatively, the first and second electrodes may be,
and after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out fall into the protection area, shielding the operation result.
In a specific embodiment, the determining unit is further configured to:
acquiring key point characteristics of an image to be processed, and forming a key point network capable of representing the key point characteristics of the image to be processed;
the method comprises the steps of obtaining key point characteristics of a protection area, generating a protection mask based on a key point network, enabling the generated protection mask to cover the protection area, and dividing an image to be processed into at least the protection area and a non-protection area.
In a specific embodiment, the detecting unit is further configured to detect a copy operation for the protection mask, and obtain a key point feature of a protection area corresponding to the protection mask;
the processing unit is further configured to form a new protection mask for the new image to be processed based on the key point feature of the protection area corresponding to the protection mask and the key point network of the new image to be processed after detecting the paste operation for the copy operation, where the new protection mask can cover an area in the new image to be processed, where the area is matched with the protection area corresponding to the protection mask.
In a third aspect, an embodiment of the present application provides an image processing apparatus, including:
one or more processors;
a memory communicatively coupled to the one or more processors;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the methods described above.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the method described above.
Like this, because this application scheme can determine two at least pending pixel points based on the position characteristic of liquefaction operation, and the parallel processing pixel point is handled moreover, so, it is long when having reduced the liquefaction processing on the one hand, has improved liquefaction efficiency, and on the other hand has promoted user experience. Moreover, according to the scheme of the application, after the operation result of the pixel point to be processed after the liquefaction operation is obtained, the operation result is not directly executed, but whether the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is carried out falls into the protection area is judged, so that whether the operation result is executed or not is determined, and the operation result is prevented from crossing into the protection area; therefore, the image processing efficiency is improved on the basis of protecting the protection area.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In some of the flows described in the specification and claims of the present application and in the above-described figures, a number of operations are included that occur in a particular order, but it should be clearly understood that the flows may include more or less operations, and that the operations may be performed sequentially or in parallel.
Based on this, the embodiment of the application provides an image liquefaction processing method, device, equipment and storage medium; specifically, fig. 1 is a schematic flow chart of an implementation of an image liquefaction processing method according to an embodiment of the present invention, and as shown in fig. 1, the method includes:
step 101: the image processing device determines a protection mask of an image to be processed, the protection mask covers a protection area of the image to be processed, and the image to be processed is at least divided into the protection area and a non-protection area.
In one embodiment, the protection mask of the image to be processed can be determined by the following method, including: acquiring key point characteristics of an image to be processed, and forming a key point network capable of representing the key point characteristics of the image to be processed; the method comprises the steps of obtaining key point characteristics of a protection area, generating a protection mask based on a key point network, enabling the generated protection mask to cover the protection area, and dividing an image to be processed into at least the protection area and a non-protection area. That is to say, the protection mask in the present application is formed based on the key point features of the image to be processed, for example, for the face image, the face key points of the face image are first obtained, face key point interpolation processing is performed to obtain dense face grids (that is, a key point network), then key point features of a protection area, such as key point features of a nose, are determined, and then the protection mask covering the nose is generated based on the dense face grids, the protection mask is used to divide the face image into a protection area covered with the protection mask and a non-protection area not covered with the protection mask, so that the purpose of performing deformation adjustment on the part of the image to be processed and protecting the area not needing deformation is achieved.
In the scheme, the protection mask is formed based on the key point network of the image to be processed, so that the protection mask can be reused in other images to be processed without being independently set for different images to be processed, and therefore, the image processing efficiency is improved, and further the user experience is also improved. Specifically, the protection mask copy method includes: detecting copy operation aiming at the protection mask, and acquiring key point characteristics of a protection area corresponding to the protection mask; and after the pasting operation aiming at the copying operation is detected, forming a new protection mask aiming at the new image to be processed based on the key point characteristics of the protection area corresponding to the protection mask and the key point network of the new image to be processed, wherein the new protection mask can cover the area, matched with the protection area corresponding to the protection mask, in the new image to be processed. Continuing to take the face image as an example, after the protection mask-1 for the nose in the face image-1 is generated, copying operation can be performed, and the protection mask-1 for the face image-1 is pasted to the face image-2, at this time, because the protection mask-1 for the face image-1 is formed based on the key point feature of the nose, after the protection mask-2 is pasted to the face image-2, the protection mask-2 matched with the face image-2 can be generated based on the key point network of the face image-2, and the protection area corresponding to the protection mask-2 is the nose of the face image-2, so that the setting flow of the mask is simplified, the complex operation is avoided, and the user experience is further improved.
Step 102: and the image processing device detects the liquefaction operation aiming at the non-protection area and determines the position characteristic corresponding to the liquefaction operation.
In practical application, the liquefaction operation may specifically be a drag operation of the image processing application program under the liquefaction function; accordingly, the location characteristic of the liquefaction operation may be embodied as a start location and an end location of the liquefaction operation (hereinafter referred to as start location).
Step 103: the image processing device determines at least two pixel points to be processed according to the position characteristics of the liquefaction operation, and obtains an operation result corresponding to the at least two pixel points to be processed after the liquefaction operation is carried out on the at least two pixel points to be processed through parallel calculation, wherein the operation result at least represents the position characteristics corresponding to the pixel points to be processed after the liquefaction operation is carried out on the pixel points to be processed.
In practical application, the process of processing the pixels in parallel can be executed in a Graphics Processing Unit (GPU); for example, in a specific scenario, the image processing apparatus includes a GPU, and in this case, the GPU may be utilized to perform parallel computation, so as to improve the image processing efficiency.
In a specific embodiment, the parallel computing to obtain the operation result corresponding to the at least two to-be-processed pixel points after the liquefaction operation is performed includes: and obtaining the offset corresponding to the pixel points to be processed in parallel, and obtaining the position characteristics corresponding to each pixel point to be processed in the at least two pixel points to be processed after the offset processing is carried out on the pixel point to be processed based on the offset corresponding to the pixel point to be processed. Further, when it is determined that the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is performed falls into the protection region, the offset corresponding to the pixel point to be processed is reduced, and whether the position characteristic corresponding to the pixel point to be processed after the offset reduction falls into the protection region is judged again. Specifically, as shown in fig. 2, the GPU processes the to-be-processed pixel points in parallel to perform the liquefaction operation, and sets an offset (offset) for each to-be-processed pixel point; judging whether the corresponding position characteristics (such as the starting point position) of each pixel point to be processed after the pixel point to be processed is subjected to offset processing based on the offset corresponding to the pixel point to be processed per se falls into the protection region, if so, decreasing the offset, and judging whether the starting point position corresponding to the pixel point to be processed after decreasing again falls into the protection region. And if the pixel point to be processed does not fall into the protection area, executing offset on the pixel point to be processed to obtain a new starting point position of the pixel point to be processed, and thus realizing deformation adjustment of the image to be processed on the basis of protecting the protection area.
Step 104: and the image processing device judges whether the position characteristics corresponding to the pixel points to be processed represented by the operation results after the liquefaction operation is carried out fall into the protection area or not, and determines whether to execute the operation results or not based on the judgment results so as to avoid the operation results from crossing into the protection area.
In practical application, if it is determined that the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is performed does not fall into the protection area, the operation result is executed; alternatively, the first and second electrodes may be,
and if it is determined that the position characteristics corresponding to the pixel points to be processed represented by the operation results after the liquefaction operation is carried out fall into the protection area, shielding the operation results. Certainly, in a specific scenario, when it is determined that the pixel point falls into the protection area, the operation result is directly shielded, that is, the operation result is not executed for the pixel point to be processed which falls into the protection area after the liquefaction processing, so that the processing efficiency can be improved to the greatest extent. Or, in order to optimize the image processing effect, the liquefaction process may be optimized after determining that the pixel point falls into the protection region, for example, the offset is decreased progressively, and then it is determined whether the position feature obtained by the liquefaction operation after the offset is decreased progressively on the pixel point to be processed falls into the protection region again.
Like this, because this application scheme can determine two at least pending pixel points based on the position characteristic of liquefaction operation, and the parallel processing pixel point is handled moreover, so, it is long when having reduced the liquefaction processing on the one hand, has improved liquefaction efficiency, and on the other hand has promoted user experience. Moreover, according to the scheme of the application, after the operation result of the pixel point to be processed after the liquefaction operation is obtained, the operation result is not directly executed, but whether the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is carried out falls into the protection area is judged, so that whether the operation result is executed or not is determined, and the operation result is prevented from crossing into the protection area; therefore, the image processing efficiency is improved on the basis of protecting the protection area.
An embodiment of the present application further provides an image processing apparatus, as shown in fig. 3, the apparatus includes:
a determining unit 31, configured to determine a protection mask of an image to be processed, where the protection mask covers a protection area of the image to be processed, and divides the image to be processed into at least the protection area and a non-protection area;
a detection unit 32, configured to detect a liquefaction operation for the non-protected area, and determine a location characteristic corresponding to the liquefaction operation;
the calculation unit 33 is configured to determine at least two pixel points to be processed according to the position characteristics of the liquefaction operation, and perform parallel calculation to obtain operation results corresponding to the at least two pixel points to be processed after the liquefaction operation is performed, where the operation results at least represent the position characteristics corresponding to the pixel points to be processed after the liquefaction operation is performed;
and the processing unit 34 is configured to determine whether the position feature corresponding to the to-be-processed pixel point represented by the operation result after the liquefaction operation is performed falls into the protection area, and determine whether to execute the operation result based on the determination result, so as to prevent the operation result from crossing into the protection area.
In a specific embodiment, the calculating unit 33 is further configured to:
and obtaining the offset corresponding to the pixel points to be processed in parallel, and obtaining the position characteristics corresponding to each pixel point to be processed in the at least two pixel points to be processed after the offset processing is carried out on the pixel point to be processed based on the offset corresponding to the pixel point to be processed.
In a specific embodiment, the processing unit 34 is further configured to:
and after determining that the position characteristic corresponding to the pixel point to be processed represented by the operation result after the liquefaction operation is carried out falls into the protection region, reducing the offset corresponding to the pixel point to be processed, and judging whether the position characteristic corresponding to the pixel point to be processed after the offset is reduced falls into the protection region again.
In a specific embodiment, the processing unit 34 is further configured to:
after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out do not fall into the protection area, executing the operation result; alternatively, the first and second electrodes may be,
and after determining that the position characteristics corresponding to the pixel points to be processed represented by the operation result after the liquefaction operation is carried out fall into the protection area, shielding the operation result.
In a specific embodiment, the determining unit 31 is further configured to:
acquiring key point characteristics of an image to be processed, and forming a key point network capable of representing the key point characteristics of the image to be processed;
the method comprises the steps of obtaining key point characteristics of a protection area, generating a protection mask based on a key point network, enabling the generated protection mask to cover the protection area, and dividing an image to be processed into at least the protection area and a non-protection area.
In a specific embodiment, the detecting unit 32 is further configured to detect a copy operation for the protection mask, and obtain a key point feature of a protection area corresponding to the protection mask;
the processing unit 34 is further configured to, after detecting a paste operation for the copy operation, form a new protection mask for the new image to be processed based on the key point feature of the protection area corresponding to the protection mask and the key point network of the new image to be processed, where the new protection mask can cover an area, in the new image to be processed, that matches the protection area corresponding to the protection mask.
Here, it should be noted that: the descriptions of the embodiments of the apparatus are similar to the descriptions of the methods, and have the same advantages as the embodiments of the methods, and therefore are not repeated herein. For technical details that are not disclosed in the embodiments of the apparatus of the present invention, those skilled in the art should refer to the description of the embodiments of the method of the present invention to understand, and for brevity, will not be described again here.
An embodiment of the present application further provides an image processing apparatus, including: one or more processors; a memory communicatively coupled to the one or more processors; one or more application programs; wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the method described above.
In a specific example, the image processing apparatus according to the embodiment of the present application may be embodied as a structure as shown in fig. 4, and the image processing apparatus includes at least a processor 41, a storage medium 42, and at least one external communication interface 43; the processor 41, the storage medium 42, and the external communication interface 43 are all connected by a bus 44. The processor 41 may be a microprocessor, a central processing unit, a digital signal processor, or a programmable logic array, etc. electronic components with processing functions. The storage medium has stored therein computer executable code capable of performing the method of any of the above embodiments. In practical applications, the determining unit 31, the detecting unit 31, the calculating unit 33, and the processing unit 34 can be implemented by the processor 41, and of course, in practical applications, the processor 41 can be embodied as an image processor.
Here, it should be noted that: the above description of the embodiment of the image processing apparatus is similar to the above description of the method, and has the same beneficial effects as the embodiment of the method, and therefore, the description thereof is omitted. For technical details not disclosed in the embodiment of the image processing apparatus of the present invention, those skilled in the art should refer to the description of the embodiment of the method of the present invention for understanding, and for the sake of brevity, will not be described again here.
Embodiments of the present application also provide a computer-readable storage medium, which stores a computer program, and when the program is executed by a processor, the computer program implements the method described above.
A computer-readable storage medium can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM). Additionally, the computer-readable storage medium may even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that all or part of the steps carried by the method for implementing the above embodiments can be implemented by hardware related to instructions of a program, which can be stored in a computer readable storage medium, and the program includes one or a combination of the steps of the method embodiments when the program is executed.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a separate product, may also be stored in a computer readable storage medium. The storage medium may be a read-only memory, a magnetic or optical disk, or the like.
The embodiments described above are only a part of the embodiments of the present invention, and not all of them. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.