CN113223100A - Picture compression and decompression processing method - Google Patents

Picture compression and decompression processing method Download PDF

Info

Publication number
CN113223100A
CN113223100A CN202110495432.4A CN202110495432A CN113223100A CN 113223100 A CN113223100 A CN 113223100A CN 202110495432 A CN202110495432 A CN 202110495432A CN 113223100 A CN113223100 A CN 113223100A
Authority
CN
China
Prior art keywords
picture
color
pixels
compression
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
CN202110495432.4A
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 Zhongke Shiwei Technology Co ltd
Original Assignee
Shenzhen Zhongke Shiwei 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 Zhongke Shiwei Technology Co ltd filed Critical Shenzhen Zhongke Shiwei Technology Co ltd
Priority to CN202110495432.4A priority Critical patent/CN113223100A/en
Publication of CN113223100A publication Critical patent/CN113223100A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/41Bandwidth or redundancy reduction

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Signal Processing (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The invention relates to the technical field of picture processing, in particular to a picture compression processing method, which comprises the following steps: step S1, acquiring the resolution of the picture to be compressed, wherein the resolution comprises two parameters of H and W; step S2, acquiring the color specification of the picture, namely the number of colors in the whole picture; in step S3, the pixels and color table of the picture are extracted and compressed.

Description

Picture compression and decompression processing method
Technical Field
The invention relates to the technical field of picture processing, in particular to a picture compression and decompression processing method.
Background
With the progress of science and technology, the performance of the mobile phone is greatly improved, and meanwhile, more and more pictures are available in the mobile phone; the source of the picture can include multiple aspects, such as user photographing, web page pictures, pictures generated by social software, and the like; with the increase of pictures, a large amount of storage space of a mobile phone is occupied, and how to reduce the storage space occupied by the pictures under the condition of ensuring the picture quality is a technical problem to be solved urgently.
At present, the storage space occupied by pictures is mainly reduced by clipping or compressing the pictures.
However, clipping the picture with uniform height such as 1024 pixels may cause the definition of the picture to be reduced when the picture is displayed on a mobile phone with high pixel density; if the height of the picture is smaller than the uniform cutting height, the picture is stretched and displayed, and the definition of the picture is poor; compressing pictures with uniform size, such as 200kb, can cause data loss and the definition of the pictures can be reduced;
in addition, when the picture is decompressed after being compressed, data loss can be caused, and the definition of the picture can be reduced.
Disclosure of Invention
The present invention aims to provide a method for processing compression and decompression of a picture, so as to solve the technical problems of large picture storage space, poor definition of the compressed picture, data loss and poor user experience in the background art.
In order to achieve the above purpose, the present invention is widely applied to the technical scheme of the fuel cell, and particularly provides the following technical scheme: a picture compression processing method comprises the following steps:
step S1, acquiring the resolution of the picture to be compressed, wherein the resolution comprises two parameters of H and W;
step S2, acquiring the color specification of the picture, namely the number of colors in the whole picture;
step S3, extracting the pixels and color table of the picture for compression;
wherein, step S3 includes:
step S301, saving the agent 16 ColorTab [256] of the color table; uint8 colorindex, Lastcolor, data of pixels uint8 pixdata [ H.W ];
step S302, before compression is started, the pixels prepared in the step S301 need to be cleared, and the process of preparing compression is started;
in step S303, the search and compression of the pixels are started from the top left corner to the bottom right corner of the pixels.
Preferably, the step S303 further includes the steps of:
step 3031, reading pixel colors;
step S3032, checking whether the color of the pixel exists in colororab, and if so, returning the offset value colorendex of the color in the color table;
if not, adding the color to the color table and returning the offset value colorendex of the current color; this process completes the filling of the color table and pixel compression to provide the count.
Preferably, if the color in the result returned in step S3032 is the same as lastcolor, it represents that continuous color appears for pixcount + +; the number of pixels for pix is then increased but not saved.
Preferably, if the color returned in step S3032 is different from lastcolor, it represents that the color change requires saving the previously counted color; and completing one-stage compression of the pixels before expression, storing the data, and starting color storage of the next group of pixels.
Preferably, in the step S2, it is further determined whether the picture format is a png picture of 8bp, if so, the next compression is directly performed, and if not, the picture is compressed into the png picture of 8bp by an 8bp approximate conversion method.
Preferably, H in step 301 is the height of the picture to be compressed, W is the width of the picture to be compressed, and uint8pixcount is the statistical number of the same continuous pixels.
The method for decompressing the picture based on the above is as follows:
step S100, reading a color table corresponding to the picture ID from Flash and storing the color table into colTab;
step S200, reading 512-byte image data from Flash;
step S300, starting DMA to read subsequent 512-byte data from Flash;
step S400, filling pixels to a display screen according to colors and corresponding quantity;
step S500, the data of the read buffer is drawn, if the read buffer finishes the read system, the DMA data is waited to be read, otherwise, the step S400 is repeated;
and S600, finishing the reading of the switched DMA data, if so, finishing the decompression, otherwise, continuing the DMA to acquire the residual data, returning to the step S400, and repeating the corresponding steps until the decompression of the picture is finished.
Compared with the prior art, the invention has the beneficial effects that:
by the method, the size of the picture is 32x32, the size of the pixel color table is 256 x 2-512 bytes, the content of the pixel is 1024 pixels, and the total size is 1024+512 bytes; the compressed sizes were: 512 bytes of pixel color table, about 320 bytes of pixel content, total 832 bytes; the pixel content compressed content is about 1/3 of the original map; the compression rate can be close to 30% under the condition that the size of the picture is large, so that the compressed picture has the advantages of small storage space, clear picture, no data loss or reduced storage space after compression and decompression, clear picture and no data loss.
Drawings
FIG. 1 is a flowchart of a method for compressing pictures according to the present invention:
FIG. 2 and FIG. 3 are flow charts of extracting pixels and color tables of a picture according to the present invention;
FIG. 4 is a flowchart of a method for compressing and decompressing pictures according to the present invention;
FIG. 5 is a diagram illustrating the effect of picture compression according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, 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 invention.
Referring to fig. 1-3, an embodiment of the present invention is shown:
a picture compression processing method comprises the following steps:
step S1, acquiring the resolution of the picture to be compressed, wherein the resolution comprises two parameters of H and W;
step S2, acquiring the color specification of the picture, namely the number of colors in the whole picture;
the general low-end embedded device uses pictures with RGB565 colors, and if the format of each picture is png-8, the whole picture has 256 colors;
if the picture belongs to png-8, starting to enter a picture compression flow, if the picture does not belong to png-8, firstly entering a picture conversion flow, entering colors into an approximate compression flow, and keeping the colors of the whole picture within 256 colors; the png-8 picture is generally saved by color table + pixel data;
the storage space size of the png 8240 × 240 picture without compression is 256 × 2 bytes +57600 bytes of data pixel data of the color table. The total size is 58112 bytes.
Step S3, extracting the pixels and color table of the picture for compression;
the pixels refer to each pixel point of the picture, and if the resolution of one picture is 240 × 240, the pixels of the picture contained in the whole picture are 57600 pixel points; the color table is an index table of the colors of the picture, and the colors of the whole picture are stored in the color table;
as shown in fig. 2 and 3, in order to extract the picture pixels and the color table, step S3 includes the following steps:
step S301, saving the agent 16 ColorTab [256] of the color table; uint8 colorindex, Lastcolor, data of pixels uint8 pixdata [ H.W ];
step S302, before compression is started, the pixels prepared in the step S301 need to be cleared, and the process of preparing compression is started;
in step S303, the search and compression of the pixels are started from the top left corner to the bottom right corner of the pixels.
The step S303 further includes the steps of:
step 3031, reading pixel colors;
step S3032, checking whether the color of the pixel exists in colororab, and if so, returning the offset value colorendex of the color in the color table;
if not, adding the color to the color table and returning the offset value colorendex of the current color; this process completes the filling of the color table and pixel compression to provide the count.
If the color in the result returned in step S3032 is the same as lastcolor, pixcount + + indicates that continuous color appears; the number of pixels for pix is then increased but not saved.
If the color returned in step S3032 is different from lastcolor, it represents that the color changes and the previously counted color needs to be saved; and completing one-stage compression of the pixels before expression, storing the data, and starting color storage of the next group of pixels.
For compressed pictures with png of 8bp, in said step S2:
and judging whether the picture format is the png picture of 8bp, if so, directly performing the next compression, and if not, compressing the picture into the png picture of 8bp by an 8bp approximate conversion method.
H in the step 301 is the height of the picture to be compressed, W is the width of the picture to be compressed, and the count number of the same continuous pixels of the uint8 pixcount.
Referring to fig. 4, an embodiment of the present invention:
in order to decompress a compressed picture, a picture decompression processing method comprises the following steps:
step S100, reading a color table corresponding to the picture ID from Flash and storing the color table into colTab;
step S200, reading 512-byte image data from Flash;
step S300, starting DMA to read subsequent 512-byte data from Flash;
step S400, filling pixels to a display screen according to colors and corresponding quantity;
step S500, the data of the read buffer is drawn, if the read buffer finishes the read system, the DMA data is waited to be read, otherwise, the step S400 is repeated;
and S600, finishing the reading of the switched DMA data, if so, finishing the decompression, otherwise, continuing the DMA to acquire the residual data, returning to the step S400, and repeating the corresponding steps until the decompression of the picture is finished.
As shown in fig. 5, for the compression case of the present invention:
the picture is a picture of 32x32 pixels, and is displayed in a thinning mode after being magnified by 20 times; we start compression from 1 pixel in the whole picture, extract the first color as 0x0000, save the first color to the position of colorTab [0], assign colorindex as 0x0000, and now execute the flow to S3032, and pixindex + +.
Then, when the 12 th pixel is repeatedly executed, if the pixel color value is 0x10EC, the data is saved until pixdata [0] is 0x0, and the color offset value is obtained; pixdata [1] ═ 11, number of colors; all pixels are compressed into the color table and pixdata in this loop.
In combination with the above shown: referring to the picture in fig. 5, the size of the picture before being uncompressed is 32 × 32, and the size of the pixel color table is 256 × 2 — 512 bytes. The pixel content is 1024 pixels, and the total size is 1024+512 bytes;
the compressed sizes were: the pixel color table is 512 bytes, and the pixel content is about 320 bytes, which is a total of 832 bytes. The pixel content compression content is about 1/3 of the original picture, and the compression rate can approach the effect of 30% when the picture size is relatively large.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.

Claims (7)

1. A picture compression processing method is characterized in that: the method comprises the following steps:
step S1, acquiring the resolution of the picture to be compressed, wherein the resolution comprises two parameters of H and W;
step S2, acquiring the color specification of the picture, namely the number of colors in the whole picture;
step S3, extracting the pixels and color table of the picture for compression;
wherein, step S3 includes:
step S301, saving the agent 16 ColorTab [256] of the color table;
uint8 colorindex, Lastcolor, data of pixels uint8 pixdata [ H.W ];
step S302, before compression is started, the pixels prepared in the step S301 need to be cleared, and the process of preparing compression is started;
in step S303, the search and compression of the pixels are started from the top left corner to the bottom right corner of the pixels.
2. The method of claim 1, wherein: the step S303 further includes the steps of:
step 3031, reading pixel colors;
step S3032, checking whether the color of the pixel exists in colororab, if so, returning the offset value colorindex of the color in the color table, if not, adding the color to the color table, and returning the offset value colorindex of the current color; this process completes the filling of the color table and pixel compression to provide the count.
3. The method of claim 2, wherein: if the color in the result returned in step S3032 is the same as lastcolor, pixcount + + indicates that continuous color appears; the number of pixels for pix is then increased but not saved.
4. The method of claim 2, wherein: if the color returned in step S3032 is different from lastcolor, it represents that the color changes and the previously counted color needs to be saved; and completing one-stage compression of the pixels before expression, storing the data, and starting color storage of the next group of pixels.
5. The method of claim 1, wherein: in step S2, it is further determined whether the picture format is a png picture of 8bp, if so, the next compression is directly performed, and if not, the picture is compressed into the png picture of 8bp by an 8bp approximate transformation method.
6. The method of claim 1, wherein: h in the step 301 is the height of the picture to be compressed, W is the width of the picture to be compressed, and uint8pixcount is the statistical number of the same continuous pixels.
7. The method according to any one of claims 1 to 6, wherein: the method comprises the following steps:
step S100, reading a color table corresponding to the picture ID from Flash and storing the color table into colTab;
step S200, reading 512-byte image data from Flash;
step S300, starting DMA to read subsequent 512-byte data from Flash;
step S400, filling pixels to a display screen according to colors and corresponding quantity;
step S500, the data of the read buffer is drawn, if the read buffer finishes the read system, the DMA data is waited to be read, otherwise, the step S400 is repeated;
and S600, finishing the reading of the switched DMA data, if so, finishing the decompression, otherwise, continuing the DMA to acquire the residual data, returning to the step S400, and repeating the corresponding steps until the decompression of the picture is finished.
CN202110495432.4A 2021-05-07 2021-05-07 Picture compression and decompression processing method Pending CN113223100A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110495432.4A CN113223100A (en) 2021-05-07 2021-05-07 Picture compression and decompression processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110495432.4A CN113223100A (en) 2021-05-07 2021-05-07 Picture compression and decompression processing method

Publications (1)

Publication Number Publication Date
CN113223100A true CN113223100A (en) 2021-08-06

Family

ID=77091466

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110495432.4A Pending CN113223100A (en) 2021-05-07 2021-05-07 Picture compression and decompression processing method

Country Status (1)

Country Link
CN (1) CN113223100A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114119784A (en) * 2021-11-25 2022-03-01 业成科技(成都)有限公司 Electronic tag display image processing method and device and computer equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5218431A (en) * 1990-04-26 1993-06-08 The United States Of America As Represented By The Secretary Of The Air Force Raster image lossless compression and decompression with dynamic color lookup and two dimensional area encoding
US5408542A (en) * 1992-05-12 1995-04-18 Apple Computer, Inc. Method and apparatus for real-time lossless compression and decompression of image data
US20090033752A1 (en) * 1999-06-08 2009-02-05 Lightsurf Technologies, Inc. Digital Camera Device and Methodology for Distributed Processing and Wireless Transmission of Digital Images
CN104142924A (en) * 2013-05-06 2014-11-12 中国移动通信集团福建有限公司 Method and device for compressing flash picture format

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5218431A (en) * 1990-04-26 1993-06-08 The United States Of America As Represented By The Secretary Of The Air Force Raster image lossless compression and decompression with dynamic color lookup and two dimensional area encoding
US5408542A (en) * 1992-05-12 1995-04-18 Apple Computer, Inc. Method and apparatus for real-time lossless compression and decompression of image data
US20090033752A1 (en) * 1999-06-08 2009-02-05 Lightsurf Technologies, Inc. Digital Camera Device and Methodology for Distributed Processing and Wireless Transmission of Digital Images
CN104142924A (en) * 2013-05-06 2014-11-12 中国移动通信集团福建有限公司 Method and device for compressing flash picture format

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114119784A (en) * 2021-11-25 2022-03-01 业成科技(成都)有限公司 Electronic tag display image processing method and device and computer equipment

Similar Documents

Publication Publication Date Title
CN108810622B (en) Video frame extraction method and device, computer readable medium and electronic equipment
CN103957416B (en) Partial expansion method of encoded images and image processing apparatus
EP2559270B1 (en) Method and apparatus for generating and playing animation message
CN111311716B (en) Animation playing method, device, terminal equipment and storage medium
KR20080018396A (en) Computer-readable medium for recording mobile application and personal computer application for displaying display information of mobile communications terminal in external display device
CN111294600A (en) Compression method, decompression method and device for video sequence frame
CN106803959A (en) Encoding video pictures, coding/decoding method and device
CN112991412B (en) Liquid crystal instrument sequence frame animation performance optimization method and liquid crystal instrument
CN113223100A (en) Picture compression and decompression processing method
CN112714357A (en) Video playing method, video playing device, electronic equipment and storage medium
CN111738951A (en) Image processing method and device
CN110619667B (en) PNG picture compression method and system
CN112653905B (en) Image processing method, device, equipment and storage medium
CN109685861B (en) Picture compression method, device and equipment and computer readable storage medium
CN108235024B (en) Method and device for compressing image
US20220138906A1 (en) Image Processing Method, Apparatus, and Device
US20050286803A1 (en) Image processing apparatus, display device, image processing method, and image processing program
CN113271466B (en) Image encoding method, decoding method, transmission method, storage device, and processing device
US7848581B2 (en) System and method for decoding and viewing of image files
CN113473150B (en) Image processing method and device and computer readable storage device
Dominé Using texture compression in OpenGL
US6965642B2 (en) Method and device for compressing and decompressing moving image data and information recording medium
CN113784142A (en) Method for lossless compression of tobacco leaf pictures
US7181078B2 (en) Apparatus and method for compressing/decompressing images in a mobile communication terminal
US20110286663A1 (en) Method And Apparatus Of Color Image Rotation For Display And Recording Using JPEG

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