CN115022641A - Image encoding method, image decoding method, electronic device, and computer-readable storage medium - Google Patents

Image encoding method, image decoding method, electronic device, and computer-readable storage medium Download PDF

Info

Publication number
CN115022641A
CN115022641A CN202210580450.7A CN202210580450A CN115022641A CN 115022641 A CN115022641 A CN 115022641A CN 202210580450 A CN202210580450 A CN 202210580450A CN 115022641 A CN115022641 A CN 115022641A
Authority
CN
China
Prior art keywords
current image
image
motion
processing mode
detection result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210580450.7A
Other languages
Chinese (zh)
Inventor
张祥
杨阳
马东星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202210580450.7A priority Critical patent/CN115022641A/en
Publication of CN115022641A publication Critical patent/CN115022641A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/172Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a picture, frame or field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/44Decoders specially adapted therefor, e.g. video decoders which are asymmetric with respect to the encoder

Abstract

The application discloses an image coding and decoding method, an electronic device and a computer readable storage medium, wherein the method comprises the following steps: obtaining a current image, and determining a reference image detection result of the current image; responding to the reference image detection result that a reference image exists, obtaining a motion detection result, and selecting a processing mode to process the current image based on the motion detection result; when the motion detection result is that a motion target exists, the processing mode is to encode at least partial area of the current image, and the partial area comprises the motion target; and setting a flag bit matched with the processing mode for the processed current image. According to the scheme, the encoding compression rate and the encoding efficiency can be improved.

Description

