CN113747167A - Image compression coding method and device and electronic equipment - Google Patents

Image compression coding method and device and electronic equipment Download PDF

Info

Publication number
CN113747167A
CN113747167A CN202010463212.9A CN202010463212A CN113747167A CN 113747167 A CN113747167 A CN 113747167A CN 202010463212 A CN202010463212 A CN 202010463212A CN 113747167 A CN113747167 A CN 113747167A
Authority
CN
China
Prior art keywords
image
coding
decoding
original image
data
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
CN202010463212.9A
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 Lumi United Technology Co Ltd
Lumi United Technology Co Ltd
Original Assignee
Lumi United 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 Lumi United Technology Co Ltd filed Critical Lumi United Technology Co Ltd
Priority to CN202010463212.9A priority Critical patent/CN113747167A/en
Publication of CN113747167A publication Critical patent/CN113747167A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/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/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/157Assigned coding mode, i.e. the coding mode being predefined or preselected to be further used for selection of another element or parameter

Abstract

The embodiment of the application discloses an image compression coding method, an image compression coding device, electronic equipment and a storage medium. The method comprises the following steps: acquiring an original image to be coded; acquiring the number of pixels of each color in the original image; distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels; and coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image. By the method, the code words with different lengths are distributed to each pixel according to the number of the pixels with different colors in the original image for coding, so that the flexibility of compressing and coding the image can be effectively improved.

Description

