WO2014075567A1 - 一种无损压缩图片的方法和装置 - Google Patents

一种无损压缩图片的方法和装置 Download PDF

Info

Publication number
WO2014075567A1
WO2014075567A1 PCT/CN2013/086484 CN2013086484W WO2014075567A1 WO 2014075567 A1 WO2014075567 A1 WO 2014075567A1 CN 2013086484 W CN2013086484 W CN 2013086484W WO 2014075567 A1 WO2014075567 A1 WO 2014075567A1
Authority
WO
WIPO (PCT)
Prior art keywords
picture
data
format
preset
compression
Prior art date
Application number
PCT/CN2013/086484
Other languages
English (en)
French (fr)
Inventor
黄飞跃
吴运声
吴永坚
丁守鸿
吴尚
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2014075567A1 publication Critical patent/WO2014075567A1/zh
Priority to US14/716,557 priority Critical patent/US9710929B2/en

Links

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
    • 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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • 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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/119Adaptive subdivision aspects, e.g. subdivision of a picture into rectangular or non-rectangular coding 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/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/40Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video transcoding, i.e. partial or full decoding of a coded input stream followed by re-encoding of the decoded output stream
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and apparatus for lossless compression of pictures. Background technique
  • the method is important for reducing image transmission bandwidth and storage space.
  • the mainstream image storage formats are JPEG (Joint Photographic Experts Group) and PNG (Portable Network Graphic Format).
  • the technique for compressing picture capacity of these two pictures is generally to remove pictures.
  • the way of redundant information is generally to remove the auxiliary information of the JPEG format picture and remove the auxiliary information in the auxiliary block of the PNG format.
  • Another compression method is to reduce the resolution of the picture to reduce the space occupied by the picture.
  • the picture compression method of removing the auxiliary information of the picture although the requirement of lossless compression can be achieved, the compression efficiency of the picture is relatively low, and the compression is insufficient; the image compression mode of reducing the resolution is performed with loss. Compressed, the original image data cannot be guaranteed.
  • a method of losslessly compressing a picture comprising:
  • the auxiliary information and the redundant information for removing the picture according to the preset manner include:
  • the auxiliary information in the picture is removed.
  • the auxiliary information and the redundant information for removing the picture according to the preset manner include:
  • the transparent channel data is included, the data other than the transparent channel data in the auxiliary block of the picture is removed as redundant data, and the red, green and blue RGB colors of the transparent pixels in the transparent channel data in the picture are removed.
  • the value is modified to a preset color value
  • the auxiliary block of the picture is removed as redundant data.
  • the compression parameter of the progressive JPEG format is set for the original picture data of the picture whose resolution is greater than the preset resolution
  • the Huffman encoded compression parameters are set, and the original picture data of the picture is compressed.
  • the method further includes: before the compressing the original image data of the picture, and recompressing the image of the format type before the image is decompressed, the method further includes:
  • the color depth parameter of the original picture data of the picture is less than or equal to the preset bit
  • the PNG type is the original picture data of the picture of the non-palette type. , converted to a palette type
  • an apparatus for losslessly compressing a picture comprising: a first removing module, configured to remove auxiliary information of the picture and redundant information according to a preset manner; a decompression module, configured to perform decompression processing on the picture, and restore original picture data of the picture; And setting a compression parameter to the original picture data of the picture, and compressing into a format type picture before the picture is decompressed.
  • the first removal module includes:
  • a first removing unit configured to remove auxiliary information in the picture when the picture is in a JPEG format.
  • the first removal module includes:
  • a second removing unit configured to: when the picture is in a PNG format, remove auxiliary information in the picture; the determining unit is configured to determine whether the auxiliary block of the picture includes transparent channel data;
  • a third removing unit configured to remove, when the transparent channel data is included, data other than the transparent channel data in the auxiliary block of the picture as redundant data, and transparent pixels in the transparent channel data in the picture
  • the red, green and blue RGB color values of the points are modified to preset color values
  • a fourth removing unit configured to remove the auxiliary block of the picture as redundant data if the transparent channel data is not included.
  • the compression module includes:
  • a setting unit configured to: when the format of the picture before the decompressing is a JPEG format, set a compression parameter of the progressive JPEG format for the original picture data of the picture whose resolution is greater than the preset resolution;
  • a first compression unit configured to set a compression parameter of the Huffman code, and compress the original picture data of the picture.
  • the compression module includes:
  • a second compression unit configured to: when the format of the image is decompressed into a PNG format, select multiple combinations from a preset filtering type and a preset compression parameter, and perform traversal compression on the image. After the preset number of times, the result with the largest compression ratio is selected as the compressed result.
  • the device further includes:
  • a conversion module configured to: when the format of the picture is decompressed into a PNG format, the color depth parameter in the original picture data of the picture is less than or equal to a preset bit, and the PNG type is a non-palette type The original image data of the image, converted to a palette type;
  • a query module configured to query, in the original image data of the picture, whether the palette data block in the key block of the PNG type is a palette type contains duplicate entries, and/or a palette data block of the key block Whether there is an entry in the color value that does not correspond to the pixel point;
  • a second removing module configured to remove duplicate entries in the palette data block in the key block if there are duplicate entries
  • a third removing module configured to: if there is an entry that does not correspond to a pixel point color value, remove an entry of the color data value of the corresponding color point in the palette data block in the key block.
  • the picture is decompressed, and then compressed according to the preset compression parameters, and the compression ratio of the picture is improved on the basis of lossless compression, thereby saving storage space.
  • Embodiment 1 is a flowchart of a method for losslessly compressing a picture according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a method for losslessly compressing a picture according to Embodiment 2 of the present invention
  • FIG. 3 is a flowchart of a method for losslessly compressing a picture according to Embodiment 3 of the present invention
  • FIG. 4 is a schematic structural diagram of an apparatus for lossless compression of pictures according to Embodiment 4 of the present invention.
  • FIG. 5 is a schematic structural diagram of an apparatus for lossless compression of pictures according to Embodiment 5 of the present invention.
  • FIG. 6 is a schematic structural diagram of an apparatus for lossless compression of pictures according to Embodiment 6 of the present invention.
  • FIG. 7 is a schematic structural diagram of a terminal according to Embodiment 7 of the present invention. detailed description
  • An embodiment of the present invention provides a method for losslessly compressing a picture.
  • the method process includes:
  • the embodiment of the present invention provides a method for losslessly compressing a picture.
  • the method embodiment is for compression performed when the picture format is JPEG.
  • the method flow includes:
  • the step 201 may be specifically: 201: When the picture is in the JPEG format, the auxiliary information in the picture is removed.
  • the auxiliary information of the JPEG format picture is removed, that is, some useless JPEG METADATA (metadata) is removed, which may include Exif (Exchangeable image file) information, which is used for recording.
  • Exif Exchangeable image file
  • Attribute information and shooting data of digital photos including: shooting conditions such as aperture, shutter, white balance, ISO (sensitivity), focus, date and time, and camera brand, model, color coding, and sound recorded during shooting And location information, thumbnails, etc. obtained by positioning. Except for white balance and color coding in Exif information, the rest of the information and data have nothing to do with the picture display, you can delete this. In general, deleting the Exif information in the picture can reduce the volume by about 20 kilobits.
  • auxiliary information for the picture may also be: Some of the recompressed picture information may include comment information embedded in the picture code in text form, such as a description of the location of the photo, the name of the photographer, etc., and Similar to the Exif information, such redundancy is also independent of the picture display, and will not affect the picture display after deletion.
  • the picture in the JPEG format with the auxiliary information removed it is compressed by Huffman coding.
  • the picture to be compressed in the JPEG format is recompressed, so data needs to be processed.
  • Restore restore to the original image data before the original JPEG format. This process is prior art and will not be described here.
  • the progressive JPEG format image has the following features: When browsing the image on the web page, only one blurred image is displayed at the beginning. As the data is loaded, the image gradually becomes clear, compared with the normal JPEG format image, the progressive JPEG format The image takes up less storage space based on the same display.
  • step 203 can be specifically as follows:
  • the raw data of the picture is losslessly compressed using standard Huffman optimized coding.
  • the image lossless compression process based on Huffman coding is usually divided into two steps, namely, correlation and coding removal. Removing the correlation is to remove the redundant part of the image data and reduce the source entropy, which is the compression process of the image data; the encoding is to replace the redundant image data with a new symbol code, which is also The process of re-encoding image data for storage.
  • the image data is compressed into a prior art by Huffman optimization coding, and will not be described here.
  • the embodiment of the present invention provides a method for lossless compression of a picture.
  • the method embodiment is for compression performed when the picture format is PNG.
  • the method flow includes:
  • the standard PNG file structure is composed of a PNG file identifier and a plurality of PNG data blocks, as shown in Table 1.
  • PNG data blocks are further divided into key blocks and auxiliary blocks, where the data contained in the key blocks is as shown in Table 2:
  • File header data block IHDR basic information such as image type, width and height, color depth
  • Palette data block PLTE palette color list PLTE for color type 3 must exist, for color
  • Color type 2, 6 optional, for color type 0, 4 cannot exist Image data block IDAT Actual image data, which can contain multiple consecutive IDATs (dividing into multiple IDATs will slightly increase the file, but can stream PNG files)
  • the end of the image is the end of the IEND file, indicating the end of the PNG stream.
  • the auxiliary block has a total of 14 kinds of data, which can be divided into five categories according to the type of information: transparent information (tRNS), color space information (c-leg, gAMA, iCCP, sBIT, sRGB), text information (tEXt, zTXt, iTXt) , other information (bKGD, hIST, pHYs, sPLT) and timestamp information (tIME).
  • the auxiliary block is not required to be included in the PNG file, so data blocks unrelated to the picture display can be deleted during compression, for example, text information data blocks (tEXt, zTXt, iTXt) and time stamp information (tIME).
  • auxiliary block data all the auxiliary data blocks are removed for the picture without the transparent channel data, and all the auxiliary block data except the tRNS data are removed for the picture containing the transparent channel data in the auxiliary block data, and are transparent
  • the RGB (Red Green Blue) color values of the pixels of the state are modified.
  • the tRNS is an image transparent data block, and stores related information of the transparent channel.
  • Step 301 can be specifically as follows:
  • the auxiliary information removed in this step is the same as the auxiliary information in the JPEG format picture removed in step 201, and will not be described here.
  • the transparent channel data is included, the data other than the transparent channel data in the auxiliary block of the picture is removed as redundant data, and the RGB color value of the transparent pixel in the transparent channel data in the picture is removed. Modified to a preset color value;
  • the transparent information of the corresponding pixel points in the transparent channel data it is known which pixels in the picture are completely transparent, so for the transparent pixel, regardless of the color of the corresponding original RGB color value, When the picture shows the pixel, the corresponding color is not displayed. Instead, the pixel is completely transparent according to the transparent attribute of the corresponding pixel in the transparent information of the PNG picture, and the color value is invisible. It is useless for the RGB color value saved by this pixel, so you can change its corresponding RGB color value to (0, 0, 0), which reduces the storage space.
  • the picture in the PNG format that needs to be compressed it is compressed by Huffman coding.
  • the picture to be compressed in the PNG format is re-compressed, so data needs to be processed.
  • the color depth parameter in the original picture data of the picture is less than or equal to the preset bit, and the PNG type is the original of the picture of the non-palette type.
  • the size of the preset bit may be 8 bits. Of course, the size of the preset bit may be 16 bits or in addition to 8 bits.
  • this embodiment does not specifically limit the size of the preset bits.
  • PNG format pictures use PNG type PNG24/PNG32 (RGBA four channels, each channel is 8 bits, each pixel is 24-32 bits). If the number of colors stored in the picture is less than 256, you can use The palette type PNG8 (8 bits per pixel) is stored, which greatly increases the compression ratio for pictures with a large number of pixels.
  • the color value of each pixel in the palette type image is changed from the previously saved RGB value to the pixel index of the pixel, and the palette data in the key block data of the image holds the image included in the image. All colors, all color information in the picture are stored in the palette data block.
  • Palette Chunk PLTE Palette Chunk
  • Palette Chunk PLTE is one of the four key blocks in the PNG format image. It is used to store all the color values corresponding to the pixels in the PNG format image of the palette type.
  • Reducing the palette data block contains two things: removing duplicate entries and entries that do not correspond to the color values of individual pixels. Wherein, the redundant duplicate entries refer to duplicate entries representing the same RGB value. If the palette of the PNG image contains duplicate or unused color values, the palette data blocks representing the color values may be Remove it.
  • the step 307 may be specifically: 307: when the format of the image before the decompression is in the PNG format, multiple combinations are selected from the preset filtering type and the preset compression parameter, respectively.
  • the picture is traversed and compressed, and after the preset number of times, the result with the largest compression ratio is selected as the compressed result.
  • the default filter type (Fitter Tpye) is specifically as follows:
  • the PNG format image filtering method defines five basic filtering types, and selecting the appropriate filtering type for the image will increase the compression ratio. These types include: Type 0: No filtering; Type 1: Sub filtering, that is, the filtering result is the difference between the pixel and the previous (left) pixel; Type 2: Up filtering, that is, the filtering result is the pixel and the previous scanning line.
  • Type 3 Average filtering, using the average of the left and upper pixels to predict the pixel value;
  • Type 4 Paeth filtering, a simple linear function for the left pixel, the upper pixel, and the upper left pixel Calculate, then select the pixel closest to the preset value and use it as the filtering result.
  • Zl ib is a function library for data compression, using the lossless compression LZ77 variant algorithm deflate, PNG image data block IDAT usually uses Zl ib-def late compression.
  • Deflate has the following four parameters, which will affect the compressed file size: Zl ib Compression Level; Zl ib Compression Strategy; Zl ib Memory Level; Floating Window Size (Zl Ib Window Size). Each of these four parameters has several values to choose from.
  • the traversal selects N different sets of PNG filter types and compression parameters, and uses the result with the highest compression ratio as the final result output.
  • the choice of filter type and Zl ib compression parameters will have a great impact on the compression effect, and there are many ways to combine different parameters. It is very time consuming to try each one.
  • An embodiment of the present invention provides a device for lossless compression of a picture.
  • the device includes:
  • the first removing module 401 is configured to remove auxiliary information and redundant information of the picture according to a preset manner
  • the decompression module 402 is configured to perform decompression processing on the image, and restore original picture data of the picture.
  • the compression module 403 is configured to set a compression parameter on the original picture data of the picture, and compress the The format type picture before the image is decompressed.
  • the compression is performed according to the preset compression parameter, and the compression ratio of the picture is improved on the basis of the lossless compression. Saves storage space Embodiment 5
  • the embodiment of the present invention provides an apparatus for losslessly compressing a picture.
  • the apparatus includes: a first removing module 501, configured to remove auxiliary information and redundant information of a picture according to a preset manner; and the decompression module 502 For compressing the picture, the original picture data of the picture is restored, and the compression module 503 is configured to set a compression parameter for the original picture data of the picture, and compress the image to be compressed before the picture is decompressed.
  • the format type picture is configured to set a compression parameter for the original picture data of the picture, and compress the image to be compressed before the picture is decompressed.
  • the first removing module 501 includes:
  • the first removing unit 5011 is configured to remove the auxiliary information in the picture when the picture is in the JPEG format.
  • the compression module 503 includes:
  • the setting unit 5031 is configured to: when the format of the picture before the decompressing is the JPEG format, set the compression parameter of the progressive JPEG format for the original picture data of the picture whose resolution is greater than the preset resolution ;
  • the first compression unit 5032 is configured to set a compression parameter of the Huffman coding, and compress the original picture data of the picture.
  • An embodiment of the present invention provides an apparatus for losslessly compressing a picture.
  • the apparatus includes: a first removing module 601, configured to remove auxiliary information and redundant information of a picture according to a preset manner; and decompressing the module 602.
  • the compression module 603 is configured to set a compression parameter for the original picture data of the picture, and compress the picture to be compressed before the picture is decompressed.
  • the format type picture is configured to set a compression parameter for the original picture data of the picture, and compress the picture to be compressed before the picture is decompressed.
  • the first removing module 601 includes:
  • the second removing unit 6011 is configured to: when the picture is in the PNG format, remove the auxiliary information in the picture; the determining unit 6012 is configured to determine whether the auxiliary block of the picture includes transparent channel data;
  • a third removing unit 6013 configured to remove, in the auxiliary block of the picture, data other than the transparent channel data as redundant data if the transparent channel data is included, and transparently transparent data in the picture
  • the RGB color value of the pixel is modified to a preset color value
  • the fourth removing unit 6014 is configured to remove the auxiliary block of the picture as redundant data if the transparent channel data is not included.
  • the compression module 603 includes:
  • the second compression unit 6031 is configured to: when the format of the picture is decompressed into a PNG format, select multiple combinations from the preset filtering type and the preset compression parameter, and perform traversal pressure on the picture. After the preset number of times, the result with the largest compression ratio is selected as the compressed result.
  • the device also includes:
  • the conversion module 604 is configured to: when the format of the picture is decompressed into a PNG format, the color depth parameter in the original picture data of the picture is less than or equal to a preset bit, and the PNG type is a non-palette type The original image data of the picture, converted into a palette type;
  • the query module 605 is configured to query, in the original picture data of the picture, whether the palette data block in the key block of the PNG type is a palette type contains duplicate entries, and/or palette data of the key block. Whether there is an entry in the block that does not correspond to the color value of the pixel;
  • a second removing module 606 configured to remove duplicate entries in the palette data block in the key block if there are duplicate entries
  • the third removing module 607 is configured to remove an entry of the color data value of the palette data block that does not correspond to the pixel point in the key block if there is an entry that does not correspond to the pixel color value.
  • the compression is performed according to the preset compression parameter, and the compression ratio of the picture is improved on the basis of the lossless compression. Saves storage space.
  • FIG. 7 is a schematic structural diagram of a touch sensitive surface according to an embodiment of the present invention.
  • the terminal can be used to implement the non-destructive pressure provided in the foregoing embodiment.
  • the method of shrinking the picture specifically:
  • the terminal 700 may include an RF (Radio Frequency) circuit 110, a memory 120 including one or more computer readable storage media, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a transmission module 170, including One or more processing core processor 180, and power supply 190 and the like.
  • RF Radio Frequency
  • the RF circuit 110 can be used for transmitting and receiving information or during a call, receiving and transmitting signals, in particular, going under the base station After the line information is received, it is processed by one or more processors 180; in addition, data related to the uplink is transmitted to the base station.
  • the RF circuit 110 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low No Aceifier), low noise. Amplifier), duplexer, etc.
  • SIM Subscriber Identity Module
  • RF circuitry 110 can also communicate with the network and other devices via wireless communication.
  • the wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System of Mobility Communication System), GPRS (General Packet Radio Service) CDMA (Code Divi) s ion Mult iple Access, code division multiple access) WCDMA (Wideband Code Divi s ion Mult iple Access), LTE (Long Term Evolut ion), e-mail, SMS (Short Messaging Service, short) Message service) and so on.
  • GSM Global System of Mobility Communication System
  • GPRS General Packet Radio Service
  • CDMA Code Divi) s ion Mult iple Access
  • code division multiple access code division multiple access
  • WCDMA Wideband Code Divi s ion Mult iple Access
  • LTE Long Term Evolut ion
  • e-mail Short Messaging Service, short
  • the memory 120 can be used to store software programs and modules, such as software programs and modules corresponding to the devices for improving the running speed of the application in the third embodiment, and the processor 180 executes various functions by running software programs and modules stored in the memory 120.
  • Application and data processing such as improving the running speed of the application.
  • the memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to The data created by the use of the terminal 700 (such as audio data, phone book, etc.) and the like.
  • memory 120 can include high speed random access memory, and can 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, memory 120 may also include a memory controller to provide access to memory 120 by processor 180 and input unit 130.
  • the input unit 130 can be used to receive input numeric or character information, as well as to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
  • input unit 130 can include touch sensitive surface 131 as well as other input devices 132.
  • Touch-sensitive surface 131 also referred to as a touch display or trackpad, can collect touch operations on or near the user (eg, the user uses a finger, stylus, etc., on any touch-sensitive surface 131 or on the touch-sensitive surface 131 The operation near the touch-sensitive surface 131) and driving the corresponding connecting device according to a preset program.
  • the touch-sensitive surface 131 may include two portions of a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information
  • the processor 180 is provided and can receive commands from the processor 180 and execute them.
  • the touch-sensitive surface 131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 130 can also include other input devices 132.
  • other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 140 can be used to display information input by the user or information provided to the user and various kinds of the terminal 700. Graphical user interfaces, these graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof.
  • the display unit 140 may include a display panel 141. Alternatively, the display panel 141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like.
  • touch-sensitive surface 131 may cover the display panel 141, and when the touch-sensitive surface 131 detects a touch operation thereon or nearby, it is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 according to the touch event The type provides a corresponding visual output on display panel 141.
  • touch-sensitive surface 131 and display panel 141 are implemented as two separate components to implement input and input functions, in some embodiments, touch-sensitive surface 131 can be integrated with display panel 141 for input. And output function.
  • Terminal 700 can also include at least one type of sensor 150, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may close the display panel 141 when the terminal 700 moves to the ear. / or backlight.
  • the gravity acceleration sensor can detect the acceleration of each direction (usually three axes), and the magnitude and direction of gravity can be detected at rest.
  • the gesture of the mobile phone such as horizontal and vertical screen switching, related Game, magnetometer attitude calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for the terminal 700 can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, here Let me repeat.
  • the audio circuit 160, the speaker 161, and the microphone 162 provide an audio interface between the user and the terminal 700.
  • the audio circuit 160 can transmit the converted electrical data of the received audio data to the speaker 161 for conversion to the sound signal output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal by the audio circuit 160. After receiving, it is converted into audio data, and then processed by the audio data output processor 180, transmitted to the terminal, for example, by the RF circuit 110, or outputted to the memory 120 for further processing.
  • the audio circuit 160 may also include an earbud jack to provide communication of the peripheral earphones with the terminal 700.
  • the terminal 700 can help the user to send and receive emails, browse web pages, access streaming media, etc. through the transmission module 170, which provides users with wireless or wired broadband Internet access.
  • FIG. 7 shows the transmission module 170, it can be understood that it does not belong to the essential configuration of the terminal 700, and can be omitted as needed within the scope of not changing the essence of the invention.
  • the processor 180 is the control center of the terminal 700, which connects various portions of the entire handset using various interfaces and lines, by running or executing software programs and/or modules stored in the memory 120, and recalling data stored in the memory 120, The various functions and processing data of the terminal 700 are performed to perform overall monitoring of the mobile phone.
  • the processor 180 may include one or more processing cores.
  • the processor 180 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like. Modulation processor master To handle wireless communication. It can be understood that the above modem processor may not be integrated into the processor 180.
  • the terminal 700 also includes a power source 190 (such as a battery) for powering various components.
  • the power source can be logically coupled to the processor 180 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • Power supply 190 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
  • the terminal 700 may further include a camera, a Bluetooth module, and the like, and details are not described herein.
  • the display unit of the terminal is a touch screen display
  • the terminal further includes a memory, and one or more programs, wherein one or more programs are stored in the memory and configured to be processed by one or more
  • the execution of one or more programs includes instructions for performing the following operations:
  • the memory of the terminal further includes an instruction for performing the following operations. :
  • the auxiliary information in the picture is removed.
  • the memory of the terminal further includes an instruction for performing the following operations:
  • the transparent channel data is included, the data other than the transparent channel data in the auxiliary block of the picture is removed as redundant data, and the RGB color value of the transparent pixel in the transparent channel data in the picture is modified to Preset color value;
  • the auxiliary block of the picture is removed as redundant data.
  • the memory of the terminal further includes an instruction for performing the following operations:
  • the compression parameter of the progressive JPEG format is set for the original picture data of the picture whose resolution is greater than the preset resolution
  • the Huffman encoded compression parameters are set, and the original picture data of the picture is compressed.
  • the memory of the terminal further includes an instruction for performing the following operations:
  • the preset filtering type and the preset compression parameter are respectively The plurality of combinations are selected, and the picture is traversed and compressed, and after the preset number of times, the result with the largest compression ratio is selected as the compressed result.
  • the memory of the terminal further includes an instruction for performing the following operations:
  • the color depth parameter of the original picture data of the picture is less than or equal to the preset bit
  • the PNG type is the original picture data of the picture of the non-palette type. , converted to a palette type
  • the embodiment of the present invention removes the auxiliary data and the redundant data of the picture, decompresses the picture, and then compresses according to the preset compression parameter, and improves the picture based on the lossless compression.
  • the compression ratio saves storage space.
  • the embodiment of the present invention provides a computer readable storage medium, which may be a computer readable storage medium included in the memory in the above embodiment, or may exist separately and not assembled into the terminal.
  • Computer readable storage medium stores one or more programs, the one or more programs being used by one or more processors to perform a method of losslessly compressing a picture, the method comprising:
  • the method includes: when the picture is in a JPEG format, removing auxiliary information in the picture.
  • the removing the auxiliary information and the redundant information of the picture according to the preset manner includes: When the picture is in a PNG format, the auxiliary information in the picture is removed;
  • the transparent channel data is included, the data other than the transparent channel data in the auxiliary block of the picture is removed as redundant data, and the RGB color value of the transparent pixel in the transparent channel data in the picture is modified to Preset color value;
  • the auxiliary block of the picture is removed as redundant data.
  • the original picture data of the picture is set with a compression parameter, and is compressed into a format picture before the picture is decompressed.
  • the compression parameter of the progressive JPEG format is set for the original picture data of the picture whose resolution is greater than the preset resolution
  • the Huffman encoded compression parameters are set, and the original picture data of the picture is compressed.
  • the original picture data of the picture is set with a compression parameter, and is compressed into a format picture before the picture is decompressed.
  • the original picture data of the picture is set with a compression parameter, and is recompressed into a format type before the picture is decompressed.
  • the method further includes:
  • the color depth parameter of the original picture data of the picture is less than or equal to the preset bit
  • the PNG type is the original picture data of the picture of the non-palette type. , converted to a palette type
  • the compression is performed according to the preset compression parameter, and the compression ratio of the picture is improved on the basis of the lossless compression. Saves storage space.
  • a graphical user interface is provided in an embodiment of the present invention, where the graphical user interface is used on a terminal, where the terminal includes a touch screen display, a memory, and one or more processors for executing one or more programs;
  • the graphical user interface includes:
  • the apparatus for losslessly compressing pictures provided by the foregoing embodiments is only illustrated by the division of the foregoing functional modules when the pictures are not loss-reduced. In actual applications, the functions may be allocated differently according to needs.
  • the function module is completed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the device for lossless compression of the image provided by the foregoing embodiment is the same as the method embodiment of the method for lossless compression of the image. The specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

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

