WO2021068729A1 - Image synthesis method and apparatus, electronic device, and computer readable storage medium - Google Patents

Image synthesis method and apparatus, electronic device, and computer readable storage medium Download PDF

Info

Publication number
WO2021068729A1
WO2021068729A1 PCT/CN2020/116292 CN2020116292W WO2021068729A1 WO 2021068729 A1 WO2021068729 A1 WO 2021068729A1 CN 2020116292 W CN2020116292 W CN 2020116292W WO 2021068729 A1 WO2021068729 A1 WO 2021068729A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
value
pixel
historical
original
Prior art date
Application number
PCT/CN2020/116292
Other languages
French (fr)
Chinese (zh)
Inventor
吕烨华
Original Assignee
北京字节跳动网络技术有限公司
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 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2021068729A1 publication Critical patent/WO2021068729A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • 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
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/181Segmentation; Edge detection involving edge growing; involving edge linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Definitions

  • the present disclosure relates to the field of image synthesis, and in particular to an image synthesis method, device, electronic equipment, and computer-readable storage medium.
  • the current video special effects production is generally completed by post-production after recording the video.
  • the displayed special effects are fixed and can only be played until the end according to the pre-time logic; and the threshold of post-production is high, and ordinary users cannot generate it quickly.
  • an embodiment of the present disclosure provides an image synthesis method, including:
  • noise image frame is a grayscale image
  • a composite image is generated according to the original image frame, the historical first image, and the noise image frame.
  • an image synthesis device including:
  • An original image frame obtaining module configured to obtain an original image frame from an image source, wherein the original image frame includes a target object
  • a target object image segmentation module configured to segment the target object image from the original image frame
  • the blur processing module is used to perform blur processing on the target object image to obtain the first image
  • the historical first image acquisition module is configured to acquire the historical first image in the buffer queue, where the historical first image is obtained by processing the original image frame before the original image frame;
  • the first image buffer module is configured to put the first image into the buffer queue
  • a noise image frame acquisition module configured to acquire a noise image frame, where the noise image frame is a grayscale image
  • the synthesis module is used to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
  • an embodiment of the present disclosure provides an electronic device, including: at least one processor; and,
  • a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processing
  • the device can execute any one of the image synthesis methods described in the first aspect.
  • embodiments of the present disclosure provide a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute the aforementioned first aspect Any of the image synthesis methods described above.
  • the present disclosure discloses an image synthesis method, device, electronic equipment, and computer-readable storage medium.
  • the image synthesis method includes: obtaining an original image frame from an image source, wherein the original image frame includes a target object; segmenting the target object image from the original image frame; and blurring the target object image to obtain the first An image; obtain a historical first image in the buffer queue, the historical first image is obtained by processing the original image frame before the original image frame; put the first image in the buffer queue; obtain a noise image Frame, the noise image frame is a grayscale image; a composite image is generated according to the original image frame, the historical first image, and the noise image frame.
  • FIG. 1 is a flowchart of an embodiment of an image synthesis method provided by the present disclosure
  • step S104 in the embodiment of the image synthesis method provided by the present disclosure
  • FIG. 3 is a flow chart of a specific example of step S107 in the embodiment of the image synthesis method provided by the present disclosure
  • step S301 is a flow chart of a specific example of step S301 in the embodiment of the image synthesis method provided by the present disclosure
  • FIG. 5 is a flow chart of a specific example of step S402 in the embodiment of the image synthesis method provided by the present disclosure
  • step S302 is a flow chart of a specific example of step S302 in the embodiment of the image synthesis method provided by the present disclosure
  • FIG. 7 is a flowchart of another specific example of step S302 in the embodiment of the image synthesis method provided by the present disclosure
  • FIG. 8 is a schematic structural diagram of an embodiment of an image synthesis device provided by an embodiment of the disclosure.
  • Fig. 9 is a schematic structural diagram of an electronic device provided according to an embodiment of the present disclosure.
  • FIG. 1 is a flowchart of an embodiment of an image synthesis method provided by an embodiment of the disclosure.
  • the image synthesis method provided in this embodiment may be executed by an image synthesis device, and the image synthesis device may be implemented as software, or as software and With a combination of hardware, the image synthesis device can be integrated in a certain device in the image synthesis system, such as an image synthesis server or an image synthesis terminal device. As shown in Figure 1, the method includes the following steps:
  • Step S101 Obtain an original image frame from an image source
  • the original image frame includes a target object, where the target object is a preset object to be detected, such as a portrait of a person, an animal, and the like.
  • the original image frame is the current image frame of the original image obtained from the image source
  • the current image frame is the image frame played by the original image at the current moment.
  • the original image frame is an image frame received from an image sensor.
  • the image sensor refers to various devices that can collect images, and typical image sensors are video cameras, cameras, cameras, and so on.
  • the image sensor may be a camera on a terminal device, such as a front or rear camera on a smart phone, and the image collected by the camera may be directly displayed on the display screen of the mobile phone.
  • the original image frame is an image frame that receives a video image from a memory
  • the video image is a pre-recorded video and is stored in the memory.
  • the storage is a local storage or a network storage.
  • the acquisition of the original image frame is one of the multiple frames in the original image, and specifically refers to the image frame being played at the current moment.
  • the image frames are played at a certain speed to form the original image. Typically, 30 image frames per second are played.
  • the image frame is replaced every 33 milliseconds, such as 0 seconds at the beginning of the playback.
  • the original image frame is the first frame of the entire original image, and when the first second is played, the original image frame is the 31st frame of the entire original image, and so on.
  • the frame rate (the number of frames played per second) of the original image can be any value, and the above examples are merely examples and do not constitute any limitation to the present disclosure.
  • Step S102 segmenting a target object image from the original image frame
  • the target object may be any preset object that needs to be recognized from the original image, and the typical target object may be a portrait.
  • Any target recognition algorithm can be used to recognize the target object in the original image.
  • the neural network can be trained using images with portraits, and the trained neural network can be used to perform training on the first image frame in the acquired video image.
  • a portrait detection algorithm is used to detect the key points of the portrait to determine the outline of the portrait; or it can be used to mark people
  • the neural network is trained on the image of the outer frame, and the trained neural network is used to perform the regression of the outer frame on each image frame in the video image to reduce the scope of the portrait, and then use the portrait detection algorithm to detect the key points of the portrait To determine the contour of the portrait; or use the image marked with the key points of the portrait to train the neural network, and use the trained neural network to perform portrait key point regression on each image frame in the video image to determine the image frame Whether a portrait is included and the outline of the portrait is determined according to the key points.
  • the above-mentioned portraits and recognition methods are only examples, and do not constitute a limitation to the present disclosure.
  • the target object and a suitable recognition algorithm for the target object can be pre-selected according to the effect to be achieved and the scene.
  • the target object is segmented from the original image frame to generate a target object image. While judging whether the target object is included in the original image frame, it will be determined whether the original image frame contains certain features of the target object. Based on these features, the outline of the target object can be determined so as to The target object is segmented from the first image frame.
  • the above identification and segmentation can also be the same step, typically using a trained convolutional neural network to classify each pixel in the first image frame to determine whether it is a pixel in the portrait , When all the pixels are classified, if the first image frame includes a portrait, the image of the portrait has also been segmented.
  • Step S103 performing blur processing on the target object image to obtain a first image
  • the blurring processing is Gaussian blurring processing. After blurring the target object image, a first image is obtained. The edges of the target object in the first image may be affected by the blurring processing. The cause spreads outward, producing a divergent effect.
  • said performing blur processing on the target object image to obtain the first image includes:
  • Gaussian blurring is performed on the target object image according to the blurring parameter to obtain a first image.
  • the blur parameter determines the degree of Gaussian blur processing.
  • the blur parameter is a blur radius and/or a weight matrix.
  • the fuzzy parameters can be acquired through a configuration file or through a human-computer interaction interface, which will not be repeated here.
  • said performing blur processing on the target object image to obtain the first image includes:
  • the target object is a portrait
  • the size attribute is the width or height of the circumscribing frame of the face in the face.
  • a and b are preset constant values, where a ⁇ 0, b ⁇ 0, and b>a; facewidthmin and facewidthmax are preset constant values, facewidth is the size attribute of the target object, and facewidth ⁇ facewidthmin .
  • the range parameter Scale when performing blur processing, regardless of the processing method, multiply the range parameter in the calculation. Since the range parameter is related to the size of the target object, the blur can be controlled by the size of the target object. The range in turn controls the effect range of the final composite image.
  • the blur processing in the present disclosure may also be other blur processing, whose purpose is to produce a divergent effect of the target object image.
  • the above-mentioned Gaussian blur is only an example and does not constitute a limitation of the present disclosure.
  • Step S104 Obtain the first historical image in the cache queue
  • a buffer queue is preset to store the first image obtained from the historical original image frame.
  • the original image frame before the current time has been obtained before the original image frame at the current time is obtained, and the same After the processing of step S103, the corresponding first images are obtained. These images become historical first images in the present disclosure.
  • the size of the cache queue determines the number of historical first images. The typical length of the cache queue is 6, then The buffer queue buffers the first images corresponding to the original image frames at 6 moments before the current moment, that is, 6 historical first images.
  • the historical first image is the result of processing the image in the cache queue.
  • the obtaining the historical first image in the cache queue includes:
  • Step S201 Obtain multiple original historical first images in the cache queue
  • Step S202 Obtain the transparency coefficients of the multiple original historical first images
  • Step S203 Multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency
  • Step S204 calculating the maximum adjustment transparency of the plurality of adjustment transparency
  • Step S205 Generate the historical first image according to the maximum adjusted transparency.
  • the length of the cache queue is set to 6.
  • six original historical first images in the cache queue are acquired.
  • the original historical first image is before the current moment.
  • the transparency coefficients are based on the time sequence of the cache.
  • the original historical first images at the 6 buffer positions in the queue are buffer1, buffer2, buffer3, buffer4, buffer5, and buffer6, among which the time of buffer6 is the earliest, and the time of buffer1 is the latest, and the corresponding transparency coefficients are 1, 0.8, 0.6, 0.4, 0.2, 0,
  • the transparency can be adjusted by multiplying the transparency of the original historical first image by the transparency coefficient buffer1.a*1, buffer2.a*0.8, buffer3.a*0.6, buffer4.a*0.4, buffer5 .a*0.2, buffer6.a*0, where buffer1.a represents the transparency of the original historical first image at the first buffer location, and so on.
  • a.max max(buffer1.a*1,buffer2.a*0.8,buffer3.a*0.6,buffer4.a*0.4,buffer5.a*0.2,buffer6. a*0), using the maximum adjusted transparency of each pixel on the original historical first image as the transparency of the historical first image to generate the historical first image.
  • the multiple original historical first images are mixed to obtain a mixed image of the historical first image, and then the transparency of each pixel in the mixed image is set to the maximum adjusted transparency of the pixel to generate The first image.
  • Step S105 Put the first image into the buffer queue
  • the first image at the current moment is put into the buffer queue.
  • the putting the first image into the cache queue includes: sequentially moving the historical first images in the cache queue one position forward; putting the first image into the cache The end of the queue.
  • the cache queue includes a plurality of cache locations, and the historical first image is stored in the queue according to the sequence of original image frames (ie, time sequence), and when the multiple cache locations of the cache are all full, The historical first image at the head position in the queue is deleted, the historical first image at the second position in the queue is taken as the head of the queue, and the historical first images at other positions are moved forward one by one, and The first image at the current moment is stored at the end of the queue as the first historical image of the next original image frame.
  • Step S106 obtaining a noise image frame
  • the noise image frame is a grayscale image.
  • the noise image frame is from a noise image
  • the noise image is a sequence of noise image frames, which can be played simultaneously with the playback of the original image, but its frame rate can be different from the original image.
  • the values of the pixels on the noise image are random values. Therefore, when the noise image frame changes, the final composite image will change accordingly, resulting in dynamic effects.
  • Step S107 Generate a composite image according to the original image frame, the first historical image, and the noise image frame.
  • the original image frame, the historical first image, and the noise image are mixed according to a predetermined rule to generate a composite image. Since the historical first image is one or more images generated from the image of the target object before the current moment, when the target object moves, an effect similar to ghost follow will be produced.
  • the generating a composite image according to the original image frame, the historical first image, and the noise image frame includes:
  • Step S301 Multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
  • Step S302 Perform first processing on the second image to obtain a third image
  • Step S303 Generate a composite image according to the second image, the third image, and the original image frame.
  • step S301 the value of the pixel in the noise image frame is multiplied by the value of the pixel at the position corresponding to the position of the pixel in the historical first image to obtain the value of the pixel in the second image, where The value of the pixel is a binarized value, even if the pixel value is normalized from [0,255] to [0,1].
  • the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain the second image includes:
  • Step S401 Multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
  • Step S402 Multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain a second image.
  • the contrast coefficient and the image offset value in step S401 are preset parameters, and the purpose of which is to improve the pixel contrast of the first historical image.
  • the value of the pixel in the sound image frame is multiplied by the value of the pixel in the historical first adjusted image obtained after adjustment to obtain a second image.
  • the second image thus obtained has a higher brightness than the second image that has not been processed by the above steps, making the second image more eye-catching. It is understandable that the pixel value in the historical first adjusted image is limited to [0,1]. If the pixel value of the historical first image is multiplied by the contrast coefficient and the image offset value is added to obtain If the pixel value is less than 0 or greater than 1, set its value to 0 or 1.
  • the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image includes:
  • Step S501 Obtain the contour image of the historical first adjusted image according to the target object image and the historical first adjusted image;
  • Step S502 Multiply the value of the pixel in the noise image frame by the value of the pixel in the contour image to obtain a second image.
  • step S501 the historical first adjusted image is subtracted from the target object image to obtain the contour image of the historical first adjusted image.
  • the contour image only includes the first adjusted historical image. Describe the part of the target object image. Therefore, in step S502, the second image also only includes the result of mixing the noise image frame and the contour image.
  • a first process is further performed on the second image to obtain a third image.
  • the first process may be any process.
  • the first processing is mixing processing, and performing the first processing on the second image to obtain a third image includes:
  • Step S601 If the value of the pixel in the second image is greater than the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter are mixed to obtain a third image The value of the pixel;
  • the first threshold value is 0.8
  • the first color parameter is color1
  • the pixel value in the second image is set as flamemask
  • the pixel value in the original image is origincolor
  • the value of the pixel in the original image is origincolor.
  • the pixel value of is flamecolor
  • the value of flamecolor is calculated according to the following formula:
  • flamecolor origincolor*(1-color1)+flamemask*color1;
  • Step S602 if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the second color parameter are mixed , Get the value of the pixel in the third image;
  • the second threshold is 0.65
  • the second color parameter is color2, where 0 ⁇ color2 ⁇ 1
  • the pixel value in the second image is set as flamemask
  • the pixel value in the original image is origincolor
  • the value of the pixel in the original image is origincolor.
  • the pixel value of is flamecolor
  • the value of flamecolor is calculated according to the following formula:
  • flamecolor origincolor*(1-color2)+flamemask*color2;
  • Step S603 if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the third color parameter are mixed , Get the value of the pixel in the third image;
  • the third threshold is 0.4
  • the third color parameter is color3, where 0 ⁇ color3 ⁇ 1
  • the pixel value in the second image is set as flamemask
  • the pixel value in the original image is origincolor
  • the value of the pixel in the original image is origincolor.
  • the pixel value of is flamecolor
  • the value of flamecolor is calculated according to the following formula:
  • flamecolor origincolor*(1-color3)+flamemask*color3;
  • Step S604 If the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image, and the fourth color parameter are mixed to obtain the third image The value of the pixel.
  • the fourth color parameter is color4, where 0 ⁇ color4 ⁇ 1, set the value of the pixel in the contour image to mattingadjust, the value of the pixel in the original image is origincolor, and the value of the pixel in the third image is flamecolor, then Calculate the value of flamecolor according to the following formula:
  • flamecolor origincolor*(1-color4)+mattingadjust)*0.5*color4;
  • first color parameter, second color parameter, third color parameter, and fourth color parameter may be the same or different, and there is no limitation here.
  • the above judgment and processing are performed on each pixel in the second image to obtain the third image.
  • the step S302 performs first processing on the second image to obtain a third image, which may further include:
  • Step S701 Perform a first sub-processing on the second image to obtain a fourth image
  • Step S702 generating a first transparency coefficient according to the maximum adjusted transparency
  • Step S703 Generate a third image according to the fourth image and the transparency coefficient.
  • the first sub-processing can be any processing.
  • the first sub-processing can be the first processing in step S601-step S604.
  • the fourth image in step S701 is Step S601-The third image obtained in step 04.
  • a first transparency coefficient ttl is generated according to the maximum adjusted transparency obtained in step S204.
  • the first transparency coefficient ttl a.max*2, and 0 ⁇ ttl ⁇ 1.
  • a third image is generated according to the fourth image and the first transparency coefficient, and the value of the pixel in the fourth image is set as flamecolor, and the value of the pixel in the third image is flamecolorgrad.
  • the first image can be calculated according to the following formula. The values of the pixels in the three images:
  • flamecolorgrad flamecolor*vec3*(1-ttl)+flamecolor*ttl
  • vec3 is a three-dimensional vector, wherein the value of each bit in the three-dimensional vector is between [0, 1], for example, vec3 can be (1, 0.8, 0.3).
  • step 303 optionally, the generating a composite image according to the second image, the third image, and the original image frame includes calculating the composite image according to the following formula:
  • flamecolorgrad1 origincolor*(1-flamemask)+flamecolorgrad*flamemask
  • flamecolorgrad1 represents the value of the pixel in the composite image
  • origincolor represents the value of the pixel in the original image frame
  • flamecolorgrad represents the value of the pixel in the third image
  • flamemask represents the value of the pixel in the second image.
  • the present disclosure discloses an image synthesis method, device, electronic equipment, and computer-readable storage medium.
  • the image synthesis method includes: obtaining an original image frame from an image source, wherein the original image frame includes a target object; segmenting the target object image from the original image frame; and blurring the target object image to obtain the first An image; obtain a historical first image in the buffer queue, the historical first image is obtained by processing the original image frame before the original image frame; put the first image in the buffer queue; obtain a noise image Frame, the noise image frame is a grayscale image; a composite image is generated according to the original image frame, the historical first image, and the noise image frame.
  • FIG. 8 is a schematic structural diagram of an embodiment of an image synthesis device provided by an embodiment of the disclosure.
  • the device 800 includes: an original image frame acquisition module 801, a target object image segmentation module 802, a blur processing module 803, and a historical image An image acquisition module 804, a first image buffer module 805, a noise image frame acquisition module 806, and a synthesis module 807. among them,
  • the original image frame obtaining module 801 is configured to obtain an original image frame from an image source, wherein the original image frame includes a target object;
  • the target object image segmentation module 802 is configured to segment the target object image from the original image frame
  • the blur processing module 803 is configured to perform blur processing on the target object image to obtain a first image
  • the historical first image obtaining module 804 is configured to obtain the historical first image in the buffer queue, the historical first image being obtained by processing the original image frame before the original image frame;
  • the first image buffer module 805 is configured to put the first image into the buffer queue
  • the noise image frame acquisition module 806 is configured to acquire a noise image frame, where the noise image frame is a grayscale image
  • the synthesis module 807 is configured to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
  • the blur processing module 803 further includes:
  • the fuzzy parameter acquisition module is used to acquire fuzzy parameters
  • the Gaussian blur module is configured to perform Gaussian blur on the target object image according to the blur parameters to obtain a first image.
  • first image cache module 805 further includes:
  • the moving module is used to move the first historical image in the buffer queue one position in turn;
  • the first buffer module is used to put the first image into the end of the buffer queue.
  • the synthesis module 807 further includes:
  • the second image generation module is configured to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
  • the first processing module is configured to perform first processing on the second image to obtain a third image
  • the synthesis sub-module is used to generate a synthesized image according to the second image, the third image and the original image frame.
  • the second image generation module further includes:
  • the historical first adjusted image generating module is configured to multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
  • the first generating module of the second image is used to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image.
  • the first generating module of the second image further includes:
  • a contour image generating module configured to obtain the contour image of the historical first adjustment image according to the target object image and the historical first adjustment image
  • the second image generation module is configured to multiply the value of the pixel in the noise image frame and the value of the pixel in the contour image to obtain the second image.
  • the first processing module further includes:
  • the first processing module is used to mix the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter if the value of the pixel in the second image is greater than the first threshold , Get the value of the pixel in the third image;
  • the first processing second module if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the second The color parameters are mixed to obtain the value of the pixel in the third image;
  • the first processing third module if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the third The color parameters are mixed to obtain the value of the pixel in the third image;
  • the fourth module of the first processing if the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image and the fourth color parameter are mixed to obtain The value of the pixel in the third image.
  • the historical first image acquisition module 804 further includes:
  • the original historical first image acquisition module which is used to acquire multiple original historical first images in the cache queue
  • a transparency coefficient obtaining module configured to obtain the transparency coefficients of the multiple original historical first images
  • An adjusted transparency generating module configured to multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency
  • a maximum adjustment transparency calculation module configured to calculate the maximum adjustment transparency among the plurality of adjustment transparency
  • the historical first image acquisition sub-module is configured to generate the historical first image according to the maximum adjusted transparency.
  • the first processing module further includes:
  • a fourth image generation module configured to perform a first sub-processing on the second image to obtain a fourth image
  • a first transparency coefficient generating module configured to generate a first transparency coefficient according to the maximum adjusted transparency
  • the third image generating module is configured to generate a third image according to the fourth image and the transparency coefficient.
  • the blur processing module 803 further includes:
  • a size attribute obtaining module configured to obtain the size attribute of the target object
  • the blur processing sub-module is used to control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
  • the device shown in Fig. 8 can execute the methods of the embodiments shown in Figs.
  • the implementation process and technical effects of this technical solution please refer to the description in the embodiment shown in FIG. 1 to FIG. 7, which will not be repeated here.
  • Terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc.
  • the electronic device shown in FIG. 9 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
  • the electronic device 900 may include a processing device (such as a central processing unit, a graphics processor, etc.) 901, which may be loaded into a random access device according to a program stored in a read-only memory (ROM) 902 or from a storage device 906.
  • the program in the memory (RAM) 903 executes various appropriate actions and processing.
  • various programs and data required for the operation of the electronic device 900 are also stored.
  • the processing device 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904.
  • An input/output (I/O) interface 905 is also connected to the bus 904.
  • the following devices can be connected to the I/O interface 905: including input devices 906 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; including, for example, liquid crystal displays (LCD), speakers, vibration An output device 907 such as a device; a storage device 906 such as a magnetic tape, a hard disk, etc.; and a communication device 909.
  • the communication device 909 may allow the electronic device 900 to perform wireless or wired communication with other devices to exchange data.
  • FIG. 9 shows an electronic device 900 having various devices, it should be understood that it is not required to implement or have all of the illustrated devices. It may alternatively be implemented or provided with more or fewer devices.
  • the process described above with reference to the flowchart can be implemented as a computer software program.
  • the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, and the computer program contains program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 909, or installed from the storage device 906, or installed from the ROM 902.
  • the processing device 901 the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
  • the aforementioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable removable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
  • the client and server can communicate with any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium.
  • Communication e.g., communication network
  • Examples of communication networks include local area networks (“LAN”), wide area networks (“WAN”), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future research and development network of.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
  • the above-mentioned computer-readable medium carries one or more programs.
  • the electronic device obtains an original image frame from an image source, wherein the original image frame includes a target object Segment the target object image from the original image frame; perform blur processing on the target object image to obtain the first image; obtain the historical first image in the buffer queue, the historical first image from the original image frame The previous original image frame is processed; the first image is put into the buffer queue; the noise image frame is obtained, and the noise image frame is a grayscale image; according to the original image frame, the historical first image, and the noise The image frame generates a composite image.
  • the computer program code used to perform the operations of the present disclosure can be written in one or more programming languages or a combination thereof.
  • the above-mentioned programming languages include but are not limited to object-oriented programming languages such as Java, Smalltalk, C++, and Including conventional procedural programming languages-such as "C" language or similar programming languages.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
  • LAN local area network
  • WAN wide area network
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions.
  • the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the units involved in the embodiments described in the present disclosure can be implemented in software or hardware. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
  • exemplary types of hardware logic components include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logical device (CPLD) and so on.
  • FPGA Field Programmable Gate Array
  • ASIC Application Specific Integrated Circuit
  • ASSP Application Specific Standard Product
  • SOC System on Chip
  • CPLD Complex Programmable Logical device
  • a machine-readable medium may be a tangible medium, which may contain or store a program for use by the instruction execution system, apparatus, or device or in combination with the instruction execution system, apparatus, or device.
  • the machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • the machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing.
  • machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • RAM random access memory
  • ROM read-only memory
  • EPROM or flash memory erasable programmable read-only memory
  • CD-ROM compact disk read only memory
  • magnetic storage device or any suitable combination of the foregoing.
  • an image synthesis method including:
  • an original image frame from an image source wherein the original image frame includes a target object; segment the target object image from the original image frame; perform blur processing on the target object image to obtain the first image; obtain the buffer queue
  • the historical first image the historical first image is obtained by processing the original image frame before the original image frame; the first image is put into the buffer queue; the noise image frame is acquired, the noise image frame It is a grayscale image; a composite image is generated according to the original image frame, the first historical image, and the noise image frame.
  • the performing blur processing on the target object image to obtain the first image includes:
  • the putting the first image into the cache queue includes: sequentially moving the historical first images in the cache queue one position forward; putting the first image into the cache queue The end of the team.
  • the generating a composite image according to the original image frame, the historical first image, and the noise image frame includes: multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain A second image; the second image is subjected to a first processing to obtain a third image; a composite image is generated according to the second image, the third image, and the original image frame.
  • the multiplying the value of the pixel in the noise image frame with the value of the pixel in the historical first image to obtain the second image includes: multiplying the value of the pixel in the historical first image by a contrast coefficient And the image offset value is added to obtain the historical first adjusted image; the value of the pixel in the noise image frame is multiplied by the value of the pixel in the historical first adjusted image to obtain the second image.
  • the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image includes: obtaining the historical image according to the target object image and the historical first adjusted image The contour image of the first adjustment image; the second image is obtained by multiplying the value of the pixel in the noise image frame by the value of the pixel in the contour image.
  • the first processing of the second image to obtain the third image includes: if the value of the pixel in the second image is greater than the first threshold, then the value of the pixel in the second image is compared with the original The value of the pixel in the image is mixed with the first color parameter to obtain the value of the pixel in the third image; if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the second The value of the pixel in the image, the value of the pixel in the original image, and the second color parameter are mixed to obtain the value of the pixel in the third image; if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second Threshold, the pixel value in the second image, the pixel value in the original image, and the third color parameter are mixed to obtain the value of the pixel in the third image; if the value of the pixel in the second image is less than If it is equal to the third threshold, the pixel value in the contour image,
  • the obtaining the first historical image in the cache queue includes: obtaining a plurality of original historical first images in the cache queue; obtaining the transparency coefficients of the plurality of original historical first images; The transparency of the historical first image is respectively multiplied by the corresponding transparency coefficient to obtain multiple adjusted transparency; the maximum adjusted transparency of the multiple adjusted transparency is calculated; and the historical first image is generated according to the maximum adjusted transparency.
  • the performing the first processing on the second image to obtain the third image includes: performing the first sub-processing on the second image to obtain a fourth image; and generating a first transparency coefficient according to the maximum adjusted transparency ; Generate a third image according to the fourth image and the transparency coefficient.
  • the performing blur processing on the target object image to obtain the first image includes: obtaining the size attribute of the target object; and controlling the processing range of the blur processing according to the size attribute to perform blur processing on the target object image Get the first image.
  • an image synthesis device including:
  • An original image frame obtaining module configured to obtain an original image frame from an image source, wherein the original image frame includes a target object
  • a target object image segmentation module configured to segment the target object image from the original image frame
  • the blur processing module is used to perform blur processing on the target object image to obtain the first image
  • the historical first image acquisition module is configured to acquire the historical first image in the buffer queue, where the historical first image is obtained by processing the original image frame before the original image frame;
  • the first image buffer module is configured to put the first image into the buffer queue
  • a noise image frame acquisition module configured to acquire a noise image frame, where the noise image frame is a grayscale image
  • the synthesis module is used to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
  • the blur processing module further includes:
  • the fuzzy parameter acquisition module is used to acquire fuzzy parameters
  • the Gaussian blur module is configured to perform Gaussian blur on the target object image according to the blur parameters to obtain a first image.
  • the first image cache module further includes:
  • the moving module is used to move the first historical image in the buffer queue one position in turn;
  • the first buffer module is used to put the first image into the end of the buffer queue.
  • the synthesis module further includes:
  • the second image generation module is configured to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
  • the first processing module is configured to perform first processing on the second image to obtain a third image
  • the synthesis sub-module is used to generate a synthesized image according to the second image, the third image and the original image frame.
  • the second image generation module further includes:
  • the historical first adjusted image generating module is configured to multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
  • the first generating module of the second image is used to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image.
  • the first generating module of the second image further includes:
  • a contour image generating module configured to obtain the contour image of the historical first adjustment image according to the target object image and the historical first adjustment image
  • the second image generation module is configured to multiply the value of the pixel in the noise image frame and the value of the pixel in the contour image to obtain the second image.
  • the first processing module further includes:
  • the first processing module is used to mix the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter if the value of the pixel in the second image is greater than the first threshold , Get the value of the pixel in the third image;
  • the first processing second module if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the second The color parameters are mixed to obtain the value of the pixel in the third image;
  • the first processing third module if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the third The color parameters are mixed to obtain the value of the pixel in the third image;
  • the fourth module of the first processing if the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image and the fourth color parameter are mixed to obtain The value of the pixel in the third image.
  • the historical first image acquisition module further includes:
  • the original historical first image acquisition module which is used to acquire multiple original historical first images in the cache queue
  • a transparency coefficient obtaining module configured to obtain the transparency coefficients of the multiple original historical first images
  • An adjusted transparency generating module configured to multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency
  • a maximum adjustment transparency calculation module configured to calculate the maximum adjustment transparency among the plurality of adjustment transparency
  • the historical first image acquisition sub-module is configured to generate the historical first image according to the maximum adjusted transparency.
  • the first processing module further includes:
  • a fourth image generation module configured to perform a first sub-processing on the second image to obtain a fourth image
  • a first transparency coefficient generating module configured to generate a first transparency coefficient according to the maximum adjusted transparency
  • the third image generating module is configured to generate a third image according to the fourth image and the transparency coefficient.
  • the blur processing module further includes:
  • a size attribute obtaining module configured to obtain the size attribute of the target object
  • the blur processing sub-module is used to control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
  • an electronic device including: at least one processor; and,
  • a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processing
  • the device can perform any of the aforementioned image synthesis methods.
  • non-transitory computer-readable storage medium characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute any of the foregoing The image synthesis method.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