Image compression coding method and device and electronic equipment
Technical Field
The present application belongs to the field of image processing technologies, and in particular, to an image compression encoding method, an image compression encoding device, an electronic device, and a storage medium.
Background
Images are the most important carriers for carrying information in multimedia. However, in the digital image without compression processing, the data amount is very large. In order to save storage space and improve transmission efficiency of information, a large amount of actual data must be compressed. When the related image compression coding method is used for coding an image, the flexibility of coding still needs to be improved.
Disclosure of Invention
In view of the above problems, the present application provides an image compression encoding method, apparatus, electronic device, and storage medium to achieve an improvement of the above problems.
In a first aspect, an embodiment of the present application provides an image compression encoding method, where the method includes: acquiring an original image to be coded; acquiring the number of pixels of each color in the original image; distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels; and coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image.
In a second aspect, an embodiment of the present application provides an image decoding method, where the method includes: acquiring image coded data to be decoded; acquiring the pixel number of each color in the image coding data; determining code words corresponding to the pixels of various colors in the image coding data based on the number of the pixels; and decoding the image coded data according to a preset decoding mode based on the corresponding code word to obtain a target image.
In a third aspect, an embodiment of the present application provides an image compression encoding apparatus, including: the image acquisition unit is used for acquiring an original image to be coded; the pixel number acquisition unit is used for acquiring the pixel number of each color in the original image; the code word distribution unit is used for distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels; and the coding unit is used for coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image.
In a fourth aspect, an embodiment of the present application provides an image decoding apparatus, including: an image acquisition unit for acquiring image encoded data to be decoded; a pixel number acquiring unit for acquiring the number of pixels of each color in the image encoding data; a code word determining unit, configured to determine, based on the number of pixels, a code word corresponding to a pixel of each color in the image encoding data; and the decoding unit is used for decoding the image coded data according to a preset decoding mode based on the corresponding code word to obtain a target image.
In a fifth aspect, an embodiment of the present application provides an electronic device, including one or more processors and a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to perform the methods described above.
In a sixth aspect, the present application provides a computer-readable storage medium, in which a program code is stored, where the program code executes the method described above.
The embodiment of the application provides an image compression coding method and device, electronic equipment and a storage medium. Acquiring an original image to be coded; acquiring the number of pixels of each color in the original image; distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels; and coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image. By the method, the code words with different lengths are distributed to each pixel according to the number of the pixels with different colors in the original image for coding, so that the flexibility of compressing and coding the image can be effectively improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart illustrating an image compression encoding method according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for image compression encoding according to another embodiment of the present application;
FIG. 3 is a schematic encoding diagram illustrating an image compression encoding method according to another embodiment of the present application;
FIG. 4 is a flow chart of a method for image compression encoding according to yet another embodiment of the present application;
FIG. 5 is a schematic encoding diagram illustrating an image compression encoding method according to yet another embodiment of the present application;
FIG. 6 is a flow chart illustrating an image decoding method according to another embodiment of the present application;
fig. 7 is a schematic structural diagram of an image compression encoding apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an image decoding apparatus according to an embodiment of the present application;
fig. 9 shows a block diagram of an electronic device for executing an image compression encoding method or an image decoding method according to an embodiment of the present application in real time.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The use of electronic price tags has become a trend, and in some areas with less sensitivity to price, such as high-end convenience stores, import commodity supermarkets, and the like, more and more stores use the electronic price tags. The electronic price tags are electronic tags for displaying price information of word supermarkets, convenience stores, pharmacies and the like, are mainly placed on the goods shelves and can replace electronic display devices of traditional paper price tags, each electronic shelf tag is connected with a computer database through a wired or wireless network, and latest commodity prices are displayed through screens on the electronic shelf tags. Sometimes, when a commodity price image is displayed through a screen on an electronic shelf label, the image needs to be compressed, and the image is an extremely important carrier for carrying information in multimedia. However, in the digital image without compression processing, the data amount is very large. In order to save storage space and improve transmission efficiency of information, a large amount of actual data must be compressed.
The inventor finds that, in the process of researching related image compression and encoding methods, when the related image compression and encoding methods encode images, the encoding flexibility still needs to be improved.
Therefore, the inventor proposes a method, an apparatus, an electronic device, and a storage medium for effectively improving flexibility of a compressed and encoded image by acquiring an original image to be encoded, acquiring the number of pixels of each color in the original image, allocating corresponding code words to the pixels of each color in the original image according to the number of pixels, and encoding the original image according to a preset encoding mode based on the corresponding code words to obtain image encoded data of the original image.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 1, an image compression encoding method according to an embodiment of the present application includes:
step S110: an original image to be encoded is acquired.
In one mode, the original image is an image expressed by using three colors of red, black, and white. Each electronic price tag can be connected with a computer database through a wired or wireless network, a large number of images needing to be displayed when the electronic price tags are updated can be stored in the computer database in advance, and the electronic price tags can acquire the images needing to be displayed when the electronic price tags are updated every time from the computer database to obtain the original images to be coded.
Step S120: and acquiring the number of pixels of each color in the original image.
As one mode, the obtained original image to be encoded represented by three colors, red, black and white, is processed, and the number of pixels of the three colors, red, black and white, in the original image is respectively counted.
Step S130: and distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels.
As one way, codewords of different lengths may be assigned to the pixels of each color according to the number of the pixels of the three colors of red, black and white in the original image obtained in the above-described manner. Illustratively, the number of pixels of three colors of red, black and white in the original image is 40, 80 and 60 respectively, so that the pixels of three colors of red, black and white can be respectively allocated with a 3-byte code word, a 1-byte code word and a 2-byte code word, and the length of the allocated code words can be freely set.
Step S140: and coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image.
As a mode, the corresponding code words with different lengths are allocated to the pixels of each color by the above method, and further, the original image may be encoded according to the corresponding code words with different lengths in a preset encoding mode, so as to obtain the image encoded data of the original image. The preset encoding mode may include a first encoding mode and a second encoding mode, which encoding mode is specifically used for encoding the original image, the encoding lengths of the image encoding data encoded by using the two encoding modes may be calculated in advance, and by comparing the encoding lengths of the image encoding data of the two encoding modes, it is determined whether to encode the original image by using the first encoding mode or encode the original image by using the second encoding mode. The coding length of different images coded according to the first coding mode is different from that coded according to the second coding mode, the coding mode of the images is determined according to the coding length of the images, the flexibility of image coding can be improved, the coding mode with the small coding length is selected as the final coding mode, the data amount of image coding can be reduced, in addition, the image coding data with the small image coding data amount is selected for transmission, the image transmission time can be reduced, and the image refreshing frequency can be improved.
According to the image compression coding method provided by the embodiment of the application, the original image to be coded is obtained, the number of pixels of various colors in the original image is obtained, corresponding code words are distributed to the pixels of various colors in the original image according to the number of the pixels, the original image is coded according to a preset coding mode based on the corresponding code words, and image coding data of the original image are obtained.
Referring to fig. 2, an image compression encoding method according to an embodiment of the present application includes:
step S210: an original image to be encoded is acquired.
Step S220: and acquiring the number of pixels of each color in the original image.
Step S230: and allocating a first code word to the pixels of the same type of color with the largest number of pixels in the original image, and allocating a second code word to the pixels of the same type of color with the other number of pixels in the original image, wherein the first code word is shorter than the second code word.
As one way, the representation method of the pixel of each color can be determined according to the counted number of the pixels of the three colors of red, black and white in the original image. Specifically, the shortest first code word may be used to represent the pixel corresponding to the color with the largest number of pixels in the image, and the longest second code word may be used to represent the pixel corresponding to the color with the other number of pixels in the image. Illustratively, as shown in fig. 3, a is represented by a code '0', B is represented by a code '10', and C is represented by a code '11'. A. B, C each represent one of three colors, red, black, and white. Specifically, it may be determined A, B, C which color is represented respectively according to the counted number of pixels of the three colors of red, black and white in the original image, if it is counted that the number of pixels of the red color in the original image is the largest, a represents the red color, and the code of the corresponding red color is '0'. By using the code '0' for the pixel corresponding to the color having the largest number of pixels in the original image, since the code '0' is shortest, when the pixel corresponding to the color having the largest number of pixels in the original image is represented by the code '0', the image coded data can be further compressed.
Step S240: and acquiring the coding length of first image coding data, wherein the first image coding data is obtained by coding each pixel according to a first coding mode.
In one aspect, the first encoding scheme is such that each line of pixels is treated as one coding unit in the first encoding scheme. The encoding length of the image encoded data obtained by encoding each pixel in accordance with the first encoding method is calculated. Specifically, the coding length of the coded data of each line may be calculated as Num ═ 3+ n (a) +2 × n (b) +2 × n (c)) bit, where the above expression indicates that the image coded data of each line has a line start code of 3bit, and n (a) '0', n (b) '10', and n (c) '11'. Then, the image coding length of the whole image is calculated as Data _ Num ═ H (1.5-0.5 × (a) + W) × 2bit ═ H × (W) × 2 bit-H (n) (a) -3) bit, where H denotes the image height and W denotes the image width, and W ═ n (a) + n (b) + n (c)), where n (a) denotes the pixel corresponding to the color class with the largest number of pixels in each row, and thus, the number of n (a) is equal to or greater than one third of the image width and is less than or equal to the image width, that is, W/3 ═ n (a) < ═ W. The range in which the code length of the image data calculated by the above method is reduced from the code length of the image coded data coded by the 2-ary coding method is [ H (W/3-3), H (W-3) ]. Furthermore, according to the rule of designing the electronic price tag image, n (A) of a plurality of lines in the electronic price tag image is close to W, so that the image compression coding method can obviously and effectively reduce the data volume.
Step S250: and acquiring the coding length of second image coding data, wherein the second image coding data is obtained by coding each pixel according to a second coding mode.
In one aspect, the second encoding scheme is such that each column of pixels is treated as one encoding unit in the second encoding scheme. The encoding length of the image encoded data obtained by encoding each pixel in the second encoding mode is also calculated by the above-described method.
Step S260: and if the coding length of the first image coding data is smaller than that of the second image coding data, coding each pixel in the original image according to the first coding mode based on the corresponding code word to obtain the image coding data of the original image.
As one mode, the step of encoding each pixel in the original image according to the first encoding mode based on the corresponding codeword to obtain the image encoded data of the original image includes: acquiring a sequencing result of the number of pixels of each type of color in each coding unit of the first coding mode; determining the initial code corresponding to each coding unit according to the sequencing result; and based on the initial coding, coding each pixel of each coding unit in the original image according to the first coding mode to obtain image coding data of the original image.
Specifically, the pixel numbers of red, black and white in each line of the original image are obtained, the pixel numbers of red, black and white in each line are sequenced, the line start code of each line of the original image is determined according to the sequencing result, and finally the original image is coded through the line start code and the independent code of each pixel in each line of the pixels to obtain the image coded data of the original image. The pixel numbers of the three colors of red, black and white can be sorted by the number of the pixel numbers of each row by 3! Each of the 6 species is as follows:
color pixel number ordering Line start coding
n (Red)>n (Black)>n (white) 000
n (Red)>n (white)>n (Black) 001
n (Black)>n (Red)>n (white) 010
n (Black)>n (white)>n (Red) 011
n (white)>n (Red)>n (Black) 100
n (white)>n (Black)>n (Red) 101
As can be seen from the above table, if the ordering of the numbers of pixels of the three colors of red, black, and white in a certain line of the original image is n (red) > n (black) > n (white), the line start of the line is determined to be '000', and if the ordering of the numbers of pixels of the three colors of red, black, and white in a certain line of the original image is n (white) > n (red) > n (black), the line start of the line is determined to be '100'.
Optionally, the line start coding manner in the table may be stored in an electronic price tag, after the electronic price tag obtains an original image to be coded from a database, the original image is processed, the numbers of pixels of three colors of red, black and white in each line of the original image are respectively counted, the counted numbers of pixels of three colors of red, black and white are sorted, a corresponding line start code is obtained according to a sorting result of the numbers of the color pixels, based on a current line start code, the pixels corresponding to three colors of red, black and white in each line are respectively allocated with codewords of different lengths, and each pixel of each line of the original image is coded to obtain image coded data of the original image.
Further, when counting the number of pixels of the red, black, and white colors in each line of the original image, the case that the number of pixels is equal may occur, in which case, the number of pixels of the red, black, and white colors in each line of the original image may be sorted according to the order of first prioritizing the red color, then prioritizing the black color, and finally prioritizing the white color, as shown below:
Figure BDA0002511644640000081
as shown in the above table, "color pixel number sorting (actual)" in the above table is a result of sorting the number of pixels of three colors of red, white, and black when counting, and "color pixel number sorting (when encoding)" is a result of sorting the number of pixels of three colors of red, black, and white when determining line start encoding. After the line start code is determined in the above manner, the original image is coded through the line start code and the individual code of each pixel in each line of pixels, so as to obtain the image coded data of the original image. For example, if the number of pixels of a certain line of three colors of red, black, and white in the original image is n (black) > n (white) ═ n (red), when determining the start code of the line, the start code of the line is determined to be '010' in the order of n (black) > n (red) > n (white).
The image compression coding method provided by the embodiment of the application obtains an original image to be coded, obtains the number of pixels of various colors in the original image, allocates a first code word to the pixel of the same color with the largest number of pixels in the original image, allocates a second code word to the pixel of the same color with the other number of pixels in the original image, obtains the coding length of first image coding data, obtains the coding length of second image coding data, obtains the coding length of the first image coding data which is smaller than the coding length of the second image coding data, and codes each pixel in the original image according to the first coding mode based on the corresponding code word to obtain the image coding data of the original image. By the method, short code words are distributed to the pixels with large number of various color pixels in each row, long code words are distributed to the pixels with small number of various color pixels in each row, and the original image is coded according to 3 initial codes and the independent code of each row of pixels in each row, so that the image can be effectively compressed, and the data volume of the image is reduced, so that the image transmission time can be reduced and the image refreshing frequency can be improved when the image is transmitted.
Referring to fig. 4, an image compression encoding method according to an embodiment of the present application includes:
step S310: an original image to be encoded is acquired.
Step S320: and acquiring the number of pixels of each color in the original image.
Step S330: and allocating a first code word to the pixels of the same type of color with the largest number of pixels in the original image, and allocating a second code word to the pixels of the same type of color with the other number of pixels in the original image, wherein the first code word is shorter than the second code word.
Step S340: and acquiring the coding length of first image coding data, wherein the first image coding data is obtained by coding each pixel according to a first coding mode.
Step S350: and acquiring the coding length of second image coding data, wherein the second image coding data is obtained by coding each pixel according to a second coding mode.
Step S360: and if the coding length of the first image coding data is greater than that of the second image coding data, coding each pixel in the original image according to the second coding mode based on the corresponding code word to obtain the image coding data of the original image.
As one mode, the step of encoding each pixel in the original image according to the second encoding method based on the corresponding codeword to obtain the image encoded data of the original image includes: acquiring a sorting result of the number of pixels of each type of color in each coding unit of the second coding mode; determining the initial code corresponding to each coding unit according to the sequencing result; and based on the initial coding, coding each pixel of each coding unit in the original image according to the second coding mode to obtain image coding data of the original image.
Specifically, the pixel numbers of red, black and white in each column of the original image are obtained, the pixel numbers of red, black and white in each column are sequenced, the column start code of each column of the original image is determined according to the sequencing result, and finally the original image is coded through the column start code and the independent code of each pixel in each column of the pixels to obtain the image coded data of the original image. The encoding mode of the column start encoding is the same as that of the row start encoding, and the encoding mode of the column start encoding is determined to be any one of '000', '001', '010', '011', '100' and '101' according to the sequencing result of the pixel numbers of each column of each type of color.
Further, it is possible to select whether to encode the original image in the first encoding method or the second encoding method using 1-bit data at the beginning of the image encoding data of the original image. Specifically, the first encoding scheme may be represented by '0' and the second encoding scheme may be represented by '1'. For example, the final image encoding data may be as shown in fig. 5, S represents whether encoding is performed in the first encoding mode or the second encoding mode, and if S ═ 0 represents that encoding is performed in the first encoding mode. W1 denotes a row start code or a column start code, depending on S. W1 is followed by H pixel encoding.
The image compression coding method provided by the embodiment of the application obtains an original image to be coded, obtains the number of pixels of various colors in the original image, allocates a first code word to the pixel of the same color with the largest number of pixels in the original image, allocates a second code word to the pixel of the same color with the other number of pixels in the original image, obtains the coding length of first image coding data, obtains the coding length of second image coding data, obtains the coding length of the first image coding data which is greater than the coding length of the second image coding data, and codes each pixel in the original image according to the second coding mode based on the corresponding code word to obtain the image coding data of the original image. By the method, short code words are distributed to the pixels with large number of various color pixels in each row, long code words are distributed to the pixels with small number of various color pixels in each row, each row codes the original image according to 3 initial codes plus the independent code of each row of pixels, the image can be effectively compressed, and the data volume of the image is reduced, so that the image transmission time can be reduced and the image refreshing frequency can be improved when the image is transmitted.
Referring to fig. 6, an image decoding method provided in the embodiment of the present application includes:
step S410: and acquiring image coded data to be decoded.
As one mode, the electronic price tag device acquires the image coded data obtained by the above coding mode, and performs a decoding operation on the image coded data.
Step S420: and acquiring a code word in the image coding data.
As one way, the number of pixels for each type of color may be determined by the number of codes in the image coded data. Specifically, the number of codes '0', the number of codes '10', and the number of codes '11' in the image coded data may be counted, respectively.
Specifically, pixels of three colors, namely red, black and white, are respectively encoded by the encoding '0', the encoding '10' and the encoding '11' in the image encoding data, so that the corresponding image color can be determined by acquiring the code words of the pixel encoding in the image encoding data.
Step S430: and decoding the image coded data according to a preset decoding mode based on the corresponding code word to obtain a target image.
As one mode, the preset decoding mode includes a first decoding mode in which each row of pixels is used as one decoding unit in the first decoding mode and a second decoding mode in which each column of pixels is used as one decoding unit in the second decoding mode.
Further, decoding the image encoding data according to a preset decoding mode based on the corresponding code word to obtain a target image, including: determining a decoding mode of the image coded data; if the decoding mode of the image coded data is the first decoding mode, acquiring the initial code of each decoding unit corresponding to the first decoding mode; determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code; and decoding the image coded data according to the first decoding mode based on the color corresponding to the code word to obtain the target image.
As another mode, the decoding the image encoding data according to a preset decoding mode based on the corresponding codeword to obtain the target image includes: if the decoding mode of the image coded data is the second decoding mode, acquiring the initial code of each decoding unit corresponding to the second decoding mode; determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code; and decoding the image coded data according to the second decoding mode based on the color corresponding to the code word to obtain the target image.
Specifically, whether to perform decoding in the first decoding method or the second decoding method may be determined by whether the header of the image coded data is '1' or '0'. After the decoding mode is determined, determining a sequencing result of the number of pixels of each color in the image coding data through initial coding, and determining a code word corresponding to the pixels of each color according to the sequencing result. For example, as shown in fig. 5, it may be determined that the image coded data is decoded in the first decoding manner by S ═ 0, and it is determined that n (red) > n (white) > n (black) is obtained by W1 ═ 001 as a result of sorting the pixel numbers of the three colors of red, black and white in the image coded data, and thus it may be determined that the color corresponding to the pixel coded as '0' is a red color, the color corresponding to the pixel coded as '10' is a white color, and the color corresponding to the pixel coded as '11' is a black color. The image coded data are decoded in the above mode to obtain a target image, and the target image is displayed, so that the electronic price tag image is updated.
According to the image decoding method provided by the embodiment of the application, the code words in the image coded data are obtained by obtaining the image coded data to be decoded, and the image coded data are decoded according to a preset decoding mode based on the code words to obtain the target image. By the method, the image of the electronic price tag can be updated in time.
Referring to fig. 7, an image compression encoding apparatus 500 according to an embodiment of the present application includes:
an image obtaining unit 510, configured to obtain an original image to be encoded.
A pixel number obtaining unit 520, configured to obtain the number of pixels of each color in the original image.
And a code word allocating unit 530, configured to allocate corresponding code words to the pixels of each color in the original image according to the number of the pixels.
The code word allocating unit 530 is further configured to allocate a first code word to the pixels of the same type of color with the largest number of pixels in the original image, and allocate a second code word to the pixels of the same type of color with the other number of pixels in the original image, where the first code word is shorter than the second code word.
And an encoding unit 540, configured to encode the original image according to a preset encoding manner based on the corresponding codeword, so as to obtain image encoded data of the original image.
The encoding unit 540 is further configured to obtain a coding length of first image encoded data, where the first image encoded data is image encoded data obtained by encoding each pixel according to a first encoding method; acquiring the coding length of second image coding data, wherein the second image coding data are image coding data obtained by coding each pixel according to a second coding mode; if the coding length of the first image coding data is smaller than that of the second image coding data, coding each pixel in the original image according to the first coding mode based on the corresponding code word to obtain the image coding data of the original image; and if the coding length of the first image coding data is greater than that of the second image coding data, coding each pixel in the original image according to the second coding mode based on the corresponding code word to obtain the image coding data of the original image.
The encoding unit 540 is further configured to obtain a result of sorting the number of pixels of each type of color in each encoding unit of the first encoding manner; determining the initial code corresponding to each coding unit according to the sequencing result; and based on the initial coding, coding each pixel of each coding unit in the original image according to the first coding mode to obtain image coding data of the original image.
The encoding unit 540 is further configured to obtain a result of sorting the number of pixels of each type of color in each encoding unit of the second encoding manner; determining the initial code corresponding to each coding unit according to the sequencing result; and based on the initial coding, coding each pixel of each coding unit in the original image according to the second coding mode to obtain image coding data of the original image.
Referring to fig. 8, an image decoding apparatus 600 according to an embodiment of the present application includes:
an image obtaining unit 610 is used for obtaining the image coding data to be decoded.
A codeword obtaining unit 620, configured to obtain a codeword in the image encoded data.
A decoding unit 630, configured to decode the image encoded data according to a preset decoding manner based on the codeword, so as to obtain a target image.
The decoding unit 630 is further configured to determine a decoding manner of the encoded image data; if the decoding mode of the image coded data is the first decoding mode, acquiring the initial code of each decoding unit corresponding to the first decoding mode; determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code; and decoding the image coded data according to the first decoding mode based on the color corresponding to the code word to obtain the target image. If the decoding mode of the image coded data is the second decoding mode, acquiring the initial code of each decoding unit corresponding to the second decoding mode; determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code; and decoding the image coded data according to the second decoding mode based on the color corresponding to the code word to obtain the target image.
It should be noted that the device embodiment and the method embodiment in the present application correspond to each other, and specific principles in the device embodiment may refer to the contents in the method embodiment, which is not described herein again.
An embodiment of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the image compression encoding method or the image decoding method provided in the foregoing method embodiment.
The memory may be used to store software programs and modules, and the processor may execute various functional applications and data processing by operating the software programs and modules stored in the memory. The memory can mainly comprise a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs needed by functions and the like; the storage data area may store data created according to use of the apparatus, and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory may also include a memory controller to provide the processor access to the memory.
Fig. 9 is a block diagram of a hardware structure of an electronic device according to an embodiment of the present invention, wherein the electronic device is an image compression encoding method or an image decoding method. As shown in fig. 9, the electronic device 1100 may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 1110 (the processors 1110 may include but are not limited to Processing devices such as a microprocessor MCU or a programmable logic device FPGA), a memory 1130 for storing data, and one or more storage media 1120 (e.g., one or more mass storage devices) for storing applications 1123 or data 1122. The memory 1130 and the storage medium 1120 may be, among other things, transient storage or persistent storage. The program stored in the storage medium 1120 may include one or more modules, each of which may include a series of instructions operating on an electronic device. Still further, the processor 1110 may be configured to communicate with the storage medium 1120, and execute a series of instruction operations in the storage medium 1120 on the server 1100. The electronic device 1100 may also include one or more power supplies 1160, one or more wired or wireless network interfaces 1150, one or more input-output interfaces 1140, and/or one or more operating systems 1121, such as Windows Server, MacOS6TM, Uni6TM, Linu6, FreeBSDTM, etc.
The input output interface 1140 may be used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the electronic device 1100. In one example, i/o Interface 1140 includes a Network adapter (NIC) that may be coupled to other Network devices via a base station to communicate with the internet. In one example, the input/output interface 1140 can be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
It will be understood by those skilled in the art that the structure shown in fig. 9 is merely an illustration and is not intended to limit the structure of the electronic device. For example, electronic device 1100 may also include more or fewer components than shown in FIG. 9, or have a different configuration than shown in FIG. 9.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above-mentioned embodiment of the image compression encoding method, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The embodiment of the application provides an image compression coding method, an image compression coding device, electronic equipment and a storage medium, wherein an original image to be coded is obtained, the number of pixels of various colors in the original image is obtained, corresponding code words are distributed to the pixels of various colors in the original image according to the number of the pixels, the original image is coded according to a preset coding mode based on the corresponding code words, image coding data of the original image are obtained, and in the mode, the code words with different lengths are distributed to each pixel according to the number of the pixels of different colors in the original image for coding, so that the flexibility of the compressed coded image can be effectively improved.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (14)