Abstract

本发明公开了一种无损压缩图片的方法和装置,属于计算机技术领域。所述方法包括:根据预设方式去除图片的辅助信息以及冗余信息;将所述图片进行解压缩处理,还原所述图片的原始图片数据;对所述图片的原始图片数据设置压缩参数,压缩为所述图片解压缩前的格式类型图片。本发明通过去除图片的辅助数据以及冗余数据,对图片进行解压缩后,重新根据预设的压缩参数进行压缩,在无损压缩的基础上,提高了图片的压缩率,节省了存储空间。

Description

一种无损压缩图片的方法和装置 本申请要求于 2012年 11月 19日提交中国专利局、 申请号为 201210468024. 0、发明名 称为 "一种无损压縮图片的方法和装置" 的中国专利申请的优先权, 其全部内容通过引用 结合在本申请中。 技术领域
本发明涉及计算机技术领域, 特别涉及一种无损压縮图片的方法和装置。 背景技术
随着高分辨率图像采集设备的发展, 获取图片的质量越来越高, 海量的图像数据与有 限的存储空间、 有限的网络带宽之间的矛盾日趋突出, 因此研究出更好的图像压縮方法对 减少图像传输带宽和存储空间有重要意义。
目前主流的图片存储格式为 JPEG ( Joint Photographic Experts Group, 联合图像专 家小组) 和 PNG (Portable Network Graphic Format , 流式网络图形格式), 对于这两种图 片的压縮图片容量的技术一般采用去除图片中的冗余信息的方式, 一般为去除 JPEG格式图 片的辅助信息和去除 PNG格式辅助块中的辅助信息。 另一种压縮方式则为降低图片的分辨 率, 来达到降低图片占用空间的目的。
在实现本发明的过程中, 发明人发现现有技术至少存在以下问题:
去除图片的辅助信息的图片压縮方式, 虽然可以达到无损压縮的要求, 但是对于图片 的压縮效率比较低, 压縮不充分; 降低分辨率的图片压縮方式, 则进行的是有损压縮, 无 法保证原始的图片数据。 发明内容
为了解决现有技术中无损压縮图片不充分的问题, 本发明实施例提供了一种无损压縮 图片的方法和装置。 所述技术方案如下:
一方面, 提供了一种无损压縮图片的方法, 所述方法包括:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。 其中, 所述根据预设方式去除图片的辅助信息以及冗余信息, 包括:
当所述图片为 JPEG格式时, 去除所述图片中的辅助信息。
其中, 所述根据预设方式去除图片的辅助信息以及冗余信息, 包括:
当所述图片为 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为 冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的红绿蓝 RGB颜色值修 改为预设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
其中, 所述对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格 式图片, 包括:
当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于预设分辨率的所 述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
其中, 所述对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格 式图片, 包括:
当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数 中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果 作为压縮后的结果。
其中, 所述对所述图片的原始图片数据设置压縮参数, 重新压縮为所述图片解压縮前 的格式类型图片之前, 所述方法还包括:
当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参 数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为 调色板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据 块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的 条目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜 色值的条目。
另一方面, 提供了一种无损压縮图片的装置, 所述装置包括: 第一去除模块, 用于根据预设方式去除图片的辅助信息以及冗余信息; 解压縮模块, 用于将所述图片进行解压縮处理, 还原所述图片的原始图片数据; 压縮模块, 用于对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前 的格式类型图片。
其中, 所述第一去除模块, 包括:
第一去除单元, 用于当所述图片为 JPEG格式时, 去除所述图片中的辅助信息。
其中, 所述第一去除模块, 包括:
第二去除单元, 用于当所述图片为 PNG格式时, 去除所述图片中的辅助信息; 判断单元, 用于判断所述图片的辅助块中是否含有透明通道数据;
第三去除单元, 用于若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据 以外的其他数据作为冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的 红绿蓝 RGB颜色值修改为预设的颜色值;
第四去除单元, 用于若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进 行去除。
其中, 所述压縮模块, 包括:
设置单元, 用于当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于 预设分辨率的所述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
第一压縮单元, 用于设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行 压縮。
其中, 所述压縮模块, 包括:
第二压縮单元, 用于当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类 型和预设的压縮参数中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选 取压縮率最大的结果作为压縮后的结果。
其中, 所述装置还包括:
转换模块, 用于当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数 据中色彩深度参数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片 数据, 转换成为调色板类型;
查询模块, 用于查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键 块中调色板数据块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应 像素点颜色值的条目;
第二去除模块, 用于若存在重复的条目, 则去除关键块中调色板数据块中重复的条目; 第三去除模块, 用于若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据 块中未对应像素点颜色值的条目。
本发明实施例提供的技术方案带来的有益效果是:
通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根据预设的压縮 参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空间。 附图说明
为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描述中所需要使用的 附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发明的一些实施例, 对于本 领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还可以根据这些附图获得其他的 附图。
图 1是本发明实施例一提供的一种无损压縮图片的方法流程图;
图 2是本发明实施例二提供的一种无损压縮图片的方法流程图;
图 3是本发明实施例三提供的一种无损压縮图片的方法流程图;
图 4是本发明实施例四提供的一种无损压縮图片的装置结构示意图;
图 5是本发明实施例五提供的一种无损压縮图片的装置结构示意图;
图 6是本发明实施例六提供的一种无损压縮图片的装置结构示意图;
图 7是本发明实施例七提供的一种终端的结构示意图。 具体实施方式
为使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对本发明实施方式作 进一步地详细描述。
实施例一
本发明实施例提供了一种无损压縮图片的方法, 参见图 1, 方法流程包括:
101: 根据预设方式去除图片的辅助信息以及冗余信息;
102: 将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
103: 对所述图片的原始图片数据设置压縮参数, 重新压縮为所述图片解压縮前的格式 类型图片。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例二
本发明实施例提供了一种无损压縮图片的方法, 参见图 2, 需要说明的是, 本方法实施 例是针对图片格式为 JPEG时所进行的压縮。
方法流程包括:
201: 根据预设方式去除图片的辅助信息以及冗余信息;
其中步骤 201在本发明实施例中可以具体为: 201 : 当所述图片为 JPEG格式时, 去除 所述图片中的辅助信息。
在识别出 JPEG格式图片后,去除 JPEG格式的图片的辅助信息,即去除一些无用的 JPEG METADATA (元数据), 其中可以包括 Exif (Exchangeable image file, 可交换图像文件) 信息, 该信息用于记录数码照片的属性信息和拍摄数据, 包括: 拍摄时的光圈、 快门、 白 平衡、 ISO (感光度)、 焦距、 日期时间等各种拍摄条件以及相机品牌、 型号、 色彩编码、 拍摄时录制的声音以及通过定位得到的位置信息、 縮略图等。 在 Exif信息中除了白平衡和 色彩编码, 其余信息和数据均与图片显示没有关系, 可以对此进行删除。 一般情况下, 删 除图片中的 Exif信息可减少 20千比特左右的体积。
进一步的, 对于图片的辅助信息还可以为: 某些经过重压縮的图片信息中会包含以文 本形式嵌入在图片代码中的评论信息, 例如对拍照地点的描述、 摄影师的姓名等, 和 Exif 信息类似, 此类冗余也与图片显示无关, 删除之后不会对图片显示造成影响。
202: 将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对于去除辅助信息的 JPEG格式的图片, 其本身是经过哈夫曼编码优化压縮的, 在本发 明实施例中会对待压縮的 JPEG格式的图片进行重新的压縮, 因此需要对其进行数据还原, 还原成为最初未经过生成 JPEG格式之前的原始图片数据。 本过程为现有技术, 在此不再赘 述。
203: 对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型 图片。
为图片的原始数据选取统一的压縮参数, 对图片进行压縮, 提高了压縮的效率。
由于大部分浏览器对 progressive (渐进式) JPEG格式图片兼容, 并且在图片的分辨 率比较大时,例如图片分辨率大于 500*500以上的 JPEG图片,将其转换为 progressive JPEG 格式后会比普通的 JPEG格式的图片文件的容量会有所减小。
因此对于 JPEG图片可以进行更进一步地深度压縮, 当待压縮的图片在压縮前不是渐进 式 JPEG格式且图片分辨率大于预设分辨率时, 将其转换为 progressive JPEG格式。 这种 progressive JPEG格式图片的特点为: 在网页浏览该图像时, 开始只显示一个模糊的图像, 随着数据的装入, 图像逐步变得清晰, 与普通 JPEG格式的图片相比, 渐进式 JPEG格式的 图片在具有相同显示效果的基础上占用了更小的存储空间。
因此首先选取大于预设分辨率的图片的原始数据, 并为其压縮成 progressive JPEG格 式的 JPEG图片设置压縮参数。 因此步骤 203可以具体为:
2031: 当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于预设分辨 率的所述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
2032: 设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
对图片的原始数据使用标准哈夫曼优化编码进行无损压縮。 基于哈夫曼编码的图像无 损压縮过程通常分为两步, 即去除相关和编码。 去除相关就是要去除图像数据的冗余部分, 降低信源熵, 这是对图像数据的压縮过程; 编码就是对去除冗余后的图像数据重新用一种 新的符号编码代替, 这也是对图像数据的重编码进行存储的过程。 通过哈夫曼优化编码对 图片数据进行压縮为现有技术, 在此不再赘述。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例三
本发明实施例提供了一种无损压縮图片的方法, 参见图 3, 需要说明的是, 本方法实施 例是针对图片格式为 PNG时所进行的压縮。
方法流程包括:
301: 根据预设方式去除图片的辅助信息以及冗余信息;
具体的, 标准的 PNG文件结构由一个 PNG文件标识和数个 PNG数据块构成, 如表 1所
Figure imgf000008_0001
表 1
PNG数据块又分为关键块和辅助块, 其中关键块中包含的数据, 如表 2所示:
数据类型 描述
文件头数据块 IHDR 基本信息, 如图像类型, 宽高, 色深
调色板数据块 PLTE 调色板颜色列表, PLTE对颜色类型 3必须存在, 对颜
色类型 2, 6可选, 对颜色类型 0, 4不可存在 图像数据块 IDAT 实际图像数据,可以包含多个连续 IDAT (分成多个 IDAT 会略微增大文件, 但可以流式产生 PNG文件)
图像结束数据 IEND 文件尾部, 表示 PNG数据流结束
表 2
其中, 辅助块一共有 14种数据, 根据信息类型可分为 5类: 透明信息 (tRNS)、 色彩 空间信息 ( c腿、 gAMA、 iCCP、 sBIT、 sRGB)、 文本信息 ( tEXt、 zTXt、 iTXt )、 其他信息 (bKGD、 hIST、 pHYs、 sPLT) 和时间戳信息 (tIME)。 辅助块不是 PNG文件必须包含的, 所 以可以在压縮过程中删除与图片显示无关的数据块, 例如, 文本信息数据块 (tEXt、 zTXt, iTXt ) 和时间戳信息 ( tIME)o
辅助块在多数情况下并非必须保留。 在辅助块数据中, 对于没有透明通道数据的图片 则去除所有的辅助数据块, 对于在辅助块数据中含有透明通道数据的图片去除掉除 tRNS数 据之外所有的辅助块数据, 并对处于透明状态的像素点的 RGB (Red Green Blue,红绿蓝) 颜色值进行修改处理。 其中, tRNS是图像透明数据块, 存储了透明通道的相关信息。
步骤 301可以具体为:
3011: 当所述图片为 PNG格式时, 去除所述图片中的辅助信息;
本步骤中去除的辅助信息与步骤 201中 JPEG格式图片去除的辅助信息相同, 在此不再 赘述。
3012: 判断所述图片的辅助块中是否含有透明通道数据;
3013: 若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数 据作为冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的 RGB颜色值修 改为预设的颜色值;
根据透明通道数据中对应保存的各像素点的透明信息可知, 在图片中哪些像素点是完 全透明的, 因此对于透明的像素点, 无论其对应的原有的 RGB颜色值是何种颜色, 在图片 显示该像素点时都不显示其对应的颜色, 而是根据 PNG 图片的透明信息中对应的该像素点 的透明属性显示该像素点为完全透明的, 颜色值则为不可见。对于该像素点对应保存的 RGB 颜色值来说则是无用的, 因此可以将其对应的 RGB颜色值修改为 (0, 0, 0), 减少了存储 空间。
3014: 若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
302: 将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对于需要压縮的 PNG格式的图片, 其本身是经过哈夫曼编码优化压縮的, 在本发明实 施例中会对待压縮的 PNG格式的图片进行重新的压縮, 因此需要对其进行数据还原, 还原 成为最初未经过生成 PNG格式之前的原始图片数据。 本过程为现有技术, 在此不再赘述。
303: 当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深 度参数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换 成为调色板类型;
其中, 预设位的大小具体可为 8位, 当然, 预设位的大小除 8位外, 还可以为 16位或
24位, 本实施例对预设位的大小不进行具体限定。
很多 PNG格式的图片使用的 PNG类型为 PNG24/PNG32 (RGBA四个通道, 每个通道各 8比 特,每个像素 24-32比特),若其图片存储的颜色数少于 256种,则可以用调色板(palette ) 类型 PNG8 (每个像素 8比特)进行存储, 对于像素个数较多的图片, 这可以极大程度提高压 縮率。
调色板类型的图片中每一个像素点的颜色值由之前保存的 RGB值, 变更为该像素的像 素索引, 而在图片的关键块数据中的调色板数据则保存着图片中所包含的所有颜色, 图片 中所有的颜色信息全部存储在调色板数据块中。
304: 查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板 数据块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色 值的条目;
在解压縮后的 PNG格式图片中, 可以去除图片的关键块中的冗余信息, 即去除关键块 中调色板数据块中的冗余信息。 调色板数据块 PLTE (Palette Chunk)是 PNG格式的图片中四 个关键块之一, 用于存储调色板类型的 PNG格式图片中像素点所对应的所有颜色值。
减小调色板数据块包含两方面的内容: 去除重复条目以及与各个像素点的颜色值未对 应的条目。 其中, 多余的重复条目是指表示同一个 RGB值的重复条目, 如果 PNG图像的调 色板中含有重复的或者没有被用到的颜色值, 那么表示这些颜色值的调色板数据块可以被 去掉。
305: 若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
306: 若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素 点颜色值的条目;
307: 对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型 图片。
其中步骤 307在本发明实施例中可以具体为: 307: 当所述图片解压縮前的格式为 PNG 格式时, 分别从预设的过滤类型和预设的压縮参数中选取多种组合, 对所述图片进行遍历 压縮, 经过预设次数后从中选取压縮率最大的结果作为压縮后的结果。 在 PNG格式所对应的压縮体系中有几个可以选择的参数, 例如, PNG过滤器和 Zl ib参 数, 由于 PNG默认的参数不一定能使每一张图片都压縮到最小, 所以遍历尝试每一种可以 选择的参数值, 找出使所述图片占用存储空间最小的配置。
预设的过滤类型 (Fi lter Tpye ) 具体为: PNG格式图片过滤方法定义了 5种基本过滤 类型, 为图片选择合适的过滤类型会提高压縮率。 这些类型包括: 类型 0: 不过滤; 类型 1 : Sub过滤, 即过滤结果为该像素和前一个 (左侧)像素之差; 类型 2: Up过滤, 即过滤结果 为该像素与前一条扫描线 (上方) 上的像素之差; 类型 3: Average过滤, 使用左侧和上方 像素的平均值预测像素值; 类型 4: Paeth过滤, 对左方像素、 上方像素及左上方像素进行 简单的线性函数计算, 然后选择最接近预设值像素, 并将其作为过滤结果。
预设的压縮参数为: Zl ib 是用于资料压縮的函数库, 使用无损压縮 LZ77 的变种算法 deflate, PNG的图像数据块 IDAT通常使用 Zl ib-def late压縮。 Deflate有如下 4个参数, 会影响压縮后的文件大小: 压縮级别 (Zl ib Compression Level ) ; 压縮策略 (Zl ib Compression Strategy);内存级别(Zl ib Memory Level );浮动窗口大小(Zl ib Window Size)。 这 4个参数分别都有若干个数值可以选取。
遍历选择 N组不同的 PNG过滤类型和压縮参数组合, 使用压縮率最大的结果作为最后 的结果输出。 过滤类型和 Zl ib压縮参数选取的好坏都会对压縮效果产生很大影响, 而它们 不同参数的组合方式有很多种, 去尝试每一种是非常耗时的。 优选的, 经过实验发现, 尝 试一定种类的组合参数与尝试所有的组合参数得到的结果压縮率不会相差很多, 遍历的预 设次数目前选取为 24次。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例四
本发明实施例提供了一种无损压縮图片的装置, 参见图 4, 所述装置包括:
第一去除模块 401, 用于根据预设方式去除图片的辅助信息以及冗余信息;
解压縮模块 402, 用于将所述图片进行解压縮处理, 还原所述图片的原始图片数据; 压縮模块 403, 用于对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮 前的格式类型图片。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 实施例五
本发明实施例提供了一种无损压縮图片的装置, 参见图 5, 所述装置包括: 第一去除模块 501, 用于根据预设方式去除图片的辅助信息以及冗余信息; 解压縮模块 502, 用于将所述图片进行解压縮处理, 还原所述图片的原始图片数据; 压縮模块 503, 用于对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮 前的格式类型图片。
其中, 在所述具体实施方式中, 所述第一去除模块 501, 包括:
第一去除单元 5011, 用于当所述图片为 JPEG格式时, 去除所述图片中的辅助信息。 其中, 压縮模块 503, 包括:
设置单元 5031, 用于当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率 大于预设分辨率的所述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
第一压縮单元 5032, 用于设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据 进行压縮。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例六
本发明实施例提供了一种无损压縮图片的装置, 参见图 6, 所述装置包括: 第一去除模块 601, 用于根据预设方式去除图片的辅助信息以及冗余信息; 解压縮模块 602, 用于将所述图片进行解压縮处理, 还原所述图片的原始图片数据; 压縮模块 603, 用于对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮 前的格式类型图片。
其中, 在具体是实施方式中, 所述第一去除模块 601, 包括:
第二去除单元 6011, 用于当所述图片为 PNG格式时, 去除所述图片中的辅助信息; 判断单元 6012, 用于判断所述图片的辅助块中是否含有透明通道数据;
第三去除单元 6013, 用于若含有透明通道数据, 则将所述图片的辅助块中除透明通道 数据以外的其他数据作为冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素 点的 RGB颜色值修改为预设的颜色值; 第四去除单元 6014, 用于若未含有透明通道数据, 则将所述图片的辅助块作为冗余数 据进行去除。
其中, 压縮模块 603, 包括:
第二压縮单元 6031, 用于当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过 滤类型和预设的压縮参数中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从 中选取压縮率最大的结果作为压縮后的结果。
所述装置还包括:
转换模块 604, 用于当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片 数据中色彩深度参数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图 片数据, 转换成为调色板类型;
查询模块 605,用于查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关 键块中调色板数据块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对 应像素点颜色值的条目;
第二去除模块 606, 用于若存在重复的条目, 则去除关键块中调色板数据块中重复的条 目;
第三去除模块 607, 用于若存在未对应像素点颜色值的条目, 则去除关键块中调色板数 据块中未对应像素点颜色值的条目。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例七
本发明实施例提供的一种终端的结构示意图, 参见图 7, 其示出了本发明实施例所涉及 的具有触敏表面的结构示意图, 该终端可以用于实施上述实施例中提供的无损压縮图片的 方法, 具体来讲:
终端 700可以包括 RF ( Radio Frequency, 射频) 电路 110、 包括有一个或一个以上计 算机可读存储介质的存储器 120、输入单元 130、显示单元 140、传感器 150、音频电路 160、 传输模块 170、 包括有一个或者一个以上处理核心的处理器 180、 以及电源 190等部件。 本 领域技术人员可以理解, 图 7 中示出的终端结构并不构成对终端的限定, 可以包括比图示 更多或更少的部件, 或者组合某些部件, 或者不同的部件布置。 其中:
RF电路 110可用于收发信息或通话过程中, 信号的接收和发送, 特别地, 将基站的下 行信息接收后, 交由一个或者一个以上处理器 180 处理; 另外, 将涉及上行的数据发送给 基站。 通常, RF电路 110包括但不限于天线、 至少一个放大器、 调谐器、 一个或多个振荡 器、 用户身份模块 (SIM) 卡、 收发信机、 耦合器、 LNA ( Low Noi se Ampl ifier, 低噪声放 大器)、 双工器等。 此外, RF电路 110还可以通过无线通信与网络和其他设备通信。 所述无 线通信可以使用任一通信标准或协议, 包括但不限于 GSM (Global System of Mob i le communicat ion, 全球移动通讯系统)、 GPRS (General Packet Radio Service , 通用分组无 线服务) CDMA (Code Divi s ion Mult iple Access ,码分多址) WCDMA (Wideband Code Divi s ion Mult iple Access, 宽带码分多址)、 LTE (Long Term Evolut ion,长期演进)、 电子邮件、 SMS (Short Messaging Service , 短消息服务)等。
存储器 120 可用于存储软件程序以及模块, 如实施例三中提高应用程序运行速度的装 置所对应的软件程序以及模块, 处理器 180通过运行存储在存储器 120的软件程序以及模 块, 从而执行各种功能应用以及数据处理, 如实现应用程序运行速度的提高等。 存储器 120 可主要包括存储程序区和存储数据区, 其中, 存储程序区可存储操作系统、 至少一个功能 所需的应用程序 (比如声音播放功能、 图像播放功能等) 等; 存储数据区可存储根据终端 700的使用所创建的数据 (比如音频数据、 电话本等)等。 此外, 存储器 120可以包括高速 随机存取存储器, 还可以包括非易失性存储器, 例如至少一个磁盘存储器件、 闪存器件、 或其他易失性固态存储器件。 相应地, 存储器 120还可以包括存储器控制器, 以提供处理 器 180和输入单元 130对存储器 120的访问。
输入单元 130 可用于接收输入的数字或字符信息, 以及产生与用户设置以及功能控制 有关的键盘、 鼠标、 操作杆、 光学或者轨迹球信号输入。 具体地, 输入单元 130 可包括触 敏表面 131以及其他输入设备 132。 触敏表面 131, 也称为触摸显示屏或者触控板, 可收集 用户在其上或附近的触摸操作 (比如用户使用手指、 触笔等任何适合的物体或附件在触敏 表面 131上或在触敏表面 131附近的操作), 并根据预先设定的程式驱动相应的连接装置。 可选的, 触敏表面 131 可包括触摸检测装置和触摸控制器两个部分。 其中, 触摸检测装置 检测用户的触摸方位, 并检测触摸操作带来的信号, 将信号传送给触摸控制器; 触摸控制 器从触摸检测装置上接收触摸信息, 并将它转换成触点坐标, 再送给处理器 180, 并能接收 处理器 180发来的命令并加以执行。 此外, 可以采用电阻式、 电容式、 红外线以及表面声 波等多种类型实现触敏表面 131。 除了触敏表面 131, 输入单元 130还可以包括其他输入设 备 132。 具体地, 其他输入设备 132可以包括但不限于物理键盘、 功能键(比如音量控制按 键、 开关按键等)、 轨迹球、 鼠标、 操作杆等中的一种或多种。
显示单元 140可用于显示由用户输入的信息或提供给用户的信息以及终端 700的各种 图形用户接口, 这些图形用户接口可以由图形、 文本、 图标、 视频和其任意组合来构成。 显示单元 140可包括显示面板 141, 可选的, 可以采用 LCD (Liquid Crystal Display, 液 晶显示器)、 OLED (Organic Light-Emitting Diode,有机发光二极管)等形式来配置显示面 板 141。 进一步的, 触敏表面 131可覆盖显示面板 141, 当触敏表面 131检测到在其上或附 近的触摸操作后, 传送给处理器 180以确定触摸事件的类型, 随后处理器 180根据触摸事 件的类型在显示面板 141上提供相应的视觉输出。 虽然在图 7中, 触敏表面 131与显示面 板 141 是作为两个独立的部件来实现输入和输入功能, 但是在某些实施例中, 可以将触敏 表面 131与显示面板 141集成而实现输入和输出功能。
终端 700还可包括至少一种传感器 150, 比如光传感器、 运动传感器以及其他传感器。 具体地, 光传感器可包括环境光传感器及接近传感器, 其中, 环境光传感器可根据环境光 线的明暗来调节显示面板 141 的亮度, 接近传感器可在终端 700移动到耳边时, 关闭显示 面板 141和 /或背光。 作为运动传感器的一种, 重力加速度传感器可检测各个方向上 (一般 为三轴) 加速度的大小, 静止时可检测出重力的大小及方向, 可用于识别手机姿态的应用 (比如横竖屏切换、 相关游戏、磁力计姿态校准)、 振动识别相关功能(比如计步器、 敲击) 等; 至于终端 700还可配置的陀螺仪、 气压计、 湿度计、 温度计、 红外线传感器等其他传 感器, 在此不再赘述。
音频电路 160、 扬声器 161, 传声器 162可提供用户与终端 700之间的音频接口。 音频 电路 160可将接收到的音频数据转换后的电信号, 传输到扬声器 161, 由扬声器 161转换为 声音信号输出; 另一方面, 传声器 162 将收集的声音信号转换为电信号, 由音频电路 160 接收后转换为音频数据, 再将音频数据输出处理器 180处理后, 经 RF电路 110以发送给比 如另一终端, 或者将音频数据输出至存储器 120以便进一步处理。 音频电路 160还可能包 括耳塞插孔, 以提供外设耳机与终端 700的通信。
终端 700通过传输模块 170可以帮助用户收发电子邮件、 浏览网页和访问流式媒体等, 它为用户提供了无线或有线的宽带互联网访问。虽然图 7示出了传输模块 170, 但是可以理 解的是, 其并不属于终端 700 的必须构成, 完全可以根据需要在不改变发明的本质的范围 内而省略。
处理器 180是终端 700的控制中心, 利用各种接口和线路连接整个手机的各个部分, 通过运行或执行存储在存储器 120内的软件程序和 /或模块, 以及调用存储在存储器 120内 的数据, 执行终端 700 的各种功能和处理数据, 从而对手机进行整体监控。 可选的, 处理 器 180可包括一个或多个处理核心; 优选的, 处理器 180可集成应用处理器和调制解调处 理器, 其中, 应用处理器主要处理操作系统、 用户界面和应用程序等, 调制解调处理器主 要处理无线通信。 可以理解的是, 上述调制解调处理器也可以不集成到处理器 180中。 终端 700还包括给各个部件供电的电源 190 (比如电池), 优选的, 电源可以通过电源 管理系统与处理器 180逻辑相连, 从而通过电源管理系统实现管理充电、 放电、 以及功耗 管理等功能。 电源 190还可以包括一个或一个以上的直流或交流电源、 再充电系统、 电源 故障检测电路、 电源转换器或者逆变器、 电源状态指示器等任意组件。
尽管未示出, 终端 700还可以包括摄像头、 蓝牙模块等, 在此不再赘述。 具体在本实 施例中, 终端的显示单元是触摸屏显示器, 终端还包括有存储器, 以及一个或者一个以上 的程序, 其中一个或者一个以上程序存储于存储器中, 且经配置以由一个或者一个以上处 理器执行述一个或者一个以上程序包含用于进行以下操作的指令:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。 假设上述为第一种可能的实施方式, 则在第一种可能的实施方式作为基础而提供的第 二种可能的实施方式中, 所述终端的存储器中, 还包含用于执行以下操作的指令:
当所述图片为 JPEG格式时, 去除所述图片中的辅助信息。
在第一种可能的实施方式作为基础而提供的第三种可能的实施方式中, 所述终端的存 储器中, 还包含用于执行以下操作的指令:
当所述图片为 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为 冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的 RGB颜色值修改为预 设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
在第一种可能的实施方式作为基础而提供的第四种可能的实施方式中, 所述终端的存 储器中, 还包含用于执行以下操作的指令:
当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于预设分辨率的所 述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
在第一种可能的实施方式作为基础而提供的第五种可能的实施方式中, 所述终端的存 储器中, 还包含用于执行以下操作的指令:
当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数 中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果 作为压縮后的结果。
在第五种可能的实施方式作为基础而提供的第六种可能的实施方式中, 所述终端的存 储器中, 还包含用于执行以下操作的指令:
当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参 数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为 调色板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据 块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的 条目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜 色值的条目。
综上所述, 本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮 后, 重新根据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节 省了存储空间。 实施例八
本发明实施例提供了一种计算机可读存储介质, 该计算机可读存储介质可以是上述实 施例中的存储器中所包含的计算机可读存储介质; 也可以是单独存在, 未装配入终端中的 计算机可读存储介质。 所述计算机可读存储介质存储有一个或者一个以上程序, 所述一个 或者一个以上程序被一个或者一个以上的处理器用来执行一个无损压縮图片的方法, 所述 方法包括:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。 假设上述为第一种可能的实施方式, 则在第一种可能的实施方式作为基础而提供的第 二种可能的实施方式中, 所述根据预设方式去除图片的辅助信息以及冗余信息, 包括: 当所述图片为 JPEG格式时, 去除所述图片中的辅助信息。
在第一种可能的实施方式作为基础而提供的第三种可能的实施方式中, 所述根据预设 方式去除图片的辅助信息以及冗余信息, 包括: 当所述图片为 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为 冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的 RGB颜色值修改为预 设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
在第一种可能的实施方式作为基础而提供的第四种可能的实施方式中, 所述对所述图 片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于预设分辨率的所 述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
在第一种可能的实施方式作为基础而提供的第五种可能的实施方式中, 所述对所述图 片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数 中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果 作为压縮后的结果。
在第五种可能的实施方式作为基础而提供的第六种可能的实施方式中, 所述对所述图 片的原始图片数据设置压縮参数, 重新压縮为所述图片解压縮前的格式类型图片之前, 所 述方法还包括:
当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参 数小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为 调色板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据 块中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的 条目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜 色值的条目。
本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 实施例九
本发明实施例中提供了一种图形用户接口, 所述图形用户接口用在终端上, 所述终端 包括触摸屏显示器、 存储器和用于执行一个或者一个以上的程序的一个或者一个以上的处 理器; 所述图形用户接口包括:
在所述触摸屏显示器上根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。 本发明实施例通过去除图片的辅助数据以及冗余数据, 对图片进行解压縮后, 重新根 据预设的压縮参数进行压縮, 在无损压縮的基础上, 提高了图片的压縮率, 节省了存储空 间。 需要说明的是: 上述实施例提供的无损压縮图片的装置在无损压縮图片时, 仅以上述 各功能模块的划分进行举例说明, 实际应用中, 可以根据需要而将上述功能分配由不同的 功能模块完成, 即将装置的内部结构划分成不同的功能模块, 以完成以上描述的全部或者 部分功能。 另外, 上述实施例提供的无损压縮图片的装置与无损压縮图片的方法实施例属 于同一构思, 其具体实现过程详见方法实施例, 这里不再赘述。
上述本发明实施例序号仅仅为了描述, 不代表实施例的优劣。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完 成, 也可以通过程序来指令相关的硬件完成, 所述的程序可以存储于一种计算机可读存储 介质中, 上述提到的存储介质可以是只读存储器, 磁盘或光盘等。
以上所述仅为本发明的较佳实施例, 并不用以限制本发明, 凡在本发明的精神和原则 之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。

