CN116996687A - Image splitting coding method and device and electronic equipment - Google Patents

Image splitting coding method and device and electronic equipment Download PDF

Info

Publication number
CN116996687A
CN116996687A CN202310909627.8A CN202310909627A CN116996687A CN 116996687 A CN116996687 A CN 116996687A CN 202310909627 A CN202310909627 A CN 202310909627A CN 116996687 A CN116996687 A CN 116996687A
Authority
CN
China
Prior art keywords
compressed
image
area
layer
coding
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
CN202310909627.8A
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.)
Shenzhen Divoom Technology Co ltd
Original Assignee
Shenzhen Divoom 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 Shenzhen Divoom Technology Co ltd filed Critical Shenzhen Divoom Technology Co ltd
Priority to CN202310909627.8A priority Critical patent/CN116996687A/en
Publication of CN116996687A publication Critical patent/CN116996687A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/30Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using hierarchical techniques, e.g. scalability
    • 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/174Methods 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 slice, e.g. a line of blocks or a group of blocks
    • 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/182Methods 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 a pixel
    • 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/186Methods 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 a colour or a chrominance component
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/423Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements
    • H04N19/426Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements using memory downsizing methods
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application relates to an image splitting coding method, an image splitting coding device and electronic equipment. Dividing M layers of regions of the image to be compressed according to the coding data amount to obtain N regions to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data quantity corresponding to the coding of each region to be compressed in the corresponding target coding mode is smaller than the coding data quantity corresponding to the coding of the region to be compressed in other candidate coding modes; each region to be compressed in other layers except the layer where the smallest region to be compressed is located is coded in a corresponding target coding mode, and the corresponding coded data volume is smaller than the sum of the coded data volumes corresponding to the coding of each sub-region of the region to be compressed in any candidate coding mode; coding each region to be compressed in a corresponding target coding mode so as to perform corresponding compression to obtain a corresponding compressed image; m is an integer greater than or equal to 1, and N is an integer greater than 1.

Description