Disclosed are an image synthesis method and apparatus, an electronic device, and a computer readable storage medium. The image synthesis method comprises: acquiring an original image frame from an image, the original image frame comprising a target object; segmenting a target object image from the original image frame; performing blurring processing on the target object image to obtain a first image; acquiring a historical first image from a cache queue, the historical first image being obtained by processing an original image frame prior to the original image frame; placing the first image in the cache queue; acquiring a noisy image frame, the noisy image frame being a greyscale image; and, on the basis of the original image frame, the historical first image, and the noisy image frame, generating a synthesised image. The present method solves the technical problem in the prior art of being unable to simply and quickly generate video effects.

Description

图像合成方法、装置、电子设备及计算机可读存储介质Image synthesis method, device, electronic equipment and computer readable storage medium
相关申请的交叉引用Cross-references to related applications
本申请要求于2019年10月10日提交的,申请号为201910959995.7、发明名称为“图像合成方法、装置、电子设备及计算机可读存储介质”的中国专利申请的优先权,该申请的全文通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed on October 10, 2019 with the application number 201910959995.7 and the invention title "Image synthesis method, device, electronic equipment and computer readable storage medium". The full text of the application is approved The reference is incorporated in this application.
技术领域Technical field
本公开涉及图像合成领域,尤其涉及一种图像合成方法、装置、电子设备及计算机可读存储介质。The present disclosure relates to the field of image synthesis, and in particular to an image synthesis method, device, electronic equipment, and computer-readable storage medium.
背景技术Background technique
随着计算机网络的发展,和智能手机的普及,普通的用户已经不能满足于仅仅利用单调的图片和文字来表达自己的情感。视频以呈现出更为丰富多样的内容和形式及带来的直观感受深受用户的喜爱,并且逐渐流行开来,普通用户制作原创视频逐渐成为一个趋势。但是另外一方面是原创自拍类视频表现形式平淡无味,与此同时,我们可以看到视频特效在影视作品中的运用越来越丰富,在内容表现形式方面 也更加的多样化,可以说视频持效是一个成功的影视作品的支撑和保障。With the development of computer networks and the popularization of smart phones, ordinary users can no longer be satisfied with just using monotonous pictures and words to express their emotions. Video is deeply loved by users for presenting more abundant and diverse content and forms and the intuitive feelings it brings, and it is gradually becoming popular. It is gradually becoming a trend for ordinary users to make original videos. But on the other hand, the original self-portrait video expression is plain and tasteless. At the same time, we can see that the use of video special effects in film and television works is becoming more and more abundant, and the form of content expression is also more diversified. It can be said that video persistence Effectiveness is the support and guarantee of a successful film and television work.
然而现在的视频特效制作一般是先录制视频之后通过后期制作完成,所显示出来特效是固定的,只能按照预先的时间逻辑播放直至结束;并且后期制作的门槛较高,普通用户无法快速的生成一个特效或制作复杂一些的特效。因此,如何简单快速的生成视频效果成为亟待解决的技术问题。However, the current video special effects production is generally completed by post-production after recording the video. The displayed special effects are fixed and can only be played until the end according to the pre-time logic; and the threshold of post-production is high, and ordinary users cannot generate it quickly. A special effect or a more complex special effect. Therefore, how to generate video effects simply and quickly becomes a technical problem to be solved urgently.
发明内容Summary of the invention
提供该发明内容部分以便以简要的形式介绍构思,这些构思将在后面的具体实施方式部分被详细描述。该发明内容部分并不旨在标识要求保护的技术方案的关键特征或必要特征,也不旨在用于限制所要求的保护的技术方案的范围。The content of the invention is provided to introduce concepts in a brief form, and these concepts will be described in detail in the following specific embodiments. The content of the invention is not intended to identify the key features or essential features of the technical solution required to be protected, nor is it intended to be used to limit the scope of the technical solution required to be protected.
第一方面,本公开实施例提供一种图像合成方法,包括:In the first aspect, an embodiment of the present disclosure provides an image synthesis method, including:
从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;Obtaining an original image frame from an image source, wherein the original image frame includes a target object;
从所述原始图像帧中分割出目标对象图像;Segmenting the target object image from the original image frame;
对所述目标对象图像做模糊处理得到第一图像;Performing blur processing on the target object image to obtain a first image;
获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;Acquiring a historical first image in the buffer queue, where the historical first image is obtained by processing an original image frame before the original image frame;
将所述第一图像放入所述缓存队列中;Putting the first image in the buffer queue;
获取噪声图像帧,所述噪声图像帧为灰度图像;Acquiring a noise image frame, where the noise image frame is a grayscale image;
根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。A composite image is generated according to the original image frame, the historical first image, and the noise image frame.
第二方面,本公开实施例提供一种图像合成装置,包括:In a second aspect, an embodiment of the present disclosure provides an image synthesis device, including:
原始图像帧获取模块,用于从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;An original image frame obtaining module, configured to obtain an original image frame from an image source, wherein the original image frame includes a target object;
目标对象图像分割模块,用于从所述原始图像帧中分割出所述目标对象图像;A target object image segmentation module, configured to segment the target object image from the original image frame;
模糊处理模块,用于对所述目标对象图像做模糊处理得到第一图像;The blur processing module is used to perform blur processing on the target object image to obtain the first image;
历史第一图像获取模块,用于获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;The historical first image acquisition module is configured to acquire the historical first image in the buffer queue, where the historical first image is obtained by processing the original image frame before the original image frame;
第一图像缓存模块,用于将所述第一图像放入所述缓存队列中;The first image buffer module is configured to put the first image into the buffer queue;
噪声图像帧获取模块,用于获取噪声图像帧,所述噪声图像帧为灰度图像;A noise image frame acquisition module, configured to acquire a noise image frame, where the noise image frame is a grayscale image;
合成模块,用于根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。The synthesis module is used to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
第三方面,本公开实施例提供一种电子设备,包括:至少一个处理器;以及,In a third aspect, an embodiment of the present disclosure provides an electronic device, including: at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有能被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行前述第一方面中的任一所述图像合成方法。A memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processing The device can execute any one of the image synthesis methods described in the first aspect.
第四方面,本公开实施例提供一种非暂态计算机可读存储介质, 其特征在于,该非暂态计算机可读存储介质存储计算机指令,该计算机指令用于使计算机执行前述第一方面中的任一所述图像合成方法。In a fourth aspect, embodiments of the present disclosure provide a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute the aforementioned first aspect Any of the image synthesis methods described above.
本公开公开了一种图像合成方法、装置、电子设备和计算机可读存储介质。其中该图像合成方法包括:从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;从所述原始图像帧中分割出目标对象图像;对所述目标对象图像做模糊处理得到第一图像;获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;将所述第一图像放入所述缓存队列中;获取噪声图像帧,所述噪声图像帧为灰度图像;根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。通过上述方法,解决了现有技术中无法简单快速的生成视频效果的技术问题。The present disclosure discloses an image synthesis method, device, electronic equipment, and computer-readable storage medium. The image synthesis method includes: obtaining an original image frame from an image source, wherein the original image frame includes a target object; segmenting the target object image from the original image frame; and blurring the target object image to obtain the first An image; obtain a historical first image in the buffer queue, the historical first image is obtained by processing the original image frame before the original image frame; put the first image in the buffer queue; obtain a noise image Frame, the noise image frame is a grayscale image; a composite image is generated according to the original image frame, the historical first image, and the noise image frame. Through the above method, the technical problem that the video effect cannot be generated simply and quickly in the prior art is solved.
上述说明仅是本公开技术方案的概述,为了能更清楚了解本公开的技术手段,而可依照说明书的内容予以实施,并且为让本公开的上述和其他目的、特征和优点能够更明显易懂,以下特举较佳实施例,并配合附图,详细说明如下。The above description is only an overview of the technical solutions of the present disclosure. In order to understand the technical means of the present disclosure more clearly, they can be implemented in accordance with the content of the specification, and to make the above and other objectives, features and advantages of the present disclosure more obvious and understandable. In the following, the preferred embodiments are cited in conjunction with the drawings, and the detailed description is as follows.
附图说明Description of the drawings
结合附图并参考以下具体实施方式,本公开各实施例的上述和其他特征、优点及方面将变得更加明显。贯穿附图中,相同或相似的附图标记表示相同或相似的元素。应当理解附图是示意性的,原件和元素不一定按照比例绘制。The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent in conjunction with the accompanying drawings and with reference to the following specific implementations. Throughout the drawings, the same or similar reference signs indicate the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
图1为本公开提供的图像合成方法实施例的流程图;FIG. 1 is a flowchart of an embodiment of an image synthesis method provided by the present disclosure;
图2为本公开提供的图像合成方法实施例中步骤S104的一个具体实例流程图;2 is a flow chart of a specific example of step S104 in the embodiment of the image synthesis method provided by the present disclosure;
图3为本公开提供的图像合成方法实施例中步骤S107的一个具体实例流程图;FIG. 3 is a flow chart of a specific example of step S107 in the embodiment of the image synthesis method provided by the present disclosure;
图4为本公开提供的图像合成方法实施例中步骤S301的一个具体实例流程图;4 is a flow chart of a specific example of step S301 in the embodiment of the image synthesis method provided by the present disclosure;
图5为本公开提供的图像合成方法实施例中步骤S402的一个具体实例流程图;FIG. 5 is a flow chart of a specific example of step S402 in the embodiment of the image synthesis method provided by the present disclosure;
图6为本公开提供的图像合成方法实施例中步骤S302的一个具体实例流程图;6 is a flow chart of a specific example of step S302 in the embodiment of the image synthesis method provided by the present disclosure;
图7为本公开提供的图像合成方法实施例中步骤S302的另一具体实例流程图FIG. 7 is a flowchart of another specific example of step S302 in the embodiment of the image synthesis method provided by the present disclosure
图8为本公开实施例提供的图像合成装置的实施例的结构示意图;FIG. 8 is a schematic structural diagram of an embodiment of an image synthesis device provided by an embodiment of the disclosure;
图9为根据本公开实施例提供的电子设备的结构示意图。Fig. 9 is a schematic structural diagram of an electronic device provided according to an embodiment of the present disclosure.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的实施例。虽然附图中显示了本公开的某些实施例,然而应当理解的是,本公开可以通过各种形 式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本公开。应当理解的是,本公开的附图及实施例仅用于示例性作用,并非用于限制本公开的保护范围。Hereinafter, embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided for Have a more thorough and complete understanding of this disclosure. It should be understood that the drawings and embodiments of the present disclosure are only used for exemplary purposes, and are not used to limit the protection scope of the present disclosure.
应当理解,本公开的方法实施方式中记载的各个步骤可以按照不同的顺序执行,和/或并行执行。此外,方法实施方式可以包括附加的步骤和/或省略执行示出的步骤。本公开的范围在此方面不受限制。It should be understood that the steps recorded in the method embodiments of the present disclosure may be executed in a different order, and/or executed in parallel. In addition, method implementations may include additional steps and/or omit to perform the illustrated steps. The scope of the present disclosure is not limited in this respect.
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。The term "including" and its variations as used herein are open-ended includes, that is, "including but not limited to". The term "based on" is "based at least in part on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments." Related definitions of other terms will be given in the following description.
需要注意,本公开中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。It should be noted that the concepts of “first” and “second” mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units. Or interdependence.
需要注意,本公开中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modifications of “a” and “a plurality of” mentioned in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as “one or Multiple".
本公开实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
图1为本公开实施例提供的图像合成方法实施例的流程图,本实施例提供的该图像合成方法可以由一图像合成装置来执行,该图像合成装置可以实现为软件,或者实现为软件和硬件的组合,该图像合成装置可以集成设置在图像合成系统中的某设备中,比如图像合成服务器或者图像合成终端设备中。如图1所示,该方法包括如下步骤:FIG. 1 is a flowchart of an embodiment of an image synthesis method provided by an embodiment of the disclosure. The image synthesis method provided in this embodiment may be executed by an image synthesis device, and the image synthesis device may be implemented as software, or as software and With a combination of hardware, the image synthesis device can be integrated in a certain device in the image synthesis system, such as an image synthesis server or an image synthesis terminal device. As shown in Figure 1, the method includes the following steps:
步骤S101,从图像源获取原始图像帧;Step S101: Obtain an original image frame from an image source;
在本公开中,所述原始图像帧中包括目标对象,其中所述目标对象为预先设置的待检测的对象,典型的如人像、动物等等。In the present disclosure, the original image frame includes a target object, where the target object is a preset object to be detected, such as a portrait of a person, an animal, and the like.
在本公开中所述原始图像帧为从所述图像源获取到的原始图像的当前图像帧,所述的当前图像帧为当前时刻所所述原始图像所播放的图像帧。In the present disclosure, the original image frame is the current image frame of the original image obtained from the image source, and the current image frame is the image frame played by the original image at the current moment.
可选的,在该步骤中,所述原始图像帧为从图像传感器接收的图像帧。所述图像传感器指可以采集图像的各种设备,典型的图像传感器为摄像机、摄像头、相机等。在该实施例中,所述图像传感器可以是终端设备上的摄像头,比如智能手机上的前置或者后置摄像头,摄像头采集的图像可以直接显示在手机的显示屏上。Optionally, in this step, the original image frame is an image frame received from an image sensor. The image sensor refers to various devices that can collect images, and typical image sensors are video cameras, cameras, cameras, and so on. In this embodiment, the image sensor may be a camera on a terminal device, such as a front or rear camera on a smart phone, and the image collected by the camera may be directly displayed on the display screen of the mobile phone.
可选的,在该步骤中,所述原始图像帧为从存储器中接收视频图像的图像帧,所述视频图像为事先录制完成的视频,并被保存在所述存储器中。可选的,所述存储器为本地存储器或者网络存储器。在该步骤之前,接收从存储器中发送来的视频图像,并显示在设备的显示装置。Optionally, in this step, the original image frame is an image frame that receives a video image from a memory, and the video image is a pre-recorded video and is stored in the memory. Optionally, the storage is a local storage or a network storage. Before this step, the video image sent from the memory is received and displayed on the display device of the device.
在该步骤中,所述获取原始图像帧,为原始图像中的多个帧中的其中一帧,且特指当前时刻正在播放的图像帧。图像帧按照一定的速度播放以形成所述原始图像,典型的每秒播放30帧图像帧,当开始播放所述原始图像帧时,每33毫秒更换一次图像帧,如刚开始播放的0秒,所述原始图像帧是整个原始图像的第一帧,而播放到第1秒时,所述原始图像帧是整个原始图像的第31帧,以此类推。可以理解的,所述原始图像的帧率(每秒所播放的帧数)可以是任意值,上述实例仅仅是举例,不对本公开构成任何限制。In this step, the acquisition of the original image frame is one of the multiple frames in the original image, and specifically refers to the image frame being played at the current moment. The image frames are played at a certain speed to form the original image. Typically, 30 image frames per second are played. When the original image frame starts to be played, the image frame is replaced every 33 milliseconds, such as 0 seconds at the beginning of the playback. The original image frame is the first frame of the entire original image, and when the first second is played, the original image frame is the 31st frame of the entire original image, and so on. It can be understood that the frame rate (the number of frames played per second) of the original image can be any value, and the above examples are merely examples and do not constitute any limitation to the present disclosure.
步骤S102,从所述原始图像帧中分割出目标对象图像;Step S102, segmenting a target object image from the original image frame;
其中所述目标对象可以是任何预先设置的需要从所述原始图像中识别出来的对象,典型的目标对象可以是人像。The target object may be any preset object that needs to be recognized from the original image, and the typical target object may be a portrait.
识别原始图像中的目标对象可以使用任何目标识别算法。典型的如基于深度学习的,所述目标对象为人像,则可以使用带有人像的图像对神经网络进行训练,使用训练好的神经网络对所述获取到的视频图像中的第一图像帧进行分类以确定所述第一图像帧中是否包含人像,当判断所述第一图像帧中包含人像时,再使用人像检测算法检测人像的关键点以将人像的轮廓确定出来;或者可以使用标记有人像外接框的图像对神经网络进行训练,使用训练好的神经网络对所述视频图像中的每个图像帧进行外接框的回归以缩小人像的范围,之后再使用人像检测算法检测人像的关键点以将人像的轮廓确定出来;或者使用标记有人像关键点的图像对神经网络进行训练,使用训练好的神经 网络对所述视频图像中的每个图像帧进行人像关键点回归以确定图像帧中是否包含人像并根据所述关键点确定出人像的轮廓。Any target recognition algorithm can be used to recognize the target object in the original image. Typically, based on deep learning, if the target object is a portrait, the neural network can be trained using images with portraits, and the trained neural network can be used to perform training on the first image frame in the acquired video image. Classification to determine whether the first image frame contains a portrait, when it is determined that the first image frame contains a portrait, a portrait detection algorithm is used to detect the key points of the portrait to determine the outline of the portrait; or it can be used to mark people The neural network is trained on the image of the outer frame, and the trained neural network is used to perform the regression of the outer frame on each image frame in the video image to reduce the scope of the portrait, and then use the portrait detection algorithm to detect the key points of the portrait To determine the contour of the portrait; or use the image marked with the key points of the portrait to train the neural network, and use the trained neural network to perform portrait key point regression on each image frame in the video image to determine the image frame Whether a portrait is included and the outline of the portrait is determined according to the key points.
可以理解的是,上述人像以及识别方法仅仅是举例,不构成对本公开的限制,实际上可以根据要实现的效果以及场景预先选择目标对象以及针对所述目标对象的合适的识别算法。It is understandable that the above-mentioned portraits and recognition methods are only examples, and do not constitute a limitation to the present disclosure. In fact, the target object and a suitable recognition algorithm for the target object can be pre-selected according to the effect to be achieved and the scene.
在确定所述原始图像帧中包括目标对象之后,将所述目标对象从所述原始图像帧中分割出来,生成目标对象图像。在判断所述原始图像帧中是否包括所述目标对象的同时,会确定所述原始图像帧中是否包含所述目标对象的某些特征,根据这些特征可以确定所述目标对象的轮廓,以便将所述目标对象从所述第一图像帧中分割出来。After determining that the original image frame includes a target object, the target object is segmented from the original image frame to generate a target object image. While judging whether the target object is included in the original image frame, it will be determined whether the original image frame contains certain features of the target object. Based on these features, the outline of the target object can be determined so as to The target object is segmented from the first image frame.
可选的,上述识别和分割也可以是同一个步骤,典型的如利用训练好的卷积神经网络,对第一图像帧中的每个像素点进行分类,判断其是否为人像中的像素点,当所有的像素点都被分类好,如果第一图像帧中包括人像,则人像的图像也已经被分割出来。Optionally, the above identification and segmentation can also be the same step, typically using a trained convolutional neural network to classify each pixel in the first image frame to determine whether it is a pixel in the portrait , When all the pixels are classified, if the first image frame includes a portrait, the image of the portrait has also been segmented.
步骤S103,对所述目标对象图像做模糊处理得到第一图像;Step S103, performing blur processing on the target object image to obtain a first image;
可选的,在本公开中,所述模糊处理为高斯模糊处理,对所述目标对象图像做模糊处理之后,得到第一图像,所述第一图像中的目标对象的边缘会由于模糊处理的原因向外扩散,产生一种发散的效果。Optionally, in the present disclosure, the blurring processing is Gaussian blurring processing. After blurring the target object image, a first image is obtained. The edges of the target object in the first image may be affected by the blurring processing. The cause spreads outward, producing a divergent effect.
可选的,所述对所述目标对象图像做模糊处理得到第一图像,包括:Optionally, said performing blur processing on the target object image to obtain the first image includes:
获取模糊参数;Obtain fuzzy parameters;
根据所述模糊参数对所述目标对象图像进行高斯模糊得到第一图像。Gaussian blurring is performed on the target object image according to the blurring parameter to obtain a first image.
其中,所述模糊参数决定所述高斯模糊处理的程度,典型的,所述模糊参数为模糊半径和/或权重矩阵。其中所述模糊参数可以通过配置文件获取也可以通过人机交互接口获取,在此不再赘述。Wherein, the blur parameter determines the degree of Gaussian blur processing. Typically, the blur parameter is a blur radius and/or a weight matrix. The fuzzy parameters can be acquired through a configuration file or through a human-computer interaction interface, which will not be repeated here.
可选的,所述对所述目标对象图像做模糊处理得到第一图像,包括:Optionally, said performing blur processing on the target object image to obtain the first image includes:
获取所述目标对象的大小属性;Acquiring the size attribute of the target object;
根据所述大小属性控制模糊处理的处理范围对所述目标对象图像做模糊处理得到第一图像。Control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
典型的,所述目标对象为人像,所述大小属性为所述人脸中的人脸外接框的宽度或者高度。所述根据所述大小属性控制模糊处理的处理范围,包括根据以下公式就算处理范围的参数:Typically, the target object is a portrait, and the size attribute is the width or height of the circumscribing frame of the face in the face. The control of the processing range of the fuzzy processing according to the size attribute includes the parameter of the processing range according to the following formula:
Scale=a+(b-a)*(facewidth-facewidthmin)/(facewidthmax-facewidthmin)Scale=a+(b-a)*(facewidth-facewidthmin)/(facewidthmax-facewidthmin)
其中,a,b为预先设置的常数值,其中a≥0,b≥0,且b>a;facewidthmin和facewidthmax为预先设置的常数值,facewidth为所述目标对象的大小属性,且facewidth≥facewidthmin。Where a and b are preset constant values, where a≥0, b≥0, and b>a; facewidthmin and facewidthmax are preset constant values, facewidth is the size attribute of the target object, and facewidth≥facewidthmin .
得到上述范围参数Scale之后,在进行模糊处理时,无论是何种处理方式,在计算时均乘以该范围参数,由于范围参数与目标对象的大小相关,因此可以通过目标对象的大小控制模糊的范围进而控制最终合成图像的效果范围。After obtaining the above range parameter Scale, when performing blur processing, regardless of the processing method, multiply the range parameter in the calculation. Since the range parameter is related to the size of the target object, the blur can be controlled by the size of the target object. The range in turn controls the effect range of the final composite image.
可以理解的是,本公开中的模糊处理还可以是其他模糊处理,其目的在于产生目标对象图像的发散效果,上述高斯模糊仅仅是举例,不构成对本公开的限制。It is understandable that the blur processing in the present disclosure may also be other blur processing, whose purpose is to produce a divergent effect of the target object image. The above-mentioned Gaussian blur is only an example and does not constitute a limitation of the present disclosure.
步骤S104,获取缓存队列中的历史第一图像;Step S104: Obtain the first historical image in the cache queue;
在本公开中,预先设置缓存队列,用于存储由历史原始图像帧得到的第一图像,典型的,在获取当前时刻的原始图像帧之前,已经获取过当前时刻之前的原始图像帧,并同样经过步骤S103的处理得到 了其对应的第一图像,这些图像在本公开中成为历史第一图像,缓存队列的大小决定历史第一图像的多少,典型的所述缓存队列的长度为6,则缓存队列中缓存有当前时刻之前的6个时刻的原始图像帧所对应的第一图像,即6个历史第一图像。In the present disclosure, a buffer queue is preset to store the first image obtained from the historical original image frame. Typically, the original image frame before the current time has been obtained before the original image frame at the current time is obtained, and the same After the processing of step S103, the corresponding first images are obtained. These images become historical first images in the present disclosure. The size of the cache queue determines the number of historical first images. The typical length of the cache queue is 6, then The buffer queue buffers the first images corresponding to the original image frames at 6 moments before the current moment, that is, 6 historical first images.
可选的,所述历史第一图像是对缓存队列中的图像进行处理之后的结果,在此情况下,所述获取缓存队列中的历史第一图像,包括:Optionally, the historical first image is the result of processing the image in the cache queue. In this case, the obtaining the historical first image in the cache queue includes:
步骤S201,获取缓存队列中的多个原始历史第一图像;Step S201: Obtain multiple original historical first images in the cache queue;
步骤S202,获取所述多个原始历史第一图像的透明度系数;Step S202: Obtain the transparency coefficients of the multiple original historical first images;
步骤S203,将所述多个原始历史第一图像的透明度分别和与其对应的透明度系数相乘得到多个调整透明度;Step S203: Multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency;
步骤S204,计算得到所述多个调整透明度中的最大调整透明度;Step S204, calculating the maximum adjustment transparency of the plurality of adjustment transparency;
步骤S205,根据所述最大调整透明度生成所述历史第一图像。Step S205: Generate the historical first image according to the maximum adjusted transparency.
典型的,设所述缓存队列的长度为6,在步骤S201中,获取缓存队列中的6个原始历史第一图像,在该可选实施例中,所述原始历史第一图像为当前时刻之前的原始图像帧所对应的第一图像。获取所述多个原始历史第一图像的透明度系数,典型的,该透明度系数根据缓存的时间先后,时间越早的原始历史第一图像所对应的透明度系数越小,如该实例中,设缓存队列中的6个缓存位置上的原始历史第一图像分别为buffer1、buffer2、buffer3、buffer4、buffer5、buffer6,其中buffer6的时间最早,buffer1的时间最近,其对应的透明度系数分别为1、0.8、0.6、0.4、0.2、0,则可以通过原始历史第一图像的透明度乘以透明度系数得到调整透明度buffer1.a*1、 buffer2.a*0.8、buffer3.a*0.6、buffer4.a*0.4、buffer5.a*0.2、buffer6.a*0,其中buffer1.a表示第一个缓存位置上的原始历史第一图像的透明度,其他以此类推。之后计算这6个调整透明度中的最大调整透明度a.max=max(buffer1.a*1,buffer2.a*0.8,buffer3.a*0.6,buffer4.a*0.4,buffer5.a*0.2,buffer6.a*0),将所述原始历史第一图像上的每个像素点的最大调整透明度作为历史第一图像的透明度生成所述历史第一图像。可选的,将所述多个原始历史第一图像进行混合得到历史第一图像的混合图像,之后将该混合图像中的每个像素点的透明度设置为所述像素点的最大调整透明度,生成第一图像。Typically, the length of the cache queue is set to 6. In step S201, six original historical first images in the cache queue are acquired. In this optional embodiment, the original historical first image is before the current moment. The first image corresponding to the original image frame. Obtain the transparency coefficients of the multiple original historical first images. Typically, the transparency coefficients are based on the time sequence of the cache. The earlier the original historical first image corresponds to the smaller the transparency coefficient, as in this example, the cache The original historical first images at the 6 buffer positions in the queue are buffer1, buffer2, buffer3, buffer4, buffer5, and buffer6, among which the time of buffer6 is the earliest, and the time of buffer1 is the latest, and the corresponding transparency coefficients are 1, 0.8, 0.6, 0.4, 0.2, 0, the transparency can be adjusted by multiplying the transparency of the original historical first image by the transparency coefficient buffer1.a*1, buffer2.a*0.8, buffer3.a*0.6, buffer4.a*0.4, buffer5 .a*0.2, buffer6.a*0, where buffer1.a represents the transparency of the original historical first image at the first buffer location, and so on. Then calculate the maximum adjustment transparency a.max=max(buffer1.a*1,buffer2.a*0.8,buffer3.a*0.6,buffer4.a*0.4,buffer5.a*0.2,buffer6. a*0), using the maximum adjusted transparency of each pixel on the original historical first image as the transparency of the historical first image to generate the historical first image. Optionally, the multiple original historical first images are mixed to obtain a mixed image of the historical first image, and then the transparency of each pixel in the mixed image is set to the maximum adjusted transparency of the pixel to generate The first image.
步骤S105,将所述第一图像放入所述缓存队列中;Step S105: Put the first image into the buffer queue;
在该步骤中,将当前时刻的第一图像放入所述缓存队列中。In this step, the first image at the current moment is put into the buffer queue.
可选的,所述将所述第一图像放入所述缓存队列中,包括:将所述缓存队列中的历史第一图像依次前移一个位置;将所述第一图像放入所述缓存队列的队尾。所述缓存队列包括多个缓存位置,所述历史第一图像按照原始图像帧的先后顺序(即时间顺序)存入所述队列中,当所述缓存的多个缓存位置均被存满时,将所述队列中的头部位置的历史第一图像删除,将队列中第二个位置上的历史第一图像作为队列的头部,其他位置上的历史第一图像依次向前移动,并将当前时刻的第一图像存入队列的尾部,作为下一帧原始图像帧的历史第一图像。Optionally, the putting the first image into the cache queue includes: sequentially moving the historical first images in the cache queue one position forward; putting the first image into the cache The end of the queue. The cache queue includes a plurality of cache locations, and the historical first image is stored in the queue according to the sequence of original image frames (ie, time sequence), and when the multiple cache locations of the cache are all full, The historical first image at the head position in the queue is deleted, the historical first image at the second position in the queue is taken as the head of the queue, and the historical first images at other positions are moved forward one by one, and The first image at the current moment is stored at the end of the queue as the first historical image of the next original image frame.
步骤S106,获取噪声图像帧;Step S106, obtaining a noise image frame;
可选的,所述噪声图像帧为灰度图像。所述噪声图像帧来自噪声图像,所述噪声图像为噪声图像帧序列,其可以随着原始图像的播放而同时播放,但是其帧率可以与原始图像不同,在获取到原始图像帧时,可以获取当前时刻所播放到的噪声图像的图像帧。所述噪声图像 上的像素点的值为随机值,因此当噪声图像帧发生变化时,最终的合成图像中会随之发生变化,产生动态效果。Optionally, the noise image frame is a grayscale image. The noise image frame is from a noise image, and the noise image is a sequence of noise image frames, which can be played simultaneously with the playback of the original image, but its frame rate can be different from the original image. When the original image frame is acquired, Get the image frame of the noise image played at the current moment. The values of the pixels on the noise image are random values. Therefore, when the noise image frame changes, the final composite image will change accordingly, resulting in dynamic effects.
步骤S107,根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。Step S107: Generate a composite image according to the original image frame, the first historical image, and the noise image frame.
在该步骤中,将所述原始图像帧、历史第一图像以及噪声图像按照预定的规则进行混合以生成合成图像。由于历史第一图像为当前时刻之前的目标对象的图像生成的一个或多个图像,因此当目标对象发生移动时,会产生类似重影跟随的效果。In this step, the original image frame, the historical first image, and the noise image are mixed according to a predetermined rule to generate a composite image. Since the historical first image is one or more images generated from the image of the target object before the current moment, when the target object moves, an effect similar to ghost follow will be produced.
可选的,所述根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像,包括:Optionally, the generating a composite image according to the original image frame, the historical first image, and the noise image frame includes:
步骤S301,将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像;Step S301: Multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
步骤S302,将所述第二图像进行第一处理得到第三图像;Step S302: Perform first processing on the second image to obtain a third image;
步骤S303,根据所述第二图像、第三图像以及所述原始图像帧生成合成图像。Step S303: Generate a composite image according to the second image, the third image, and the original image frame.
在步骤S301中,将所述噪声图像帧中的像素的值与所述历史第一图像中的与该像素的位置对应的位置的像素的值相乘得到第二图像中的像素的值,其中所述像素的值为二值化的值,即使说,将所述像素值从[0,255]归一化到[0,1]之间。在一个可选实施例中,所述将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像,包括:In step S301, the value of the pixel in the noise image frame is multiplied by the value of the pixel at the position corresponding to the position of the pixel in the historical first image to obtain the value of the pixel in the second image, where The value of the pixel is a binarized value, even if the pixel value is normalized from [0,255] to [0,1]. In an optional embodiment, the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain the second image includes:
步骤S401,将所述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到历史第一调整图像;Step S401: Multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
步骤S402,将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像。Step S402: Multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain a second image.
其中步骤S401中的对比系数以及图像偏移值为预先设定的参数,其目的在于将所述历史第一图像的像素对比度提高。在步骤S402中,将声图像帧中的像素的值与调整后得到的历史第一调整图像中的像素的值相乘得到第二图像。由此得到的第二图像,比没有经过上述 步骤处理的第二图像的亮度高,使第二图像更加醒目。可以理解的,所述历史第一调整图像中的像素值被限定在[0,1]之间,如果所述述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到的像素值小于0或者大于1,则将其值设定为0或1。The contrast coefficient and the image offset value in step S401 are preset parameters, and the purpose of which is to improve the pixel contrast of the first historical image. In step S402, the value of the pixel in the sound image frame is multiplied by the value of the pixel in the historical first adjusted image obtained after adjustment to obtain a second image. The second image thus obtained has a higher brightness than the second image that has not been processed by the above steps, making the second image more eye-catching. It is understandable that the pixel value in the historical first adjusted image is limited to [0,1]. If the pixel value of the historical first image is multiplied by the contrast coefficient and the image offset value is added to obtain If the pixel value is less than 0 or greater than 1, set its value to 0 or 1.
在所述步骤S402中,可选的,所述将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像,包括:In the step S402, optionally, the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image includes:
步骤S501,根据所述目标对象图像和历史第一调整图像得到历史第一调整图像的轮廓图像;Step S501: Obtain the contour image of the historical first adjusted image according to the target object image and the historical first adjusted image;
步骤S502,将噪声图像帧中的像素的值与所述轮廓图像中的像素的值相乘得到第二图像。Step S502: Multiply the value of the pixel in the noise image frame by the value of the pixel in the contour image to obtain a second image.
可选的,在步骤S501中,将历史第一调整图像减去目标对象图像得到历史第一调整图像的轮廓图像,可以理解的,该轮廓图像只包括所述历史第一调整图像中外扩出所述目标对象图像的部分。由此,在步骤S502中,所述第二图像也只包括了噪声图像帧与轮廓图像的混合结果。Optionally, in step S501, the historical first adjusted image is subtracted from the target object image to obtain the contour image of the historical first adjusted image. It is understandable that the contour image only includes the first adjusted historical image. Describe the part of the target object image. Therefore, in step S502, the second image also only includes the result of mixing the noise image frame and the contour image.
在步骤S302中,对所述第二图像进一步进行第一处理得到第三图像,其中为了实现不同的图像效果,所述第一处理可以为任何处理。可选的,所述第一处理为混合处理,所述将所述第二图像进行第一处理得到第三图像,包括:In step S302, a first process is further performed on the second image to obtain a third image. In order to achieve different image effects, the first process may be any process. Optionally, the first processing is mixing processing, and performing the first processing on the second image to obtain a third image includes:
步骤S601,如果第二图像中的像素的值大于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第一颜色参数进行混合,得到第三图像中的像素的值;Step S601: If the value of the pixel in the second image is greater than the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter are mixed to obtain a third image The value of the pixel;
典型的,所述第一阈值为0.8,第一颜色参数为color1,其中0<color1<1,设第二图像中的像素值为flamemask,原始图像中的像素的值为origincolor,第三图像中的像素的值为flamecolor,则根据以下公式计算flamecolor的值:Typically, the first threshold value is 0.8, the first color parameter is color1, where 0<color1<1, the pixel value in the second image is set as flamemask, the pixel value in the original image is origincolor, and the value of the pixel in the original image is origincolor. The pixel value of is flamecolor, then the value of flamecolor is calculated according to the following formula:
flamecolor=origincolor*(1-color1)+flamemask*color1;flamecolor=origincolor*(1-color1)+flamemask*color1;
步骤S602,如果第二图像中的像素的值大于第二阈值且小于等 于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第二颜色参数进行混合,得到第三图像中的像素的值;Step S602, if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the second color parameter are mixed , Get the value of the pixel in the third image;
典型的,所述第二阈值为0.65,第二颜色参数为color2,其中0<color2<1,设第二图像中的像素值为flamemask,原始图像中的像素的值为origincolor,第三图像中的像素的值为flamecolor,则根据以下公式计算flamecolor的值:Typically, the second threshold is 0.65, the second color parameter is color2, where 0<color2<1, and the pixel value in the second image is set as flamemask, the pixel value in the original image is origincolor, and the value of the pixel in the original image is origincolor. The pixel value of is flamecolor, then the value of flamecolor is calculated according to the following formula:
flamecolor=origincolor*(1-color2)+flamemask*color2;flamecolor=origincolor*(1-color2)+flamemask*color2;
步骤S603,如果第二图像中的像素的值大于第三阈值且小于等于第二阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第三颜色参数进行混合,得到第三图像中的像素的值;Step S603, if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the third color parameter are mixed , Get the value of the pixel in the third image;
典型的,所述第三阈值为0.4,第三颜色参数为color3,其中0<color3<1,设第二图像中的像素值为flamemask,原始图像中的像素的值为origincolor,第三图像中的像素的值为flamecolor,则根据以下公式计算flamecolor的值:Typically, the third threshold is 0.4, and the third color parameter is color3, where 0<color3<1, and the pixel value in the second image is set as flamemask, the pixel value in the original image is origincolor, and the value of the pixel in the original image is origincolor. The pixel value of is flamecolor, then the value of flamecolor is calculated according to the following formula:
flamecolor=origincolor*(1-color3)+flamemask*color3;flamecolor=origincolor*(1-color3)+flamemask*color3;
步骤S604,如果第二图像中的像素的值小于等于第三阈值,则将所述轮廓图像中的像素的值、原始图像中的像素的值和第四颜色参数进行混合,得到第三图像中的像素的值。Step S604: If the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image, and the fourth color parameter are mixed to obtain the third image The value of the pixel.
典型的,第四颜色参数为color4,其中0<color4<1,设轮廓图像中的像素的值为mattingadjust,原始图像中的像素的值为origincolor,第三图像中的像素的值为flamecolor,则根据以下公式计算flamecolor的值:Typically, the fourth color parameter is color4, where 0<color4<1, set the value of the pixel in the contour image to mattingadjust, the value of the pixel in the original image is origincolor, and the value of the pixel in the third image is flamecolor, then Calculate the value of flamecolor according to the following formula:
flamecolor=origincolor*(1-color4)+mattingadjust)*0.5*color4;flamecolor=origincolor*(1-color4)+mattingadjust)*0.5*color4;
可以理解的,上述第一颜色参数、第二颜色参数、第三颜色参数和第四颜色参数可以相同也可以不同,在此不做限制。对第二图像中的每个像素均做以上判断和处理,得到第三图像。It is understandable that the above-mentioned first color parameter, second color parameter, third color parameter, and fourth color parameter may be the same or different, and there is no limitation here. The above judgment and processing are performed on each pixel in the second image to obtain the third image.
可选的,在所述步骤S201-步骤S205之后,所述步骤S302将所述第二图像进行第一处理得到第三图像,还可以包括:Optionally, after the steps S201 to S205, the step S302 performs first processing on the second image to obtain a third image, which may further include:
步骤S701,将所述第二图像进行第一子处理,得到第四图像;Step S701: Perform a first sub-processing on the second image to obtain a fourth image;
步骤S702,根据所述最大调整透明度生成第一透明度系数;Step S702, generating a first transparency coefficient according to the maximum adjusted transparency;
步骤S703,根据所述第四图像以及所述透明度系数生成第三图像。Step S703: Generate a third image according to the fourth image and the transparency coefficient.
在步骤S701中,所述第一子处理可以是任何处理,典型的,所述第一子处理可以是步骤S601-步骤S604中的第一处理,此时该步骤S701中的第四图像即为步骤S601-步骤04中得到的第三图像。在步骤S702中,根据步骤S204中得到的最大调整透明度生成第一透明度系数ttl,典型的,所述第一透明度系数ttl=a.max*2,且0≤ttl≤1。在步骤S703中,根据第四图像以及所述第一透明度系数生成第三图像,设第四图像中的像素的值为flamecolor,第三图像中的像素的值为flamecolorgrad,可以根据以下公式计算第三图像中的像素的值:In step S701, the first sub-processing can be any processing. Typically, the first sub-processing can be the first processing in step S601-step S604. At this time, the fourth image in step S701 is Step S601-The third image obtained in step 04. In step S702, a first transparency coefficient ttl is generated according to the maximum adjusted transparency obtained in step S204. Typically, the first transparency coefficient ttl=a.max*2, and 0≤ttl≤1. In step S703, a third image is generated according to the fourth image and the first transparency coefficient, and the value of the pixel in the fourth image is set as flamecolor, and the value of the pixel in the third image is flamecolorgrad. The first image can be calculated according to the following formula. The values of the pixels in the three images:
flamecolorgrad=flamecolor*vec3*(1-ttl)+flamecolor*ttl,flamecolorgrad=flamecolor*vec3*(1-ttl)+flamecolor*ttl,
其中vec3为一个三维的向量,其中所述三维向量中的每一位的值均在[0,1]之间,如vec3可以为(1,0.8,0.3)。Where vec3 is a three-dimensional vector, wherein the value of each bit in the three-dimensional vector is between [0, 1], for example, vec3 can be (1, 0.8, 0.3).
在步骤303中,可选的,所述根据所述第二图像、第三图像以及所述原始图像帧生成合成图像,包括根据以下公式计算合成图像:In step 303, optionally, the generating a composite image according to the second image, the third image, and the original image frame includes calculating the composite image according to the following formula:
flamecolorgrad1=origincolor*(1-flamemask)+flamecolorgrad*flamemaskflamecolorgrad1=origincolor*(1-flamemask)+flamecolorgrad*flamemask
其中flamecolorgrad1表示合成图像中的像素的值,origincolor表示原始图像帧中的像素的值,flamecolorgrad表示第三图像中像素的值,flamemask表示第二图像中像素的值。Among them, flamecolorgrad1 represents the value of the pixel in the composite image, origincolor represents the value of the pixel in the original image frame, flamecolorgrad represents the value of the pixel in the third image, and flamemask represents the value of the pixel in the second image.
本公开公开了一种图像合成方法、装置、电子设备和计算机可读存储介质。其中该图像合成方法包括:从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;从所述原始图像帧中分割出目标对象图像;对所述目标对象图像做模糊处理得到第一图像;获取缓 存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;将所述第一图像放入所述缓存队列中;获取噪声图像帧,所述噪声图像帧为灰度图像;根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。通过上述方法,解决了现有技术中无法简单快速的生成视频效果的技术问题The present disclosure discloses an image synthesis method, device, electronic equipment, and computer-readable storage medium. The image synthesis method includes: obtaining an original image frame from an image source, wherein the original image frame includes a target object; segmenting the target object image from the original image frame; and blurring the target object image to obtain the first An image; obtain a historical first image in the buffer queue, the historical first image is obtained by processing the original image frame before the original image frame; put the first image in the buffer queue; obtain a noise image Frame, the noise image frame is a grayscale image; a composite image is generated according to the original image frame, the historical first image, and the noise image frame. Through the above method, the technical problem that the video effect cannot be generated simply and quickly in the prior art is solved
在上文中,虽然按照上述的顺序描述了上述方法实施例中的各个步骤,本领域技术人员应清楚,本公开实施例中的步骤并不必然按照上述顺序执行,其也可以倒序、并行、交叉等其他顺序执行,而且,在上述步骤的基础上,本领域技术人员也可以再加入其他步骤,这些明显变型或等同替换的方式也应包含在本公开的保护范围之内,在此不再赘述。In the above, although the steps in the above method embodiments are described in the above order, those skilled in the art should understand that the steps in the embodiments of the present disclosure are not necessarily executed in the above order, and they can also be reversed, parallel, or interleaved. Other steps are executed in other order, and, on the basis of the above steps, those skilled in the art can also add other steps. These obvious modifications or equivalent substitutions should also be included in the scope of protection of the present disclosure, and will not be repeated here. .
图8为本公开实施例提供的图像合成装置实施例的结构示意图,如图8所示,该装置800包括:原始图像帧获取模块801、目标对象图像分割模块802、模糊处理模块803、历史第一图像获取模块804、第一图像缓存模块805、噪声图像帧获取模块806和合成模块807。其中,FIG. 8 is a schematic structural diagram of an embodiment of an image synthesis device provided by an embodiment of the disclosure. As shown in FIG. 8, the device 800 includes: an original image frame acquisition module 801, a target object image segmentation module 802, a blur processing module 803, and a historical image An image acquisition module 804, a first image buffer module 805, a noise image frame acquisition module 806, and a synthesis module 807. among them,
原始图像帧获取模块801,用于从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;The original image frame obtaining module 801 is configured to obtain an original image frame from an image source, wherein the original image frame includes a target object;
目标对象图像分割模块802,用于从所述原始图像帧中分割出所述目标对象图像;The target object image segmentation module 802 is configured to segment the target object image from the original image frame;
模糊处理模块803,用于对所述目标对象图像做模糊处理得到第一图像;The blur processing module 803 is configured to perform blur processing on the target object image to obtain a first image;
历史第一图像获取模块804,用于获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;The historical first image obtaining module 804 is configured to obtain the historical first image in the buffer queue, the historical first image being obtained by processing the original image frame before the original image frame;
第一图像缓存模块805,用于将所述第一图像放入所述缓存队列中;The first image buffer module 805 is configured to put the first image into the buffer queue;
噪声图像帧获取模块806,用于获取噪声图像帧,所述噪声图像帧为灰度图像;The noise image frame acquisition module 806 is configured to acquire a noise image frame, where the noise image frame is a grayscale image;
合成模块807,用于根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。The synthesis module 807 is configured to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
进一步的,所述模糊处理模块803,还包括:Further, the blur processing module 803 further includes:
模糊参数获取模块,用于获取模糊参数;The fuzzy parameter acquisition module is used to acquire fuzzy parameters;
高斯模糊模块,用于根据所述模糊参数对所述目标对象图像进行高斯模糊得到第一图像。The Gaussian blur module is configured to perform Gaussian blur on the target object image according to the blur parameters to obtain a first image.
进一步的,所述第一图像缓存模块805,还包括:Further, the first image cache module 805 further includes:
移动模块,用于将所述缓存队列中的历史第一图像依次前移一个位置;The moving module is used to move the first historical image in the buffer queue one position in turn;
第一缓存模块,用于将所述第一图像放入所述缓存队列的队尾。The first buffer module is used to put the first image into the end of the buffer queue.
进一步的,所述合成模块807,还包括:Further, the synthesis module 807 further includes:
第二图像生成模块,用于将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像;The second image generation module is configured to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
第一处理模块,用于将所述第二图像进行第一处理得到第三图像;The first processing module is configured to perform first processing on the second image to obtain a third image;
合成子模块,用于根据所述第二图像、第三图像以及所述原始图像帧生成合成图像。The synthesis sub-module is used to generate a synthesized image according to the second image, the third image and the original image frame.
进一步的,所述第二图像生成模块,还包括:Further, the second image generation module further includes:
历史第一调整图像生成模块,用于将所述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到历史第一调整图像;The historical first adjusted image generating module is configured to multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
第二图像第一生成模块,用于将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像。The first generating module of the second image is used to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image.
进一步的,所述第二图像第一生成模块,还包括:Further, the first generating module of the second image further includes:
轮廓图像生成模块,用于根据所述目标对象图像和历史第一调整图像得到历史第一调整图像的轮廓图像;A contour image generating module, configured to obtain the contour image of the historical first adjustment image according to the target object image and the historical first adjustment image;
第二图像第二生成模块,用于将噪声图像帧中的像素的值与所述轮廓图像中的像素的值相乘得到第二图像。The second image generation module is configured to multiply the value of the pixel in the noise image frame and the value of the pixel in the contour image to obtain the second image.
进一步的,所述第一处理模块,还包括:Further, the first processing module further includes:
第一处理第一模块,用于如果第二图像中的像素的值大于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第一颜色参数进行混合,得到第三图像中的像素的值;The first processing module is used to mix the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter if the value of the pixel in the second image is greater than the first threshold , Get the value of the pixel in the third image;
第一处理第二模块,如果第二图像中的像素的值大于第二阈值且小于等于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第二颜色参数进行混合,得到第三图像中的像素的值;The first processing second module, if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the second The color parameters are mixed to obtain the value of the pixel in the third image;
第一处理第三模块,如果第二图像中的像素的值大于第三阈值且小于等于第二阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第三颜色参数进行混合,得到第三图像中的像素的值;The first processing third module, if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the third The color parameters are mixed to obtain the value of the pixel in the third image;
第一处理第四模块,如果第二图像中的像素的值小于等于第三阈值,则将所述轮廓图像中的像素的值、原始图像中的像素的值和第四颜色参数进行混合,得到第三图像中的像素的值。The fourth module of the first processing, if the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image and the fourth color parameter are mixed to obtain The value of the pixel in the third image.
进一步的,所述历史第一图像获取模块804,还包括:Further, the historical first image acquisition module 804 further includes:
原始历史第一图像获取模块,用于获取缓存队列中的多个原始历史第一图像;The original historical first image acquisition module, which is used to acquire multiple original historical first images in the cache queue;
透明度系数获取模块,用于获取所述多个原始历史第一图像的透明度系数;A transparency coefficient obtaining module, configured to obtain the transparency coefficients of the multiple original historical first images;
调整透明度生成模块,用于将所述多个原始历史第一图像的透明度分别和与其对应的透明度系数相乘得到多个调整透明度;An adjusted transparency generating module, configured to multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency;
最大调整透明度计算模块,用于计算得到所述多个调整透明度中的最大调整透明度;A maximum adjustment transparency calculation module, configured to calculate the maximum adjustment transparency among the plurality of adjustment transparency;
历史第一图像获取子模块,用于根据所述最大调整透明度生成所 述历史第一图像。The historical first image acquisition sub-module is configured to generate the historical first image according to the maximum adjusted transparency.
进一步的,所述第一处理模块,还包括:Further, the first processing module further includes:
第四图像生成模块,用于将所述第二图像进行第一子处理,得到第四图像;A fourth image generation module, configured to perform a first sub-processing on the second image to obtain a fourth image;
第一透明度系数生成模块,用于根据所述最大调整透明度生成第一透明度系数;A first transparency coefficient generating module, configured to generate a first transparency coefficient according to the maximum adjusted transparency;
第三图像生成模块,用于根据所述第四图像以及所述透明度系数生成第三图像。The third image generating module is configured to generate a third image according to the fourth image and the transparency coefficient.
进一步的,所述模糊处理模块803,还包括:Further, the blur processing module 803 further includes:
大小属性获取模块,用于获取所述目标对象的大小属性;A size attribute obtaining module, configured to obtain the size attribute of the target object;
模糊处理子模块,用于根据所述大小属性控制模糊处理的处理范围对所述目标对象图像做模糊处理得到第一图像。The blur processing sub-module is used to control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
图8所示装置可以执行图1-图7所示实施例的方法,本实施例未详细描述的部分,可参考对图1-图7所示实施例的相关说明。该技术方案的执行过程和技术效果参见图1-图7所示实施例中的描述,在此不再赘述。The device shown in Fig. 8 can execute the methods of the embodiments shown in Figs. For the implementation process and technical effects of this technical solution, please refer to the description in the embodiment shown in FIG. 1 to FIG. 7, which will not be repeated here.
下面参考图9,其示出了适于用来实现本公开实施例的电子设备900的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图9示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Next, referring to FIG. 9, it shows a schematic structural diagram of an electronic device 900 suitable for implementing the embodiments of the present disclosure. Terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in FIG. 9 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
如图9所示,电子设备900可以包括处理装置(例如中央处理器、 图形处理器等)901,其可以根据存储在只读存储器(ROM)902中的程序或者从存储装置906加载到随机访问存储器(RAM)903中的程序而执行各种适当的动作和处理。在RAM 903中,还存储有电子设备900操作所需的各种程序和数据。处理装置901、ROM 902以及RAM 903通过总线904彼此相连。输入/输出(I/O)接口905也连接至总线904。As shown in FIG. 9, the electronic device 900 may include a processing device (such as a central processing unit, a graphics processor, etc.) 901, which may be loaded into a random access device according to a program stored in a read-only memory (ROM) 902 or from a storage device 906. The program in the memory (RAM) 903 executes various appropriate actions and processing. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
通常,以下装置可以连接至I/O接口905:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置906;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置907;包括例如磁带、硬盘等的存储装置906;以及通信装置909。通信装置909可以允许电子设备900与其他设备进行无线或有线通信以交换数据。虽然图9示出了具有各种装置的电子设备900,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Generally, the following devices can be connected to the I/O interface 905: including input devices 906 such as touch screens, touch pads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; including, for example, liquid crystal displays (LCD), speakers, vibration An output device 907 such as a device; a storage device 906 such as a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to perform wireless or wired communication with other devices to exchange data. Although FIG. 9 shows an electronic device 900 having various devices, it should be understood that it is not required to implement or have all of the illustrated devices. It may alternatively be implemented or provided with more or fewer devices.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在非暂态计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置909从网络上被下载和安装,或者从存储装置906被安装,或者从ROM 902被安装。在该计算机程序被处理装置901执行时,执行本公开实施例的方法中限定的上述功能。In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 909, or installed from the storage device 906, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the aforementioned computer-readable medium in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable removable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium. The computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device . The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
在一些实施方式中,客户端、服务器可以利用诸如HTTP(HyperText Transfer Protocol,超文本传输协议)之类的任何当前已知或未来研发的网络协议进行通信,并且可以与任意形式或介质 的数字数据通信(例如,通信网络)互连。通信网络的示例包括局域网(“LAN”),广域网(“WAN”),网际网(例如,互联网)以及端对端网络(例如,ad hoc端对端网络),以及任何当前已知或未来研发的网络。In some embodiments, the client and server can communicate with any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can communicate with digital data in any form or medium. Communication (e.g., communication network) interconnects. Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future research and development network of.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;从所述原始图像帧中分割出目标对象图像;对所述目标对象图像做模糊处理得到第一图像;获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;将所述第一图像放入所述缓存队列中;获取噪声图像帧,所述噪声图像帧为灰度图像;根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains an original image frame from an image source, wherein the original image frame includes a target object Segment the target object image from the original image frame; perform blur processing on the target object image to obtain the first image; obtain the historical first image in the buffer queue, the historical first image from the original image frame The previous original image frame is processed; the first image is put into the buffer queue; the noise image frame is obtained, and the noise image frame is a grayscale image; according to the original image frame, the historical first image, and the noise The image frame generates a composite image.
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括但不限于面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。The computer program code used to perform the operations of the present disclosure can be written in one or more programming languages or a combination thereof. The above-mentioned programming languages include but are not limited to object-oriented programming languages such as Java, Smalltalk, C++, and Including conventional procedural programming languages-such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions, and operations of the system, method, and computer program product according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions. It should also be noted that, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定。The units involved in the embodiments described in the present disclosure can be implemented in software or hardware. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。The functions described hereinabove may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logical device (CPLD) and so on.
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、 装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present disclosure, a machine-readable medium may be a tangible medium, which may contain or store a program for use by the instruction execution system, apparatus, or device or in combination with the instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
根据本公开的一个或多个实施例,提供了一种图像合成方法,包括:According to one or more embodiments of the present disclosure, there is provided an image synthesis method, including:
从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;从所述原始图像帧中分割出目标对象图像;对所述目标对象图像做模糊处理得到第一图像;获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;将所述第一图像放入所述缓存队列中;获取噪声图像帧,所述噪声图像帧为灰度图像;根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。Obtain an original image frame from an image source, wherein the original image frame includes a target object; segment the target object image from the original image frame; perform blur processing on the target object image to obtain the first image; obtain the buffer queue The historical first image, the historical first image is obtained by processing the original image frame before the original image frame; the first image is put into the buffer queue; the noise image frame is acquired, the noise image frame It is a grayscale image; a composite image is generated according to the original image frame, the first historical image, and the noise image frame.
进一步的,所述对所述目标对象图像做模糊处理得到第一图像,包括:Further, the performing blur processing on the target object image to obtain the first image includes:
获取模糊参数;根据所述模糊参数对所述目标对象图像进行高斯模糊得到第一图像。Obtain a blur parameter; perform Gaussian blur on the target object image according to the blur parameter to obtain a first image.
进一步的,所述将所述第一图像放入所述缓存队列中,包括:将所述缓存队列中的历史第一图像依次前移一个位置;将所述第一图像放入所述缓存队列的队尾。Further, the putting the first image into the cache queue includes: sequentially moving the historical first images in the cache queue one position forward; putting the first image into the cache queue The end of the team.
进一步的,所述根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像,包括:将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像;将所述第二图像进行第一处 理得到第三图像;根据所述第二图像、第三图像以及所述原始图像帧生成合成图像。Further, the generating a composite image according to the original image frame, the historical first image, and the noise image frame includes: multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain A second image; the second image is subjected to a first processing to obtain a third image; a composite image is generated according to the second image, the third image, and the original image frame.
进一步的,所述将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像,包括:将所述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到历史第一调整图像;将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像。Further, the multiplying the value of the pixel in the noise image frame with the value of the pixel in the historical first image to obtain the second image includes: multiplying the value of the pixel in the historical first image by a contrast coefficient And the image offset value is added to obtain the historical first adjusted image; the value of the pixel in the noise image frame is multiplied by the value of the pixel in the historical first adjusted image to obtain the second image.
进一步的,所述将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像,包括:根据所述目标对象图像和历史第一调整图像得到历史第一调整图像的轮廓图像;将噪声图像帧中的像素的值与所述轮廓图像中的像素的值相乘得到第二图像。Further, the multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image includes: obtaining the historical image according to the target object image and the historical first adjusted image The contour image of the first adjustment image; the second image is obtained by multiplying the value of the pixel in the noise image frame by the value of the pixel in the contour image.
进一步的,所述将所述第二图像进行第一处理得到第三图像,包括:如果第二图像中的像素的值大于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第一颜色参数进行混合,得到第三图像中的像素的值;如果第二图像中的像素的值大于第二阈值且小于等于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第二颜色参数进行混合,得到第三图像中的像素的值;如果第二图像中的像素的值大于第三阈值且小于等于第二阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第三颜色参数进行混合,得到第三图像中的像素的值;如果第二图像中的像素的值小于等于第三阈值,则将所述轮廓图像中的像素的值、原始图像中的像素的值和第四颜色参数进行混合,得到第三图像中的像素的值。Further, the first processing of the second image to obtain the third image includes: if the value of the pixel in the second image is greater than the first threshold, then the value of the pixel in the second image is compared with the original The value of the pixel in the image is mixed with the first color parameter to obtain the value of the pixel in the third image; if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the second The value of the pixel in the image, the value of the pixel in the original image, and the second color parameter are mixed to obtain the value of the pixel in the third image; if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second Threshold, the pixel value in the second image, the pixel value in the original image, and the third color parameter are mixed to obtain the value of the pixel in the third image; if the value of the pixel in the second image is less than If it is equal to the third threshold, the pixel value in the contour image, the pixel value in the original image, and the fourth color parameter are mixed to obtain the pixel value in the third image.
进一步的,所述获取缓存队列中的历史第一图像,包括:获取缓存队列中的多个原始历史第一图像;获取所述多个原始历史第一图像的透明度系数;将所述多个原始历史第一图像的透明度分别和与其对应的透明度系数相乘得到多个调整透明度;计算得到所述多个调整透明度中的最大调整透明度;根据所述最大调整透明度生成所述历史第一图像。Further, the obtaining the first historical image in the cache queue includes: obtaining a plurality of original historical first images in the cache queue; obtaining the transparency coefficients of the plurality of original historical first images; The transparency of the historical first image is respectively multiplied by the corresponding transparency coefficient to obtain multiple adjusted transparency; the maximum adjusted transparency of the multiple adjusted transparency is calculated; and the historical first image is generated according to the maximum adjusted transparency.
进一步的,所述将所述第二图像进行第一处理得到第三图像,包括:将所述第二图像进行第一子处理,得到第四图像;根据所述最大调整透明度生成第一透明度系数;根据所述第四图像以及所述透明度 系数生成第三图像。Further, the performing the first processing on the second image to obtain the third image includes: performing the first sub-processing on the second image to obtain a fourth image; and generating a first transparency coefficient according to the maximum adjusted transparency ; Generate a third image according to the fourth image and the transparency coefficient.
进一步的,所述对所述目标对象图像做模糊处理得到第一图像,包括:获取所述目标对象的大小属性;根据所述大小属性控制模糊处理的处理范围对所述目标对象图像做模糊处理得到第一图像。Further, the performing blur processing on the target object image to obtain the first image includes: obtaining the size attribute of the target object; and controlling the processing range of the blur processing according to the size attribute to perform blur processing on the target object image Get the first image.
根据本公开的一个或多个实施例,提供了一种图像合成装置,包括:According to one or more embodiments of the present disclosure, there is provided an image synthesis device, including:
原始图像帧获取模块,用于从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;An original image frame obtaining module, configured to obtain an original image frame from an image source, wherein the original image frame includes a target object;
目标对象图像分割模块,用于从所述原始图像帧中分割出所述目标对象图像;A target object image segmentation module, configured to segment the target object image from the original image frame;
模糊处理模块,用于对所述目标对象图像做模糊处理得到第一图像;The blur processing module is used to perform blur processing on the target object image to obtain the first image;
历史第一图像获取模块,用于获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;The historical first image acquisition module is configured to acquire the historical first image in the buffer queue, where the historical first image is obtained by processing the original image frame before the original image frame;
第一图像缓存模块,用于将所述第一图像放入所述缓存队列中;The first image buffer module is configured to put the first image into the buffer queue;
噪声图像帧获取模块,用于获取噪声图像帧,所述噪声图像帧为灰度图像;A noise image frame acquisition module, configured to acquire a noise image frame, where the noise image frame is a grayscale image;
合成模块,用于根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。The synthesis module is used to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
进一步的,所述模糊处理模块,还包括:Further, the blur processing module further includes:
模糊参数获取模块,用于获取模糊参数;The fuzzy parameter acquisition module is used to acquire fuzzy parameters;
高斯模糊模块,用于根据所述模糊参数对所述目标对象图像进行高斯模糊得到第一图像。The Gaussian blur module is configured to perform Gaussian blur on the target object image according to the blur parameters to obtain a first image.
进一步的,所述第一图像缓存模块,还包括:Further, the first image cache module further includes:
移动模块,用于将所述缓存队列中的历史第一图像依次前移一个位置;The moving module is used to move the first historical image in the buffer queue one position in turn;
第一缓存模块,用于将所述第一图像放入所述缓存队列的队尾。The first buffer module is used to put the first image into the end of the buffer queue.
进一步的,所述合成模块,还包括:Further, the synthesis module further includes:
第二图像生成模块,用于将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像;The second image generation module is configured to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain a second image;
第一处理模块,用于将所述第二图像进行第一处理得到第三图像;The first processing module is configured to perform first processing on the second image to obtain a third image;
合成子模块,用于根据所述第二图像、第三图像以及所述原始图像帧生成合成图像。The synthesis sub-module is used to generate a synthesized image according to the second image, the third image and the original image frame.
进一步的,所述第二图像生成模块,还包括:Further, the second image generation module further includes:
历史第一调整图像生成模块,用于将所述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到历史第一调整图像;The historical first adjusted image generating module is configured to multiply the pixel value of the historical first image by the contrast coefficient and add the image offset value to obtain the historical first adjusted image;
第二图像第一生成模块,用于将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像。The first generating module of the second image is used to multiply the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image.
进一步的,所述第二图像第一生成模块,还包括:Further, the first generating module of the second image further includes:
轮廓图像生成模块,用于根据所述目标对象图像和历史第一调整图像得到历史第一调整图像的轮廓图像;A contour image generating module, configured to obtain the contour image of the historical first adjustment image according to the target object image and the historical first adjustment image;
第二图像第二生成模块,用于将噪声图像帧中的像素的值与所述轮廓图像中的像素的值相乘得到第二图像。The second image generation module is configured to multiply the value of the pixel in the noise image frame and the value of the pixel in the contour image to obtain the second image.
进一步的,所述第一处理模块,还包括:Further, the first processing module further includes:
第一处理第一模块,用于如果第二图像中的像素的值大于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第一颜色参数进行混合,得到第三图像中的像素的值;The first processing module is used to mix the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter if the value of the pixel in the second image is greater than the first threshold , Get the value of the pixel in the third image;
第一处理第二模块,如果第二图像中的像素的值大于第二阈值且小于等于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第二颜色参数进行混合,得到第三图像中的像素的值;The first processing second module, if the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the second The color parameters are mixed to obtain the value of the pixel in the third image;
第一处理第三模块,如果第二图像中的像素的值大于第三阈值且小于等于第二阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第三颜色参数进行混合,得到第三图像中的像素的值;The first processing third module, if the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image and the third The color parameters are mixed to obtain the value of the pixel in the third image;
第一处理第四模块,如果第二图像中的像素的值小于等于第三阈值,则将所述轮廓图像中的像素的值、原始图像中的像素的值和第四颜色参数进行混合,得到第三图像中的像素的值。The fourth module of the first processing, if the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image and the fourth color parameter are mixed to obtain The value of the pixel in the third image.
进一步的,所述历史第一图像获取模块,还包括:Further, the historical first image acquisition module further includes:
原始历史第一图像获取模块,用于获取缓存队列中的多个原始历史第一图像;The original historical first image acquisition module, which is used to acquire multiple original historical first images in the cache queue;
透明度系数获取模块,用于获取所述多个原始历史第一图像的透明度系数;A transparency coefficient obtaining module, configured to obtain the transparency coefficients of the multiple original historical first images;
调整透明度生成模块,用于将所述多个原始历史第一图像的透明度分别和与其对应的透明度系数相乘得到多个调整透明度;An adjusted transparency generating module, configured to multiply the transparency of the multiple original historical first images by the corresponding transparency coefficients to obtain multiple adjusted transparency;
最大调整透明度计算模块,用于计算得到所述多个调整透明度中的最大调整透明度;A maximum adjustment transparency calculation module, configured to calculate the maximum adjustment transparency among the plurality of adjustment transparency;
历史第一图像获取子模块,用于根据所述最大调整透明度生成所述历史第一图像。The historical first image acquisition sub-module is configured to generate the historical first image according to the maximum adjusted transparency.
进一步的,所述第一处理模块,还包括:Further, the first processing module further includes:
第四图像生成模块,用于将所述第二图像进行第一子处理,得到第四图像;A fourth image generation module, configured to perform a first sub-processing on the second image to obtain a fourth image;
第一透明度系数生成模块,用于根据所述最大调整透明度生成第一透明度系数;A first transparency coefficient generating module, configured to generate a first transparency coefficient according to the maximum adjusted transparency;
第三图像生成模块,用于根据所述第四图像以及所述透明度系数生成第三图像。The third image generating module is configured to generate a third image according to the fourth image and the transparency coefficient.
进一步的,所述模糊处理模块,还包括:Further, the blur processing module further includes:
大小属性获取模块,用于获取所述目标对象的大小属性;A size attribute obtaining module, configured to obtain the size attribute of the target object;
模糊处理子模块,用于根据所述大小属性控制模糊处理的处理范围对所述目标对象图像做模糊处理得到第一图像。The blur processing sub-module is used to control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
根据本公开一个或多个实施例,提供一种电子设备,包括:至少 一个处理器;以及,According to one or more embodiments of the present disclosure, there is provided an electronic device including: at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有能被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行前述任一所述图像合成方法。A memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processing The device can perform any of the aforementioned image synthesis methods.
根据本公开一个或多个实施例,提供一种非暂态计算机可读存储介质,其特征在于,该非暂态计算机可读存储介质存储计算机指令,该计算机指令用于使计算机执行前述任一所述图像合成方法。According to one or more embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute any of the foregoing The image synthesis method.
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in this disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover the above technical features or technical solutions without departing from the above disclosed concept. Other technical solutions formed by arbitrarily combining the equivalent features. For example, the above-mentioned features and the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form a technical solution.

