Image encoding method, device, storage medium and electronic device
By dividing the target image and adjusting the quantization parameters, the problem of poor image encoding effect is solved and a higher quality encoding effect is achieved.
Patent Information
- Application Number
- CN202410744396.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-11
AI Technical Summary
In the existing technology, image coding has subjective problems such as tailing effects, resulting in poor coding effects, and there is no effective solution yet.
By dividing the target image, the target area of interest, the expanded area of interest and other areas are determined, the initial offset value and quantization parameters are calculated according to the image characteristics, and the quantization parameters are adjusted to achieve adaptive coding.
It improves the image coding quality, solves the problem of poor coding effect, and reduces the tailing effect and blocking effect.
Smart Images

Figure CN118317092B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of communications, and in particular, to an image encoding method, device, storage medium, electronic device, and computer program product. Background Art
[0002] In the related art, images are usually encoded using predicted motion trajectories. However, encoding images using predicted motion trajectories may cause subjective problems such as a tailing effect on the trajectory after motion.
[0003] It can be seen from this that the related art has the problem of poor image encoding effect.
[0004] Currently, no effective solution has been proposed for the above-mentioned problems existing in the related technologies. Summary of the invention
[0005] The embodiments of the present invention provide an image encoding method, device, storage medium, electronic device, and computer program product to at least solve the problem of poor image encoding effect existing in the related art.
[0006] According to one embodiment of the present invention, a method for encoding an image is provided, comprising: dividing the target image based on image features of the target image to obtain a target region of interest, an extended region of interest, and other regions, wherein the other regions are regions in the target image other than the target region of interest and the extended region of interest; performing the following operations for each target region included in the target region of interest, the extended region of interest, and the other regions to encode the target image: when the target region is not one of the other regions, determining a target region of interest comprehensive value indicating the importance of the target region, and based on the target region of interest comprehensive value Determine an initial offset value of the target area, determine a first calculation value when the target area is the other area, and determine the initial offset value of the target area based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value for indicating a target motion type of the target motion existing in the target area, and a first texture calculation value for indicating a target texture complexity of the target area; adjust the initial offset value based on encoding information of an encoded image included in the video where the target image is located to obtain a target offset value; adjust an initial quantization parameter based on the target offset value to obtain a target quantization parameter, and encode the target area based on the target quantization parameter.
[0007] According to another embodiment of the present invention, there is provided an image encoding device, comprising: a division module, for dividing the target image based on image features of the target image to obtain a target region of interest, an extended region of interest and other regions, wherein the other regions are regions in the target image other than the target region of interest and the extended region of interest; an encoding module, for performing the following operations for each target region included in the target region of interest, the extended region of interest and the other regions to encode the target image: when the target region is not the other region, determining a target region of interest comprehensive value indicating the importance of the target region, based on the target region of interest; The comprehensive value of the region of interest determines the initial offset value of the target region, and when the target region is the other region, determines a first calculation value, and determines the initial offset value of the target region based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value for indicating the target motion type of the target motion existing in the target region, and a first texture calculation value for indicating the target texture complexity of the target region; the initial offset value is adjusted based on the encoding information of the encoded image included in the video where the target image is located to obtain the target offset value; the initial quantization parameter is adjusted based on the target offset value to obtain the target quantization parameter, and the target region is encoded based on the target quantization parameter.
[0008] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.
[0009] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0010] According to yet another embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.
[0011] According to the present invention, a target image is divided based on the image features of the target image to obtain a target region of interest, an expanded region of interest and other regions, wherein the other regions are regions other than the target region of interest and the expanded region of interest in the target image; the following operations are performed for each target region included in the target region of interest, the expanded region of interest and other regions to encode the target image: when the target region is not other regions, a target region of interest comprehensive value indicating the importance of the target region is determined, an initial offset value of the target region is determined based on the target region of interest comprehensive value; when the target region is other regions, a first calculated value is determined, and an initial offset value of the target region is determined based on the first calculated value, wherein the first calculated value includes at least one of the following: a first motion detection value indicating a target motion type of a target motion existing in the target region, a first texture calculated value indicating a target texture complexity of the target region, the initial offset value is adjusted based on the encoding information of an encoded image included in a video where the target image is located to obtain a target offset value; an initial quantization parameter is adjusted based on the target offset value to obtain a target quantization parameter, and the target region is encoded based on the target quantization parameter. Since the target image can be divided according to the image features of the target image to obtain the target region of interest, the extended region of interest and other regions, the target offset value for adjusting the initial quantization parameter is determined for each target region, and the initial quantization parameter is adjusted using the target offset value to obtain the target quantization parameter, and each target region is encoded using its corresponding target quantization parameter to complete the encoding of the target image. That is, the quantization parameter can be adaptively adjusted according to the image parameter to achieve the encoding of the target region of interest, the extended region of interest and other regions using different target quantization parameters, therefore, the problem of poor image encoding effect existing in the related art can be solved, and the effect of improving the image encoding quality can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a hardware structure block diagram of a mobile terminal of an image encoding method according to an embodiment of the present invention;
[0013] Figure 2 is a flowchart of a method for encoding an image according to an embodiment of the present invention;
[0014] Figure 3 is a schematic diagram of a sub-region of each frame of an image in N consecutive frames of images according to an embodiment of the present invention;
[0015] Figure 4 is a schematic diagram of a combined area according to an embodiment of the present invention;
[0016] Figure 5 is a schematic diagram of a target region of interest according to an embodiment of the present invention;
[0017] Figure 6 is a schematic diagram of expanding the region of interest according to an embodiment of the present invention Figure 1 ;
[0018] Figure 7 is a schematic diagram of a historical region of interest of an encoded image according to an embodiment of the present invention;
[0019] Figure 8 is a schematic diagram of a target region of interest of a target image according to an embodiment of the present invention;
[0020] Fig. 9 is an expanded region of interest 2 according to an embodiment of the present invention;
[0021] Fig.10 is a flow chart of an image encoding method according to a specific embodiment of the present invention;
[0022] Fig.11 is a structural block diagram of an image encoding device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0025] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of an image encoding method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the image encoding method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0028] In this embodiment, a method for encoding an image is provided. Figure 2 is a flowchart of a method for encoding an image according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:
[0029] Step S202, dividing the target image based on image features of the target image to obtain a target region of interest, an expanded region of interest, and other regions, wherein the other regions are regions in the target image other than the target region of interest and the expanded region of interest;
[0030] Step S204, performing the following operations for each target area included in the target area of interest, the extended area of interest and the other areas to encode the target image: when the target area is not the other areas, determining a target area of interest comprehensive value indicating the importance of the target area, determining an initial offset value of the target area based on the target area of interest comprehensive value; when the target area is the other areas, determining a first calculation value, and determining the initial offset value of the target area based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value indicating a target motion type of the target motion existing in the target area, a first texture calculation value indicating a target texture complexity of the target area; adjusting the initial offset value based on the encoding information of an encoded image included in the video where the target image is located to obtain a target offset value; adjusting an initial quantization parameter based on the target offset value to obtain a target quantization parameter, and encoding the target area based on the target quantization parameter.
[0031] In the above embodiments, the image encoding method can be applied in the video encoding scene, and the method for encoding each frame of the video can utilize the image encoding method. The standards for video encoding and decoding include H.264 / AVC, H.265 / HEVC, H.266 / VVC, VP8, VP9, AV1, AVS, etc., and their main purpose is to compress the collected video signal into data in different standard formats for easy transmission or storage. In order to apply video encoding technology to actual scenes and improve subjective quality while compressing the bit rate, rate control, ROI, motion detection and other technologies are widely used in actual encoding. The code rate of the encoder can be controlled to a certain degree by controlling some encoder parameters. Generally speaking, the higher the bit rate, the higher the subjective quality of the video and the worse the compression rate; conversely, the worse the subjective quality of the video, but the higher the compression rate. Bit rate control is a method of achieving a balance between subjective quality and compression rate. Common bit rates include constant bit rate (CBR), variable bit rate (VBR), adaptive variable bit rate (AVBR), etc.
[0032] In the above embodiment, the target image may be any frame image included in the video, and the image features may include texture features, such as temporal texture information and spatial texture information. The image features may also include region of interest information, and may also include color information, shape information, depth information, motion information, etc. Dividing the target image based on the image features of the target image to obtain the target region of interest, the extended region of interest, and other regions may include: determining the target region of interest based on the region of interest information included in the image features, determining the region whose distance from the target region of interest is less than the set parameter as the extended region of interest, and determining the region other than the target region of interest and the extended region of interest in the target image as other regions. Among them, other regions may also be referred to as non-regions of interest. The target region of interest ROI in the image may be found by applying a threshold and an edge detection algorithm. ROI (Region of Interest): A region in the image is selected from the image, and this region is the focus of image analysis and attention. Encircling the region for further processing can reduce processing time and increase accuracy. Deep learning and computer vision technology can also be used to train models to automatically detect and identify regions of interest in images. A feature point detection algorithm can also be used to find significant feature points in the image and determine the ROI accordingly. The significant feature points in the target region of interest can be greater than the first parameter value, and the significant feature points in the extended region of interest can be greater than the second parameter value and less than the first parameter value, wherein the first parameter value is greater than the second parameter value.
[0033] In the above embodiment, the ROI area, the expanded area of interest, and the non-ROI area are divided by image features, and the QP offset values are calculated according to the areas, and the QP offset values are adjusted and limited using the encoded frame information, and then used for encoding to ensure that the objective result of encoding, subjective quality, and user needs are optimal. By determining the expanded area of interest, that is, the expansion method of the ROI planning, the subjective quality around the ROI area can be improved, and the problems of tailing effect and block effect around the ROI area can be effectively reduced.
[0034] In the above embodiment, the target offset value of the target region of interest can be determined, the initial quantization parameter of the target region of interest can be adjusted according to the target offset value, the target quantization parameter can be obtained, and the target region of interest can be encoded according to the target quantization parameter. The target offset value of the extended region of interest can be determined, the initial quantization parameter of the extended region of interest can be adjusted according to the target offset value, the target quantization parameter can be obtained, and the extended region of interest can be encoded according to the target quantization parameter. The target offset values of other regions can be determined, the initial quantization parameters of other regions can be adjusted according to the target offset value, the target quantization parameter can be obtained, and the other regions can be encoded according to the target quantization parameter. Among them, the initial quantization parameter of the target region of interest, the initial quantization parameter of the extended region of interest, and the initial quantization parameters of other regions can be predetermined parameters. The initial quantization parameter of the target region of interest, the initial quantization parameter of the extended region of interest, and the initial quantization parameters of other regions can be initial parameters of the encoding method for encoding the image. The three can be the same or different. Among them, the quantization parameter can be expressed as QP, Quantization Parameter, the quantization parameter used in the encoding process.
[0035] In the above embodiment, the target area may include target motion, and the target motion detection value of the target area can be determined according to the type of motion. The target texture calculation value is determined according to the target texture complexity, and the target region of interest comprehensive value is determined according to the importance of the target area. The initial offset value of the target area is determined according to the target motion detection value, the target texture calculation value, and the target region of interest comprehensive value.
[0036] In the above embodiment, the initial offset value can be adjusted according to the encoded image in the video where the target image is located, wherein the encoded image can include one frame of image or multiple frames of image, and the present invention does not limit this. Adjusting the initial offset value can include increasing or decreasing the initial offset value, and of course, adjusting the initial offset value can also include keeping the initial offset value unchanged.
[0037] In the above embodiment, adjusting the initial quantization parameter based on the target offset value may include adding the initial quantization parameter to the target offset value to obtain the target quantization parameter, and may also include subtracting the initial quantization parameter from the target offset value to obtain the target quantization parameter.
[0038] According to the present invention, a target image is divided based on the image features of the target image to obtain a target region of interest, an expanded region of interest and other regions, wherein the other regions are regions other than the target region of interest and the expanded region of interest in the target image; the following operations are performed for each target region included in the target region of interest, the expanded region of interest and other regions to encode the target image: when the target region is not other regions, a target region of interest comprehensive value indicating the importance of the target region is determined, an initial offset value of the target region is determined based on the target region of interest comprehensive value; when the target region is other regions, a first calculated value is determined, and an initial offset value of the target region is determined based on the first calculated value, wherein the first calculated value includes at least one of the following: a first motion detection value indicating a target motion type of a target motion existing in the target region, a first texture calculated value indicating a target texture complexity of the target region, the initial offset value is adjusted based on the encoding information of an encoded image included in a video where the target image is located to obtain a target offset value; an initial quantization parameter is adjusted based on the target offset value to obtain a target quantization parameter, and the target region is encoded based on the target quantization parameter. Since the target image can be divided according to the image features of the target image to obtain the target region of interest, the extended region of interest and other regions, the target offset value for adjusting the initial quantization parameter is determined for each target region, and the initial quantization parameter is adjusted using the target offset value to obtain the target quantization parameter, and each target region is encoded using its corresponding target quantization parameter to complete the encoding of the target image. That is, the quantization parameter can be adaptively adjusted according to the image parameter to achieve the encoding of the target region of interest, the extended region of interest and other regions using different target quantization parameters, therefore, the problem of poor image encoding effect existing in the related art can be solved, and the effect of improving the image encoding quality can be achieved.
[0039] Optionally, the executor of the above steps may be a background processor, or other devices with similar processing capabilities, or a machine that integrates at least an image acquisition device and a data processing device, wherein the image acquisition device may include a graphics acquisition module such as a camera, and the data processing device may include a computer, a mobile phone or other terminal, but is not limited thereto.
[0040] In an exemplary embodiment, dividing the target image based on the image features of the target image to obtain the target region of interest, the extended region of interest and other regions includes: determining the target region of interest based on the region of interest information included in the image features; determining the extended region of interest based on the temporal texture information or spatial texture information included in the image features; and determining the region other than the target region of interest and the extended region of interest included in the target image as the other region. In this embodiment, the region of interest information may include information such as the area, area ratio, time length, type, and level of the ROI. Temporal texture information may refer to image texture features presented in temporal changes. Temporal texture information may describe the temporal changes, motions, actions and other features of an image, such as movement, deformation, and vibration of an object. Spatial texture information may be the spatial relationship and distribution features between pixels in an image. Spatial texture usually describes the texture features of an image by counting the grayscale values or color distribution between pixels. Determining spatial texture information may include grayscale co-occurrence matrix, local binary pattern, directional gradient histogram, and the like. By analyzing and extracting the spatial texture of an image, we can help understand the structure and features of the image, which can then be used in applications such as image classification, target detection, and image segmentation.
[0041] In the above embodiment, the ROI area can be divided by an algorithm, and the target image is analyzed to divide the ROI area, i.e., the target region of interest, the ROI extension area, i.e., the extended region of interest, and the non-ROI area, i.e., other areas. According to the ROI prior information, i.e., the region of interest information, the ROI area, area ratio, type, level and other information of the current frame can be obtained to divide the region where the ROI is located. According to the prior information such as the time domain texture information, the spatial domain texture information, etc., the ROI area can be expanded to divide the ROI extension area; and the remaining area is used as the non-ROI area.
[0042] It should be noted that the target region of interest, the expanded region of interest and other regions may be independent regions, and the three regions have no intersection.
[0043] In an exemplary embodiment, determining the extended region of interest based on the temporal texture information included in the image features includes: determining N consecutive frames of images included in the video and located before the target image, wherein the last frame of the N consecutive frames is adjacent to the target image, and the N consecutive frames all include the target object included in the target image, and N is an integer greater than or equal to 1; determining the motion trajectory of the target object based on the temporal texture information of the N consecutive frames; determining the sub-regions in each frame of the N consecutive frames included in the motion trajectory; combining the sub-regions included in each frame to obtain a combined region; determining the overlapping region between the combined region and the target region of interest; and determining the other regions included in the combined region except the overlapping region as the extended region of interest. In this embodiment, the extended region can be divided by the motion trajectory combined with the object. For example, the trajectory of the last few frames that is not planned in the ROI region can be combined with the object to be divided into the ROI extended region. Get the first N continuous image frames before the target image in the video. For example, in the video, the target image is the 7th frame image. N continuous image frames can be determined from the images of the 1st to 6th frames in the video. The N continuous image frames all include the target object in the target image. For example, if the 4th to 6th frames include the target object, the 4th, 5th and 6th frames are determined as N continuous image frames. It should be noted that the N continuous image frames can be multiple frames or single frames. When only one frame of the image before the target image in the video includes the target object, the N continuous image frames are 1 frame.
[0044] In the above embodiment, the motion trajectory of the target object can be determined based on the time domain texture information of each frame included in N frames of continuous images, and the sub-region of the motion trajectory in the image can be determined, and multiple sub-regions are combined to obtain a combined region, and the overlapping region between the combined region and the target region of interest is determined, and the region except the overlapping region in the combined region is determined as the expanded region of interest.
[0045] In the above embodiment, N=3, N consecutive frames of images may include 3 frames, and the sub-region of each frame of the N consecutive frames of images may be as shown in the attached figure. Figure 3 The shaded area in the figure can be shown in the attached figure. Figure 4 The target area of interest can be as shown in the following figure. Figure 5 The shaded part in the image is as follows: Figure 6 The shaded part of the image.
[0046] In an exemplary embodiment, determining the extended region of interest based on the spatial texture information included in the image features includes: determining a first region in the target image whose distance from the target region of interest is less than a first threshold; determining a texture complexity indicating the complexity of the texture included in the first region based on the spatial texture information of the first region; and determining a second region in the first region whose texture complexity is greater than a second threshold as the extended region of interest. In this embodiment, the extended region can also be divided according to the union of ROI regions, and the spatial texture information around the current frame ROI region, that is, the target region of interest, is calculated; and the texture complex region around the ROI region is expanded to the ROI extended region.
[0047] In an exemplary embodiment, dividing the target image based on the image features of the target image to obtain the target region of interest, the extended region of interest and other regions includes: determining the target region of interest based on the region of interest information included in the image features; determining the historical region of interest of the encoded image included in the video; determining the union of the historical regions of interest to obtain a third region; determining the fourth region included in the third region that overlaps with the target region of interest; determining the region other than the fourth region included in the third region as the extended region of interest; determining the region other than the target region of interest and the extended region of interest included in the target image as the other region. In this embodiment, the region of interest information may include information such as the region, area ratio, time length, type, and level of the ROI. The target region of interest may be determined based on the region of interest information. And the historical region of interest of the encoded image included in the video is determined. Among them, the encoded image may be a multi-frame image or a single-frame image. The ROIs of the encoded frames are taken as the union, and the coverage area of the encoded frames in the ROI region is obtained and divided into the extended region of the ROI. When the coded image is 1 frame, the historical region of interest of the coded image can be found in the attached Figure 7 The target region of interest of the target image can be found in the attached Figure 8 , please refer to the attached Fig. 9 .
[0048] In an exemplary embodiment, determining a target motion detection value for indicating a motion type of a target motion existing in the target area includes: determining the target motion type of the target motion existing in the target area based on the temporal texture information of the target area; determining a first correspondence between the motion type and the motion detection value; and determining the target motion detection value corresponding to the target motion type included in the first correspondence. In this embodiment, the temporal texture can be divided into motion conditions, including but not limited to four conditions: stillness, small motion, medium motion, and large motion, represented by md. There may be a first correspondence between the motion type and the motion detection value. The motion type may include stillness, small motion, medium motion, large motion, etc. The first correspondence may be expressed as , where md represents the motion detection value. For example, the target motion type in the target area can be determined based on the temporal texture information of the target area. When the target motion type is stationary, the target motion detection value can be 0.
[0049] In an exemplary embodiment, determining a target texture calculation value for indicating the target texture complexity of the target area includes: determining the target texture complexity of the target area based on the spatial texture information of the target area; determining a second correspondence between texture complexity and texture calculation value; and determining the target texture calculation value corresponding to the target texture complexity included in the second correspondence. In this embodiment, the target texture complexity of the target area can be determined based on the spatial texture information of the target area. The spatial texture can be divided into four complex situations, including but not limited to simple, small complex, medium complex, and large complex, represented by tex. The second correspondence can be expressed as , where tex represents the texture calculation value. For example, when the target texture complexity is simple, the target texture calculation value is 0.
[0050] In an exemplary embodiment, determining a target region of interest comprehensive value for indicating the importance of the target region includes: determining a second calculated value of the target region of interest comprehensive value, wherein the second calculated value includes at least one of the following: a first level corresponding to a target area of the target region of interest, a second level corresponding to a target duration of the target region of interest appearing in the video, and a third level corresponding to the importance of the target region of interest, wherein the importance of the target region of interest is determined based on objects included in the target region of interest and a correspondence between objects and importance; determining a first product of the first target calculated value and a first weight of the target calculated value for each first target calculated value included in the second calculated value; and mapping the target region of interest comprehensive value based on the first product. In this embodiment, the target region of interest comprehensive value may be determined based on one or more of the target area of the target region of interest, the target duration of the target region of interest appearing in the video, and the importance of the target region of interest. When determining the target region of interest comprehensive value based on one of the options, the target region of interest comprehensive value may be mapped based on the level corresponding to the option, the target region of interest comprehensive value may be mapped based on the first product of the level corresponding to the option and the first weight, and the target region of interest comprehensive value may be mapped based on the first product of the level corresponding to the option and the first weight and other values. The mapping includes but is not limited to addition, subtraction, multiplication, division, convolution, and rounding.
[0051] In the above embodiment, when the target interest comprehensive value is determined according to multiple options of the target area of the target interest region, the target duration of the target interest region appearing in the video, and the importance of the target interest region, the sum of the values corresponding to the multiple options can be determined as the target interest comprehensive value, and the first product of each option and its weight can be determined, and the target interest region comprehensive value is mapped according to the multiple first products. The mapping may include but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc.
[0052] In an exemplary embodiment, determining the target region of interest comprehensive value for indicating the importance of the target region includes: determining a first level corresponding to the target area of the target region of interest; determining a second level corresponding to the target duration of the target region of interest appearing in the video; determining a third level corresponding to the importance of the target region of interest, wherein the importance of the target region of interest is determined based on the objects included in the target region of interest and the corresponding relationship between the objects and the importance; determining a target first weight corresponding to the first level, determining a target second weight corresponding to the second level, and determining a target third weight corresponding to the third level; determining a first product of the first level and the target first weight, determining a second product of the second level and the target second weight, and determining a third product of the third level and the target third weight; and determining the sum of the first product, the second product, and the third product as the target region of interest comprehensive value. In this embodiment, ROI information acquisition includes but is not limited to the following information: its location area, occupied area, occupied duration, ROI level, etc. The target region of interest comprehensive value can be determined according to the region of interest information. For example, the starting point of the ROI region coordinates at 1080P resolution is (0, 0), and the ending point is (300, 400). The area occupied by the divided region is 300*400=120,000 pixels, and the proportion is 120,000 / (1920*1080)=0.058, so the area ratio is 5.8%. If the area ratio is divided into 10 levels from 1 to 10 according to the ratio of 10%, the level of the area ratio is 1. If the duration of the occupied region is 30 seconds in total, accounting for 50% of the duration of 1 minute, and the time ratio is divided into 10 levels from 1 to 10 according to the ratio of 10%, the level of the time ratio is 5. The ROI importance level classification N=3 is divided into three types: important, unimportant, and ignored. For important types, we can focus on increasing the bit rate investment, not process unimportant areas, and reduce the bit rate investment for ignored areas. Assume that the level value can correspond to -10, 0, and 10 respectively according to unimportant, neglected, and important. In this embodiment, the level classification is important. The value of ROI needs to combine the above three situations and finally calculate a comprehensive ROI value; assuming that the area accounts for 20%, the time accounts for 20%, and the level classification accounts for 60% in the comprehensive value calculation, the calculation formula of ROI is as follows: ROI=1*0.2+5*0.2+10*0.6=7.2. After fusion, the comprehensive value of ROI is 7.2.
[0053] It should be noted that the above-mentioned target first weight, target second weight and target third weight are only exemplary descriptions, and the target first weight, target second weight and target third weight can also be set to other values, which is not limited in the present invention.
[0054] In an exemplary embodiment, determining the initial offset value of the target region based on the target region of interest comprehensive value includes: when the target region is the target region of interest, mapping the initial offset value based on the target region of interest comprehensive value; when the target region is the extended region of interest, mapping the initial offset value based on the target region of interest comprehensive value and a first preset constant. In this embodiment, mapping the initial offset value according to the target region of interest comprehensive value may include determining the target region of interest comprehensive value as the initial offset value, and may also include performing an operation on the target region of interest comprehensive value, and determining the operation result as the initial offset value, and the operation includes but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc. For example, the target region of interest comprehensive value plus the target region of interest comprehensive value, the target region of interest comprehensive value multiplied, divided or subtracted by a certain coefficient, the target region of interest comprehensive value convolved with the target region of interest comprehensive value, the target region of interest comprehensive value rounded up, rounded down, etc., and may also include comparing the operation result with a mapping table to determine the initial offset value corresponding to the operation result in the mapping table. Among them, the mapping table may be a predetermined table, and the mapping table includes a one-to-one correspondence between each operation result and the offset value.
[0055] In the above embodiment, mapping the initial offset value based on the target comprehensive value of interest and the first preset constant may include performing an operation on the target comprehensive value of interest and the first preset constant, and determining the operation result as the initial offset value, and the operation includes but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc. For example, the target comprehensive value of interest is added with the first preset constant, the target comprehensive value of interest is multiplied, divided or subtracted with the first preset constant, the target comprehensive value of interest is convolved with the first preset constant, the target comprehensive value of interest is rounded up or rounded down after the operation is performed with the first preset constant, etc., and it may also include comparing the operation result with a mapping table to determine the initial offset value corresponding to the operation result in the mapping table. Among them, the mapping table may be a predetermined table, and the mapping table includes a one-to-one correspondence between each operation result and the offset value.
[0056] In an exemplary embodiment, determining the initial offset value of the target area based on the target region of interest comprehensive value includes: when the target area is not the other area, determining a third calculation value, wherein the third calculation value includes at least one of the following: a second motion detection value for indicating the target motion type of the target motion existing in the target area, and a second texture calculation value for indicating the target texture complexity of the target area; when the target area is the target region of interest, determining a second product of the second target calculation value and a second weight of the second target calculation value for each second target calculation value included in the third calculation value, and mapping the initial offset value based on the target region of interest comprehensive value and the second product; when the target area is the extended region of interest, determining a third product of the second target calculation value and a third weight of the second target calculation value for each second target calculation value included in the third calculation value, and mapping the initial offset value based on the target region of interest comprehensive value, the third product and a second preset constant. In this embodiment, when the target region is a target region of interest or an extended region of interest, the initial offset value may be mapped according to the target region of interest comprehensive value and the second motion detection value, or according to the target region of interest comprehensive value and the second texture calculation value, or according to the target region of interest comprehensive value, the second motion detection value and the second texture calculation value. The mapping may include but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc.
[0057] In the above embodiment, a second motion detection value indicating the target motion type of the target motion existing in the target area can be determined, or a second texture calculation value indicating the target texture complexity of the target area can be determined, or a second motion detection value and a second texture calculation value can be determined. The second product of the second motion detection value and / or the second texture calculation value and its corresponding weight can be determined. The initial offset value is mapped according to the target region of interest comprehensive value and the second product. For example, the sum of the target region of interest comprehensive value and the second product can be determined as the initial offset value, the difference between the target region of interest comprehensive value and the second product can be determined as the initial offset value, the product of the target region of interest comprehensive value and the second product can be determined as the initial offset value, the ratio of the target region of interest comprehensive value to the second product can be determined as the initial offset value, the convolution of the target region of interest comprehensive value and the second product can be determined as the initial offset value, and the operation result of the target region of interest comprehensive value and the second product can be rounded up, rounded down, etc. to obtain the initial offset value. The operation result of the target region of interest comprehensive value and the second product can also be compared with the mapping table to determine the initial offset value corresponding to the operation result in the mapping table. The mapping table may be a predetermined table, which includes a one-to-one correspondence between each operation result and the offset value.
[0058] In an exemplary embodiment, determining the initial offset value of the target region based on the target region of interest comprehensive value includes: when the target region is the target region of interest, determining a fourth product of a target fourth weight corresponding to the target motion detection value and the target motion detection value, and determining a fifth product of a target fifth weight corresponding to the target texture calculation value and the target texture calculation value; determining the sum of the fourth product, the fifth product and the comprehensive value of the target region of interest as the initial offset value; when the target region is the extended region of interest, determining a sixth product of a target sixth weight corresponding to the target motion detection value and the target motion detection value, and determining a seventh product of a target seventh weight corresponding to the target texture calculation value and the target texture calculation value; determining the sum of the sixth product and the seventh product, the target region of interest comprehensive value and a preset constant as the initial offset value; when the target region is other regions, determining a eighth product of a target eighth weight corresponding to the target motion detection value and the target motion detection value, and determining a ninth product of a target ninth weight corresponding to the target texture calculation value and the target texture calculation value; and determining the sum of the eighth product and the ninth product as the initial offset value. In this embodiment, the calculation of the QP initial offset value is mapped in different ways according to different regions; the main factors affecting the size of the QP offset value include but are not limited to information such as temporal texture, spatial texture, and ROI level: the current frame can be partitioned according to the size of the spatial texture.
[0059] Class; can distinguish the motion of the current frame based on the time domain texture, divided into
[0060] Classification; It can be targeted at ROI information, including but not limited to the following information: its location area, occupied area, occupied time, ROI level, etc., where the location area is element s1, the occupied area is element s2, the occupied time is element s3, and the ROI level is element s4. The classification is obtained by the following formula:
[0061] .
[0062] Among them, f 1 is the mapping function curve, which can be a linear function or a nonlinear function, N 3 is the classification result. The rest of the reference information is Based on the above m types of information, the initial QP offset value Offset can be calculated respectively:
[0063]
[0064] Among them, f2, f3, and f4 are mapped function curves, which can be linear functions or nonlinear functions, and Offset is the calculated offset value result.
[0065] In the above embodiment, the target fourth weight, the target fifth weight, the target sixth weight, the target seventh weight, the target eighth weight and the target ninth weight are predetermined weights. The target fourth weight, the target fifth weight, the target sixth weight, the target seventh weight, the target eighth weight and the target ninth weight may be the same, different or partially the same, and the present invention is not limited thereto.
[0066] In the above embodiment, the initial offset value can be expressed as , where ROI area represents the initial offset value of the target region of interest, ROI expansion represents the initial offset value of the expanded region of interest, and non-ROI area represents the offset value of other regions. md represents the target motion detection value, tex represents the target texture calculation value, ROI represents the target region of interest comprehensive value, and d represents a preset constant. At this time, the fourth target weight, the fifth target weight, the sixth target weight, the seventh target weight, the eighth target weight, and the ninth target weight are 0.3, 0.2, 0.3, 0.2, 0.7, and 0.3, respectively.
[0067] When the md motion detection value is 3, the tex texture calculation value is set to 2, the ROI is the value calculated by ROI synthesis and is set to 7.2, and the d is a constant set to -1, the QP offset value calculated according to the above model is .
[0068] It should be noted that the target fourth weight, target fifth weight, target sixth weight, target seventh weight, target eighth weight and target ninth weight in the above formula are only exemplary descriptions. The target fourth weight, target fifth weight, target sixth weight, target seventh weight, target eighth weight and target ninth weight can also be other values, and the present invention is not limited to this.
[0069] In an exemplary embodiment, determining the initial offset value of the target area based on the first calculation value includes: determining the fourth product of the third target calculation value and the fourth weight for each third target calculation value included in the first calculation value; and mapping the initial offset value based on the fourth product. In this embodiment, for other areas, the first motion detection value and / or the first texture calculation value of other areas can be determined. The initial offset value can be mapped according to the fourth product of the first motion detection value and the fourth weight, and the initial offset value can also be mapped according to the fourth product of the first texture calculation value and the fourth weight, and the initial offset value can also be mapped according to the fourth product of the first motion detection value and the fourth weight and the fourth product of the first texture calculation value and the fourth weight. Mapping can include but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc. For example, when there is one fourth product, that is, there is a fourth product of the first motion detection value and the fourth weight, or there is a fourth product of the first texture calculation value and the fourth weight, the fourth product can be determined as the initial offset value, and the fourth product can also be operated with a coefficient to obtain an operation result, and the operation result is determined as the initial offset value, and the operation includes but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc. When there are two fourth products, that is, there is a fourth product of the first motion detection value and the fourth weight and a fourth product of the first texture calculation value and the fourth weight, the two fourth products can be operated to obtain an operation result, and the operation result is determined as the initial offset value, and the operation includes but is not limited to addition, subtraction, multiplication, division, convolution, rounding, etc. The operation result can also be compared with a mapping table to determine the initial offset value corresponding to the operation result in the mapping table. Among them, the mapping table can be a predetermined table, and the mapping table includes a one-to-one correspondence between each operation result and the offset value.
[0070] In an exemplary embodiment, the initial offset value is adjusted based on the encoding information of the encoded image included in the video where the target image is located, and obtaining the target offset value includes at least one of the following: determining a first peak signal-to-noise ratio of the target image, and determining a second peak signal-to-noise ratio of the encoded image, determining a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determining the sum of the initial offset value and a first constant as the target offset value, and when the first difference is less than a second set value, determining the difference between the initial offset value and the second constant as the target offset value, and when the first difference is greater than the second set value and less than the second set value. In the case of a first set value, the initial offset value is determined as the target offset value, wherein the first set value is greater than the second set value; a first complexity of the spatial domain texture of the target image is determined, and a second complexity of the spatial domain texture of the encoded image is determined, a second difference between the first complexity and the second complexity is determined, and in the case that the second difference is greater than a third set value, the difference between the initial offset value and a third constant is determined as the target offset value, and in the case that the second difference is less than a fourth set value, the sum of the initial offset value and the fourth constant is determined as the target offset value, and in the case that the second difference is greater than the fourth set value and less than the third set value, the initial offset value is determined as the target offset value, wherein the third set value is less than the fourth set value; determining a first peak signal-to-noise ratio of the target image, and determining a second peak signal-to-noise ratio of the encoded image, determining a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than the first set value, determining the sum of the initial offset value and the first constant as the first intermediate offset value, and when the first difference is less than the second set value, determining the difference between the initial offset value and the second constant as the first intermediate offset value, and when the first difference is greater than the second set value and less than the first set value, determining the initial offset value as the first intermediate offset value, wherein the first The set value is greater than the second set value, a first complexity of the spatial domain texture of the target image is determined, and a second complexity of the spatial domain texture of the encoded image is determined, a second difference between the first complexity and the second complexity is determined, and when the second difference is greater than a third set value, a difference between the first intermediate offset value and a third constant is determined as the target offset value, and when the second difference is less than a fourth set value, a sum of the first intermediate offset value and a fourth constant is determined as the target offset value, and when the second difference is greater than the fourth set value and less than the third set value, the first intermediate offset value is determined as the target offset value, wherein the third set value is less than the fourth set value;Determine a first complexity of the spatial domain texture of the target image, and determine a second complexity of the spatial domain texture of the encoded image, determine a second difference between the first complexity and the second complexity, and when the second difference is greater than a third set value, determine the difference between the initial offset value and a third constant as a second intermediate offset value, and when the second difference is less than a fourth set value, determine the sum of the initial offset value and a fourth constant as the second intermediate offset value, and when the second difference is greater than the fourth set value and less than the third set value, determine the initial offset value as the second intermediate offset value, wherein the third set value is less than the fourth set value; Determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the second intermediate offset value and a first constant as the target offset value, and when the first difference is less than a second set value, determine the difference between the second intermediate offset value and a second constant as the target offset value, and when the first difference is greater than the second set value and less than the first set value, determine the second intermediate offset value as the target offset value, wherein the first set value is greater than the second set value. In this embodiment, the obtained encoded frame information can be used to adjust the obtained QP initial offset value, and the encoded frame information includes but is not limited to information such as PSNR, spatial texture, and encoded frame quantization parameter QP. ;
[0071] In the above embodiment, the second peak signal-to-noise ratio PSNR of the ROI region of the encoded previous frame can be compared with the first peak signal-to-noise ratio PSNR in the ROI region of the current frame. If the PSNR difference is higher than the maximum critical value, the QP offset value is adjusted upward; if the PSNR difference is lower than the minimum critical value, the QP offset value is adjusted downward; if the PSNR difference is between the maximum and minimum critical values, no adjustment is required. The adjustment formula can be Offset new =f 5 (offset,PSNR ROI ,PSNR max ,PSNR min , PSNR last ). Among them, offset is the initial offset value of QP, PSNR ROI is the PSNR value of the ROI area in the current frame, that is, the first peak signal-to-noise ratio of the target image, PSNR max is the first setting value, PSNR min is the second set value, which is the pre-set critical value of the ROI area, PSNR lastIt is the average PSNR of the ROI area of the encoded frame, that is, the second peak signal-to-noise ratio.
[0072] In the above embodiment, the spatial texture complexity of the ROI region of the last frame or frames that have been encoded can be compared with the spatial texture complexity in the ROI region. If the texture complexity difference is higher than the maximum critical value of the complexity in the ROI region, the QP offset value is adjusted downward; if the texture complexity difference is lower than the minimum critical value of the complexity in the ROI region, the QP offset value is adjusted upward. The adjustment formula can be Offset new =f 6 (offset,TEX ROI , TEX max , TEX min , TEX last ). Among them, the critical values of the maximum and minimum spatiotemporal texture are expressed as TEX max (Third setting value), TEX min (Fourth setting value); The first complexity of the spatial texture in the ROI area is TEX ROI , TEX last It is the average complexity of the spatial texture of the ROI area of the encoded frame, that is, the second complexity.
[0073] In the above embodiment, the Offset new =f 5 (offset,PSNR ROI ,PSNR max , PSNR min ,PSNR last ) Adjust the initial offset value to determine the first method, through the Offset new =f 6 (offset,TEX ROI , TEX max ,TEX min , TEX last) Adjust the initial offset value to determine the second method. The initial offset value can be adjusted separately by the first method to obtain the target offset value. The initial offset value can also be adjusted separately by the second method to obtain the target offset value. The initial offset value can also be adjusted by the method of the first method plus the second method to obtain the target offset value. When the initial offset value is adjusted by the method of the first method plus the second method, the initial offset value adjusted by the first method can be defined as the first intermediate offset value, the first intermediate offset value is input into the second method as the initial offset value in the second method, and the first intermediate offset value is adjusted by the method of the second method to obtain the target offset value. Similarly, the initial offset value can also be adjusted by the method of the second method plus the first method to obtain the target offset value. When the initial offset value is adjusted by the method of the second method plus the first method, the initial offset value adjusted by the second method can be defined as the second intermediate offset value, the second intermediate offset value is input into the first method as the initial offset value in the first method, and the second intermediate offset value is adjusted by the method of the first method to obtain the target offset value.
[0074] In the above embodiment, the adjustment formula between PSNR and QP offset value in method 1 is Offset new =f 5 (offset,PSNR ROI ,PSNR max , PSNR min , PSNR last ) can be expressed as
[0075] , where the maximum and minimum PSNR are expressed as PSNR max 、PSNR min ; The first peak signal-to-noise ratio of the ROI area is PSNR ROI , the second peak signal-to-noise ratio is PSNR last When the encoded image consists of multiple frames, the second peak signal-to-noise ratio may be an average value of peak signal-to-noise ratios of the multiple frames.
[0076] In the above embodiment, the adjustment formula between the spatial texture and QP in the second method is Offset new =f 6 (offset,TEX ROI , TEX max , TEX min , TEX last ) can be expressed as
[0077] , where the maximum and minimum spatial texture critical values are expressed as TEX max (Third setting value), TEX min(Fourth setting value); The first complexity of the spatial texture in the ROI area is TEX ROI , TEX last is the second complexity of the spatial texture of the ROI region of the encoded image. When the encoded image is multiple frames, the second complexity may be an average value of the spatial texture complexities of the ROI region of the multiple frames.
[0078] In an exemplary embodiment, adjusting the initial quantization parameter based on the target offset value to obtain the target quantization parameter includes at least one of the following: determining a first quantization parameter of the encoded image, determining a third difference between the first quantization parameter and a fifth constant, and determining a first sum value between the first quantization parameter and a sixth constant, determining a target sum value between the initial quantization parameter and the target offset value, and when the target sum value is less than the third difference, determining the third difference as the target quantization parameter, and when the target sum value is greater than the first sum value, determining the first sum value as the target quantization parameter, and when the target sum value is greater than or equal to the third difference and less than or equal to the first sum value, determining the first sum value as the target quantization parameter. In the case of the target sum value being determined as the target quantization parameter; determining the second quantization parameter of the macroblock level of the encoded image, determining the fourth difference between the second quantization parameter and the seventh constant, and determining the second sum value of the second quantization parameter and the eighth constant, determining the target sum value of the initial quantization parameter and the target offset value, and in the case that the target sum value is less than the fourth difference value, determining the fourth difference value as the target quantization parameter, in the case that the target sum value is greater than the second sum value, determining the second sum value as the target quantization parameter, and in the case that the target sum value is greater than or equal to the fourth difference value and less than or equal to the second sum value, determining the target sum value as the target quantization parameter. In this embodiment, the QP offset value of the target area can also be limited to the upper and lower limits according to the size relationship between the first quantization parameter QP of the encoded image, the initial quantization parameter QP in the target area, and the macroblock QP in the target area, so as to ensure that the difference between the macroblock QP in the target area of the current frame and the QP of the entire frame in the target area of the previous frame is between the maximum and minimum critical values.
[0079] For example, taking the target region as the target region of interest, the QP of the target region of the current frame is the initial quantization parameter QP ROI , the first quantization parameter of the previous frame level QP is QP frame , the second quantization parameter of the macroblock-level QP is QP mb , then the restrictions are as follows: QP frame -10 <QP ROI +offset <QP frame +10;QP mb -5 <QP ROI+offset <QP mb +5.
[0080] In the above embodiment, after the target quantization parameter QP is determined, the adjusted quantization parameter QP may be applied to the encoder for encoding, and finally an encoded image or video sequence is obtained.
[0081] The following is an explanation of the image encoding method in conjunction with a specific implementation method:
[0082] Fig.10 is a flow chart of an image encoding method according to a specific embodiment of the present invention, such as Fig.10 As shown, the process includes:
[0083] Step S1002, obtaining prior information (corresponding to the above-mentioned image features).
[0084] The prior information of the current frame is obtained by software, hardware or other means. The prior information of the current frame obtained includes but is not limited to the following information: temporal texture information, spatial texture information, and ROI information. The temporal texture information may include the result of motion detection; the spatial texture information may include the spatial texture complexity of the current frame and the spatial texture complexity of the ROI area; the ROI information may include the area, area ratio, time length, type, level and other information of the ROI.
[0085] Step S1004: divide the regions according to the prior information, establish a mapping model according to the divided regions, and calculate the QP offset value.
[0086] Among them, the ROI area needs to be divided by an algorithm, and the current frame information is analyzed to divide the ROI area, ROI extension area and non-ROI area. The specific method is as follows:
[0087] (1) Based on the prior information of the ROI, obtain the ROI area, area ratio, type, level and other information of the current frame, and divide the ROI area;
[0088] (2) Based on prior information such as motion detection and spatial texture, the ROI area is expanded and the ROI expansion area is divided;
[0089] (3) The remaining area is regarded as the non-ROI area.
[0090] The specific methods for dividing the ROI expansion area in step (2) include but are not limited to the following three methods:
[0091] Method 1: Expand the area by combining motion trajectory with object division.
[0092] (1) Obtain the trajectory route by accumulating the trajectory of motion detection;
[0093] (2) The trajectories in the most recent frames that are not planned in the ROI area are combined with objects to form the ROI expansion area;
[0094] Method 2: Divide the expanded area by the union of the ROI regions.
[0095] (1) Obtain the ROI area of the encoded frame according to the ROI information;
[0096] (2) Taking the union of the ROIs of the encoded frames, the coverage area of the encoded frames in the ROI region is obtained and divided into the expanded area of the ROI;
[0097] Method 3: Divide the expanded region by the union of the ROI regions.
[0098] (1) Calculate the texture information around the ROI area of the current frame;
[0099] (2) Expand the complex texture area around the ROI area to the ROI expansion area.
[0100] The specific steps of establishing a mapping model and calculating the QP offset value according to the divided area are as follows:
[0101] The calculation of the initial QP offset value will be mapped in different ways according to different regions; the main factors affecting the size of the QP offset value include but are not limited to information such as temporal texture, spatial texture, and ROI level: the complexity of the current frame can be divided into
[0102] Class; can distinguish the motion of the current frame based on the time domain texture, divided into
[0103] Classification; It can be targeted at ROI information, including but not limited to the following information: its location area, occupied area, occupied time, ROI level, etc., where the location area is element s1, the occupied area is element s2, the occupied time is element s3, and the ROI level is element s4. The classification is obtained by the following formula:
[0104] .
[0105] Among them, f 1 is the mapping function curve, which can be a linear function or a nonlinear function, N 3 is the classification result. The rest of the reference information is Based on the above m types of information, the initial QP offset value Offset can be calculated respectively:
[0106]
[0107] Among them, f2, f3, and f4 are mapped function curves, which can be linear functions or nonlinear functions, and Offset is the calculated offset value result.
[0108] Temporal texture can be divided into four types of motion, including but not limited to static, small motion, medium motion, and large motion, represented by md:
[0109] .
[0110] Spatial textures can be classified into four complex situations, including but not limited to simple, slightly complex, medium complex, and highly complex, which are represented by tex: .
[0111] ROI information acquisition includes but is not limited to the following information: its location area, occupied area, occupied time, ROI level, etc.
[0112] At 1080P resolution, the starting point of the ROI area coordinates is (0, 0) and the ending point is (300, 400), so the divided area is determined; the area occupied is 300*400=120000 pixels, and the proportion is 120000 / (1920*1080)=0.058, so the area ratio is 5.8%. Assuming that the area ratio is divided into 10 levels of 1-10 according to the ratio of 10%, the level of the area ratio is 1.
[0113] Suppose the occupied area appears for a total of 30 seconds, which accounts for 50% of the 1-minute duration. Suppose the time proportion is divided into 10 levels from 1 to 10 according to a ratio of 10%, then the level of the time proportion is 5.
[0114] ROI level classification N=3, divided into three types: important, unimportant, and neglected. For the important type, the bit rate investment can be increased, the unimportant area is not processed, and the bit rate investment is reduced in the neglected area. The level values are set to -10, 0, and 10. In the embodiment, the level classification is important.
[0115] The value of ROI needs to combine the above three situations and finally calculate a comprehensive ROI value; assuming that the area accounts for 20%, the time accounts for 20%, and the level classification accounts for 60% in the comprehensive value calculation, the calculation formula of ROI is as follows: ROI=1*0.2+5*0.2+10*0.6=7.2. After fusion, the comprehensive value of ROI is 7.2.
[0116] The above three types of information are combined and mapped into the quantization parameter QP offset value: , when the md motion detection value is 3, the tex texture calculation value is set to 2, the ROI is the value calculated by ROI comprehensive calculation and is set to 7.2, and d is a constant set to -1, then the QP offset value calculated according to the above model is .
[0117] Step S1006: adjusting the QP initial offset value according to the encoded frame information.
[0118] By comparing the second peak signal-to-noise ratio (PSNR) of the ROI area of the previous frame that has been encoded with the first peak signal-to-noise ratio (PSNR) of the ROI area of the current frame, if the PSNR difference is higher than the maximum critical value, the QP offset value is adjusted upward; if the PSNR difference is lower than the minimum critical value, the QP offset value is adjusted downward; if the PSNR difference is between the maximum and minimum critical values, no adjustment is required. The adjustment formula can be Offset new =f 5 (offset,PSNR ROI ,PSNR max , PSNR min , PSNR last ). Among them, offset is the initial offset value of QP, PSNR ROI is the PSNR value of the ROI area in the current frame, that is, the first peak signal-to-noise ratio of the target image, PSNR max is the first setting value, PSNR min is the second set value, which is the pre-set critical value of the ROI area, PSNR last It is the average PSNR of the ROI area of the encoded frame, that is, the second peak signal-to-noise ratio.
[0119] By comparing the spatial texture complexity of the ROI area of the previous frame or frames that have been encoded with the spatial texture complexity of the ROI area, if the texture complexity difference is higher than the maximum critical value of the complexity in the ROI area, the QP offset value is lowered; if the texture complexity difference is lower than the minimum critical value of the complexity in the ROI area, the QP offset value is raised. The adjustment formula can be Offset new =f 6 (offset,TEX ROI , TEX max , TEX min , TEX last ). Among them, the critical values of the maximum and minimum spatiotemporal texture are expressed as TEX max (Third setting value), TEX min (Fourth setting value); The first complexity of the spatial texture in the ROI area is TEX ROI , TEX last It is the average complexity of the spatial texture of the ROI area of the encoded frame, that is, the second complexity.
[0120] According to the relationship between the encoded QP of the previous frame, the QP in the ROI area and the macroblock QP in the current ROI area, the upper and lower limits of the QP offset value in the current ROI area are set to ensure that the difference between the macroblock QP in the ROI area of the current frame and the QP in the ROI area of the previous frame and the QP of the entire frame is between the maximum and minimum critical values.
[0121] Specifically, the adjustment between PSNR and QP offset value is as follows:
[0122] , where the maximum and minimum PSNR are expressed as PSNR max 、PSNR min ; The first peak signal-to-noise ratio of the ROI area is PSNR ROI , the second peak signal-to-noise ratio is PSNR last When the encoded image consists of multiple frames, the second peak signal-to-noise ratio may be an average value of peak signal-to-noise ratios of the multiple frames.
[0123] The adjustment between spatial texture and QP is as follows:
[0124] , where the maximum and minimum spatial texture critical values are expressed as TEX max (Third setting value), TEX min (Fourth setting value); The first complexity of the spatial texture in the ROI area is TEX ROI , TEX last is the second complexity of the spatial texture of the ROI region of the encoded image. When the encoded image is multiple frames, the second complexity may be an average value of the spatial texture complexities of the ROI region of the multiple frames.
[0125] The QP of the target area of the current frame is the initial quantization parameter QP ROI , the first quantization parameter of the previous frame level QP is QP frame , the second quantization parameter of the macroblock-level QP is QP mb , then the restrictions are as follows: QP frame -10 <QP ROI +offset <QP frame +10;QP mb -5 <QP ROI +offset <QP mb +5.
[0126] Step S1008, sending to encoder for encoding.
[0127] The adjusted quantization parameter QP is applied to the encoder for encoding, and finally an encoded image or video sequence is obtained.
[0128] In the above-mentioned embodiment, the ROI area, ROI extension area, and non-ROI area are divided by prior information, and the QP offset value is calculated according to the area, and then the QP offset value is adjusted and limited by the encoded frame information, which is used for encoding and ensuring that the objective result of encoding, subjective quality and user needs reach the best solution. The ROI area is expanded to a certain extent by the motion trajectory of the ROI area and the target, the ROI area, the spatial texture characteristics, etc., so as to improve the subjective quality and remove the tailing effect. A mapping method for mapping the QP offset value according to the ROI information, the method establishes corresponding mapping models according to the different divided areas, calculates the QP offset value according to the ROI level, the spatiotemporal texture and other information, so as to improve the subjective quality under the premise of basically unchanged compression rate. A method for adjusting the QP offset value of the current frame quantization parameter by PSNR, encoded frame texture, encoded frame QP and other information, the method adaptively adjusts the quantization parameter QP by comparing the PSNR, QP, texture and other parameters of the ROI area of the current frame with the same area of the encoded frame, so that the quantization parameter QP is more in line with the current scene. It also achieves the goal of improving subjective quality without increasing the encoding bit rate, thus achieving a balance between subjective quality, compression rate and user needs.
[0129] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0130] In this embodiment, a coding device for an image is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0131] Fig.11 is a structural block diagram of an image encoding device according to an embodiment of the present invention, such as Fig.11 As shown, the device comprises:
[0132] A division module 1102 is used to divide the target image based on the image features of the target image to obtain a target region of interest, an extended region of interest and other regions, wherein the other regions are regions in the target image other than the target region of interest and the extended region of interest;
[0133] The encoding module 1104 is used to perform the following operations for each target area included in the target area of interest, the extended area of interest and the other areas to encode the target image: when the target area is not the other area, determine a target area of interest comprehensive value indicating the importance of the target area, determine an initial offset value of the target area based on the target area of interest comprehensive value; when the target area is the other area, determine a first calculation value, and determine the initial offset value of the target area based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value indicating a target motion type of the target motion existing in the target area, a first texture calculation value indicating a target texture complexity of the target area, adjust the initial offset value based on the encoding information of the encoded image included in the video where the target image is located to obtain a target offset value; adjust an initial quantization parameter based on the target offset value to obtain a target quantization parameter, and encode the target area based on the target quantization parameter.
[0134] In an exemplary embodiment, the segmentation module 1102 can segment the target image based on the image features of the target image to obtain a target region of interest, an extended region of interest, and other regions in the following manner: determining the target region of interest based on the region of interest information included in the image features; determining the extended region of interest based on the time domain texture information or the spatial domain texture information included in the image features; and determining the region included in the target image other than the target region of interest and the extended region of interest as the other region.
[0135] In an exemplary embodiment, the division module 1102 can determine the extended region of interest based on the temporal texture information included in the image features in the following manner: determine N consecutive frames of images included in the video and located before the target image, wherein the last frame of the N consecutive frames is adjacent to the target image, and the N consecutive frames all include the target object included in the target image, and N is an integer greater than or equal to 1; determine the motion trajectory of the target object based on the temporal texture information of the N consecutive frames; determine the sub-region in each frame of the N consecutive frames included in the motion trajectory; combine the sub-regions included in each frame to obtain a combined region; determine the overlapping region between the combined region and the target region of interest; and determine other regions included in the combined region except the overlapping region as the extended region of interest.
[0136] In an exemplary embodiment, the division module 1102 can determine the extended region of interest based on the spatial texture information included in the image features in the following manner: determine a first region in the target image whose distance from the target region of interest is less than a first threshold; determine a texture complexity indicating the complexity of the texture included in the first region based on the spatial texture information of the first region; and determine a second region in the first region whose texture complexity is greater than a second threshold as the extended region of interest.
[0137] In an exemplary embodiment, the division module 1102 can divide the target image based on the image features of the target image to obtain a target region of interest, an expanded region of interest and other regions in the following manner: determine the target region of interest based on the region of interest information included in the image features; determine the historical region of interest of the encoded image included in the video; determine the union of the historical regions of interest to obtain a third region; determine a fourth region included in the third region that overlaps with the target region of interest; determine the region included in the third region except the fourth region as the expanded region of interest; determine the region included in the target image except the target region of interest and the expanded region of interest as the other region.
[0138] In an exemplary embodiment, the encoding module 1104 can determine the target motion detection value used to indicate the motion type of the target motion existing in the target area in the following manner: determine the target motion type of the target motion existing in the target area based on the time domain texture information of the target area; determine a first corresponding relationship between the motion type and the motion detection value; determine the target motion detection value included in the first corresponding relationship and corresponding to the target motion type.
[0139] In an exemplary embodiment, the encoding module 1104 can determine the target texture calculation value used to indicate the target texture complexity of the target area in the following manner: determine the target texture complexity of the target area based on the spatial texture information of the target area; determine a second corresponding relationship between texture complexity and texture calculation value; determine the target texture calculation value included in the second corresponding relationship and corresponding to the target texture complexity.
[0140] In an exemplary embodiment, the encoding module 1104 can determine a target region of interest comprehensive value indicating the importance of the target region in the following manner: determine a second calculated value of the target region of interest comprehensive value, wherein the second calculated value includes at least one of the following: a first level corresponding to the target area of the target region of interest, a second level corresponding to the target duration of the target region of interest appearing in the video, and a third level corresponding to the importance of the target region of interest, wherein the importance of the target region of interest is determined based on the objects included in the target region of interest and the correspondence between the objects and the importance; for each first target calculated value included in the second calculated value, determine a first product of the first target calculated value and the first weight of the target calculated value; and map the target region of interest comprehensive value based on the first product.
[0141] In an exemplary embodiment, the encoding module 1104 can determine the target region of interest comprehensive value used to indicate the importance of the target region in the following manner: determine a first level corresponding to the target area of the target region of interest; determine a second level corresponding to the target duration of the target region of interest appearing in the video; determine a third level corresponding to the importance of the target region of interest, wherein the importance of the target region of interest is determined based on the objects included in the target region of interest and the correspondence between the objects and the importance; determine a first weight corresponding to the first level, determine a second weight corresponding to the second level, and determine a third weight corresponding to the third level; determine a first product of the first level and the first weight, determine a second product of the second level and the second weight, and determine a third product of the third level and the third weight; determine the sum of the first product, the second product and the third product as the target region of interest comprehensive value.
[0142] In an exemplary embodiment, the encoding module 1104 can determine the initial offset value of the target area based on the target area of interest comprehensive value by: when the target area is the target area of interest, mapping the initial offset value based on the target area of interest comprehensive value; when the target area is the extended area of interest, mapping the initial offset value based on the target area of interest comprehensive value and a first preset constant.
[0143] In an exemplary embodiment, the encoding module 1104 can determine the initial offset value of the target region based on the target region of interest comprehensive value in the following manner: when the target region is the target region of interest, determine the fourth weight corresponding to the target motion detection value and the fourth product of the target motion detection value, determine the fifth weight corresponding to the target texture calculation value and the fifth product of the target texture calculation value; determine the sum of the fourth product, the fifth product and the target region of interest comprehensive value as the initial offset value; when the target region is the extended region of interest, determine the target motion detection value; The sixth weight corresponding to the detection value and the sixth product of the target motion detection value are determined to determine the seventh weight corresponding to the target texture calculation value and the seventh product of the target texture calculation value; the sum of the sixth product and the seventh product, the target area of interest comprehensive value and a preset constant is determined as the initial offset value; when the target area is other areas, the eighth weight corresponding to the target motion detection value and the eighth product of the target motion detection value are determined, and the ninth weight corresponding to the target texture calculation value and the ninth product of the target texture calculation value are determined; the sum of the eighth product and the ninth product is determined as the initial offset value.
[0144] In an exemplary embodiment, the encoding module 1104 can determine the initial offset value of the target area based on the target region of interest comprehensive value in the following manner: when the target area is not the other area, determine a third calculation value, wherein the third calculation value includes at least one of the following: a second motion detection value for indicating the target motion type of the target motion existing in the target area, and a second texture calculation value for indicating the target texture complexity of the target area; when the target area is the target region of interest, for each second target calculation value included in the third calculation value, determine the second product of the second target calculation value and the second weight of the second target calculation value, and map the initial offset value based on the target region of interest comprehensive value and the second product; when the target area is the extended region of interest, for each second target calculation value included in the third calculation value, determine the third product of the second target calculation value and the third weight of the second target calculation value, and map the initial offset value based on the target region of interest comprehensive value, the third product and a second preset constant.
[0145] In an exemplary embodiment, the encoding module 1104 can determine the initial offset value of the target area based on the first calculated value in the following manner: for each third target calculated value included in the first calculated value, determine the fourth product of the third target calculated value and the fourth weight; and map the initial offset value based on the fourth product.
[0146] In an exemplary embodiment, the encoding module 1104 may adjust the initial offset value based on the encoding information of the encoded image included in the video where the target image is located to obtain the target offset value in the following manner: determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the initial offset value and a first constant as the target offset value, and when the first difference is less than a second set value, determine the difference between the initial offset value and the second constant as the target offset value, and when the first difference is greater than the second set value, determine the difference between the initial offset value and the second constant as the target offset value. value and is less than the first set value, determining the initial offset value as the target offset value, wherein the first set value is greater than the second set value; determining a first complexity of the spatial domain texture of the target image, and determining a second complexity of the spatial domain texture of the encoded image, determining a second difference between the first complexity and the second complexity, and when the second difference is greater than a third set value, determining the difference between the initial offset value and a third constant as the target offset value, and when the second difference is less than a fourth set value, determining the sum of the initial offset value and a fourth constant as the target offset value, and when the second difference is greater than the fourth set value and less than the third set value, determining the initial offset value as the target offset value. The first offset value is determined as the target offset value, wherein the third set value is less than the fourth set value; a first peak signal-to-noise ratio of the target image is determined, and a second peak signal-to-noise ratio of the encoded image is determined, and a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio is determined, and when the first difference is greater than the first set value, the sum of the initial offset value and a first constant is determined as a first intermediate offset value, and when the first difference is less than the second set value, the difference between the initial offset value and the second constant is determined as the first intermediate offset value, and when the first difference is greater than the second set value and less than the first set value, the initial offset value is determined as the first intermediate offset value, wherein the The first set value is greater than the second set value, a first complexity of the spatial domain texture of the target image is determined, and a second complexity of the spatial domain texture of the encoded image is determined, a second difference between the first complexity and the second complexity is determined, and when the second difference is greater than a third set value, a difference between the first intermediate offset value and a third constant is determined as the target offset value, and when the second difference is less than a fourth set value, a sum of the first intermediate offset value and a fourth constant is determined as the target offset value, and when the second difference is greater than the fourth set value and less than the third set value, the first intermediate offset value is determined as the target offset value, wherein the third set value is less than the fourth set value;Determine a first complexity of the spatial domain texture of the target image, and determine a second complexity of the spatial domain texture of the encoded image, determine a second difference between the first complexity and the second complexity, and when the second difference is greater than a third set value, determine the difference between the initial offset value and a third constant as a second intermediate offset value, and when the second difference is less than a fourth set value, determine the sum of the initial offset value and a fourth constant as the second intermediate offset value, and when the second difference is greater than the fourth set value and less than the third set value, determine the initial offset value as the second intermediate offset value, wherein the third set value is less than the fourth set value; Determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the second intermediate offset value and a first constant as the target offset value, and when the first difference is less than a second set value, determine the difference between the second intermediate offset value and a second constant as the target offset value, and when the first difference is greater than the second set value and less than the first set value, determine the second intermediate offset value as the target offset value, wherein the first set value is greater than the second set value. ;
[0147] In an exemplary embodiment, the encoding module 1104 may adjust the initial quantization parameter based on the target offset value to obtain the target quantization parameter in at least one of the following ways: determining a first quantization parameter of the encoded image, determining a third difference between the first quantization parameter and a fifth constant, and determining a first sum value between the first quantization parameter and a sixth constant, determining a target sum value between the initial quantization parameter and the target offset value, and when the target sum value is less than the third difference, determining the third difference as the target quantization parameter, and when the target sum value is greater than the first sum value, determining the first sum as the target quantization parameter, and when the target sum value is greater than or equal to the third difference and less than or equal to the first sum value. In the case of the first sum value, the target sum value is determined as the target quantization parameter; a second quantization parameter of the macroblock level of the encoded image is determined, a fourth difference value between the second quantization parameter and a seventh constant is determined, and a second sum value between the second quantization parameter and an eighth constant is determined, a target sum value of the initial quantization parameter and the target offset value is determined, and in the case that the target sum value is less than the fourth difference value, the fourth difference value is determined as the target quantization parameter, and in the case that the target sum value is greater than the second sum value, the second sum value is determined as the target quantization parameter, and in the case that the target sum value is greater than or equal to the fourth difference value and less than or equal to the second sum value, the target sum value is determined as the target quantization parameter.
[0148] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0149] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0150] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0151] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0152] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0153] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the method in each embodiment of the present application when the computer program is executed by a processor.
[0154] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0155] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0156] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for encoding an image, characterized in that: include: Dividing the target image based on image features of the target image to obtain a target region of interest, an expanded region of interest, and other regions, wherein the other regions are regions in the target image other than the target region of interest and the expanded region of interest; The following operations are performed for each target region included in the target region of interest, the expanded region of interest, and the other regions to encode the target image: In the case where the target area is not the other area, a target region of interest comprehensive value indicating the importance of the target area is determined, and an initial offset value of the target area is determined based on the target region of interest comprehensive value; in the case where the target area is the other area, a first calculation value is determined, and the initial offset value of the target area is determined based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value indicating a target motion type of a target motion existing in the target area, and a first texture calculation value indicating a target texture complexity of the target area; the initial offset value is adjusted based on encoding information of an encoded image included in the video where the target image is located to obtain a target offset value; an initial quantization parameter is adjusted based on the target offset value to obtain a target quantization parameter, and the target area is encoded based on the target quantization parameter; Wherein, the expanded region of interest is a region whose distance from the target region of interest is less than a set parameter; The target region of interest comprehensive value is a value determined based on one or more of a target area of the target region of interest, a target duration of the target region of interest appearing in a video, and an importance of the target region of interest; The encoding information of the encoded image includes at least one of the following: peak signal-to-noise ratio PSNR, spatial domain texture, and encoded frame quantization parameter QP.
2. The method according to claim 1, characterized in that The target image is divided based on the image features of the target image to obtain the target region of interest, the expanded region of interest and other regions including: Determining the target region of interest based on the region of interest information included in the image features; Determining the expanded region of interest based on temporal texture information or spatial texture information included in the image features; An area in the target image other than the target ROI and the expanded ROI is determined as the other area.
3. The method according to claim 2, characterized in that Determining the expanded region of interest based on the temporal texture information included in the image features comprises: Determine N consecutive frames of images included in the video and located before the target image, wherein a last frame of the N consecutive frames of images is adjacent to the target image, and the N consecutive frames of images all include the target object included in the target image, and N is an integer greater than or equal to 1; Determine the motion trajectory of the target object based on the temporal texture information of the N frames of continuous images; Determine a sub-region of each frame of the N consecutive frames of images included in the motion trajectory; Combining the sub-regions included in each frame of the image to obtain a combined region; Determine an overlapping area between the combined area and the target region of interest; The other regions included in the combined region except the overlapping region are determined as the expanded region of interest.
4. The method according to claim 2, characterized in that: Determining the expanded region of interest based on the spatial texture information included in the image features includes: Determining that the target image includes a first region whose distance to the target region of interest is less than a first threshold; determining, based on the spatial texture information of the first region, texture complexity indicating a degree of complexity of a texture included in the first region; A second region in the first region, where the texture complexity is greater than a second threshold, is determined as the expanded region of interest.
5. The method according to claim 1, characterized in that The target image is divided based on the image features of the target image to obtain the target region of interest, the expanded region of interest and other regions including: Determining the target region of interest based on the region of interest information included in the image features; determining a historical region of interest of encoded images included in the video; Determine a union of the historical regions of interest to obtain a third region; Determine a fourth area included in the third area and overlapping with the target region of interest; Determining an area included in the third area except the fourth area as the expanded area of interest; An area in the target image other than the target ROI and the expanded ROI is determined as the other area.
6. The method according to claim 1, characterized in that Determining the target motion detection value for indicating the motion type of the target motion present in the target area includes: determining a target motion type of the target motion existing in the target area based on the temporal texture information of the target area; Determining a first corresponding relationship between a motion type and a motion detection value; The target motion detection value included in the first corresponding relationship and corresponding to the target motion type is determined.
7. The method according to claim 1, characterized in that Determining a target texture calculation value for indicating a target texture complexity of the target area includes: Determining target texture complexity of the target area based on spatial texture information of the target area; Determining a second corresponding relationship between texture complexity and texture calculation value; The target texture calculation value included in the second corresponding relationship and corresponding to the target texture complexity is determined.
8. The method according to claim 1, characterized in that Determining a target region of interest comprehensive value for indicating the importance of the target region includes: Determine a second calculated value of the target region of interest comprehensive value, wherein the second calculated value includes at least one of the following: a first level corresponding to a target area of the target region of interest, a second level corresponding to a target duration of the target region of interest appearing in the video, and a third level corresponding to an importance of the target region of interest, wherein the importance of the target region of interest is determined based on an object included in the target region of interest and a corresponding relationship between the object and the importance; determining, for each first target calculated value included in the second calculated value, a first product of the first target calculated value and a first weight of the target calculated value; The target region of interest comprehensive value is mapped based on the first product.
9. The method according to claim 1, characterized in that: Determining the initial offset value of the target region based on the target region of interest comprehensive value includes: In a case where the target region is the target region of interest, mapping the initial offset value based on the target region of interest comprehensive value; In a case where the target region is the expanded region of interest, the initial offset value is mapped based on the target comprehensive value of interest and a first preset constant.
10. The method according to claim 1, characterized in that Determining the initial offset value of the target region based on the target region of interest comprehensive value includes: In the case where the target area is not the other area, a third calculated value is determined, wherein the third calculated value includes at least one of the following: a second motion detection value for indicating a target motion type of a target motion existing in the target area, and a second texture calculation value for indicating a target texture complexity of the target area; In a case where the target region is the target region of interest, determining a second product of the second target calculated value and a second weight of the second target calculated value for each second target calculated value included in the third calculated value, and mapping the initial offset value based on the target region of interest comprehensive value and the second product; In the case where the target area is the expanded area of interest, a third product of the second target calculation value and the third weight of the second target calculation value is determined for each second target calculation value included in the third calculation value, and the initial offset value is mapped based on the target area of interest comprehensive value, the third product and a second preset constant.
11. The method according to claim 1, characterized in that: Determining the initial offset value of the target area based on the first calculated value includes: determining, for each third target calculated value included in the first calculated value, a fourth product of the third target calculated value and a fourth weight; The initial offset value is mapped based on the fourth product.
12. The method according to claim 1, characterized in that The initial offset value is adjusted based on the encoding information of the encoded image included in the video where the target image is located, and the target offset value is obtained, including at least one of the following: Determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the initial offset value and a first constant as the target offset value, and when the first difference is less than a second set value, determine the difference between the initial offset value and the second constant as the target offset value, and when the first difference is greater than the second set value and less than the first set value, determine the initial offset value as the target offset value, wherein the first set value is greater than the second set value; Determine a first complexity of the spatial domain texture of the target image, and determine a second complexity of the spatial domain texture of the encoded image, determine a second difference between the first complexity and the second complexity, and when the second difference is greater than a third set value, determine the difference between the initial offset value and a third constant as the target offset value, and when the second difference is less than a fourth set value, determine the sum of the initial offset value and a fourth constant as the target offset value, and when the second difference is greater than the fourth set value and less than the third set value, determine the initial offset value as the target offset value, wherein the third set value is less than the fourth set value; Determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the initial offset value and a first constant as a first intermediate offset value, and when the first difference is less than a second set value, determine the difference between the initial offset value and the second constant as the first intermediate offset value, and when the first difference is greater than the second set value and less than the first set value, determine the initial offset value as the first intermediate offset value, wherein the first set value is greater than the second set value, and determine A first complexity of the spatial domain texture of the target image, and a second complexity of the spatial domain texture of the encoded image are determined, a second difference between the first complexity and the second complexity is determined, when the second difference is greater than a third set value, a difference between the first intermediate offset value and a third constant is determined as the target offset value, when the second difference is less than a fourth set value, a sum of the first intermediate offset value and a fourth constant is determined as the target offset value, when the second difference is greater than the fourth set value and less than the third set value, the first intermediate offset value is determined as the target offset value, wherein the third set value is less than the fourth set value; Determine a first complexity of the spatial domain texture of the target image, and determine a second complexity of the spatial domain texture of the encoded image, determine a second difference between the first complexity and the second complexity, and when the second difference is greater than a third set value, determine the difference between the initial offset value and a third constant as a second intermediate offset value, and when the second difference is less than a fourth set value, determine the sum of the initial offset value and a fourth constant as the second intermediate offset value, and when the second difference is greater than the fourth set value and less than the third set value, determine the initial offset value as the second intermediate offset value, wherein the third set value is less than the fourth set value; Determine a first peak signal-to-noise ratio of the target image, and determine a second peak signal-to-noise ratio of the encoded image, determine a first difference between the first peak signal-to-noise ratio and the second peak signal-to-noise ratio, and when the first difference is greater than a first set value, determine the sum of the second intermediate offset value and a first constant as the target offset value, when the first difference is less than a second set value, determine the difference between the second intermediate offset value and a second constant as the target offset value, and when the first difference is greater than the second set value and less than the first set value, determine the second intermediate offset value as the target offset value, wherein the first set value is greater than the second set value.
13. The method according to claim 1, characterized in that Adjusting the initial quantization parameter based on the target offset value to obtain the target quantization parameter includes at least one of the following: Determine a first quantization parameter of the encoded image, determine a third difference between the first quantization parameter and a fifth constant, and determine a first sum value between the first quantization parameter and a sixth constant, determine a target sum value between the initial quantization parameter and the target offset value, and when the target sum value is less than the third difference value, determine the third difference value as the target quantization parameter, when the target sum value is greater than the first sum value, determine the first sum value as the target quantization parameter, and when the target sum value is greater than or equal to the third difference value and less than or equal to the first sum value, determine the target sum value as the target quantization parameter; Determine a second quantization parameter at the macroblock level of the encoded image, determine a fourth difference between the second quantization parameter and a seventh constant, and determine a second sum value between the second quantization parameter and an eighth constant, determine a target sum value between the initial quantization parameter and the target offset value, and when the target sum value is less than the fourth difference value, determine the fourth difference value as the target quantization parameter, when the target sum value is greater than the second sum value, determine the second sum value as the target quantization parameter, and when the target sum value is greater than or equal to the fourth difference value and less than or equal to the second sum value, determine the target sum value as the target quantization parameter.
14. An image encoding device, characterized in that: include: A division module, used for dividing the target image based on the image features of the target image to obtain a target region of interest, an extended region of interest and other regions, wherein the other regions are regions in the target image other than the target region of interest and the extended region of interest; A coding module, configured to perform the following operations for each target region included in the target region of interest, the extended region of interest, and the other regions, so as to encode the target image: when the target region is not the other regions, determine a target region of interest comprehensive value indicating the importance of the target region, determine an initial offset value of the target region based on the target region of interest comprehensive value, when the target region is the other regions, determine a first calculation value, and determine the initial offset value of the target region based on the first calculation value, wherein the first calculation value includes at least one of the following: a first motion detection value indicating a target motion type of a target motion existing in the target region, a first texture calculation value indicating a target texture complexity of the target region, adjust the initial offset value based on coding information of an encoded image included in a video where the target image is located, to obtain a target offset value; adjust an initial quantization parameter based on the target offset value to obtain a target quantization parameter, and encode the target region based on the target quantization parameter; Wherein, the expanded region of interest in the division module is a region whose distance from the target region of interest is less than a set parameter; The target region of interest comprehensive value in the encoding module is a value determined based on one or more of a target area of the target region of interest, a target duration of the target region of interest appearing in the video, and an importance of the target region of interest; The encoding information of the encoded image in the encoding module includes at least one of the following: peak signal-to-noise ratio PSNR, spatial domain texture, and encoded frame quantization parameter QP.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 13 when executed.
16. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 13.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 13 are implemented.
Citation Information
Patent Citations
Video coding method based on self-adaptive ROI (region of interest)
CN106791856A
Video coding processing method and device, equipment, storage medium and product
CN116962701A
