CN110113617A - A kind of method and device of compression of images and decompression - Google Patents

A kind of method and device of compression of images and decompression Download PDF

Info

Publication number
CN110113617A
CN110113617A CN201910510161.8A CN201910510161A CN110113617A CN 110113617 A CN110113617 A CN 110113617A CN 201910510161 A CN201910510161 A CN 201910510161A CN 110113617 A CN110113617 A CN 110113617A
Authority
CN
China
Prior art keywords
image
frame image
pixel
data
difference 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.)
Granted
Application number
CN201910510161.8A
Other languages
Chinese (zh)
Other versions
CN110113617B (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910510161.8A priority Critical patent/CN110113617B/en
Publication of CN110113617A publication Critical patent/CN110113617A/en
Application granted granted Critical
Publication of CN110113617B publication Critical patent/CN110113617B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/182Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a pixel
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/186Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a colour or a chrominance component
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/44Decoders specially adapted therefor, e.g. video decoders which are asymmetric with respect to the encoder

Landscapes

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

Abstract

The embodiment of the invention discloses a kind of compression of images and decompression method and device, this method comprises: obtaining at least one image pair in target image, each image is to the two field pictures for including arbitrary neighborhood in the target image;It determines the pixel difference data between the two field pictures of at least one image pair, which is ranked up, the corresponding compressed data of the condensed frame image pixel difference data after sequence being determined as in the target image;The condensed frame image is the frame image in the target image other than first frame image;First frame image in the multiple image and the compressed data are synthesized into the corresponding compression image of the target image.This method further includes that the compression image to generation is decompressed by obtaining pixel difference data.Using the present invention, it is possible to reduce the bandwagon effect for guaranteeing image itself while image size effectively realizes the lossless compression of image, and reduces the network transmission consumption of image in the application.

Description

A kind of method and device of compression of images and decompression
Technical field
The present invention relates to field of computer technology more particularly to the method and devices of a kind of compression of images and decompression.
Background technique
With the rapidly development of internet, amusement, study, work of people etc. all be unable to do without internet, therefore occur More and more websites or application etc., to meet the needs of people's various aspects.Just because of website or application etc. increase, same Field generally all more than one internet product, and generally will not change especially using the number of the internet product in the field Greatly, these internet products are just needed to optimize from function and vision etc. to enhance user's viscosity, to improve Flow.From studies have shown that people are generally more deep to the memory or impression of image, video etc., also allow for more interconnecting Net product can more focus on the page presentation effect of oneself, but since the display effect of image or video etc. is better, itself Storage volume is bigger, and required transmission is time-consuming longer, especially possesses the Dynamic Graph of multiple image, therefore how to realize The storage volume for reducing image while the display effect as small as possible for influencing image becomes a problem of crucial importance.
Nowadays, most of image is all the frame number by reducing image, the unnecessary characteristic point in image is removed, to reach Image is compressed to the storage volume for reducing image, or using Lossy Compression Algorithm, is deposited by the way of lossy compression Picture is stored up, such as webp format, to reach the storage volume for reducing image, although removal is unnecessary characteristic point, but Destroy the data of original image to a certain extent, so as to will lead to image show when occur animation it is not smooth or The problems such as image is serrating.
Summary of the invention
Based on this, this application provides the method and devices of a kind of compression of images and decompression, to improve to Dynamic Graph As the effect of lossless compression.
First aspect of the embodiment of the present invention provides a kind of method for compressing image characterized by comprising
At least one image pair in target image is obtained, the target image includes multiple frame images, each image pair Two field pictures comprising arbitrary neighborhood in the target image;
The pixel difference data between the two field pictures of at least one image pair are determined, by the pixel difference data The corresponding compressed data of condensed frame image being determined as in the target image;The condensed frame image is in the target image Frame image other than first frame image;
First frame image in the multiple image and the compressed data are synthesized into the corresponding compression figure of the target image Picture.
Wherein, the pixel difference data between the two field pictures of at least one image pair described in the determination, by the picture Plain variance data is determined as the corresponding compressed data of condensed frame image in the target image, comprising:
The image of at least one image pair is obtained to Ti, described image is to TiIncluding frame image SiWith frame image Si+1;I is positive integer, and i is less than or equal to m-1, and the m is the quantity of the frame image in the target image;
Determine the frame image SiWith frame image Si+1Pixel difference data between each pixel, the pixel difference heteromerism According to for frame image Si+1In be different from the frame image SiPixel colour information;The frame image Si+1Belong to the compression Frame image;
The pixel difference data are determined as the frame image Si+1Corresponding compressed data, until determining image pair Tm-1In frame image SmCorresponding compressed data.
Wherein it is determined that the frame image SiWith frame image Si+1Pixel difference data between each pixel, comprising:
Compare the frame image SiWith frame image Si+1The colour information of pixel under middle same position information;
When there are the colour information difference of pixel, the different pixel of the colour information is determined as difference pixel Point, according to frame image Si+1Described in the colour information of difference pixel determine the frame image SiWith frame image Si+1Between pixel Variance data.Wherein, frame image SiWith frame image Si+1Between difference pixel quantity and frame image SiWith frame image Si+1Between The quantity of pixel difference data is identical, it is believed that the corresponding pixel difference data of each difference pixel.
Wherein, described according to frame image Si+1Described in the colour information of difference pixel determine the frame image SiAnd frame Image Si+1Between pixel difference data, comprising:
Obtain the frame image Si+1Described in difference pixel colour information and location information;
Position by the Data Format Transform of the location information at the data format of the colour information, after format is converted Confidence breath and the colour information are determined as the frame image SiWith frame image Si+1Between pixel difference data.
Wherein, described that the pixel difference data are determined as the frame image Si+1Corresponding compressed data, comprising:
Based on the difference value between pixel difference data, to the frame image SiWith frame image Si+1Between multiple pixel differences Data are ranked up;
Pixel difference data after sequence are determined as the frame image Si+1Corresponding compressed data.
Wherein, the difference value between the data based on pixel difference, to the frame image SiWith frame image Si+1Between it is multiple Pixel difference data are ranked up, comprising:
Described image is obtained to TiCorresponding pixel difference data sorting queue;
Obtain j-th of pixel difference data and unsorted pixel difference data in the pixel difference data sorting queue Between difference value, by the p pixel difference heteromerism with the difference value of j-th of pixel difference data less than the first discrepancy threshold According to, successively it is ranked up along j-th of pixel difference data, it will be unsorted after ordering pixel difference data and update Pixel difference data are spliced, and updated pixel difference data sorting queue is obtained;P is 0 or positive integer, and p is less than institute State the quantity of pixel difference data;
Pth+j pixel difference data are obtained in the updated pixel difference data sorting queue;
It will be small with the difference value of the pth+j pixel difference data in pixel difference data unsorted after the update In k pixel difference data of first discrepancy threshold, successively it is ranked up along the pth+j pixel difference data, directly To the frame image SiWith frame image Si+1Between be not present unsorted pixel difference data.
Wherein, described that the pixel difference data are determined as the frame image Si+1Corresponding compressed data, comprising:
Determine the length of the first cycling among windows and the length of the second cycling among windows, first cycling among windows and described second There are separator between cycling among windows, first cycling among windows are adjacent with second cycling among windows;
The separator is placed in the first character of the pixel difference data, is determined described in the pixel difference data The maximum matching length of identical characters in first cycling among windows and second cycling among windows, according to the maximum matching length Identical characters generate first compressed node;
The mobile separator L characters, generate next compressed node, until first cycling among windows and described the The separator between two cycling among windows is located at the end character of the pixel difference data, and wherein L is based on described maximum With determined by length;
According to the character for being not belonging to the compressed node in the compressed node and the pixel difference data, institute is generated State frame image Si+1Corresponding compressed data.
Second aspect of the embodiment of the present invention provides a kind of image expansion method characterized by comprising
The first frame image and compressed data in compression image are obtained, the first frame image is the first frame figure in target image Picture, the compressed data are the corresponding compressed data of condensed frame image in the target image, and the condensed frame image is institute State the frame image in target image other than first frame image;
Pixel difference data are determined according to the compressed data, and the target image includes at least one image pair, described Image is to the two field pictures for including arbitrary neighborhood in target image, and the pixel difference data are between the adjacent two field pictures Difference;
Target image is drawn according to the pixel difference data and the first frame image.
It is wherein, described that pixel difference data are determined according to the compressed data, comprising:
Obtain the length of the first cycling among windows and the length of the second cycling among windows, first cycling among windows and described second There are separator between cycling among windows, first cycling among windows are adjacent with second cycling among windows;
The separator is in the first character of the compressed data, slides first cycling among windows and described second Cycling among windows traverse each of compressed data character;
If the character is compressed node, the compressed node is reduced to data convert node;
According to the character for being not belonging to the compressed node in the data convert node and the compressed data, determine described in Pixel difference data.
It is wherein, described to draw target image according to the pixel difference data and the first frame image, comprising:
Draw the first frame image;
According to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data and the frame image SiDraw institute State frame image Si+1, until determining frame image Sm;M is the quantity for multiple frame images that the target image includes, and i is positive integer, And i is less than m;
According to all frame images after drafting, the target image is generated.
Wherein, it is described according to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data and the frame image SiDraw the frame image Si+1, comprising:
Described image is obtained to TiThe location information and colour information of middle pixel difference data determine the frame image Si+1 In difference pixel, the difference pixel be the pixel difference data in the corresponding pixel of location information;
The frame image S is drawn according to the location information of the pixel difference data and colour informationi+1In the difference Pixel;
According to non-difference pixel in the frame image SiIn location information and colour information, draw the frame image Si+1In the non-difference pixel, the frame image S after being drawni+1;The non-difference pixel is the frame image Si Or the frame image Si+1In be the difference pixel pixel.
The third aspect of the embodiment of the present invention provides a kind of image compressing device, comprising:
Module is obtained, for obtaining at least one image pair in target image, the target image includes multiple frame figures Picture, each image is to the two field pictures for including arbitrary neighborhood in the target image;
Determining module, the pixel difference data between two field pictures for determining at least one image pair, by institute State the corresponding compressed data of condensed frame image that pixel difference data are determined as in the target image;The condensed frame image is Frame image in the target image other than first frame image;
Generation module, for first frame image in the multiple image and the compressed data to be synthesized the target image Corresponding compression image.
Wherein, the determining module includes:
Acquiring unit, for obtaining the image of at least one image pair to Ti, described image is to TiIncluding frame image SiWith frame image Si+1;I is positive integer, and i is less than or equal to m-1, and the m is the quantity of the frame image in the target image;
Determination unit, for determining the frame image SiWith frame image Si+1Pixel difference data between each pixel, institute Stating pixel difference data is frame image Si+1In be different from the frame image SiPixel colour information;The frame image Si+1 Belong to the condensed frame image;
The determination unit is also used to for the pixel difference data to be determined as the frame image Si+1Corresponding compression number According to until determining image to Tm-1In frame image SmCorresponding compressed data.
Wherein, the frame image S is being determinediWith frame image Si+1It is described in terms of pixel difference data between each pixel Determination unit includes:
First contrast subunit, for comparing the frame image SiWith frame image Si+1Pixel under middle same position information The colour information of point;
First determines subelement, for when there are the colour information difference of pixel, the colour information is different Pixel is determined as difference pixel, according to frame image Si+1Described in the colour information of difference pixel determine the frame image SiWith frame image Si+1Between pixel difference data.
Wherein, described first determine that subelement is specifically used for:
Obtain the frame image Si+1Described in difference pixel colour information and location information;
Position by the Data Format Transform of the location information at the data format of the colour information, after format is converted Confidence breath and the colour information are determined as the frame image SiWith frame image Si+1Between pixel difference data.
Wherein, the pixel difference data are determined as the frame image S describedi+1In terms of corresponding compressed data, institute Stating determination unit includes:
Second contrast subunit, for based on the difference value between pixel difference data, to the frame image SiWith frame image Si+1Between multiple pixel difference data be ranked up;
Second determines subelement, for the pixel difference data after sequence to be determined as the frame image Si+1Corresponding pressure Contracting data.
Wherein, second contrast subunit is specifically used for:
Described image is obtained to TiCorresponding pixel difference data sorting queue;
Obtain j-th of pixel difference data and unsorted pixel difference data in the pixel difference data sorting queue Between difference value, by the p pixel difference heteromerism with the difference value of j-th of pixel difference data less than the first discrepancy threshold According to, successively it is ranked up along j-th of pixel difference data, it will be unsorted after ordering pixel difference data and update Pixel difference data are spliced, and updated pixel difference data sorting queue is obtained;P is 0 or positive integer, and p is less than institute State the quantity of pixel difference data;
Pth+j pixel difference data are obtained in the updated pixel difference data sorting queue;
It will be small with the difference value of the pth+j pixel difference data in pixel difference data unsorted after the update In k pixel difference data of first discrepancy threshold, successively it is ranked up along the pth+j pixel difference data, directly To the frame image SiWith frame image Si+1Between be not present unsorted pixel difference data.
Wherein, the pixel difference data are determined as the frame image S describedi+1In terms of corresponding compressed data, institute State determination unit further include:
Subelement is obtained, for determining the length of the first cycling among windows and the length of the second cycling among windows, the first pass It goes through there are separator between window and second cycling among windows, first cycling among windows are adjacent with second cycling among windows;
Third determines subelement, for the separator to be placed in the first character of the pixel difference data, determines institute State the maximum matching length of identical characters in the first cycling among windows described in pixel difference data and second cycling among windows;
First generates subelement, for generating first compressed node according to the identical characters of the maximum matching length;
Described first generates subelement, is also used to move the separator L characters, generates next compressed node, directly It is located at the end of the pixel difference data to the separator between first cycling among windows and second cycling among windows Character, wherein L is based on determined by the maximum matching length;
Second generates subelement, for being not belonging to the pressure according in the compressed node and the pixel difference data The character of casing coupling point generates the frame image Si+1Corresponding compressed data.
Fourth aspect of the embodiment of the present invention provides a kind of image decompression compression apparatus, comprising:
Module is obtained, for obtaining first frame image and compressed data in compression image, the first frame image is target figure First frame image as in, the compressed data are the corresponding compressed data of condensed frame image in the target image, the pressure Contracting frame image is the frame image in the target image other than first frame image;
Determining module determines pixel difference data according to the compressed data, and the target image includes at least one figure As right, for described image to the two field pictures for including arbitrary neighborhood in target image, the pixel difference data are described adjacent Difference between two field pictures;
Drafting module, for drawing target image according to the pixel difference data and the first frame image.
Wherein, the determining module includes:
Acquiring unit, for obtaining the length of the first cycling among windows and the length of the second cycling among windows, first traversal There are separator between window and second cycling among windows, first cycling among windows are adjacent with second cycling among windows;
Traversal Unit slides first traversal for the separator to be in the first character of the compressed data Window and second cycling among windows, traverse each of compressed data character;
The compressed node is reduced to data convert node if being compressed node for the character by reduction unit;
First determination unit, for saving according to being not belonging to the compression in the data convert node and the compressed data The character of point, determines the pixel difference data.
Wherein, the drafting module, comprising:
Drawing unit, for drawing the first frame image;
Second determination unit is used for according to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data and institute State frame image SiDraw the frame image Si+1, until determining frame image Sm;M is multiple frame images that the target image includes Quantity, i is positive integer, and i is less than m;
Generation unit, for generating the target image according to all frame images after drafting.
Wherein, second determination unit includes:
Subelement is obtained, for obtaining described image to TiThe location information and colour information of middle pixel difference data;
Subelement is determined, for determining the frame image Si+1In difference pixel, the difference pixel be the picture The corresponding pixel of location information in plain variance data;
Subelement is drawn, for drawing the frame image according to the location information and colour information of the pixel difference data Si+1In the difference pixel;
The drafting subelement is also used to according to non-difference pixel in the frame image SiIn location information and color value Information draws the frame image Si+1In the non-difference pixel, the frame image S after being drawni+1;The non-difference picture Vegetarian refreshments is the frame image SiOr the frame image Si+1In be the difference pixel pixel.
The 5th aspect of the embodiment of the present invention provides a kind of electronic equipment, which is characterized in that including processor, memory;
The processor is connected with the memory, wherein the memory is for storing program code, the processor For calling said program code, to execute the method for compressing image as described in first aspect in the embodiment of the present invention or execute such as Image expansion method described in second aspect in the embodiment of the present invention.
The 6th aspect of the embodiment of the present invention provides computer storage medium, which is characterized in that the computer storage is situated between Matter is stored with computer program, and the computer program includes program instruction, and described program is instructed when being executed by a processor, held Method for compressing image or execution of the row as described in first aspect in the embodiment of the present invention are such as second aspect institute in the embodiment of the present invention The image expansion method stated.
Implement the embodiment of the present invention, will have the following beneficial effects:
The embodiment of the present invention includes more by analysis such as GIF image when getting the target image comprising multiple image Different frame image in the target image of frame image, extracts the color in the target image between consecutive frame image between difference pixel Value information and corresponding location information, according between each difference pixel got colour information and location information determine picture Plain variance data, and the pixel difference data are stored by lossless compression algorithm storage, by the pixel after lossless compression Variance data is determined as the corresponding compressed data of condensed frame image in target image, condensed frame image be in target image in addition to First frame image in target image and compressed data are synthesized the corresponding compression figure of target image by the frame image except first frame image Picture, to effectively realize the lossless compression to target image.Due to being to extract pixel difference heteromerism on the basis of previous frame image According to, by the pixel difference data extracted carry out lossless compression, the corresponding compressed data of condensed frame image is obtained, thus reducing The bandwagon effect for guaranteeing image itself while image size effectively realizes the lossless compression of image, and then reduces image in net Network transmission consumption in standing or applying.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Wherein:
Fig. 1 is a kind of interaction schematic diagram of method for compressing image provided in an embodiment of the present invention;
Fig. 2 is a kind of composition schematic diagram of target image provided in an embodiment of the present invention;
Fig. 3 is a kind of method flow schematic diagram of compression of images provided in an embodiment of the present invention;
Fig. 4 is a kind of specific implementation flow schematic diagram of method for compressing image provided in an embodiment of the present invention;
Fig. 5 is a kind of pixel data format provided in an embodiment of the present invention;
Fig. 6 is a kind of character string compression schematic diagram provided in an embodiment of the present invention;
Fig. 7 a is a kind of colour information schematic diagram of partial pixel point for extracting image provided in an embodiment of the present invention;
Fig. 7 b is the colour information schematic diagram of another partial pixel point for extracting image provided in an embodiment of the present invention;
Fig. 8 is a kind of schematic diagram of function logic module provided in an embodiment of the present invention;
Fig. 9 is a kind of image decompressor flow diagram provided in an embodiment of the present invention;
Figure 10 is a kind of image compressing device provided in an embodiment of the present invention;
Figure 11 is a kind of image decompression compression apparatus provided in an embodiment of the present invention;
Figure 12 is the structural schematic diagram of electronic equipment provided by the embodiments of the present application.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
Wherein, some proper nouns being previously mentioned in the embodiment of the present invention are explained as follows:
1, GIF:Graphics Interchange Format, graphic interchange format are a kind of companies based on lzw algorithm The nondestructive compression type of continuous tone, for compression ratio generally 50% or so, it is not belonging to any application program, can deposit several coloured silks Chromatic graph picture is a kind of Dynamic Graph comprising multiple image.
2, LZW, Lempel-Ziv-Welch Encoding, string list compression algorithm, be by establishing a string table, Longer character string is indicated with shorter code to realize compression.
3, the color space of RGBA, Red-Green-Blue-Alpha, only RGB model attached additional information, The color of use is RGB, may belong to any RGB color, so that alpha rendering and alpha synthesis become possible, The alpha derives from Greek alphabet used in linear interpolation equation α A+ (1- α) B.Wherein, red channel Red, green channel Green, blue channel Blue value range be 0~255, the value range of opacity Alpha, which can be 0~1, (to be indicated not The percentage of transparency) or 0~255,0~255 value range is used in embodiments of the present invention.
4, pixel is indivisible unit or element in whole image, is to exist with the small lattice of a solid color, often One dot matrix image contains a certain amount of pixel, these pixels determine the size that image is presented on the screen.
5, nodejs is the development platform for allowing JavaScript to operate in server-side, is carried out to some special cases Optimization, provides the application programming interface (Application Programming Interface, API) of substitution.
6, canvas, a HTML5 element are used for drawing image, and built-in a variety of application programs for image procossing are compiled Journey interface (Application Programming Interface, API) obtains each pixel in image such as drawing image Data etc..
It referring to Figure 1, is a kind of interaction schematic diagram of method for compressing image provided in an embodiment of the present invention.As shown in Figure 1, Such as there are target image 201, which is Dynamic Graph or static map comprising multiple image, the specific target figure Picture 201 is GIF Dynamic Graph, as shown in Fig. 2, being a kind of composition schematic diagram of target image provided in an embodiment of the present invention, the mesh Logo image 201 includes first frame image 2011, the second frame image 2012, third frame image 2013 and the 4th frame image 2014, is this Four frame images successively carry out the Dynamic Graph of dynamic play.When server 10 receive by display interface 20 send comprising target The target image 201 is carried out expansion frame by frame and is independent image, obtains each frame image, and obtain target image by image 201 At least one image pair in 201, each image is to the two field pictures for including arbitrary neighborhood in target image 201.Wherein, it obtains Image is got to T1, including first frame image 2011 and the second frame image 2012, image is to T2, including the second frame image 2012 and Three frame images 2013, image is to T3, including third frame image 2013 and the 4th frame image 2014.Compare at least one image pair Two field pictures each pixel colour information, specifically under same position information compare two field pictures color value letter Breath.Such as image to T1, when location information is (1,1), comparison first frame image 2011 is in the color that location information is at (1,1) Value information and the second frame image 2012 are in the colour information that location information is at (1,1), right then when location information is (1,2) It is colour information at (1,2) and the second frame image 2012 in location information than first frame image 2011 in location information is (1,2) The colour information at place, continues to image to T1Traversal comparison is carried out, until by image to T1In the comparison of each pixel terminate.Its In, when between first frame image 2011 and the second frame image 2012 there are when the colour information difference of pixel, not by the colour information Same pixel is determined as difference pixel, and obtains the colour information in the second frame image 2012 in the difference pixel and position Confidence breath, so that it is determined that image is to T1Pixel difference data.It is corresponding that pixel difference data are determined as the second frame image 2012 Compressed data.Third frame image 2013 and the corresponding compressed data of the 4th frame image 2014 are similarly determined, by first frame image 2011, the compression of the compressed data of the second frame image 2012, the compressed data of third frame image 2013 and the 4th frame image 2014 Data Synthesis is the corresponding compression image of target image 201.
Wherein, the detailed process of compression of images may refer to following figure 3 to embodiment corresponding to 8.
Further, Fig. 3, a kind of method flow schematic diagram of compression of images provided in an embodiment of the present invention are referred to.Such as Shown in Fig. 3, the above method includes the following steps:
Step S301 obtains at least one image pair in target image.
Specifically, target image is the image comprising multiple image, the first frame image of target image is first frame image, is removed Frame image other than first frame image is condensed frame image.At least one image pair in target image is obtained, the image is to packet Two field pictures containing arbitrary neighborhood in target image, it is believed that the quantity of the image pair in target image is than the frame figure that is included The quantity of picture few one.
For example, it is assumed that target image is the GIF Dynamic Graph comprising four frame images, which is first frame figure respectively Picture, the second frame image, third frame image and the 4th frame image, after server receives the target image, to the target image It carries out expansion frame by frame and obtains the above-mentioned independent image of four frames image, and obtained in target image extremely according to adjacent two field pictures A few image pair, including the image that is made of first frame image and the second frame image to, the second frame image and third frame image group At image pair and third frame image and the 4th frame image composition image pair.
Step S302 determines the pixel difference data between the two field pictures of at least one image pair, to pixel difference heteromerism According to being ranked up, the corresponding compressed data of the condensed frame image pixel difference data after sequence being determined as in target image.
Specifically, successively determining the two field pictures of each image pair to comparing to image each in target image Between pixel difference data the pixel difference data after sequence are determined to determining that obtained pixel difference data are ranked up For the corresponding compressed data of condensed frame image in target image, it is right in target image to be specifically determined as pixel difference data Answer the corresponding compressed data of second frame image of image pair.Wherein, the first frame image and second frame figure of image pair It seem for the relative ranks played out in the target image with frame image.Specifically according to the location information of pixel to mesh Each pixel that the two field pictures of at least one image pair are included in logo image successively traverses comparison, when there are pixels Colour information difference when, the different pixel of colour information is determined as difference pixel, and extract the difference pixel Colour information and location information, as a pixel difference data between two field pictures, until will be included in two field pictures All pixels point all compares completion, gets all differences pixel and the corresponding picture of each difference pixel between two field pictures Plain variance data, all pixels variance data between the two field pictures that will acquire are determined as the pixel difference heteromerism of correspondence image pair According to.It is ranked up compression by the pixel difference data to image pair, the compressed pixel difference data that will sort are determined as this The corresponding compressed data of second frame image of image pair.Similarly obtain at least one accessed by the target image centering The pixel difference data of each image pair of image pair, and determine that each condensed frame image in addition to first frame image is corresponding Compressed data.
For example, for three images pair extracted in the target image comprising four frame images, with the target image In first image pair for, first image to include first frame image and the second frame image, compare first frame image and second Frame image believes the position if colour information is different at information in the position in the colour information that location information is at (1,1) Pixel at breath (1,1) is determined as difference pixel, and by the location information (1,1) and the second frame image at (1,1) Colour information is determined as the pixel difference data of the difference pixel;If colour information is identical at information in the position or has determined The pixel difference data of the pixel then compare the color of first frame image and the second frame image at next location information (1,2) Value information determines the pixel difference data of pixel at the location information (1,2) or determines the colour information phase being somebody's turn to do at (1,2) Together.Similarly, the pixel between first frame image and the second frame image is compared, until determining first frame image and the second frame image The pixel difference data or the identical pixel of colour information of difference pixel in all pixels point for being included.By the second frame figure The corresponding pixel difference data of the difference pixel between first frame image as included in are ranked up so that color it is identical or Pixel difference data similar in color are put in adjacent position, and it is corresponding that the pixel difference data after sequence are determined as the second frame image Compressed data.It wherein, is by comparing the difference value between each difference pixel, which is the color value of difference pixel The difference of the sum of the data that information is included, or the corresponding difference of each data for including by colour information, are on duty When different value is less than the first discrepancy threshold, it is believed that the color of the corresponding two difference pixels of the difference value is same or similar.
According to the acquisition modes of the pixel difference data of first image pair, second image pair and third image are obtained Pair pixel difference data, and determine and according to the pixel difference data of second image pair determine the corresponding compression of third frame image Data determine the corresponding compressed data of the 4th frame image according to the pixel difference data of third image pair.
Wherein it is possible to be analyzed using corresponding image analysis library by nodejs and obtain each frame image in target image All pixels point colour information, which can be the RGBA value of pixel, which is that may be implemented Image procossing, to extract the image procossing library of the data of each pixel in image, such as Jimp.Especially by image solution The two field pictures of at least one image pair are analyzed in analysis library, get the color value letter of the point of all pixels included in two field pictures Breath, and in the colour information of corresponding pixel points in two field pictures under getting a location information, to the two field pictures picture The colour information of vegetarian refreshments compares, if colour information is identical, compares corresponding in two field pictures under next location information The colour information of pixel stores second frame image in two field pictures in the position under information if colour information is different Pixel colour information.Comparison process is executed to each pixel in two field pictures, until between determining two field pictures Pixel difference data.The pixel difference data are ranked up, if colour information is RGBA value, in a kind of possible mode, The sum of tetra- values of RGBA for the colour information that each pixel difference data are included are calculated, four between pixel difference data are compared Value the sum of difference value, if difference value less than the first discrepancy threshold, by the difference value corresponding two less than the first discrepancy threshold A pixel difference data are placed in adjacent position;In alternatively possible mode, respectively compare pixel difference data between R value, G The difference of four values is respectively less than the first difference threshold if the difference of four values is respectively less than the first discrepancy threshold by value, B value and A value The corresponding two pixel difference data of the difference value of value are placed in adjacent position.Wherein, adjacent position is indicated to compare pixel difference Data are initial position, are successively arranged along the initial position, so that each difference value is less than the pixel difference of first threshold Data are adjacent less than the pixel difference data of first threshold with the difference value of previous determination.
First frame image in target image and compressed data are synthesized the corresponding compression image of target image by step S303.
Specifically, the corresponding compressed data of condensed frame image in first frame image in target image and target image is synthesized For the corresponding compression image of target image.Wherein, condensed frame image is the frame image in target image other than first frame image. It is according to the condensed frame image and previous frame image due to the corresponding compressed data of each condensed frame image in the target image Between pixel difference data determine so that pixel difference data by the previous frame image of condensed frame image and between the two, The colour information of each pixel in the condensed frame image can be determined, so as to according to first frame image and compressed data synthesis The corresponding compression image of target image realizes the lossless compression to target image.
For example, the pixel difference data of three images pair got in above-mentioned steps S302 given example, and According to the corresponding compressed data of three frame images that the pixel difference data of three images pair determine, by first frame image, the second frame The corresponding compressed data of image, the corresponding compressed data of third frame image and the corresponding compressed data of the 4th frame image synthesize mesh The corresponding compression image of logo image.
The embodiment of the invention provides a kind of method for compressing image, by obtaining at least one image in target image It is right, it determines the pixel difference data between the two field pictures of at least one image pair, pixel difference data is determined as target figure The corresponding compressed data of condensed frame image as in, synthesizes target image pair for first frame image in target image and compressed data The compression image answered, realizes the compression to target image, real due to not abandoning any data in compression process The lossless compression to target image is showed.The embodiment of the present invention is by the difference between extracting adjacent two field pictures, as adjacent The compressed data of second frame image in two field pictures, due to mistake of the Dynamic Graph comprising multiple image in adjacent two field pictures Crossing property, therefore difference is smaller, so that not influencing target figure in the case where reducing the storage size and time-consuming transmission of target image The display effect of picture.
Wherein, the embodiment of the invention provides a kind of specific implementation flow schematic diagrames of method for compressing image.Such as Fig. 4 institute Show, this method comprises the following steps:
Step S401 obtains at least one image in target image to Ti, the image is to TiIncluding frame image SiWith frame figure As Si+1
Specifically, including m frame image in target image, the quantity for getting the image pair in the target image at this time is M-1, i.e. m are the quantity of the frame image in target image, are positive integer.At least one image in target image is obtained to Ti, The image is to TiIncluding frame image SiWith frame image Si+1, i is positive integer, and i is less than or equal to m-1, frame image Si+1Belong to compression Frame image.In other words, image is to T1Including frame image S1With frame image S2, image is to T2Including frame image S2With frame image S3, Image is to T3Including frame image S3With frame image S4....
Target image 201 as shown in Figure 2, the target image 201 include first frame image 2011, the second frame image 2012, Third frame image 2013 and the 4th frame image 2014 obtain first image in target image 201 to T1, first image To T1Including first frame image 2011 and the second frame image 2012, second image is to including the second frame image and third frame figure Picture, third
Step S402 compares frame image SiWith frame image Si+1The colour information of pixel under middle same position information.
Specifically, contrast images are to TiMiddle frame image SiWith frame image Si+1The color value of pixel under middle same position information Information, for frame image SiWith frame image Si+1The asynchronous pixel of colour information under middle same position information executes step S403, for frame image SiWith frame image Si+1Pixel when colour information under middle same position information is identical, not locates Reason, and compare the colour information of the pixel under next location information of the image pair.
Wherein, the colour information of pixel can be the RGBA value of the pixel, and frame figure is compared under same position information As SiWith frame image Si+1The RGBA value of pixel under corresponding position, as the corresponding Red of pixel under a certain location information Value, Green value, Blue value or Alpha value have at least one value different, then it is assumed that the color value of the pixel under the location information is believed Breath is different.Specifically frame image S can be extracted by image analysis relevant in nodejs libraryiWith frame image Si+1Middle same position The colour information of pixel under information.Wherein, all pixels point of each frame image of extraction can by two-dimensional array into Row record, the line number and row number of the two-dimensional array are used to indicate the location information of each pixel in frame image, the location information It is to be generated for the first pixel in the upper left corner in frame image for coordinate origin.For example, at location information (1,1), it is right Than frame image SiIn first pixel of the first row and frame image Si+1In first pixel of the first row colour information. By analyzing the frame image S gotiData include xiValue, yiValue, RiValue, GiValue, BiValue and AiIt is worth, wherein xiValue, yiValue group Framing image SiIn the pixel location information, RiValue, GiValue, BiValue and AiValue forms the colour information of the pixel, obtains The frame image S arrivedi+1In data include xi+1Value, yi+1Value, Ri+1Value, Gi+1Value, Bi+1Value and Ai+1It is worth, wherein xi+1Value, yi+1Value Component frame image Si+1In the pixel location information, Ri+1Value, Gi+1Value, Bi+1Value and Ai+1Value forms the color value of the pixel Information compares R respectivelyiValue and Ri+1Value, GiValue and Gi+1Value, BiValue and Bi+1Value and AiValue and Ai+1Value, if existing in colour information At least one value is different, then it is assumed that (xi, yi) or (xi+1, yi+1) at pixel be difference pixel, wherein xi=xi+1, yi= yi+1
The different pixel of colour information is determined as difference pixel by step S403.
Specifically, the different pixel of colour information is determined as difference pixel, according to frame image Si+1Middle difference pixel The colour information of point determines frame image SiWith frame image Si+1Between pixel difference data.Specific getting frame image Si+1In the difference The colour information and location information of pixel, by the Data Format Transform of location information at the data format of colour information, by lattice Location information and colour information after formula conversion are determined as frame image SiWith frame image Si+1Between pixel at the difference pixel Variance data.If frame image SiWith frame image Si+1Between all pixels point comparison all has been carried out, then follow the steps S404, If frame image SiWith frame image Si+1Between between there is also the pixel not compared, then return to step S402, compare frame image Si With frame image Si+1Between pixel under next same position information colour information.
Specifically, getting frame image Si+1In the difference pixel under information in the position colour information, specific obtain should The RGBA value of difference pixel under location information, the range of each value are 0~255, and the data format of the location information is turned The data format for changing colour information into, location information and colour information after format is converted are determined as image to believing in the position Pixel difference data under breath, so that determining the position of difference pixel in the picture, and root according to location information The colour information of the difference pixel is determined according to colour information, to realize the reduction to second frame image of image pair.Its In, compression image will be converted into target image, the data value of pixel each for image is up to 255, and for position Data value in information is not necessarily in 0~255, it is therefore desirable to convert to the data format of location information.
For example, it is assumed that compressed data is stored by png format, for each pixel in the image of png format Data be the pixel RGBA value, therefore location information is converted into can be written into the data format of png format-pattern, be had Body pixel data format as shown in Figure 5, the pixel data format include high position x501, low level x502, a high position y503, low level Y504, R value 505, G value 506, B value 507 and A value 508, wherein high position x501 and low level x502 form the position of the difference pixel X coordinate in confidence breath, high-order y503 and low level 504 form the y-coordinate in the location information of the difference pixel, high-order x501 Being low level x502 obtains encountering 256 Shi Jinyi, and high-order y503, which is low level y504, to be obtained encountering 256 Shi Jinyi.Wherein, The value that high-order x501 is indicated is the value of 255* high position x501, and the value that low level x502 is indicated is the value of 1* low level x502, the i.e. difference X coordinate in the location information of pixel is (value of the value+1* low level x of 255* high position x);The value that high-order y503 is indicated is 255* The value of high-order y503, the value that low level y504 is indicated are the value of 1* low level y504, i.e., the y in the location information of the difference pixel is sat It is designated as (value of the value+1* low level y of 255* high position y).Wherein, the conversion process of the data format can also in step s 404 really Determine to execute again after the pixel difference data of image pair.
Step S404 determines image to TiPixel difference data.
Specifically, by frame image SiWith frame image Si+1Between all pixels point comparison all has been carried out, be extracted figure As to TiIncluded in all differences pixel and the difference pixel location information and colour information, above-mentioned all differences The location information and colour information of pixel form the image to TiPixel difference data.Wherein, image is to TiPixel difference Data include the pixel difference data of multiple difference pixels, and each pixel difference data include eight numerical value, and each numerical value is 0 In~255 ranges, first four numerical value indicates that the location information of corresponding difference pixel, rear four numerical value indicate corresponding difference The colour information of pixel.
Step S405, based on the difference value between pixel difference data, to frame image SiWith frame image Si+1Between multiple pixels Variance data is ranked up.
Specifically, based on the difference value between pixel difference data, to the frame image SiWith frame image Si+1Between multiple pictures Plain variance data is ranked up.The sequencer procedure is specific as follows:
Image is obtained to TiCorresponding pixel difference data sorting queue;
It obtains in the queue of pixel difference data sorting between j-th of pixel difference data and unsorted pixel difference data Difference value, by the p pixel difference data with the difference value of j-th of pixel difference data less than the first discrepancy threshold, successively edge J-th of pixel difference data is ranked up, the unsorted pixel difference data by ordering pixel difference data and after updating Spliced, obtains updated pixel difference data sorting queue;P is 0 or positive integer, and p is less than the image to TiMiddle institute The quantity for the difference pixel for including;
Pth+j pixel difference data are obtained in pixel difference data sorting queue in the updated;
It will be poor less than first with the difference value of+j pixel difference data of pth in pixel difference data unsorted after update K pixel difference data of different threshold value are successively ranked up, until frame image S along+j pixel difference data of pthiWith frame figure As Si+1Between be not present unsorted pixel difference data.
Specifically, based on the difference value between pixel difference data, to the frame image SiWith frame image Si+1Between multiple pictures Plain variance data is ranked up, so that the same or similar corresponding pixel difference data of RGBA value of color are placed on adjacent position It sets.For the difference value for the colour information that the difference value between two pixel difference data is two pixel difference data, specifically It is that colour information in the difference or two pixel difference data of the sum of colour information in two pixel difference data is wrapped The difference of each Color Channel contained.For example, there are two pixel difference data, the colour information note of a pixel difference data Make R1 value, G1 value, B1 value and A1 value, the colour information of one other pixel variance data is denoted as R2 value, G2 value, B2 value and A2 value, The difference value for calculating two pixel difference data, one is by obtain (R1 value+G1 value+B1 value+A1 value) with (R2 value+G2 value+ B2 value+A2 value) between difference value of the difference as two pixel difference data, when the difference is less than the first discrepancy threshold, table Show that the two pixel difference data are the pixel difference data of two same or similar pixels of color;One is pass through difference Between difference and A1 value and A2 value between difference, G1 value between calculating R1 value and R2 value and the difference between G2 value, B1 value and B2 value Difference when this four differences are respectively less than the first discrepancy threshold, indicates that the two pixel difference data are that color is same or similar The pixel difference data of two pixels.
Wherein, when being ranked up to the pixel difference data in pixel difference data sorting queue, the algorithm of the sequence can Referring to the sort method to " 1,3,9,4,5 ", it is assumed that the first discrepancy threshold herein is 3, and the sort method is specific as follows:
Obtain the difference value between " 1 " and " 3 ", which is 2, less than the first discrepancy threshold 3, by " 3 " be put in " 1 " it Afterwards;The difference value between " 1 " and " 9 " is obtained, which is 8, is greater than the first discrepancy threshold 3;It obtains between " 1 " and " 4 " Difference value, the difference value are 3, are not less than the first discrepancy threshold;The difference value between " 1 " and " 5 " is obtained, which is 4, greatly In the first discrepancy threshold, to obtain 1 numerical value of the difference value between " 1 " less than the first discrepancy threshold, and obtain " 1,3,9, 4,5";
(1+1) a numerical value " 3 " in " 1,3,9,4,5 " is obtained, the difference value between " 3 " and " 9 " is obtained, which is 6, Greater than the first discrepancy threshold;The difference value between " 3 " and " 4 " is obtained, which is 1, and less than the first discrepancy threshold, " 4 " are put After " 3 ";Obtain the difference value between " 3 " and " 5 ", which is 2, less than the first discrepancy threshold, by " 5 " be put in " 4 " it Afterwards, to obtain 2 numerical value of the difference value between " 3 " less than the first discrepancy threshold, and " 1,3,4,5,9 " are obtained;
(2+2) a numerical value " 5 " in " 1,3,4,5,9 " is obtained, the difference value between " 5 " and " 9 " is obtained, which is 4, Greater than the first discrepancy threshold, the difference value between " 5 " is not found in unsorted numerical value in the updated less than the first discrepancy threshold Numerical value when, obtain " 1,3,4,5,9 " in " 5 " next numerical value " 9 ", " 9 " be the last one numerical value, then terminate this row Program process, " 1,3,4,5,9 " after finally being sorted.
Wherein, for frame image SiWith frame image Si+1Between the method that is ranked up of multiple pixel difference data can be Such as the sequencer procedure of above-mentioned " 1,3,9,4,5 ", it is also possible to other sort algorithms, it is above-mentioned collated in embodiments of the present invention Difference value of the difference between pixel difference data in journey.
Pixel difference data after sequence are determined as frame image S by step S406i+1Corresponding compressed data.
Specifically, the pixel difference data after sequence are frame image Si+1Middle colour information is different from frame image SiIdentical bits Pixel difference data after sequence are determined as frame image S by the pixel number evidence of the colour information under confidence breathi+1Corresponding pressure Contracting data.When i+1 is less than the quantity of the frame image in target image, indicate that there are still do not compressed in the target image Frame image, then return to step S401, to next image to handling;When i+1 is equal to the frame image in target image Quantity when, indicate that all frame images included in the target image all compress completion, then follow the steps S407.
Specifically can also the pixel difference data after sequence be carried out with lossless compression, be such as based on the lossless pressure of " sliding window " It contracting, in the pixel difference data after sequence, the same or similar pixel difference data of colour information are located at adjacent position, so that The storage size of pixel difference data is reduced by lossless compression.The lossless compression method is shown in Figure 6, and character string compression is shown It is intended to, specific as follows:
Determine the length of the first cycling among windows and the length of the second cycling among windows, the first cycling among windows and the second cycling among windows Between there are separator, the first cycling among windows are adjacent with the second cycling among windows;Separator is placed in the first word of pixel difference data Symbol determines the maximum matching length of identical characters in the first cycling among windows and the second cycling among windows in pixel difference data, according to The identical characters of maximum matching length generate first compressed node;Mobile separator L character generates next compression section Point, until the separator between the first cycling among windows and the second cycling among windows is located at the end character of pixel difference data, wherein L is Based on determined by maximum matching length;According to the character for being not belonging to compressed node in compressed node and pixel difference data, Delta frame image Si+1Corresponding compressed data.
For example, the matching result of the longest matching length of character string in the second cycling among windows is indicated by (q, l, c), Wherein, when q indicates longest matching, position when character starts, relative to the position of separator, l indicates longest matching length, c Indicate next character when the corresponding matching character ends of longest matching length in the second cycling among windows, when mobile separator is mobile Digit be state-of-the-art record (q, l, c) in l add one.Wherein, the first cycling among windows are for storing history character, the second traversal Window is for traversing character to be compressed.With character string (a, a, c, a, a, c, a, b, c, a, b, a, a) for, the first cycling among windows Length be 6, the length of the second cycling among windows is 4, and separator is placed in the first character of the character string, determines the second traversal window Mouthful in there is no with identical characters in the first cycling among windows, be denoted as (, 0, a);Mobile 1 character of separator, the first traversal of comparison (a, c, a, a), there are an identical characters, maximum matching length is 1, is denoted as (1,1, c) for window (a) and the second cycling among windows; Mobile separator 2, (a, a, c, a), there are four same words for comparison the first cycling among windows (a, a, c) and the second cycling among windows Symbol, maximum matching length are 4, are denoted as (3,4, b);Mobile separator 5, compare the first cycling among windows (c, a, a, c, a, b) and Second cycling among windows (c, a, b, a), there are three identical characters, maximum matching length is 3, be denoted as (3,3, a);Mobile separator 4, (a, b, c, a, b, a) with the second cycling among windows (a), there are an identical characters, maximum matchings for the first cycling among windows of comparison Length is 1, is denoted as (1,1);Mobile separator 2, separator is located at the end character of character string at this time, completes to character string Compression.
The process compressed particularly for the pixel difference data after sequence such as above-mentioned character string (a, a, c, a, a, c, a, B, c, a, b, a, compression process a).Optionally, which it is corresponding can also to generate in step S 407 target image When compressing image, realized using the lossless compression algorithm of compression image correspondence image format itself, it is not limited here.
Step S407 generates the corresponding compression image of target image.
Specifically, the compressed data of the first frame image in target image and condensed frame image in target image is synthesized mesh The corresponding compression image of logo image, wherein condensed frame image is the frame image in target image in addition to first frame image.
Optional way in step S406 uses compression image pair in the corresponding compression image of generation target image The lossless compression algorithm of the picture format answered itself is realized.For example, by after the sequence of frame image each in target image Pixel difference data are written in image, and the format of the image of write-in can be png format, by the pixel difference data of frame image When png format is written, the compression to pixel difference data is realized by the LZ77 lossless compression algorithm built in the png image.
In example in real time of the invention, by least one image in target image between the picture the two field pictures for being included Plain variance data is ranked up simultaneously lossless compression, effectively realizes the lossless compression to target image.It on the one hand, is to extract target Condensed frame image in image and the pixel difference data between the previous frame image of the condensed frame image reduce the figure for needing to store As data;On the one hand, the pixel difference data the consecutive frame image extracted are ranked up, so that difference between colour information Value is placed on adjacent position less than the pixel difference data of the first discrepancy threshold, so that the identical characters between adjacent pixel variance data Maximum matching length become larger, can be with thus when carrying out lossless compression to the pixel difference data after sequence by " sliding window " Improve the compression ratio of pixel difference data.By above-mentioned two aspect, the lossless compression to target image is effectively realized, is being reduced While transmission is time-consuming and reduces storage size, the display effect of target image is not influenced.
Extract schematic diagram the embodiment of the invention provides a kind of colour information of frame image is as shown in Fig. 7 a to Fig. 7 b The color of the first frame image 2011 for included to target image shown in Fig. 2 and the partial pixel point extracted in the second frame image 2012 Value information, it is assumed that all frame images included in target image are the image of 600*500 pixel size.As shown in Figure 7a, Pixel packet for the image block of 3*5 pixel size in dotted portion in first frame image 2011, at each location information It is worth containing four, respectively the R value, G value, B value and A value of the pixel;As shown in Figure 7b, for dotted line in the second frame image 2012 The image block of 3*5 pixel size in part under same position information, the pixel at each location information include four values, The respectively R value, G value, B value and A value of the pixel.The image block for obtaining the partial pixel size in the first frame image 2011 exists Location information is that the colour information at (376,121) is (0,0,0,255), and the partial pixel obtained in the second frame image 2012 is big It is (0,0,0,255) that small image block, which is colour information at (376,121) in location information, compares first frame under the location information The colour information of image 2011 and the second frame image 2012 is identical for the colour information at (376,121) in location information;In place Confidence breath is (376,122), compares the colour information (1,0,5,230) of first frame image 2011 and the color value of the second frame image 2012 Information (1,0,5,230), the colour information are identical;It is (376,123), the color value letter of comparison first frame image 2011 in location information The colour information (0,0,0,250) of (253,240,243,250) and the second frame image 2012 is ceased, the colour information is different, by this Pixel is determined as difference pixel, and determines the colour information (0,0,0,250) of the difference pixel, combining position information (376,123) determine the pixel difference data (376,123,0,0,0,250) of the difference pixel, and by the number of the location information The data format of colour information is converted into according to format, pixel difference data after being converted (1,121,0,123,0,0,0, 250);It is (376,124) in location information, compares the colour information (0,0,0,255) and the second frame image of first frame image 2011 2012 colour information (0,0,0,255), the colour information are identical;Similarly, comparison is in first frame image 2011 and the second frame image The colour information of pixel under 2012 other positions information obtains the pixel between first frame image 2011 and the second frame image 2012 Variance data, including ... (1,121,0,123,0,0,0,250), (1,121,0,123,0,0,0,255) ..., (1, 122,0,122,0,0,0,250), (1,122,0,123,0,0,0,255) ..., (1,123,0,122,234,240,243, 255), (1,123,0,122,230,286,234,248) ....To between first frame image 2011 and the second frame image 2012 Pixel difference data are ranked up compression, the sequence compression process referring to fig. 4 described in process, to obtain the second frame image 2012 corresponding compressed datas.In the same manner, the compressed data of third frame image 2013 and the 4th frame image 2014 is obtained.Root According to first frame image 2011 and the compressed data of the second frame image 2012, the compressed data of third frame image 2013, the 4th frame image 2014 compressed data synthesizes the corresponding compression image of target image 201.
Further, side shown in Fig. 3 and Fig. 4 is more completely illustrated from the angle of function logic please also refer to Fig. 8, Fig. 8 Other aspects that method may relate to, to help reader to further understand the technical solution of the application record, Fig. 8 is that the present invention is real A kind of schematic diagram of function logic module of example offer is provided.As shown in figure 8, may include to score in the function logic module Analysis module obtains pixel difference data module, is ranked up module and lossless compression modules by colour information.These modules can be with The function that the module has is executed to the target image got respectively.
The modules shown in Fig. 8 are obtained by the colour information of pixel in the adjacent two field pictures of comparative analysis The pixel difference data are ranked up by the pixel difference data between two field pictures by colour information, and to the pixel after sequence Variance data carries out lossless compression, obtains compression image.Specifically, these modules respectively correspond following process: 801, to score Analysis;802, pixel difference data are obtained;803, it is ranked up by colour information;804, lossless compression.It is described as follows:
801, comparative analysis.
Specifically, being compared point to the colour information of each pixel included in first frame image and the second frame image Analysis, is determined as difference pixel for the different pixel of colour information, when colour information is identical, compares the color of next pixel Value information, detailed process is referring in step S302 or Fig. 4 shown in step S402 to step S403, details are not described herein in Fig. 3.
802, pixel difference data are obtained.
Specifically, according to the location information and colour information of the difference pixel determined in first frame image and the second frame image Determine the pixel difference data between first frame image and the second frame image, detailed process is referring to step in step S302 or Fig. 4 in Fig. 3 Shown in S404, details are not described herein.
803, it is ranked up by colour information.
Specifically, being ranked up according to colour information to the pixel difference data between first frame image and the second frame image, make Between colour information difference value less than the difference pixel of the first discrepancy threshold be put in adjacent position, the sequencer procedure referring specifically to Sequencer procedure shown in step S405 in Fig. 4, details are not described herein.
804, lossless compression.
Specifically, carrying out lossless compression to the pixel difference data after sequence, the storage size of image is reduced, is compressed Image 1, specific loss-free compression process referring to fig. 4 in compression process shown in step S406, details are not described herein.
The corresponding compression image 2 of the second frame image is obtained further according to first frame image and the second frame image, until obtaining mesh Each corresponding compressed data of frame image in logo image.
Fig. 9 is referred to, Fig. 9 is a kind of image decompressor flow diagram provided in an embodiment of the present invention.This method includes Following steps:
Step S901 obtains first frame image and compressed data in compression image.
Specifically, obtaining the first frame image and compressed data in compression image, first frame image is the first frame in target image Image, compressed data are the corresponding compressed data of condensed frame image in target image, and condensed frame image is to remove in target image Frame image except first frame image, compression image are that target image is obtained by lossless compression.
Specifically, the corresponding compression of condensed frame image in target image can be obtained by the built-in API in canvas Data, such as getImageData obtain the data of each pixel.Wherein, if the compression image is the image of png format, Compression image is drawn by canvas, and obtains the data of each pixel in the image after drawing, each data packet Four numerical value are included, to get the compressed data of each condensed frame image.
Step S902 determines pixel difference data according to compressed data.
Specifically, determining pixel difference data according to compressed data, target image includes at least one image pair, image pair Two field pictures including arbitrary neighborhood in target image, difference of the pixel difference data between adjacent two field pictures.Specifically, The length of the first cycling among windows and the length of the second cycling among windows are obtained, exists between the first cycling among windows and the second cycling among windows and divides Every symbol, the first cycling among windows are adjacent with the second cycling among windows;Separator is in the first character of compressed data, slides first pass Go through window and the second cycling among windows, each of traversal compressed data character;If character is compressed node, by compressed node It is reduced to data convert node;According to the character for being not belonging to compressed node in data convert Node compression data, pixel difference is determined Heteromerism evidence.
The specific process is the decompression process for the process that step S406 compresses pixel difference data in Fig. 4.
Step S903 draws target image according to pixel difference data and first frame image.
Specifically, drawing the first frame image;According to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference Data and frame image SiDrawing frames image Si+1, until determining frame image Sm;M is multiple frame images that the target image includes Quantity, i is positive integer, and i is less than m;According to all frame images after drafting, the target image is generated.
Wherein, this is according to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data and frame image SiIt draws Frame image Si+1Process is to obtain image to TiThe location information and colour information of middle pixel difference data determine frame image Si+1 In difference pixel, difference pixel be pixel difference data in the corresponding pixel of location information;According to pixel difference The location information and colour information drawing frames image S of datai+1In difference pixel;According to non-difference pixel in frame image SiIn location information and colour information, drawing frames image Si+1In non-difference pixel, the frame image S after being drawni+1; Non- difference pixel is frame image SiOr frame image Si+1In be difference pixel pixel.Specifically, successively drawing frames figure As Si+1In each pixel colour information, when the pixel is difference pixel, the colour information of the point is corresponding picture Colour information in plain variance data, when the pixel is non-difference pixel, the colour information of the point is frame image SiIn Colour information under corresponding position information;The colour information of next pixel is drawn again, until drawing out frame image Si+1In All pixels point.
After the embodiment of the present invention is by getting compression image, the compression of condensed frame image is got according to the compression image Data, and decompressed to the compressed data is counter, the pixel difference data of condensed frame image are obtained, for each condensed frame figure Picture can obtain each pixel of the condensed frame image by the pixel difference data and previous frame image of the condensed frame image Colour information, to be restored to the compression image after lossless compression, the target image for obtaining target image, and obtaining with Data difference is not present between original image, realizes the lossless decompression to the image of lossless compression, and then realize to target image Rendering is shown, is effectively realized the lossless decompression to image, is further increased the lossless compression effect of picture.
It optionally, is a kind of image compressing device provided in an embodiment of the present invention referring to Figure 10, Figure 10.As shown in Figure 10, The image compressing device can be used for the electronic equipment in embodiment corresponding to above-mentioned Fig. 3 to Fig. 8, specific compression of images dress Setting 1a includes obtaining module 10a, determining module 20a and generation module 30a.
Module 10a is obtained, for obtaining at least one image pair in target image, the target image includes multiple frames Image, each image is to the two field pictures for including arbitrary neighborhood in the target image;
Determining module 20a, the pixel difference data between two field pictures for determining at least one image pair, base Difference value between pixel difference data is ranked up multiple pixel difference data the two field pictures, after sequence The pixel difference data be determined as the corresponding compressed data of condensed frame image in the target image;The condensed frame figure As being the frame image in the target image other than first frame image;
Generation module 30a, for first frame image in the multiple image and the compressed data to be synthesized the target The corresponding compression image of image.
Wherein, the determining module 20a includes:
Acquiring unit 201a, for obtaining the image of at least one image pair to Ti, described image is to TiIncluding frame Image SiWith frame image Si+1;I is positive integer, and i is less than or equal to m-1, and the m is the frame image in the target image Quantity;
Determination unit 202a, for determining the frame image SiWith frame image Si+1Pixel difference heteromerism between each pixel According to the pixel difference data are frame image Si+1In be different from the frame image SiPixel colour information;The frame figure As Si+1Belong to the condensed frame image;
The determination unit 202a is also used to for the pixel difference data to be determined as the frame image Si+1Corresponding pressure Contracting data, until determining image to Tm-1In frame image SmCorresponding compressed data.
Wherein, the frame image S is being determinediWith frame image Si+1It is described in terms of pixel difference data between each pixel Determination unit 202a includes:
First contrast subunit 2021a, for comparing the frame image SiWith frame image Si+1Under middle same position information The colour information of pixel;
First determines subelement 2022a, for when there are the colour information difference of pixel, not by the colour information Same pixel is determined as difference pixel, according to frame image Si+1Described in the colour information of difference pixel determine the frame Image SiWith frame image Si+1Between pixel difference data.
Wherein, described first determine that subelement 2022a is specifically used for:
Obtain the frame image Si+1Described in difference pixel colour information and location information;
Position by the Data Format Transform of the location information at the data format of the colour information, after format is converted Confidence breath and the colour information are determined as the frame image SiWith frame image Si+1Between pixel difference data.
Wherein, the pixel difference data are determined as the frame image S describedi+1In terms of corresponding compressed data, institute Stating determination unit 202a includes:
Second contrast subunit 2023a, for based on the difference value between pixel difference data, to the frame image SiAnd frame Image Si+1Between multiple pixel difference data be ranked up;
Second determines subelement 2024a, for the pixel difference data after sequence to be determined as the frame image Si+1It is corresponding Compressed data.
Wherein, the second contrast subunit 2023a is specifically used for:
Described image is obtained to TiCorresponding pixel difference data sorting queue;
Obtain j-th of pixel difference data and unsorted pixel difference data in the pixel difference data sorting queue Between difference value, by the p pixel difference heteromerism with the difference value of j-th of pixel difference data less than the first discrepancy threshold According to, successively it is ranked up along j-th of pixel difference data, it will be unsorted after ordering pixel difference data and update Pixel difference data are spliced, and updated pixel difference data sorting queue is obtained;P is 0 or positive integer, and p is less than institute State the quantity of pixel difference data;
Pth+j pixel difference data are obtained in the updated pixel difference data sorting queue;
It will be small with the difference value of the pth+j pixel difference data in pixel difference data unsorted after the update In k pixel difference data of first discrepancy threshold, successively it is ranked up along the pth+j pixel difference data, directly To the frame image SiWith frame image Si+1Between be not present unsorted pixel difference data.
Wherein, the pixel difference data are determined as the frame image S describedi+1In terms of corresponding compressed data, institute State determination unit 202a further include:
Subelement 2025a is obtained, for determining the length of the first cycling among windows and the length of the second cycling among windows, described the There are separator, first cycling among windows and the second cycling among windows phases between one cycling among windows and second cycling among windows It is adjacent;
Third determines subelement 2026a, for the separator to be placed in the first character of the pixel difference data, really First cycling among windows described in the fixed pixel difference data match length with the maximum of identical characters in second cycling among windows Degree;
First generates subelement 2027a, for generating first compression according to the identical characters of the maximum matching length Node;
Described first generates subelement 2027a, is also used to move the separator L characters, generates next compression section Point, until the separator between first cycling among windows and second cycling among windows is located at the pixel difference data End character, wherein L is based on determined by the maximum matching length;
Second generates subelement 2028a, for being not belonging to according in the compressed node and the pixel difference data The character of the compressed node generates the frame image Si+1Corresponding compressed data.
The embodiment of the invention provides a kind of image compressing device, above-mentioned apparatus is getting the target compressed When image, which includes multiple image, extracts the image pair in target image, each image is to comprising in target image The two field pictures of arbitrary neighborhood;The corresponding compression number of second frame image is determined according to the pixel difference data between this two field pictures According to second is for frame image display order in the target image, thus according to the first frame figure in target image The compressed data of picture and condensed frame image obtains the compression image of target image, effectively realizes the lossless compression of image.Moreover, On the one hand the embodiment of the present invention is to be determined as second frame image by extracting the pixel difference data between adjacent two field pictures Compressed data;On the other hand pixel difference data are ranked up, so that adjacent position in the pixel compressed data after sequence Data are close, and carry out lossless compression to the pixel difference data after sequence, further improve from these two aspects to target figure The compression ratio of picture reduces the compressed storage size of target image, the display effect without influencing target image.
It optionally, is a kind of image decompression compression apparatus provided in an embodiment of the present invention referring to Figure 11, Figure 11.Such as Figure 11 institute Show, which can be used for the electronic equipment in embodiment corresponding to above-mentioned Fig. 9, the specific image compressing device 1b includes obtaining module 10b, determining module 20b and drafting module 30b.
Module 10b is obtained, for obtaining first frame image and compressed data in compression image, the first frame image is target First frame image in image, the compressed data is the corresponding compressed data of condensed frame image in the target image, described Condensed frame image is the frame image in the target image other than first frame image;
Determining module 20b determines pixel difference data according to the compressed data, and the target image includes at least one Image pair, for described image to the two field pictures for including arbitrary neighborhood in target image, the pixel difference data are described adjacent Two field pictures between difference;
Drafting module 30b, for drawing target image according to the pixel difference data and the first frame image.
Wherein, the determining module 20b includes:
Acquiring unit 201b, for obtaining the length of the first cycling among windows and the length of the second cycling among windows, described first There are separator, first cycling among windows and the second cycling among windows phases between cycling among windows and second cycling among windows It is adjacent;
Traversal Unit 202b, for the separator to be in the first character of the compressed data, sliding described first Cycling among windows and second cycling among windows, traverse each of compressed data character;
The compressed node is reduced to data convert if being compressed node for the character by reduction unit 203b Node;
First determination unit 204b, for being not belonging to the pressure according in the data convert node and the compressed data The character of casing coupling point determines the pixel difference data.
Wherein, the drafting module 30b, comprising:
Drawing unit 301b, for drawing the first frame image;
Second determination unit 302b is used for according to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data And the frame image SiDraw the frame image Si+1, until determining frame image Sm;M is multiple frame figures that the target image includes The quantity of picture, i is positive integer, and i is less than m;
Generation unit 303b, for generating the target image according to all frame images after drafting.
Wherein, the second determination unit tool 302b body is used for:
Subelement 3021b is obtained, for obtaining described image to TiThe location information and color value of middle pixel difference data are believed Breath;
Subelement 3022b is determined, for determining the frame image Si+1In difference pixel, the difference pixel is The corresponding pixel of location information in the pixel difference data;
Subelement 3023b is drawn, for according to the location information of the pixel difference data and colour information drafting Frame image Si+1In the difference pixel;
The drafting subelement 3023b is also used to according to non-difference pixel in the frame image SiIn location information And colour information, draw the frame image Si+1In the non-difference pixel, the frame image S after being drawni+1;It is described non- Difference pixel is the frame image SiOr the frame image Si+1In be the difference pixel pixel.
The embodiment of the invention provides a kind of image decompression compression apparatus, after the device is by getting compression image, according to The compression image gets the compressed data of condensed frame image, and is decompressed to the compressed data is counter, and condensed frame image is obtained Pixel difference data the pixel difference data and former frame of the condensed frame image can be passed through for each condensed frame image Image obtains the colour information of each pixel of the condensed frame image, to go back to the compression image after lossless compression Original obtains target image, and deletes process since data being not present in compression or decompression process, so that obtained target figure As there is no data difference, lossless solution of the realization to the image of lossless compression between the original image before being compressed with target image Pressure, and then realize that the rendering to target image is shown, the lossless decompression to image is effectively realized, picture is further increased Lossless compression effect.
It is the structural schematic diagram of electronic equipment provided by the embodiments of the present application referring to Figure 12, Figure 12.As shown in figure 12, this reality Applying the terminal device in example may include: one or more processors 1201 and memory 1202.It above-mentioned processor 1201 and deposits Reservoir 1202 is connected by bus 1203.For memory 1202 for storing computer program, which includes that program refers to It enables;Processor 1201 is used to execute the program instruction of the storage of memory 1202, performs the following operations:
At least one image pair in target image is obtained, the target image includes multiple frame images, each image pair Two field pictures comprising arbitrary neighborhood in the target image;
The pixel difference data between the two field pictures of at least one image pair are determined, by the pixel difference data The corresponding compressed data of condensed frame image being determined as in the target image;The condensed frame image is in the target image Frame image other than first frame image;
First frame image in the target image and the compressed data are synthesized into the corresponding compression figure of the target image Picture.
Alternatively, processor 1201 is for performing the following operations:
The first frame image and compressed data in compression image are obtained, the first frame image is the first frame figure in target image Picture, the compressed data are the corresponding compressed data of condensed frame image in the target image, and the condensed frame image is institute State the frame image in target image other than first frame image;
Pixel difference data are determined according to the compressed data, and the target image includes at least one image pair, described Image is to the two field pictures for including arbitrary neighborhood in target image, and the pixel difference data are between the adjacent two field pictures Difference;
Target image is drawn according to the pixel difference data and the first frame image.
In some possible embodiments, above-mentioned processor 1201 can be central processing unit (central Processing unit, CPU), which can also be other general processors, digital signal processor (digital Signal processor, DSP), specific integrated circuit (application specific integrated circuit, ASIC), ready-made programmable gate array (field-programmable gate array, FPGA) or other programmable logic Device, discrete gate or transistor logic, discrete hardware components etc..General processor can be microprocessor or this at Reason device is also possible to any conventional processor etc..
The memory 1202 may include read-only memory and random access memory, and provide instruction to processor 1201 And data.The a part of of memory 1202 can also include nonvolatile RAM.For example, memory 1202 may be used also With the information of storage device type.
In the specific implementation, above-mentioned electronic equipment can be executed by each functional module built in it as above-mentioned Fig. 2 to Fig. 9 is each Implementation provided by a step, for details, reference can be made to above-mentioned Fig. 2 into Fig. 9 implementation provided by each step, herein It repeats no more.
The embodiment of the present invention is by providing a kind of electronic equipment, comprising: processor, memory are deposited by processor acquisition Computer instruction in reservoir executes each step of method shown in above-mentioned Fig. 2 to Fig. 9, carries out acquisition target image, extracts Pixel difference data in target image between the two field pictures of arbitrary neighborhood, pixel difference data are determined as in two field pictures The compressed data of second frame image, and the pressure of the frame image according to the first frame image in target image and in addition to first frame image Contracting data obtain the compression image of target image, to realize the lossless compression to target image, or obtain compression image, extract Data in the compression image, the data include the compression of the first frame image of target image and the frame image in addition to first frame image Data obtain the pixel difference data between frame image and previous frame image in addition to first frame image according to compressed data, from And the initial pictures of the frame image can be determined according to previous frame image and pixel difference data, realize the nothing to compressed data Damage decompression.The deletion of data is not present in compression or decompression process, and due to not being the compression to whole image, so that Storage size shared by image is reduced, and does not influence display effect, and it is time-consuming to reduce transmission.
The embodiment of the present application also provides a kind of computer readable storage medium, which has meter Calculation machine program, the computer program include program instruction, which realizes that Fig. 2 is each into Fig. 9 when being executed by processor The method for consulting the user of text data is determined provided by step, for details, reference can be made to each steps of above-mentioned Fig. 2 to Fig. 9 to be provided Implementation, details are not described herein.
Above-mentioned computer readable storage medium can be the use for determining access text data that aforementioned any embodiment provides The internal storage unit of the device at family or above-mentioned terminal device, such as the hard disk or memory of electronic equipment.This is computer-readable Storage medium is also possible to the plug-in type hard disk being equipped on the External memory equipment of the electronic equipment, such as the electronic equipment, intelligence Energy storage card (smart media card, SMC), secure digital (secure digital, SD) card, flash card (flash Card) etc..Further, which can also both include the internal storage unit of the electronic equipment or wrap Include External memory equipment.The computer readable storage medium is for storing needed for the computer program and the electronic equipment it His program and data.The computer readable storage medium can be also used for temporarily storing the number that has exported or will export According to.
The specification and claims of the embodiment of the present invention and term " first " in attached drawing, " second " etc. are for area Not different objects, not for description particular order.In addition, term " includes " and their any deformations, it is intended that covering Non-exclusive includes.Such as it contains process, method, device, product or the equipment of a series of steps or units and is not limited to Listed step or module, but optionally further comprising the step of not listing or module, or optionally further comprising for this A little process, methods, device, other step units of product or equipment inherently.In addition, term " at least " is for enumerating part feelings Condition, to reflect implementation process, rather than only include that the method provided is implemented to require.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware With the interchangeability of software, each exemplary composition and step are generally described according to function in the above description.This A little functions are implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Specially Industry technical staff can use different methods to achieve the described function each specific application, but this realization is not It is considered as beyond scope of the present application.
Method provided by the embodiments of the present application and relevant apparatus be referring to method flow diagram provided by the embodiments of the present application and/ Or structural schematic diagram is come what is described, can specifically be realized by computer program instructions the every of method flow diagram and/or structural schematic diagram The combination of process and/or box in one process and/or box and flowchart and/or the block diagram.These computer programs refer to Enable the processor that can provide general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices To generate a machine, so that generating use by the instruction that computer or the processor of other programmable data processing devices execute In the function that realization is specified in one or more flows of the flowchart and/or structural schematic diagram one box or multiple boxes Device.These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with specific In the computer-readable memory that mode works, so that it includes instruction that instruction stored in the computer readable memory, which generates, The manufacture of device, the command device are realized in one box of one or more flows of the flowchart and/or structural schematic diagram Or the function of being specified in multiple boxes.These computer program instructions can also be loaded into computer or the processing of other programmable datas In equipment, so that executing series of operation steps on a computer or other programmable device to generate computer implemented place Reason, so that instruction executed on a computer or other programmable device offer is for realizing in one process of flow chart or multiple The step of function of being specified in process and/or structural representation one box or multiple boxes.
The above disclosure is only the preferred embodiments of the present invention, cannot limit the right model of the present invention with this certainly It encloses, therefore equivalent changes made in accordance with the claims of the present invention, is still within the scope of the present invention.

Claims (14)

1. a kind of method for compressing image characterized by comprising
At least one image pair in target image is obtained, the target image includes multiple frame images, and each image is to wrapping Two field pictures containing arbitrary neighborhood in the target image;
Determine the pixel difference data between the two field pictures of at least one image pair;
Based on the difference value between pixel difference data, multiple pixel difference data the two field pictures are ranked up;
The corresponding compressed data of condensed frame image pixel difference data after sequence being determined as in the target image;It is described Condensed frame image is the frame image in the target image other than first frame image;
First frame image in the target image and the compressed data are synthesized into the corresponding compression image of the target image.
2. the method as described in claim 1, which is characterized in that the two field pictures of at least one image pair described in the determination Between pixel difference data, the corresponding compression of the condensed frame image pixel difference data being determined as in the target image Data, comprising:
The image of at least one image pair is obtained to Ti, described image is to TiIncluding frame image SiWith frame image Si+1;I is Positive integer, and i is less than or equal to m-1, the m is the quantity of the frame image in the target image;
Determine the frame image SiWith frame image Si+1Pixel difference data between each pixel, the pixel difference data are frame Image Si+1In be different from the frame image SiPixel colour information;The frame image Si+1Belong to the condensed frame figure Picture;
Based on the difference value between pixel difference data, to the frame image SiWith frame image Si+1Between multiple pixel difference data into Row sequence;
Pixel difference data after sequence are determined as the frame image Si+1Corresponding compressed data, until determining image pair Tm-1In frame image SmCorresponding compressed data.
3. method according to claim 2, which is characterized in that the determination frame image SiWith frame image Si+1Each pixel Pixel difference data between point, comprising:
Compare the frame image SiWith frame image Si+1The colour information of pixel under middle same position information;
When there are the colour information difference of pixel, the different pixel of the colour information is determined as difference pixel, According to frame image Si+1Described in the colour information of difference pixel determine the frame image SiWith frame image Si+1Between pixel difference Heteromerism evidence.
4. method as claimed in claim 3, which is characterized in that described according to frame image Si+1Described in difference pixel color Value information determines the frame image SiWith frame image Si+1Between pixel difference data, comprising:
Obtain the frame image Si+1Described in difference pixel colour information and location information;
Position letter by the Data Format Transform of the location information at the data format of the colour information, after format is converted Breath and the colour information are determined as the frame image SiWith frame image Si+1Between pixel difference data.
5. method according to claim 2, which is characterized in that the difference value between the data based on pixel difference, to described Frame image SiWith frame image Si+1Between multiple pixel difference data be ranked up, comprising:
Described image is obtained to TiCorresponding pixel difference data sorting queue;
It obtains in the pixel difference data sorting queue between j-th of pixel difference data and unsorted pixel difference data Difference value, by the p pixel difference data with the difference value of j-th of pixel difference data less than the first discrepancy threshold, according to It is secondary to be ranked up along j-th of pixel difference data, the unsorted pixel by ordering pixel difference data and after updating Variance data is spliced, and updated pixel difference data sorting queue is obtained;P is 0 or positive integer, and p is less than the picture The quantity of plain variance data;
Pth+j pixel difference data are obtained in the updated pixel difference data sorting queue;
Institute will be less than with the difference value of the pth+j pixel difference data in pixel difference data unsorted after the update K pixel difference data of the first discrepancy threshold are stated, are successively ranked up along the pth+j pixel difference data, until institute State frame image SiWith frame image Si+1Between be not present unsorted pixel difference data.
6. method according to claim 2, which is characterized in that the pixel difference data by after sequence are determined as the frame Image Si+1Corresponding compressed data, comprising:
Determine the length of the first cycling among windows and the length of the second cycling among windows, first cycling among windows and second traversal There are separator between window, first cycling among windows are adjacent with second cycling among windows;
The separator is placed in the first character of the pixel difference data, is determined first described in the pixel difference data The maximum matching length of identical characters in cycling among windows and second cycling among windows, according to the identical of the maximum matching length Character generates first compressed node;
The mobile separator L characters, generate next compressed node, until first cycling among windows and described second time The separator gone through between window is located at the end character of the pixel difference data, and wherein L is based on the maximum matching length Determined by degree;
According to the character for being not belonging to the compressed node in the compressed node and the pixel difference data, the frame is generated Image Si+1Corresponding compressed data.
7. a kind of image expansion method, which is characterized in that the described method includes:
The first frame image and compressed data in compression image are obtained, the first frame image is the first frame image in target image, institute Stating compressed data is the corresponding compressed data of condensed frame image in the target image, and the condensed frame image is the target Frame image in image other than first frame image;
Pixel difference data are determined according to the compressed data, and the target image includes at least one image pair, described image To the two field pictures for including arbitrary neighborhood in target image, difference of the pixel difference data between the adjacent two field pictures It is different;
Target image is drawn according to the pixel difference data and the first frame image.
8. the method for claim 7, which is characterized in that it is described that pixel difference data are determined according to the compressed data, Include:
Obtain the length of the first cycling among windows and the length of the second cycling among windows, first cycling among windows and second traversal There are separator between window, first cycling among windows are adjacent with second cycling among windows;
The separator is in the first character of the compressed data, slides first cycling among windows and second traversal Window traverses each of compressed data character;
If the character is compressed node, the compressed node is reduced to data convert node;
According to the character for being not belonging to the compressed node in the data convert node and the compressed data, the pixel is determined Variance data.
9. the method for claim 7, which is characterized in that described according to the pixel difference data and the first frame image Draw target image, comprising:
Draw the first frame image;
According to image to TiMiddle frame image SiWith frame image Si+1Between pixel difference data and the frame image SiDraw the frame Image Si+1, until determining frame image Sm;M is the quantity of the target image multiple frame images for including, and i is positive integer, and i Less than m;
According to all frame images after drafting, the target image is generated.
10. method as claimed in claim 9, which is characterized in that it is described according to image to TiMiddle frame image SiWith frame image Si+1 Between pixel difference data and the frame image SiDraw the frame image Si+1, comprising:
Described image is obtained to TiThe location information and colour information of middle pixel difference data determine the frame image Si+1In difference Aniseikania vegetarian refreshments, the difference pixel are the corresponding pixel of location information in the pixel difference data;
The frame image S is drawn according to the location information of the pixel difference data and colour informationi+1In the difference pixel Point;
According to non-difference pixel in the frame image SiIn location information and colour information, draw the frame image Si+1In The non-difference pixel, the frame image S after being drawni+1;The non-difference pixel is the frame image SiOr the frame Image Si+1In be the difference pixel pixel.
11. a kind of image compressing device, which is characterized in that described device includes:
Module is obtained, for obtaining at least one image pair in target image, the target image includes multiple frame images, often A image is to the two field pictures for including arbitrary neighborhood in the target image;
Determining module, the pixel difference data between two field pictures for determining at least one image pair, is based on pixel Difference value between variance data is ranked up multiple pixel difference data the two field pictures, described in after sequence Pixel difference data are determined as the corresponding compressed data of condensed frame image in the target image;The condensed frame image is institute State the frame image in target image other than first frame image;
Generation module, it is corresponding for first frame image in the multiple image and the compressed data to be synthesized the target image Compression image.
12. a kind of image decompression compression apparatus, which is characterized in that described device includes:
Module is obtained, for obtaining first frame image and compressed data in compression image, the first frame image is in target image First frame image, the compressed data be the target image in the corresponding compressed data of condensed frame image, the condensed frame Image is the frame image in the target image other than first frame image;
Determining module determines pixel difference data according to the compressed data, and the target image includes at least one image pair, For described image to the two field pictures for including arbitrary neighborhood in target image, the pixel difference data are the two adjacent frame figures Difference as between;
Drafting module, for drawing target image according to the pixel difference data and the first frame image.
13. a kind of electronic equipment, which is characterized in that including processor, memory;
The processor is connected with the memory, wherein for storing program code, the processor is used for the memory Said program code is called, to execute the method as described in any one of claim 1-6 or claim 7-10.
14. a kind of computer storage medium, which is characterized in that the computer storage medium is stored with computer program, described Computer program includes program instruction, and described program instructs when being executed by a processor, executes such as claim 1-6 or right and wants Seek method described in any one of 7-10.
CN201910510161.8A 2019-06-13 2019-06-13 Image compression and decompression method and device, electronic equipment and storage medium Active CN110113617B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910510161.8A CN110113617B (en) 2019-06-13 2019-06-13 Image compression and decompression method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910510161.8A CN110113617B (en) 2019-06-13 2019-06-13 Image compression and decompression method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110113617A true CN110113617A (en) 2019-08-09
CN110113617B CN110113617B (en) 2022-09-20

Family

ID=67494907

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910510161.8A Active CN110113617B (en) 2019-06-13 2019-06-13 Image compression and decompression method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110113617B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111603771A (en) * 2020-05-22 2020-09-01 腾讯科技(深圳)有限公司 Animation generation method, device, equipment and medium
CN111683254A (en) * 2020-06-24 2020-09-18 湖南国科微电子股份有限公司 Image compression method and device, electronic equipment and storage medium
CN112714338A (en) * 2020-12-25 2021-04-27 平安普惠企业管理有限公司 Video transmission method, video playing method, video transmission device, video playing device, computer equipment and storage medium
CN113055729A (en) * 2019-12-27 2021-06-29 中兴通讯股份有限公司 Cloud set top box image differential processing method and device

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030048207A1 (en) * 2001-09-06 2003-03-13 Xerox Corporation Sliding window compression method utilizing compression hotspots
US20030198381A1 (en) * 2002-04-17 2003-10-23 Tetsuomi Tanaka Image compression method and apparatus, and image coding method and apparatus
JP2004229261A (en) * 2002-11-27 2004-08-12 Canon Inc Image-compressing method, image-compressing device, program, and recording media
CN101046735A (en) * 2006-03-30 2007-10-03 华为技术有限公司 Video data compression method
US20080193032A1 (en) * 2007-02-08 2008-08-14 Christopher Andrew Segall Methods and Systems for Coding Multiple Dynamic Range Images
CN105359533A (en) * 2013-08-12 2016-02-24 英特尔公司 Techniques for low power image compression and display
CN105744281A (en) * 2016-03-28 2016-07-06 飞依诺科技(苏州)有限公司 Continuous image processing method and device
US9875552B1 (en) * 2016-07-26 2018-01-23 Teradici Corporation Content independent method of motion determination using sparse matrices
CN109803180A (en) * 2019-03-08 2019-05-24 腾讯科技(深圳)有限公司 Video preview drawing generating method, device, computer equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030048207A1 (en) * 2001-09-06 2003-03-13 Xerox Corporation Sliding window compression method utilizing compression hotspots
US20030198381A1 (en) * 2002-04-17 2003-10-23 Tetsuomi Tanaka Image compression method and apparatus, and image coding method and apparatus
JP2004229261A (en) * 2002-11-27 2004-08-12 Canon Inc Image-compressing method, image-compressing device, program, and recording media
CN101046735A (en) * 2006-03-30 2007-10-03 华为技术有限公司 Video data compression method
US20080193032A1 (en) * 2007-02-08 2008-08-14 Christopher Andrew Segall Methods and Systems for Coding Multiple Dynamic Range Images
CN105359533A (en) * 2013-08-12 2016-02-24 英特尔公司 Techniques for low power image compression and display
CN105744281A (en) * 2016-03-28 2016-07-06 飞依诺科技(苏州)有限公司 Continuous image processing method and device
US9875552B1 (en) * 2016-07-26 2018-01-23 Teradici Corporation Content independent method of motion determination using sparse matrices
CN109803180A (en) * 2019-03-08 2019-05-24 腾讯科技(深圳)有限公司 Video preview drawing generating method, device, computer equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113055729A (en) * 2019-12-27 2021-06-29 中兴通讯股份有限公司 Cloud set top box image differential processing method and device
CN113055729B (en) * 2019-12-27 2024-05-28 中兴通讯股份有限公司 Cloud set top box image differential processing method and device
CN111603771A (en) * 2020-05-22 2020-09-01 腾讯科技(深圳)有限公司 Animation generation method, device, equipment and medium
CN111683254A (en) * 2020-06-24 2020-09-18 湖南国科微电子股份有限公司 Image compression method and device, electronic equipment and storage medium
CN112714338A (en) * 2020-12-25 2021-04-27 平安普惠企业管理有限公司 Video transmission method, video playing method, video transmission device, video playing device, computer equipment and storage medium
CN112714338B (en) * 2020-12-25 2022-11-25 平安普惠企业管理有限公司 Video transmission method, video playing method, video transmission device, video playing device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110113617B (en) 2022-09-20

Similar Documents

Publication Publication Date Title
CN110113617A (en) A kind of method and device of compression of images and decompression
CN108022212B (en) High-resolution picture generation method, generation device and storage medium
CN106611435B (en) Animation processing method and device
JP7165272B2 (en) Video data encoding/decoding method, device, program and computer device
TWI230516B (en) Segmented layered image system
US20210021872A1 (en) Image coding and decoding method and device
JPH04504920A (en) Method and apparatus for manipulating digital video data
CN105933708B (en) A kind of method and apparatus of data compression and decompression
CN112714357B (en) Video playing method, video playing device, electronic equipment and storage medium
CN108235055A (en) Transparent video implementation method and equipment in AR scenes
JP7213291B2 (en) Method and apparatus for generating images
CN110428382A (en) A kind of efficient video Enhancement Method, device and storage medium for mobile terminal
CN112118449B (en) Method and device for compressing and decompressing image
CN101790749B (en) Multi-sample rendering of 2d vector images
EP0810552B1 (en) Image display device
KR100573527B1 (en) How to compress and restore graphic images
CN111768467A (en) Image filling method, device, equipment and storage medium
US20010012398A1 (en) Multi-color image encoding apparatus and method, multi-color image decoding apparatus and method
KR100882250B1 (en) A method for combining dynamic virtual image
CN112653905A (en) Image processing method, device, equipment and storage medium
CN114782249A (en) Super-resolution reconstruction method, device and equipment for image and storage medium
CN111541901B (en) Picture decoding method and device
US6912305B1 (en) Computer animation
US7184599B2 (en) Image compression in retained-mode renderer
CN112150585A (en) Animation data encoding method, animation data decoding method, animation data encoding apparatus, animation data decoding apparatus, storage medium, and computer device

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
GR01 Patent grant
GR01 Patent grant