CN109685861B - Picture compression method, device and equipment and computer readable storage medium - Google Patents

Picture compression method, device and equipment and computer readable storage medium Download PDF

Info

Publication number
CN109685861B
CN109685861B CN201811016766.3A CN201811016766A CN109685861B CN 109685861 B CN109685861 B CN 109685861B CN 201811016766 A CN201811016766 A CN 201811016766A CN 109685861 B CN109685861 B CN 109685861B
Authority
CN
China
Prior art keywords
compressed
picture
compression
segmentation
subgraphs
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.)
Active
Application number
CN201811016766.3A
Other languages
Chinese (zh)
Other versions
CN109685861A (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.)
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
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 OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN201811016766.3A priority Critical patent/CN109685861B/en
Priority to PCT/CN2018/122718 priority patent/WO2020042467A1/en
Publication of CN109685861A publication Critical patent/CN109685861A/en
Application granted granted Critical
Publication of CN109685861B publication Critical patent/CN109685861B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Abstract

The invention discloses a picture compression method, which comprises the following steps: segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed; determining optimal compression methods respectively corresponding to the sub-graphs to be compressed based on a preset compression rule; and compressing the plurality of subgraphs to be compressed based on the optimal compression method. The invention also discloses a picture compression device, equipment and a computer readable storage medium. The invention improves the compression rate of the picture.

Description

