CN108171677A - A kind of image processing method and relevant device - Google Patents

A kind of image processing method and relevant device Download PDF

Info

Publication number
CN108171677A
CN108171677A CN201711293350.1A CN201711293350A CN108171677A CN 108171677 A CN108171677 A CN 108171677A CN 201711293350 A CN201711293350 A CN 201711293350A CN 108171677 A CN108171677 A CN 108171677A
Authority
CN
China
Prior art keywords
image
mask
pixel
gray value
grayscale
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201711293350.1A
Other languages
Chinese (zh)
Other versions
CN108171677B (en
Inventor
周景锦
程培
傅斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201711293350.1A priority Critical patent/CN108171677B/en
Publication of CN108171677A publication Critical patent/CN108171677A/en
Application granted granted Critical
Publication of CN108171677B publication Critical patent/CN108171677B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/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
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

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

Abstract

The embodiment of the invention discloses a kind of image processing method and relevant device, including:First image is handled to obtain the first grayscale mask;The mask after corrosion treatment is corroded is carried out to first grayscale mask;According to the mask after first grayscale mask and the corrosion, the mask edge of described first image is determined;The mask edge is added in first grayscale mask and obtains the second grayscale mask;Fusion treatment is carried out to second grayscale mask, described first image and background image and obtains the second image.Using the embodiment of the present invention, the display effect of image can be improved.

Description

A kind of image processing method and relevant device
Technical field
The present invention relates to image processing field more particularly to a kind of image processing methods and relevant device.
Background technology
Green curtain technology can be applied to many scenes, for example, weather forecast, live news or film special efficacy etc., host Or performer only needs the activity before pure color curtain (e.g., green curtain or blue curtain), after video camera takes video image, to video image Carry out processing and extract foreground image, finally merge foreground image with background image, so as to showing in host or Person performer picture movable under various virtual scenes.In addition, in net cast field, main broadcaster only needs to arrange one piece of green curtain, Then the background scene for selecting oneself desired, with regard to the visual effect of net cast can be promoted.
In the prior art scheme, image is handled by green curtain algorithm first to obtain initial gray mask, then Gaussian Blur processing is carried out to initial gray mask (mask) and generates final grayscale mask, by final grayscale mask, original image Fusion treatment, which is carried out, with background image obtains new image, edge sawtooth or discontinuous problem so as to improve mask, still, This processing mode only considered the local message of pixel, and the display effect of the image finally handled is unsatisfactory.
Invention content
An embodiment of the present invention provides a kind of image processing method and relevant devices, and it is bad to solve image display effect Problem.
In a first aspect, an embodiment of the present invention provides a kind of image processing method, including:
First image is handled to obtain the first grayscale mask;
The mask after corrosion treatment is corroded is carried out to first grayscale mask;
According to the mask after first grayscale mask and the corrosion, the mask edge of described first image is determined;
The mask edge is added in first grayscale mask and obtains the second grayscale mask;
Fusion treatment is carried out to second grayscale mask, described first image and background image and obtains the second image.
Wherein, the mask according to after first grayscale mask and the corrosion, determines covering for described first image Film edge includes:
The gray value of pixel in first grayscale mask is subtracted into pixel described in the mask after the corrosion The gray value of pixel described in the mask edge is calculated in gray value.
Wherein, it is described that second grayscale mask, described first image and background image progress fusion treatment are obtained Second image includes:
Fusion treatment is carried out to second grayscale mask and described first image and obtains foreground image;
The gray value of pixel according to the gray value of pixel in the foreground image and the background image, really The gray value of pixel described in fixed second image.
Wherein, the pixel according to the gray value of pixel in the foreground image and the background image Gray value determines that the gray value of pixel described in second image includes:
Calculate the gray scale of pixel described in the gray value of pixel described in the foreground image and the background image The weighted average of value;
Using the weighted average as the gray value of pixel described in second image.
Wherein, the corresponding weights of pixel described in the foreground image is default transparent value.
Wherein, it is described to first grayscale mask carry out corrosion treatment corroded after mask include:
Obtain the gray value of other each pixels in first grayscale mask around target pixel points;
Minimum in the gray value of other each pixels one is chosen as described in the mask after the corrosion The gray value of target pixel points.
Wherein, it is described that second grayscale mask, described first image and background image progress fusion treatment are obtained Before second image, further include:
Gaussian Blur processing is carried out to second grayscale mask.
Wherein, it is described that second grayscale mask progress Gaussian Blur processing is included:
Obtain other each pixels in second grayscale mask around target pixel points and the target pixel points Distance;
According to other described each pixels and the distance of the target pixel points, other described each pixels pair are determined The weights answered;
According to the corresponding weights of other described each pixels, the weighting of the gray value of other each pixels is calculated Average value is as the gray value by Gaussian Blur treated target pixel points described in second grayscale mask.
Second aspect, an embodiment of the present invention provides a kind of image processing apparatus, including:
Processing module, for being handled the first image to obtain the first grayscale mask;
The processing module is additionally operable to carry out first grayscale mask mask after corrosion treatment is corroded;
The processing module is additionally operable to according to the mask after first grayscale mask and the corrosion, determines described The mask edge of one image;
Fusion Module obtains the second grayscale mask for the mask edge to be added in first grayscale mask;
The Fusion Module is additionally operable to melt second grayscale mask, described first image and background image Conjunction handles to obtain the second image.
Wherein, the processing module is additionally operable to the gray value of pixel in first grayscale mask subtracting the corruption The gray value of pixel described in the mask edge is calculated in the gray value of pixel described in mask after erosion.
Wherein, the Fusion Module is specifically used for:
Fusion treatment is carried out to second grayscale mask and described first image and obtains foreground image;
The gray value of pixel according to the gray value of pixel in the foreground image and the background image, really The gray value of pixel described in fixed second image.
Wherein, the Fusion Module is additionally operable to calculate the gray value of pixel described in the foreground image and the back of the body The weighted average of the gray value of pixel described in scape image;Using the weighted average as described in second image The gray value of pixel.
Wherein, the corresponding weights of pixel described in the foreground image is default transparent value.
Wherein, the processing module, be additionally operable to obtain in first grayscale mask around target pixel points other are each The gray value of a pixel;Minimum in the gray value of other each pixels one is chosen as covering after the corrosion The gray value of target pixel points described in film.
Wherein, the processing module is additionally operable to carry out Gaussian Blur processing to second grayscale mask.
Wherein, the processing module is specifically used for:
Obtain other each pixels in second grayscale mask around target pixel points and the target pixel points Distance;
According to other described each pixels and the distance of the target pixel points, other described each pixels pair are determined The weights answered;
According to the corresponding weights of other described each pixels, the weighting of the gray value of other each pixels is calculated Average value is as the gray value by Gaussian Blur treated target pixel points described in second grayscale mask.
The third aspect, this application provides a kind of image processing equipment, including:Processor, memory and communication bus, In, communication bus is used to implement connection communication between processor and memory, and processor performs the program stored in memory and uses Step in a kind of image processing method that above-mentioned first aspect offer is provided.
In a possible design, the image processing equipment that the application provides can include to perform in the above method The corresponding module of behavior.Module can be software and/or be hardware.
It is yet another aspect of the present invention to provide a kind of computer readable storage medium, in the computer readable storage medium It is stored with a plurality of instruction, described instruction is suitable for being loaded as processor and the method described in performing above-mentioned various aspects.
It is yet another aspect of the present invention to provide a kind of computer program product for including instruction, when it runs on computers When so that computer performs the method described in above-mentioned various aspects.
Implement the embodiment of the present invention, the first image is handled to obtain the first grayscale mask first;First gray scale is covered Film carries out the mask after corrosion treatment is corroded;Then according to the mask after the first grayscale mask and corrosion, the first figure is determined The mask edge of picture;Mask edge is added in the first grayscale mask and obtains the second grayscale mask;Finally the second gray scale is covered Film, the first image and background image carry out fusion treatment and obtain the second image.Due to mask edge region be foreground image and The transitional region of background image when carrying out Fuzzy Processing to image, is strengthened by the edge to mask so that this is excessively Region is more smooth naturally, improving the display effect of image.
Description of the drawings
Technical solution in order to illustrate the embodiments of the present invention more clearly or in background technology below will be implemented the present invention Attached drawing illustrates needed in example or background technology.
Fig. 1 is a kind of structure diagram of image processing system provided in an embodiment of the present invention;
Fig. 2 is a kind of flow diagram of image processing method provided in an embodiment of the present invention;
Fig. 3 (A) is a kind of schematic diagram of first image provided in an embodiment of the present invention;
Fig. 3 (B) is a kind of schematic diagram of first grayscale mask provided in an embodiment of the present invention;
Fig. 4 is a kind of schematic diagram of pixel provided in an embodiment of the present invention;
Fig. 5 is a kind of schematic diagram of edge detection provided in an embodiment of the present invention;
Fig. 6 is a kind of schematic diagram of image co-registration provided in an embodiment of the present invention;
Fig. 7 is a kind of flow diagram for image processing method that another embodiment of the present invention provides;
Fig. 8 is a kind of structure diagram of image processing apparatus provided in an embodiment of the present invention;
Fig. 9 is a kind of structure diagram for image processing equipment that the embodiment of the present invention proposes.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is part of the embodiment of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, the every other implementation that those of ordinary skill in the art are obtained without creative efforts Example, shall fall within the protection scope of the present invention.
Refer to Fig. 1, Fig. 1 is a kind of structure diagram of image processing system provided in an embodiment of the present invention, the image Processing system can include video camera 101, server 102 and user equipment 103, and video camera 101 can be used in pure color curtain Shooting video image or photo under cloth (e.g., green curtain or blue curtain), and by the video image of shooting or photo upload to server 102.Server 102 is used to that video image or photo handle by green curtain algorithm to extract foreground image, then by before Scape image is merged with background image, and the video image after fusion or photo finally are sent to user equipment 103.User sets Standby 103 receive the video image or photo after fusion, can show picture movable under various virtual scenes.
Refer to Fig. 2, Fig. 2 is a kind of flow diagram of image processing method provided in an embodiment of the present invention, this method Including but not limited to following steps:
S201 handles the first image to obtain the first grayscale mask.
In the specific implementation, can be split to the first image, judging the gray value of each pixel in the first image is It is no to be more than predetermined threshold value, if the gray value of some pixel is more than predetermined threshold value in the first image, by the value of the pixel It is determined as 1, if the value of the pixel is determined as by the gray value of some pixel no more than predetermined threshold value in the first image 0.So as to pluck out solid background in the first image, retain the foreground part in the first image, the image finally split is the One grayscale mask.Wherein, which is bianry image, and in the same size with original image, white portion can be prospect Image, black portions are background parts, and grey parts are the edge of foreground and background.
As shown in Fig. 3 (A), Fig. 3 (A) is a kind of schematic diagram of first image provided in an embodiment of the present invention.First figure As including solid background and personage's prospect, the first image is handled by green curtain algorithm.As shown in Fig. 3 (B), Fig. 3 (B) is A kind of schematic diagram of first grayscale mask provided in an embodiment of the present invention, white portion is personage's prospect in the first image, black Color part is the background in the first image.
S202 carries out first grayscale mask mask after corrosion treatment is corroded.
In the specific implementation, other each pixels in first grayscale mask around target pixel points can be obtained Gray value;Minimum in the gray value of other each pixels one is chosen as mesh described in the mask after the corrosion Mark the gray value of pixel.Mask after corrosion visually embeds a circle than the first grayscale mask.
As shown in figure 4, Fig. 4 includes 9 pixels, wherein, the pixel around intermediary image vegetarian refreshments 5 includes pixel 1st, pixel 2, pixel 3, pixel 4, pixel 6, pixel 7, pixel 8, pixel 9.Pixel can be respectively compared 1st, pixel 2, pixel 3, pixel 4, pixel 6, pixel 7, pixel 8, pixel 9 gray value size, choose Wherein gray value of the minimum gray value as intermediary image vegetarian refreshments 5.
Optionally, the structural element of 3x3 can be used, each pixel in the first grayscale mask is scanned, by structural elements 9 pixels in the first grayscale mask (bianry image) that element is covered with it do with operation respectively, if result is all 1, Then the value of intermediary image vegetarian refreshments is 1, and otherwise, the value of intermediary image vegetarian refreshments is 0.
S203 according to the mask after first grayscale mask and the corrosion, determines the mask side of described first image Edge.Wherein, edge of the mask edge between foreground part and background parts.
In the specific implementation, the gray value of pixel in first grayscale mask can be subtracted to the mask after the corrosion Described in pixel gray value, the gray value of pixel described in the mask edge is calculated.Due to covering after corrosion Film is different only on mask edge compared with the first grayscale mask, therefore the two is made difference and can obtain mask edge.
The mask edge is added in first grayscale mask and obtains the second grayscale mask by S204.
In the specific implementation, pixel described in the gray value of pixel and the first grayscale mask in mask edge can be calculated Gray value as pixel in the second grayscale mask of the sum of gray value, so as to be added to the edge of the first grayscale mask By force, strengthened first grayscale mask is the second grayscale mask.
As shown in figure 5, Fig. 5 is a kind of schematic diagram of edge detection provided in an embodiment of the present invention.It is as shown in the figure, right first First grayscale mask corroded after mask, then by the first grayscale mask subtract corrosion after mask covered Mask edge is finally added in the first grayscale mask and obtains the second grayscale mask by film edge.
S205 carries out fusion treatment to second grayscale mask, described first image and background image and obtains second Image.
In the specific implementation, any one background image can be chosen first, then to second grayscale mask and described First image carries out fusion treatment and obtains foreground image;Finally according to the gray value of pixel in the foreground image and selection The gray value of pixel described in the background image determines the gray value of pixel described in second image.
Further, it can calculate described in the gray value of pixel described in the foreground image and the background image The weighted average of the gray value of pixel;Using the weighted average as the gray scale of pixel described in second image Value.Wherein, the corresponding weights of pixel described in the foreground image is default transparent value.User can set default transparency It is set to 0.5 so that the edge of the image of synthesis reaches more smooth and natural.It is as follows:
Rbg=foreground*alpha+background* (1-alpha)
Wherein, foreground is the gray value of pixel in foreground image, and alpha is default transparency, Background is the gray value of pixel in background image.
As shown in fig. 6, Fig. 6 is a kind of schematic diagram of image co-registration provided in an embodiment of the present invention.A represents original graph in figure Picture, B represent the mask after Edge Enhancement, and C represents background image, and D is the new image after fusion.It can be first to original image Mask B after A and Edge Enhancement is merged to obtain foreground image, which retains character image part, then to preceding Scape image and background image C are merged, and new figure has been obtained so as to which the background in original image A is replaced with background image C As D.
In embodiments of the present invention, the first image is handled first to obtain the first grayscale mask;First gray scale is covered Film carries out the mask after corrosion treatment is corroded;Then according to the mask after the first grayscale mask and corrosion, the first figure is determined The mask edge of picture;Mask edge is added in the first grayscale mask and obtains the second grayscale mask;Finally the second gray scale is covered Film, the first image and background image carry out fusion treatment and obtain the second image.Due to mask edge region be foreground image and The transitional region of background image when carrying out Fuzzy Processing to image, is strengthened by the edge to mask so that this is excessively Region is more smooth naturally, improving the display effect of image.
Fig. 7 is referred to, Fig. 7 is a kind of flow diagram for image processing method that another embodiment of the present invention provides, should Method includes but not limited to following steps:
S701 handles the first image to obtain the first grayscale mask.It is identical with the operating procedure of a upper embodiment, this Embodiment repeats no more.
S702 carries out first grayscale mask mask after corrosion treatment is corroded.With the behaviour of a upper embodiment It is identical to make step, the present embodiment repeats no more.
S703 according to the mask after first grayscale mask and the corrosion, determines the mask side of described first image Edge.Identical with the operating procedure of a upper embodiment, the present embodiment repeats no more.
The mask edge is added in first grayscale mask and obtains the second grayscale mask by S704.It is real with upper one The operating procedure for applying example is identical, and the present embodiment repeats no more.
S705 carries out Gaussian Blur processing to second grayscale mask.
In the specific implementation, can obtain other each pixels in second grayscale mask around target pixel points with The distance of the target pixel points;According to the distance of other described each pixels and the target pixel points, determine it is described its The corresponding weights of his each pixel;According to the corresponding weights of other described each pixels, other described each pixels are calculated The weighted average of the gray value of point is used as by Gaussian Blur treated object pixel described in second grayscale mask The gray value of point.Wherein, the formula for calculating the corresponding weights of each pixel is as follows:
Wherein, A is constant, x0、y0For the coordinate of target pixel points, σx、σyFor preset variance, x, y are any point Coordinate.By formula it is found that the more remote pixel of distance objective pixel, the weights of calculating are smaller;Distance objective pixel Nearer pixel, the weights of calculating are bigger.The corresponding weights of each pixel are in normal distribution state.
It should be noted that in the prior art scheme, when Gaussian Blur is used to be smoothed, due to not examining Consider edge, although simple Gaussian Blur so that edge sawtooth makes moderate progress, will also result in the smudgy of edge change, It shows unnatural.The embodiment of the present invention handles to obtain mask edge in a manner that corrosion makes the difference, and is then superimposed mask edge Onto grayscale mask, the edge of grayscale mask is strengthened.Gaussian Blur processing finally is carried out to the mask behind reinforcement edge When, it can achieve the effect that improve sawtooth while keep edge.
S706 carries out fusion treatment to second grayscale mask, described first image and background image and obtains second Image.Identical with the operating procedure of a upper embodiment, the present embodiment repeats no more.
The embodiment of the present invention can be applied to weather forecast, live news or film special efficacy etc..For example, under green curtain background The action of performer is shot, the raw video image of shooting includes green curtain background and personage's prospect.First to original video figure It handles to obtain grayscale mask as carrying out green curtain, grayscale mask white portion is personage's prospect, and black portions are background image, secondly Grayscale mask is corroded, the mask after corrosion visually embeds a circle than the grayscale mask before corrosion.It then will corrosion The grayscale mask that preceding grayscale mask subtracts after corrosion obtains mask edge, the grayscale mask before corrosion that mask edge is added to On obtain new grayscale mask, realize the effect strengthened mask edge.Finally to new by Gaussian Blur processing Mask, raw video image and the background image arbitrarily chosen are synthesized.When the background image of selection is fantasy scene, Performer can be placed oneself in the midst of in fantasy scene, fantasy effect is shown to spectators;It, can when the background image of selection is scenery with hills and waters scene Among performer is placed oneself in the midst of scenery with hills and waters, different beautiful scenerys is shown to spectators.Due to covering between background image and personage's prospect Film edge is strengthened, in the sawtooth for carrying out improving mask edge to mask during Gaussian Blur processing so that the image of synthesis Display is more smooth natural.
The device of the embodiment of the present invention is provided below in the above-mentioned method for illustrating the embodiment of the present invention.
As shown in figure 8, Fig. 8 is a kind of structure diagram of image processing apparatus provided in an embodiment of the present invention.As schemed Show, the device in the embodiment of the present invention includes:
Processing module 801, for being handled the first image to obtain the first grayscale mask.
In the specific implementation, can be split to the first image, judging the gray value of each pixel in the first image is It is no to be more than predetermined threshold value, if the gray value of some pixel is more than predetermined threshold value in the first image, by the value of the pixel It is determined as 1, if the value of the pixel is determined as by the gray value of some pixel no more than predetermined threshold value in the first image 0.So as to pluck out solid background in the first image, retain the foreground part in the first image, the image finally split is the One grayscale mask.Wherein, which is bianry image, and in the same size with original image, white portion can be prospect Image, black portions are background parts, and grey parts are the edge of foreground and background.
As shown in Fig. 3 (A), Fig. 3 (A) is a kind of schematic diagram of first image provided in an embodiment of the present invention.First figure As including solid background and personage's prospect, the first image is handled by green curtain algorithm.As shown in Fig. 3 (B), Fig. 3 (B) is A kind of schematic diagram of first grayscale mask provided in an embodiment of the present invention, white portion is personage's prospect in the first image, black Color part is the solid background in the first image.
Processing module 801 is additionally operable to carry out first grayscale mask mask after corrosion treatment is corroded.
In the specific implementation, other each pixels in first grayscale mask around target pixel points can be obtained Gray value;Minimum in the gray value of other each pixels one is chosen as mesh described in the mask after the corrosion Mark the gray value of pixel.Mask after corrosion visually embeds a circle than the first grayscale mask.
As shown in figure 4, Fig. 4 includes 9 pixels, wherein, the pixel around intermediary image vegetarian refreshments 5 includes pixel 1st, pixel 2, pixel 3, pixel 4, pixel 6, pixel 7, pixel 8, pixel 9.Pixel can be respectively compared 1st, pixel 2, pixel 3, pixel 4, pixel 6, pixel 7, pixel 8, pixel 9 gray value size, choose Wherein gray value of the minimum gray value as intermediary image vegetarian refreshments 5.
Optionally, the structural element of 3x3 can be used, each pixel in the first grayscale mask is scanned, by structural elements 9 pixels in the first grayscale mask (bianry image) that element is covered with it do with operation respectively, if result is all 1, Then the value of intermediary image vegetarian refreshments is 1, and otherwise, the value of intermediary image vegetarian refreshments is 0.
Processing module 801 is additionally operable to, according to the mask after first grayscale mask and the corrosion, determine described first The mask edge of image.Wherein, edge of the mask edge between foreground part and background parts.
In the specific implementation, the gray value of pixel in first grayscale mask can be subtracted to the mask after the corrosion Described in pixel gray value, the gray value of pixel described in the mask edge is calculated.Due to covering after corrosion Film is different only on mask edge compared with the first grayscale mask, therefore the two is obtained mask edge as difference.
Optionally, processing module 801 are additionally operable to carry out Gaussian Blur processing to second grayscale mask.
Specifically, can obtain other each pixels in second grayscale mask around target pixel points with it is described The distance of target pixel points;According to the distance of other described each pixels and the target pixel points, determine that described other are each The corresponding weights of a pixel;According to the corresponding weights of other described each pixels, other each pixels are calculated The weighted average of gray value is as by Gaussian Blur treated target pixel points described in second grayscale mask Gray value.Wherein, the formula for calculating the corresponding weights of each pixel is as follows:
Wherein, A is constant, x0、y0For the coordinate of target pixel points, σx、σyFor preset variance, x, y are any point Coordinate.The more remote pixel of distance objective pixel, the weights of calculating are smaller;The nearer pixel of distance objective pixel Point, the weights of calculating are bigger.The corresponding weights of pixel are in normal distribution state.
It should be noted that in the prior art scheme, when Gaussian Blur is used to be smoothed, due to not examining Consider edge, although simple Gaussian Blur so that edge sawtooth makes moderate progress, will also result in the smudgy of edge change, It shows unnatural.The embodiment of the present invention handles to obtain mask edge in a manner that corrosion makes the difference, and is then superimposed mask edge Onto grayscale mask, the edge of grayscale mask is strengthened.Gaussian Blur processing finally is carried out to the mask behind reinforcement edge When, it can achieve the effect that improve sawtooth while keep edge.
Fusion Module 802, being additionally operable to the mask edge being added in first grayscale mask obtains the second gray scale Mask.
In the specific implementation, pixel described in the gray value of pixel and the first grayscale mask in mask edge can be calculated Gray value as pixel in the second grayscale mask of the sum of gray value, so as to be added to the edge of the first grayscale mask By force, strengthened first grayscale mask is the second grayscale mask.
As shown in figure 5, Fig. 5 is a kind of schematic diagram of edge detection provided in an embodiment of the present invention.It is as shown in the figure, right first First grayscale mask corroded after mask, then by the first grayscale mask subtract corrosion after mask covered Mask edge is finally added in the first grayscale mask and obtains the second grayscale mask by film edge.
Fusion Module 802 is additionally operable to merge second grayscale mask, described first image and background image Processing obtains the second image.
In the specific implementation, any one background image can be chosen first, then to second grayscale mask and described First image carries out fusion treatment and obtains foreground image;Finally according to the gray value of pixel in the foreground image and selection The gray value of pixel described in the background image determines the gray value of pixel described in second image.
Further, it can calculate described in the gray value of pixel described in the foreground image and the background image The weighted average of the gray value of pixel;Using the weighted average as the gray scale of pixel described in second image Value.Wherein, the corresponding weights of pixel described in the foreground image is default transparent value.User can set default transparency It is set to 0.5 so that the edge of the image of synthesis reaches more smooth and natural.It is as follows:
Rbg=foreground*alpha+background* (1-alpha)
Wherein, foreground is the gray value of pixel in foreground image, and alpha is default transparency, Background is the gray value of pixel in background image.
As shown in fig. 6, Fig. 6 is a kind of schematic diagram of image co-registration provided in an embodiment of the present invention.A represents original graph in figure Picture, B represent the mask after Edge Enhancement, and C represents background image, and D is the new image after fusion.It can be first to original image Mask B after A and Edge Enhancement is merged to obtain foreground image, which retains character image part, then to preceding Scape image and background image C are merged, and new figure has been obtained so as to which the background in original image A is replaced with background image C As D.
The embodiment of the present invention can be applied to weather forecast, live news or film special efficacy etc..For example, under green curtain background The action of performer is shot, the raw video image of shooting includes green curtain background and personage's prospect.First to original video figure It handles to obtain grayscale mask as carrying out green curtain, grayscale mask white portion is personage's prospect, and black portions are background image, secondly Grayscale mask is corroded, the mask after corrosion visually embeds a circle than the grayscale mask before corrosion.It then will corrosion The grayscale mask that preceding grayscale mask subtracts after corrosion obtains mask edge, the grayscale mask before corrosion that mask edge is added to On obtain new grayscale mask, realize the effect strengthened mask edge.Finally to new by Gaussian Blur processing Mask, raw video image and the background image arbitrarily chosen are synthesized.When the background image of selection is fantasy scene, Performer can be placed oneself in the midst of in fantasy scene, fantasy effect is shown to spectators;It, can when the background image of selection is scenery with hills and waters scene Among performer is placed oneself in the midst of scenery with hills and waters, different beautiful scenerys is shown to spectators.Due to covering between background image and personage's prospect Film edge is strengthened, in the sawtooth for carrying out improving mask edge to mask during Gaussian Blur processing so that the image of synthesis Display is more smooth natural.
In embodiments of the present invention, the first image is handled first to obtain the first grayscale mask;First gray scale is covered Film carries out the mask after corrosion treatment is corroded;Then according to the mask after the first grayscale mask and corrosion, the first figure is determined The mask edge of picture;Mask edge is added in the first grayscale mask and obtains the second grayscale mask;Finally the second gray scale is covered Film, the first image and background image carry out fusion treatment and obtain the second image.Due to mask edge region be foreground image and The transitional region of background image when carrying out Fuzzy Processing to image, is strengthened by the edge to mask so that this is excessively Region is more smooth naturally, improving the display effect of image.
Please continue to refer to Fig. 9, Fig. 9 is a kind of structure diagram for image processing equipment that the embodiment of the present invention proposes.Such as Shown in figure, which can include:At least one processor 901, at least one communication interface 902 are at least one Memory 903 and at least one communication bus 904.
Wherein, processor 901 can be central processor unit, general processor, digital signal processor, special integrated Circuit, field programmable gate array either other programmable logic device, transistor logic, hardware component or it is arbitrary Combination.It can be realized or performed with reference to the described various illustrative logic blocks of present disclosure, module and electricity Road.The processor can also be the combination for realizing computing function, such as be combined comprising one or more microprocessors that number is believed Combination of number processor and microprocessor etc..Communication bus 904 can be Peripheral Component Interconnect standard PCI bus or extension work Industry normal structure eisa bus etc..The bus can be divided into address bus, data/address bus, controlling bus etc..For ease of representing, It is only represented in Fig. 9 with a thick line, it is not intended that an only bus or a type of bus.Communication bus 904 is used for Realize the connection communication between these components.Wherein, the communication interface 902 of equipment is used for and other nodes in the embodiment of the present application Equipment carries out the communication of signaling or data.Memory 903 can include volatile memory, such as non-volatile dynamic random is deposited Take memory (Nonvolatile Random Access Memory, NVRAM), phase change random access memory (Phase Change RAM, PRAM), magnetic-resistance random access memory (Magetoresistive RAM, MRAM) etc., can also include non- Volatile memory, for example, at least a disk memory, Electrical Erasable programmable read only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), flush memory device, such as anti-or flash memory (NOR Flash memory) or anti-and flash memory (NAND flash memory), semiconductor devices, such as solid state disk (Solid State Disk, SSD) etc..Memory 903 optionally can also be at least one storage for being located remotely from aforementioned processor 901 Device.Batch processing code is stored in memory 903, and processor 901 performs the program in memory 903.
First image is handled to obtain the first grayscale mask;
The mask after corrosion treatment is corroded is carried out to first grayscale mask;
According to the mask after first grayscale mask and the corrosion, the mask edge of described first image is determined;
The mask edge is added in first grayscale mask and obtains the second grayscale mask;
Fusion treatment is carried out to second grayscale mask, described first image and background image and obtains the second image.
Optionally, processor 901 is additionally operable to perform following operating procedure:
The gray value of pixel in first grayscale mask is subtracted into pixel described in the mask after the corrosion The gray value of pixel described in the mask edge is calculated in gray value.
Optionally, processor 901 is additionally operable to perform following operating procedure:
Fusion treatment is carried out to second grayscale mask and described first image and obtains foreground image;
The gray value of pixel according to the gray value of pixel in the foreground image and the background image, really The gray value of pixel described in fixed second image.
Optionally, processor 901 is additionally operable to perform following operating procedure:
Calculate the gray scale of pixel described in the gray value of pixel described in the foreground image and the background image The weighted average of value;
Using the weighted average as the gray value of pixel described in second image.
Wherein, the corresponding weights of pixel described in the foreground image is default transparent value.
Optionally, processor 901 is additionally operable to perform following operating procedure:
Obtain the gray value of other each pixels in first grayscale mask around target pixel points;
Minimum in the gray value of other each pixels one is chosen as described in the mask after the corrosion The gray value of target pixel points.
Optionally, processor 901 is additionally operable to perform following operating procedure:
Gaussian Blur processing is carried out to second grayscale mask.
Optionally, processor 901 is additionally operable to perform following operating procedure:
Obtain other each pixels in second grayscale mask around target pixel points and the target pixel points Distance;
According to other described each pixels and the distance of the target pixel points, other described each pixels pair are determined The weights answered;
According to the corresponding weights of other described each pixels, the weighting of the gray value of other each pixels is calculated Average value is as the gray value by Gaussian Blur treated target pixel points described in second grayscale mask.
Further, processor can also be matched with memory and communication interface, performed and schemed in foregoing invention embodiment As the operation of processing unit.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or its arbitrary combination real It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.The computer program Product includes one or more computer instructions.When loading on computers and performing the computer program instructions, all or It partly generates according to the flow or function described in the embodiment of the present application.The computer can be all-purpose computer, special meter Calculation machine, computer network or other programmable devices.The computer instruction can be stored in computer readable storage medium In or from a computer readable storage medium to another computer readable storage medium transmit, for example, the computer Instruction can pass through wired (such as coaxial cable, optical fiber, number from a web-site, computer, server or data center User's line (DSL)) or wireless (such as infrared, wireless, microwave etc.) mode to another web-site, computer, server or Data center is transmitted.The computer readable storage medium can be any usable medium that computer can access or It is the data storage devices such as server, the data center integrated comprising one or more usable mediums.The usable medium can be with It is magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (for example, DVD) or semiconductor medium (such as solid state disk Solid State Disk (SSD)) etc..
Above-described specific embodiment has carried out further the purpose, technical solution and advantageous effect of the application It is described in detail.It is all within spirit herein and principle, any modification, equivalent replacement, improvement and so on should be included in Within the protection domain of the application.

Claims (15)

1. a kind of image processing method, which is characterized in that the method includes:
First image is handled to obtain the first grayscale mask;
The mask after corrosion treatment is corroded is carried out to first grayscale mask;
According to the mask after first grayscale mask and the corrosion, the mask edge of described first image is determined;
The mask edge is added in first grayscale mask and obtains the second grayscale mask;
Fusion treatment is carried out to second grayscale mask, described first image and background image and obtains the second image.
2. the method as described in claim 1, which is characterized in that it is described according to first grayscale mask and the corrosion after Mask determines that the mask edge of described first image includes:
The gray value of pixel in first grayscale mask is subtracted to the gray scale of pixel described in the mask after the corrosion The gray value of pixel described in the mask edge is calculated in value.
3. the method as described in claim 1, which is characterized in that it is described to second grayscale mask, described first image with And background image progress fusion treatment obtains the second image and includes:
Fusion treatment is carried out to second grayscale mask and described first image and obtains foreground image;
The gray value of pixel, determines institute according to the gray value of pixel in the foreground image and the background image State the gray value of pixel described in the second image.
4. method as claimed in claim 3, which is characterized in that it is described according to the gray value of pixel in the foreground image and The gray value of pixel described in the background image determines that the gray value of pixel described in second image includes:
Calculate the gray value of pixel described in the gray value of pixel described in the foreground image and the background image Weighted average;
Using the weighted average as the gray value of pixel described in second image.
5. method as claimed in claim 4, which is characterized in that the corresponding weights of pixel described in the foreground image is pre- If transparent value.
6. such as claim 1-5 any one of them methods, which is characterized in that described that first grayscale mask is corroded Mask after processing is corroded includes:
Obtain the gray value of other each pixels in first grayscale mask around target pixel points;
Minimum in the gray value of other each pixels one is chosen as target described in the mask after the corrosion The gray value of pixel.
7. such as claim 1-5 any one of them methods, which is characterized in that it is described to second grayscale mask, described the Before one image and background image progress fusion treatment obtain the second image, further include:
Gaussian Blur processing is carried out to second grayscale mask.
8. the method for claim 7, which is characterized in that described that Gaussian Blur processing is carried out to second grayscale mask Including:
Obtain other each pixels in second grayscale mask around target pixel points and the target pixel points away from From;
According to other described each pixels and the distance of the target pixel points, determine that other described each pixels are corresponding Weights;
According to the corresponding weights of other described each pixels, the weighted average of the gray value of other each pixels is calculated Value is as the gray value for passing through Gaussian Blur treated target pixel points described in second grayscale mask.
9. a kind of image processing apparatus, which is characterized in that described device includes:
Processing module, for being handled the first image to obtain the first grayscale mask;
The processing module is additionally operable to carry out first grayscale mask mask after corrosion treatment is corroded;
The processing module is additionally operable to, according to the mask after first grayscale mask and the corrosion, determine first figure The mask edge of picture;
Fusion Module obtains the second grayscale mask for the mask edge to be added in first grayscale mask;
The Fusion Module is additionally operable to carry out at fusion second grayscale mask, described first image and background image Reason obtains the second image.
10. device as claimed in claim 9, which is characterized in that
The processing module is additionally operable to subtracting the gray value of pixel in first grayscale mask into the mask after the corrosion Described in pixel gray value, the gray value of pixel described in the mask edge is calculated.
11. device as claimed in claim 9, which is characterized in that the Fusion Module is specifically used for:
Fusion treatment is carried out to second grayscale mask and described first image and obtains foreground image;
The gray value of pixel, determines institute according to the gray value of pixel in the foreground image and the background image State the gray value of pixel described in the second image.
12. device as claimed in claim 11, which is characterized in that
The Fusion Module is additionally operable to calculate institute in the gray value of pixel described in the foreground image and the background image State the weighted average of the gray value of pixel;Using the weighted average as the ash of pixel described in second image Angle value.
13. device as claimed in claim 12, which is characterized in that the corresponding weights of pixel described in the foreground image is Default transparent value.
14. such as claim 9-13 any one of them devices, which is characterized in that the processing module is additionally operable to described in acquisition The gray value of other each pixels in first grayscale mask around target pixel points;Choose other each pixels A minimum gray value as target pixel points described in the mask after the corrosion in gray value.
15. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has a plurality of finger It enables, described instruction is suitable for being loaded by processor and being performed such as claim 1-8 any one of them methods.
CN201711293350.1A 2017-12-07 2017-12-07 Image processing method and related equipment Active CN108171677B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711293350.1A CN108171677B (en) 2017-12-07 2017-12-07 Image processing method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711293350.1A CN108171677B (en) 2017-12-07 2017-12-07 Image processing method and related equipment

Publications (2)

Publication Number Publication Date
CN108171677A true CN108171677A (en) 2018-06-15
CN108171677B CN108171677B (en) 2023-03-24

Family

ID=62525575

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711293350.1A Active CN108171677B (en) 2017-12-07 2017-12-07 Image processing method and related equipment

Country Status (1)

Country Link
CN (1) CN108171677B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110298813A (en) * 2019-06-28 2019-10-01 北京金山安全软件有限公司 Method and device for processing picture and electronic equipment
CN110717919A (en) * 2019-10-15 2020-01-21 阿里巴巴(中国)有限公司 Image processing method, device, medium and computing equipment
CN111127303A (en) * 2018-11-01 2020-05-08 Tcl集团股份有限公司 Background blurring method and device, terminal equipment and computer readable storage medium
CN111179282A (en) * 2019-12-27 2020-05-19 Oppo广东移动通信有限公司 Image processing method, image processing apparatus, storage medium, and electronic device
CN111598903A (en) * 2020-05-21 2020-08-28 Oppo广东移动通信有限公司 Portrait segmentation method, portrait segmentation device, storage medium and electronic equipment
CN112381222A (en) * 2020-11-12 2021-02-19 北京乐学帮网络技术有限公司 Sample generation method and device, computer equipment and storage medium
CN112561847A (en) * 2020-12-24 2021-03-26 Oppo广东移动通信有限公司 Image processing method and device, computer readable medium and electronic device
CN112927144A (en) * 2019-12-05 2021-06-08 北京迈格威科技有限公司 Image enhancement method, image enhancement device, medium, and electronic apparatus
CN113965790A (en) * 2020-07-20 2022-01-21 Tcl科技集团股份有限公司 Image display processing method, storage medium and terminal equipment
CN114816169A (en) * 2022-06-29 2022-07-29 荣耀终端有限公司 Desktop icon display method and device and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214355A (en) * 2011-05-20 2011-10-12 西安工程大学 Cutout method of clothing display material
CN105100646A (en) * 2015-08-31 2015-11-25 北京奇艺世纪科技有限公司 Video processing method and device
CN105450946A (en) * 2014-06-09 2016-03-30 华为技术有限公司 Image processing method and device and calculation device
CN106097380A (en) * 2016-08-03 2016-11-09 中国电力科学研究院 A kind of system and method for core rod of insulator defect on-line checking based on image
US20170213112A1 (en) * 2016-01-25 2017-07-27 Adobe Systems Incorporated Utilizing deep learning for automatic digital image segmentation and stylization
CN107123088A (en) * 2017-04-21 2017-09-01 山东大学 A kind of method of automatic replacing photo background color
CN107230182A (en) * 2017-08-03 2017-10-03 腾讯科技(深圳)有限公司 A kind of processing method of image, device and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214355A (en) * 2011-05-20 2011-10-12 西安工程大学 Cutout method of clothing display material
CN105450946A (en) * 2014-06-09 2016-03-30 华为技术有限公司 Image processing method and device and calculation device
CN105100646A (en) * 2015-08-31 2015-11-25 北京奇艺世纪科技有限公司 Video processing method and device
US20170213112A1 (en) * 2016-01-25 2017-07-27 Adobe Systems Incorporated Utilizing deep learning for automatic digital image segmentation and stylization
CN106097380A (en) * 2016-08-03 2016-11-09 中国电力科学研究院 A kind of system and method for core rod of insulator defect on-line checking based on image
CN107123088A (en) * 2017-04-21 2017-09-01 山东大学 A kind of method of automatic replacing photo background color
CN107230182A (en) * 2017-08-03 2017-10-03 腾讯科技(深圳)有限公司 A kind of processing method of image, device and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ZHU XINJUAN ET AL.: "Apparel image matting and applications in e-commerce", 《2011 6TH IEEE JOINT INTERNATIONAL INFORMATION TECHNOLOGY AND ARTIFICIAL INTELLIGENCE CONFERENCE》 *
胡媛媛: "基于形态学的图像分割方法的研究与应用", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111127303A (en) * 2018-11-01 2020-05-08 Tcl集团股份有限公司 Background blurring method and device, terminal equipment and computer readable storage medium
CN110298813A (en) * 2019-06-28 2019-10-01 北京金山安全软件有限公司 Method and device for processing picture and electronic equipment
CN110717919A (en) * 2019-10-15 2020-01-21 阿里巴巴(中国)有限公司 Image processing method, device, medium and computing equipment
CN112927144A (en) * 2019-12-05 2021-06-08 北京迈格威科技有限公司 Image enhancement method, image enhancement device, medium, and electronic apparatus
CN111179282A (en) * 2019-12-27 2020-05-19 Oppo广东移动通信有限公司 Image processing method, image processing apparatus, storage medium, and electronic device
CN111179282B (en) * 2019-12-27 2024-04-23 Oppo广东移动通信有限公司 Image processing method, image processing device, storage medium and electronic apparatus
CN111598903B (en) * 2020-05-21 2023-09-29 Oppo广东移动通信有限公司 Portrait segmentation method, device, storage medium and electronic equipment
CN111598903A (en) * 2020-05-21 2020-08-28 Oppo广东移动通信有限公司 Portrait segmentation method, portrait segmentation device, storage medium and electronic equipment
CN113965790A (en) * 2020-07-20 2022-01-21 Tcl科技集团股份有限公司 Image display processing method, storage medium and terminal equipment
CN112381222A (en) * 2020-11-12 2021-02-19 北京乐学帮网络技术有限公司 Sample generation method and device, computer equipment and storage medium
CN112561847A (en) * 2020-12-24 2021-03-26 Oppo广东移动通信有限公司 Image processing method and device, computer readable medium and electronic device
CN112561847B (en) * 2020-12-24 2024-04-12 Oppo广东移动通信有限公司 Image processing method and device, computer readable medium and electronic equipment
CN114816169A (en) * 2022-06-29 2022-07-29 荣耀终端有限公司 Desktop icon display method and device and storage medium

Also Published As

Publication number Publication date
CN108171677B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
CN108171677A (en) A kind of image processing method and relevant device
Cui et al. Multitask aet with orthogonal tangent regularity for dark object detection
Wang et al. Gladnet: Low-light enhancement network with global awareness
CN111028189B (en) Image processing method, device, storage medium and electronic equipment
CN108335279B (en) Image fusion and HDR imaging
CN108668093B (en) HDR image generation method and device
CN107749062B (en) Image processing method and device
US9098534B2 (en) Image display system, image display method, social network service system, and computer-readable medium
CN110889824A (en) Sample generation method and device, electronic equipment and computer readable storage medium
CN109785264B (en) Image enhancement method and device and electronic equipment
Guo et al. Single image dehazing based on fusion strategy
CN112767281A (en) Image ghost eliminating method, device, electronic equipment and storage medium
CN107105172B (en) Focusing method and device
CN112561777A (en) Method and device for adding light spots to image
CN111953893B (en) High dynamic range image generation method, terminal device and storage medium
KR100875780B1 (en) Image processing apparatus and method, and imaging device
CN107564085B (en) Image warping processing method and device, computing equipment and computer storage medium
CN107766803B (en) Video character decorating method and device based on scene segmentation and computing equipment
CN111311481A (en) Background blurring method and device, terminal equipment and storage medium
GB2488191A (en) Reducing Noise in Graphical Images using a Depth-Based Order Filter
JP2009237927A (en) Image composition method and device
CN112887639A (en) Image processing method, device, system, electronic device and storage medium
US20220398704A1 (en) Intelligent Portrait Photography Enhancement System
CN109658360B (en) Image processing method and device, electronic equipment and computer storage medium
WO2022247702A1 (en) Image processing method and apparatus, electronic device, and storage medium

Legal Events

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