1. A method of image compression encoding, the method comprising:
acquiring an original image to be coded;
acquiring the number of pixels of each color in the original image;
distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels;
and coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image.
2. The method according to claim 1, wherein said assigning corresponding codewords to the pixels of each color type in the original image according to the number of pixels comprises:
and allocating a first code word to the pixels of the same type of color with the largest number of pixels in the original image, and allocating a second code word to the pixels of the same type of color with the other number of pixels in the original image, wherein the first code word is shorter than the second code word.
3. The method according to claim 2, wherein the preset encoding mode includes a first encoding mode and a second encoding mode, and the encoding the original image according to the preset encoding mode based on the corresponding codeword to obtain the image encoding data of the original image includes:
acquiring the coding length of first image coding data, wherein the first image coding data are image coding data obtained by coding each pixel according to a first coding mode;
acquiring the coding length of second image coding data, wherein the second image coding data are image coding data obtained by coding each pixel according to a second coding mode;
if the coding length of the first image coding data is smaller than that of the second image coding data, coding each pixel in the original image according to the first coding mode based on the corresponding code word to obtain the image coding data of the original image;
and if the coding length of the first image coding data is greater than that of the second image coding data, coding each pixel in the original image according to the second coding mode based on the corresponding code word to obtain the image coding data of the original image.
4. The method according to claim 3, wherein said encoding each pixel in the original image according to the first encoding method based on the corresponding codeword to obtain the image encoding data of the original image comprises:
acquiring a sequencing result of the number of pixels of each type of color in each coding unit of the first coding mode;
determining the initial code corresponding to each coding unit according to the sequencing result;
and based on the initial coding, coding each pixel of each coding unit in the original image according to the first coding mode to obtain image coding data of the original image.
5. The method according to claim 3, wherein said encoding each pixel in the original image according to the second encoding method based on the corresponding codeword to obtain the image encoding data of the original image comprises:
acquiring a sorting result of the number of pixels of each type of color in each coding unit of the second coding mode;
determining the initial code corresponding to each coding unit according to the sequencing result;
and based on the initial coding, coding each pixel of each coding unit in the original image according to the second coding mode to obtain image coding data of the original image.
6. The method according to any one of claims 3 to 5, wherein the first encoding scheme is such that each row of pixels is treated as one coding unit in the first encoding scheme, and the second encoding scheme is such that each column of pixels is treated as one coding unit in the second encoding scheme.
7. An image decoding method, characterized in that the method comprises:
acquiring image coded data to be decoded;
acquiring a code word in the image coding data;
and decoding the image coded data according to a preset decoding mode based on the code word to obtain a target image.
8. The method according to claim 7, wherein the preset decoding mode includes a first decoding mode and a second decoding mode, and the decoding the image encoding data according to the preset decoding mode based on the code word to obtain the target image includes:
determining a decoding mode of the image coded data;
if the decoding mode of the image coded data is the first decoding mode, acquiring the initial code of each decoding unit corresponding to the first decoding mode;
determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code;
and decoding the image coded data according to the first decoding mode based on the color corresponding to the code word to obtain the target image.
9. The method according to claim 8, wherein the decoding the encoded image data according to a preset decoding manner based on the codeword to obtain a target image further comprises:
if the decoding mode of the image coded data is the second decoding mode, acquiring the initial code of each decoding unit corresponding to the second decoding mode;
determining the color corresponding to the code word of each pixel in each decoding unit according to the initial code;
and decoding the image coded data according to the second decoding mode based on the color corresponding to the code word to obtain the target image.
10. The method according to any one of claims 8 to 9, wherein the first decoding scheme is such that each row of pixels is treated as one decoding unit in the first decoding scheme, and the second decoding scheme is such that each column of pixels is treated as one decoding unit in the second decoding scheme.
11. An image compression encoding apparatus, characterized in that the apparatus comprises:
the image acquisition unit is used for acquiring an original image to be coded;
the pixel number acquisition unit is used for acquiring the pixel number of each color in the original image;
the code word distribution unit is used for distributing corresponding code words to the pixels of various colors in the original image according to the number of the pixels;
and the coding unit is used for coding the original image according to a preset coding mode based on the corresponding code word to obtain the image coding data of the original image.
12. An image decoding apparatus, characterized in that the apparatus comprises:
an image acquisition unit for acquiring image encoded data to be decoded;
a code word acquiring unit, configured to acquire a code word in the image encoded data;
and the decoding unit is used for decoding the image coded data according to a preset decoding mode based on the corresponding code word to obtain a target image.
13. An electronic device comprising one or more processors and memory; one or more programs stored in the memory and configured to be executed by the one or more processors to perform the method of any of claims 1-6 or the method of any of claims 7-10.
14. A computer-readable storage medium, having a program code stored therein, wherein the program code when executed by a processor performs the method of any of claims 1-6 or the method of any of claims 7-10.
CN202010463212.9A 2020-05-27 2020-05-27 Image compression coding method and device and electronic equipment Pending CN113747167A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010463212.9A CN113747167A (en) 2020-05-27 2020-05-27 Image compression coding method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010463212.9A CN113747167A (en) 2020-05-27 2020-05-27 Image compression coding method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN113747167A true CN113747167A (en) 2021-12-03