Claims (13)

  1. 一种图像合成方法,包括:An image synthesis method, including:
    从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;Obtaining an original image frame from an image source, wherein the original image frame includes a target object;
    从所述原始图像帧中分割出目标对象图像;Segmenting the target object image from the original image frame;
    对所述目标对象图像做模糊处理得到第一图像;Performing blur processing on the target object image to obtain a first image;
    获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;Acquiring a historical first image in the buffer queue, where the historical first image is obtained by processing an original image frame before the original image frame;
    将所述第一图像放入所述缓存队列中;Putting the first image in the buffer queue;
    获取噪声图像帧,所述噪声图像帧为灰度图像;Acquiring a noise image frame, where the noise image frame is a grayscale image;
    根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。A composite image is generated according to the original image frame, the historical first image, and the noise image frame.
  2. 如权利要求1所述的图像合成方法,其中所述对所述目标对象图像做模糊处理得到第一图像,包括:8. The image synthesis method according to claim 1, wherein said blurring said target object image to obtain the first image comprises:
    获取模糊参数;Obtain fuzzy parameters;
    根据所述模糊参数对所述目标对象图像进行高斯模糊得到第一图像。Gaussian blurring is performed on the target object image according to the blurring parameter to obtain a first image.
  3. 如权利要求1所述的图像合成方法,其中所述将所述第一图像放入所述缓存队列中,包括:5. The image synthesis method according to claim 1, wherein the putting the first image into the buffer queue comprises:
    将所述缓存队列中的历史第一图像依次前移一个位置;Moving the first historical image in the buffer queue one position in turn;
    将所述第一图像放入所述缓存队列的队尾。Put the first image at the end of the buffer queue.
  4. 如权利要求1所述的图像合成方法,其中所述根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像,包括:8. The image synthesis method according to claim 1, wherein said generating a synthesized image according to said original image frame, historical first image and noise image frame comprises:
    将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像;Multiplying the value of the pixel in the noise image frame with the value of the pixel in the historical first image to obtain a second image;
    将所述第二图像进行第一处理得到第三图像;Performing first processing on the second image to obtain a third image;
    根据所述第二图像、第三图像以及所述原始图像帧生成合成图像。A composite image is generated according to the second image, the third image, and the original image frame.
  5. 如权利要求4所述的图像合成方法,其中所述将噪声图像帧中的像素的值与所述历史第一图像中的像素的值相乘得到第二图像,包括:5. The image synthesis method according to claim 4, wherein said multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first image to obtain the second image comprises:
    将所述历史第一图像的像素的值乘以对比系数并加上图像偏移值得到历史第一调整图像;Multiplying the pixel value of the historical first image by the contrast coefficient and adding the image offset value to obtain the historical first adjusted image;
    将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像。The second image is obtained by multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image.
  6. 如权利要求5所述的图像合成方法,其中所述将噪声图像帧中的像素的值与所述历史第一调整图像中的像素的值相乘得到第二图像,包括:5. The image synthesis method according to claim 5, wherein said multiplying the value of the pixel in the noise image frame by the value of the pixel in the historical first adjusted image to obtain the second image comprises:
    根据所述目标对象图像和历史第一调整图像得到历史第一调整图像的轮廓图像;Obtaining the contour image of the historical first adjusted image according to the target object image and the historical first adjusted image;
    将噪声图像帧中的像素的值与所述轮廓图像中的像素的值相乘得到第二图像。The second image is obtained by multiplying the value of the pixel in the noise image frame by the value of the pixel in the contour image.
  7. 如权利要求6所述的图像合成方法,其中所述将所述第二图像进行第一处理得到第三图像,包括:7. The image synthesis method according to claim 6, wherein the first processing of the second image to obtain the third image comprises:
    如果第二图像中的像素的值大于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第一颜色参数进行混合,得到第三图像中的像素的值;If the value of the pixel in the second image is greater than the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the first color parameter are mixed to obtain the value of the pixel in the third image value;
    如果第二图像中的像素的值大于第二阈值且小于等于第一阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第二颜色参数进行混合,得到第三图像中的像素的值;If the value of the pixel in the second image is greater than the second threshold and less than or equal to the first threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the second color parameter are mixed to obtain the first The value of the pixels in the three images;
    如果第二图像中的像素的值大于第三阈值且小于等于第二阈值,则将所述第二图像中的像素的值、原始图像中的像素的值和第三颜色参数进行混合,得到第三图像中的像素的值;If the value of the pixel in the second image is greater than the third threshold and less than or equal to the second threshold, then the value of the pixel in the second image, the value of the pixel in the original image, and the third color parameter are mixed to obtain the first The value of the pixels in the three images;
    如果第二图像中的像素的值小于等于第三阈值,则将所述轮廓图像中的像素的值、原始图像中的像素的值和第四颜色参数进行混合, 得到第三图像中的像素的值。If the value of the pixel in the second image is less than or equal to the third threshold, then the value of the pixel in the contour image, the value of the pixel in the original image, and the fourth color parameter are mixed to obtain the value of the pixel in the third image value.
  8. 如权利要求4所述的图像合成方法,其中所述获取缓存队列中的历史第一图像,包括:5. The image synthesis method according to claim 4, wherein said obtaining the historical first image in the buffer queue comprises:
    获取缓存队列中的多个原始历史第一图像;Acquire multiple original historical first images in the cache queue;
    获取所述多个原始历史第一图像的透明度系数;Acquiring the transparency coefficients of the multiple original historical first images;
    将所述多个原始历史第一图像的透明度分别和与其对应的透明度系数相乘得到多个调整透明度;Multiplying the transparency of the multiple original historical first images with the corresponding transparency coefficients to obtain multiple adjusted transparency;
    计算得到所述多个调整透明度中的最大调整透明度;The maximum adjustment transparency of the plurality of adjustment transparency is obtained by calculation;
    根据所述最大调整透明度生成所述历史第一图像。The historical first image is generated according to the maximum adjusted transparency.
  9. 如权利要求8所述的图像合成方法,其中所述将所述第二图像进行第一处理得到第三图像,包括:8. The image synthesis method according to claim 8, wherein the first processing of the second image to obtain the third image comprises:
    将所述第二图像进行第一子处理,得到第四图像;Performing a first sub-processing on the second image to obtain a fourth image;
    根据所述最大调整透明度生成第一透明度系数;Generating a first transparency coefficient according to the maximum adjusted transparency;
    根据所述第四图像以及所述透明度系数生成第三图像。A third image is generated according to the fourth image and the transparency coefficient.
  10. 如权利要求1所述的图像合成方法,其中所述对所述目标对象图像做模糊处理得到第一图像,包括:8. The image synthesis method according to claim 1, wherein said blurring said target object image to obtain the first image comprises:
    获取所述目标对象的大小属性;Acquiring the size attribute of the target object;
    根据所述大小属性控制模糊处理的处理范围对所述目标对象图像做模糊处理得到第一图像。Control the processing range of the blur processing according to the size attribute to perform the blur processing on the target object image to obtain the first image.
  11. 一种图像合成装置,包括:An image synthesis device, including:
    原始图像帧获取模块,用于从图像源获取原始图像帧,其中所述原始图像帧中包括目标对象;An original image frame obtaining module, configured to obtain an original image frame from an image source, wherein the original image frame includes a target object;
    目标对象图像分割模块,用于从所述原始图像帧中分割出所述目标对象图像;A target object image segmentation module, configured to segment the target object image from the original image frame;
    模糊处理模块,用于对所述目标对象图像做模糊处理得到第一图像;The blur processing module is used to perform blur processing on the target object image to obtain the first image;
    历史第一图像获取模块,用于获取缓存队列中的历史第一图像,所述历史第一图像由所述原始图像帧之前的原始图像帧处理得到;The historical first image acquisition module is configured to acquire the historical first image in the buffer queue, where the historical first image is obtained by processing the original image frame before the original image frame;
    第一图像缓存模块,用于将所述第一图像放入所述缓存队列中;The first image buffer module is configured to put the first image into the buffer queue;
    噪声图像帧获取模块,用于获取噪声图像帧,所述噪声图像帧为灰度图像;A noise image frame acquisition module, configured to acquire a noise image frame, where the noise image frame is a grayscale image;
    合成模块,用于根据所述原始图像帧、历史第一图像以及噪声图像帧生成合成图像。The synthesis module is used to generate a synthesized image according to the original image frame, the first historical image, and the noise image frame.
  12. 一种电子设备,包括:An electronic device including:
    存储器,用于存储计算机可读指令;以及Memory for storing computer readable instructions; and
    处理器,用于运行所述计算机可读指令,使得所述处理器运行时实现根据权利要求1-10中任意一项所述的图像合成方法。The processor is configured to run the computer-readable instructions, so that the processor implements the image synthesis method according to any one of claims 1-10 when the processor is running.
  13. 一种非暂态计算机可读存储介质,用于存储计算机可读指令,当所述计算机可读指令由计算机执行时,使得所述计算机执行权利要求1-10中任意一项所述的图像合成方法。A non-transitory computer-readable storage medium for storing computer-readable instructions. When the computer-readable instructions are executed by a computer, the computer can execute the image synthesis according to any one of claims 1-10 method.