Claims

权 利 要 求 书
1、 一种无损压缩图片的方法, 其特征在于, 所述方法包括:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。
2、根据权利要求 1所述的方法, 其特征在于, 所述根据预设方式去除图片的辅助信息以 及冗余信息, 包括:
当所述图片为联合照片专家组 JPEG格式时, 去除所述图片中的辅助信息。
3、根据权利要求 1所述的方法, 其特征在于, 所述根据预设方式去除图片的辅助信息以 及冗余信息, 包括:
当所述图片为流式网络图形格式 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为冗 余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的红绿蓝 RGB颜色值修改为 预设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
4、根据权利要求 1所述的方法, 其特征在于, 所述对所述图片的原始图片数据设置压縮 参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 JPEG格式时,为所述图片的分辨率大于预设分辨率的所述 图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
5、根据权利要求 1所述的方法, 其特征在于, 所述对所述图片的原始图片数据设置压縮 参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数中 选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果作为 压縮后的结果。
6、根据权利要求 5所述的方法, 其特征在于, 所述对所述图片的原始图片数据设置压縮 参数, 重新压縮为所述图片解压縮前的格式类型图片之前, 所述方法还包括:
当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参数 小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为调色 板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据块 中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的条 目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜色 值的条目。
7、 一种无损压縮图片的装置, 其特征在于, 所述装置包括:
第一去除模块, 用于根据预设方式去除图片的辅助信息以及冗余信息;
解压縮模块, 用于将所述图片进行解压縮处理, 还原所述图片的原始图片数据; 压縮模块, 用于对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的 格式类型图片。
8、 根据权利要求 7所述的装置, 其特征在于, 所述第一去除模块, 包括:
第一去除单元, 用于当所述图片为联合照片专家组 JPEG格式时, 去除所述图片中的辅助 信息。
9、 根据权利要求 7所述的装置, 其特征在于, 所述第一去除模块, 包括:
第二去除单元, 用于当所述图片为流式网络图形格式 PNG格式时, 去除所述图片中的辅 助信息;
判断单元, 用于判断所述图片的辅助块中是否含有透明通道数据;
第三去除单元, 用于若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以 外的其他数据作为冗余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的红绿 蓝 RGB颜色值修改为预设的颜色值;
第四去除单元, 用于若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行
10、 根据权利要求 7所述的装置, 其特征在于, 所述压縮模块, 包括:
设置单元, 用于当所述图片解压縮前的格式为 JPEG格式时, 为所述图片的分辨率大于预 设分辨率的所述图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
第一压縮单元, 用于设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压 縮。
11、 根据权利要求 7所述的装置, 其特征在于, 所述压縮模块, 包括:
第二压縮单元, 用于当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型 和预设的压縮参数中选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压 縮率最大的结果作为压縮后的结果。
12、 根据权利要求 11所述的装置, 其特征在于, 所述装置还包括:
转换模块, 用于当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据 中色彩深度参数小于或等于预设位,且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为调色板类型;
查询模块, 用于查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块 中调色板数据块中是否包含重复的条目,和 /或关键块的调色板数据块中是否存在未对应像素 点颜色值的条目;
第二去除模块, 用于若存在重复的条目, 则去除关键块中调色板数据块中重复的条目; 第三去除模块, 用于若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块 中未对应像素点颜色值的条目。
13、 一种终端, 其特征在于, 所述终端包括: 触摸屏显示器、 一个或者一个以上的处理 器; 存储器; 以及一个或者一个以上的程序, 其中所述一个或者一个以上程序存储于所述存 储器中, 且经配置以由所述一个或者一个以上处理器执行, 所述一个或者一个以上程序包含 用于进行以下操作的指令:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。
14、 根据权利要求 13所述的终端, 其特征在于, 包含用于执行以下操作的指令: 当所述图片为联合照片专家组 JPEG格式时, 去除所述图片中的辅助信息。
15、 根据权利要求 13所述的终端, 其特征在于, 包含用于执行以下操作的指令: 当所述图片为流式网络图形格式 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为冗 余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的红绿蓝 RGB颜色值修改为 预设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
16、 根据权利要求 13所述的终端, 其特征在于, 包含用于执行以下操作的指令: 当所述图片解压縮前的格式为 JPEG格式时,为所述图片的分辨率大于预设分辨率的所述 图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
17、 根据权利要求 13所述的终端, 其特征在于, 包含用于执行以下操作的指令: 当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数中 选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果作为 压縮后的结果。
18、 根据权利要求 17所述的终端, 其特征在于, 包含用于执行以下操作的指令: 当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参数 小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为调色 板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据块 中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的条 目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜色 值的条目
19、 一种计算机可读存储介质, 其特征在于, 所述计算机可读存储介质存储有一个或者 一个以上程序, 所述一个或者一个以上程序被一个或者一个以上的处理器用来执行一个无损 压縮图片的方法, 所述方法包括:
根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。
20、根据权利要求 19所述的计算机可读存储介质, 其特征在于, 所述根据预设方式去除 图片的辅助信息以及冗余信息, 包括:
当所述图片为联合照片专家组 JPEG格式时, 去除所述图片中的辅助信息。
21、根据权利要求 19所述的计算机可读存储介质, 所述根据预设方式去除图片的辅助信 息以及冗余信息, 包括:
当所述图片为流式网络图形格式 PNG格式时, 去除所述图片中的辅助信息;
判断所述图片的辅助块中是否含有透明通道数据;
若含有透明通道数据, 则将所述图片的辅助块中除透明通道数据以外的其他数据作为冗 余数据进行去除, 并将所述图片中透明通道数据中透明的像素点的红绿蓝 RGB颜色值修改为 预设的颜色值;
若未含有透明通道数据, 则将所述图片的辅助块作为冗余数据进行去除。
22、根据权利要求 19所述的计算机可读存储介质, 其特征在于, 所述对所述图片的原始 图片数据设置压縮参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 JPEG格式时,为所述图片的分辨率大于预设分辨率的所述 图片的原始图片数据, 设置渐进式 JPEG格式的压縮参数;
设置哈夫曼编码的压縮参数, 并对所述图片的原始图片数据进行压縮。
23、根据权利要求 19所述的计算机可读存储介质, 其特征在于, 所述对所述图片的原始 图片数据设置压縮参数, 压縮为所述图片解压縮前的格式图片, 包括:
当所述图片解压縮前的格式为 PNG格式时, 分别从预设的过滤类型和预设的压縮参数中 选取多种组合, 对所述图片进行遍历压縮, 经过预设次数后从中选取压縮率最大的结果作为 压縮后的结果。
24、根据权利要求 23所述的计算机刻度存储介质, 其特征在于, 所述对所述图片的原始 图片数据设置压縮参数, 重新压縮为所述图片解压縮前的格式类型图片之前, 所述方法还包 括:
当所述图片解压縮前的格式为 PNG格式时, 将所述图片的原始图片数据中色彩深度参数 小于或等于预设位, 且 PNG类型为非调色板类型的所述图片的原始图片数据, 转换成为调色 板类型;
查询所述图片的原始图片数据中 PNG类型为调色板类型的图片的关键块中调色板数据块 中是否包含重复的条目, 和 /或关键块的调色板数据块中是否存在未对应像素点颜色值的条 目;
若存在重复的条目, 则去除关键块中调色板数据块中重复的条目;
若存在未对应像素点颜色值的条目, 则去除关键块中调色板数据块中未对应像素点颜色 值的条目。
25、 一种图形用户接口, 其特征在于, 所述图形用户接口用在终端上, 所述终端包括触 摸屏显示器、 存储器和用于执行一个或者一个以上的程序的一个或者一个以上的处理器; 所 述图形用户接口包括:
在所述触摸屏显示器上根据预设方式去除图片的辅助信息以及冗余信息;
将所述图片进行解压縮处理, 还原所述图片的原始图片数据;
对所述图片的原始图片数据设置压縮参数, 压縮为所述图片解压縮前的格式类型图片。
PCT/CN2013/086484 2012-11-19 2013-11-04 一种无损压缩图片的方法和装置 WO2014075567A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US14/716,557 US9710929B2 (en) 2012-11-19 2015-05-19 Method and apparatus for lossless image compression

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210468024.0 2012-11-19
CN201210468024.0A CN103826028B (zh) 2012-11-19 2012-11-19 一种无损压缩图片的方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/716,557 Continuation US9710929B2 (en) 2012-11-19 2015-05-19 Method and apparatus for lossless image compression