Family

ID=78723892

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010463212.9A Pending CN113747167A (en) 2020-05-27 2020-05-27 Image compression coding method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113747167A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116389668A (en) * 2023-06-06 2023-07-04 佳木斯大学 Coding method for digital video image signal

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5067023A (en) * 1989-06-29 1991-11-19 Samsung Electronics Co., Ltd. Image data coding apparatus
US6091850A (en) * 1997-04-30 2000-07-18 Fujitsu Microelectronics, Inc. Method of compressing and decompressing graphic images
US20020081038A1 (en) * 2000-12-27 2002-06-27 Koninklijke Philips Electronics N.V. Graphic image coding
US6683978B1 (en) * 1997-10-02 2004-01-27 S3 Graphics Co., Ltd. Fixed-rate block-based image compression with inferred pixel values
CN1625893A (en) * 2002-02-01 2005-06-08 皇家飞利浦电子股份有限公司 Compression of palettized color images with variable length color codes
JP2006246061A (en) * 2005-03-03 2006-09-14 Canon Inc Image coding apparatus, image decoding apparatus, control method of them, computer program, and computer-readable storage medium
CN101068350A (en) * 2007-06-04 2007-11-07 北京派瑞根科技开发有限公司 Image coding and decoding processing method based on picture element st atistical characteristic and visual characteristic
JP2008205636A (en) * 2007-02-16 2008-09-04 Canon Inc Image processing device, image processing method of image processing device, and program
CN105191304A (en) * 2013-03-08 2015-12-23 联发科技股份有限公司 Image encoding method and apparatus for performing bit-plane scanning coding upon pixel data and related image decoding method and apparatus
CN106256126A (en) * 2014-05-02 2016-12-21 三星电子株式会社 Method and apparatus for compressing image data adaptively
US20170214928A1 (en) * 2016-01-21 2017-07-27 Samsung Display Co., Ltd. Classification preserving image transform compression
CN110855990A (en) * 2019-11-29 2020-02-28 京东方科技集团股份有限公司 Image encoding method, image decoding method, computer device, and image processing system

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5067023A (en) * 1989-06-29 1991-11-19 Samsung Electronics Co., Ltd. Image data coding apparatus
US6091850A (en) * 1997-04-30 2000-07-18 Fujitsu Microelectronics, Inc. Method of compressing and decompressing graphic images
US6683978B1 (en) * 1997-10-02 2004-01-27 S3 Graphics Co., Ltd. Fixed-rate block-based image compression with inferred pixel values
US20020081038A1 (en) * 2000-12-27 2002-06-27 Koninklijke Philips Electronics N.V. Graphic image coding
CN1625893A (en) * 2002-02-01 2005-06-08 皇家飞利浦电子股份有限公司 Compression of palettized color images with variable length color codes
JP2006246061A (en) * 2005-03-03 2006-09-14 Canon Inc Image coding apparatus, image decoding apparatus, control method of them, computer program, and computer-readable storage medium
JP2008205636A (en) * 2007-02-16 2008-09-04 Canon Inc Image processing device, image processing method of image processing device, and program
CN101068350A (en) * 2007-06-04 2007-11-07 北京派瑞根科技开发有限公司 Image coding and decoding processing method based on picture element st atistical characteristic and visual characteristic
CN105191304A (en) * 2013-03-08 2015-12-23 联发科技股份有限公司 Image encoding method and apparatus for performing bit-plane scanning coding upon pixel data and related image decoding method and apparatus
CN106256126A (en) * 2014-05-02 2016-12-21 三星电子株式会社 Method and apparatus for compressing image data adaptively
US20170214928A1 (en) * 2016-01-21 2017-07-27 Samsung Display Co., Ltd. Classification preserving image transform compression
CN110855990A (en) * 2019-11-29 2020-02-28 京东方科技集团股份有限公司 Image encoding method, image decoding method, computer device, and image processing system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116389668A (en) * 2023-06-06 2023-07-04 佳木斯大学 Coding method for digital video image signal
CN116389668B (en) * 2023-06-06 2023-08-15 佳木斯大学 Coding method for digital video image signal