Picture compression method, device and equipment and computer readable storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image compression method, an image compression apparatus, an image compression device, and a computer-readable storage medium.
Background
As is well known, the size of the APP is the key point for optimizing by mobile developers, the picture in the APP occupies a large part of resources, the compression mode adopted by the large picture in the APP at present is single, and usually single compression modes such as jpeg, png, webp or svg are adopted, so that the compression rate is improved only in a limited way.
Disclosure of Invention
The invention mainly aims to provide a picture compression method, a picture compression device and a computer readable storage medium, and aims to solve the technical problem of low picture compression rate caused by single picture compression mode in the prior art.
In order to achieve the above object, the present invention provides a picture compression method, including:
segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
determining optimal compression methods respectively corresponding to the sub-graphs to be compressed based on a preset compression rule;
and compressing the plurality of subgraphs to be compressed based on the optimal compression method.
Optionally, the step of segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed includes:
acquiring color distribution of a picture to be compressed, and receiving a segmentation instruction based on the color distribution;
and determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation line according to a preset algorithm so as to segment the picture to be compressed into a plurality of subgraphs to be compressed.
Optionally, the segmentation lines include a segmentation horizontal line and a segmentation vertical line, the determining the segmentation lines in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation lines according to a preset algorithm, so that the step of segmenting the picture to be compressed into a plurality of sub-pictures to be compressed includes:
determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation horizontal line up and down and/or adjusting the segmentation vertical line left and right according to a preset algorithm so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed based on the segmentation horizontal line and/or the segmentation vertical line, wherein the preset algorithm has a calculation formula as follows:
Figure BDA0001784859970000021
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure BDA0001784859970000022
wherein, the C1And C2Representing pixel color 1 and color 2, C1R、C2RR channels, C, representing colors 1 and 21G、C2GG channel, C, representing colors 1 and 21B、C2BB-channels representing colors 1 and 2.
Optionally, after the step of segmenting the picture to be compressed according to the preset segmentation rule to obtain a plurality of subgraphs to be compressed, the method further includes:
and recording the position information of the plurality of subgraphs to be compressed in the pictures to be compressed.
Optionally, the step of determining the optimal compression method respectively corresponding to the plurality of subgraphs to be compressed based on a preset compression rule includes:
acquiring a preset compression rule and characteristic parameters of the plurality of subgraphs to be compressed;
and determining compression rules corresponding to the sub-images to be compressed based on the characteristic parameters, and respectively determining the optimal compression method of the sub-images to be compressed according to the compression rules.
Optionally, the optimal compression method includes compression quality and compression format, and the step of compressing the plurality of subgraphs to be compressed based on the optimal compression method includes:
and determining a compression algorithm corresponding to the plurality of subgraphs to be compressed based on the compression quality and the compression format, and compressing the subgraphs to be compressed based on the compression algorithm.
Optionally, after the step of compressing the plurality of subgraphs to be compressed based on the optimal compression method, the method further includes:
saving the compressed subgraph to be compressed, and decompressing the compressed subgraph to be compressed when a display instruction based on the picture to be compressed is detected;
and combining the decompressed sub-images to be compressed to obtain the pictures to be compressed based on the recorded position information, and displaying the combined pictures to be compressed.
In addition, to achieve the above object, the present invention also provides a picture compression apparatus, including:
the picture segmentation module is used for segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
the compression method determining module is used for determining optimal compression methods corresponding to the sub-images to be compressed respectively based on a preset compression rule;
and the picture compression module is used for compressing the plurality of subgraphs to be compressed based on the optimal compression method.
Further, to achieve the above object, the present invention also provides a picture compression apparatus comprising: a memory, a processor and a picture compression program stored on the memory and executable on the processor, the computer program realizing the steps of the picture compression method as described above when executed by the processor.
Further, to achieve the above object, the present invention also provides a computer readable storage medium having stored thereon a picture compression program, which when executed by a processor, implements the steps of the picture compression method as described above.
The invention provides a picture compression method, which comprises the steps of firstly segmenting a picture to be compressed based on a preset segmentation rule, segmenting the picture into a plurality of different subgraphs to be compressed, then respectively determining an optimal compression method corresponding to the plurality of subgraphs to be compressed according to the preset compression rule, and compressing the subgraphs based on the optimal compression method. According to the picture compression method provided by the invention, the large picture to be compressed is segmented, and the optimal compression method is adopted for each sub-picture to be compressed, so that the sum of the sizes of the compressed pictures is smaller than that of the large picture obtained by independently adopting a certain mode, the compression ratio of the pictures is greatly improved, and the size of an APP is reduced.
Drawings
Fig. 1 is a schematic diagram of a hardware structure of a picture compression device according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a method for compressing pictures according to the present invention;
FIG. 3 is a detailed flowchart of step S10 in FIG. 2;
FIG. 4 is a flowchart illustrating a second embodiment of a method for compressing pictures according to the present invention;
FIG. 5 is a flowchart illustrating a third embodiment of a method for compressing pictures according to the present invention;
fig. 6 is a functional block diagram of a picture compression apparatus according to a first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The main solution of the embodiment of the invention is as follows: segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed; determining optimal compression methods respectively corresponding to the sub-graphs to be compressed based on a preset compression rule; and compressing the plurality of subgraphs to be compressed based on the optimal compression method. By the technical scheme of the embodiment of the invention, the technical problem of low picture compression ratio caused by single picture compression mode in the prior art is solved.
As shown in fig. 1, fig. 1 is a schematic diagram of a hardware structure of a picture compression apparatus according to an embodiment of the present invention.
The picture compression method related by the embodiment of the invention is mainly applied to picture compression equipment, and the picture compression equipment can be equipment with display and processing functions, such as a PC (personal computer), a portable computer, a mobile terminal and the like.
As shown in fig. 1, the picture compression apparatus may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Optionally, the picture compression device may further include a camera, RF (Radio Frequency) circuitry, sensors, audio circuitry, a Wi-Fi module, and so forth. Such as light sensors, motion sensors, and other sensors. Of course, the image compression device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which are not described herein again.
It will be understood by those skilled in the art that the configuration of the picture compression device shown in fig. 1 does not constitute a limitation of the picture compression device, and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a picture compression program. In fig. 1, the network interface 1004 is mainly used for connecting to a backend server and communicating with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 and the memory 1005 may be provided in a picture compression apparatus, which calls a picture compression program stored in the memory 1005 through the processor 1001 and executes the picture compression method provided by the embodiment of the present invention.
According to the scheme provided by the embodiment, firstly, a picture to be compressed is segmented based on a preset segmentation rule, the picture is segmented into a plurality of different subgraphs to be compressed, then, an optimal compression method of the plurality of subgraphs to be compressed is respectively determined according to the preset compression rule, and the subgraphs to be compressed are compressed based on the optimal compression method. According to the picture compression method provided by the invention, the large picture to be compressed is segmented, and the optimal compression method is adopted for each sub-picture to be compressed, so that the sum of the sizes of the compressed pictures is smaller than that of the large picture obtained by independently adopting a certain mode, the compression ratio of the pictures is greatly improved, and the size of an APP is reduced.
Based on the hardware structure, the embodiment of the picture compression method is provided.
Referring to fig. 2, fig. 2 is a schematic flowchart of a first embodiment of a picture compression method according to the present invention, in this embodiment, the method includes:
step S10, segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
step S20, determining optimal compression methods corresponding to the sub-graphs to be compressed respectively based on preset compression rules;
and step S30, compressing the plurality of subgraphs to be compressed based on the optimal compression method.
In order to solve the problem of low picture compression ratio caused by a single picture compression mode and improve the picture compression ratio to reduce the size of APP, the invention provides a picture compression method.
In this embodiment, a picture to be compressed is firstly segmented according to a preset segmentation rule, specifically, the preset segmentation rule may be based on a color change in the picture to be compressed, as shown in fig. 3, where the step S10 includes:
step S11, acquiring the color distribution of the picture to be compressed, and receiving a segmentation instruction based on the color distribution;
step S12, determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation line according to a preset algorithm so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed.
Specifically, in this embodiment, the color distribution in the picture to be compressed is obtained, and the picture to be compressed is roughly divided into several different blocks based on manual work, the division is based on the color change, i.e., the color block change, in the picture to be compressed, and the picture to be compressed is divided into different blocks with a relatively large color block difference. For example, if there is a portrait in the picture to be compressed, and the other parts are the scene images, and the change of the color blocks of the portrait part and the other scene image parts is large, two or more sub-pictures to be compressed can be obtained by dividing the portrait and the other scene images.
It can be understood that, in addition to the above-mentioned rough division of the picture to be compressed first by human, the color distribution in the picture to be compressed may be obtained by a corresponding program, and the blocks where different colors are located may be divided based on the color distribution to perform the preliminary division of the picture to be compressed.
Further, based on the color distribution in the picture to be compressed, after the picture to be compressed is primarily divided, the division of the blocks is further adjusted, specifically, the color distance is calculated.
Specifically, the step S12 includes:
step a, determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation horizontal line up and down and/or adjusting the segmentation vertical line left and right according to a preset algorithm so as to segment the picture to be compressed into a plurality of subgraphs to be compressed based on the segmentation horizontal line and/or the segmentation vertical line, wherein the preset algorithm has a calculation formula as follows:
Figure BDA0001784859970000061
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure BDA0001784859970000062
wherein, the C1And C2Representing pixel color 1 and color 2, C1R、C2RR channels, C, representing colors 1 and 21G、C2GG channel, C, representing colors 1 and 21B、C2BB-channels representing colors 1 and 2.
Specifically, the segmentation lines for segmenting the picture to be compressed comprise segmentation transverse lines and segmentation vertical lines, the picture to be compressed is roughly divided into blocks containing different color blocks, and the efficiency of adjusting the subsequent segmentation lines can be greatly improved by setting the initial values of the segmentation lines. It can be understood that the way of splitting the picture to be compressed is splitting in a horizontal line or a vertical line way, and therefore, each block obtained after splitting is a regular square block. Furthermore, the segmented horizontal lines or vertical lines are adjusted based on a preset algorithm, so that the blocks are divided more accurately. The specific manner of adjusting the horizontal line or the vertical line of the segmentation is as follows:
color distance refers to the difference between two colors, typically the greater the color distance, the greater the difference between the two colors; conversely, the closer the two colors are. The split lines can be adjusted by calculating the color distance of the split transverse lines or vertical lines up and down or left and right, so that the block splitting is more accurate. Specifically, in calculating the color distance, the color distance is calculated by using the same formula as that for calculating the euclidean distance between two points. In the RGB space, the calculation formula of the color distance is:
Figure BDA0001784859970000071
wherein, C1And C2Representing color 1 and color 2, C1R、C2RR channels, C, representing colors 1 and 21G、C2GG channel, C, representing colors 1 and 21B、C2BB-channels representing colors 1 and 2.
However, since the RGB spaces are linear and orthogonal to each other, but the visual system of human eyes is not linear, the RGB spaces do not reflect the perception of colors by human eyes, and therefore, the corresponding color distance does not well reflect whether two colors are close to each other. Based on the above problem, the modified weighted euclidean distance is used, and the specific calculation method is as follows:
Figure BDA0001784859970000072
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure BDA0001784859970000073
likewise, C1And C2Representing pixel color 1 and color 2, C1R、C2RR channels, C, representing colors 1 and 21G、C2GG channel, C, representing colors 1 and 21B、C2BB-channels representing colors 1 and 2. By the improved weighted Euclidean distance calculation method, the difference between the two colors can be calculated. In this embodiment, the split line can be adjusted and determined based on the color distance on both sides of the split line.
For ease of understanding, the following are specifically exemplified: and taking the original segmentation line determined based on the color distribution as a center, if the segmentation line is a vertical line, moving the vertical segmentation line by n pixels left and right respectively, wherein the moving step length is 1 pixel, and obtaining 2 x n vertical lines. And simultaneously acquiring central vertical lines of the left subgraph and the right subgraph of the original vertical segmentation line, and respectively calculating the distance between the 2 x n vertical lines and the central vertical lines of the two subgraphs, wherein the color distance of a single pixel is calculated by using an improved weighted Euclidean distance formula, the color distance of the central vertical lines of the two subgraphs is the sum of the color distances of the corresponding pixels, and the segmentation line with the minimum color distance from the central vertical line of the left subgraph or the right subgraph can be determined as the segmentation line for finally segmenting the picture to be compressed. Similarly, the transverse tangent line is similarly processed, so that a final segmentation line can be obtained, and further a segmented subgraph to be compressed is obtained.
Further, the picture to be compressed is segmented according to the color block change in the picture to be compressed to obtain a plurality of subgraphs to be compressed, then a preset compression rule is obtained, an optimal compression method is determined for each subgraph to be compressed based on the preset compression rule, and each subgraph to be compressed is compressed based on the optimal compression method to achieve the improvement of the compression ratio of the subgraph to be compressed.
In this embodiment, a picture to be compressed is firstly segmented based on a preset segmentation rule, the picture is segmented into several different subgraphs to be compressed, then an optimal compression method for the several subgraphs to be compressed is respectively determined according to the preset compression rule, and the subgraphs to be compressed are compressed based on the optimal compression method. According to the picture compression method provided by the invention, the large picture to be compressed is segmented, and the optimal compression method is adopted for each sub-picture to be compressed, so that the sum of the sizes of the compressed pictures is smaller than that of the large picture obtained by independently adopting a certain mode, the compression ratio of the pictures is greatly improved, and the size of an APP is reduced.
Further, referring to fig. 4, a second embodiment of the picture compression method according to the present invention is proposed based on the foregoing embodiment, in this embodiment, the step S20 includes:
step S21, acquiring a preset compression rule and the characteristic parameters of the plurality of subgraphs to be compressed;
step S22, determining compression rules corresponding to the sub-graphs to be compressed based on the characteristic parameters and the preset compression rules, and respectively determining the optimal compression method of the sub-graphs to be compressed according to the compression rules.
The method comprises the following steps of segmenting a picture to be compressed according to color block changes in the picture to be compressed to obtain a plurality of subgraphs to be compressed, and then compressing each subgraph to be compressed by adopting the most appropriate compression method based on a preset compression rule, wherein the specific method comprises the following steps: firstly, obtaining feature parameters of a subgraph to be compressed, wherein the feature parameters may include: the picture size refers to the total pixel number contained in the sub-picture to be compressed after segmentation and is represented by the product of pixels in the width direction and pixels in the height direction; whether the subgraph to be compressed contains the transparency means whether the image color number of the subgraph to be compressed is smaller than a certain numerical value, if so, the subgraph to be compressed is considered to contain the transparency; the number of colors in an image refers to how many colors are contained in the image, and is related to the number of bits used to describe the colors.
It is understood that besides the above listed feature parameters of the subgraph to be compressed, other feature parameters may be included, which are not listed here.
According to the characteristic parameters of the subgraph to be compressed, the compression rules corresponding to the subgraphs to be compressed can be determined based on the corresponding preset compression rules, and the optimal compression method of each subgraph to be compressed can be determined based on the compression rules, wherein the optimal compression method comprises the compression quality and the compression format. Specifically, different compression rules may be set for different types of subgraphs to be compressed, for example, if the picture size of a subgraph to be compressed is smaller than a first preset threshold, and the subgraph to be compressed contains transparency and the number of picture colors is smaller than a first preset number of colors, the compression rule corresponding to the subgraph to be compressed may be determined to be the first compression rule, and so on, the compression rules under different picture sizes, transparency parameters, and color parameters may be set. The following table shows a preset compression rule in this embodiment:
size of picture Whether or not to include transparency Number of colors of picture Quality of compression Compressed format
<2k May contain a transparent <=4 100% SVG
>20k Is free of transparency >=256 70% JPEG
>20K May contain a transparent >=512 70% WEBP
It is understood that the preset compression rules are not complete, and can be added and adjusted according to actual needs. Based on the preset compression rule, according to the acquired characteristic parameters corresponding to the subgraph to be compressed, the optimal compression method corresponding to the subgraph to be compressed can be determined so as to compress the subgraph.
Further, the step of compressing the plurality of subgraphs to be compressed based on the optimal compression method comprises:
and b, determining a compression algorithm corresponding to the plurality of subgraphs to be compressed based on the compression quality and the compression format, and compressing the subgraphs to be compressed based on the compression algorithm.
Further, based on the corresponding preset compression rule, the optimal compression method corresponding to each of the plurality of subgraphs to be compressed can be determined, the optimal compression method comprises compression quality, compression format and the like, and the compression processing algorithm of the corresponding subgraph to be compressed can be determined according to the determined compression quality and compression format. Specifically, the corresponding relationship between the compression quality, the compression format, and the compression algorithm may be preset, where the compression algorithm may be a preset logic rule, and the existing tool using the compression algorithm may also be invoked to compress the picture. It will be appreciated that a decision tree algorithm may also be employed to determine the optimal compression method for the subgraph to be compressed. After the optimal compression method of the subgraph to be compressed is determined, each subgraph to be compressed is compressed, and the compression ratio of the picture is improved.
In this embodiment, after a picture to be compressed is segmented to obtain a plurality of subgraphs to be compressed, feature parameters of the subgraphs to be compressed are obtained, and according to the feature parameters of the subgraphs to be compressed, a corresponding optimal compression method is determined based on a preset compression rule, wherein the optimal compression method comprises compression quality and a compression format, a compression algorithm of the subgraph to be compressed is further determined based on the compression quality and the compression format, and finally, the corresponding subgraph to be compressed is compressed according to the compression algorithm. By adopting the optimal compression method for each subgraph to be compressed, the occupied memory of the compressed subgraph is reduced, and the picture compression ratio is improved.
Further, referring to fig. 5, a third embodiment of the picture compression method according to the present invention is proposed based on the foregoing embodiment, and in this embodiment, after step S30, the method further includes:
step S40, storing the compressed subgraph to be compressed, and decompressing the compressed subgraph to be compressed when a display instruction based on the picture to be compressed is detected;
and step S50, combining the decompressed subgraphs to be compressed to obtain the pictures to be compressed based on the recorded position information, and displaying the combined pictures to be compressed.
In this embodiment, after each sub-image to be compressed is compressed by an optimal compression method, the compressed sub-images are stored, and when a large image needs to be displayed, the compressed sub-images to be compressed are decompressed and combined in a manner that the compressed sub-images are combined according to the arrangement position before the sub-images to be compressed are split to splice into a complete image, so that decompression and display of the image to be compressed can be completed.
Specifically, after the step S10, the method further includes:
and c, recording the position information of the plurality of subgraphs to be compressed in the picture to be compressed.
Specifically, after the picture to be compressed is segmented to obtain a plurality of subgraphs to be compressed, in order to facilitate subsequent combination of the compressed subgraphs, the plurality of subgraphs to be compressed obtained by segmentation should be marked, specifically, the position mark of the subgraph to be compressed in the original picture to be compressed. For example, the position of the subgraph to be compressed in the picture to be compressed can be determined by saving the position parameter information of the subgraph to be compressed after segmentation.
Further, after the subgraph to be compressed is compressed based on the optimal compression method, a series of picture format files after the subgraph to be compressed is generated, and a data description file, wherein the data description file mainly comprises the file name, the left top coordinate and the width and height of each subgraph to be compressed, and the left top coordinate and the width and height describe the position information of the subgraph to be compressed in the original big graph to be compressed. When the display information based on the large graph to be compressed is detected, each compressed sub-graph is decompressed to obtain the sub-graphs to be compressed again, the decompressed sub-graphs to be compressed are combined according to the left top coordinate and the width and the height in the data description file, the original large graph to be compressed can be obtained through splicing again, and the large graph to be compressed is displayed.
In this embodiment, a picture to be compressed is segmented based on a preset segmentation rule, the picture is segmented into a plurality of different subgraphs to be compressed, and position information of the plurality of subgraphs to be compressed in an original big picture to be compressed is recorded, so that when the big picture to be compressed needs to be displayed, the decompressed subgraphs to be compressed are spliced again according to the recorded position information to obtain the picture to be compressed, and the combined picture to be compressed is displayed, so that the size of an APP is reduced, and the use experience of a user is improved.
In addition, the embodiment of the invention also provides a picture compression device.
Referring to fig. 6, fig. 6 is a functional block diagram of a picture compression apparatus according to a first embodiment of the present invention.
In this embodiment, the picture compression apparatus includes:
the picture segmentation module is used for segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
the compression method determining module is used for determining optimal compression methods corresponding to the sub-images to be compressed respectively based on a preset compression rule;
and the picture compression module is used for compressing the plurality of subgraphs to be compressed based on the optimal compression method.
Further, the picture slicing module 10 specifically includes:
the picture segmentation unit is used for acquiring the color distribution of a picture to be compressed and receiving a segmentation instruction based on the color distribution;
and the segmentation adjusting unit is used for determining a segmentation line in the picture to be compressed based on the segmentation instruction and adjusting the segmentation line according to a preset algorithm so as to segment the picture to be compressed into a plurality of subgraphs to be compressed.
Further, the segmentation adjusting unit specifically includes:
a segmentation line adjusting subunit, configured to determine a segmentation line in the picture to be compressed based on the segmentation instruction, and adjust the horizontal segmentation line up and down and/or adjust the vertical segmentation line left and right according to a preset algorithm, so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed based on the horizontal segmentation line and/or the vertical segmentation line, where a calculation formula of the preset algorithm is:
Figure BDA0001784859970000121
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure BDA0001784859970000122
wherein, the C1And C2Representing pixel color 1 and color 2, C1R、C2RR channels, C, representing colors 1 and 21G、C2GG channel, C, representing colors 1 and 21B、C2BB-channels representing colors 1 and 2.
Further, the picture compression apparatus further includes:
and the position recording unit is used for recording the position information of the plurality of subgraphs to be compressed in the pictures to be compressed.
Further, the compression method determining module 20 specifically includes:
the parameter acquisition unit is used for acquiring a preset compression rule and the characteristic parameters of the plurality of subgraphs to be compressed;
and the compression method determining unit is used for determining the compression rules corresponding to the plurality of subgraphs to be compressed based on the characteristic parameters and the preset compression rules, and respectively determining the optimal compression method of the plurality of subgraphs to be compressed according to the compression rules.
Further, the picture compression module 30 specifically includes:
and the compression algorithm determining unit is used for determining the compression algorithms corresponding to the plurality of subgraphs to be compressed based on the compression quality and the compression format and compressing the subgraphs to be compressed based on the compression algorithms.
Further, the picture compression apparatus further includes:
the subgraph decompression unit is used for storing the compressed subgraph to be compressed and decompressing the compressed subgraph to be compressed when a display instruction based on the picture to be compressed is detected;
and the subgraph combination unit is used for combining the decompressed subgraphs to be compressed to obtain the picture to be compressed based on the recorded position information and displaying the combined picture to be compressed.
Each module in the image compression apparatus corresponds to each step in the image compression method embodiment, and the functions and implementation processes thereof are not described in detail herein.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium, where a picture compression program is stored, and when being executed by a processor, the picture compression program implements the steps of the picture compression method as described above.
The method for implementing the picture compression program when executed may refer to various embodiments of the picture compression method of the present invention, and will not be described herein again.
According to the scheme provided by the embodiment, firstly, a picture to be compressed is segmented based on a preset segmentation rule, the picture is segmented into a plurality of different subgraphs to be compressed, then, an optimal compression method of the plurality of subgraphs to be compressed is respectively determined according to the preset compression rule, and the subgraphs to be compressed are compressed based on the optimal compression method. According to the picture compression method provided by the invention, the large picture to be compressed is segmented, and the optimal compression method is adopted for each sub-picture to be compressed, so that the sum of the sizes of the compressed pictures is smaller than that of the large picture obtained by independently adopting a certain mode, the compression ratio of the pictures is greatly improved, and the size of an APP is reduced.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (8)