Publications (1)

Publication Number Publication Date
WO2014075567A1 true WO2014075567A1 (zh) 2014-05-22

Family

ID=50730582

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/086484 WO2014075567A1 (zh) 2012-11-19 2013-11-04 一种无损压缩图片的方法和装置

Country Status (3)

Country Link
US (1) US9710929B2 (zh)
CN (1) CN103826028B (zh)
WO (1) WO2014075567A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113068043A (zh) * 2020-01-02 2021-07-02 武汉金山办公软件有限公司 一种png图像压缩方法、装置、电子设备及存储介质
CN115883839A (zh) * 2023-03-09 2023-03-31 湖北芯擎科技有限公司 一种图像校验方法、装置、设备及计算机可读存储介质

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11330297B2 (en) 2014-08-19 2022-05-10 Qualcomm Incorporated Methods incorporating extensions to copy-above mode for palette mode coding
CN105491398B (zh) * 2014-09-19 2019-06-28 腾讯科技(深圳)有限公司 图片处理方法、图片处理装置以及图片处理平台
CN105430393B (zh) * 2014-09-19 2020-02-11 腾讯科技(深圳)有限公司 一种图片处理方法、图片处理装置、图片处理平台以及存储介质
WO2016106553A1 (zh) * 2014-12-30 2016-07-07 富士通株式会社 图像编码方法、装置以及图像处理设备
CN106611432B (zh) * 2015-10-21 2020-09-04 深圳市腾讯计算机系统有限公司 一种图片格式转换方法、装置和系统
CN105812714A (zh) * 2016-03-18 2016-07-27 浙江万朋教育科技股份有限公司 一种用于共享ppt文档页面的数据压缩方法
CN108111858B (zh) * 2016-11-24 2020-06-05 腾讯科技(深圳)有限公司 一种图片压缩方法及装置
CN108536707A (zh) * 2017-03-03 2018-09-14 绍兴读图网络科技有限公司 图片信息安全处理方法及系统
CN109089162B (zh) * 2017-04-08 2021-05-28 腾讯科技(深圳)有限公司 一种图片文件处理方法及系统
US10348897B2 (en) * 2017-06-27 2019-07-09 Avaya Inc. System and method for reducing storage space in a contact center
CN108846872A (zh) * 2018-07-09 2018-11-20 苏州浪潮智能软件有限公司 一种图像处理方法及装置
CN109272449A (zh) * 2018-08-20 2019-01-25 中国平安人寿保险股份有限公司 图片显示方法及装置、计算机装置及可读存储介质
CN110288670B (zh) * 2019-06-19 2023-06-23 杭州绝地科技股份有限公司 一种ui描边特效的高性能渲染方法
CN112929621A (zh) * 2021-01-20 2021-06-08 深圳市瑞驰信息技术有限公司 一种基于哈夫曼算法提升图片压缩传输的方法
CN113473150B (zh) * 2021-07-08 2022-11-22 浙江大华技术股份有限公司 一种图像处理方法、装置以及计算机可读存储装置
CN113626395A (zh) * 2021-07-09 2021-11-09 深圳市国华光电科技有限公司 数据压缩方法、装置、电子设备及存储介质
CN113568578B (zh) * 2021-07-27 2023-10-10 北京奇艺世纪科技有限公司 一种图片处理方法、装置、电子设备和可读存储介质
CN114339226B (zh) * 2021-12-28 2024-02-09 山东云海国创云计算装备产业创新中心有限公司 一种提高画面的流畅度的方法、装置及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017533A (zh) * 2007-03-09 2007-08-15 清华大学 印刷体蒙古文字符识别方法
CN101109814A (zh) * 2007-08-28 2008-01-23 北京交通大学 缺乏高精度运动补偿系统下实现机载雷达重聚焦成像方法
CN102223534A (zh) * 2011-06-03 2011-10-19 东南大学 用于图像压缩的全并行位平面编码方法
CN102244784A (zh) * 2011-06-09 2011-11-16 杭州典能科技有限公司 含透明信息图片压缩和显示的方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6121903A (en) * 1998-01-27 2000-09-19 Infit Communications Ltd. On-the-fly data re-compression
US8571311B2 (en) * 2011-12-15 2013-10-29 Microsoft Corporation Raster graphics image transcoding for file size reduction

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101017533A (zh) * 2007-03-09 2007-08-15 清华大学 印刷体蒙古文字符识别方法
CN101109814A (zh) * 2007-08-28 2008-01-23 北京交通大学 缺乏高精度运动补偿系统下实现机载雷达重聚焦成像方法
CN102223534A (zh) * 2011-06-03 2011-10-19 东南大学 用于图像压缩的全并行位平面编码方法
CN102244784A (zh) * 2011-06-09 2011-11-16 杭州典能科技有限公司 含透明信息图片压缩和显示的方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113068043A (zh) * 2020-01-02 2021-07-02 武汉金山办公软件有限公司 一种png图像压缩方法、装置、电子设备及存储介质
CN113068043B (zh) * 2020-01-02 2024-04-30 武汉金山办公软件有限公司 一种png图像压缩方法、装置、电子设备及存储介质
CN115883839A (zh) * 2023-03-09 2023-03-31 湖北芯擎科技有限公司 一种图像校验方法、装置、设备及计算机可读存储介质
CN115883839B (zh) * 2023-03-09 2023-06-06 湖北芯擎科技有限公司 一种图像校验方法、装置、设备及计算机可读存储介质