Image encoding method, image decoding method, electronic device, and computer-readable storage medium
Technical Field
The present application relates to the field of image encoding and decoding technologies, and in particular, to an image encoding method, an image decoding method, an electronic device, and a computer-readable storage medium.
Background
With the increasing image quality of images or videos acquired by a camera device, a higher requirement is put on the compression rate when the images are encoded. The existing image coding method generally codes images in images based on spatial redundancy characteristics, and each complete image needs to be coded in sequence when coding in the images, so that the coding compression rate and the coding efficiency are not high. In view of the above, how to improve the compression rate and the encoding efficiency becomes an urgent problem to be solved.
Disclosure of Invention
The technical problem mainly solved by the application is to provide an image encoding method, an image decoding method, an electronic device and a computer readable storage medium, which can improve the encoding compression rate and the encoding efficiency.
To solve the above technical problem, a first aspect of the present application provides an image encoding method, including: obtaining a current image, and determining a reference image detection result of the current image; responding to the reference image detection result that a reference image exists, obtaining a motion detection result, and selecting a processing mode to process the current image based on the motion detection result; when the motion detection result indicates that a motion target exists, the processing mode is to encode at least a partial region of the current image, and the partial region includes the motion target; and setting a flag bit matched with the processing mode for the processed current image.
In order to solve the above technical problem, a second aspect of the present application provides an image decoding method applied to the image encoding method according to the first aspect, the method including: obtaining a current image to be decoded, and determining a processing mode of the current image based on a flag bit matched with the processing mode; and in response to the processing mode, encoding at least part of the region of the current image, decoding the encoded region to obtain a decoded sub-region, superposing the timestamp corresponding to the current image and the decoded sub-region to the corresponding position on the reference image corresponding to the current image to obtain a decoded current image, and taking the decoded current image as a new reference image.
To solve the above technical problem, a third aspect of the present application provides an electronic device, including: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method of the first or second aspect.
In order to solve the above technical problem, a fourth aspect of the present application provides a computer storage medium having program data stored thereon, the program data implementing the method of the first or second aspect when executed by a processor.
In the scheme, after the current image is obtained, a reference image detection result of the current image is determined in the current image, wherein the reference image is an image coded in a whole frame, when the reference image detection result is that the reference image exists, a motion detection result is obtained, a processing mode is selected to process the current image based on the motion detection result, when the motion detection result is that the motion target exists, the processing mode is that at least partial area of the current image is coded, only the partial area including the motion target can be coded, the coding compression rate is improved, for a scene with the motion target, the consumption of coding is effectively reduced, the coding efficiency is improved, the coded partial area is decoded and then superposed on the decoded reference image in the decoding process, and a complete image corresponding to the image coded in the processing mode of at least partial area can be obtained, thereby improving decoding efficiency.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts. Wherein:
FIG. 1 is a flowchart illustrating an embodiment of an image encoding method according to the present application;
FIG. 2 is a schematic flow chart diagram illustrating another embodiment of an image encoding method according to the present application;
FIG. 3 is a schematic flowchart of an embodiment corresponding to step S203 in FIG. 2;
FIG. 4 is a schematic diagram of an application scenario of an embodiment corresponding to step S204 in FIG. 2;
FIG. 5 is a schematic diagram of an application scenario of another embodiment corresponding to step S204 in FIG. 2;
FIG. 6 is a flowchart illustrating an embodiment of an image decoding method according to the present application;
FIG. 7 is a schematic structural diagram of an embodiment of an electronic device of the present application;
FIG. 8 is a schematic structural diagram of an embodiment of a computer-readable storage medium according to the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two.
The image encoding method provided by the present application is used for encoding the original data of the image into a file in an image format, wherein the original data of the image may be a video frame extracted from video data or an image arranged in sequence, and the image decoding method provided by the present application is used for decoding the file in the image format into the original data of the image for display.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating an embodiment of an image encoding method according to the present application, the method including:
s101: and obtaining the current image, and determining a reference image detection result of the current image.
Specifically, a current image to be encoded is obtained, and reference image detection is performed on the current image to determine a reference image detection result of the current image. The reference image detection result comprises a no-reference image and a reference image, wherein the reference image is a completely coded image and is in time sequence before the current image.
In an application mode, after a reference image is referred once, the use count value corresponding to the reference image is accumulated once and cleared after the use count value is accumulated to a count threshold value, and whether the reference image which is completely coded and can be referred to by the current image exists before the current image is determined based on the use count value, so that the reference image detection result of the current image is obtained.
In an application scene, a reference image is an image which is completely coded, when the reference image is used continuously, a use count value corresponding to the reference image is added, when the use count value is added to exceed a count threshold value, the current image is judged not to have the reference image, so that the current image is subsequently coded in a whole frame, the condition that the number of times of using the same reference image is large is avoided, the coding compression ratio is improved, and the probability of poor quality of the coded image is reduced.
S102: and responding to the reference image detection result that a reference image exists, obtaining a motion detection result, and selecting a processing mode to process the current image based on the motion detection result, wherein the reference image is an image obtained after the whole frame of encoding, and when the motion detection result is that a motion target exists, the processing mode is to encode at least a partial area of the current image, and the partial area comprises the motion target.
Specifically, when the reference image detection result is that a reference image exists, a motion detection result is obtained, wherein the motion detection result comprises a non-motion object and a motion object.
Further, the reference image is an image obtained by encoding the whole frame, and when the motion detection result indicates that a motion target exists, the processing mode is to encode at least a partial region of the current image, and the partial region includes the motion target. That is, when the moving object is included in the current image, the processing is to encode at least a partial region of the current image, and the partial region includes the moving object.
Optionally, when the current image does not include the moving object, the processing mode is to continue using the reference image corresponding to the current image.
In an application manner, when the motion detection result is that there is no motion target and there is a reference image, the processing manner may be selected to continue using the reference image corresponding to the current image and increment the usage count value of the reference image once, and when the motion detection result is that there is a motion target and there is a reference image, the processing manner may be selected to encode at least a partial region of the current image and increment the usage count value of the reference image once, so that a matching processing manner is selected based on a combination between different motion detection results and reference image detection results.
Further, when the motion detection result indicates that a motion target exists, when a partial region on the current image is coded, the partial region includes the motion target, so that the coded partial region and the reference image can be combined to decode to obtain a complete picture of the image and feed back the state of the motion target.
S103: and setting a flag bit matched with the processing mode for the processed current image.
Specifically, based on the combination of different motion detection results and reference image detection results, matching processing modes are selected, each processing mode corresponds to a matching flag bit, and the flag bit matched with the processing mode is set for the current image after the processing mode is selected, so that the processing mode of any image during encoding can be conveniently determined during decoding, and the decoding efficiency is improved.
Furthermore, in the decoding process, the encoded partial region is decoded and then superimposed on the decoded reference image, so that a complete image corresponding to the image encoded by at least the partial region in the processing mode can be obtained, and the decoding processing amount is reduced to improve the decoding efficiency.
In an application scenario, a reference image is an image subjected to whole-frame encoding, when the processing mode of the image is to continue using the reference image or encode at least a partial region of a current image, a usage count value of the reference image corresponding to the image needs to be incremented, and when the usage count value of the reference image is incremented and exceeds a count threshold, the image is subjected to whole-frame encoding again to obtain a new reference image, so that when the usage count value exceeds the count threshold or the image is a first image to be encoded, a reference image detection result of the current image is considered to be a no-reference image.
Further, whether a reference image detection result corresponds to a reference image or not is judged, if the reference image detection result is no reference image, the whole frame encoding is carried out on the current image, so that the whole current image is used as a new reference image after being encoded, if the reference image detection result is a reference image, whether a motion detection result corresponds to a motion target or not is further judged, if the motion detection result is no motion target, the reference image corresponding to the current image is used, and if the motion detection result is a motion target, a partial area corresponding to the target which has moved in the current image is encoded, so that when the reference image exists in the current image, the encoding amount of image encoding is effectively reduced, and the encoding compression rate and the encoding efficiency are improved.
In the scheme, after the current image is obtained, a reference image detection result of the current image is determined in the current image, wherein the reference image is an image coded in a whole frame, when the reference image detection result is that the reference image exists, a motion detection result is obtained, a processing mode is selected to process the current image based on the motion detection result, when the motion detection result is that the motion target exists, the processing mode is that at least partial area of the current image is coded, only the partial area including the motion target can be coded, the coding compression rate is improved, for a scene with the motion target, the consumption of coding is effectively reduced, the coding efficiency is improved, the coded partial area is decoded and then superposed on the decoded reference image in the decoding process, and a complete image corresponding to the image coded in the processing mode of at least partial area can be obtained, thereby improving decoding efficiency.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating another embodiment of an image encoding method according to the present application, the method including:
s201: and obtaining the current image, and determining a reference image detection result of the current image.
Specifically, if the current picture is an initial picture of the entire video data, the reference picture detection result of the current picture is a no-reference picture, and if a completely encoded picture that is closest to the current picture in time series is lost, the reference picture detection result of the current picture is a no-reference picture.
S202: and responding to the detection result of the reference image as no reference image, selecting a processing mode of carrying out whole-frame coding on the current image, and taking the current image subjected to whole-frame coding as a new reference image.
Specifically, when the reference image detection result is no reference image, the processing mode is selected to perform whole-frame encoding on the current image, the whole picture of the current image is encoded by using an encoding algorithm, and the current image after the whole-frame encoding is used as a new reference image.
Further, when the reference image corresponds to the usage count value, the usage count value of the new reference image is cleared while the new reference image is obtained.
In an application mode, when the reference image detection result is no reference image, the processing mode is selected to perform whole-frame coding on the current image, the whole picture of the current image is coded by using a coding algorithm, the current image after the whole-frame coding is used as a new reference image, and meanwhile, the use count value of the new reference image is set to be zero.
S203: and obtaining a motion detection result in response to the reference image detection result being that the reference image exists.
Specifically, referring to fig. 3, fig. 3 is a flowchart illustrating an embodiment corresponding to step S203 in fig. 2, where the motion detection result is determined based on the following steps, including:
s301: dividing the current image into a plurality of macro blocks, and determining the sub-block detection result corresponding to each macro block.
Specifically, after the current image is obtained, the current image is divided into a plurality of macro blocks, and each macro block is subjected to motion detection, so that a sub-block detection result corresponding to each macro block is determined.
In an application scene, after a current image is obtained, the current image is divided into a plurality of macro blocks according to the pixel size, wherein the pixel size of the macro block at the edge position of the current image is self-adaptive, the pixel size of the macro block at the non-edge position of the current image is a preset pixel value, each macro block is subjected to motion detection, so that a motion detection flag bit corresponding to a motion detection result in each macro block is output, a sub-block detection result of each macro block is obtained based on the motion detection flag bit of each macro block, the sub-block detection result is a motion target and a non-motion target, the macro block with the motion target is a motion macro block, the current image is divided into a plurality of macro blocks for judgment, and the judgment fineness and the judgment accuracy are improved.
S302: and determining that the motion detection result corresponding to the current image is the moving target in response to the current image including at least one motion macro block with the motion target as the sub-block detection result.
Specifically, if at least one subblock detection result exists in the current image and is a moving macro block with a moving target, it is determined that the moving detection result corresponding to the current image is the moving target.
S303: and determining that the motion detection result corresponding to the current image is a non-motion target in response to the fact that the sub-block detection results corresponding to all the macro blocks corresponding to the current image are non-motion targets.
Specifically, if the subblock detection results of all macroblocks in the current image are motion macroblocks without a motion target, it is determined that the motion detection result corresponding to the current image is the motion target.
S204: and responding to the motion detection result that no motion target exists, selecting a processing mode to continue using the reference image corresponding to the current image, extracting the time stamp of the current image, and adding the use count value corresponding to the reference image.
Specifically, when the motion detection result is that no motion target exists and the reference frame detection result is that a reference frame exists, the coding mode is selected to continue to use the reference frame corresponding to the current frame, the timestamp in the current frame is extracted from the current frame for storage, and the use count value corresponding to the reference frame is incremented on the existing basis.
S205: and in response to the motion detection result that a motion target exists, selecting a processing mode to encode at least partial region of the current image, thereby extracting at least a region corresponding to the target which has moved from the current image for encoding and increasing the use count value corresponding to the reference image.
Specifically, when the motion detection result is that a moving target exists and the reference image detection result is that a reference image exists, the selection processing mode is to encode at least a partial region of the current image, extract a region corresponding to the moving target in the current image or extract a region corresponding to the moving target and a peripheral region thereof to perform partial encoding, so that only partial encoding is performed when the target in the current image moves.
In an application, the step of encoding at least a partial region of a current image comprises: determining a motion boundary area corresponding to the motion macro block, and expanding the motion boundary area outwards according to the preset macro block step length to obtain an area to be scratched; and determining the position information of the region to be scratched in the current image, and coding the region to be scratched in the current image based on the coding parameters matched with the position information.
Specifically, when the current image determines a motion detection result, the current image is divided into a plurality of macro blocks, when the current image is partially encoded, a motion boundary corresponding to the motion macro block is driven based on the position of the motion macro block, and the motion boundary region is expanded outwards according to a preset macro block step to obtain a region to be subjected to matting, so that the range of partial encoding is expanded, the fault tolerance rate of judging the motion boundary region is improved, and a moving target is ensured to be in the region to be subjected to matting.
Further, the position information of the region to be scratched in the current image is determined, and the coding parameters are adjusted, so that the region to be scratched in the current image is coded after the coding parameters are matched with the position information of the region to be scratched.
In an application scene, determining a motion boundary area corresponding to a motion macro block, and expanding the motion boundary area outwards according to a preset macro block step length to obtain a region to be subjected to matting, wherein the step comprises the following steps: determining a motion boundary area based on all motion macroblocks in response to the distance between any motion macroblock and the nearest motion macroblock being within a distance threshold; and in response to the distance between the at least two motion macro blocks and the nearest motion macro block exceeding a distance threshold, dividing all the motion macro blocks into at least two motion macro block aggregation areas based on the distance threshold, and respectively determining motion boundary areas corresponding to the motion macro block aggregation areas.
Specifically, whether the distance between any one motion macro block and the motion macro block closest to the motion macro block is within a distance threshold value is judged, and if all the motion macro blocks and the motion macro blocks closest to the motion macro block are within the distance threshold value, a motion boundary area is determined based on all the motion macro blocks, so that an area to be scratched is obtained. If the distance between at least two motion macro blocks and the motion macro block closest to the motion macro blocks exceeds a distance threshold, dividing the motion macro blocks according to the distance threshold to obtain at least two motion macro block aggregation areas, wherein when the distance between the N motion macro blocks and the motion macro block closest to the motion macro blocks exceeds the distance threshold, the N motion macro block aggregation areas are obtained, the motion macro block aggregation areas at least comprise one motion macro block, a motion boundary area is determined based on each motion macro block aggregation area to obtain an area to be subjected to image matting corresponding to each motion boundary area, so that when the motion macro blocks are farther, the different motion macro block aggregation areas are respectively subjected to partial coding, the coding amount of partial coding is reduced, and the compression rate of coding is improved.
In a specific application scenario, please refer to fig. 4, where fig. 4 is an application scenario diagram of an embodiment corresponding to step S204 in fig. 2, where a slash frame corresponds to a motion macro block, a distance threshold is a distance of 4 motion macro blocks, and a distance between any motion macro block and a nearest motion macro block is within the distance threshold, only one motion macro block aggregation area is obtained, where a one-dimensional array is returned by a dynamic detection algorithm (the array is sequentially stored from left to right and from top to bottom according to an image), each member in the array represents a motion state of one macro block, 1 is motion, and 0 is not motion; the coordinates of each moving macro block can be obtained through the array and the width and the height of the image, the horizontal and vertical coordinate ratios of all the coordinates are judged, the maximum and minimum values, namely the upper left corner and the lower right corner in the dashed line frame, are respectively taken out, the area surrounded by the dashed line frame in the image is the moving boundary area, and after the moving boundary area is obtained, an area to be subjected to image matting, namely the area surrounded by the gray macro block in the image 4 is obtained according to the preset macro block step length.
In another specific application scenario, please refer to fig. 5, where fig. 5 is a schematic view of an application scenario of another embodiment corresponding to step S204 in fig. 2, where an oblique line frame corresponds to a motion macro block, a distance threshold is a distance of 5 motion macro blocks, a distance between regions corresponding to two motion macro blocks exceeds the distance threshold, and two aggregation regions are located between the motion macro blocks, two motion macro block aggregation regions shown in a dashed line frame in fig. 5 are obtained, and thus, the two motion macro block regions are respectively expanded outwards according to a preset macro block step size to obtain two regions to be scratched, that is, regions surrounded by gray macro blocks in fig. 5. Therefore, when the distance between the moving macro block gathering areas is large, the area coding can be carried out, so that the coding amount of the non-moving area is reduced, and the coding compression rate is improved.
Optionally, before the step of selecting a processing mode to encode at least a partial region of the current image, so as to extract at least a region corresponding to a moving object from the current image, and encode the region, and increment a usage count value corresponding to a reference image, the method further includes: determining whether the area of a region corresponding to the moving target accounts for the total area of the current image and exceeds an accounting threshold value; and responding to the exceeding of the ratio threshold value, selecting a processing mode to carry out whole-frame coding on the current image, taking the current image subjected to whole-frame coding as a new reference image and clearing the use count value.
Specifically, when the motion detection result is that a motion target exists and the reference image detection result is that a reference image exists, it is first determined whether the total area of the current image occupied by the area of the region corresponding to the motion target exceeds a duty threshold, when the total area exceeds the duty threshold, it is determined that there are many and large motion targets in the current image, the selection processing mode is to perform whole-frame encoding on the current image to reduce other determination processes and directly encode the image, improve the encoding efficiency and avoid the loss of the motion target, and when the duty does not exceed the duty threshold, the selection processing mode is to perform encoding on at least part of the region of the current image.
In an application scene, when judging whether the area of the area corresponding to the moving target accounts for the total area of the current image exceeds an accounting threshold value, determining the ratio of the area corresponding to the moving target to the total area of the current image according to the ratio of the moving macro blocks to all the macro blocks corresponding to the current image.
S206: in response to the usage count value exceeding the count threshold, the current image is full frame encoded and the usage count value is cleared.
Specifically, when the usage count value corresponding to the reference image exceeds the count threshold, the current image is subjected to whole-frame coding and the usage count value is cleared at the same time, so that the situation that the same reference image is used or referenced too many times is avoided, the inter-frame coding error is reduced, and the waiting time during decoding is reduced.
S207: and setting a flag bit matched with the processing mode for the processed current image.
In particular, the processing mode corresponds to the matched flag bit, thereby facilitating the efficient determination of the decoding mode during decoding.
In an application mode, in response to a processing mode of carrying out whole-frame coding on a current image, setting a first flag bit corresponding to the processing mode, and packaging and storing the processed current image and the first flag bit; setting a second zone bit corresponding to the processing mode in response to the fact that the processing mode is to continue using the reference image corresponding to the current image, and packaging and storing the timestamp of the current image and the second zone bit; and responding to the processing mode that at least partial area of the current image is coded, setting a third flag bit corresponding to the processing mode, and packaging and storing the position information and the processed partial area and the third flag bit.
In particular, after selecting a matching processing mode for the image, the processed image needs to be packaged and stored, when the processing mode is to encode the whole frame of the current image, setting a first flag bit corresponding to the processing mode, packaging and storing the processed current image and the first flag bit, when the processing mode is to continue using the reference image corresponding to the current image, setting a second flag bit corresponding to the processing mode, packaging and storing the timestamp of the current image extracted before and the second flag bit, when the processing mode is to encode at least partial area of the current image, setting a third flag bit corresponding to the processing mode, packaging and storing the position information corresponding to the processed partial area and the processed partial area with the third flag bit, therefore, how the decoded partial image area is overlapped with the reference image can be determined during decoding, and the decoding accuracy is improved.
In an application scenario, when the processing mode is to encode at least a partial region of the current image, the partial region corresponds to the region to be subjected to matting in step S205, and the position information corresponding to the region to be subjected to matting, the processed region to be subjected to matting and the third flag bit are packaged and stored.
In this embodiment, a current image is divided into a plurality of macro blocks and then motion detection is performed, after a motion detection result and a reference image detection result are obtained, an appropriate processing mode is selected based on the motion detection result and the reference image detection result to improve the compression rate of coding in a time domain, wherein when the processing mode is to code at least part of the current image, the distance between any motion macro block and the nearest motion macro block is determined, so that a motion macro block aggregation region is divided and expanded to obtain a region to be scratched, the region to be scratched is coded, when the distance between the motion macro block aggregation regions is large, regional coding can be performed to reduce the coding amount of a non-motion region, so that the coding compression rate is improved, matched flag bits are set for different surfaces and then the coding is performed to improve the decoding efficiency, and when the processing mode is to continue using the reference image corresponding to the current image, the current image does not need to be coded, so that the current image has the coding efficiency The compression rate and the encoding efficiency of encoding are effectively improved, when the processing mode is whole-frame encoding, the image can be subjected to whole-frame encoding, so that a new reference image is obtained, the phenomenon that the same reference image is used for a plurality of times is avoided, the encoding compression rate is improved, and the probability of poor quality of the encoded image is reduced.
Referring to fig. 6, fig. 6 is a flowchart illustrating an embodiment of an image decoding method according to the present application, wherein the image decoding method according to the present embodiment is applied to an image encoded based on the image encoding method described in any of the above embodiments, and the method includes:
s601: and obtaining a current image to be decoded, and determining the processing mode of the current image based on the flag bit matched with the processing mode.
Specifically, a current image to be decoded is obtained when the encoded image is decoded, and the processing mode of the current image during encoding is determined based on the flag bit matched with the processing mode during encoding.
S602: and in response to the processing mode, encoding at least part of the region of the current image, decoding the encoded region to obtain a decoded sub-region, superposing the timestamp corresponding to the current image and the decoded sub-region to the corresponding position on the reference image corresponding to the current image to obtain a decoded current image, and taking the decoded current image as a new reference image.
Specifically, when the processing mode is to encode at least a partial region of the current image, the encoded region is decoded to obtain a decoded subregion, the decoded subregion is superposed on the current image, the decoded subregion is superposed and replaced based on the position information to display a moving target, a time stamp of the current image is superposed on a reference image of the current image to keep the time stamp display accurate, and the decoded current image is used as a new reference image to ensure the continuity and the real-time performance of the image during continuous display.
In an application scenario, an encoded region is obtained based on the region to be subjected to matting in the above embodiment, and the encoded region corresponding to the region to be subjected to matting is decoded to obtain a decoded sub-region, so that the decoded sub-region is superimposed on a current image based on position information corresponding to the region to be subjected to matting, and the decoded image is used as a new reference image, and then when a subsequent image needs to use the reference image, a moving target in the current image can still be displayed.
Further, after the step of obtaining a current image to be decoded and determining a processing mode of the current image based on the flag bit matched with the processing mode, the method further includes: in response to the processing mode, performing whole-frame encoding on the current image, directly performing whole-frame decoding on the current image to obtain a decoded current image, and taking the decoded current image as a new reference image; and in response to the processing mode that the reference image corresponding to the current image is used, overlaying the timestamp corresponding to the current image onto the reference image corresponding to the current image to obtain the decoded current image.
Specifically, when the processing mode is to perform whole-frame encoding on the current image, the current image is directly subjected to whole-frame decoding during decoding to obtain a decoded current image, and the whole-frame decoded current image is used as a new reference image, wherein after each whole-frame decoded image is obtained, the whole-frame decoded image is used as a new reference image for later image reference.
Further, when the processing mode is to continue using the reference image corresponding to the current image, the current reference image is obtained, and the timestamp of the current image is superposed on the reference image corresponding to the current image, so that the timestamp display is kept accurate, and the decoded current image is obtained.
It can be understood that, when a video stream needs to be dragged for playback, if the processing mode of playing back an initial image is full-frame encoding, then performing full-frame decoding from the current image is enough, and if the processing mode of playing back an initial image is to continue to use a reference image or a part of encoding corresponding to the current image, then searching forward from the current image for at most the threshold number of images counted in the above embodiments, that is, necessarily obtaining the reference image corresponding to the playback initial video, so as to obtain a picture of the playback initial image, and performing frame-by-frame display from the playback initial image.
According to the scheme, if the processing mode of the current image is to continue using the reference image corresponding to the current image, only the stored time stamp needs to be extracted, if the processing mode of the current image is to encode at least part of the region of the current image, the encoded region is decoded to obtain the decoded sub-region, and the decoded sub-region and the time stamp corresponding to the current image are superposed on the reference image, so that the decoding efficiency is improved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an embodiment of an electronic device 70 of the present application, where the electronic device 70 includes a memory 701 and a processor 702 coupled to each other, where the memory 701 stores program data (not shown), and the processor 702 calls the program data to implement the method in any of the embodiments described above, and for a description of related contents, reference is made to the detailed description of the embodiment of the method described above, which is not repeated herein.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an embodiment of a computer-readable storage medium 80 of the present application, the computer-readable storage medium 80 stores program data 800, and the program data 800 is executed by a processor to implement the method of any of the above embodiments, and the related contents are described in detail with reference to the above method embodiments, which are not repeated herein.
It should be noted that, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the purpose of illustrating embodiments of the present application and is not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application or are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (12)