1. A picture compression method, characterized in that the picture compression method comprises the following steps:
segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
determining optimal compression methods respectively corresponding to the sub-graphs to be compressed based on a preset compression rule;
compressing the plurality of subgraphs to be compressed based on the optimal compression method;
the method for obtaining the subgraph comprises the following steps of:
acquiring color distribution of a picture to be compressed, and receiving a segmentation instruction based on the color distribution;
determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation line according to a preset algorithm so as to segment the picture to be compressed into a plurality of subgraphs to be compressed;
the dividing line comprises a dividing transverse line and a dividing vertical line, the dividing line in the picture to be compressed is determined based on the dividing instruction, and the dividing line is adjusted according to a preset algorithm, so that the step of dividing the picture to be compressed into a plurality of sub-pictures to be compressed comprises the following steps:
determining a segmentation line in the picture to be compressed based on the segmentation instruction, and adjusting the segmentation horizontal line up and down and/or adjusting the segmentation vertical line left and right according to a preset algorithm so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed based on the segmentation horizontal line and/or the segmentation vertical line, wherein the preset algorithm has a calculation formula as follows:
Figure FDA0003360929010000021
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure FDA0003360929010000022
wherein, C1,R、C2,RR channels, C, representing colors 1 and 21,G、C2,GG channel, C, representing colors 1 and 21,B、C2,BB-channels representing colors 1 and 2.
2. The picture compression method according to claim 1, wherein after the step of segmenting the picture to be compressed according to the preset segmentation rule to obtain a plurality of subgraphs to be compressed, the method further comprises:
and recording the position information of the plurality of subgraphs to be compressed in the pictures to be compressed.
3. The picture compression method according to claim 2, wherein the step of determining the optimal compression method respectively corresponding to the plurality of subgraphs to be compressed based on the preset compression rules comprises:
acquiring a preset compression rule and characteristic parameters of the plurality of subgraphs to be compressed;
and determining compression rules corresponding to the plurality of subgraphs to be compressed based on the characteristic parameters and the preset compression rules, and respectively determining the optimal compression method of the plurality of subgraphs to be compressed according to the compression rules.
4. The picture compression method according to claim 3, wherein the optimal compression method comprises compression quality and compression format, and the step of compressing the plurality of sub-pictures to be compressed based on the optimal compression method comprises:
and determining a compression algorithm corresponding to the plurality of subgraphs to be compressed based on the compression quality and the compression format, and compressing the subgraphs to be compressed based on the compression algorithm.
5. The picture compression method according to claim 4, wherein the step of compressing the number of sub-pictures to be compressed based on the optimal compression method further comprises:
saving the compressed subgraph to be compressed, and decompressing the compressed subgraph to be compressed when a display instruction based on the picture to be compressed is detected;
and combining the decompressed sub-images to be compressed to obtain the pictures to be compressed based on the recorded position information, and displaying the combined pictures to be compressed.
6. A picture compression apparatus, characterized in that the picture compression apparatus comprises:
the picture segmentation module is used for segmenting the picture to be compressed according to a preset segmentation rule to obtain a plurality of subgraphs to be compressed;
the compression method determining module is used for determining optimal compression methods corresponding to the sub-images to be compressed respectively based on a preset compression rule;
the picture compression module is used for compressing the plurality of subgraphs to be compressed based on the optimal compression method;
the image segmentation module is further used for obtaining the color distribution of the image to be compressed and receiving a segmentation instruction based on the color distribution;
the picture segmentation module is further configured to determine a segmentation line in the picture to be compressed based on the segmentation instruction, and adjust the segmentation line according to a preset algorithm so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed;
the picture segmentation module is further configured to determine a segmentation line in the picture to be compressed based on the segmentation instruction, and adjust the segmentation line up and down and/or adjust the segmentation vertical line left and right according to a preset algorithm, so as to segment the picture to be compressed into a plurality of sub-pictures to be compressed based on the segmentation line and/or the segmentation vertical line, where a calculation formula of the preset algorithm is:
Figure FDA0003360929010000041
ΔR=C1,R-C2,R
ΔG=C1,G-C2,G
ΔB=C1,B-C2,B
Figure FDA0003360929010000042
wherein, C1,R、C2,RR channels, C, representing colors 1 and 21,G、C2,GG channel, C, representing colors 1 and 21,B、C2,BB-channels representing colors 1 and 2.
7. A picture compression device, characterized in that the picture compression device comprises: memory, processor and picture compression program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the picture compression method as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, having stored thereon a picture compression program which, when executed by a processor, implements the steps of the picture compression method as claimed in any one of claims 1 to 5.
CN201811016766.3A 2018-08-31 2018-08-31 Picture compression method, device and equipment and computer readable storage medium Active CN109685861B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201811016766.3A CN109685861B (en) 2018-08-31 2018-08-31 Picture compression method, device and equipment and computer readable storage medium
PCT/CN2018/122718 WO2020042467A1 (en) 2018-08-31 2018-12-21 Image compression method, apparatus and device, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811016766.3A CN109685861B (en) 2018-08-31 2018-08-31 Picture compression method, device and equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN109685861A CN109685861A (en) 2019-04-26
CN109685861B true CN109685861B (en) 2022-03-15

Family

ID=66184483

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811016766.3A Active CN109685861B (en) 2018-08-31 2018-08-31 Picture compression method, device and equipment and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN109685861B (en)
WO (1) WO2020042467A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110634098A (en) * 2019-06-13 2019-12-31 眸芯科技(上海)有限公司 Lossless sparse image display method, device and system
CN111768459A (en) * 2020-06-28 2020-10-13 百度在线网络技术(北京)有限公司 Image processing method, image processing device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110229027A1 (en) * 2010-03-16 2011-09-22 Canon Kabushiki Kaisha Image processing apparatus, image processing method, and computer-readable medium
CN102523367A (en) * 2011-12-29 2012-06-27 北京创想空间商务通信服务有限公司 Real-time image compression and reduction method based on plurality of palettes
CN103886623A (en) * 2012-12-19 2014-06-25 华为技术有限公司 Image compression method and equipment, and system
CN108399052A (en) * 2018-02-07 2018-08-14 深圳壹账通智能科技有限公司 Picture compression method, apparatus, computer equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9998739B2 (en) * 2015-03-06 2018-06-12 Qualcomm Incorporated Optimization for encoding video data using non-square partitions
CN108009984B (en) * 2017-11-21 2020-07-07 中国地质大学(武汉) Water environment monitoring-oriented water surface saliency area detection method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110229027A1 (en) * 2010-03-16 2011-09-22 Canon Kabushiki Kaisha Image processing apparatus, image processing method, and computer-readable medium
CN102523367A (en) * 2011-12-29 2012-06-27 北京创想空间商务通信服务有限公司 Real-time image compression and reduction method based on plurality of palettes
CN103886623A (en) * 2012-12-19 2014-06-25 华为技术有限公司 Image compression method and equipment, and system
CN108399052A (en) * 2018-02-07 2018-08-14 深圳壹账通智能科技有限公司 Picture compression method, apparatus, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
窄信道情况下远程屏幕图像高倍压缩传输方法;王晓日 等;《价值工程》;20130918(第26期);第208-209页 *

Also Published As

Publication number Publication date
WO2020042467A1 (en) 2020-03-05
CN109685861A (en) 2019-04-26

Similar Documents

Publication Publication Date Title
CN109618173B (en) Video compression method, device and computer readable storage medium
US20170180794A1 (en) Dynamic video overlays
EP2645697B1 (en) Image processing apparatus and method
US11681745B2 (en) Digital image presentation
US9300840B2 (en) Image processing device and computer-readable storage medium storing computer-readable instructions
CN109685861B (en) Picture compression method, device and equipment and computer readable storage medium
CN106713689A (en) Picture uploading method and device
CN110084154B (en) Method and device for rendering image, electronic equipment and computer readable storage medium
CN111538799A (en) Thermodynamic diagram construction method, thermodynamic diagram construction equipment, thermodynamic diagram construction storage medium and thermodynamic diagram construction device
CN107113464B (en) Content providing apparatus, display apparatus, and control method thereof
CN109685714B (en) Picture compression method, device, equipment and computer readable storage medium
CN114494775A (en) Video segmentation method, device, equipment and storage medium
CN113301408A (en) Video data processing method and device, electronic equipment and readable storage medium
CN109615620B (en) Image compression degree identification method, device, equipment and computer readable storage medium
CN112396610A (en) Image processing method, computer equipment and storage medium
WO2024094077A1 (en) Cloud desktop image processing method, image processing method, device, and storage medium
CN116884359A (en) Adaptive dimming method, device, equipment and storage medium based on picture content
WO2016197705A1 (en) Image processing method and device
US10354125B2 (en) Photograph processing method and system
CN113453017B (en) Video processing method, device, equipment and computer program product
CN110913193B (en) Image processing method, device, apparatus and computer readable storage medium
CN109712216B (en) Chart rendering method and device, readable storage medium and electronic equipment
CN113223100A (en) Picture compression and decompression processing method
CN110647898B (en) Image processing method, image processing device, electronic equipment and computer storage medium
CN114119427B (en) Picture conversion method, device, equipment and readable storage medium

Legal Events

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