PCT/CN2020/116292 2019-10-10 2020-09-18 Image synthesis method and apparatus, electronic device, and computer readable storage medium WO2021068729A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910959995.7A CN112651909B (en) 2019-10-10 2019-10-10 Image synthesis method, device, electronic equipment and computer readable storage medium
CN201910959995.7 2019-10-10

Publications (1)

Publication Number Publication Date
WO2021068729A1 true WO2021068729A1 (en) 2021-04-15

Family

ID=75342779

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/116292 WO2021068729A1 (en) 2019-10-10 2020-09-18 Image synthesis method and apparatus, electronic device, and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN112651909B (en)
WO (1) WO2021068729A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160125633A1 (en) * 2013-05-13 2016-05-05 Nokia Technologies Oy Method, apparatus and computer program product to represent motion in composite images
US10217195B1 (en) * 2017-04-17 2019-02-26 Amazon Technologies, Inc. Generation of semantic depth of field effect
CN110035236A (en) * 2019-03-26 2019-07-19 北京字节跳动网络技术有限公司 Image processing method, device and electronic equipment
CN110047124A (en) * 2019-04-23 2019-07-23 北京字节跳动网络技术有限公司 Method, apparatus, electronic equipment and the computer readable storage medium of render video
CN110070515A (en) * 2019-01-31 2019-07-30 北京字节跳动网络技术有限公司 Image composition method, device and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109348089B (en) * 2018-11-22 2020-05-22 Oppo广东移动通信有限公司 Night scene image processing method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160125633A1 (en) * 2013-05-13 2016-05-05 Nokia Technologies Oy Method, apparatus and computer program product to represent motion in composite images
US10217195B1 (en) * 2017-04-17 2019-02-26 Amazon Technologies, Inc. Generation of semantic depth of field effect
CN110070515A (en) * 2019-01-31 2019-07-30 北京字节跳动网络技术有限公司 Image composition method, device and computer readable storage medium
CN110035236A (en) * 2019-03-26 2019-07-19 北京字节跳动网络技术有限公司 Image processing method, device and electronic equipment
CN110047124A (en) * 2019-04-23 2019-07-23 北京字节跳动网络技术有限公司 Method, apparatus, electronic equipment and the computer readable storage medium of render video