Image splitting coding method and device and electronic equipment
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image splitting encoding method, an image splitting encoding device, and an electronic device.
Background
With the popularization of mobile internet, users have a higher demand for animation resources. But the user experience is often impacted due to bandwidth limitations and device performance limitations. In the conventional animation image compression algorithm, the conventional JPEG format algorithm adopts lossy compression, so that the distortion problem is serious when processing certain pictures with smaller sizes, and the GIF format algorithm supports animation compression, but the compression rate is not high enough. In order to improve the efficiency of the transmission of animation resources and the viewing experience of users, an efficient compression algorithm is needed to reduce the amount of memory occupied by the animation resources, so as to improve the corresponding decoding speed.
Disclosure of Invention
In order to reduce the memory occupied by images and improve the corresponding decoding speed, the application provides an image splitting and encoding method, an image splitting and encoding device and electronic equipment.
In a first aspect, the present application provides an image splitting encoding method, including:
according to the coding data volume, carrying out M-layer region division on the image to be compressed to obtain N regions to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data volume corresponding to each region to be compressed coded in the corresponding target coding mode is smaller than the coding data volume corresponding to the region to be compressed coded in other candidate coding modes; the width of the smallest area to be compressed is larger than or equal to the dividing width of the preset area; each to-be-compressed area in other layers except the layer where the smallest to-be-compressed area is located is coded by the corresponding target coding mode to obtain a corresponding coded data volume which is smaller than the sum of coded data volumes corresponding to all sub-areas of the to-be-compressed area coded by any candidate coding mode;
Coding each region to be compressed in a corresponding target coding mode to perform corresponding compression so as to obtain a corresponding compressed image;
the candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode; m is an integer greater than or equal to 1, and N is an integer greater than 1.
By adopting the technical scheme, the image to be compressed is divided into M layers of regions according to the coding data quantity, and the target coding mode of each region to be compressed, which is obtained correspondingly, is the coding mode with the minimum coding data quantity. And carrying out targeted coding compression on each region to be compressed, so that the coding data volume of each region to be compressed is minimized, and the memory volume occupied by the whole picture is reduced. Compared with a method for compressing in a JPEG format, the image splitting and encoding method used in the embodiment is lossless compression, so that distortion of an image to be compressed can be avoided; compared with the method for compressing the GIF format, the image splitting and encoding method of the embodiment can reduce the compression rate, obtain a better compression effect and correspondingly improve the decoding speed.
Optionally, the performing M-layer region division on the image to be compressed according to the encoded data amount to obtain N regions to be compressed and corresponding target encoding modes includes:
According to the preset region division width and the preset level proportion, carrying out M-layer region division on the image to be compressed to obtain M-layer region to be compressed corresponding to the image to be compressed and a color mapping table corresponding to each region to be compressed;
based on a candidate coding mode and the color mapping table corresponding to each candidate compression area, counting the coding data quantity under each candidate coding mode corresponding to each candidate compression area;
and determining N areas to be compressed and corresponding target coding modes from the M-layer area to be compressed according to the coding data quantity of each candidate coding mode corresponding to each area to be compressed.
By adopting the technical scheme, the image to be compressed is divided according to the preset area dividing width and the preset level proportion, M layers of compressed areas to be selected are obtained, and the color mapping table corresponding to each compressed area to be selected is correspondingly obtained. And calculating the coded data quantity under each candidate coding mode corresponding to each candidate compression area based on the color mapping table and the candidate coding modes, so that the coded data quantity is more accurate and reliable. The target coding mode determined based on the coded data quantity is more accurate.
Optionally, the dividing the image to be compressed into M layers according to a preset area dividing width and a preset level proportion to obtain M layers of compressed areas to be selected corresponding to the image to be compressed and a color mapping table corresponding to each compressed area to be selected, including:
performing color classification on the image to be compressed to generate a basic color table;
carrying out layer 1 division on the image to be compressed according to the preset region division width to obtain a layer 1 compressed region to be selected;
for each layer 1 to-be-selected compression area, generating a color mapping table corresponding to each layer 1 to-be-selected compression area according to the color of each pixel point in each layer 1 to-be-selected compression area and referring to the basic color table;
according to the preset level proportion, taking a corresponding number of i-th layer to-be-selected compression areas as sub-areas, and carrying out non-repeated combination to generate a corresponding father area so as to obtain i+1-th layer to-be-selected compression areas; i is an integer greater than or equal to 1 and less than M;
and determining a color mapping table corresponding to each i+1-th layer to-be-selected compression region according to the color mapping table of the sub-region corresponding to the i+1-th layer to-be-selected compression region for each i+1-th layer to-be-selected compression region.
By adopting the technical scheme, the color mapping table of each 1 st layer compression area to be selected can be determined through the basic color table of the image to be compressed. And generating the color mapping table of the (i+1) th layer of the compressed area to be selected corresponding to the father area through a plurality of color mapping tables of the (i) th layer of the compressed area to be selected serving as the sub-areas, so that the color mapping table of each layer of the compressed area to be selected has clear and reliable sources.
Optionally, the determining N areas to be compressed and the corresponding target coding modes from the M layers of the areas to be compressed according to the coded data amount under each candidate coding mode corresponding to each area to be compressed includes:
for each layer 1 to-be-selected compression area, determining a corresponding target coding mode by comparing the corresponding coding data quantity of each candidate coding mode;
and for each i+1th layer of the to-be-compressed areas, determining N to-be-compressed areas and corresponding target coding modes by comparing the corresponding coding data quantity of the i+1th layer of the to-be-compressed areas under each candidate coding mode and the sum of the coding data quantity of the target coding modes of the sub-areas corresponding to the i+1th layer of the to-be-compressed areas.
By adopting the technical scheme, the region to be compressed and the target coding mode are determined through the comparison of the corresponding coding data quantity of each candidate coding mode or the comparison of the sum of the corresponding coding data quantity under each candidate coding mode and the coding data quantity of the target coding mode of the corresponding sub-region. And dividing each layer to obtain a to-be-selected compression region, and carrying out association processing to obtain the to-be-selected compression region to be compressed finally, thereby improving the accuracy of split coding.
Optionally, for each i+1th layer of the compression area to be selected, determining N regions to be compressed and corresponding target coding modes by comparing a sum of a corresponding coded data amount of the i+1th layer of the compression area to be selected in each candidate coding mode and a coded data amount of a target coding mode of a sub region corresponding to the i+1th layer of the compression area to be selected, including:
for each i+1 layer of to-be-selected compression area, if the coding data amount corresponding to each candidate coding mode of the i+1 layer of to-be-selected compression area is larger than the sum of the coding data amounts of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-selected compression area, determining the sub-area corresponding to the i+1 layer of to-be-selected compression area as the to-be-compressed area, and determining the target coding mode corresponding to the sub-area corresponding to the i+1 layer of to-be-selected compression area as the target coding mode corresponding to the to-be-compressed area; otherwise, determining the i+1th layer to-be-compressed area as a to-be-compressed area, and determining a candidate coding mode with the smallest coding data amount corresponding to the i+1th layer to-be-compressed area under each candidate coding mode as a target coding mode corresponding to the to-be-compressed area.
By adopting the technical scheme, when the coded data quantity corresponding to the i+1 layer to-be-selected compression region under each candidate coding mode is larger than the sum of the coded data quantities of the target coding modes of the sub-regions corresponding to the i+1 layer to-be-selected compression region, the target coding mode of the corresponding sub-region is used as the target coding mode of the i+1 layer to-be-selected compression region. Otherwise, the i+1th layer to-be-selected compression area is used as the to-be-compressed area, so that the determination of the to-be-compressed area is more accurate and reliable.
Optionally, the method further comprises:
judging whether the size of the original image meets the cutting condition or not;
if not, storing the size of the original image, and complementing the original image to the size corresponding to the cutting condition; determining the complemented original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity;
if yes, the original image is determined to be the image to be compressed, and M layers of area division is carried out on the image to be compressed according to the coding data quantity.
By adopting the technical scheme, whether the size of the original image meets the cutting condition is judged, the original image is complemented when the size of the original image does not meet the cutting condition, the fact that the size of the minimum to-be-selected compression area obtained by direct division does not meet the preset area division width is avoided, and then the compression effect of some to-be-compressed areas is poor is caused.
Optionally, the method further comprises:
when receiving a decompression request of the image to be compressed, decompressing a compressed image corresponding to the image to be compressed;
and removing the complement pixel points of the image to be compressed according to the size of the original image to obtain the original image.
By adopting the technical scheme, the complementary pixel points can be removed after the image to be compressed is decompressed, and the situation that the watching experience of a user is reduced due to the fact that the image to be compressed is directly displayed is avoided.
Optionally, the method further comprises:
when receiving an encoding instruction, extracting images from the animation resources to be compressed, determining a plurality of frames of images to be compressed, and dividing M layers of areas of the frames of images to be compressed respectively to obtain a plurality of corresponding compressed images;
and when a decoding instruction is received, decompressing the compressed images, and recovering the animation resources to be compressed.
By adopting the technical scheme, the image extraction is firstly carried out on the animation resources to be compressed when the encoding is needed, then the image splitting encoding method is carried out on each frame of the image to be compressed, the encoding is carried out, the decompression is correspondingly carried out when the decoding is needed, the memory occupied by the animation resources to be compressed is reduced, and meanwhile, the overall decoding speed is improved.
In a second aspect, the present application provides an image split encoding apparatus comprising:
the target coding mode determining module is used for dividing M layers of areas of the image to be compressed according to the coding data quantity to obtain N areas to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data volume corresponding to each region to be compressed coded in the corresponding target coding mode is smaller than the coding data volume corresponding to the region to be compressed coded in other candidate coding modes; the width of the smallest area to be compressed is larger than or equal to the dividing width of the preset area; each to-be-compressed area in other layers except the layer where the smallest to-be-compressed area is located is coded by the corresponding target coding mode to obtain a corresponding coded data volume which is smaller than the sum of coded data volumes corresponding to all sub-areas of the to-be-compressed area coded by any candidate coding mode;
the corresponding coding module is used for coding each region to be compressed in a corresponding target coding mode so as to perform corresponding compression to obtain a corresponding compressed image;
The candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode; m is an integer greater than or equal to 1, and N is an integer greater than 1.
Optionally, the target coding mode determining module is specifically configured to:
according to the preset region division width and the preset level proportion, carrying out M-layer region division on the image to be compressed to obtain M-layer region to be compressed corresponding to the image to be compressed and a color mapping table corresponding to each region to be compressed;
based on a candidate coding mode and the color mapping table corresponding to each candidate compression area, counting the coding data quantity under each candidate coding mode corresponding to each candidate compression area;
and determining N areas to be compressed and corresponding target coding modes from the M-layer area to be compressed according to the coding data quantity of each candidate coding mode corresponding to each area to be compressed.
Optionally, the target coding mode determining module is specifically configured to:
performing color classification on the image to be compressed to generate a basic color table;
carrying out layer 1 division on the image to be compressed according to the preset region division width to obtain a layer 1 compressed region to be selected;
For each layer 1 to-be-selected compression area, generating a color mapping table corresponding to each layer 1 to-be-selected compression area according to the color of each pixel point in each layer 1 to-be-selected compression area and referring to the basic color table;
according to the preset level proportion, taking a corresponding number of i-th layer to-be-selected compression areas as sub-areas, and carrying out non-repeated combination to generate a corresponding father area so as to obtain i+1-th layer to-be-selected compression areas; i is an integer greater than or equal to 1 and less than M;
and determining a color mapping table corresponding to each i+1-th layer to-be-selected compression region according to the color mapping table of the sub-region corresponding to the i+1-th layer to-be-selected compression region for each i+1-th layer to-be-selected compression region.
Optionally, the target coding mode determining module is specifically configured to:
for each layer 1 to-be-selected compression area, determining a corresponding target coding mode by comparing the corresponding coding data quantity of each candidate coding mode;
and for each i+1th layer of the to-be-compressed areas, determining N to-be-compressed areas and corresponding target coding modes by comparing the corresponding coding data quantity of the i+1th layer of the to-be-compressed areas under each candidate coding mode and the sum of the coding data quantity of the target coding modes of the sub-areas corresponding to the i+1th layer of the to-be-compressed areas.
Optionally, the target coding mode determining module is specifically configured to:
for each i+1 layer of to-be-selected compression area, if the coding data amount corresponding to each candidate coding mode of the i+1 layer of to-be-selected compression area is larger than the sum of the coding data amounts of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-selected compression area, determining the sub-area corresponding to the i+1 layer of to-be-selected compression area as the to-be-compressed area, and determining the target coding mode corresponding to the sub-area corresponding to the i+1 layer of to-be-selected compression area as the target coding mode corresponding to the to-be-compressed area; otherwise, determining the i+1th layer to-be-compressed area as a to-be-compressed area, and determining a candidate coding mode with the smallest coding data amount corresponding to the i+1th layer to-be-compressed area under each candidate coding mode as a target coding mode corresponding to the to-be-compressed area.
Optionally, the image splitting and encoding device further includes an image complement module, configured to:
judging whether the size of the original image meets the cutting condition or not;
if not, storing the size of the original image, and complementing the original image to the size corresponding to the cutting condition; determining the complemented original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity;
If yes, the original image is determined to be the image to be compressed, and M layers of area division is carried out on the image to be compressed according to the coding data quantity.
Optionally, the image splitting and encoding device further includes a decompression module, configured to:
when receiving a decompression request of the image to be compressed, decompressing a compressed image corresponding to the image to be compressed;
and removing the complement pixel points of the image to be compressed according to the size of the original image to obtain the original image.
Optionally, the image splitting and encoding device further includes an animation resource splitting module, configured to:
when receiving an encoding instruction, extracting images from the animation resources to be compressed, determining a plurality of frames of images to be compressed, and dividing M layers of areas of the frames of images to be compressed respectively to obtain a plurality of corresponding compressed images;
and when a decoding instruction is received, decompressing the compressed images, and recovering the animation resources to be compressed.
In a third aspect, the present application provides an electronic device comprising: a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and performing the method of the first aspect.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program capable of being loaded by a processor and performing the method of the first aspect.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions of the prior art, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it will be obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort to a person skilled in the art.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
FIG. 2 is a flowchart of an image splitting encoding method according to an embodiment of the present application;
FIG. 3 is a flow chart of split encoding according to an embodiment of the present application;
FIG. 4 is a flowchart of determining an optimal coding format according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an image splitting encoding device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It will be apparent that the described embodiments are some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In addition, the term "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In this context, unless otherwise specified, the term "/" generally indicates that the associated object is an "or" relationship.
Embodiments of the application are described in further detail below with reference to the drawings.
Currently, the number of users of the internet is increasing, and some animation resources are often checked on the network. Under the condition of limited bandwidth, the animation resources are required to be compressed, and the corresponding decoding speed is relatively high, so that a user can quickly browse the animation resources, and meanwhile, the user experience is enhanced. The compression formats that are more common in the related art are JPEG format and GIF format. In which the JPEG format is a lossy format, the distortion is very severe for smaller size pictures. And the compression rate of the GIF format is high and the decoding speed is also slow. Therefore, a lossless compression method with a higher compression ratio is needed to meet the requirement of users for fast browsing of animation resources.
Based on the image splitting and encoding method and device and electronic equipment are provided. A part of the color of a region on one image may be the same or similar, and the whole image may have a plurality of colors to be reused. Although the number of colors of the entire image is relatively large, the color variety of some partial areas is relatively small. Therefore, the image to be compressed can be divided, and targeted coding compression can be performed on the divided small areas. And carrying out M-layer region division on the image to be compressed according to the coding data quantity to obtain N regions to be compressed and a target coding mode corresponding to each region to be compressed, and coding the corresponding regions to be compressed according to the target coding mode so as to compress the regions to be compressed. The memory amount occupied by the animation resources is reduced, and the corresponding decoding speed is further improved.
Fig. 1 is a schematic view of an application scenario provided by the present application. The animation resource may contain a plurality of images to be compressed, and each image to be compressed can be processed when the animation resource is compressed. In the application scenario shown in fig. 1, the image splitting encoding method may be built on a splitting encoding device. The splitting and encoding device can divide each image to be compressed into areas according to the encoding data amount, obtain each divided area to be compressed and the corresponding target encoding mode, and then encode correspondingly so as to compress subsequently according to encoding.
Reference may be made to the following examples for specific implementation.
Fig. 2 is a flowchart of an image splitting encoding method according to an embodiment of the present application, where the method of the present embodiment may be applied to the splitting encoding device in the above scenario. As shown in fig. 2, the method includes:
and S201, dividing M layers of regions of the image to be compressed according to the coding data amount to obtain N regions to be compressed and corresponding target coding modes.
The amount of encoded data may be the amount of bytes that occupy memory when compressed after encoding. The region to be compressed can be a region to be compressed after splitting encoding of the image to be compressed is finished, and the target encoding mode is one of candidate encoding modes. The candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode.
M is an integer greater than or equal to 1, and N is an integer greater than 1. The coding data quantity corresponding to the coding of each region to be compressed in the corresponding target coding mode is smaller than the coding data quantity corresponding to the coding of the region to be compressed in other candidate coding modes.
The preset area dividing width can be a preset minimum width which can be achieved by the area to be compressed after the image to be compressed is divided. The width of the minimum region to be compressed is larger than or equal to the dividing width of the preset region, and the coded data amount corresponding to the coding of each region to be compressed in the other layers except the layer where the minimum region to be compressed is located in a corresponding target coding mode is smaller than the sum of the coded data amounts corresponding to the coding of each sub-region of the region to be compressed in any candidate coding mode. In some implementations, the preset area division width may be set to be long×width=8×8.
Specifically, when each layer of the image to be compressed is divided, the coding data amount under each candidate coding mode can be determined for each region to be compressed obtained by dividing. By comparing the coded data amount of each candidate coding mode, it is determined whether the division of the next layer is required. Therefore, the M-layer region division can be carried out on the image to be compressed according to the coding data quantity, and N regions to be compressed and corresponding target coding modes are obtained.
S202, coding according to a corresponding target coding mode for each region to be compressed so as to perform corresponding compression, and obtaining a corresponding compressed image.
The compressed image may be an integral image obtained by encoding each region of the image to be compressed according to a corresponding target encoding mode.
Specifically, after the to-be-compressed areas to be compressed are obtained, for each to-be-compressed area, encoding is performed according to a corresponding target encoding mode, so that the to-be-compressed areas are subjected to corresponding compression according to encoding, and a compressed image is obtained.
According to the coding data amount, the image to be compressed is divided into M layers of regions, and the target coding mode of each region to be compressed, which is obtained correspondingly, is the coding mode with the minimum coding data amount. And carrying out targeted coding compression on each region to be compressed, so that the coding data volume of each region to be compressed is minimized, and the memory volume occupied by the whole picture is reduced. Compared with a method for compressing in a JPEG format, the image splitting and encoding method used in the embodiment is lossless compression, so that distortion of an image to be compressed can be avoided; compared with the method for compressing the GIF format, the image splitting and encoding method of the embodiment can reduce the compression rate, obtain a better compression effect and correspondingly improve the decoding speed.
In some embodiments, the image to be compressed may be divided into M layers according to a preset region division width and a preset hierarchy ratio to obtain M layers of compressed regions to be selected and color mapping tables corresponding to each compressed region to be selected. And obtaining the coding data quantity of each candidate compression region in each candidate coding mode through the color mapping table, and determining N regions to be compressed in the M layers of the candidate compression regions based on the coding data quantity. Specifically, according to a preset region division width and a preset level proportion, carrying out M-layer region division on an image to be compressed to obtain M-layer regions to be compressed corresponding to the image to be compressed and a color mapping table corresponding to each region to be compressed; based on the candidate coding modes and the color mapping table corresponding to each candidate compression area, counting the coding data quantity under each candidate coding mode corresponding to each candidate compression area; and determining N areas to be compressed and corresponding target coding modes from the M layers of the areas to be compressed according to the coding data quantity of each candidate coding mode corresponding to each area to be compressed.
The preset level ratio may be an expansion ratio of a preset region division width when each layer of division is performed on the image to be compressed. In some implementations, the preset level ratio may be set to 2 times, and assuming that the preset area division width is 8×8, then the layer 1 division may perform image division according to 8×8, the layer 2 may perform image division according to 16×16, the layer 3 may perform image division according to 32×32, and the color mapping table of the layer … … may be used to store the position of each pixel point on the image to be compressed and the color of each pixel point in the corresponding area to be compressed. The color mapping tables of the different areas to be compressed may be stored in advance. The compressed region to be selected may be a small region obtained by dividing the image to be compressed, and these small regions are not necessarily regions to be compressed.
Assuming that the total number of colors of the region to be compressed in any one of the compression regions is C, the number of pixels in the region to be compressed is N, and b may be used to represent the number of bits to be used when storing the data in the region to be compressed, it should be noted that a binary system is used when storing. The coded data amount (byte amount) corresponding to the independent index mode of the compressed area to be selected may be:
c3+ (n+b+7)/8, wherein 2 b <C<2 b+1
When the M-layer region division is performed, the candidate compression region of the current layer is obtained by dividing a certain candidate compression region of the previous layer, so that the certain candidate compression region of the previous layer can be used as a parent region of the candidate compression region of the current layer, and the candidate compression region of the current layer can be used as a sub-region of the certain candidate compression region of the previous layer.
Assuming that the number of pixel points H of the parent region of any one of the compression regions is C, the total number of colors of the parent region of the compression region to be selected may be the coded data amount (byte amount) corresponding to the inheritance index manner of the compression region to be selected:
(H.b+7)/8, wherein 2 b <C<2 b+1
Assuming that the total number of colors of any one of the compression areas is C, the total number of colors of the parent area of the compression area is H, the coded data amount (byte amount) corresponding to the mixed index mode of the compression area may be:
(h+7)/8+ (n+b+7)/8, wherein 2 b <C<2 b+1
Assuming that the number of pixel points of any compression region to be selected is N, the bare data encoding mode of the compression region to be selected is to directly store RGB data of the compression region to be selected, and the corresponding encoding data amount (byte amount) may be:
N*3。
specifically, the preset region dividing width is expanded according to the preset level proportion, M layers of division are carried out, M layers of compressed regions to be selected corresponding to the M layers of divided regions are obtained, and then a corresponding color mapping table is matched for each compressed region to be selected. For each of the candidate compression regions, a corresponding number of pixel points and a total number of colors may be determined according to a corresponding color mapping table. According to the compressed areas to be selected obtained by dividing each layer, the father area corresponding to each compressed area to be selected can be determined. And then, calculating the corresponding coded data quantity of each candidate compression region according to each candidate coding mode, and carrying out statistics. The coding data amount under each candidate coding mode corresponding to each candidate compression area can be compared, the candidate compression area with the minimum coding data amount when any candidate coding mode is used for coding is determined as the area to be compressed, and the candidate coding mode with the minimum coding data amount is used as the target coding mode of the area to be compressed.
In this embodiment, the image to be compressed is divided according to a preset region division width and a preset level proportion, so as to obtain M layers of compressed regions to be selected, and a color mapping table corresponding to each compressed region to be selected is correspondingly obtained. And calculating the coded data quantity under each candidate coding mode corresponding to each candidate compression area based on the color mapping table and the candidate coding modes, so that the coded data quantity is more accurate and reliable. The target coding mode determined based on the coded data quantity is more accurate.
In some embodiments, the image to be compressed may be color-classified to generate a base color table, and different processing is performed on the 1 st layer partition and the i+1 th layer partition based on the base color table, so as to obtain a color mapping table of each layer of the compressed area to be selected. Specifically, performing color classification on an image to be compressed to generate a basic color table; carrying out layer 1 division on the image to be compressed according to the preset region division width to obtain a layer 1 compressed region to be selected; for each layer 1 to-be-selected compression area, generating a color mapping table corresponding to each layer 1 to-be-selected compression area according to the color of each pixel point in each layer 1 to-be-selected compression area and referring to a basic color table; according to the preset level proportion, taking a corresponding number of i-th layer to-be-selected compression areas as sub-areas, and carrying out non-repeated combination to generate a corresponding father area so as to obtain i+1-th layer to-be-selected compression areas; and determining the color mapping table corresponding to each i+1-th layer to-be-selected compression region according to the color mapping table of the sub-region corresponding to the i+1-th layer to-be-selected compression region.
Wherein i is an integer of 1 or more and less than M. The base color table may be used to store the location of each pixel of the entire image to be compressed on the image to be compressed and the color of each pixel. Since the size of the image to be compressed is known, the preset area division width and the preset level ratio can be set in advance, so that the number of the compressed areas to be selected which can be obtained by each layer of division can be determined.
Specifically, an image to be compressed is analyzed, which color is corresponding to different pixel points is determined, the different colors are used as the table heads, the positions of the pixel points corresponding to each color are correspondingly stored, and a basic color table is generated. Firstly, carrying out layer 1 division on an image to be compressed according to a preset region division width, correspondingly searching colors in a basic color table according to the positions of pixel points for each layer 1 region to be compressed, and then extracting the corresponding relation between the positions of the pixel points of each layer 1 region to be compressed and the colors to generate a corresponding color mapping table. Except for the 1 st layer of the compressed areas to be selected, a corresponding number of i th layer of the compressed areas to be selected can be correspondingly determined according to a preset level proportion, the i th layer of the compressed areas to be selected of the corresponding number are taken as sub-areas, non-repeated combination is carried out, corresponding father areas are generated, and a plurality of father areas can form the i+1 th layer of the compressed areas to be selected. For each i+1-th layer to-be-selected compression region, the color mapping tables corresponding to each i+1-th layer to-be-selected compression region can be generated in a combined mode according to the color mapping tables of the corresponding sub-regions.
The embodiment can determine the color mapping table of each layer 1 candidate compression area through the basic color table of the image to be compressed. And generating the color mapping table of the (i+1) th layer of the compressed area to be selected corresponding to the father area through a plurality of color mapping tables of the (i) th layer of the compressed area to be selected serving as the sub-areas, so that the color mapping table of each layer of the compressed area to be selected has clear and reliable sources.
In some embodiments, the comparison of the coded data amounts of different modes is performed for each 1 st layer to-be-selected compression region and each i+1 th layer to-be-selected compression region, so as to determine the respective target coding modes corresponding to each 1 st layer to-be-selected compression region and each i+1 th layer to-be-selected compression region. Specifically, for each layer 1 to-be-selected compression area, determining a corresponding target coding mode by comparing the coded data amount corresponding to each candidate coding mode; and aiming at each i+1 layer of to-be-compressed area, determining N to-be-compressed areas and corresponding target coding modes by comparing the corresponding coding data quantity of the i+1 layer of to-be-compressed area under each candidate coding mode and the sum of the coding data quantity of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-compressed area.
The layer 1 to-be-selected compression area is obtained by dividing the image to be compressed into a first layer of areas, so that the father area corresponding to the layer 1 to-be-selected compression area is the image to be compressed. If the encoding mode of the candidate corresponding to the encoding data amount of the whole image to be compressed is used for encoding, the encoding mode is not consistent with the split encoding of the application, so that the encoding data amount of a father region is not considered for the corresponding layer 1 to be compressed region, and only each layer 1 to be compressed region is considered.
Specifically, for the layer 1 candidate compression region, the corresponding coded data amount calculated by each candidate coding mode is compared, and the coded data amount is the minimum as the target coding mode. For each i+1 layer of the compression area to be selected, determining the coding mode with the minimum data quantity by comparing the corresponding coded data quantity calculated by the i+1 layer of the compression area to be selected by using each candidate coding mode and the sum of the coded data quantity of the target coding modes of the sub-areas corresponding to the i+1 layer of the compression area to be selected, wherein the coding mode with the minimum data quantity is used as the corresponding target coding mode, and the compression area to be selected coded by using the target coding mode can be used as the compression area to be compressed.
In this embodiment, the region to be compressed and the target coding mode are determined by comparing the corresponding coded data amount of each candidate coding mode or comparing the sum of the corresponding coded data amount of each candidate coding mode and the coded data amount of the target coding mode of the corresponding sub-region. And dividing each layer to obtain a to-be-selected compression region, and carrying out association processing to obtain the to-be-selected compression region to be compressed finally, thereby improving the accuracy of split coding.
In some embodiments, for each i+1th layer to-be-selected compressed area, if the sum of the coded data amounts corresponding to the target coding modes of the corresponding sub-areas is the smallest coded data amount of the i+1th layer to-be-selected compressed area, the target coding mode of the sub-area may be used as its own target coding mode; otherwise, determining the candidate coding mode with the minimum corresponding coding data quantity under each candidate coding mode as the corresponding target coding mode. Specifically, for each i+1th layer of to-be-selected compression area, if the amount of coded data corresponding to each candidate coding mode of the i+1th layer of to-be-selected compression area is greater than the sum of the amounts of coded data of the target coding modes of the sub-areas corresponding to the i+1th layer of to-be-selected compression areas, determining the sub-area corresponding to the i+1th layer of to-be-selected compression area as the to-be-compressed area, and determining the target coding mode corresponding to the sub-area corresponding to the i+1th layer of to-be-selected compression area as the target coding mode corresponding to the to-be-compressed area; otherwise, determining the i+1th layer to-be-compressed area as the to-be-compressed area, and determining the candidate coding mode with the smallest coding data amount corresponding to the i+1th layer to-be-compressed area under each candidate coding mode as the target coding mode corresponding to the to-be-compressed area.
Specifically, when the amount of encoded data corresponding to the i+1th layer to-be-selected compression area in each candidate encoding mode is greater than the sum of the amounts of encoded data of the target encoding modes of the sub-areas corresponding to the i+1th layer to-be-selected compression area, it can be stated that if the i+1th layer to-be-selected compression area is taken as the to-be-compressed area, the amount of encoded data is not the minimum, and at this time, the target encoding mode of the corresponding sub-area is taken as the target encoding mode of the i+1th layer to-be-selected compression area. When the amount of the encoded data corresponding to the i+1th layer to-be-selected compression area under each candidate encoding mode is smaller than the sum of the amounts of the encoded data of the target encoding modes of the sub-areas corresponding to the i+1th layer to-be-selected compression area, it can be explained that the i+1th layer to-be-selected compression area is the smallest as the amount of the encoded data of the to-be-compressed area, and the i+1th layer to-be-selected compression area can be determined as the to-be-compressed area. And determining a target coding mode corresponding to the region to be compressed through comparing the corresponding coding data quantity under each candidate coding mode.
In this embodiment, when the amount of encoded data corresponding to each candidate encoding mode in the i+1th layer to-be-selected compression area is greater than the sum of the amounts of encoded data of the target encoding modes of the sub-areas corresponding to the i+1th layer to-be-selected compression area, the target encoding mode of the corresponding sub-area is used as the target encoding mode of the i+1th layer to-be-selected compression area. Otherwise, the i+1th layer to-be-selected compression area is used as the to-be-compressed area, so that the determination of the to-be-compressed area is more accurate and reliable.
In some embodiments, it may be determined in advance whether the size of the original image meets the cutting condition, and if the size meets the cutting condition, the region division is performed, and if the size does not meet the cutting condition, the complement is performed. Specifically, judging whether the size of the original image meets the cutting condition or not; if not, storing the size of the original image, and complementing the original image to the size corresponding to the cutting condition; determining the complemented original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity; if yes, determining the original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity.
The condition for satisfying the cutting condition may be a condition for satisfying a preset area division width and a width expanded by a preset level ratio for cutting. The original image meeting the cutting condition can be subjected to region division according to the preset region division width and the preset level proportion. Assuming that the preset area dividing width is long x width=8 x 8, the preset level ratio is 2 times, when the size of the original image is a x a and the cutting condition is not satisfied, the pixel point can be supplemented for the original image at this time, so that the original image is expanded to the power of 2 x 2, the cutting condition is satisfied, and the image with the power of 2 x 2 can be used as the target image. In some implementations, whether the size of the original image meets the cutting condition can be determined according to the preset area division width and the preset level proportion, and if not, the size of the original image is stored first and then is complemented. And determining the complemented original image as a region to be compressed, and then dividing the region. If the two images are in accordance, the original images are directly subjected to regional division.
In other implementations, the cutting conditions corresponding to different preset area division widths and different preset level ratios may be preset. And matching the size of the original image with the size corresponding to the cutting condition, and determining whether the original image meets the cutting condition.
In this embodiment, whether the size of the original image meets the cutting condition is first determined, and if not, the original image is complemented, so that the fact that the size of the minimum to-be-selected compression area obtained by direct division does not meet the preset area division width is avoided, and further the compression effect of some to-be-compressed areas is poor.
In some embodiments, if the original image does not meet the cutting condition and is complemented, the complemented pixels are removed when the decompressed image to be compressed is obtained. Specifically, when receiving a decompression request of an image to be compressed, decompressing a compressed image corresponding to the image to be compressed; and removing the complement pixel points of the image to be compressed according to the size of the original image to obtain the original image.
The decompression request may be a requirement of a user for decompressing an image to be compressed, and in an actual implementation process, the requirement of the user for decompressing the image to be compressed corresponding to a certain animation resource may be generated when the user clicks a link of the animation resource to play the animation resource. The complement pixel may be a pixel that increases when the image is complemented to a size corresponding to the cutting condition in the above embodiment.
Specifically, decompression is performed when a decompression request of an image to be compressed sent by a user is received. And then removing the complement pixels of the image to be compressed obtained by decompression according to the size of the original image stored in the embodiment, and restoring the original image.
According to the embodiment, the supplementary pixel points can be removed after the target image is decompressed, so that the problem that the watching experience of a user is reduced due to direct display of the target image is avoided.
In some embodiments, the animation resources to be compressed may be subjected to image splitting, and for each frame of the image to be compressed, an image splitting encoding method is performed to encode. Specifically, when receiving an encoding instruction, extracting images from animation resources to be compressed, determining a plurality of frames of images to be compressed, and dividing M layers of areas of the frames of images to be compressed respectively to obtain a plurality of corresponding compressed images; and when a decoding instruction is received, decompressing a plurality of compressed images, and recovering the animation resources to be compressed.
The animation resources to be compressed may be animation resources that need to be compressed. The coding instruction can be an instruction for compressing the to-be-compressed resource, and can be triggered when the download of the to-be-compressed animation resource is detected and a cache button is selected. The decoding instruction may be an instruction generated by decompressing the compressed animation resource to be compressed when the user clicks a link of a certain animation resource to play the animation resource. The coding instruction can contain the name of the animation resource to be compressed, which needs to be coded, so that the corresponding animation resource to be compressed can be conveniently searched for coding. The decoding instruction can contain the name of the animation resource to be compressed, which needs to be decompressed, so that the corresponding compressed animation resource to be compressed can be conveniently searched for decompression.
Specifically, the animation resource to be compressed can be subjected to image splitting to obtain a plurality of frames of images to be compressed. When receiving the encoding instruction, the image splitting encoding method in the above embodiment is performed for encoding for each frame of the image to be compressed. And when receiving the decoding instruction, decompressing each frame of compressed image of the corresponding compressed animation resource to be compressed, and reverting to the animation resource to be compressed.
In the embodiment, firstly, the image extraction is carried out on the animation resources to be compressed in need of encoding, then the image splitting encoding method is carried out on each frame of image to be compressed, encoding is carried out, decompression is correspondingly carried out when decoding is needed, the memory occupied by the animation resources to be compressed is reduced, and meanwhile, the overall decoding speed is improved.
In other embodiments, it is generally believed that a portion of an image will have the same or similar color and that the entire work will have many colors that are reused, although the number of colors in the entire work is relatively large, some of the partial areas will have a relatively small color count.
The basic idea of the coding is that firstly, a color table (basic color table) of an image is stored, all used color types are stored in a table header, and the space (storage space) occupied by the table header is =image information fixed head+color information table (the basic color table has the specification of C3, wherein C is the number of colors); and then stores the image point (pixel point) data of the image.
Image point color index table: the color of this image point (pixel point) is at the position of the color information table header;
the image point stores a bitmap: if the total number of colors of the color information table (base color table) is C, then all the pixel indices will be smaller than C, so b+1 bit data can be used to represent the pixel index (2 b <C<2 b+1 ). If the picture (image) has N points, then storing the data (image taking up the size of the storage space) would require ((b+1) n+7)/8 bytes.
Image subregion: there may be a relatively large number of colors in the Zhang Datu area, and when the area is divided into four small areas (to-be-selected compressed areas), the number of colors used in each small area (to-be-selected compressed area) is relatively small, and the occupied space is dependent on the number of colors used in the area when the bitmap is stored from the upper image point, so that in order to obtain a lower compression rate, the area is divided into four sub-areas when necessary, so that the space for storing the bitmap is reduced to improve the overall image compression rate.
Color mapping table: for an image area, the stored information is divided into a color index table and an image point storage bitmap, and the number of colors is fixed, so that the space occupied by the color index table is reduced in order to achieve higher compression rate.
Here we also use the image point storage bitmap to represent that if the parent region of the previous stage uses N colors, then the number of colors used by the current sub-region must be less than N, we can use N bits, where a bit of 1 indicates that this color is used and 0 indicates that this color is not used, so as to reduce the space occupied by the color index table. For example, the parent region uses 12 colors, the sub-region uses the 3,4,5,8,9, 11 six colors of the 12 colors, which can be represented by bits 010110011100 =0x059c, and only six colors are used for the present region, each image point stores the bitmap only requiring 3 bits, wherein the sub-region and the parent region have the color correspondence of (1 st- > 3 rd color), (2 nd- > 4 th color), (3 rd- > 5 th color), (4 th- > 8 th color), (5 th- > 9 th color), (6 th- > 11 th color).
Image coding several ways:
first: image point color index table (C colors) +image point storage bitmap (N image points, 2) b <C<2 b+1 ) We refer to the independent index method, which is that the pixel color index table records all colors used in the area, and the occupied space is 3 (each color stores three bytes of RGB), so the total size of the encoded space=c3+ (n×b+7)/8 bytes; second,: color mapping table of parent region (parent region contains C colors) +image point storage bitmap (N image points, 2) b <C<2 b+1 ) We refer to the inheritance index approach, which directly uses the color mapping table of the parent region, so the total size of the encoded space (n×b+7)/8 bytes;
third,: color mapping table of the local area (C colors of the local area, H colors of the father area) +image point storage bitmap (N image points, 2) b <C<2 b+1 ) We refer to the hybrid index approach, which stores one more color mapping table from parent region to sub-region, but the color number is reduced, the total size of the encoded space (h+7)/8+ (n×b+7)/8 bytes;
fourth,: the direct storage of bare data in the region, which is referred to as a bare data encoding method, is referred to as a bare RGB data encoding method, and if the number of image points is N, the total size of the encoded space is N×3;
fifth (coding scheme corresponding to the sum of the coded data amounts of the target coding scheme of the sub-region corresponding to the present region): the area is not coded, but divided into four sub-areas, split from left to right and then from top to bottom, and the sub-areas are coded, which is called a split coding mode, and the coded space is formed by the sum of the four sub-area coding spaces, namely sub-area one coding data, sub-area two coding data, sub-area three coding data and sub-area four coding data.
Related data structures:
coding data structure of image area:
image width (two bytes W) +image height (two bytes H) +image coding mode (one byte) +coded data;
the algorithm implementation will be described below, and for convenience of explanation, we will refer to the image size as (2 b *2 b Wherein b>An image of=3) is exemplified.
In the encoding process, in order to obtain a lower compression rate, we compare several encoded data amounts, and finally use the one with the smallest encoded data amount (target encoding mode), so as to reach the highest compression rate in the algorithm.
The following is a detailed process of encoding, refer to a split encoding flowchart shown in fig. 3, where the area width1 may be used to represent an image width corresponding to a preset division width; the area width 2=area width1×2 may be used to indicate that the preset division width is expanded according to a preset hierarchy ratio to obtain an image width; the AreaID subregion can be used for representing the subregion obtained by dividing the region of the layer of the object to be compressed:
first: acquiring coding modes of all areas:
step 1: if the width of the coding region is smaller than 8, counting the size of the coded data in four modes of an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode, taking the final coding mode with the minimum coded data size, and marking the coding mode of the current region; otherwise (the width is more than 8), jumping to the step 2;
Step 2: firstly, counting the size of the coded data of the area by using an independent index mode, a inheritance index mode, a mixed index mode and a bare data coding mode; dividing the region into four sub-regions, respectively counting the data size of the four sub-regions after coding by using recursion statistics, defining the sum of the coded data sizes of the four sub-regions as the data size of a split coding mode, comparing independent index modes, inheriting the index modes, mixing the index modes, a bare data coding mode, splitting the data sizes of five coding modes of the coding mode, taking the data size which is the smallest as a final coding mode (target coding mode), and marking the coding mode of the current region;
second,: encoding a certain image area, referring to the optimal encoding format determination flowchart shown in fig. 4, wherein the area width1 may be used to represent an image width corresponding to a preset division width; the area width 2=area width1×2 may be used to indicate that the image width is obtained after the preset division width is expanded according to the preset hierarchy ratio:
step 1: if the region coding is any one of an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode, corresponding coding is carried out, and the region coding is ended; otherwise, enter step 2;
Step 2: the region is divided into four sub-regions, the four word regions are encoded respectively, and the four sub-region encoded data are combined to generate final encoded data (the optimal encoding format is shown in fig. 4).
1. Determining the coding mode of each region in the image to be coded:
judging whether the width of the image to be coded is larger than the dividing width of a preset area or not;
if the width of the image to be coded is smaller than or equal to the preset area division width, directly calculating the corresponding coding data amount of the image to be coded in each candidate coding mode, and determining the candidate coding mode with the minimum coding data amount as a target coding mode;
if the width of the image to be coded is larger than the dividing width of the preset region, calculating the corresponding coding data amount of the image to be coded in each candidate coding mode, splitting the image to be coded into a corresponding number of regions according to the proportion of the preset hierarchy, respectively counting the corresponding coding data amount of each region in each candidate coding mode by using recursion statistics, defining the sum of the minimum coding data amounts of each region as the coding data amount of the splitting coding mode of the region, comparing the data amounts of the candidate coding mode and the splitting coding mode, and determining the coding mode with the minimum data amount as the coding mode corresponding to the region; if the coding mode is a split coding mode, repeating the steps of splitting the region according to the preset hierarchy ratio and determining the coding mode until the width of the region is smaller than or equal to the dividing width of the preset region.
2. According to the coding mode of each region, determining the coding data structure of the image to be coded:
image width (two bytes W) +image height (two bytes H) +image coding mode (one byte) +coded data.
3. Coding the image to be coded according to the coding mode of each region stored in the coding data structure of the image to be coded:
judging whether the coding mode of each region is a candidate coding mode or not according to each region;
if the coding mode of the region is the same, directly coding by a corresponding coding mode;
if the coding mode of the region is not candidate (split coding mode), splitting the region into a corresponding number of sub-regions according to a preset level ratio, and coding according to the corresponding coding mode.
Fig. 5 is a schematic structural diagram of an image splitting encoding device according to an embodiment of the present application, and as shown in fig. 5, an image splitting encoding device 500 according to the present embodiment includes: a target coding mode determining module 501 and a corresponding coding module 502.
The target coding mode determining module 501 is configured to perform M-layer region division on an image to be compressed according to the amount of coded data, to obtain N regions to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data quantity corresponding to the coding of each region to be compressed in the corresponding target coding mode is smaller than the coding data quantity corresponding to the coding of the region to be compressed in other candidate coding modes; the width of the smallest area to be compressed is larger than or equal to the dividing width of the preset area; each region to be compressed in other layers except the layer where the smallest region to be compressed is located is coded in a corresponding target coding mode, and the corresponding coding data quantity is smaller than the sum of the coding data quantities corresponding to the coding of all the subregions of the region to be compressed in any candidate coding mode;
The corresponding encoding module 502 is configured to encode each region to be compressed in a corresponding target encoding manner, so as to perform corresponding compression, thereby obtaining a corresponding compressed image;
the candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode; m is an integer greater than or equal to 1, and N is an integer greater than 1.
Optionally, the target coding manner determining module 501 is specifically configured to:
according to the preset region division width and the preset level proportion, carrying out M-layer region division on the image to be compressed to obtain M-layer compression regions to be selected corresponding to the image to be compressed and a color mapping table corresponding to each compression region to be selected;
based on the candidate coding modes and the color mapping table corresponding to each candidate compression area, counting the coding data quantity under each candidate coding mode corresponding to each candidate compression area;
and determining N areas to be compressed and corresponding target coding modes from the M layers of the areas to be compressed according to the coding data quantity of each candidate coding mode corresponding to each area to be compressed.
Optionally, the target coding manner determining module 501 is specifically configured to:
performing color classification on an image to be compressed to generate a basic color table;
Carrying out layer 1 division on the image to be compressed according to the preset region division width to obtain a layer 1 compressed region to be selected;
for each layer 1 to-be-selected compression area, generating a color mapping table corresponding to each layer 1 to-be-selected compression area according to the color of each pixel point in each layer 1 to-be-selected compression area and referring to a basic color table;
according to the preset level proportion, taking a corresponding number of i-th layer to-be-selected compression areas as sub-areas, and carrying out non-repeated combination to generate a corresponding father area so as to obtain i+1-th layer to-be-selected compression areas; i is an integer greater than or equal to 1 and less than M;
and determining the color mapping table corresponding to each i+1-th layer to-be-selected compression region according to the color mapping table of the sub-region corresponding to the i+1-th layer to-be-selected compression region.
Optionally, the target coding manner determining module 501 is specifically configured to:
for each layer 1 to-be-selected compression area, determining a corresponding target coding mode by comparing the corresponding coding data quantity of each candidate coding mode;
and aiming at each i+1 layer of to-be-compressed area, determining N to-be-compressed areas and corresponding target coding modes by comparing the corresponding coding data quantity of the i+1 layer of to-be-compressed area under each candidate coding mode and the sum of the coding data quantity of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-compressed area.
Optionally, the target coding manner determining module 501 is specifically configured to:
for each i+1 layer of to-be-compressed area, if the coding data amount corresponding to the i+1 layer of to-be-compressed area under each candidate coding mode is larger than the sum of the coding data amounts of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-compressed areas, determining the sub-areas corresponding to the i+1 layer of to-be-compressed areas as to-be-compressed areas, and determining the target coding modes corresponding to the sub-areas corresponding to the i+1 layer of to-be-compressed areas as to-be-compressed areas;
otherwise, determining the i+1th layer to-be-compressed area as the to-be-compressed area, and determining the candidate coding mode with the smallest coding data amount corresponding to the i+1th layer to-be-compressed area under each candidate coding mode as the target coding mode corresponding to the to-be-compressed area.
Optionally, the image splitting encoding apparatus 500 further includes an image complement module 503, configured to:
judging whether the size of the original image meets the cutting condition or not;
if not, storing the size of the original image, and complementing the original image to the size corresponding to the cutting condition;
determining the complemented original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity;
If yes, determining the original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity.
Optionally, the image splitting encoding apparatus 500 further includes a decompression module 504, configured to:
when receiving a decompression request of an image to be compressed, decompressing the compressed image corresponding to the image to be compressed;
and removing the complement pixel points of the image to be compressed according to the size of the original image to obtain the original image.
Optionally, the image splitting encoding apparatus 500 further includes an animation resource splitting module 505 for:
when receiving an encoding instruction, extracting images from the animation resources to be compressed, determining a plurality of frames of images to be compressed, and dividing M layers of areas of the frames of images to be compressed respectively to obtain a plurality of corresponding compressed images;
and when a decoding instruction is received, decompressing the compressed images, and recovering the animation resources to be compressed.
The apparatus of this embodiment may be used to perform the method of any of the foregoing embodiments, and its implementation principle and technical effects are similar, and will not be described herein again.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application, as shown in fig. 6, an electronic device 600 of the present embodiment may include: a memory 601 and a processor 602.
The memory 601 has stored thereon a computer program that can be loaded by the processor 602 and that performs the methods of the embodiments described above.
The processor 602 is coupled to the memory 601, such as via a bus.
Optionally, the electronic device 600 may also include a transceiver. It should be noted that, in practical applications, the transceiver is not limited to one, and the structure of the electronic device 600 is not limited to the embodiment of the present application.
The processor 602 may be a CPU (Central Processing Unit ), general purpose processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit ), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware components, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 602 may also be a combination that performs computing functions, such as including one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
A bus may include a path that communicates information between the components. The bus may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture ) bus, or the like. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The Memory 601 may be, but is not limited to, ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, RAM (Random Access Memory ) or other type of dynamic storage device that can store information and instructions, EEPROM (Electrically Erasable Programmable Read Only Memory ), CD-ROM (Compact Disc Read Only Memory, compact disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
The memory 601 is used for storing application program codes for executing the inventive arrangements and is controlled to be executed by the processor 602. The processor 602 is configured to execute the application code stored in the memory 601 to implement what is shown in the foregoing method embodiments.
Among them, electronic devices include, but are not limited to: mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. But may also be a server or the like. The electronic device shown in fig. 6 is only an example and should not be construed as limiting the functionality and scope of use of the embodiments of the application.
The electronic device of the present embodiment may be used to execute the method of any of the foregoing embodiments, and its implementation principle and technical effects are similar, and will not be described herein.
The present application also provides a computer-readable storage medium storing a computer program capable of being loaded by a processor and executing the method in the above embodiments.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.

Claims (10)

1. An image splitting encoding method, comprising:
according to the coding data volume, carrying out M-layer region division on the image to be compressed to obtain N regions to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data volume corresponding to each region to be compressed coded in the corresponding target coding mode is smaller than the coding data volume corresponding to the region to be compressed coded in other candidate coding modes; the width of the smallest area to be compressed is larger than or equal to the dividing width of the preset area; each to-be-compressed area in other layers except the layer where the smallest to-be-compressed area is located is coded by the corresponding target coding mode to obtain a corresponding coded data volume which is smaller than the sum of coded data volumes corresponding to all sub-areas of the to-be-compressed area coded by any candidate coding mode;
Coding each region to be compressed in a corresponding target coding mode to perform corresponding compression so as to obtain a corresponding compressed image;
the candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode; m is an integer greater than or equal to 1, and N is an integer greater than 1.
2. The method according to claim 1, wherein the performing M-layer region division on the image to be compressed according to the encoded data amount to obtain N regions to be compressed and corresponding target encoding modes includes:
according to the preset region division width and the preset level proportion, carrying out M-layer region division on the image to be compressed to obtain M-layer region to be compressed corresponding to the image to be compressed and a color mapping table corresponding to each region to be compressed;
based on a candidate coding mode and the color mapping table corresponding to each candidate compression area, counting the coding data quantity under each candidate coding mode corresponding to each candidate compression area;
and determining N areas to be compressed and corresponding target coding modes from the M-layer area to be compressed according to the coding data quantity of each candidate coding mode corresponding to each area to be compressed.
3. The method according to claim 2, wherein the dividing the image to be compressed into M layers according to a preset region dividing width and a preset hierarchy ratio to obtain M layers of compressed regions corresponding to the image to be compressed and a color mapping table corresponding to each compressed region to be compressed, includes:
performing color classification on the image to be compressed to generate a basic color table;
carrying out layer 1 division on the image to be compressed according to the preset region division width to obtain a layer 1 compressed region to be selected;
for each layer 1 to-be-selected compression area, generating a color mapping table corresponding to each layer 1 to-be-selected compression area according to the color of each pixel point in each layer 1 to-be-selected compression area and referring to the basic color table;
according to the preset level proportion, taking a corresponding number of i-th layer to-be-selected compression areas as sub-areas, and carrying out non-repeated combination to generate a corresponding father area so as to obtain i+1-th layer to-be-selected compression areas; i is an integer greater than or equal to 1 and less than M;
and determining a color mapping table corresponding to each i+1-th layer to-be-selected compression region according to the color mapping table of the sub-region corresponding to the i+1-th layer to-be-selected compression region for each i+1-th layer to-be-selected compression region.
4. The method of claim 2, wherein determining N regions to be compressed and corresponding target coding modes from the M layer regions to be compressed according to the amount of coded data in each candidate coding mode corresponding to each region to be compressed, comprises:
for each layer 1 to-be-selected compression area, determining a corresponding target coding mode by comparing the corresponding coding data quantity of each candidate coding mode;
and for each i+1th layer of the to-be-compressed areas, determining N to-be-compressed areas and corresponding target coding modes by comparing the corresponding coding data quantity of the i+1th layer of the to-be-compressed areas under each candidate coding mode and the sum of the coding data quantity of the target coding modes of the sub-areas corresponding to the i+1th layer of the to-be-compressed areas.
5. The method according to claim 4, wherein the determining N areas to be compressed and the corresponding target coding modes by comparing, for each i+1th layer to be compressed area, the sum of the corresponding coded data amounts of the i+1th layer to be compressed area in each candidate coding mode and the coded data amounts of the target coding modes of the sub-areas corresponding to the i+1th layer to be compressed area includes:
For each i+1 layer of to-be-selected compression area, if the coding data amount corresponding to each candidate coding mode of the i+1 layer of to-be-selected compression area is larger than the sum of the coding data amounts of the target coding modes of the sub-areas corresponding to the i+1 layer of to-be-selected compression area, determining the sub-area corresponding to the i+1 layer of to-be-selected compression area as the to-be-compressed area, and determining the target coding mode corresponding to the sub-area corresponding to the i+1 layer of to-be-selected compression area as the target coding mode corresponding to the to-be-compressed area;
otherwise, determining the i+1th layer to-be-compressed area as a to-be-compressed area, and determining a candidate coding mode with the smallest coding data amount corresponding to the i+1th layer to-be-compressed area under each candidate coding mode as a target coding mode corresponding to the to-be-compressed area.
6. The method as recited in claim 1, further comprising:
judging whether the size of the original image meets the cutting condition or not;
if not, storing the size of the original image, and complementing the original image to the size corresponding to the cutting condition;
determining the complemented original image as an image to be compressed, and dividing M layers of areas of the image to be compressed according to the coding data quantity;
If yes, the original image is determined to be the image to be compressed, and M layers of area division is carried out on the image to be compressed according to the coding data quantity.
7. The method as recited in claim 6, further comprising:
when receiving a decompression request of the image to be compressed, decompressing a compressed image corresponding to the image to be compressed;
and removing the complement pixel points of the image to be compressed according to the size of the original image to obtain the original image.
8. The method as recited in claim 1, further comprising:
when receiving an encoding instruction, extracting images from the animation resources to be compressed, determining a plurality of frames of images to be compressed, and dividing M layers of areas of the frames of images to be compressed respectively to obtain a plurality of corresponding compressed images;
and when a decoding instruction is received, decompressing the compressed images, and recovering the animation resources to be compressed.
9. An image split encoding apparatus, comprising:
the target coding mode determining module is used for dividing M layers of areas of the image to be compressed according to the coding data quantity to obtain N areas to be compressed and corresponding target coding modes; the target coding mode is one of candidate coding modes; the coding data volume corresponding to each region to be compressed coded in the corresponding target coding mode is smaller than the coding data volume corresponding to the region to be compressed coded in other candidate coding modes; the width of the smallest area to be compressed is larger than or equal to the dividing width of the preset area; each to-be-compressed area in other layers except the layer where the smallest to-be-compressed area is located is coded by the corresponding target coding mode to obtain a corresponding coded data volume which is smaller than the sum of coded data volumes corresponding to all sub-areas of the to-be-compressed area coded by any candidate coding mode;
The corresponding coding module is used for coding each region to be compressed in a corresponding target coding mode so as to perform corresponding compression to obtain a corresponding compressed image;
the candidate coding modes comprise an independent index mode, an inheritance index mode, a mixed index mode and a bare data coding mode; m is an integer greater than or equal to 1, and N is an integer greater than 1.
10. An electronic device, comprising: a memory and a processor;
the memory is used for storing program instructions;
the processor is configured to invoke and execute program instructions in the memory to perform the image splitting encoding method of any of claims 1-7.
CN202310909627.8A 2023-07-21 2023-07-21 Image splitting coding method and device and electronic equipment Pending CN116996687A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310909627.8A CN116996687A (en) 2023-07-21 2023-07-21 Image splitting coding method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310909627.8A CN116996687A (en) 2023-07-21 2023-07-21 Image splitting coding method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN116996687A true CN116996687A (en) 2023-11-03

Family

ID=88527745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310909627.8A Pending CN116996687A (en) 2023-07-21 2023-07-21 Image splitting coding method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN116996687A (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101203886A (en) * 2005-03-04 2008-06-18 Arm挪威股份有限公司 Method and equipment for encoding data
CN104853211A (en) * 2014-02-16 2015-08-19 上海天荷电子信息有限公司 Image compression method and apparatus employing various forms of reference pixel storage spaces
CN105900422A (en) * 2014-06-12 2016-08-24 富士通株式会社 Three-dimensional palette based image coding method, device and image processing apparatus
WO2018066990A1 (en) * 2016-10-04 2018-04-12 김기백 Image data encoding/decoding method and apparatus
CN108259808A (en) * 2018-01-31 2018-07-06 维沃移动通信有限公司 A kind of video frame compression method and mobile terminal
US20180288426A1 (en) * 2017-03-31 2018-10-04 Ati Technologies Ulc Method and apparatus for image compression that employs multiple index color history buffers
CN109819254A (en) * 2019-01-31 2019-05-28 深圳市战音科技有限公司 A kind of image compression transmission method damaged and system
CN111669597A (en) * 2018-03-06 2020-09-15 联发科技股份有限公司 Palette decoding apparatus and method
US20210056731A1 (en) * 2019-08-23 2021-02-25 Imagination Technologies Limited Methods and decompression units for decompressing a compressed block of image data
US20220358685A1 (en) * 2019-06-24 2022-11-10 Nippon Telegraph And Telephone Corporation Image encoding method and image decoding method
CN115623205A (en) * 2021-07-15 2023-01-17 北京金山云网络技术有限公司 Encoding processing method and device, electronic equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101203886A (en) * 2005-03-04 2008-06-18 Arm挪威股份有限公司 Method and equipment for encoding data
CN104853211A (en) * 2014-02-16 2015-08-19 上海天荷电子信息有限公司 Image compression method and apparatus employing various forms of reference pixel storage spaces
CN105900422A (en) * 2014-06-12 2016-08-24 富士通株式会社 Three-dimensional palette based image coding method, device and image processing apparatus
WO2018066990A1 (en) * 2016-10-04 2018-04-12 김기백 Image data encoding/decoding method and apparatus
US20180288426A1 (en) * 2017-03-31 2018-10-04 Ati Technologies Ulc Method and apparatus for image compression that employs multiple index color history buffers
CN108259808A (en) * 2018-01-31 2018-07-06 维沃移动通信有限公司 A kind of video frame compression method and mobile terminal
CN111669597A (en) * 2018-03-06 2020-09-15 联发科技股份有限公司 Palette decoding apparatus and method
CN109819254A (en) * 2019-01-31 2019-05-28 深圳市战音科技有限公司 A kind of image compression transmission method damaged and system
US20220358685A1 (en) * 2019-06-24 2022-11-10 Nippon Telegraph And Telephone Corporation Image encoding method and image decoding method
US20210056731A1 (en) * 2019-08-23 2021-02-25 Imagination Technologies Limited Methods and decompression units for decompressing a compressed block of image data
CN115623205A (en) * 2021-07-15 2023-01-17 北京金山云网络技术有限公司 Encoding processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US8265407B2 (en) Method for coding and decoding 3D data implemented as a mesh model
US11257252B2 (en) Image coding apparatus, probability model generating apparatus and image compression system
US8502709B2 (en) Decoding variable length codes in media applications
CN114020756B (en) Remote sensing image real-time map service publishing method and device
EP3849188A1 (en) Point cloud coding method and encoder
US20170171547A1 (en) Method for controlling data rate of motion video and electronic apparatus
CN110198473B (en) Video processing method and device, electronic equipment and computer readable storage medium
JP4693072B2 (en) Decoding variable-length codes in JPEG applications
CN116996687A (en) Image splitting coding method and device and electronic equipment
CN112332854A (en) Hardware implementation method and device of Huffman coding and storage medium
US20220199202A1 (en) Method and apparatus for compressing fastq data through character frequency-based sequence reordering
CN113505253B (en) Block chain based picture uploading method and device, server and storage medium
CN115250352A (en) Partitioning ASTC textures into sub-image sets
US9756342B2 (en) Method for context based encoding of a histogram map of an image
CN113821689A (en) Pedestrian retrieval method and device based on video sequence and electronic equipment
US20140301655A1 (en) Image decoding methods and image decoding devices
US8331693B2 (en) Information encoding apparatus and method, information retrieval apparatus and method, information retrieval system and method, and program
US8244071B2 (en) Non-dyadic spatial scalable wavelet transform
KR100718638B1 (en) Method for preprocessing color image for lossless gui image compression and mobile terminals therefor
CN111309988A (en) Character string retrieval method and device based on coding and electronic equipment
CN111919445A (en) Image compression and decompression using triangulation
CN117939127A (en) Image processing method and related equipment thereof
CN104090898A (en) Method and device for matching local music and music in database
US20240005562A1 (en) Point cloud encoding method and apparatus, electronic device, medium and program product
CN117793466A (en) Template loading method and device and computing equipment

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