CN110399511A - Image cache method, equipment, storage medium and device based on Redis - Google Patents

Image cache method, equipment, storage medium and device based on Redis Download PDF

Info

Publication number
CN110399511A
CN110399511A CN201910670805.XA CN201910670805A CN110399511A CN 110399511 A CN110399511 A CN 110399511A CN 201910670805 A CN201910670805 A CN 201910670805A CN 110399511 A CN110399511 A CN 110399511A
Authority
CN
China
Prior art keywords
picture
redis
stored
similarity
group
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910670805.XA
Other languages
Chinese (zh)
Inventor
雷建云
雷才哲
郑禄
宋中山
艾勇
马尧
周玮瑜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
South Central Minzu University
Original Assignee
South Central University for Nationalities
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 South Central University for Nationalities filed Critical South Central University for Nationalities
Priority to CN201910670805.XA priority Critical patent/CN110399511A/en
Publication of CN110399511A publication Critical patent/CN110399511A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/51Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/58Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • G06F16/583Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4038Scaling the whole image or part thereof for image mosaicing, i.e. plane images composed of plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/10Image enhancement or restoration by non-spatial domain filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
    • H03M7/3059Digital compression and data reduction techniques where the original information is represented by a subset or similar information, e.g. lossy compression
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/32Indexing scheme for image data processing or generation, in general involving image mosaicing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20064Wavelet transform [DWT]

Abstract

The invention discloses a kind of, and image cache method, equipment, storage medium and device based on Redis calculate described wait store the picture similarity between picture this method comprises: obtaining multiple pictures to be stored according to difference value hash algorithm;The picture to be stored is grouped according to the picture similarity, obtains multiple picture groups;Picture respectively to be stored in the picture group is spliced, the corresponding splicing picture of the picture group is obtained;Lossless compression is carried out to each splicing picture respectively, obtains picture file compression;Redis buffer memory is carried out to the picture file compression.In the present invention, processing is grouped to picture according to picture similarity, lossless compression has been carried out to it, repeated to express to reduce block of pixels with this, reduce storage cost.

Description