1. An image encoding method, characterized in that the method comprises:
obtaining a current image, and determining a reference image detection result of the current image;
responding to the reference image detection result that a reference image exists, obtaining a motion detection result, and selecting a processing mode to process the current image based on the motion detection result; when the motion detection result indicates that a motion target exists, the processing mode is to encode at least a partial region of the current image, and the partial region includes the motion target;
and setting a flag bit matched with the processing mode for the processed current image.
2. The image encoding method of claim 1, wherein the step of obtaining the motion detection result and selecting a processing mode to process the current image based on the motion detection result comprises:
responding to the motion detection result that no motion target exists, selecting a processing mode to continue using a reference image corresponding to the current image, extracting a time stamp of the current image, and increasing a use count value corresponding to the reference image; alternatively, the first and second electrodes may be,
in response to the motion detection result indicating that a motion target exists, selecting a processing mode to encode at least a partial region of the current image, so as to extract at least a region corresponding to the motion-generated target from the current image for encoding, and adding a use count value corresponding to the reference image;
in response to the usage count value exceeding a count threshold, performing full frame encoding on the current image and clearing the usage count value.
3. The image encoding method of claim 2, wherein the step of obtaining the current image and determining the reference image detection result of the current image is followed by further comprising:
and in response to the reference image detection result being no reference image, selecting a processing mode to perform whole-frame encoding on the current image, wherein the current image after the whole-frame encoding is used as a new reference image.
4. The image encoding method according to claim 2, wherein the selection processing means, before the step of encoding at least a partial region of the current image, extracting at least a region corresponding to a target that has moved from the current image, encoding the region, and incrementing a usage count value corresponding to the reference image, further comprises:
determining whether the area of the region corresponding to the moving target accounts for the total area of the current image and exceeds a ratio threshold value;
and responding to the occupation ratio threshold value, selecting a processing mode to carry out whole-frame coding on the current image, taking the current image subjected to whole-frame coding as a new reference image and clearing the use count value.
5. The image encoding method according to claim 3, wherein the step of setting a flag bit matching the processing mode for the processed current image comprises:
responding to a processing mode to perform whole-frame coding on the current image, setting a first zone bit corresponding to the processing mode, and packaging and storing the processed current image and the first zone bit;
responding to a processing mode that a reference image corresponding to the current image is used, setting a second zone bit corresponding to the processing mode, and packaging and storing a timestamp of the current image and the second zone bit;
and responding to a processing mode of encoding at least partial area of the current image, setting a third zone bit corresponding to the processing mode, and packaging and storing the position information, the processed partial area and the third zone bit.
6. The image encoding method of claim 1, wherein the motion detection result is determined based on the steps comprising:
dividing the current image into a plurality of macro blocks, and determining sub-block detection results corresponding to the macro blocks;
responding to a motion macro block with a motion target in the current image, wherein at least one sub-block detection result in the current image is determined to be the motion macro block with the motion target, and determining that the motion detection result corresponding to the current image is determined to be the motion target;
and determining that the motion detection result corresponding to the current image is a non-motion target in response to that the detection results of the subblocks corresponding to all the macro blocks corresponding to the current image are non-motion targets.
7. The image encoding method of claim 6, wherein the step of encoding at least a partial region of the current image comprises:
determining a motion boundary area corresponding to the motion macro block, and expanding the motion boundary area outwards according to a preset macro block step length to obtain an area to be scratched;
determining the position information of the region to be scratched in the current image, and coding the region to be scratched in the current image based on the coding parameters matched with the position information.
8. The image coding method according to claim 7, wherein the step of determining a motion boundary region corresponding to the motion macroblock, and expanding the motion boundary region outwards according to a preset macroblock step size to obtain a region to be scratched comprises:
determining the motion boundary area based on all the motion macroblocks in response to the distance between any of the motion macroblocks and the nearest motion macroblock being within a distance threshold;
in response to the distance between at least two motion macro blocks and the nearest motion macro block exceeding the distance threshold, dividing all the motion macro blocks into at least two motion macro block aggregation areas based on the distance threshold, and respectively determining motion boundary areas corresponding to the motion macro block aggregation areas.
9. An image decoding method applied to the image encoding method according to any one of claims 1 to 8, comprising:
obtaining a current image to be decoded, and determining a processing mode of the current image based on a flag bit matched with the processing mode;
and in response to the processing mode, encoding at least part of the region of the current image, decoding the encoded region to obtain a decoded sub-region, superposing the timestamp corresponding to the current image and the decoded sub-region to the corresponding position on the reference image corresponding to the current image to obtain a decoded current image, and taking the decoded current image as a new reference image.
10. The image decoding method according to claim 9, wherein after the step of obtaining the current image to be decoded and determining the processing mode of the current image based on the flag bit matching the processing mode, the method further comprises:
in response to the processing mode, performing whole-frame encoding on the current image, directly performing whole-frame decoding on the current image to obtain a decoded current image, and taking the decoded current image as a new reference image;
and responding to a processing mode that a reference image corresponding to the current image is used, and superposing a time stamp corresponding to the current image on the reference image corresponding to the current image to obtain a decoded current image.
11. An electronic device, comprising: a memory and a processor coupled to each other, wherein the memory stores program data that the processor calls to perform the method of any of claims 1-8 or 9-10.
12. A computer-readable storage medium, on which program data are stored, which program data, when being executed by a processor, carry out the method of any one of claims 1-8 or 9-10.
CN202210580450.7A 2022-05-25 2022-05-25 Image encoding method, image decoding method, electronic device, and computer-readable storage medium Pending CN115022641A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210580450.7A CN115022641A (en) 2022-05-25 2022-05-25 Image encoding method, image decoding method, electronic device, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210580450.7A CN115022641A (en) 2022-05-25 2022-05-25 Image encoding method, image decoding method, electronic device, and computer-readable storage medium

