CN110503704B - Method and device for constructing three-dimensional graph and electronic equipment - Google Patents

Method and device for constructing three-dimensional graph and electronic equipment Download PDF

Info

Publication number
CN110503704B
CN110503704B CN201910799574.2A CN201910799574A CN110503704B CN 110503704 B CN110503704 B CN 110503704B CN 201910799574 A CN201910799574 A CN 201910799574A CN 110503704 B CN110503704 B CN 110503704B
Authority
CN
China
Prior art keywords
edge
bipartite graph
image
region
color image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910799574.2A
Other languages
Chinese (zh)
Other versions
CN110503704A (en
Inventor
聂旎
张哲斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Megvii Technology Co Ltd
Original Assignee
Beijing Megvii Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Megvii Technology Co Ltd filed Critical Beijing Megvii Technology Co Ltd
Priority to CN201910799574.2A priority Critical patent/CN110503704B/en
Publication of CN110503704A publication Critical patent/CN110503704A/en
Application granted granted Critical
Publication of CN110503704B publication Critical patent/CN110503704B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides a method and a device for constructing a trimap image and electronic equipment, wherein the method comprises the following steps: acquiring a color image containing a target object and a bipartite graph of the color image; performing edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph; a bipartite graph of the color image is constructed based on the smoothed filtered image of the bipartite graph. In the embodiment of the invention, the pixel values of the bipartite image edge area are changed due to the bilateral characteristic of edge-preserving smooth filtering, so that the pixel values of the pixel points with similar color and space distance to the foreground area are more towards the foreground area, the pixel values of the pixel points with similar background area are more towards the background area, and the pixel points with less similarity to the foreground area and the background area are still used as unknown areas.

Description

Method and device for constructing three-dimensional graph and electronic equipment
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for constructing a trimap image, and an electronic device.
Background
The fine matting (image matting) algorithm is an algorithm widely applied to the field of computational photography, in particular to a technology for finely separating a foreground image from a background image, and the result is a foreground mask (i.e. an alpha mask) of a foreground object, wherein the foreground mask can be used in image processing applications which are deeply favored by mobile phone users at present, such as background replacement, image mode background blurring and the like.
In order to achieve fine matting, in addition to providing the original image of the image, a trimap image (i.e., trimap) of one image needs to be provided as an assist. In the trimap image, white areas represent absolute foreground areas, black areas represent absolute background areas, gray areas represent transition areas of foreground and background areas, which are commonly referred to as unknown areas, and the fine matting algorithm only processes the unknown areas. In the design of the traditional fine matting algorithm, the trisection of the image can be obtained by manually marking the image along the image segmentation boundary by a user through a painting tool, and the trisection obtained in the mode is accurate but takes a long time; the method can be obtained by automatically constructing the three-dimensional image through a corrosion expansion algorithm based on some priori knowledge (such as an image segmentation result), the construction mode is simple and quick, but the accuracy is poor, unknown areas in the constructed three-dimensional image are large, so that the number of pixels processed by the subsequent fine matting algorithm is increased, the time consumption is increased, and in addition, the effect of final fine matting is influenced due to the fact that the unknown areas are covered with too many background areas.
In conclusion, the existing three-dimensional graph construction method has the technical problems of long time consumption and poor accuracy.
Disclosure of Invention
In view of the above, the present invention aims to provide a method, a device and an electronic device for constructing a trimap image, so as to alleviate the technical problems of long time consumption and poor accuracy of the existing trimap image constructing method.
In a first aspect, an embodiment of the present invention provides a method for constructing a trimap image, including: acquiring a color image containing a target object and a bipartite graph of the color image; the bipartite graph comprises: a foreground region and a background region, the foreground region being for representing an image region of the target object; performing edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph; constructing a bipartite graph of the color image based on the smoothed filtered image of the bipartite graph; the trimap image includes: an optimized foreground region, an optimized background region, and an unknown region.
Further, the step of acquiring a color image containing the target object and a bipartite graph of the color image includes: acquiring a color image containing a target object; and carrying out image segmentation processing on the color image to obtain a bipartite graph of the color image.
Further, the step of performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image includes: acquiring a target edge-preserving smooth filtering strategy selected by a user according to image processing requirements; the target edge protection smoothing filtering strategy comprises any one of a first edge protection smoothing filtering strategy, a second edge protection smoothing filtering strategy, a third edge protection smoothing filtering strategy and a fourth edge protection smoothing filtering strategy, and the first edge protection smoothing filtering strategy comprises: a policy of a first edge-preserving smoothing filtering algorithm, the second edge-preserving smoothing filtering policy comprising: a downsampling algorithm and a first edge-preserving smoothing filtering algorithm, the third edge-preserving smoothing filtering algorithm comprising: the strategy of a downsampling algorithm, a first edge-preserving smooth filtering algorithm and a noise suppression algorithm, and the fourth edge-preserving smooth filtering strategy comprises: a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm; and carrying out edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy.
Further, when the target edge-preserving smoothing filtering strategy is the strategy of the first edge-preserving smoothing filtering algorithm; based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps: and inputting the color image and the bipartite graph into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
Further, when the target edge-preserving smoothing filtering strategy is a strategy of a downsampling algorithm and a first edge-preserving smoothing filtering algorithm; based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps: respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image with a first size and a bipartite graph with a first size; and inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, so as to obtain a smoothing filtering image of the bipartite graph.
Further, when the target edge-preserving smoothing filtering strategy is a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a noise suppression algorithm; based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps: respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image with a first size and a bipartite graph with a first size; inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain an initial smoothing filtering image of the bipartite graph; and carrying out noise suppression processing on the initial smooth filtered image by adopting the noise suppression algorithm to obtain the smooth filtered image of the bipartite graph.
Further, when the target edge-preserving smoothing filtering strategy is a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm; based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps: respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image of a first size, a color image of a second size and a bipartite graph of the first size; inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering treatment to obtain the bipartite graph with the first size after smoothing filtering; upsampling the smoothed and filtered bipartite graph of the first size to obtain a bipartite graph of the second size; and inputting the color image with the second size and the bipartite graph with the second size into the second edge-preserving smooth filtering algorithm to carry out edge-preserving smooth filtering processing, so as to obtain a smooth filtering image of the bipartite graph.
Further, after obtaining the bipartite graph of the second size, before inputting the color image of the second size and the bipartite graph of the second size into the second edge-preserving smoothing filtering algorithm to perform edge-preserving smoothing filtering processing, the method further includes: and carrying out noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm to obtain a bipartite graph with the second size after noise suppression, and inputting the color image with the second size and the bipartite graph with the second size after noise suppression into the second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing.
Further, the step of performing noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm includes: in the bipartite graph with the second size, the pixel value of the pixel point of the first area is reduced according to a first coefficient, and the pixel value of the pixel point of the second area is enlarged according to a second coefficient; the first region is a region in which the pixel value of the pixel point is smaller than a first preset threshold, the second region is a region in which the pixel value of the pixel point is larger than a second preset threshold, the first preset threshold is smaller than the second preset threshold, the first coefficient is a proportion between the pixel value of the corresponding pixel point in the first region and the first preset threshold, and the second coefficient is a proportion between the pixel value of the corresponding pixel point in the second region and the second preset threshold.
Further, the step of constructing a trimap image of the color image based on the smoothed filtered image of the bipartite image includes: in the smooth filtering image, setting the pixel value of the pixel point of the third area as a first value, setting the pixel value of the pixel point of the fourth area as a second value, and setting the pixel value of the pixel point of the fifth area as a third value; the third region is a region with pixel values of the pixel points larger than a third preset threshold, the fourth region is a region with pixel values of the pixel points smaller than a fourth preset threshold, and the fifth region is a remaining region in the smooth filtered image after the third region and the fourth region are removed, wherein the third preset threshold is larger than the fourth preset threshold; marking the third region as the optimized foreground region, the fourth region as the optimized background region, and the fifth region as the unknown region.
Further, the method further comprises: and carrying out fine matting processing on the trisection image to obtain a fine matting result of the target object.
Further, the step of performing fine matting processing on the trimap image includes: respectively up-sampling or down-sampling the trisection image and the color image according to the fine matting processing size to obtain a trisection image of the fine matting processing size and a color image of the fine matting processing size; inputting the trisection image of the fine matting processing size and the color image of the fine matting processing size into a fine matting model for fine matting processing to obtain a fine matting result of the target object.
In a second aspect, an embodiment of the present invention further provides a device for constructing a trimap image, including: an acquisition unit configured to acquire a color image including a target object and a bipartite graph of the color image; the bipartite graph comprises: a foreground region and a background region, the foreground region being for representing an image region of the target object; the edge-preserving smooth filtering processing unit is used for carrying out edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph; a bipartite graph construction unit for constructing a bipartite graph of the color image based on the smoothed filtered image of the bipartite graph; the trimap image includes: an optimized foreground region, an optimized background region, and an unknown region.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the method according to any one of the first aspects when the processor executes the computer program.
In a fourth aspect, embodiments of the present invention provide a computer readable medium having non-volatile program code executable by a processor, the program code causing the processor to perform the steps of the method of any of the first aspects above.
In the embodiment of the invention, a color image containing a target object and a bipartite graph of the color image are firstly acquired; then, edge-preserving smooth filtering processing is carried out on the bipartite graph based on the color image, and a smooth filtering image of the bipartite graph is obtained; finally, a bipartite graph of the color image is constructed based on the smoothed filtered image of the bipartite graph. As can be seen from the above description, in the embodiment of the present invention, in the process of performing edge-preserving smoothing filtering on a bipartite graph through a color image, the pixel values of the edge regions of the bipartite graph are changed due to the bilateral characteristics of the edge-preserving smoothing filtering, so that the pixel values of the pixel points with similar color and spatial distances to the foreground region are more towards the foreground region, the pixel values of the pixel points with similar background region are more towards the background region, and the pixel points with less similarity to the foreground region and the background region are still used as the unknown region.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of an electronic device according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of constructing a trimap image according to embodiments of the present invention;
FIG. 3 is a flowchart of a method for performing edge-preserving smoothing filtering on a bipartite graph according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for performing edge-preserving smoothing filtering processing on a bipartite graph based on a color image and a fourth edge-preserving smoothing filtering strategy according to an embodiment of the present invention;
FIG. 5 is a flowchart of a method for performing fine matting processing on a trimap image according to the embodiment of the invention;
FIG. 6a is a schematic diagram of a color image including a target object according to an embodiment of the present invention;
FIG. 6b is a schematic diagram of a three-dimensional view of a color image according to an embodiment of the present invention;
FIG. 6c is a schematic diagram of a fine matting result of a target object according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a device for constructing a trimap image according to an embodiment of the invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1:
first, an electronic device 100 for implementing an embodiment of the present invention, which can be used to operate the construction method of the trimap image of each embodiment of the present invention, will be described with reference to fig. 1.
As shown in fig. 1, electronic device 100 includes one or more processors 102, one or more memories 104, an input device 106, an output device 108, and a camera 110, which are interconnected by a bus system 112 and/or other forms of connection mechanisms (not shown). It should be noted that the components and structures of the electronic device 100 shown in fig. 1 are exemplary only and not limiting, as the electronic device may have other components and structures as desired.
The processor 102 may be implemented in hardware in at least one of a digital signal processor (DSP, digital Signal Processing), field programmable gate array (FPGA, field-Programmable Gate Array), programmable logic array (PLA, programmable Logic Array) and ASIC (Application Specific Integrated Circuit), and the processor 102 may be a central processing unit (CPU, central Processing Unit) or other form of processing unit having data processing and/or instruction execution capabilities and may control other components in the electronic device 100 to perform desired functions.
The memory 104 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, random Access Memory (RAM) and/or cache memory (cache), and the like. The non-volatile memory may include, for example, read Only Memory (ROM), hard disk, flash memory, and the like. One or more computer program instructions may be stored on the computer readable storage medium that can be executed by the processor 102 to implement client functions and/or other desired functions in embodiments of the present invention as described below. Various applications and various data, such as various data used and/or generated by the applications, may also be stored in the computer readable storage medium.
The input device 106 may be a device used by a user to input instructions and may include one or more of a keyboard, mouse, microphone, touch screen, and the like.
The output device 108 may output various information (e.g., images or sounds) to the outside (e.g., a user), and may include one or more of a display, a speaker, and the like.
The camera 110 is configured to acquire a color image, where the color image acquired by the camera is processed by the method of constructing a trimap image to obtain a trimap image of the color image, for example, the camera may take an image (e.g. a photograph, a video, etc.) desired by a user, then process the image by the method of constructing the trimap image to obtain a trimap image of the color image, and store the taken image in the memory 104 for use by other components.
By way of example, the electronic device for implementing the method of constructing the trimap image according to the embodiment of the present invention may be implemented as a smart mobile terminal such as a smart phone, a tablet computer, or any other device having computing power.
Example 2:
In accordance with an embodiment of the present invention, there is provided an embodiment of a method of constructing a three-dimensional figure, it being noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer executable instructions, and, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order other than that illustrated herein.
Fig. 2 is a flowchart of a method of constructing a trimap image according to an embodiment of the invention, as shown in fig. 2, the method including the steps of:
step S202, a color image containing the target object and a bipartite graph of the color image are acquired.
Wherein, the bipartite graph comprises: a foreground region for representing an image region of the target object, and a background region.
In the embodiment of the present invention, the target object may be a person, or may be other foreground objects such as an animal, a vehicle, etc., which is not specifically limited.
The bipartite graph of the color image is obtained by performing image segmentation processing on the color image, in which a foreground region and a background region are roughly marked, the pixel value of the foreground region pixel point may be set to 255 for representing the image region of the target object, and the pixel value of the background region pixel point may be set to 0. In fact, in the bipartite graph, the pixel values of the pixel points include pixel values between 0 and 255 in addition to 0 and 255, but the pixel values between 0 and 255 are relatively small.
And step S204, performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image to obtain a smoothing filtering image of the bipartite graph.
The above-mentioned process of edge-preserving smoothing filtering can be performed in the edge-preserving smoothing filter, and the edge information in the image can be effectively preserved in the filtering process, and the pixel points of many marks errors in the image edge region can be reduced (i.e. the pixel values of the two-pixel edge region can be changed due to the bilateral characteristic of the edge-preserving smoothing filter, so that the pixel values of the pixel points with similar color and space distance to the foreground region are more towards the foreground region, the pixel values of the pixel points with similar background region are more towards the background region, and the pixel points with less similarity to the foreground region and the background region are still used as unknown regions). The edge-preserving smoothing filter may be a Bilateral filter (bilinear filter), a pilot filter (Guided image filter), a weighted least square filter (Weighted least square filter), or the like, and the embodiment is not limited specifically.
Step S206, constructing a trimap image of the color image based on the smoothed filtered image of the trimap image.
Wherein, the trisection diagram includes: an optimized foreground region, an optimized background region, and an unknown region.
When the method is realized, the region marking can be carried out on each pixel point in the smooth filter image again according to the pixel value of each pixel point in the smooth filter image, so that a trimap image of the color image is obtained.
In the above-described trimap image, the pixel value of the optimized foreground region pixel may be set to 255, the pixel value of the optimized background region pixel may be set to 0, and the pixel value of the unknown region pixel may be set to any value (e.g., 128) between 0 and 255 for distinguishing from the optimized foreground region and the optimized background region. In the subsequent fine matting processing, only the unknown region is processed, after the edge-preserving smoothing filtering processing in the step S204, the pixel values of the pixel points similar to the foreground region in the smoothing filtering image tend towards the foreground region, and the pixel values of the pixel points similar to the background region tend towards the background region, so that when the region marking is performed on each pixel point in the smoothing filtering image again according to the pixel values of each pixel point in the smoothing filtering image, the area of the unknown region can be reduced, the pixel points in the subsequent processing of the fine matting algorithm are reduced, and the time consumption of the algorithm is further reduced.
In the embodiment of the invention, a color image containing a target object and a bipartite graph of the color image are firstly acquired; then, edge-preserving smooth filtering processing is carried out on the bipartite graph based on the color image, and a smooth filtering image of the bipartite graph is obtained; finally, a bipartite graph of the color image is constructed based on the smoothed filtered image of the bipartite graph. As can be seen from the above description, in the embodiment of the present invention, in the process of performing edge-preserving smoothing filtering on a bipartite graph through a color image, the pixel values of the edge regions of the bipartite graph are changed due to the bilateral characteristics of the edge-preserving smoothing filtering, so that the pixel values of the pixel points with similar color and spatial distances to the foreground region are more towards the foreground region, the pixel values of the pixel points with similar background region are more towards the background region, and the pixel points with less similarity to the foreground region and the background region are still used as the unknown region.
In the present embodiment, the above step S202 is given, and one implementation of acquiring a color image containing a target object and a bipartite graph of the color image is provided, including the steps of (1) and (2) as follows:
(1) A color image is acquired that contains the target object.
In the implementation, the color image may be an image obtained by photographing the target object with a photographing device such as a camera or a video camera, may be a pre-stored image including the target object, or may be an image including the target object downloaded from a target location, and the embodiment does not specifically limit the acquisition manner.
(2) And performing image segmentation processing on the color image to obtain a bipartite graph of the color image.
Among them, image segmentation is generally used to locate objects and boundaries in an image, and is a process of adding a label to each pixel in an image, which can enable pixels having the same label to have a common visual characteristic.
In this embodiment, an implementation manner of the image segmentation process is provided, including:
and carrying out image segmentation processing on the color image based on a semantic segmentation algorithm corresponding to the target object to obtain a bipartite graph of the color image.
For example: if the target object is a person, the semantic segmentation algorithm corresponding to the target object can be a portrait semantic segmentation algorithm; if the target object is an animal, the semantic segmentation algorithm corresponding to the target object may be an animal semantic segmentation algorithm. The two semantic segmentation algorithms are basically the same, but the training samples adopted in training are different, the portrait semantic segmentation algorithm adopts the images containing people in training, and the animal semantic segmentation algorithm adopts the images containing animals in training.
In addition, besides the semantic segmentation algorithm described in the above description, other image segmentation algorithms may be used to perform image segmentation processing on the color image, so as to obtain a bipartite graph of the color image. For example, other image segmentation algorithms may also be: the image segmentation algorithm is not particularly limited in this embodiment, and may be any one of a segmentation method based on edge detection, a segmentation method based on a threshold value, a segmentation method based on a region, and the like.
Considering that the area label marked on each pixel point is not accurate enough in the image segmentation process, a plurality of marked pixel points with errors appear in the edge area of the obtained bipartite graph, based on this, referring to the flowchart of the method for performing edge-preserving smoothing filtering processing on the bipartite graph shown in fig. 3, the method provides a specific implementation manner of the step of performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image in the step S206, and the method includes the following steps:
Step S301, a target edge-preserving smooth filtering strategy selected by a user according to image processing requirements is obtained.
The target edge protection smoothing filtering strategy comprises any one of a first edge protection smoothing filtering strategy, a second edge protection smoothing filtering strategy, a third edge protection smoothing filtering strategy and a fourth edge protection smoothing filtering strategy, and the first edge protection smoothing filtering strategy comprises: the strategy of the first edge-preserving smoothing filtering algorithm, and the second edge-preserving smoothing filtering strategy comprises: the strategy of the downsampling algorithm and the first edge-preserving smoothing filtering algorithm, and the third edge-preserving smoothing filtering strategy comprises: the strategy of a downsampling algorithm, a first edge-preserving smooth filtering algorithm and a noise suppression algorithm, and the fourth edge-preserving smooth filtering strategy comprises: a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm.
When the method is implemented, a user can select a corresponding target edge-preserving smooth filtering strategy according to the actual image processing requirement. For easy understanding, the following describes the advantages and disadvantages of the four edge-preserving smoothing filtering strategies in this embodiment:
the first edge-preserving smoothing filtering strategy can be a strategy of a first edge-preserving smoothing filtering algorithm, namely, edge-preserving smoothing filtering processing is directly carried out on a bipartite graph with the same size as a color image through the first edge-preserving smoothing filtering algorithm, and the time consumption is relatively long during the edge-preserving smoothing filtering processing because the bipartite graph is large in size and more in pixel number to be processed; however, since the size of the bipartite graph is the same as that of the color image, the edge effect of the obtained smooth filter image is better after the edge protection smooth filter processing is directly carried out on the bipartite graph with the same size as the color image. If the processing capability of the hardware device is strong and the user has a relatively high requirement on the edge optimization effect, the first edge-preserving smoothing filtering strategy can be selected.
The second edge-preserving smooth filtering strategy can be a downsampling algorithm and a first edge-preserving smooth filtering algorithm, namely, the downsampling algorithm is adopted to downsample the color image and the bipartite graph respectively, then the downsampled bipartite graph is subjected to edge-preserving smooth filtering treatment through the first edge-preserving smooth filtering algorithm, the size of the downsampled bipartite graph is reduced, the number of pixels to be treated is reduced, and therefore time consumption is saved during the edge-preserving smooth filtering treatment; however, due to the reduction of the size of the bipartite graph, the edge effect of the obtained smooth filtered image is slightly worse than that of the smooth filtered image obtained by smoothing the bipartite graph with the size not reduced. If the processing capability of the hardware device is general and the requirement of the user on the edge optimization effect is not high, a second edge-preserving smooth filtering strategy can be selected.
The third edge-preserving smoothing filtering strategy can be a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a noise suppression algorithm, namely, downsampling is carried out on the color image and the bipartite image respectively by adopting the downsampling algorithm, then edge-preserving smoothing filtering processing is carried out on the downsampled bipartite image by adopting the first edge-preserving smoothing filtering algorithm, and further noise suppression is carried out on the filtered image. Based on the above description, compared with the second edge-preserving smoothing filtering strategy, the edge optimization effect of the strategy is relatively better, and meanwhile, the time is saved. If the processing capability of the hardware device is general and the requirement of the user on the edge optimization effect is high, a third edge protection smoothing filtering strategy can be selected.
The fourth edge-preserving smoothing filtering strategy may be a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm, that is, downsampling the color image and the bipartite graph respectively by the downsampling algorithm, then performing edge-preserving smoothing filtering processing on the downsampled bipartite graph by the first edge-preserving smoothing filtering algorithm, further upsampling the image obtained after the second edge-preserving smoothing filtering processing, and finally performing edge-preserving smoothing filtering processing on the upsampled image by the second edge-preserving smoothing filtering algorithm. Therefore, the policy performs edge protection smoothing filter processing on the bipartite graph in two sizes, the first edge protection smoothing filter processing is implemented on the downsampled bipartite graph, so that pixel points with errors marked in an edge area can be greatly reduced, and the purpose of greatly reducing an unknown area is further achieved. If the processing capacity of the hardware device is general and the requirement of the user on the edge optimization effect is high, a fourth edge protection smoothing filtering strategy can be selected.
It should be noted that: other edge smoothing filter strategies besides the four edge smoothing filter strategies described in the foregoing description of the present embodiment may be used. For example, a multi-scale edge smoothing strategy similar to the fourth edge smoothing strategy, that is, the edge smoothing filtering is performed not only twice on the bipartite graph, but also more times on more sizes, but the time consumption and the effect are weighed according to the actual situation. Other edge-preserving smoothing filtering strategies derived from this embodiment are within the scope of the present application.
Step S302, edge protection smoothing filter processing is carried out on the bipartite graph based on the color image and the target edge protection smoothing filter strategy.
The following specifically describes a process of performing edge-preserving smoothing filtering processing on the bipartite graph by adopting each edge-preserving smoothing filtering strategy:
1. when the target edge-preserving smoothing filtering strategy is the first edge-preserving smoothing filtering strategy (i.e. the strategy of the first edge-preserving smoothing filtering algorithm), the step of performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy includes:
and inputting the color image and the bipartite graph into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
2. When the target edge-preserving smoothing filtering strategy is the second edge-preserving smoothing filtering strategy (i.e. the strategy of the downsampling algorithm and the first edge-preserving smoothing filtering algorithm), the step of performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy comprises:
(1) And respectively downsampling the color image and the bipartite graph by adopting a downsampling algorithm to obtain the color image of the first size and the bipartite graph of the first size.
The first size is not specifically limited, and may be determined according to the processing capability of the hardware device and the time-consuming requirement of the user (if the processing capability of the hardware device is strong and the user has no requirement for time consumption, the first size may be a size that is slightly smaller than the size of the original color image, and if the processing capability of the hardware device is insufficient and the user wants to save time, the first size may be a smaller size).
The downsampling algorithm may be a bilinear or nearest neighbor downsampling algorithm, and the downsampling algorithm is not limited in this embodiment.
(2) And inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
The size of the smoothed filtered image of the obtained bipartite graph after the edge-preserving smoothing filtering processing is also the first size.
3. When the target edge-preserving smoothing filtering strategy is the third edge-preserving smoothing filtering strategy (namely the strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a noise suppression algorithm), the step of carrying out edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy comprises the following steps:
(a) And respectively downsampling the color image and the bipartite graph by adopting a downsampling algorithm to obtain the color image of the first size and the bipartite graph of the first size.
The process may refer to the description of (1) in the second edge-preserving smoothing filtering strategy, which is not described herein.
(b) And inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, so as to obtain an initial smoothing filtering image of the bipartite graph.
After the edge-preserving smoothing filtering process, the size of the initial smoothing filtered image of the obtained bipartite graph is also the first size.
(c) And carrying out noise suppression processing on the initial smooth filtered image by adopting a noise suppression algorithm to obtain a smooth filtered image of the bipartite graph.
The inventor considers that noise may be introduced when the edge-preserving smoothing filter processing is performed, based on which, after the edge-preserving smoothing filter processing is completed, the embodiment further performs noise suppression processing on the initial smoothing filter image obtained by the edge-preserving smoothing filter processing by using a noise suppression algorithm, so as to obtain a bipartite smoothing filter image.
The specific process of performing the noise suppression processing on the initial smooth filtered image by using the noise suppression algorithm can refer to the process of performing the noise suppression processing on the bipartite graph with the second size by using the noise suppression algorithm, which is not described herein.
4. When the target edge-preserving smoothing filtering policy is a fourth edge-preserving smoothing filtering policy (i.e., a policy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm, and a second edge-preserving smoothing filtering algorithm), referring to fig. 4, the step of performing edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering policy includes:
in step S401, a downsampling algorithm is used to downsample the color image and the bipartite graph respectively, so as to obtain a color image of a first size, a color image of a second size and the bipartite graph of the first size.
In this embodiment, the value of the second dimension is larger than the value of the first dimension, and the first dimension and the second dimension may also be determined according to the processing capability of the hardware device and the time-consuming requirement of the user.
Step S402, inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, and obtaining the bipartite graph with the first size after smoothing filtering.
Step S403, upsampling the smoothed first size bipartite graph to obtain a second size bipartite graph.
In this embodiment, the upsampling may be performed by using a bilinear algorithm, and the specific algorithm of the upsampling is not limited in this embodiment.
Step S404, inputting the color image with the second size and the bipartite graph with the second size into a second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, and obtaining a smoothing filtering image of the bipartite graph.
In the fourth edge-preserving smooth filtering strategy, the bipartite graph of the first size after smooth filtering is obtained by carrying out edge-preserving smooth filtering on the bipartite graph of the first size, so that pixel points with errors marked in an edge area can be greatly reduced, the purpose of greatly reducing an unknown area is achieved, the smooth filtering image of the bipartite graph is obtained by carrying out edge-preserving smooth filtering on the bipartite graph of the second size, the pixel points with errors marked in the edge area can be accurately reduced, and the purpose of accurately reducing the unknown area is achieved. In addition, the first edge-preserving smoothing filter algorithm and the second edge-preserving smoothing filter algorithm may be the same edge-preserving smoothing filter, but parameters of the algorithm need to be changed according to the change of the size.
The inventors consider that noise is introduced in the first edge-preserving smoothing filter processing and the upsampling process, based on which, after obtaining the second size bipartite graph, the method further comprises the following steps before inputting the second size color image and the second size bipartite graph into the second edge-preserving smoothing filter algorithm for edge-preserving smoothing filter processing:
and carrying out noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm to obtain the bipartite graph with the second size after noise suppression, and inputting the color image with the second size and the bipartite graph with the second size after noise suppression into a second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing.
After the noise suppression processing is completed, inputting the bipartite graph with the second size and the color image with the second size after the noise suppression into a second edge protection smoothing filter algorithm to carry out edge protection smoothing filter processing, and finally obtaining a smoothing filter image with the bipartite graph with better effect.
The embodiment provides an implementation manner of noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm, which comprises the following steps:
in the bipartite graph with the second size, the pixel value of the pixel point of the first area is reduced according to the first coefficient, and the pixel value of the pixel point of the second area is enlarged according to the second coefficient.
The first region is a region in which the pixel value of the pixel point is smaller than a first preset threshold value, the second region is a region in which the pixel value of the pixel point is larger than a second preset threshold value, the first preset threshold value is smaller than the second preset threshold value, the first coefficient is the proportion between the pixel value of the corresponding pixel point in the first region and the first preset threshold value, and the second coefficient is the proportion between the pixel value of the corresponding pixel point in the second region and the second preset threshold value.
The procedure of the above noise suppression processing is described below in a popular language: for the bipartite graph of the second size, the pixel points of the region in which the pixel value is smaller than T1 (i.e. a first preset threshold value, such as 255×0.4) are scaled down by dividing the pixel value of the region by T1 as a coefficient (i.e. a first coefficient); meanwhile, the pixel point of the region with the pixel value larger than T2 (i.e. a second preset threshold value, such as 255 x 0.6) is divided by the pixel value of the region by T2 to be a coefficient (i.e. a second coefficient) to expand the pixel value of the region.
It should be noted that, the first preset threshold and the second preset threshold may be adjusted according to actual applications, which is not limited in this embodiment.
After the noise suppression processing is performed, in the bipartite graph with the second size, the pixel value of the pixel point with the pixel value smaller than the first preset threshold value is closer to 0, and the pixel value of the pixel point with the pixel value larger than the second preset threshold value is closer to 255, so that the purpose of reducing noise points is achieved.
After finishing the edge-preserving smoothing filtering processing to obtain a smoothed filtered image, further constructing a trimap image of the color image based on the smoothed filtered image of the trimap image, the method may include the steps of:
(i) In the smoothing filter image, the pixel value of the pixel point of the third region is set to the first value, the pixel value of the pixel point of the fourth region is set to the second value, and the pixel value of the pixel point of the fifth region is set to the third value.
The third region is a region with pixel values of the pixel points larger than a third preset threshold value, the fourth region is a region with pixel values of the pixel points smaller than a fourth preset threshold value, the fifth region is a remaining region in the smooth filtering image after the third region and the fourth region are removed, and the third preset threshold value is larger than the fourth preset threshold value.
(ii) The third region is marked as an optimized foreground region, the fourth region is marked as an optimized background region, and the fifth region is marked as an unknown region.
When the three-dimensional graph construction of the color image is carried out, setting the pixel value of the pixel point with the pixel value larger than T3 (namely a third preset threshold value which can be 255 x 0.8) in the smooth filtering image as 255 (namely a first value), and marking the area (namely a third area) surrounded by the pixel points as an optimized foreground area; meanwhile, setting the pixel value of the pixel point with the pixel value smaller than T4 (a fourth preset threshold value which can be 255 x 0.2) in the smooth filtering image to be 0 (namely a second value), and marking the area (namely a fourth area) surrounded by the pixel points as an optimized background area; the area surrounded by other pixels (i.e., the fifth area) is marked as an unknown area, where the pixel value of the pixel may be set to 128 (i.e., the third value).
The third preset threshold, the fourth preset threshold, the first value, the second value and the third value are not limited in this embodiment.
After the trisection of the color image is obtained, the obtained trisection can be subjected to fine matting processing through a fine matting algorithm, so that a fine matting result of the target object is obtained. In an optional implementation manner of this embodiment, referring to fig. 5, a process of performing fine matting processing on the trimap image includes the following steps:
step S501, up-sampling or down-sampling the trisection image and the color image according to the fine matting processing size to obtain the trisection image and the color image of the fine matting processing size.
When the method is implemented, if the fine matting processing size is larger than the size of the trisection, downsampling is carried out on the obtained trisection, and downsampling is carried out to the fine matting processing size; if the fine matting processing size is smaller than the size of the trisection, up-sampling is carried out on the obtained trisection, and up-sampling is carried out to the fine matting size. Similarly, the color image needs to be up-sampled or down-sampled according to the fine matting processing size.
In a specific implementation, the collected color image is generally a high-definition image, which has the largest corresponding resolution size, the fine matting processing size is repeated, the second size is repeated, and the first size is the smallest.
Step S502, inputting the trisection image of the fine matting processing size and the color image of the fine matting processing size into the fine matting model for fine matting processing, and obtaining a fine matting result of the target object.
The fine matting model (i.e. the fine matting algorithm may be a closed-form solution based matting algorithm (i.e. a closed surface matting algorithm)) inputs a tri-component image with a fine matting processing size and a color image with a fine matting processing size into the fine matting model, and then the fine matting model performs fine matting processing on the edge of an unknown region of the tri-component image, thereby obtaining a fine matting result of the target object. Referring to fig. 6a to 6c, a schematic diagram of a color image including a target object is shown in fig. 6a, a schematic diagram of a three-dimensional image of the color image is shown in fig. 6b, and a schematic diagram of a fine matting result of the target object is shown in fig. 6 c.
After the fine matting result (i.e. alpha mask) of the target object is obtained, the fine matting result can be used in some common image processing functions, such as background replacement, depth effect rendering, and the like.
In the trimap image of the color image constructed by the trimap image construction method of the embodiment, the unknown area is very small, and the number of pixel points of the fine matting processing is reduced, thereby achieving the purpose of reducing the time consumption of the algorithm. In addition, when the unknown region is subjected to refined edge restoration by the fine matting algorithm, if the unknown region is too large, the known region information reliable in the space distance is relatively less, so that the effect of final fine matting is affected.
Example 3:
the embodiment of the invention also provides a device for constructing the trimap image, which is mainly used for executing the method for constructing the trimap image provided by the embodiment of the invention, and the device for constructing the trimap image provided by the embodiment of the invention is specifically introduced below.
Fig. 7 is a schematic view of a three-dimensional drawing constructing apparatus according to an embodiment of the present invention, and as shown in fig. 7, the three-dimensional drawing constructing apparatus mainly includes: an acquisition unit 10, a guard smoothing filter processing unit 20, and a three-dimensional map construction unit 30, wherein:
an acquisition unit configured to acquire a color image containing a target object and a bipartite graph of the color image; the bipartite graph comprises: a foreground region and a background region, the foreground region being for representing an image region of a target object;
the edge-preserving smooth filtering processing unit is used for carrying out edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph;
a bipartite graph construction unit for constructing a bipartite graph of the color image based on the smoothed filtered image of the bipartite graph; the trimap image includes: an optimized foreground region, an optimized background region, and an unknown region.
In the embodiment of the invention, a color image containing a target object and a bipartite graph of the color image are firstly acquired; then, edge-preserving smooth filtering processing is carried out on the bipartite graph based on the color image, and a smooth filtering image of the bipartite graph is obtained; finally, a bipartite graph of the color image is constructed based on the smoothed filtered image of the bipartite graph. As can be seen from the above description, in the embodiment of the present invention, in the process of performing edge-preserving smoothing filtering on a bipartite graph through a color image, the pixel values of the edge regions of the bipartite graph are changed due to the bilateral characteristics of the edge-preserving smoothing filtering, so that the pixel values of the pixel points with similar color and spatial distances to the foreground region are more towards the foreground region, the pixel values of the pixel points with similar background region are more towards the background region, and the pixel points with less similarity to the foreground region and the background region are still used as the unknown region.
Optionally, the above-mentioned acquisition unit is further configured to: acquiring a color image containing a target object; and performing image segmentation processing on the color image to obtain a bipartite graph of the color image.
Optionally, the above-mentioned edge-preserving smoothing filter processing unit is further configured to: acquiring a target edge-preserving smooth filtering strategy selected by a user according to image processing requirements; the target edge-preserving smoothing filtering strategy comprises any one of a first edge-preserving smoothing filtering strategy, a second edge-preserving smoothing filtering strategy, a third edge-preserving smoothing filtering strategy and a fourth edge-preserving smoothing filtering strategy, and the first edge-preserving smoothing filtering strategy comprises: the strategy of the first edge-preserving smoothing filtering algorithm, and the second edge-preserving smoothing filtering strategy comprises: the strategy of the downsampling algorithm and the first edge-preserving smoothing filtering algorithm, and the third edge-preserving smoothing filtering strategy comprises: the strategy of a downsampling algorithm, a first edge-preserving smooth filtering algorithm and a noise suppression algorithm, and the fourth edge-preserving smooth filtering strategy comprises: a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm; and carrying out edge-preserving smoothing filtering treatment on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy.
Optionally, when the target guard smoothing filter policy is the policy of the first guard smoothing filter algorithm; the edge-protection smooth filtering processing unit is also used for: and inputting the color image and the bipartite graph into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
Optionally, when the target guard smoothing filter strategy is a strategy of a downsampling algorithm and a first guard smoothing filter algorithm; the edge-protection smooth filtering processing unit is also used for: respectively downsampling the color image and the bipartite graph by adopting a downsampling algorithm to obtain a color image of a first size and a bipartite graph of the first size; and inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
Optionally, when the target guard smoothing filtering strategy is a strategy of a downsampling algorithm, a first guard smoothing filtering algorithm and a noise suppression algorithm; the edge-protection smooth filtering processing unit is also used for: respectively downsampling the color image and the bipartite graph by adopting a downsampling algorithm to obtain a color image of a first size and a bipartite graph of the first size; inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain an initial smoothing filtering image of the bipartite graph; and carrying out noise suppression processing on the initial smooth filtered image by adopting a noise suppression algorithm to obtain a smooth filtered image of the bipartite graph.
Optionally, when the target edge-preserving smoothing filtering strategy is a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm; the edge-protection smooth filtering processing unit is also used for: respectively downsampling the color image and the bipartite graph by adopting a downsampling algorithm to obtain a color image of a first size, a color image of a second size and the bipartite graph of the first size; inputting the color image with the first size and the bipartite graph with the first size into a first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering treatment to obtain a bipartite graph with the first size after smoothing filtering; up-sampling the smoothed and filtered bipartite graph with the first size to obtain a bipartite graph with the second size; and inputting the color image with the second size and the bipartite graph with the second size into a second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, so as to obtain a smoothing filtering image of the bipartite graph.
Optionally, the above-mentioned edge-preserving smoothing filter processing unit is further configured to: and carrying out noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm to obtain the bipartite graph with the second size after noise suppression, and inputting the color image with the second size and the bipartite graph with the second size after noise suppression into a second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing.
Optionally, the above-mentioned edge-preserving smoothing filter processing unit is further configured to: in the bipartite graph with the second size, the pixel value of the pixel point of the first area is reduced according to a first coefficient, and the pixel value of the pixel point of the second area is enlarged according to a second coefficient; the first region is a region in which the pixel value of the pixel point is smaller than a first preset threshold value, the second region is a region in which the pixel value of the pixel point is larger than a second preset threshold value, the first preset threshold value is smaller than the second preset threshold value, the first coefficient is the proportion between the pixel value of the corresponding pixel point in the first region and the first preset threshold value, and the second coefficient is the proportion between the pixel value of the corresponding pixel point in the second region and the second preset threshold value.
Optionally, the above-mentioned bipartite graph construction unit is further configured to: in the smooth filtered image, setting the pixel value of the pixel point of the third area as a first value, the pixel value of the pixel point of the fourth area as a second value, and the pixel value of the pixel point of the fifth area as a third value; the third region is a region with pixel values of the pixel points being larger than a third preset threshold value, the fourth region is a region with pixel values of the pixel points being smaller than a fourth preset threshold value, and the fifth region is a remaining region after the third region and the fourth region are removed from the smooth filtering image, wherein the third preset threshold value is larger than the fourth preset threshold value; the third region is marked as an optimized foreground region, the fourth region is marked as an optimized background region, and the fifth region is marked as an unknown region.
Optionally, the device is further configured to: and carrying out fine matting processing on the trimap image to obtain a fine matting result of the target object.
Optionally, the device is further configured to: respectively up-sampling or down-sampling the trisection image and the color image according to the fine matting processing size to obtain a trisection image of the fine matting processing size and a color image of the fine matting processing size; inputting the three-part images with the fine matting processing size and the color images with the fine matting processing size into the fine matting model to carry out fine matting processing, and obtaining a fine matting result of the target object.
The device provided by the embodiment of the present invention has the same implementation principle and technical effects as those of the foregoing method embodiment, and for the sake of brevity, reference may be made to the corresponding content in the foregoing method embodiment where the device embodiment is not mentioned.
In another implementation of the present invention, there is also provided a computer storage medium having stored thereon a computer program which, when run, performs the steps of the method of any of the above method embodiments 2.
In addition, in the description of embodiments of the present invention, unless explicitly stated and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the above examples are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention, but it should be understood by those skilled in the art that the present invention is not limited thereto, and that the present invention is described in detail with reference to the foregoing examples: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (14)

1. A method of constructing a bipartite graph, comprising:
acquiring a color image containing a target object and a bipartite graph of the color image; the bipartite graph comprises: a foreground region and a background region, the foreground region being for representing an image region of the target object;
Performing edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph;
re-marking the areas of all the pixel points in the smooth filter image based on the pixel values of all the pixel points in the smooth filter image of the bipartite graph to obtain a bipartite graph of the color image; the trimap image includes: an optimized foreground region, an optimized background region, and an unknown region;
the step of re-marking the area of each pixel point in the smooth filtering image based on the pixel value of each pixel point in the smooth filtering image of the bipartite graph comprises the following steps:
in the smooth filtering image, setting the pixel value of the pixel point of the third area as a first value, setting the pixel value of the pixel point of the fourth area as a second value, and setting the pixel value of the pixel point of the fifth area as a third value; the third region is a region with pixel values of the pixel points larger than a third preset threshold, the fourth region is a region with pixel values of the pixel points smaller than a fourth preset threshold, and the fifth region is a remaining region in the smooth filtered image after the third region and the fourth region are removed, wherein the third preset threshold is larger than the fourth preset threshold;
Marking the third region as the optimized foreground region, the fourth region as the optimized background region, and the fifth region as the unknown region.
2. The method of claim 1, wherein the step of acquiring a color image containing the target object and a bipartite graph of the color image comprises:
acquiring a color image containing a target object;
and carrying out image segmentation processing on the color image to obtain a bipartite graph of the color image.
3. The method of claim 1, wherein performing a warranty smoothing filter process on the bipartite graph based on the color image comprises:
acquiring a target edge-preserving smooth filtering strategy selected by a user according to image processing requirements; the target edge protection smoothing filtering strategy comprises any one of a first edge protection smoothing filtering strategy, a second edge protection smoothing filtering strategy, a third edge protection smoothing filtering strategy and a fourth edge protection smoothing filtering strategy, and the first edge protection smoothing filtering strategy comprises: a policy of a first edge-preserving smoothing filtering algorithm, the second edge-preserving smoothing filtering policy comprising: a downsampling algorithm and a first edge-preserving smoothing filtering algorithm, the third edge-preserving smoothing filtering algorithm comprising: the strategy of a downsampling algorithm, a first edge-preserving smooth filtering algorithm and a noise suppression algorithm, and the fourth edge-preserving smooth filtering strategy comprises: a strategy of a downsampling algorithm, a first edge-preserving smoothing filtering algorithm and a second edge-preserving smoothing filtering algorithm;
And carrying out edge-preserving smoothing filtering processing on the bipartite graph based on the color image and the target edge-preserving smoothing filtering strategy.
4. The method of claim 3, wherein when the target guard smoothing filter policy is a policy of a first guard smoothing filter algorithm;
based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps:
and inputting the color image and the bipartite graph into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain a smoothing filtering image of the bipartite graph.
5. The method of claim 3, wherein when the target guard smoothing filter strategy is a strategy of a downsampling algorithm and a first guard smoothing filter algorithm;
based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps:
respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image with a first size and a bipartite graph with a first size;
and inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing, so as to obtain a smoothing filtering image of the bipartite graph.
6. The method of claim 3, wherein when the target guard smoothing filter strategy is a strategy of a downsampling algorithm, a first guard smoothing filter algorithm, and a noise suppression algorithm;
based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps:
respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image with a first size and a bipartite graph with a first size;
inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing to obtain an initial smoothing filtering image of the bipartite graph;
and carrying out noise suppression processing on the initial smooth filtered image by adopting the noise suppression algorithm to obtain the smooth filtered image of the bipartite graph.
7. The method of claim 3, wherein when the target guard smoothing filter strategy is a strategy of a downsampling algorithm, a first guard smoothing filter algorithm, and a second guard smoothing filter algorithm;
based on the color image and the target edge-preserving smooth filtering strategy, the step of carrying out edge-preserving smooth filtering processing on the bipartite graph comprises the following steps:
Respectively downsampling the color image and the bipartite graph by adopting the downsampling algorithm to obtain a color image of a first size, a color image of a second size and a bipartite graph of the first size;
inputting the color image with the first size and the bipartite graph with the first size into the first edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering treatment to obtain the bipartite graph with the first size after smoothing filtering;
upsampling the smoothed and filtered bipartite graph of the first size to obtain a bipartite graph of the second size;
and inputting the color image with the second size and the bipartite graph with the second size into the second edge-preserving smooth filtering algorithm to carry out edge-preserving smooth filtering processing, so as to obtain a smooth filtering image of the bipartite graph.
8. The method of claim 7, wherein after obtaining the bipartite graph of the second size, the method further comprises, before inputting the color image of the second size and the bipartite graph of the second size into the second edge-preserving smoothing filter algorithm for edge-preserving smoothing filter processing:
and carrying out noise suppression processing on the bipartite graph with the second size by adopting a noise suppression algorithm to obtain a bipartite graph with the second size after noise suppression, and inputting the color image with the second size and the bipartite graph with the second size after noise suppression into the second edge-preserving smoothing filtering algorithm to carry out edge-preserving smoothing filtering processing.
9. The method of claim 8, wherein the step of noise suppressing the bipartite graph of the second size using a noise suppression algorithm comprises:
in the bipartite graph with the second size, the pixel value of the pixel point of the first area is reduced according to a first coefficient, and the pixel value of the pixel point of the second area is enlarged according to a second coefficient;
the first region is a region in which the pixel value of the pixel point is smaller than a first preset threshold, the second region is a region in which the pixel value of the pixel point is larger than a second preset threshold, the first preset threshold is smaller than the second preset threshold, the first coefficient is a proportion between the pixel value of the corresponding pixel point in the first region and the first preset threshold, and the second coefficient is a proportion between the pixel value of the corresponding pixel point in the second region and the second preset threshold.
10. The method according to claim 1, wherein the method further comprises:
and carrying out fine matting processing on the trisection image to obtain a fine matting result of the target object.
11. A method as in claim 10 wherein the step of performing fine matting of the trimap image comprises:
Respectively up-sampling or down-sampling the trisection image and the color image according to the fine matting processing size to obtain a trisection image of the fine matting processing size and a color image of the fine matting processing size;
inputting the trisection image of the fine matting processing size and the color image of the fine matting processing size into a fine matting model for fine matting processing to obtain a fine matting result of the target object.
12. A device for constructing a trimap image, comprising:
an acquisition unit configured to acquire a color image including a target object and a bipartite graph of the color image; the bipartite graph comprises: a foreground region and a background region, the foreground region being for representing an image region of the target object;
the edge-preserving smooth filtering processing unit is used for carrying out edge-preserving smooth filtering processing on the bipartite graph based on the color image to obtain a smooth filtering image of the bipartite graph;
the three-division image construction unit is used for re-marking each pixel point in the smooth filter image based on the pixel value of each pixel point in the smooth filter image of the two-division image to obtain a three-division image of the color image; the trimap image includes: an optimized foreground region, an optimized background region, and an unknown region;
Wherein the three-dimensional graph construction unit is further configured to: in the smooth filtering image, setting the pixel value of the pixel point of the third area as a first value, setting the pixel value of the pixel point of the fourth area as a second value, and setting the pixel value of the pixel point of the fifth area as a third value; the third region is a region with pixel values of the pixel points larger than a third preset threshold, the fourth region is a region with pixel values of the pixel points smaller than a fourth preset threshold, and the fifth region is a remaining region in the smooth filtered image after the third region and the fourth region are removed, wherein the third preset threshold is larger than the fourth preset threshold; marking the third region as the optimized foreground region, the fourth region as the optimized background region, and the fifth region as the unknown region.
13. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1 to 11 when executing the computer program.
14. A computer storage medium, characterized in that a computer program is stored thereon, which computer program, when running, performs the steps of the method according to any of the preceding claims 1 to 11.
CN201910799574.2A 2019-08-27 2019-08-27 Method and device for constructing three-dimensional graph and electronic equipment Active CN110503704B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910799574.2A CN110503704B (en) 2019-08-27 2019-08-27 Method and device for constructing three-dimensional graph and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910799574.2A CN110503704B (en) 2019-08-27 2019-08-27 Method and device for constructing three-dimensional graph and electronic equipment

Publications (2)

Publication Number Publication Date
CN110503704A CN110503704A (en) 2019-11-26
CN110503704B true CN110503704B (en) 2023-07-21

Family

ID=68589963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910799574.2A Active CN110503704B (en) 2019-08-27 2019-08-27 Method and device for constructing three-dimensional graph and electronic equipment

Country Status (1)

Country Link
CN (1) CN110503704B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111047604B (en) * 2019-11-29 2023-04-28 贵州民族大学 Transparency mask extraction method and device for high-definition image and storage medium
CN113129207B (en) * 2019-12-30 2023-08-01 武汉Tcl集团工业研究院有限公司 Picture background blurring method and device, computer equipment and storage medium
CN111462027B (en) * 2020-03-12 2023-04-18 中国地质大学(武汉) Multi-focus image fusion method based on multi-scale gradient and matting
CN111489429B (en) * 2020-04-16 2024-06-07 诚迈科技(南京)股份有限公司 Image rendering control method, terminal equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107452010A (en) * 2017-07-31 2017-12-08 中国科学院长春光学精密机械与物理研究所 A kind of automatically stingy nomography and device
CN107516319A (en) * 2017-09-05 2017-12-26 中北大学 A kind of high accuracy simple interactive stingy drawing method, storage device and terminal

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2374107B1 (en) * 2008-12-11 2020-07-08 Imax Corporation Devices and methods for processing images using scale space
JP5012967B2 (en) * 2010-07-05 2012-08-29 カシオ計算機株式会社 Image processing apparatus and method, and program
EP3046073A1 (en) * 2015-01-14 2016-07-20 Thomson Licensing Method and apparatus for color correction in an alpha matting process
CN106485720A (en) * 2016-11-03 2017-03-08 广州视源电子科技股份有限公司 Image processing method and device
CN108205804B (en) * 2016-12-16 2022-05-31 斑马智行网络(香港)有限公司 Image processing method and device and electronic equipment
CN106952270A (en) * 2017-03-01 2017-07-14 湖南大学 A kind of quickly stingy drawing method of uniform background image
CN107481261B (en) * 2017-07-31 2020-06-16 中国科学院长春光学精密机械与物理研究所 Color video matting method based on depth foreground tracking
CN107730528A (en) * 2017-10-28 2018-02-23 天津大学 A kind of interactive image segmentation and fusion method based on grabcut algorithms
CN107993238A (en) * 2017-12-19 2018-05-04 中科视拓(北京)科技有限公司 A kind of head-and-shoulder area image partition method and device based on attention model
CN108320294B (en) * 2018-01-29 2021-11-05 袁非牛 Intelligent full-automatic portrait background replacement method for second-generation identity card photos
CN108230341B (en) * 2018-03-07 2021-12-17 汕头大学 Eyeground image blood vessel segmentation method based on layered matting algorithm
CN108876743B (en) * 2018-06-26 2020-12-29 中山大学 Image rapid defogging method, system, terminal and storage medium
CN108961303B (en) * 2018-07-23 2021-05-07 北京旷视科技有限公司 Image processing method and device, electronic equipment and computer readable medium
CN109377499B (en) * 2018-09-12 2022-04-15 中山大学 Pixel-level object segmentation method and device
CN109903321A (en) * 2018-10-16 2019-06-18 迈格威科技有限公司 Image processing method, image processing apparatus and storage medium
CN109584262A (en) * 2018-12-15 2019-04-05 中国科学院深圳先进技术研究院 Cloud detection method of optic, device and electronic equipment based on remote sensing image

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107452010A (en) * 2017-07-31 2017-12-08 中国科学院长春光学精密机械与物理研究所 A kind of automatically stingy nomography and device
CN107516319A (en) * 2017-09-05 2017-12-26 中北大学 A kind of high accuracy simple interactive stingy drawing method, storage device and terminal

Also Published As

Publication number Publication date
CN110503704A (en) 2019-11-26

Similar Documents

Publication Publication Date Title
CN110503704B (en) Method and device for constructing three-dimensional graph and electronic equipment
CN108961303B (en) Image processing method and device, electronic equipment and computer readable medium
JP7446457B2 (en) Image optimization method and device, computer storage medium, computer program, and electronic equipment
CN109325954B (en) Image segmentation method and device and electronic equipment
JP6636154B2 (en) Face image processing method and apparatus, and storage medium
CN110766639B (en) Image enhancement method and device, mobile equipment and computer readable storage medium
WO2018082185A1 (en) Image processing method and device
JP6136537B2 (en) Image processing apparatus, image processing method, image processing control program, and recording medium
WO2015106700A1 (en) Method and apparatus for implementing image denoising
JP2015225665A (en) Image noise removal method and image noise removal device
CN111161136B (en) Image blurring method, image blurring device, equipment and storage device
CN111325657A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN110415237B (en) Skin flaw detection method, skin flaw detection device, terminal device and readable storage medium
CN112150371B (en) Image noise reduction method, device, equipment and storage medium
WO2017173578A1 (en) Image enhancement method and device
CN116580028B (en) Object surface defect detection method, device, equipment and storage medium
WO2022016326A1 (en) Image processing method, electronic device, and computer-readable medium
WO2020038065A1 (en) Image processing method, terminal, and computer storage medium
CN109214996A (en) A kind of image processing method and device
CN111353955A (en) Image processing method, device, equipment and storage medium
WO2022233252A1 (en) Image processing method and apparatus, and computer device and storage medium
CN110517201B (en) Method and device for smoothing filtering along environment-friendly edge and electronic equipment
CN113744142B (en) Image restoration method, electronic device and storage medium
CN113658197B (en) Image processing method, device, electronic equipment and computer readable storage medium
CN111161299B (en) Image segmentation method, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant