Video processing method and device, electronic equipment, storage medium and product
By dynamically generating a brightness mapping function, adjusting the brightness of the video frame based on the brightness statistics of the video frame, solving the problem of abnormal video frame contrast or brightness, and improving the video playback quality.
Patent Information
- Application Number
- CN202411526680.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, during video playback, the contrast or brightness of the video frame is abnormal, resulting in poor playback effect, and fixed numerical adjustment cannot adapt to all pictures, which cannot effectively solve the problem of brightness abnormality, reducing the quality of the video frame picture.
By obtaining the brightness statistics information of the first video frame of the to-process video, a brightness mapping function is dynamically generated, which is used to adjust the brightness of the next video frame and realize dynamic adjustment of contrast and brightness.
It improves the accuracy of video frame brightness and contrast adjustment, improves the playback quality of video frame screen, and makes the video playback effect more stable and high-quality.
Smart Images

Figure CN119520753A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a video processing method, device, electronic device, storage medium and product. Background Art
[0002] Currently, users have higher and higher requirements for video quality. During the actual video playback process, the contrast or brightness of the frames in the video may be abnormal, which affects the playback effect. In related technologies, the contrast adjustment of the video is usually performed with a fixed value, but the fixed value adjustment may not be applicable to all pictures, which may result in the inability to solve the problem of abnormal brightness, thereby reducing the quality of the video frame. Summary of the invention
[0003] The present disclosure provides a video processing method, device, electronic device, storage medium and product.
[0004] In a first aspect, the present disclosure provides a video processing method, the video processing method comprising:
[0005] Obtain first brightness statistical information of a first video frame of a video to be processed;
[0006] Determine, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is used to obtain a mapped output brightness for an input brightness;
[0007] According to the brightness mapping function, the brightness of each pixel of the second video frame is adjusted to obtain a second video frame after the brightness adjustment, so that the adjusted second video frame can be played.
[0008] In a second aspect, the present disclosure provides a video processing device, the video processing device comprising:
[0009] An obtaining module, used for obtaining first brightness statistical information of a first video frame of a video to be processed;
[0010] A determination module, configured to determine, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is used to obtain a mapped output brightness for an input brightness;
[0011] The adjustment module is used to adjust the brightness of each pixel of the second video frame according to the brightness mapping function to obtain the second video frame after the brightness adjustment, so as to play the adjusted second video frame.
[0012] In a third aspect, the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can perform the above-mentioned video processing method.
[0013] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned video processing method when executed by a processor.
[0014] In a fifth aspect, the present disclosure provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned video processing method.
[0015] The video processing method provided by the embodiment of the present disclosure obtains first brightness statistical information of a first video frame of a video to be processed, and determines a brightness mapping function for adjusting a next second video frame of the first video frame according to the first brightness statistical information, thereby adjusting the brightness of each pixel point of the second video frame according to the brightness mapping function to obtain a second video frame after brightness adjustment, so as to play the adjusted second video frame. In this way, a brightness mapping function can be dynamically generated according to the brightness statistical information of the current first video frame, so as to be able to dynamically adjust the brightness of the next second video frame, thereby improving the accuracy of brightness and contrast adjustment of the video frame, thereby improving the playback quality of the video frame.
[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0018] Figure 1 An application scenario diagram of the video processing method and device provided in the embodiments of the present disclosure;
[0019] Figure 2 A flowchart of a video processing method provided by an embodiment of the present disclosure;
[0020] Figure 3 It is a schematic diagram of an objective function curve in an embodiment of the present disclosure;
[0021] Figure 4 A block diagram of a video processing device provided by an embodiment of the present disclosure;
[0022] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0024] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0025] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0026] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0027] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0028] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.
[0029] To facilitate understanding of the embodiments of the present disclosure, several concepts are briefly introduced below:
[0030] Brightness: Indicates the brightness of a video frame. For a frame of image, brightness can be understood as the average grayscale level of the image or the average color intensity of each pixel.
[0031] Contrast: It refers to the measurement of different brightness levels between the brightest white and the darkest black in the light and dark areas of the video frame, that is, it refers to the size of the grayscale contrast of an image. The larger the difference range, the greater the contrast, and the smaller the difference range, the smaller the contrast.
[0032] Due to various factors affecting video playback or factors related to the quality of the video itself, the contrast or brightness of the frames in the video may be abnormal. In related technologies, the contrast of the video is usually adjusted with a fixed value, but the fixed value adjustment may not be applicable to all images, which may result in the inability to solve the problem of abnormal brightness, thereby reducing the quality of the video frame.
[0033] In an embodiment of the present disclosure, a video processing method is provided to obtain first brightness statistical information of a first video frame of a video to be processed, thereby generating a brightness mapping function for adjusting a next second video frame of the first video frame, and adjusting the brightness of the second video frame according to the brightness mapping function. In this way, the brightness statistical information of the current video frame can be counted in real time to dynamically generate a brightness mapping function, and then the next video frame can be dynamically adjusted, thereby improving the accuracy of brightness and contrast adjustment of the video frame and improving the frame picture quality of the video.
[0034] Figure 1 The application scenario diagram of the video processing method and device provided by the embodiments of the present disclosure is schematically shown.
[0035] like Figure 1As shown, the application scenario of the embodiment of the present disclosure may include a terminal device 101, a network 103 and a server 102. The network 103 is used to provide a medium for a communication link between the terminal device 101 and the server 102. The network 103 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0036] The user can use the terminal device 101 to interact with the server 102 through the network 103 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as video playback applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0037] The terminal device 101 may be any electronic device having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.
[0038] The server 102 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the terminal device 101. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0039] It should be noted that the video processing method and apparatus provided in the embodiments of the present disclosure can be executed by the server 102. Accordingly, the video processing method and apparatus provided in the embodiments of the present disclosure can be arranged in the server 102. The video processing method and apparatus provided in the embodiments of the present disclosure can also be executed by a server or a server cluster that is different from the server 102 and can communicate with the terminal device 101 and / or the server 102. Accordingly, the video processing method and apparatus provided in the embodiments of the present disclosure can also be arranged in a server or a server cluster that is different from the server 102 and can communicate with the terminal device 101 and / or the server 102. Of course, the video processing method and apparatus in the embodiments of the present disclosure can also be executed by the terminal device 101, which is not limited in the embodiments of the present disclosure.
[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0041] Figure 2 A flowchart of a video processing method provided by an embodiment of the present disclosure. Figure 2 , the method comprising:
[0042] S210: Obtain first brightness statistical information of a first video frame of a video to be processed.
[0043] In the embodiments of the present disclosure, it can be applied to the brightness adjustment scenario of video frames during video playback, and can also be applied to the adjustment during video generation, etc. The embodiments of the present disclosure do not limit the application scenarios.
[0044] For example, the video to be processed is the currently playing video. During the playback of the video to be processed, the brightness of the next second video frame can be dynamically adjusted according to the first brightness statistical information of the first video frame currently playing and displayed, and the contrast adjustment of the second video frame can be achieved through brightness adjustment.
[0045] S220: Determine, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is used to obtain a mapped output brightness with respect to the input brightness.
[0046] The first brightness statistical information includes the pixel brightness of each pixel point of the first video frame.
[0047] In the embodiments of the present disclosure, there may be different implementation methods for determining pixel brightness for videos to be processed in different color modes. 1) In one possible embodiment, the color mode is grayscale. For a video frame of a grayscale image, each pixel corresponds to a brightness value, and the pixel value is determined as the pixel brightness of the pixel.
[0048] 2) In a possible embodiment, the color mode is red / green / blue (RGB). For an RGB image, each pixel contains three components: red (R), green (G), and blue (B). R, G, and B can be converted into brightness values using different formulas. For example, the average value or weighted average value of R, G, and B of a pixel point can be determined as the brightness value of the pixel point. For another example, the maximum value of the three components R, G, and B of a pixel point can be determined as the brightness value of the pixel point.
[0049] 3) In a possible embodiment, the color mode is Hue / Saturation / Value (HSV). For the HSV color mode, brightness is an independent component, and the V value of each pixel can be directly obtained, that is, the pixel brightness of each pixel.
[0050] S230: adjusting the brightness of each pixel of the second video frame according to the brightness mapping function to obtain the second video frame after the brightness adjustment, so as to play the adjusted second video frame.
[0051] In the disclosed embodiment, based on the first brightness statistical information of the first video frame, the brightness distribution of the first video frame can be obtained, and then based on the first brightness statistical information, a brightness mapping function for adjusting the second video frame can be determined, and according to the brightness mapping function, the brightness of the second video frame is adjusted to obtain the second video frame after the brightness adjustment, so that the adjusted second video frame can be played. In this way, a brightness mapping function can be dynamically generated for each frame, and the next frame can be dynamically adjusted, which improves flexibility and specificity, and makes the adjustment more accurate, so that the picture of the adjusted video frame can have better contrast, thereby also improving the quality of the video frame picture.
[0052] The video processing method according to the embodiment of the present disclosure is described below.
[0053] Regarding the above step S220, in order to further improve the adjustment accuracy, in the embodiment of the present disclosure, when determining the brightness mapping function, it can also include: obtaining a first function curve set by the user, the first function curve is used to characterize the first correlation relationship between different pixel brightness and pixel quantity.
[0054] In a possible embodiment, determining, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame includes:
[0055] S1. Generate a second function curve according to the first brightness statistical information, where the second function data is used to characterize a second correlation relationship between different pixel brightnesses and the number of pixels.
[0056] The first brightness statistical information includes the pixel brightness of each pixel point of the first video frame, and generating a second function curve according to the first brightness statistical information includes:
[0057] 1) According to a plurality of preset brightness statistical intervals and the pixel brightness of each pixel point in the first video frame, the number of pixels whose pixel brightness belongs to each brightness statistical interval is counted.
[0058] Among them, the brightness statistical interval is related to the pixel brightness value range of the first video frame. For example, for a 12-bit video frame image, each pixel point can have 2^12=4096 different brightness levels, that is, the pixel brightness value range is 0-4095. Based on this, it can be divided into 32 small brightness statistical intervals, each brightness statistical interval corresponds to a different pixel brightness value, and the number of pixels corresponding to each brightness statistical interval can be counted.
[0059] Furthermore, the embodiments of the present disclosure also take into account the situation where a background black border may appear in the picture of the video frame. For example, for a movie video picture, there may be a black border at the edge position to facilitate user viewing. In this case, the counting of the number of pixels in the background black border area will actually interfere with the brightness adjustment of the normal playback picture of the video frame. Therefore, the embodiments of the present disclosure also provide a possible embodiment, which also includes: determining the first number of pixels whose pixel brightness is less than a first brightness threshold according to the pixel brightness of each pixel point in the first video frame; adding the first number of pixels to the number of pixels corresponding to each brightness statistical interval according to a preset distribution method.
[0060] Among them, the preset allocation method can be an average allocation. For example, there are 32 brightness statistical intervals. The number of first pixels whose pixel brightness is less than the first brightness threshold can be evenly distributed to the 32 brightness statistical intervals, that is, each brightness statistical interval can increase the first number of pixels / 32 numbers of pixels. In this way, the number of pixels with lower brightness in these background black edge areas can be evenly distributed to other brightness statistical intervals, thereby reducing the impact on the second function curve.
[0061] 2) Generate a brightness statistical histogram according to the number of pixels corresponding to each brightness statistical interval, where the horizontal axis of the brightness statistical histogram is the plurality of brightness statistical intervals and the vertical axis is the number of pixels.
[0062] 3) Generate a second function curve based on the brightness statistical histogram.
[0063] S2. Determine a weight parameter, and determine a target function curve according to the weight parameter, the first function curve and the second function curve, where the target function curve is used to characterize a brightness mapping function for adjusting a next second video frame of the first video frame.
[0064] In the embodiment of the present disclosure, the specifications of the first function curve and the second function data are the same, for example, the meanings of the horizontal and vertical coordinates are the same and the value ranges are the same. The first function curve can be set by the user, for example, the user sets 32 sets of coordinates and generates the first function curve according to the 32 sets of coordinates. For another example, the user can use a preset image mode and obtain the first function curve corresponding to the image mode. The first function curve is not limited in the embodiment of the present disclosure.
[0065] In a possible embodiment, determining the weight parameter includes:
[0066] 1) Determine the brightness distribution parameters of the first video frame according to the second function curve.
[0067] In the embodiment of the present disclosure, the brightness distribution parameters of the first video frame can be obtained by performing step-by-step subtraction on the second function curve of the first video frame statistics and performing difference calculation on the number of pixels corresponding to each brightness statistical interval. The brightness distribution parameters are used to characterize the changing trend or brightness degree of the brightness distribution.
[0068] For example, the brightness distribution parameter is DEV, the brightness statistical curve is differentiated step by step, and the difference values corresponding to the brightness statistical intervals are accumulated. If the difference value is <128, then DEV=DEV+64; if 512<difference value<1024, then DEV=DEV+128; if the difference value is >1024, then DEV=DEV+256.
[0069] In this way, the fluctuation degree of brightness distribution of the whole video frame is expressed by accumulating the change of the number of pixels between the brightness statistical intervals. A higher DEV value usually indicates that the brightness distribution of the video frame is more uneven, and there may be more high-contrast areas or areas with sharp changes in brightness, while a lower DEV value may indicate that the brightness distribution is smoother and the contrast is lower.
[0070] 2) Determine a weight parameter according to the brightness distribution parameter, and the weight parameter is used to adjust the closeness between the target function curve and the first function curve or the second function curve.
[0071] For example, the weight parameter is R, R=Max{b-[(DEV*a) / 1024], c}, where Max represents the maximum value, a, b and c are preset parameters, which can be set according to actual conditions and experience, and are not limited in the embodiments of the present disclosure.
[0072] Furthermore, in the embodiment of the present disclosure, the target function curve can be determined according to the weight parameter, the first function curve and the second function curve. For example, the target function curve is Z, the first function curve is B, the second function curve is A, and the weight parameter is R, then Z=B+[R(AB)] / 1024.
[0073] In another possible embodiment, the embodiment of the present disclosure can also perform brightness adjustment on the video frame in different regions, and different weight parameters can be set separately for the bright and dark areas in the video frame. Specifically, the present disclosure provides a possible implementation method, the weight parameters include multiple first weight parameters, and the size of the video frame of the video to be processed is pre-divided into multiple sub-intervals, each sub-interval corresponds to a first weight parameter, and the target function curve is determined according to the weight parameters, the first function curve and the second function curve, including: generating the target function curve according to the first function curve and the second function curve, and the first weight parameter corresponding to each sub-interval.
[0074] In the embodiment of the present disclosure, in order to improve the accuracy of the final objective function curve for adjusting the brightness, the first function curve and the second function curve may be monotonically increasing functions. In order to ensure that the first function curve and the second function curve are monotonically increasing, a possible implementation method may be to add a certain proportion of the number of pixels corresponding to the brightness statistical interval to the number of pixels of the corresponding next-level brightness statistical interval. Then, when generating the objective function curve, the first x of the plurality of brightness statistical intervals may correspond to a first weight parameter, and the last y may correspond to other first weight parameters. Alternatively, different brightness statistical intervals may correspond to a plurality of different first weight parameters. For example, the first weight parameter may be 0, R / 2, R, 2R, in this way, the brightness of different areas of the video frame can be dynamically adjusted according to different needs, and the generated objective function curve is also required to be monotonically increasing or monotonically non-decreasing. The initially generated objective function curve can be detected from the very end forward. If it is not satisfied, the higher value of the previous level can be assigned to be equal to the next level, so that the final adjusted objective function curve can meet the monotony and non-decreasing requirements. In this way, when the brightness of the next frame is adjusted based on the objective function curve, the horizontal and vertical coordinates of the objective function curve represent the input brightness and output brightness. The monotonically non-decreasing curve trend allows higher input brightness to still be mapped to obtain higher output brightness, thereby reducing the abnormality of the output brightness after mapping.
[0075] Furthermore, in an embodiment of the present disclosure, when determining the brightness mapping function of the second video frame, the influence of consecutive video frames can also be considered. Specifically, the present disclosure provides a possible implementation method, including: when it is determined that the first brightness statistical information and the first average brightness statistical information of multiple consecutive video frames before the first video frame meet similar conditions, determining the second average brightness statistical information based on the first brightness statistical information and the first average brightness statistical information; and determining the brightness mapping function of the next second video frame for adjusting the first video frame based on the second average brightness statistical information.
[0076] In the disclosed embodiment, when the brightness distribution of the first video frame is similar to that of the previous continuous multiple video frames, it means that there is no video frame with significantly different contrast, and the contrast playback effect of the continuous video frames should also be similar. Therefore, the average brightness statistical information can be used for determination. For example, based on the second average brightness statistical information, the second function curve is determined, and then the target function curve is determined according to the first function curve, the second function curve and the weight parameter to determine the brightness mapping function of the second video frame. In this way, the brightness mapping function of the next frame can be determined by averaging based on the brightness statistical information of the continuous multiple video frames, which can reduce the influence of noise and improve accuracy.
[0077] In addition, in the embodiment of the present disclosure, when the first brightness statistical information and the first average brightness statistical information of multiple consecutive video frames before the first video frame do not meet the similarity condition, it means that the contrast of the current first video frame is significantly different from that of the previous multiple consecutive video frames, which may be due to the switching of different scenes in the video. In order to improve accuracy, in this case, a second function curve can be generated only based on the first brightness statistical information of the first video frame, so as to determine the target function curve based on the first function curve, the second function curve and the weight parameters to determine the brightness mapping function of the second video frame.
[0078] Thus, in the disclosed embodiment, when the brightness statistical information of a new video frame differs too greatly from the previous average brightness statistical information, a single video frame statistical method can be used, and statistical comparison can be continued until the brightness statistical information of multiple consecutive video frames meet similar conditions again. The statistical method of multiple consecutive video frames can be restored, which can improve accuracy and reduce noise impact.
[0079] In a possible embodiment, the brightness of each pixel point of the second video frame is adjusted according to the brightness mapping function in the above step S230 to obtain the second video frame after brightness adjustment, including: inputting the pixel brightness of each pixel point of the second video frame into the brightness mapping function to obtain the adjusted pixel brightness output by the brightness mapping function.
[0080] For example, Figure 3 As shown, it is a schematic diagram of an objective function curve in an embodiment of the present disclosure, such as Figure 3 As shown, taking 4096 pixels in a video frame as an example, it is divided into 32 intervals, each interval differs by 128, the horizontal coordinate of the target function curve is the input brightness, and the vertical coordinate is the output brightness. When calculating the adjusted pixel brightness corresponding to each pixel, the linear interpolation result of the original input brightness Yin of the pixel can be calculated between the output brightness of the two nearest adjacent interval points to obtain the adjusted pixel brightness Yout corresponding to Yin. For example, the pixel brightness Yin of each pixel in the second video frame has a value range of 0 to 4095, dcc[] represents the output brightness array of each interval point corresponding to the brightness mapping function, then dcc[] is an array of size 33, int dcc
[33] ={0}for(int i=0; i<33; i++)dcc[i+1]=D[i], and then the adjusted pixel brightness Yout corresponding to each pixel can be obtained by interpolation calculation:
[0081] Yout=(dcc[Yin / 128]*(128-Yin%32)+dcc[1+Yin / 128]*(Yin%32)) / 128
[0082] Among them, Yin%32 indicates the interval in which Yin is located, and Yin / 128 indicates the proportion in the interval, so that the value of Yout between the two nearest adjacent sets of coordinates can be calculated by linear interpolation.
[0083] In addition, in the embodiment of the present disclosure, when the brightness of each pixel point of the second video frame is adjusted based on the brightness mapping function, some parts with grayscale levels may become white during the adjustment process, causing the levels to disappear and brightness saturation to occur. Therefore, in the embodiment of the present disclosure, the brightness in the video frame can also be prevented from being over-saturated by limiting the maximum brightness slope. In a possible embodiment, when the brightness of each pixel point of the second video frame is adjusted, it also includes: for the adjusted pixel brightness of each pixel point, controlling the adjusted pixel brightness to be less than or equal to a target value, wherein the target value is related to the maximum output brightness of the brightness mapping function.
[0084] For example, in the embodiment of the present disclosure, the method of controlling the brightness saturation in the video frame when the brightness is adjusted is:
[0085] if(clampEn&&Yout>dcc
[32] -clamping*(4095-Yin) / 4095) / / maximum brightness slope calculation
[0086] {
[0087] Yout=dcc
[32] -clamping*(4095-Yin) / 4095;
[0088] }
[0089] Among them, clamping is a preset coefficient for controlling the degree of compression, which can be set in advance according to actual experience and needs. clampEn is a Boolean variable, indicating whether the brightness anti-saturation function is enabled. 4095 represents the maximum value of the pixel brightness. In this way, the linear transformation controlled by the slope can be used to control the adjusted pixel brightness not to exceed a certain maximum value, which can effectively prevent brightness saturation while retaining the picture details and dynamic range of the video frame.
[0090] In a possible embodiment, based on the brightness mapping function, when the brightness of each pixel point of the second video frame is adjusted, the pure color image part in the second video frame may become darker after the brightness adjustment. In order to further improve the picture quality and playback effect of the video frame, in the embodiment of the present disclosure, when the brightness of each pixel point of the second video frame is adjusted, it also includes: controlling the saturation of each pixel point after adjustment to be greater than or equal to a preset saturation threshold.
[0091] In this way, in the embodiment of the present disclosure, a saturation compensation function is also added. Saturation can be used to measure the purity or intensity of color. The higher the saturation, the brighter and purer the color. The lower the saturation, the darker the color. Through the saturation compensation function, the picture quality of the video frame can be improved.
[0092] In a possible embodiment, when the brightness of each pixel point of the second video frame is adjusted based on the brightness mapping function, when the pixel brightness after mapping is converted to RGB, it may appear that RGB exceeds the maximum value. In this case, when the brightness of each pixel point of the second video frame is adjusted in the embodiment of the present disclosure, it also includes: controlling the RGB value of each pixel point after adjustment to be less than or equal to the RGB maximum value.
[0093] For example, based on the brightness mapping function, the adjusted pixel brightness of each pixel point of the second video frame is obtained and converted into RGB values. If RGB exceeds its maximum value, the three components of RGB can be reduced proportionally until the three components are less than or equal to their maximum values.
[0094] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0095] In addition, the present disclosure also provides a video processing device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any video processing method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0096] Figure 4 A block diagram of a video processing device provided in an embodiment of the present disclosure.
[0097] Reference Figure 4 , an embodiment of the present disclosure provides a video processing device, the video processing device comprising:
[0098] An obtaining module 41 is used to obtain first brightness statistical information of a first video frame of a video to be processed;
[0099] A determination module 42, configured to determine, based on the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is configured to obtain a mapped output brightness for an input brightness;
[0100] The adjustment module 43 is used to adjust the brightness of each pixel of the second video frame according to the brightness mapping function to obtain the second video frame after the brightness adjustment, so as to play the adjusted second video frame.
[0101] In a possible embodiment, the obtaining module 41 is further used to: obtain a first function curve set by a user, where the first function curve is used to characterize a first correlation relationship between different pixel brightnesses and the number of pixels;
[0102] When determining the brightness mapping function for adjusting the next second video frame of the first video frame according to the first brightness statistical information, the determination module 42 is used to:
[0103] Generate a second function curve according to the first brightness statistical information, wherein the second function data is used to characterize a second correlation relationship between brightness of different pixels and the number of pixels;
[0104] A weight parameter is determined, and a target function curve is determined according to the weight parameter, the first function curve and the second function curve, wherein the target function curve is used to characterize a brightness mapping function for adjusting a next second video frame of the first video frame.
[0105] In a possible embodiment, the first brightness statistical information includes the pixel brightness of each pixel point of the first video frame, and when generating the second function curve according to the first brightness statistical information, the determination module 42 is used to:
[0106] According to the preset plurality of brightness statistical intervals and the pixel brightness of each pixel point in the first video frame, counting the number of pixels whose pixel brightness belongs to each brightness statistical interval;
[0107] Generate a brightness statistical histogram according to the number of pixels corresponding to each brightness statistical interval, wherein the abscissa of the brightness statistical histogram is the plurality of brightness statistical intervals, and the ordinate is the number of pixels;
[0108] A second function curve is generated according to the brightness statistical histogram.
[0109] In a possible embodiment, when counting the number of pixels whose pixel brightness belongs to each brightness statistical interval according to the preset multiple brightness statistical intervals and the pixel brightness of each pixel point in the first video frame, the determination module 42 is further used to:
[0110] Determine, according to the pixel brightness of each pixel point in the first video frame, a first number of pixels whose pixel brightness is less than a first brightness threshold;
[0111] The first number of pixels is added to the number of pixels corresponding to each brightness statistical interval according to a preset allocation method.
[0112] In a possible embodiment, when determining the weight parameter, the determination module 42 is used to:
[0113] determining a brightness distribution parameter of the first video frame according to the second function curve;
[0114] A weight parameter is determined according to the brightness distribution parameter, and the weight parameter is used to adjust the degree of proximity between the target function curve and the first function curve or the second function curve.
[0115] In a possible embodiment, the weight parameters include multiple first weight parameters, the size of the video frame of the video to be processed is pre-divided into multiple sub-intervals, each sub-interval corresponds to a first weight parameter, and when determining the target function curve based on the weight parameters, the first function curve and the second function curve, the determination module 42 is used to: generate the target function curve based on the first function curve and the second function curve, and the first weight parameter corresponding to each sub-interval.
[0116] In a possible embodiment, the determination module 42 is further configured to:
[0117] In a case where it is determined that the first brightness statistical information and first average brightness statistical information of a plurality of consecutive video frames before the first video frame meet a similarity condition, determining second average brightness statistical information according to the first brightness statistical information and the first average brightness statistical information;
[0118] A brightness mapping function for adjusting a next second video frame of the first video frame is determined according to the second average brightness statistical information.
[0119] In a possible embodiment, when the brightness of each pixel point of the second video frame is adjusted, the adjustment module 43 is also used to: for the adjusted pixel brightness of each pixel point, control the adjusted pixel brightness to be less than or equal to a target value, wherein the target value is related to the maximum output brightness of the brightness mapping function.
[0120] In a possible embodiment, when the brightness of each pixel of the second video frame is adjusted, the adjustment module 43 is further used to: control the saturation of each pixel after adjustment to be greater than or equal to a preset saturation threshold.
[0121] In a possible embodiment, when the brightness of each pixel of the second video frame is adjusted, the adjustment module 43 is further used to: control the RGB value of each pixel after adjustment to be less than or equal to the RGB maximum value.
[0122] Each module in the above video processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0123] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0124] Reference Figure 5 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 501; at least one memory 502, and one or more I / O interfaces 503, connected between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs that can be executed by the at least one processor 501, and the one or more computer programs are executed by the at least one processor 501 so that the at least one processor 501 can execute the above-mentioned video processing method.
[0125] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0126] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned video processing method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0127] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned video processing method.
[0128] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0129] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0130] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0131] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0132] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0133] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0134] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0135] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0136] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0137] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A video processing method, characterized in that: include: Obtain first brightness statistical information of a first video frame of a video to be processed; Determine, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is used to obtain a mapped output brightness for an input brightness; According to the brightness mapping function, the brightness of each pixel of the second video frame is adjusted to obtain a second video frame after the brightness adjustment, so that the adjusted second video frame can be played.
2. The video processing method according to claim 1, characterized in that: The method further comprises: Obtaining a first function curve set by a user, wherein the first function curve is used to represent a first correlation relationship between brightness of different pixels and the number of pixels; Then, determining, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame includes: Generate a second function curve according to the first brightness statistical information, wherein the second function data is used to characterize a second correlation relationship between brightness of different pixels and the number of pixels; A weight parameter is determined, and a target function curve is determined according to the weight parameter, the first function curve and the second function curve, wherein the target function curve is used to characterize a brightness mapping function for adjusting a next second video frame of the first video frame.
3. The video processing method according to claim 2, characterized in that: The first brightness statistical information includes the pixel brightness of each pixel point of the first video frame, and generating a second function curve according to the first brightness statistical information includes: According to the preset plurality of brightness statistical intervals and the pixel brightness of each pixel point in the first video frame, counting the number of pixels whose pixel brightness belongs to each brightness statistical interval; Generate a brightness statistical histogram according to the number of pixels corresponding to each brightness statistical interval, wherein the abscissa of the brightness statistical histogram is the plurality of brightness statistical intervals, and the ordinate is the number of pixels; A second function curve is generated according to the brightness statistical histogram.
4. The video processing method according to claim 3, characterized in that: When counting the number of pixels whose pixel brightness belongs to each brightness statistical interval according to the preset multiple brightness statistical intervals and the pixel brightness of each pixel point in the first video frame, the method further includes: Determine, according to the pixel brightness of each pixel point in the first video frame, a first number of pixels whose pixel brightness is less than a first brightness threshold; The first number of pixels is added to the number of pixels corresponding to each brightness statistical interval according to a preset allocation method.
5. The video processing method according to claim 2 or 3, characterized in that: The determining of the weight parameter comprises: determining a brightness distribution parameter of the first video frame according to the second function curve; A weight parameter is determined according to the brightness distribution parameter, and the weight parameter is used to adjust the degree of proximity between the target function curve and the first function curve or the second function curve.
6. The video processing method according to claim 2, characterized in that: The weight parameters include a plurality of first weight parameters, the size of the video frame of the video to be processed is pre-divided into a plurality of sub-intervals, each sub-interval corresponds to a first weight parameter, and determining the target function curve according to the weight parameters, the first function curve and the second function curve includes: An objective function curve is generated according to the first function curve, the second function curve, and a first weight parameter corresponding to each subinterval.
7. The video processing method according to claim 1 or 2, characterized in that: The method further comprises: In a case where it is determined that the first brightness statistical information and first average brightness statistical information of a plurality of consecutive video frames before the first video frame meet a similarity condition, determining second average brightness statistical information according to the first brightness statistical information and the first average brightness statistical information; A brightness mapping function for adjusting a next second video frame of the first video frame is determined according to the second average brightness statistical information.
8. The video processing method according to claim 1, characterized in that: When the brightness of each pixel point of the second video frame is adjusted, the method further includes: For the adjusted pixel brightness of each pixel point, the adjusted pixel brightness is controlled to be less than or equal to a target value, wherein the target value is related to the maximum output brightness of the brightness mapping function.
9. The video processing method according to claim 1, characterized in that: When the brightness of each pixel point of the second video frame is adjusted, the method further includes: The saturation of each pixel after adjustment is controlled to be greater than or equal to a preset saturation threshold.
10. The video processing method according to claim 1, characterized in that: When the brightness of each pixel point of the second video frame is adjusted, the method further includes: The RGB value of each pixel after adjustment is controlled to be less than or equal to the maximum RGB value.
11. A video processing device, characterized in that: include: An obtaining module, used for obtaining first brightness statistical information of a first video frame of a video to be processed; A determination module, configured to determine, according to the first brightness statistical information, a brightness mapping function for adjusting a next second video frame of the first video frame, wherein the brightness mapping function is used to obtain a mapped output brightness for an input brightness; The adjustment module is used to adjust the brightness of each pixel of the second video frame according to the brightness mapping function to obtain the second video frame after the brightness adjustment, so as to play the adjusted second video frame.
12. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the video processing method according to any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the video processing method according to any one of claims 1 to 10.
14. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the video processing method as described in any one of claims 1 to 10.
Citation Information
Cited By
Data processing method and device, electronic equipment, program product and storage medium
CN122205053A