Publications (1)

Publication Number Publication Date
CN115022641A true CN115022641A (en) 2022-09-06

Family

ID=83071385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210580450.7A Pending CN115022641A (en) 2022-05-25 2022-05-25 Image encoding method, image decoding method, electronic device, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN115022641A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115955566A (en) * 2023-03-03 2023-04-11 浙江大华技术股份有限公司 Encoding method and decoding method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115955566A (en) * 2023-03-03 2023-04-11 浙江大华技术股份有限公司 Encoding method and decoding method
CN115955566B (en) * 2023-03-03 2023-06-20 浙江大华技术股份有限公司 Encoding method and decoding method

Similar Documents

Publication Publication Date Title
US8320470B2 (en) Method for spatial error concealment
KR101152576B1 (en) Selecting encoding types and predictive modes for encoding video data
US20220058775A1 (en) Video denoising method and apparatus, and storage medium
JP5554831B2 (en) Distortion weighting
US20100080472A1 (en) Image processing apparatus, moving image decoding apparatus, moving image encoding apparatus and method
US8320700B2 (en) Apparatus and method of estimating scale ratio and noise strength of encoded image
CN110087075B (en) Image coding method, coding device and computer storage medium
CN109688407B (en) Reference block selection method and device for coding unit, electronic equipment and storage medium
CN111246219B (en) Quick dividing method for depth of CU (Central Unit) in VVC (variable valve timing) frame
US8363978B2 (en) System and method for block edge location with varying block sizes and offsets in compressed digital video
CN107820095B (en) Long-term reference image selection method and device
US20240015310A1 (en) Multimedia data processing method, apparatus, device, computer-readable storage medium, and computer program product
CN115022641A (en) Image encoding method, image decoding method, electronic device, and computer-readable storage medium
CN110381312B (en) HEVC (high efficiency video coding) -based depth partition range prediction method and device
KR20060111528A (en) Detection of local visual space-time details in a video signal
CN110572713B (en) Transcoding method and processing terminal for adaptive video bandwidth ratio
CN110493599B (en) Image recognition method and device
CN111083481A (en) Image coding method and device
CN113691811B (en) Coding block dividing method, device, system and storage medium
CN110519597B (en) HEVC-based encoding method and device, computing equipment and medium
CN111713105B (en) Video image processing method, device and storage medium
EP3926584A1 (en) Method, computer program and system for detecting changes and moving objects in a video view
CN110839157B (en) Image processing method and device
Decombas et al. Seam carving for semantic video coding
CN109951707B (en) Target motion vector selection method and device, electronic equipment and medium

Legal Events

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