Similar Documents

Publication Publication Date Title
CN108900843B (en) Monochrome image compression method, apparatus, medium, and electronic device
CN1139044C (en) A memory based VLSI architecture for image compression
US20030093817A1 (en) System for moving image data using wireless communication and the method of the same
CN113747167A (en) Image compression coding method and device and electronic equipment
CN107040791B (en) Self-adaptive binary image compression method suitable for electronic display label
CN104869327A (en) High-definition display screen image file rapid display method and system
CN103248951A (en) System and method for adding scrolling information into video
CN113852379A (en) Data encoding method, system, equipment and computer readable storage medium
CN114064308A (en) Multi-data sending and receiving method, device and equipment based on column type data scanning
CN113542225A (en) Data compression method and device, terminal equipment and storage medium
CN111337133B (en) Infrared data generation method and device and infrared data analysis method and device
CN109379591B (en) Image transcoding method, electronic device and computer readable storage medium
CN111708574A (en) Instruction stream compression and decompression method and device
CN116796785A (en) Electronic price tag display method and device, electronic equipment and readable storage medium
CN106874979B (en) Bar code processing, displaying and reading method and device
CN113592717A (en) Video image character superposition method and device, storage medium and electronic device
US11335281B2 (en) Image processing method and image processing system
CN113099270A (en) File storage method, decoding method, device, storage medium and electronic device
CN112016270A (en) Chinese-sensible code logistics information coding method, device and equipment
CN114125456A (en) Data processing method and system and electronic equipment
CN109451313A (en) A kind of method for video coding, system and electronic equipment and storage medium
CN116263792B (en) Method and system for crawling complex internet data
US20050111556A1 (en) System and method for real-time decompression and display of Huffman compressed video data
CN115661274A (en) Image processing method, image processing device, electronic equipment and storage medium
CN115309349B (en) Deep learning sparse data storage method, computer device and storage medium

Legal Events

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