CN110636331B - Method and apparatus for processing video - Google Patents

Method and apparatus for processing video Download PDF

Info

Publication number
CN110636331B
CN110636331B CN201910919234.9A CN201910919234A CN110636331B CN 110636331 B CN110636331 B CN 110636331B CN 201910919234 A CN201910919234 A CN 201910919234A CN 110636331 B CN110636331 B CN 110636331B
Authority
CN
China
Prior art keywords
image
channel
value
video
original
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910919234.9A
Other languages
Chinese (zh)
Other versions
CN110636331A (en
Inventor
丁予康
张赫男
刘霄
孙昊
文石磊
丁二锐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201910919234.9A priority Critical patent/CN110636331B/en
Publication of CN110636331A publication Critical patent/CN110636331A/en
Application granted granted Critical
Publication of CN110636331B publication Critical patent/CN110636331B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements

Abstract

The embodiment of the disclosure discloses a method and a device for processing video. One embodiment of the method comprises: for the video frames in the acquired original video, the following processing operations are performed: converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame; determining an updated value according to the original value of the L channel to obtain a brightness updated image; performing edge extraction on the L channel to obtain an edge image; processing the original values of the channel A and the channel B respectively to obtain a first image for the channel A and a second image for the channel B; obtaining an RGB image based on the luminance update image, the edge image, the first image, and the second image; generating a video based on the obtained RGB image, and outputting the generated video. The embodiment realizes the conversion of the original video into the cartoon-style video.

Description

Method and apparatus for processing video
Technical Field
The disclosed embodiments relate to the field of computer technologies, and in particular, to a method and an apparatus for processing a video.
Background
The cartoon is a popular artistic form and has strong entertainment. At present, a user can convert a video stored in a terminal device (e.g., a camera or a mobile phone) or shot in real time into a cartoon-style video through an existing video processing mode. At present, most of the main video processing methods are based on neural networks. For example, a neural network is trained using a large amount of sample data, and then the trained neural network is used to process a video, thereby obtaining a cartoon-style video. Generally, the neural network has a large calculation amount and needs to be supported by higher hardware devices. In addition, the video frames in the video can be processed by using a more traditional image processing mode, so that the cartoon-style video is obtained. For example, edge extraction is firstly carried out on the video frame based on a filtering mode, and then cartoon style conversion of the video frame is realized by using a brightness processing mode. The conventional image processing method is poor in processing of image brightness, color and the like, and thus the effect of a caricatured image is poor.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for processing video.
In a first aspect, an embodiment of the present disclosure provides a method for processing video, where the method includes: for the video frames in the acquired original video, the following processing operations are performed: converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame; determining an updated value according to the original value of the L channel to obtain a brightness updated image; performing edge extraction on the L channel to obtain an edge image; processing the original values of the channel A and the channel B respectively to obtain a first image for the channel A and a second image for the channel B; obtaining an RGB image based on the luminance update image, the edge image, the first image, and the second image; generating a video based on the obtained RGB image, and outputting the generated video.
In some embodiments, the obtaining an RGB image based on the luminance update image, the edge image, the first image, and the second image includes: converting an LAB image determined based on the luminance update image, the first image, and the second image into an initial RGB image; taking the pixel points with the value of the pixel points in the edge image larger than a preset threshold value as target pixel points; and replacing the value of the corresponding pixel point in the initial RGB image by using the value of the target pixel point to obtain the RGB image.
In some embodiments, the determining an updated value according to the original value of the L channel to obtain a luminance updated image includes: for the original value in the L channel, determining a corresponding brightness sample value of the original value based on a predetermined corresponding relation between a brightness value interval and a brightness sample value and the brightness value interval to which the original value belongs; determining the difference value of the original value and the brightness sample value corresponding to the original value; determining an updated value of the original value based on the difference and the original value; and obtaining a brightness updating image based on the updating value of the original value in the L channel.
In some embodiments, the performing edge extraction on the L channel to obtain an edge image includes: filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph; filtering the original value of the L channel of the video frame by using a preset second Gaussian blur core to obtain a second filtering graph; and performing linear processing on the first filter image and the second filter image to obtain an edge image.
In some embodiments, the processing the original values of the a channel and the B channel respectively to obtain a first image for the a channel and a second image for the B channel includes: obtaining a first image based on a preset first coefficient, a preset first constant and the original value of the channel A; and obtaining a second image based on a preset second coefficient, a preset second constant and the original value of the B channel.
In a second aspect, an embodiment of the present disclosure provides an apparatus for processing video, where the apparatus includes: an execution unit configured to execute a preset processing operation on a video frame in the acquired original video, wherein the execution unit includes: a conversion unit configured to convert the video frame into an LAB mode, resulting in an L channel, an a channel, and a B channel of the video frame; the updating unit is configured to determine an updating value according to the original value of the L channel to obtain a brightness updating image; an extraction unit configured to perform edge extraction on the L channel to obtain an edge image; a processing unit configured to process original values of the a channel and the B channel, respectively, to obtain a first image for the a channel and a second image for the B channel; a generating unit configured to obtain an RGB image based on the luminance update image, the edge image, the first image, and the second image; an output unit configured to generate a video based on the obtained RGB image, and output the generated video.
In some embodiments, the generating unit is further configured to: converting an LAB image determined based on the luminance update image, the first image, and the second image into an initial RGB image; taking the pixel points with the value of the pixel points in the edge image larger than a preset threshold value as target pixel points; and replacing the value of the corresponding pixel point in the initial RGB image by using the value of the target pixel point to obtain the RGB image.
In some embodiments, the update unit is further configured to: for the original value in the L channel, determining a corresponding brightness sample value of the original value based on a predetermined corresponding relation between a brightness value interval and a brightness sample value and the brightness value interval to which the original value belongs; determining the difference value of the original value and the brightness sample value corresponding to the original value; determining an updated value of the original value based on the difference and the original value; and obtaining a brightness updating image based on the updating value of the original value in the L channel.
In some embodiments, the above extraction unit is further configured to: filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph; filtering the original value of the L channel of the video frame by using a preset second Gaussian blur core to obtain a second filtering graph; and performing linear processing on the first filter image and the second filter image to obtain an edge image.
In some embodiments, the processing unit is further configured to: obtaining a first image based on a preset first coefficient, a preset first constant and the original value of the channel A; and obtaining a second image based on a preset second coefficient, a preset second constant and the original value of the B channel.
In a third aspect, an embodiment of the present disclosure provides an apparatus, including: one or more processors; a storage device, on which one or more programs are stored, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation manner of the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for processing the video, firstly, the following processing operations are executed for each video frame in the acquired original video: and step S1, converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame. In step S2, an updated value is determined according to the original value of the L channel, and a luminance updated image is obtained. And step S3, performing edge extraction on the L channel to obtain an edge image. Step S4, processing the original values of the a channel and the B channel respectively to obtain a first image for the a channel and a second image for the B channel. In step S5, an RGB image is obtained based on the luminance update image, the edge image, the first image, and the second image. Thereafter, a video is generated based on the obtained RGB image, and the generated video is output. Therefore, the original values of the L channel, the A channel and the B channel of each video frame in the original video are processed to obtain the video with the cartoon style, and the conversion from the original video to the video with the cartoon style is realized.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for processing video, according to the present disclosure;
FIG. 3 is a schematic diagram of one application scenario of a method for processing video according to the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a method for processing video according to the present disclosure;
FIG. 5 is a schematic block diagram illustrating one embodiment of an apparatus for processing video according to the present disclosure;
FIG. 6 is a block diagram of a computer system suitable for use in implementing a terminal device of an embodiment of the disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 of a method for processing video or an apparatus for processing video to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as video processing software, image processing software, a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting video processing, including but not limited to smart cameras, smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for video playing on the terminal devices 101, 102, 103. The backend server may process the received data such as video and feed back the processing result (e.g., cartoon-style video) to the terminal devices 101, 102, 103.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the server 105 is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that the method for processing video provided by the embodiment of the present disclosure may be executed by the terminal devices 101, 102, and 103, or may be executed by the server 105. Accordingly, the apparatus for processing video may be provided in the terminal devices 101, 102, 103, or in the server 105. This is not limited in this application.
With continued reference to fig. 2, a flow 200 of one embodiment of a method for processing video in accordance with the present disclosure is shown. The method for processing video comprises the following steps:
in step 201, the following processing operation steps 2011-2015 are executed for the video frames in the acquired original video.
In the present embodiment, an executing subject of the method for processing video (e.g., the terminal apparatus 101, 102, 103 or the server 105 shown in fig. 1) may execute the following preset processing operation steps 2011-2015 for each video frame in the acquired original video.
Here, when the execution subject is a terminal device, the original video may refer to a video that is locally and previously stored in the terminal device, or may refer to a video that is captured by the terminal device in real time. When the execution subject is a server, the original video may refer to a video that is locally stored in advance by the server, or may refer to a video that is received from the terminal device in real time.
In step 2011, the video frame is converted into an LAB mode to obtain an L channel, an a channel, and a B channel of the video frame.
In this embodiment, the executing entity may convert the video frame into the LAB mode, resulting in the L, a, and B channels of the video frame. Here, the LAB pattern includes an L channel, an a channel, and a B channel. Where L channel represents luminance, a channel represents a range from magenta to green, and B channel represents a range from yellow to blue.
Step 2012, determining an updated value according to the original value of the L channel to obtain a luminance updated image.
In this embodiment, the execution subject may update the original value of the L channel of the video frame, and use the updated single-channel image of the L channel as the luminance update image. Here, the initial value in the L channel has a value range of 0 to 100. The execution agent may perform various processes on each of the original values in the L channel to obtain updated values of the original values. As an example, the execution subject may divide 0 to 100 into a preset number (for example, 10) of luminance value sections in advance, and set one luminance sample for each luminance value section. Then, for each original value in the L channel, the executing entity may take a brightness interval to which the original value belongs as a target brightness interval, and take a brightness sample corresponding to the target brightness interval as an updated value of the original value. In this way, the original value can be updated with the luminance sample values so that the luminance values in a certain luminance value interval are the same. The updated single-channel image has relatively definite region segmentation, and the region segmentation is more consistent with the style of the cartoon.
In some optional implementations of this embodiment, step 2012 above may be specifically performed as follows:
firstly, for an original value in an L channel, determining a corresponding brightness sample value of the original value based on a predetermined corresponding relation between a brightness value interval and a brightness sample value and the brightness value interval to which the original value belongs; determining the difference value of the original value and the brightness sample value corresponding to the original value; based on the difference value and the original value, an updated value for the original value is determined.
In the implementation mode, the initial value in the L channel ranges from 0 to 100. The execution main body can divide 0-100 into a preset number of brightness value intervals in advance, and stores the corresponding relation between the brightness value intervals and the brightness sample values in advance. Thus, for each original value in the L channel, the executing entity may first determine a brightness interval to which the original value belongs as a target brightness interval, and determine a brightness sample corresponding to the target brightness interval as a brightness sample corresponding to the original value. The executing entity may then calculate the difference between the original value and the luminance sample corresponding to the original value. An updated value for the original value is then determined based on the calculated difference and the original value. As an example, the execution agent may process the difference value using a tanh function, resulting in a function output value. And taking the sum of the original value and the function output value as an updated value of the original value.
Then, a luminance update image is obtained based on the update value of the original value in the L channel.
In this implementation, the execution subject may obtain the luminance update image according to the update value of each original value in the L channel. In this way, the original value can be updated based on the original value, the luminance sample value and the difference value between the original value and the corresponding luminance sample value, so that the updated L-channel image can have relatively definite region segmentation, and the excessive naturalness between the luminance values of the adjacent regions can be ensured. The region segmentation is more consistent with the style of the cartoon, and the problem of image splitting caused by overlarge difference between adjacent brightness sample values is solved, so that the generated cartoon image is more natural.
And 2013, performing edge extraction on the L channel to obtain an edge image.
In this implementation, the execution subject may perform edge extraction on the L channel of the video frame by using various edge extraction methods, so as to obtain an edge image for the L channel.
In some optional implementations of this embodiment, the step 2013 may be specifically performed as follows:
firstly, filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph.
In this implementation, the executing entity may perform filtering processing on an L channel of the video by using a preset first gaussian blur kernel, thereby obtaining a first filter map. Here, the first gaussian blur kernel may be preset by a technician according to actual needs. Here, the gaussian blur kernel may refer to a gaussian-distributed blur kernel.
Then, filtering the original value of the L channel of the video frame by using a preset second Gaussian blur kernel to obtain a second filtering graph.
In this implementation, the executing body may perform filtering processing on an original value of an L channel of the video frame by using a preset second gaussian blur kernel, so as to obtain a second filter map. Here, the second gaussian blur kernel is different from the first gaussian blur kernel, and the second gaussian blur kernel may be preset by a technician according to actual needs.
And finally, performing linear processing on the first filter image and the second filter image to obtain an edge image.
In this implementation, the execution subject may perform linear processing (e.g., subtraction of pixel values at corresponding positions) on the first filtered image and the second filtered image, and obtain an edge image according to a result of the linear processing.
Step 2014, the original values of the channel a and the channel B are processed respectively to obtain a first image for the channel a and a second image for the channel B.
In this embodiment, the execution subject may process the original values of the a channel and the B channel, respectively, to obtain a first image for the a channel and a second image for the B channel. In practice, colors in a caricature are generally prominent compared to a photographed image, and thus, the original values of the a and B channels need to be processed. As an example, the execution subject may perform various processes (e.g., multiplying by a preset multiple) on the original value of the a channel, thereby obtaining the first image. The execution body may also perform various processes (e.g., multiplication by a preset multiple) on the original value of the B channel, thereby obtaining a second image.
In some optional implementations of this embodiment, step 2014 may specifically be performed as follows:
first, a first image is obtained based on a preset first coefficient, a preset first constant and an original value of an a channel.
In this implementation, for each original value in the a channel, the execution body may process the original value by using a preset first coefficient and a preset first constant, for example, multiply the original value by the first coefficient and add the multiplied original value to the first constant. Thereby obtaining a first image. Here, the first coefficient and the first constant may be set by a skilled person according to actual needs.
Then, a second image is obtained based on a preset second coefficient, a preset second constant and the original value of the B channel.
In this implementation, for each original value in the B channel, the execution body may process the original value by using a preset second coefficient and a preset second constant, for example, multiply the original value by the second coefficient and add the multiplied original value to the second constant. Thereby obtaining a second image. Here, the second coefficient and the second constant may be set by a skilled person according to actual needs. Generally, the color saturation of the cartoon image is high, and the original values of the channel A and the channel B used for representing the colors can be processed through the implementation mode, so that the processing result is closer to the cartoon style.
Step 2015, updating the image, the edge image, the first image and the second image based on the brightness to obtain an RGB image.
In this embodiment, the execution subject may obtain an RGB image based on the luminance update image obtained in step 2012, the edge image obtained in step 2013, and the first image and the second image obtained in step 2014. As an example, the executing entity may first determine an LAB image according to the luminance update image, the first image, and the second image, and then convert the determined LAB image into an RGB image, and fuse the converted RGB image with the edge image using various image fusion methods, thereby obtaining an RGB image.
Here, the RGB color scheme is a color standard in the industry, and various colors are obtained by changing three color channels of red (R), green (G) and blue (B) and superimposing them on each other.
Step 202, generating a video based on the obtained RGB image, and outputting the generated video.
In this embodiment, the execution subject may obtain one RGB image for each video frame in the original video. Executing the subject based on the resulting plurality of RGB images may generate a video. Here, the generated video is a cartoon-style video. Thereafter, the execution body may output the generated video. As an example, when the execution subject is a terminal device, the execution subject may directly output and play a video. When the execution main body is a server, the execution main body can output the video to the terminal equipment so as to play the video by the terminal equipment.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for processing video according to the present embodiment. In the application scenario of fig. 3, the terminal device 301 first performs the following processing operations for each video frame in the raw video captured in real time: and step S1, converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame. In step S2, an updated value is determined according to the original value of the L channel, and a luminance updated image is obtained. And step S3, performing edge extraction on the L channel to obtain an edge image. Step S4, processing the original values of the a channel and the B channel respectively to obtain a first image for the a channel and a second image for the B channel. In step S5, an RGB image is obtained based on the luminance update image, the edge image, the first image, and the second image. After that, the terminal device 301 generates a video based on the obtained RGB image, and plays the generated video.
According to the method provided by the embodiment of the disclosure, the original values of the L channel, the A channel and the B channel of each video frame in the original video are processed to obtain the cartoon-style video, so that the conversion from the original video to the cartoon-style video is realized.
With further reference to fig. 4, a flow 400 of yet another embodiment of a method for processing video is shown. The flow 400 of the method for processing video comprises the steps of:
step 401, for the video frames in the acquired original video, executing the following processing operation steps 4011 to 4017.
In the present embodiment, an executing subject of the method for processing video (e.g., the terminal apparatus 101, 102, 103 or the server 105 shown in fig. 1) may execute the following preset processing operation steps 4011 to 4017 for each video frame in the acquired original video.
Step 4011, converting the video frame into an LAB mode to obtain an L channel, an a channel, and a B channel of the video frame.
In this embodiment, step 4011 is similar to step 2011 in the embodiment shown in fig. 2, and is not repeated here.
And 4012, determining an updated value according to the original value of the L channel to obtain a brightness updated image.
In this embodiment, step 4012 is similar to step 2012 of the embodiment shown in fig. 2, and is not described herein again.
And step 4013, performing edge extraction on the L channel to obtain an edge image.
In this embodiment, step 4013 is similar to step 2013 in the embodiment shown in fig. 2, and is not described herein again.
Step 4014, respectively processing the original values of the channel a and the channel B to obtain a first image for the channel a and a second image for the channel B.
In this embodiment, step 4014 is similar to step 2014 in the embodiment shown in fig. 2, and is not described herein again.
Step 4015, converting the LAB image determined based on the luminance update image, the first image and the second image into an initial RGB image.
In this embodiment, the executing subject may determine an LAB image from the luminance update image, the first image, and the second image, and convert the determined LAB image into an initial RGB image.
And step 4016, taking the pixel points with the value of the pixel points in the edge image larger than a preset threshold value as target pixel points.
In this embodiment, the execution subject may traverse each pixel point in the edge image, and take a pixel point whose value is greater than a preset threshold value as a target pixel point. Here, the threshold may be preset by a technician according to actual needs.
And 4017, replacing the value of the corresponding pixel point in the initial RGB image with the value of the target pixel point to obtain the RGB image.
In this embodiment, the execution body may replace the values of the corresponding pixels in the initial RGB image by using the values of the target pixels in the edge image, for example, replace the values of the three channels of the corresponding pixels in the initial RGB image by using the values of the target pixels. Thereby obtaining an RGB image. Here, the corresponding pixel point in the initial RGB image may refer to a pixel point in the initial RGB image, the position of which is the same as the position of the target pixel point in the edge image. For example, if the position of the target pixel point in the edge image is the 10 th row and the 8 th column, the corresponding pixel point in the initial RGB image may refer to the pixel point in the 10 th row and the 8 th column in the initial RGB image.
Step 402, generating a video based on the obtained RGB image, and outputting the generated video.
In this embodiment, step 402 is similar to step 202 of the embodiment shown in fig. 2, and is not described herein again.
As can be seen from fig. 4, compared with the embodiment shown in fig. 2, the process 400 of the method for processing a video in this embodiment highlights the steps of generating an initial RGB image based on the luminance update image, the first image and the second image, and replacing the values of the pixels in the initial RGB image with the values of the pixels whose values in the edge image are greater than the preset threshold. Therefore, the scheme described in the embodiment can improve the brightness of the generated RGB image, so that the generated RGB image is more in line with the cartoon style, and the obtained video effect of the cartoon style is better.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for processing video, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 5, the apparatus 500 for processing video of the present embodiment includes: an execution unit 501 and an output unit 502. Wherein, the execution unit 501 is configured to execute a preset processing operation on a video frame in the acquired original video, wherein the execution unit 501 comprises: a conversion unit 5011 configured to convert the video frame into an LAB mode, resulting in an L channel, an a channel, and a B channel of the video frame; an updating unit 5012 configured to determine an updated value according to the original value of the L channel, resulting in a luminance updated image; an extraction unit 5013 configured to perform edge extraction on the L channel to obtain an edge image; a processing unit 5014 configured to process original values of the a channel and the B channel respectively to obtain a first image for the a channel and a second image for the B channel; a generating unit 5015 configured to obtain an RGB image based on the luminance update image, the edge image, the first image, and the second image; the output unit 502 is configured to generate a video based on the resulting RGB image, and output the generated video.
In this embodiment, for specific processing of the execution unit 501 and the output unit 502 of the apparatus 500 for processing a video and technical effects brought by the specific processing, reference may be made to the related descriptions of step 201 and step 202 in the corresponding embodiment of fig. 2, and details are not repeated here.
In some optional implementations of the present embodiment, the generating unit 5015 is further configured to: converting an LAB image determined based on the luminance update image, the first image, and the second image into an initial RGB image; taking the pixel points with the value of the pixel points in the edge image larger than a preset threshold value as target pixel points; and replacing the value of the corresponding pixel point in the initial RGB image by using the value of the target pixel point to obtain the RGB image.
In some optional implementations of the present embodiment, the above-mentioned updating unit 5012 is further configured to: for the original value in the L channel, determining a corresponding brightness sample value of the original value based on a predetermined corresponding relation between a brightness value interval and a brightness sample value and the brightness value interval to which the original value belongs; determining the difference value of the original value and the brightness sample value corresponding to the original value; determining an updated value of the original value based on the difference and the original value; and obtaining a brightness updating image based on the updating value of the original value in the L channel.
In some optional implementations of the present embodiment, the above-mentioned extraction unit 5013 is further configured to: filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph; filtering the original value of the L channel of the video frame by using a preset second Gaussian blur core to obtain a second filtering graph; and performing linear processing on the first filter image and the second filter image to obtain an edge image.
In some optional implementations of the present embodiment, the processing unit 5014 described above is further configured to: obtaining a first image based on a preset first coefficient, a preset first constant and the original value of the channel A; and obtaining a second image based on a preset second coefficient, a preset second constant and the original value of the B channel.
Referring now to fig. 6, shown is a schematic diagram of an electronic device (e.g., terminal device in fig. 1) 600 suitable for use in implementing embodiments of the present disclosure. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: for the video frames in the acquired original video, the following processing operations are performed: converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame; determining an updated value according to the original value of the L channel to obtain a brightness updated image; performing edge extraction on the L channel to obtain an edge image; processing the original values of the channel A and the channel B respectively to obtain a first image for the channel A and a second image for the channel B; obtaining an RGB image based on the luminance update image, the edge image, the first image, and the second image; generating a video based on the obtained RGB image, and outputting the generated video.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an execution unit and an output unit. Here, the names of these units do not constitute a limitation of the unit itself in some cases, and for example, the output unit may also be described as a "unit that generates a video based on the resulting RGB image and outputs the generated video".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (10)

1. A method for processing video, comprising:
for the video frames in the acquired original video, the following processing operations are performed: converting the video frame into an LAB mode to obtain an L channel, an A channel and a B channel of the video frame; determining an updated value according to the original value of the L channel to obtain a brightness updated image; performing edge extraction on the L channel to obtain an edge image; respectively processing the original values of the channel A and the channel B to obtain a first image for the channel A and a second image for the channel B; obtaining an RGB image based on the brightness update image, the edge image, the first image and the second image;
generating a video based on the obtained RGB image, wherein the generated video is a cartoon-style video, and outputting the generated video, and the obtaining the RGB image based on the brightness updating image, the edge image, the first image and the second image comprises:
converting an LAB image determined based on the luminance update image, the first image, and the second image into an initial RGB image;
traversing each pixel point in the edge image, and taking the pixel point of which the value is greater than a preset threshold value in the edge image as a target pixel point;
replacing the value of the corresponding pixel point in the initial RGB image with the value of the target pixel point to obtain the RGB image;
determining an updated value according to the original value of the L channel to obtain a brightness updated image, including:
dividing a preset number of brightness value intervals according to the value range of the original value in the L channel, setting a brightness sample value for each brightness value interval, regarding each original value in the L channel, taking the brightness value interval to which the original value belongs as a target brightness value interval, and taking the brightness sample value corresponding to the target brightness interval as an updated value of the original value.
2. The method of claim 1, wherein said determining an updated value from an original value of the L-channel resulting in a luminance updated image comprises:
determining the difference value of the original value and the brightness sample value corresponding to the original value; determining an updated value for the original value based on the difference value and the original value;
and obtaining a brightness updating image based on the updating value of the original value in the L channel.
3. The method of claim 1, wherein the edge extracting the L channel to obtain an edge image comprises:
filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph;
filtering the original value of the L channel of the video frame by using a preset second Gaussian blur core to obtain a second filtering graph;
and carrying out linear processing on the first filtering image and the second filtering image to obtain an edge image.
4. The method of claim 1, wherein the processing raw values of the a-channel and the B-channel, respectively, to obtain a first image for the a-channel and a second image for the B-channel, comprises:
obtaining a first image based on a preset first coefficient, a preset first constant and the original value of the channel A;
and obtaining a second image based on a preset second coefficient, a preset second constant and the original value of the B channel.
5. An apparatus for processing video, comprising:
an execution unit configured to execute a preset processing operation on a video frame in the acquired original video, wherein the execution unit includes: a conversion unit configured to convert the video frame into an LAB mode, resulting in an L channel, an a channel, and a B channel of the video frame; the updating unit is configured to determine an updating value according to the original value of the L channel, and obtain a brightness updating image; the extraction unit is configured to perform edge extraction on the L channel to obtain an edge image; a processing unit configured to process original values of the a channel and the B channel, respectively, resulting in a first image for the a channel and a second image for the B channel; a generating unit configured to derive an RGB image based on the luminance update image, the edge image, the first image, and the second image;
an output unit configured to generate a video based on the obtained RGB image, the generated video being a caricature-style video, and output the generated video;
the generation unit is further configured to:
converting an LAB image determined based on the luminance update image, the first image, and the second image into an initial RGB image;
traversing each pixel point in the edge image, and taking the pixel point of which the value is greater than a preset threshold value in the edge image as a target pixel point;
replacing the value of the corresponding pixel point in the initial RGB image with the value of the target pixel point to obtain the RGB image;
the update unit is further configured to: dividing a preset number of brightness value intervals according to the value range of the original value in the L channel, setting a brightness sample value for each brightness value interval, regarding each original value in the L channel, taking the brightness value interval to which the original value belongs as a target brightness value interval, and taking the brightness sample value corresponding to the target brightness interval as an updated value of the original value.
6. The apparatus of claim 5, wherein the update unit is further configured to:
determining the difference value of the original value and the brightness sample value corresponding to the original value; determining an updated value for the original value based on the difference value and the original value;
and obtaining a brightness updating image based on the updating value of the original value in the L channel.
7. The apparatus of claim 5, wherein the extraction unit is further configured to:
filtering an original value of an L channel of the video frame by using a preset first Gaussian blur kernel to obtain a first filtering graph;
filtering the original value of the L channel of the video frame by using a preset second Gaussian blur core to obtain a second filtering graph;
and carrying out linear processing on the first filtering image and the second filtering image to obtain an edge image.
8. The apparatus of claim 5, wherein the processing unit is further configured to:
obtaining a first image based on a preset first coefficient, a preset first constant and the original value of the channel A;
and obtaining a second image based on a preset second coefficient, a preset second constant and the original value of the B channel.
9. An apparatus for processing video, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-4.
CN201910919234.9A 2019-09-26 2019-09-26 Method and apparatus for processing video Active CN110636331B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910919234.9A CN110636331B (en) 2019-09-26 2019-09-26 Method and apparatus for processing video

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910919234.9A CN110636331B (en) 2019-09-26 2019-09-26 Method and apparatus for processing video

Publications (2)

Publication Number Publication Date
CN110636331A CN110636331A (en) 2019-12-31
CN110636331B true CN110636331B (en) 2022-08-09

Family

ID=68974253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910919234.9A Active CN110636331B (en) 2019-09-26 2019-09-26 Method and apparatus for processing video

Country Status (1)

Country Link
CN (1) CN110636331B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113012185B (en) * 2021-03-26 2023-08-29 影石创新科技股份有限公司 Image processing method, device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103578080A (en) * 2012-07-25 2014-02-12 上海澜晶数码科技有限公司 Image denoising and enhancement algorithm
CN106101556A (en) * 2016-07-29 2016-11-09 广东欧珀移动通信有限公司 The image combining method of mobile terminal, device and mobile terminal

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4684959B2 (en) * 2006-07-04 2011-05-18 キヤノン株式会社 Image processing apparatus, image processing method, and program
CN101286228B (en) * 2008-05-15 2011-10-05 浙江大学 Real-time vision frequency and image abstraction method based on characteristic
CN101340510B (en) * 2008-08-07 2010-06-23 中兴通讯股份有限公司 Method for video enhancement and apparatus thereof
CN101540055B (en) * 2009-04-13 2011-05-04 浙江大学 Cartoon stylization method facing online real-time application
CN102542533A (en) * 2010-12-16 2012-07-04 方正国际软件(北京)有限公司 Image blurring method and system
JP5514344B2 (en) * 2012-05-15 2014-06-04 シャープ株式会社 Video processing device, video processing method, television receiver, program, and recording medium
CN103489204B (en) * 2013-05-15 2016-04-06 许昌学院 A kind of two-dimensional color pencil drawing automatic drafting method
CN105894459A (en) * 2015-12-10 2016-08-24 乐视云计算有限公司 Gradient value and direction based image sharpening method and device
KR20170097812A (en) * 2016-02-18 2017-08-29 한국기술교육대학교 산학협력단 Apparatus and method for making cartoon background using photo image
CN108055486B (en) * 2017-12-07 2020-02-14 浙江华睿科技有限公司 Brightness correction method and device
CN109741408A (en) * 2018-11-23 2019-05-10 成都品果科技有限公司 A kind of image and video caricature effect real-time rendering method
CN109729281A (en) * 2019-01-04 2019-05-07 Oppo广东移动通信有限公司 Image processing method, device, storage medium and terminal
CN110070482B (en) * 2019-03-14 2023-05-02 北京字节跳动网络技术有限公司 Image processing method, apparatus and computer readable storage medium
CN110070499A (en) * 2019-03-14 2019-07-30 北京字节跳动网络技术有限公司 Image processing method, device and computer readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103578080A (en) * 2012-07-25 2014-02-12 上海澜晶数码科技有限公司 Image denoising and enhancement algorithm
CN106101556A (en) * 2016-07-29 2016-11-09 广东欧珀移动通信有限公司 The image combining method of mobile terminal, device and mobile terminal

Also Published As

Publication number Publication date
CN110636331A (en) 2019-12-31

Similar Documents

Publication Publication Date Title
CN110516678B (en) Image processing method and device
CN110211030B (en) Image generation method and device
CN110865862A (en) Page background setting method and device and electronic equipment
CN111459364B (en) Icon updating method and device and electronic equipment
CN111757100B (en) Method and device for determining camera motion variation, electronic equipment and medium
CN112381717A (en) Image processing method, model training method, device, medium, and apparatus
CN111784712A (en) Image processing method, device, equipment and computer readable medium
JP7261732B2 (en) Method and apparatus for determining character color
CN113038176B (en) Video frame extraction method and device and electronic equipment
CN109102484B (en) Method and apparatus for processing image
CN110636331B (en) Method and apparatus for processing video
CN111669476B (en) Watermark processing method, device, electronic equipment and medium
CN112348910A (en) Method, device, equipment and computer readable medium for acquiring image
CN110555799A (en) Method and apparatus for processing video
CN111369475A (en) Method and apparatus for processing video
CN112258622A (en) Image processing method, image processing device, readable medium and electronic equipment
CN110097520B (en) Image processing method and device
CN111784726A (en) Image matting method and device
CN114339447A (en) Method, device and equipment for converting picture into video and storage medium
CN113628097A (en) Image special effect configuration method, image recognition method, image special effect configuration device and electronic equipment
CN115471592A (en) Dynamic image processing method and system
CN114170341A (en) Image processing method, device, equipment and medium
CN110599437A (en) Method and apparatus for processing video
CN110209851B (en) Model training method and device, electronic equipment and storage medium
CN110084835B (en) Method and apparatus for processing video

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