Also Published As

Publication number Publication date
CN112651909A (en) 2021-04-13
CN112651909B (en) 2024-03-15

Similar Documents

Publication Publication Date Title
CN110100251B (en) Apparatus, method, and computer-readable storage medium for processing document
WO2022166872A1 (en) Special-effect display method and apparatus, and device and medium
WO2021031850A1 (en) Image processing method and apparatus, electronic device and storage medium
KR101755412B1 (en) Method and device for processing identification of video file, program and recording medium
WO2023051185A1 (en) Image processing method and apparatus, and electronic device and storage medium
WO2021254502A1 (en) Target object display method and apparatus and electronic device
CN110796664B (en) Image processing method, device, electronic equipment and computer readable storage medium
JP7181375B2 (en) Target object motion recognition method, device and electronic device
CN111277893B (en) Video processing method and device, readable medium and electronic equipment
WO2020147521A1 (en) Image display method and apparatus
WO2022100735A1 (en) Video processing method and apparatus, electronic device, and storage medium
CN110059623B (en) Method and apparatus for generating information
WO2021147461A1 (en) Subtitle information display method and apparatus, and electronic device, and computer readable medium
JP6400293B2 (en) Apparatus and method for controlling content by electronic device
WO2021104130A1 (en) Method and apparatus for displaying object in video, and electronic device and computer readable storage medium
WO2022007565A1 (en) Image processing method and apparatus for augmented reality, electronic device and storage medium
US12019669B2 (en) Method, apparatus, device, readable storage medium and product for media content processing
WO2023165515A1 (en) Photographing method and apparatus, electronic device, and storage medium
WO2023103720A1 (en) Video special effect processing method and apparatus, electronic device, and program product
JP2022547594A (en) Joint rolling shutter correction and image deblurring
CN116934577A (en) Method, device, equipment and medium for generating style image
TW202219822A (en) Character detection method, electronic equipment and computer-readable storage medium
WO2023165390A1 (en) Zoom special effect generating method and apparatus, device, and storage medium
WO2023138441A1 (en) Video generation method and apparatus, and device and storage medium
WO2021068729A1 (en) Image synthesis method and apparatus, electronic device, and computer readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20875266

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 03.08.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20875266

Country of ref document: EP

Kind code of ref document: A1