Image cache method, equipment, storage medium and device based on Redis
Technical field
The present invention relates to technical field of data storage more particularly to a kind of image cache method based on Redis, equipment, Storage medium and device.
Background technique
Under the background that unstructured data increases severely, the research that unstructured data storage utilizes also gradually is goed deep into.It is non- Structural data includes three bulks from form, is text, picture and video flowing respectively, nowadays, under many scenes all The similar picture of a large amount of height can be generated, if individually stored to each picture, cost is excessively high.
Above content is only used to facilitate the understanding of the technical scheme, and is not represented and is recognized that above content is existing skill Art.
Summary of the invention
The main purpose of the present invention is to provide a kind of image cache method, equipment, storage medium and dress based on Redis It sets, it is intended to solve the excessively high technical problem of the carrying cost of a large amount of height similar pictures in the prior art.
To achieve the above object, the present invention provides a kind of image cache method based on Redis, described based on Redis's Image cache method the following steps are included:
Multiple pictures to be stored are obtained, are calculated according to difference value hash algorithm described similar wait store the picture between picture Degree;
The picture to be stored is grouped according to the picture similarity, obtains multiple picture groups;
Picture respectively to be stored in the picture group is spliced, the corresponding splicing picture of the picture group is obtained;
Lossless compression is carried out to each splicing picture respectively, obtains picture file compression;
Redis buffer memory is carried out to the picture file compression.
Preferably, described that Redis buffer memory is carried out to the picture file compression, it specifically includes:
Serializing processing is carried out to the picture file compression, obtains serialized data;
The serialized data is subjected to Redis buffer memory.
Preferably, described that lossless compression is carried out respectively to each splicing picture, picture file compression is obtained, is specifically included:
Piecemeal processing is carried out to each splicing picture respectively, obtains the corresponding multiple pieces of pictures of each splicing picture;
Integer wavelet transformation is carried out to described piece of picture, obtains transformation image data;
Entropy coding processing is carried out to the transformation image data, obtains encoded picture data;
Lossless compression is carried out to the encoded picture data, obtains picture file compression.
Preferably, described to obtain multiple pictures to be stored, according to difference value hash algorithm calculate the picture to be stored it Between picture similarity, specifically include:
Multiple pictures to be stored are obtained, described arbitrarily choose a picture to be stored in picture as base wait store from multiple Quasi- picture, other pictures to be stored, which are used as, compares picture;
Picture similarity of the reference base picture compared with described between picture is calculated according to difference value hash algorithm.
Preferably, described that the picture to be stored is grouped according to the picture similarity, multiple picture groups are obtained, It specifically includes:
Judge to be less than or equal to default similarity threshold with the presence or absence of the picture similarity in each picture similarity;
The picture similarity is less than or equal to the default similarity threshold if it exists, then by corresponding relatively picture and institute It states reference base picture and is divided into a picture group;
The difference between the picture similarity is calculated, ungrouped relatively picture is added to by other according to the difference At least one picture group in.
Preferably, the picture respectively to be stored by the picture group splices, and it is corresponding to obtain the picture group Splice picture, specifically include:
Judged respectively to whether there is identical picture in picture wait store in the picture group according to the picture similarity;
If there are identical pictures in the picture group, identical picture is subjected to duplicate removal processing;
Picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture matrix;
Judge whether the picture matrix is a complete matrix;
If the picture matrix is not a complete matrix, obtains the block of pixels that several pixels are preset value and mended Splicing is filled, the corresponding splicing picture of the picture group is obtained.
Preferably, before the progress Redis buffer memory to the picture file compression, the figure based on Redis Piece caching method further include:
Obtain the corresponding code book of the picture group, and obtain respectively the corresponding code of picture to be stored in the code book Reference address;
It is that respectively picture to be stored establishes corresponding two dimension seat in the picture group according to the code book and each reference address Mark;
The respectively picture name of picture to be stored is obtained in the picture group, according to the picture name and the two-dimensional coordinate Establish the corresponding concordance list of the picture group;
Java object encapsulation is carried out to the concordance list, and the encapsulation concordance list that encapsulation is obtained carries out Redis storage.
In addition, to achieve the above object, the present invention also proposes a kind of image cache equipment based on Redis, described to be based on The image cache equipment of Redis includes memory, processor and is stored on the memory and can transport on the processor The capable image cache program based on Redis, the image cache program based on Redis are arranged for carrying out as described above The step of image cache method based on Redis.
In addition, to achieve the above object, the present invention also proposes a kind of storage medium, it is stored with and is based on the storage medium The image cache program of Redis is realized as described above when the image cache program based on Redis is executed by processor The step of image cache method based on Redis.
In addition, to achieve the above object, the present invention also proposes a kind of image cache device based on Redis, described to be based on The image cache device of Redis includes:
Computing module calculates the picture to be stored according to difference value hash algorithm for obtaining multiple pictures to be stored Between picture similarity;
Grouping module obtains multiple pictures for being grouped according to the picture similarity to the picture to be stored Group;
It is corresponding to obtain the picture group for splicing the picture respectively to be stored in the picture group for splicing module Splicing picture;
Lossless compression modules obtain picture file compression for carrying out lossless compression respectively to each splicing picture;
Memory module, for carrying out Redis buffer memory to the picture file compression.
In the present invention, by obtaining multiple pictures to be stored, the picture to be stored is calculated according to difference value hash algorithm Between picture similarity, the picture to be stored is grouped according to the picture similarity, obtains multiple picture groups, will Similar pictures are grouped processing, to reduce cost squeeze;Picture respectively to be stored in the picture group is spliced, is obtained The corresponding splicing picture of the picture group is obtained, lossless compression is carried out to each splicing picture respectively, picture file compression is obtained, will scheme Piece group is uniformly compressed, to reduce the repeated compression storage of same pixel block;Redis is carried out to the picture file compression Compressed code book is carried out Redis storage, reduces storage cost by buffer memory.
Detailed description of the invention
Fig. 1 is the knot of the image cache equipment based on Redis for the hardware running environment that the embodiment of the present invention is related to Structure schematic diagram;
Fig. 2 is that the present invention is based on the flow diagrams of the image cache method first embodiment of Redis;
Fig. 3 is that the present invention is based on the flow diagrams of the image cache method second embodiment of Redis;
Fig. 4 is that the present invention is based on the flow diagrams of the image cache method 3rd embodiment of Redis;
Fig. 5 is that the present invention is based on the structural block diagrams of the image cache device first embodiment of Redis.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
Referring to Fig.1, Fig. 1 is the image cache based on Redis for the hardware running environment that the embodiment of the present invention is related to Device structure schematic diagram.
As shown in Figure 1, being somebody's turn to do the image cache equipment based on Redis may include: processor 1001, such as central processing unit (Central Processing Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, memory 1005.Wherein, communication bus 1002 is for realizing the connection communication between these components.User interface 1003 may include display Shield (Display), optional user interface 1003 can also include standard wireline interface and wireless interface, for user interface 1003 wireline interface can be USB interface in the present invention.Network interface 1004 optionally may include standard wireline interface, Wireless interface (such as Wireless Fidelity (WIreless-FIdelity, WI-FI) interface).Memory 1005 can be the random of high speed Memory (Random Access Memory, RAM) memory is accessed, stable memory (Non-volatile is also possible to Memory, NVM), such as magnetic disk storage.Memory 1005 optionally can also be the storage independently of aforementioned processor 1001 Device.
The image cache based on Redis is set it will be understood by those skilled in the art that structure shown in Fig. 1 is not constituted Standby restriction may include perhaps combining certain components or different component layouts than illustrating more or fewer components.
As shown in Figure 1, as may include that operating system, network are logical in a kind of memory 1005 of computer storage medium Believe module, Subscriber Interface Module SIM and the image cache program based on Redis.
In image cache equipment based on Redis shown in Fig. 1, network interface 1004 is mainly used for connecting background service Device carries out data communication with the background server;User interface 1003 is mainly used for connecting user equipment;It is described to be based on The image cache equipment of Redis calls the image cache journey based on Redis stored in memory 1005 by processor 1001 Sequence, and execute the image cache method provided in an embodiment of the present invention based on Redis.
The image cache equipment based on Redis by processor 1001 call memory 1005 in store based on The image cache program of Redis, and execute following operation:
Multiple pictures to be stored are obtained, are calculated according to difference value hash algorithm described similar wait store the picture between picture Degree;
The picture to be stored is grouped according to the picture similarity, obtains multiple picture groups;
Picture respectively to be stored in the picture group is spliced, the corresponding splicing picture of the picture group is obtained;
Lossless compression is carried out to each splicing picture respectively, obtains picture file compression;
Redis buffer memory is carried out to the picture file compression.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Serializing processing is carried out to the picture file compression, obtains serialized data;
The serialized data is subjected to Redis buffer memory.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Piecemeal processing is carried out to each splicing picture respectively, obtains the corresponding multiple pieces of pictures of each splicing picture;
Integer wavelet transformation is carried out to described piece of picture, obtains transformation image data;
Entropy coding processing is carried out to the transformation image data, obtains encoded picture data;
Lossless compression is carried out to the encoded picture data, obtains picture file compression.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Multiple pictures to be stored are obtained, described arbitrarily choose a picture to be stored in picture as base wait store from multiple Quasi- picture, other pictures to be stored, which are used as, compares picture;
Picture similarity of the reference base picture compared with described between picture is calculated according to difference value hash algorithm.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Judge to be less than or equal to default similarity threshold with the presence or absence of the picture similarity in each picture similarity;
The picture similarity is less than or equal to the default similarity threshold if it exists, then by corresponding relatively picture and institute It states reference base picture and is divided into a picture group;
The difference between the picture similarity is calculated, ungrouped relatively picture is added to by other according to the difference At least one picture group in.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Judged respectively to whether there is identical picture in picture wait store in the picture group according to the picture similarity;
If there are identical pictures in the picture group, identical picture is subjected to duplicate removal processing;
Picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture matrix;
Judge whether the picture matrix is a complete matrix;
If the picture matrix is not a complete matrix, obtains the block of pixels that several pixels are preset value and mended Splicing is filled, the corresponding splicing picture of the picture group is obtained.
Further, the image cache equipment based on Redis is called in memory 1005 by processor 1001 and is deposited The image cache program based on Redis of storage also executes following operation:
Obtain the corresponding code book of the picture group, and obtain respectively the corresponding code of picture to be stored in the code book Reference address;
It is that respectively picture to be stored establishes corresponding two dimension seat in the picture group according to the code book and each reference address Mark;
The respectively picture name of picture to be stored is obtained in the picture group, according to the picture name and the two-dimensional coordinate Establish the corresponding concordance list of the picture group;
Java object encapsulation is carried out to the concordance list, and the encapsulation concordance list that encapsulation is obtained carries out Redis storage.
In the present embodiment, by obtaining multiple pictures to be stored, the figure to be stored is calculated according to difference value hash algorithm Picture similarity between piece is grouped the picture to be stored according to the picture similarity, obtains multiple picture groups, Similar pictures are grouped processing, to reduce cost squeeze;Picture respectively to be stored in the picture group is spliced, The corresponding splicing picture of the picture group is obtained, lossless compression is carried out to each splicing picture respectively, obtains picture file compression, it will Picture group is uniformly compressed, to reduce the repeated compression storage of same pixel block;The picture file compression is carried out Compressed code book is carried out Redis storage, reduces storage cost by Redis buffer memory.
Based on above-mentioned hardware configuration, propose that the present invention is based on the embodiments of the image cache method of Redis.
It is to be proposed the present invention is based on the flow diagram of the image cache method first embodiment of Redis referring to Fig. 2, Fig. 2 The present invention is based on the image cache method first embodiments of Redis.
In the first embodiment, the image cache method based on Redis the following steps are included:
Step S10: obtaining multiple pictures to be stored, and is calculated according to difference value hash algorithm described wait store between picture Picture similarity.
It should be understood that the executing subject of the present embodiment is the image cache equipment based on Redis, it is described to be based on The image cache equipment of Redis can be the electronic equipments such as PC or server, and the present embodiment is without restriction to this. To avoid a large amount of picture features from calculating, picture is generally abstracted as several characteristic values, for example, Trace transformation, image Hash and Sift feature vector etc..Since part picture feature is less and the smooth of the edge, such as all kinds of fruit such as orange, it is also reduction image The interference that shooting angle difference judges similarity picture, can calculate the similarity between picture by perceptual hash algorithm.
It should be noted that perceptual hash algorithm carries out cryptographic Hash calculating in relative form, therefore for similarity Judgement also has certain relativity.Perceptual hash algorithm includes average value Hash (aHash), perceptual hash (pHash) and poor The algorithm for being best suitable for this paper system is found in different value Hash (dHash), experiment test.Three kinds of algorithm parameters are different, therefore make It obtains its speed and accuracy is different, experiment selects 150000 pictures to be tested, and has several to be known to occur number in experiment Test picture to be found, lookup judgement is carried out by experiment, and speed is carried out with this and accuracy judges.A such as picture Occur in 150000 pictures once, another occurs twice, and third appearance 32 is inferior, uses aHash, pHash respectively Test picture is searched in this 150000 picture with tri- kinds of algorithms of dHash, according to experimental result, selects accuracy and speed all Preferable difference value Hash carries out similarity calculation, handles every picture, generates " fingerprint " character string, then compares The Hamming distance of more different picture fingerprints.Fingerprint is more similar, and Hamming distance is smaller, illustrates that picture is more similar, i.e., by the Hamming Distance is used as the picture similarity.
Step S20: the picture to be stored is grouped according to the picture similarity, obtains multiple picture groups.
It will be appreciated that carrying out similarity calculation on the basis of a picture with other pictures, similar picture being divided into One group.Remaining picture repeats this work, completes until being grouped all pictures.But it considers calculation times, is schemed with one As reference base picture, other pictures compare picture and carry out similarity calculation with reference base picture respectively piece as picture is compared, thus Corresponding Hamming distance is obtained as the picture similarity.May determine that according to the Hamming distance compare picture with it is described Similarity between reference base picture, and can substantially infer that compare picture possible between picture compared with according to Hamming distance Similarity, to carry out specific aim calculating again.By similarity it is close described in picture to be stored be divided into one group, obtain multiple figures Piece group.
Step S30: the picture respectively to be stored in the picture group is spliced, and obtains the corresponding splicing of the picture group Picture.
In the concrete realization, a picture to be stored is considered as a secondary two-dimensional digital image, and pixel is exactly in matrix One number, picture compression exactly carry out duplicate digital information to simplify expression.It is by picture similarity that picture, which is grouped situation, Threshold value determines that grouping keeps same picture of organizing more similar, i.e., with there are a large amount of similar pixel blocks in group picture.It is compressed into reduce This, same group of picture to be stored is spliced, a code book is combined into, and reduces expression time convenient for compression space.But When similarity is high, Hamming distance calculated result is 0, two pictures to be stored can be regarded as same picture, only stored One picture.At this point, code book is removed almost after on all four picture by organizing picture together, a spelling being spliced Map interlinking piece.
Step S40: lossless compression is carried out to each splicing picture respectively, obtains picture file compression.
It will be appreciated that first set world Static Picture Compression standard is by JPEG (Joint Photographic Experts Group) it proposes, 80% image all uses JPEG compression standard on website, and JPEG compression ratio is not visually It is very considerable in visible situation.Although JPEG Joint Photographic Experts Group has preferable rate distortion characteristic, in low bit Blocking artifact is easy to produce at rate, so that picture quality is very poor.And JPEG does not provide lossless compression, does not support to be greater than 64*64K Compression of images, for these problems, the present embodiment using JPEG upgrade version JPEG2000 to each splicing picture progress it is lossless Compression.JPEG2000 supports lossless compression, and compression ratio compares JPEG and improves about 30% or so.To prevent code book to lack Amount distortion, and picture group reconstructed picture is caused a large amount of distortions occur, picture quality is influenced, JPEG2000 compression standard pair is passed through The code book of each splicing picture carries out lossless compression, obtains picture file compression.
Step S50: Redis buffer memory is carried out to the picture file compression.
It should be noted that carrying out lossless compression to the code book of each splicing picture, picture file compression, the pressure are obtained Contracting picture file is the code book of compression, converts Object object for the code book of compression, and carry out to Object object Java serializing, the serialized data that serializing is obtained carry out Redis buffer memory.This embodiment scheme can be applied to characteristic Agricultural product service platform, each agricultural product are shown by multilingual, and support bilingual displaying, and system is to agricultural production When product details are shown, minimum 5 product pictures are needed, multilingual displaying and agricultural product itself there is a variety of phases Like picture, so that occurring a large amount of similar pictures in system, these pictures can be carried out by the above scheme of this implementation efficient Storage.
In the present embodiment, by obtaining multiple pictures to be stored, the figure to be stored is calculated according to difference value hash algorithm Picture similarity between piece is grouped the picture to be stored according to the picture similarity, obtains multiple picture groups, Similar pictures are grouped processing, to reduce cost squeeze;Picture respectively to be stored in the picture group is spliced, The corresponding splicing picture of the picture group is obtained, lossless compression is carried out to each splicing picture respectively, obtains picture file compression, it will Picture group is uniformly compressed, to reduce the repeated compression storage of same pixel block;The picture file compression is carried out Compressed code book is carried out Redis storage, reduces storage cost by Redis buffer memory.
It is to be based on the present invention is based on the flow diagram of the image cache method second embodiment of Redis referring to Fig. 3, Fig. 3 Above-mentioned first embodiment shown in Fig. 2 proposes that the present invention is based on the second embodiments of the image cache method of Redis.
In a second embodiment, the step S50, comprising:
Serializing processing is carried out to the picture file compression, obtains serialized data;
The serialized data is subjected to Redis buffer memory.
It should be understood that the picture file compression is the code book of compression, for the ease of storage, by the generation of the compression Code book carries out serializing processing in the form of byte stream, obtains the serialized data for being easy to store, then by the serialized data Carry out Redis buffer memory.
In a second embodiment, the step S30, comprising:
Step S301: judged respectively to whether there is phase in picture wait store in the picture group according to the picture similarity Same picture.
It should be understood that when similarity is high, i.e., it, can be by two wait store when the described Hamming distance calculated result is 0 Picture regards same picture as, a picture is only stored, to realize efficient storage.
Step S302: if there are identical pictures in the picture group, identical picture is subjected to duplicate removal processing.
It should be noted that carrying out similarity calculation by difference value Hash, every picture to be stored is handled, it is raw At " fingerprint " character string, the then Hamming distance of more different picture fingerprints to be stored.Fingerprint is more similar, and Hamming distance is got over It is small, illustrate that picture is more similar, i.e., using the Hamming distance as the picture similarity.Can by comparing the Hamming distance, If the Hamming distance of two pictures to be stored is 0, which can be considered identical picture, if it exists Multiple identical pictures can carry out duplicate removal processing to identical picture, only retain a picture in multiple identical pictures i.e. It can.
Step S303: the picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture square Battle array.
It will be appreciated that the code book of the picture group is spliced and combined by similar picture to be stored, need to spell Map interlinking piece is in the same size, makes respectively can directly be spliced between picture wait store, cuts picture when facilitating reconstructed picture group.This reality Applying a scheme can be applied to Ways of Special Agricultural Products service platform, since the Ways of Special Agricultural Products service platform is carrying out agricultural product information When typing, agricultural product dimension of picture size is had certain limitations, therefore every picture ratio is not much different, and can unify to picture Zoom to identical size, although picture appearance can be made to be distorted to a certain degree, distortion level naked eyes are almost invisible.Removal is intimate After identical picture, remaining picture to be stored splices at first according to preset direction wait store around picture respectively, if It is spliced to form a new matrix, is spliced again by the preset direction, until needing to be stored in the picture group Picture splicing is completed, and the picture matrix is obtained.The preset direction can be clockwise.
Step S304: judge whether the picture matrix is a complete matrix.
In the concrete realization, when in the picture group need to be stored picture splicing complete when, need to judge splicing figure Whether piece matrix is a complete matrix, if not a complete matrix, then can fill remaining rest, so that It becomes a complete matrix.
Step S305: if the picture matrix is not a complete matrix, the picture that several pixels are preset value is obtained Plain block carries out supplement splicing, obtains the corresponding splicing picture of the picture group.
It should be understood that the preset value is (0,0,0), the black picture element block that several pixels are (0,0,0) can be obtained Rest is substituted, supplement splicing is carried out, thus obtain a complete matrix, i.e., the corresponding splicing picture of described picture group.
In a second embodiment, the step S40, comprising:
Step S401: piecemeal processing is carried out to each splicing picture respectively, it is multiple pieces corresponding to obtain each splicing picture Picture.
It will be appreciated that carrying out piecemeal processing to picture, the size of piecemeal is any, but will affect the quality of reconstructed picture. The code book of the picture group in the present embodiment is spliced by the picture of same size, and therefore, piecemeal size can here To splice picture size.
Step S402: carrying out integer wavelet transformation to described piece of picture, obtains transformation image data.
It should be noted that lossless compression is used to code book, using fast discrete wavelet transform (Fast Discrete Wavelet Transform, FDWT) integer wavelet transformation is carried out to described piece of picture, and data-bias is carried out, obtain the change Change image data.Since the sample value of described piece of picture is unsigned number, need to add in the sample value of each described piece of picture One offset -2B-1, keep the sub-band coefficients of wavelet transformation generation symmetrical about 0.
Step S403: entropy coding processing is carried out to the transformation image data, obtains encoded picture data.
In the concrete realization, the correlation between elimination data in statistical significance, using entropy coding to the transformation picture Data are handled, and are controlled using quality of the code stream layered model to image, and the encoded picture data are obtained.
Step S404: lossless compression is carried out to the encoded picture data, obtains picture file compression.
It will be appreciated that carrying out lossless compression to the encoded picture data by JPEG2000 compression standard, pressed Contracting picture file.
In the present embodiment, respectively whether there is wait store in picture in the picture group is judged according to the picture similarity Identical picture is carried out duplicate removal processing, by the picture if there are identical pictures in the picture group by identical picture Picture respectively to be stored in group is spliced according to preset direction, is obtained the corresponding splicing picture of the picture group, is combined into one A code book reduces expression time convenient for compression space;Piecemeal processing is carried out to each splicing picture respectively, obtains each splicing picture Corresponding multiple pieces of pictures carry out integer wavelet transformation, entropy coding processing and lossless compression to described piece of picture, are pressed Contracting picture file reduces code book and is taken up space, and reduces caching cost.
It is to be based on the present invention is based on the flow diagram of the image cache method 3rd embodiment of Redis referring to Fig. 4, Fig. 4 Above-mentioned second embodiment shown in Fig. 3 proposes that the present invention is based on the 3rd embodiments of the image cache method of Redis.
In the third embodiment, the step S10, comprising:
Step S101: obtaining multiple pictures to be stored, and described one is arbitrarily chosen in picture wait store wait store from multiple For picture as reference base picture, other pictures to be stored, which are used as, compares picture.
It should be understood that obtain multiple pictures to be stored, described one is arbitrarily chosen in picture wait deposit wait store from multiple Picture is stored up as reference base picture, similarity calculation is carried out with other pictures to be stored, similar picture to be stored is divided into one group. Remaining picture repeats the step, until will need to be stored picture grouping completion.But consider calculation times, it is multiple wait deposit Other pictures store in storage picture other than the reference base picture as comparing picture, by the comparison picture respectively with The reference base picture carries out similarity calculation, to obtain corresponding Hamming distance as the picture similarity.
Step S102: picture phase of the reference base picture compared with described between picture is calculated according to difference value hash algorithm Like degree.
It will be appreciated that carrying out similarity calculation according to difference value hash algorithm, every picture to be processed is handled, " fingerprint " character string is generated, then the Hamming distance of more different picture fingerprints to be processed.Fingerprint is more similar, Hamming distance It is smaller, illustrate that picture is more similar, i.e., using the Hamming distance as the picture similarity.It can be sentenced according to the Hamming distance The disconnected similarity relatively between picture and the reference base picture described out, and each comparison can be substantially inferred according to Hamming distance Possible similarity between picture, to carry out specific aim calculating again.
In the third embodiment, the step S20, comprising:
Judge to be less than or equal to default similarity threshold with the presence or absence of the picture similarity in each picture similarity;
The picture similarity is less than or equal to the default similarity threshold if it exists, then by corresponding relatively picture and institute It states reference base picture and is divided into a picture group;
The difference between the picture similarity is calculated, ungrouped relatively picture is added to by other according to the difference At least one picture group in.
It should be noted that judging similar less than or equal to presetting with the presence or absence of the picture similarity in each picture similarity Spend threshold value;If it exists the picture similarity be less than or equal to the default similarity threshold, then by it is corresponding relatively picture with The reference base picture is divided into a picture group, calculates the difference between the picture similarity, will be grouped according to the difference Comparison picture be added at least one other picture group;If it does not exist, then using the reference base picture as a picture Group calculates the difference between the picture similarity, and the relatively picture is added to others at least one according to the difference In a picture group.
In the concrete realization, the default similarity threshold may be configured as 1, for example, there is 6 pictures to be processed: A, B, C, D, E and F selects picture A to be processed as the reference base picture, other picture B, C, D, E and F to be processed are the relatively figure Piece calculates separately the Hamming distance relatively between picture and the reference base picture are as follows: and 4,5,1,0 and 7, it is arranged described default When similarity threshold is 1, it can clearly judge that the relatively similarity of picture D, E and the reference base picture A is high;Institute It states and compares picture B, C and the reference base picture A is somewhat different, and relatively picture B picture C possibility similarity with described compared with It is higher;The relatively picture F is lower with the reference base picture A similarity.It therefore can be by the reference base picture A, the ratio It is one group compared with picture D and described relatively picture E points, the relatively picture F is one group, is temporarily by described relatively picture B and C points One group, and continue to calculate the relatively similarity of picture B picture C with described compared with, and so on until grouping completion, makes often Group has plurality of pictures or a picture.
In the third embodiment, before the step S50, further includes:
Obtain the corresponding code book of the picture group, and obtain respectively the corresponding code of picture to be stored in the code book Reference address;
It is that respectively picture to be stored establishes corresponding two dimension seat in the picture group according to the code book and each reference address Mark;
The respectively picture name of picture to be stored is obtained in the picture group, according to the picture name and the two-dimensional coordinate Establish the corresponding concordance list of the picture group;
Java object encapsulation is carried out to the concordance list, and the encapsulation concordance list that encapsulation is obtained carries out Redis storage.
It should be understood that respectively picture to be stored is spliced in the picture group, it is combined into a code book, in code book Code is each picture to be stored in the picture group, therefore can be by respectively picture to be stored uses in code book in the picture group The reference address of code indicates.A two-dimensional coordinate is established for the code book of the picture group, each picture to be stored has One coordinate, respectively the code reference address of picture to be stored is coordinate address in the picture group, and entire picture group can be seen Make a matrix coordinate file.
It will be appreciated that each small lattice of the code book of the picture group are a picture to be stored, each picture to be stored Side length is a coordinate value, by taking the picture group of four picture compositions to be stored as an example, first, basic picture, that is, upper left corner picture Coordinate be (0,0), the Picture Coordinate to be stored on the basis picture left side is (1,0), and Picture Coordinate to be stored below is (1,0), and so on.Picture to be stored in the picture group can be indicated using reference coordinate, picture A to be stored draws It is (0,0), entitled original image title with coordinate.Concordance list quotes coordinate by code and picture name forms, finally by the figure The code book of piece group is separately stored with the concordance list.To guarantee picture quality after reconstructed picture group, by picture name and The information such as original size are all stored in the concordance list, and the concordance list is encapsulated as Java object, and encapsulation is obtained It encapsulates concordance list and carries out Redis storage.
In the third embodiment, after the step S50, further includes:
The object for obtaining Redis buffer memory carries out unserializing processing to the object, obtains object code sheet;
The object code is originally decompressed, decompression code book is obtained;
Obtain the concordance list of Redis buffer memory;
Picture reconstruction is carried out according to the concordance list and the decompression code book, obtains the picture to be stored.
It should be noted that before reading picture group the object stored in Redis can be read according to key value, to obtain Concordance list is taken, and corresponding code book is obtained by unserializing.For example, user is when requesting agricultural product picture group, request is connect Mouth can transmit the key value of respective objects picture group.Code book is decompressed, eventually by code book and concordance list reconstructed picture Group, to obtain original picture group.
In the concrete realization, after carrying out serializing storage to compressed code book, unserializing can only be used to it It is restored, but unserializing is likely to occur Java unserializing loophole.Unserializing is the inverse process of serializing, after conversion The byte stream of storage is converted to data object again, and user is facilitated to operate.At this point, if certain malicious users have input not Trust data, and Java is applied and has been carried out unserializing processing to it, so that the object that user is expected is produced, and this mistake Journey likely results in the execution of some malicious codes.Image data is read using Java unserializing in the present embodiment, therefore is needed This problem is prevented.The main reason for Java unserializing loophole known to analysis is to carry out unserializing to data Before operation, data are not detected, cause arbitrary data can be by unserializing.To Java unserializing loophole take with Lower restoring and fastening method:
(1) it using commons-collections.jar packet more than 3.2.2 version, has increased newly to dangerous java class Sequence Switching, default close, need to carry out specific aim unlatching.
(2) ObjectInputStream class is replaced with into SerialKiller, and carries out serializing operation with such, but Only interim solution, the other influences generated are unknown.
(3) by commons-collections.jar InvokerTransformer.class file, InstantiateFactory.class and InstantiateTransformer.cl-ass file is deleted, but need to not influenced It is carried out under the premise of other regular traffics in system.
In the present embodiment, by obtaining multiple pictures to be stored, described one is arbitrarily chosen in picture wait store from multiple Picture to be stored is as reference base picture, other pictures to be stored, which are used as, compares picture, according to the calculating of difference value hash algorithm Picture similarity of the reference base picture compared with described between picture reduces calculation times, improves the calculating effect of picture similarity Rate.
In addition, the embodiment of the present invention also proposes a kind of storage medium, the figure based on Redis is stored on the storage medium Piece caches program, and the image cache program based on Redis realizes following steps when being executed by processor:
Multiple pictures to be stored are obtained, are calculated according to difference value hash algorithm described similar wait store the picture between picture Degree;
The picture to be stored is grouped according to the picture similarity, obtains multiple picture groups;
Picture respectively to be stored in the picture group is spliced, the corresponding splicing picture of the picture group is obtained;
Lossless compression is carried out to each splicing picture respectively, obtains picture file compression;
Redis buffer memory is carried out to the picture file compression.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Serializing processing is carried out to the picture file compression, obtains serialized data;
The serialized data is subjected to Redis buffer memory.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Piecemeal processing is carried out to each splicing picture respectively, obtains the corresponding multiple pieces of pictures of each splicing picture;
Integer wavelet transformation is carried out to described piece of picture, obtains transformation image data;
Entropy coding processing is carried out to the transformation image data, obtains encoded picture data;
Lossless compression is carried out to the encoded picture data, obtains picture file compression.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Multiple pictures to be stored are obtained, described arbitrarily choose a picture to be stored in picture as base wait store from multiple Quasi- picture, other pictures to be stored, which are used as, compares picture;
Picture similarity of the reference base picture compared with described between picture is calculated according to difference value hash algorithm.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Judge to be less than or equal to default similarity threshold with the presence or absence of the picture similarity in each picture similarity;
The picture similarity is less than or equal to the default similarity threshold if it exists, then by corresponding relatively picture and institute It states reference base picture and is divided into a picture group;
The difference between the picture similarity is calculated, ungrouped relatively picture is added to by other according to the difference At least one picture group in.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Judged respectively to whether there is identical picture in picture wait store in the picture group according to the picture similarity;
If there are identical pictures in the picture group, identical picture is subjected to duplicate removal processing;
Picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture matrix;
Judge whether the picture matrix is a complete matrix;
If the picture matrix is not a complete matrix, obtains the block of pixels that several pixels are preset value and mended Splicing is filled, the corresponding splicing picture of the picture group is obtained.
Further, following operation is also realized when the image cache program based on Redis is executed by processor:
Obtain the corresponding code book of the picture group, and obtain respectively the corresponding code of picture to be stored in the code book Reference address;
It is that respectively picture to be stored establishes corresponding two dimension seat in the picture group according to the code book and each reference address Mark;
The respectively picture name of picture to be stored is obtained in the picture group, according to the picture name and the two-dimensional coordinate Establish the corresponding concordance list of the picture group;
Java object encapsulation is carried out to the concordance list, and the encapsulation concordance list that encapsulation is obtained carries out Redis storage.
In the present embodiment, by obtaining multiple pictures to be stored, the figure to be stored is calculated according to difference value hash algorithm Picture similarity between piece is grouped the picture to be stored according to the picture similarity, obtains multiple picture groups, Similar pictures are grouped processing, to reduce cost squeeze;Picture respectively to be stored in the picture group is spliced, The corresponding splicing picture of the picture group is obtained, lossless compression is carried out to each splicing picture respectively, obtains picture file compression, it will Picture group is uniformly compressed, to reduce the repeated compression storage of same pixel block;The picture file compression is carried out Compressed code book is carried out Redis storage, reduces storage cost by Redis buffer memory.
In addition, the embodiment of the present invention also proposes a kind of image cache device based on Redis, described to be based on referring to Fig. 5 The image cache device of Redis includes:
Computing module 10 calculates the figure to be stored according to difference value hash algorithm for obtaining multiple pictures to be stored Picture similarity between piece.
It should be understood that picture is generally abstracted as several characteristic values to avoid a large amount of picture features from calculating, such as Trace transformation, image Hash and Sift feature vector etc..Since part picture feature is less and the smooth of the edge, such as orange etc. All kinds of fruit can pass through perceptual hash algorithm also to reduce the interference that image taking angle difference judges similarity picture To calculate the similarity between picture.
It should be noted that perceptual hash algorithm carries out cryptographic Hash calculating in relative form, therefore for similarity Judgement also has certain relativity.Perceptual hash algorithm includes average value Hash (aHash), perceptual hash (pHash) and poor The algorithm for being best suitable for this paper system is found in different value Hash (dHash), experiment test.Three kinds of algorithm parameters are different, therefore make It obtains its speed and accuracy is different, experiment selects 150000 pictures to be tested, and has several to be known to occur number in experiment Test picture to be found, lookup judgement is carried out by experiment, and speed is carried out with this and accuracy judges.A such as picture Occur in 150000 pictures once, another occurs twice, and third appearance 32 is inferior, uses aHash, pHash respectively Test picture is searched in this 150000 picture with tri- kinds of algorithms of dHash, according to experimental result, selects accuracy and speed all Preferable difference value Hash carries out similarity calculation, handles every picture, generates " fingerprint " character string, then compares The Hamming distance of more different picture fingerprints.Fingerprint is more similar, and Hamming distance is smaller, illustrates that picture is more similar, i.e., by the Hamming Distance is used as the picture similarity.
Grouping module 20 obtains multiple figures for being grouped according to the picture similarity to the picture to be stored Piece group.
It will be appreciated that carrying out similarity calculation on the basis of a picture with other pictures, similar picture being divided into One group.Remaining picture repeats this work, completes until being grouped all pictures.But it considers calculation times, is schemed with one As reference base picture, other pictures compare picture and carry out similarity calculation with reference base picture respectively piece as picture is compared, thus Corresponding Hamming distance is obtained as the picture similarity.May determine that according to the Hamming distance compare picture with it is described Similarity between reference base picture, and can substantially infer that compare picture possible between picture compared with according to Hamming distance Similarity, to carry out specific aim calculating again.By similarity it is close described in picture to be stored be divided into one group, obtain multiple figures Piece group.
Splicing module 30 obtains the picture group pair for splicing the picture respectively to be stored in the picture group The splicing picture answered.
In the concrete realization, a picture to be stored is considered as a secondary two-dimensional digital image, and pixel is exactly in matrix One number, picture compression exactly carry out duplicate digital information to simplify expression.It is by picture similarity that picture, which is grouped situation, Threshold value determines that grouping keeps same picture of organizing more similar, i.e., with there are a large amount of similar pixel blocks in group picture.It is compressed into reduce This, same group of picture to be stored is spliced, a code book is combined into, and reduces expression time convenient for compression space.But When similarity is high, Hamming distance calculated result is 0, two pictures to be stored can be regarded as same picture, only stored One picture.At this point, code book is removed almost after on all four picture by organizing picture together, a spelling being spliced Map interlinking piece.
Lossless compression modules 40 obtain picture file compression for carrying out lossless compression respectively to each splicing picture.
It will be appreciated that first set world Static Picture Compression standard is by JPEG (Joint Photographic Experts Group) it proposes, 80% image all uses JPEG compression standard on website, and JPEG compression ratio is not visually It is very considerable in visible situation.Although JPEG Joint Photographic Experts Group has preferable rate distortion characteristic, in low bit Blocking artifact is easy to produce at rate, so that picture quality is very poor.And JPEG does not provide lossless compression, does not support to be greater than 64*64K Compression of images, for these problems, the present embodiment using JPEG upgrade version JPEG2000 to each splicing picture progress it is lossless Compression.JPEG2000 supports lossless compression, and compression ratio compares JPEG and improves about 30% or so.To prevent code book to lack Amount distortion, and picture group reconstructed picture is caused a large amount of distortions occur, picture quality is influenced, JPEG2000 compression standard pair is passed through The code book of each splicing picture carries out lossless compression, obtains picture file compression.
Memory module 50, for carrying out Redis buffer memory to the picture file compression.
It should be noted that carrying out lossless compression to the code book of each splicing picture, picture file compression, the pressure are obtained Contracting picture file is the code book of compression, converts Object object for the code book of compression, and carry out to Object object Java serializing, the serialized data that serializing is obtained carry out Redis buffer memory.This embodiment scheme can be applied to characteristic Agricultural product service platform, each agricultural product are shown by multilingual, and support bilingual displaying, and system is to agricultural production When product details are shown, minimum 5 product pictures are needed, multilingual displaying and agricultural product itself there is a variety of phases Like picture, so that occurring a large amount of similar pictures in system, these pictures can be carried out by the above scheme of this implementation efficient Storage.
In the present embodiment, by obtaining multiple pictures to be stored, the figure to be stored is calculated according to difference value hash algorithm Picture similarity between piece is grouped the picture to be stored according to the picture similarity, obtains multiple picture groups, Similar pictures are grouped processing, to reduce cost squeeze;Picture respectively to be stored in the picture group is spliced, The corresponding splicing picture of the picture group is obtained, lossless compression is carried out to each splicing picture respectively, obtains picture file compression, it will Picture group is uniformly compressed, to reduce the repeated compression storage of same pixel block;The picture file compression is carried out Compressed code book is carried out Redis storage, reduces storage cost by Redis buffer memory.
In one embodiment, the memory module 50 is also used to carry out serializing processing to the picture file compression, obtain Obtain serialized data;The serialized data is subjected to Redis buffer memory.
In one embodiment, the lossless compression modules 40 are also used to carry out piecemeal processing respectively to each splicing picture, obtain Obtain the corresponding multiple pieces of pictures of each splicing picture;Integer wavelet transformation is carried out to described piece of picture, obtains Transformation Graphs the piece number According to;Entropy coding processing is carried out to the transformation image data, obtains encoded picture data;Nothing is carried out to the encoded picture data Damage compression, obtains picture file compression.
In one embodiment, the computing module 10 is also used to obtain multiple pictures to be stored, from multiple described wait store A picture to be stored arbitrarily is chosen in picture as reference base picture, other pictures to be stored, which are used as, compares picture;According to difference Value hash algorithm calculates picture similarity of the reference base picture compared with described between picture.
In one embodiment, the grouping module 20 is also used to judge in each picture similarity with the presence or absence of the picture Similarity is less than or equal to default similarity threshold;The picture similarity is less than or equal to the default similarity threshold if it exists, Corresponding relatively picture and the reference base picture are then divided into a picture group;The difference between the picture similarity is calculated, Ungrouped relatively picture is added at least one other picture group according to the difference.
In one embodiment, the splicing module 30 is also used to be judged in the picture group according to the picture similarity Respectively wait store in picture with the presence or absence of identical picture;If there are identical pictures in the picture group, by identical figure Piece carries out duplicate removal processing;Picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture matrix; Judge whether the picture matrix is a complete matrix;If the picture matrix is not a complete matrix, obtain Several pixels are that the block of pixels of preset value carries out supplement splicing, obtain the corresponding splicing picture of the picture group.
In one embodiment, the image cache device based on Redis further include:
Module is obtained, for obtaining the corresponding code book of the picture group, and obtains the respectively corresponding code of picture to be stored Reference address in the code book;
Module is established, for being that respectively picture to be stored is established in the picture group according to the code book and each reference address Corresponding two-dimensional coordinate;
It is described to establish module, it is also used to obtain in the picture group the respectively picture name of picture to be stored, according to the figure Piece title and the two-dimensional coordinate establish the corresponding concordance list of the picture group;
The memory module 50 is also used to carry out the concordance list Java object encapsulation, and the encapsulation that encapsulation is obtained Concordance list carries out Redis storage.
The other embodiments or specific implementation of image cache device of the present invention based on Redis can refer to above-mentioned Each method embodiment, details are not described herein again.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the system that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or system institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or system.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.If listing equipment for drying Unit claim in, several in these devices, which can be, to be embodied by the same item of hardware.Word first, Second and the use of third etc. do not indicate any sequence, can be mark by these word explanations.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a storage medium (such as read-only memory mirror image (Read Only Memory image, ROM)/random access memory (Random Access Memory, RAM), magnetic disk, CD) in, including some instructions are used so that terminal device (can be mobile phone, computer, Server, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of image cache method based on Redis, which is characterized in that the image cache method based on Redis includes Following steps:
Multiple pictures to be stored are obtained, are calculated according to difference value hash algorithm described wait store the picture similarity between picture;
The picture to be stored is grouped according to the picture similarity, obtains multiple picture groups;
Picture respectively to be stored in the picture group is spliced, the corresponding splicing picture of the picture group is obtained;
Lossless compression is carried out to each splicing picture respectively, obtains picture file compression;
Redis buffer memory is carried out to the picture file compression.
2. the image cache method based on Redis as described in claim 1, which is characterized in that described to the compressed picture File carries out Redis buffer memory, specifically includes:
Serializing processing is carried out to the picture file compression, obtains serialized data;
The serialized data is subjected to Redis buffer memory.
3. the image cache method based on Redis as described in claim 1, which is characterized in that described to each splicing picture point Not carry out lossless compression, obtain picture file compression, specifically include:
Piecemeal processing is carried out to each splicing picture respectively, obtains the corresponding multiple pieces of pictures of each splicing picture;
Integer wavelet transformation is carried out to described piece of picture, obtains transformation image data;
Entropy coding processing is carried out to the transformation image data, obtains encoded picture data;
Lossless compression is carried out to the encoded picture data, obtains picture file compression.
4. the image cache method based on Redis as described in claim 1, which is characterized in that the acquisition is multiple wait store Picture, it is described wait store the picture similarity between picture according to the calculating of difference value hash algorithm, it specifically includes:
Multiple pictures to be stored are obtained, described arbitrarily choose a picture to be stored in picture as reference map wait store from multiple Piece, other pictures to be stored, which are used as, compares picture;
Picture similarity of the reference base picture compared with described between picture is calculated according to difference value hash algorithm.
5. the image cache method based on Redis as claimed in claim 4, which is characterized in that described according to the picture phase The picture to be stored is grouped like degree, multiple picture groups is obtained, specifically includes:
Judge to be less than or equal to default similarity threshold with the presence or absence of the picture similarity in each picture similarity;
The picture similarity is less than or equal to the default similarity threshold if it exists, then by corresponding relatively picture and the base Quasi- picture is divided into a picture group;
The difference between the picture similarity is calculated, ungrouped relatively picture is added to extremely by others according to the difference In a few picture group.
6. the image cache method based on Redis as described in claim 1, which is characterized in that it is described will be in the picture group Picture respectively to be stored spliced, obtain the corresponding splicing picture of the picture group, specifically include:
Judged respectively to whether there is identical picture in picture wait store in the picture group according to the picture similarity;
If there are identical pictures in the picture group, identical picture is subjected to duplicate removal processing;
Picture respectively to be stored in the picture group is spliced according to preset direction, obtains picture matrix;
Judge whether the picture matrix is a complete matrix;
If the picture matrix is not a complete matrix, obtains the block of pixels that several pixels are preset value and carry out supplement spelling It connects, obtains the corresponding splicing picture of the picture group.
7. such as the image cache method of any of claims 1-6 based on Redis, which is characterized in that described to institute Before stating picture file compression progress Redis buffer memory, the image cache method based on Redis further include:
The corresponding code book of the picture group is obtained, and obtains the respectively corresponding code of picture to be stored drawing in the code book Use address;
It is that respectively picture to be stored establishes corresponding two-dimensional coordinate in the picture group according to the code book and each reference address;
The respectively picture name of picture to be stored is obtained in the picture group, is established according to the picture name and the two-dimensional coordinate The corresponding concordance list of the picture group;
Java object encapsulation is carried out to the concordance list, and the encapsulation concordance list that encapsulation is obtained carries out Redis storage.
8. a kind of image cache equipment based on Redis, which is characterized in that the image cache equipment based on Redis includes: Memory, processor and it is stored in the image cache based on Redis that can be run on the memory and on the processor Program realizes such as any one of claims 1 to 7 when the image cache program based on Redis is executed by the processor The step of described image cache method based on Redis.
9. a kind of storage medium, which is characterized in that be stored with the image cache program based on Redis, institute on the storage medium State when the image cache program based on Redis is executed by processor realize as described in any one of claims 1 to 7 based on The step of image cache method of Redis.
10. a kind of image cache device based on Redis, which is characterized in that the image cache device packet based on Redis It includes:
Computing module calculates described wait store between picture for obtaining multiple pictures to be stored according to difference value hash algorithm Picture similarity;
Grouping module obtains multiple picture groups for being grouped according to the picture similarity to the picture to be stored;
Splicing module obtains the corresponding spelling of the picture group for splicing the picture respectively to be stored in the picture group Map interlinking piece;
Lossless compression modules obtain picture file compression for carrying out lossless compression respectively to each splicing picture;
Memory module, for carrying out Redis buffer memory to the picture file compression.
CN201910670805.XA 2019-07-23 2019-07-23 Image cache method, equipment, storage medium and device based on Redis Pending CN110399511A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910670805.XA CN110399511A (en) 2019-07-23 2019-07-23 Image cache method, equipment, storage medium and device based on Redis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910670805.XA CN110399511A (en) 2019-07-23 2019-07-23 Image cache method, equipment, storage medium and device based on Redis

Publications (1)

Publication Number Publication Date
CN110399511A true CN110399511A (en) 2019-11-01

Family

ID=68325854

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910670805.XA Pending CN110399511A (en) 2019-07-23 2019-07-23 Image cache method, equipment, storage medium and device based on Redis

Country Status (1)

Country Link
CN (1) CN110399511A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111161283A (en) * 2019-12-26 2020-05-15 可牛网络技术(北京)有限公司 Method and device for processing picture resources and electronic equipment
CN111968031A (en) * 2020-07-14 2020-11-20 浙江大华技术股份有限公司 Image splicing method and device, storage medium and electronic device
CN113160054A (en) * 2021-04-01 2021-07-23 佛山市顺德区美的洗涤电器制造有限公司 Method for processing image, control device and household appliance
CN113722215A (en) * 2021-08-18 2021-11-30 深圳开源互联网安全技术有限公司 Method, system, device and storage medium for detecting software code risk
CN114356869A (en) * 2022-03-11 2022-04-15 深圳市一号互联科技有限公司 Picture distributed storage method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103957341A (en) * 2014-04-30 2014-07-30 华为软件技术有限公司 Image transmission method and related device
CN104780379A (en) * 2015-01-21 2015-07-15 北京工业大学 Compression method for screen image set
CN105407353A (en) * 2014-09-11 2016-03-16 腾讯科技(深圳)有限公司 Image compression method and apparatus
CN107729935A (en) * 2017-10-12 2018-02-23 杭州贝购科技有限公司 The recognition methods of similar pictures and device, server, storage medium
CN109447154A (en) * 2018-10-29 2019-03-08 网易(杭州)网络有限公司 Picture similarity detection method, device, medium and electronic equipment
CN109685714A (en) * 2018-08-31 2019-04-26 深圳壹账通智能科技有限公司 Picture compression method, apparatus, equipment and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103957341A (en) * 2014-04-30 2014-07-30 华为软件技术有限公司 Image transmission method and related device
CN105407353A (en) * 2014-09-11 2016-03-16 腾讯科技(深圳)有限公司 Image compression method and apparatus
CN104780379A (en) * 2015-01-21 2015-07-15 北京工业大学 Compression method for screen image set
CN107729935A (en) * 2017-10-12 2018-02-23 杭州贝购科技有限公司 The recognition methods of similar pictures and device, server, storage medium
CN109685714A (en) * 2018-08-31 2019-04-26 深圳壹账通智能科技有限公司 Picture compression method, apparatus, equipment and computer readable storage medium
CN109447154A (en) * 2018-10-29 2019-03-08 网易(杭州)网络有限公司 Picture similarity detection method, device, medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙杜靖等: "面向Redis的数据序列化算法研究", 《计算机技术与发展》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111161283A (en) * 2019-12-26 2020-05-15 可牛网络技术(北京)有限公司 Method and device for processing picture resources and electronic equipment
CN111161283B (en) * 2019-12-26 2023-08-04 可牛网络技术(北京)有限公司 Picture resource processing method and device and electronic equipment
CN111968031A (en) * 2020-07-14 2020-11-20 浙江大华技术股份有限公司 Image splicing method and device, storage medium and electronic device
CN113160054A (en) * 2021-04-01 2021-07-23 佛山市顺德区美的洗涤电器制造有限公司 Method for processing image, control device and household appliance
CN113160054B (en) * 2021-04-01 2024-04-16 佛山市顺德区美的洗涤电器制造有限公司 Method for processing image, control device and household appliance
CN113722215A (en) * 2021-08-18 2021-11-30 深圳开源互联网安全技术有限公司 Method, system, device and storage medium for detecting software code risk
CN114356869A (en) * 2022-03-11 2022-04-15 深圳市一号互联科技有限公司 Picture distributed storage method and system

Similar Documents

Publication Publication Date Title
CN110399511A (en) Image cache method, equipment, storage medium and device based on Redis
CN106453572B (en) Method and system based on Cloud Server synchronous images
CN110535869B (en) Data transmission method based on compression algorithm, terminal equipment and storage medium
CN104243923B (en) A kind of method and system of picture processing and preview picture
CN108628898B (en) Method, device and equipment for data storage
US8620096B2 (en) Virtualization server for presentation virtualization and image data encoding method
CN111182332B (en) Video processing method, device, server and storage medium
Noor et al. Orchestrating image retrieval and storage over a cloud system
CN104573518B (en) File scanning method, device, server and system
CN110545446B (en) Desktop image encoding and decoding methods, related devices and storage medium
CN105204883B (en) A kind of plug-in unit loading processing method and device
CN112788338B (en) Image compression and decompression method, equipment, device and storage medium
CN114915464A (en) Image encryption method and image decryption method based on special matrix operation
CN104517059A (en) Cloud-based image encryption method and device
CN105469433B (en) Picture compression method and equipment thereof
KR102236521B1 (en) Method and apparatus for processing data
CN101065760B (en) System and method for processing image data
CN108933945B (en) GIF picture compression method, device and storage medium
CN112331310A (en) Medical image data display method and device, storage medium and intelligent equipment
JP5757904B2 (en) Image compression device
CN112001842A (en) Picture generation method and device, electronic equipment and computer readable storage medium
Nandi et al. A novel hierarchical classification scheme for adaptive quadtree partitioning based fractal image coding
CN112887726B (en) Image processing method and apparatus, storage medium, and electronic device
CN103268619A (en) Method and device for batch compression for picture data in swf document
JP2663922B2 (en) Video encoding 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20191101

RJ01 Rejection of invention patent application after publication