Also Published As

Publication number Publication date
US20150287217A1 (en) 2015-10-08
CN103826028A (zh) 2014-05-28
US9710929B2 (en) 2017-07-18
CN103826028B (zh) 2017-08-25

Similar Documents

Publication Publication Date Title
WO2014075567A1 (zh) 一种无损压缩图片的方法和装置
TWI674790B (zh) 一種影像資料的編碼、解碼方法及裝置
US10986332B2 (en) Prediction mode selection method, video encoding device, and storage medium
RU2602791C2 (ru) Способ, устройство и система набора
WO2018036352A1 (zh) 视频数据的编解码方法、装置、系统及存储介质
WO2019114724A1 (zh) 一种相机缩略图生成的方法、移动终端及存储介质
CN106844580B (zh) 一种缩略图的生成方法、装置及移动终端
JP2004348945A (ja) データ圧縮機能を有する取外し可能記憶装置
WO2018171328A1 (zh) 数据传输方法及终端
US9781380B2 (en) Method, apparatus and terminal for playing multimedia content
CN113556492B (zh) 缩略图生成方法、移动终端及可读存储介质
WO2014190830A1 (zh) 录音同步方法、装置和设备
CN105430393B (zh) 一种图片处理方法、图片处理装置、图片处理平台以及存储介质
WO2019001015A1 (zh) 一种图像数据的编码、解码方法及装置
CN110418209B (zh) 一种应用于视频传输的信息处理方法及终端设备
CN110933289A (zh) 一种基于双目相机的连拍方法、拍照装置和终端设备
CN1863297A (zh) 在便携式终端显示图像数据的方法
WO2024098873A1 (zh) 处理方法、处理设备及存储介质
CN106961612B (zh) 一种图像处理方法及设备
KR20160131831A (ko) 클라우드 스트리밍 서비스 시스템, 이미지의 투명도에 기반한 이미지 클라우드 스트리밍 서비스 방법 및 이를 위한 장치
US20110161514A1 (en) Method and apparatus for delegating computationally intensive functions
KR101247770B1 (ko) 가상 화이트보드 데이터 처리 장치와 그 방법
CN1940844A (zh) 在无线终端中使用鼠标功能来控制数据的方法
WO2022179600A1 (zh) 视频编码方法、视频解码方法、装置及电子设备
CN114022343A (zh) 资源加载方法、终端和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13855818

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS (EPO FORM 1205A DATED 08-10-2015)

122 Ep: pct application non-entry in european phase

Ref document number: 13855818

Country of ref document: EP

Kind code of ref document: A1