CN109167919B - Picture compression method and device - Google Patents

Picture compression method and device Download PDF

Info

Publication number
CN109167919B
CN109167919B CN201811184045.3A CN201811184045A CN109167919B CN 109167919 B CN109167919 B CN 109167919B CN 201811184045 A CN201811184045 A CN 201811184045A CN 109167919 B CN109167919 B CN 109167919B
Authority
CN
China
Prior art keywords
length value
compression
edge length
picture
compressed
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
CN201811184045.3A
Other languages
Chinese (zh)
Other versions
CN109167919A (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.)
Anhui Wenxiang Information Technology Co Ltd
Original Assignee
Beijing Wenxiang Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Wenxiang Information Technology Co ltd filed Critical Beijing Wenxiang Information Technology Co ltd
Priority to CN201811184045.3A priority Critical patent/CN109167919B/en
Publication of CN109167919A publication Critical patent/CN109167919A/en
Application granted granted Critical
Publication of CN109167919B publication Critical patent/CN109167919B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a picture compression method and a picture compression device, wherein the method comprises the following steps: acquiring a plurality of pictures to be compressed, acquiring a first edge length value and a second edge length value of each picture to be compressed, and calculating compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed; acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value; calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to a preset compression reference identifier; calculating the compression value of each picture to be compressed; and compressing each picture to be compressed according to the compression value. The invention not only ensures the compression quality of the picture to be compressed, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the redundant data transmission of a network, and further improves the transmission speed of the picture to be compressed.

Description

Picture compression method and device
Technical Field
The invention relates to the technical field of picture compression, in particular to a picture compression method and device.
Background
With the progress of science and technology, different mobile terminals with a photographing function are continuously brought into the market, so that more and more photos are taken by the mobile terminals. In order to enhance the resolution of pictures taken by mobile terminals, picture compression becomes a crucial issue, and is also crucial to data transmission of networks.
At present, the traditional picture compression method mainly obtains a proper compression ratio by adjusting the ratio of the length to the width of a picture to realize the compression of the picture, however, the proper compression ratio requires a processor to perform multiple calculation comparisons on the length and the width of the picture until the compression ratio is proper, so that the processing speed of the processor is slow, and only the ratio of the length to the width of the picture is adjusted, so that the compression quality of the picture is poor, when the ratio of the length to the width of the picture is adjusted too much, the compressed picture still has redundant data, which affects the network transmission speed of the picture.
Disclosure of Invention
Therefore, the technical problem to be solved by the embodiments of the present invention is that in the picture compression method in the prior art, obtaining an appropriate compression ratio by adjusting the length-to-width ratio of a picture results in a slower processing speed of a processor, and also affects the picture compression quality and the network transmission speed of the picture.
Therefore, the embodiment of the invention provides the following technical scheme:
the embodiment of the invention provides a picture compression method, which comprises the following steps:
acquiring a plurality of pictures to be compressed, and acquiring a first edge length value and a second edge length value of each picture to be compressed;
calculating compression reference proportion values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value;
calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier;
calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed;
and compressing each picture to be compressed according to the compression value.
Optionally, after the step of compressing each to-be-compressed picture according to the compression value, the method further includes:
judging whether the compression value is less than or equal to a preset compression value or not;
and if the compression value is less than or equal to a preset compression value, compressing the picture to be compressed by using the preset compression value.
Optionally, the step of calculating the compression reference ratio values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed includes:
selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
and calculating a quotient of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain the compression reference proportion value.
Optionally, the step of obtaining the preset compression reference identifier of each picture to be compressed according to the compression reference ratio value includes:
presetting a first preset range threshold, a second preset range threshold and a third preset range threshold;
acquiring a preset range threshold value to which the compression reference proportion belongs according to the first preset range threshold value, the second preset range threshold value and the third preset range threshold value;
acquiring the first edge length value of each picture to be compressed corresponding to the compression reference proportion according to the preset range threshold value to which the compression reference proportion belongs;
and obtaining the corresponding preset compression reference identifier according to the first edge length value.
Optionally, the step of obtaining the preset compression ratio of each to-be-compressed picture according to the compression reference ratio value includes:
presetting a first preset range threshold, a second preset range threshold and a third preset range threshold;
acquiring a preset range threshold value to which the compression reference proportion belongs according to the first preset range threshold value, the second preset range threshold value and the third preset range threshold value;
acquiring a first edge length value and/or a second edge length value of each picture to be compressed corresponding to the compression reference ratio according to a preset range threshold value to which the compression reference ratio belongs;
and obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value.
Optionally, the calculating, according to the preset compression reference identifier, the first target compression edge length value and the second target compression edge length value of each picture are calculated according to the following formulas:
Figure DEST_PATH_IMAGE002
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE004
compressing the edge length value for the first target,
Figure DEST_PATH_IMAGE006
is the second target compression edge length value, n is the preset compression reference mark,
Figure DEST_PATH_IMAGE008
is the value of the first side length,
Figure DEST_PATH_IMAGE010
is the second edge length value.
Optionally, the calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each picture to be compressed is performed by using the following formula:
Figure DEST_PATH_IMAGE012
wherein the size is the compression value,
Figure 905580DEST_PATH_IMAGE004
compressing the edge length value for the first target,
Figure 774179DEST_PATH_IMAGE006
compressing the edge length value for the second target,
Figure 886491DEST_PATH_IMAGE008
is the value of the first side length,
Figure 815133DEST_PATH_IMAGE010
and m is the second edge length value and the preset compression ratio.
An embodiment of the present invention provides an image compression apparatus, including:
the first acquisition module is used for acquiring a plurality of pictures to be compressed and acquiring a first edge length value and a second edge length value of each picture to be compressed;
the first calculation module is used for calculating compression reference proportion values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
the second acquisition module is used for acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value;
the second calculation module is used for calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier;
a third calculating module, configured to calculate a compression value of each to-be-compressed picture according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each to-be-compressed picture;
and the first compression module is used for compressing each picture to be compressed according to the compression value.
The embodiment of the invention provides a computer readable storage medium, which stores computer instructions, and the instructions are executed by a processor to realize the steps of the picture compression method.
The embodiment of the invention provides a picture compression device, which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the steps of the picture compression method when executing the program.
The technical scheme of the embodiment of the invention has the following advantages:
the invention discloses a picture compression method and a picture compression device, wherein the method comprises the following steps: acquiring a plurality of pictures to be compressed, acquiring a first edge length value and a second edge length value of each picture to be compressed, and calculating compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed; acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value; calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to a preset compression reference identifier; calculating the compression value of each picture to be compressed; and compressing each picture to be compressed according to the compression value. The invention not only ensures the compression quality of the picture to be compressed, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the redundant data transmission of a network, and further improves the transmission speed of the picture to be compressed.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a first flowchart of a method for compressing pictures according to an embodiment of the present invention;
FIG. 2 is a second flowchart of a method for compressing pictures according to an embodiment of the present invention;
FIG. 3 is a first block diagram of a picture compression apparatus according to an embodiment of the present invention;
FIG. 4 is a block diagram of a second structure of the image compression apparatus according to the embodiment of the present invention;
fig. 5 is a hardware diagram of a picture compression device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings, and it is to be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the embodiments of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience in describing the embodiments of the present invention and simplifying the description, but do not indicate or imply that the referred devices or elements must have specific orientations, be configured in specific orientations, and operate, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the embodiments of the present invention, it should be noted that, unless explicitly stated or limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be communicated with each other inside the two elements, or may be wirelessly connected or wired connected. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Example 1
An embodiment of the present invention provides a picture compression method, as shown in fig. 1, including the following steps:
and S1, acquiring a plurality of pictures to be compressed, and acquiring a first edge length value and a second edge length value of each picture to be compressed. The first edge length value and the second edge length value are even numbers. The pictures to be compressed here are multiple original pictures shot by the mobile terminal or the camera device, and the pictures need to be compressed for data transmission. The first edge length value may be considered as the length of each picture to be compressed, the second edge length value may be considered as the width of each picture to be compressed, and the first edge length value and the second edge length value appear at the same time and represent the resolution of the picture to be compressed. For convenience of calculation, the first edge length value and the second edge length value are usually selected as even numbers, and if the first edge length value or the second edge length value of the shot picture to be compressed is an odd number, the odd number is increased by 1 to become an even number. For example: the resolution of the picture to be compressed is 1018 × 720, the first edge length value is 1018, and the second edge length value is 720, so that both the first edge length value and the second edge length value are even numbers. For example: the multiple pictures to be compressed are respectively: 1018*724,1018*728, 1016*718,1014*728,1012*726.
And S2, calculating compression reference proportion values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed. The compression reference ratio value is a compression reference value of the group of the plurality of pictures to be compressed. The compression reference scale value is used to assist in calculating the compression value of the picture to be compressed.
The step S2 of calculating the compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed includes:
firstly, selecting a maximum first edge length value and a minimum second edge length value according to a first edge length value and a second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value. For example: the first picture to be compressed is: 1018 x 720, first edge length value of 1018, second edge length value of 720; the second picture to be compressed is: 1018 x 724, first edge length value 1018; the second edge length value is 724, the third picture to be compressed is 1014 x 728, the first edge length value is 1014, and the second edge length value is 728. Therefore, the maximum first edge length value is 1018 and the minimum second edge length value is 720.
And then, calculating a quotient value of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain a compression reference proportion value. The maximum first edge length value obtained in the above steps is 1018, and the minimum second edge length value is 720. Compression reference ratio value = minimum second side length value maximum first side length value, i.e. 7201018= 0.707. Therefore, the compression reference ratio of the plurality of pictures to be compressed in the present embodiment is 0.707. The minimum second edge length value of the plurality of pictures to be compressed is selected, the maximum first edge length value of the plurality of pictures to be compressed is selected, and then the quotient of the minimum second edge length value and the maximum first edge length value is calculated, so that the minimum compression reference ratio can be obtained, the minimum compression reference ratio is utilized to assist in calculating the compression value, and the compression value of the pictures to be compressed can be enabled to be as small as possible.
And S3, acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference ratio value. The preset compression reference mark is set by artificial experiments when the compression reference proportion belongs to different preset range thresholds, so that the reference mark can be directly used for calculation by a processor, the calculation process and the calculation amount of the processor can be reduced, and the image compression speed is improved.
The step S3 of obtaining the preset compression reference identifier of each to-be-compressed picture according to the compression reference ratio value includes:
the method comprises the following steps of firstly, presetting a first preset range threshold, a second preset range threshold and a third preset range threshold. For example: the first preset range threshold is [0.5625,1 ], the second preset range threshold is [0.5,0.5625 ], and the third preset range threshold is [0, 0.5). Here, the first preset range threshold, the second preset range threshold, and the third preset range threshold are set according to the zoom size of the picture, for example: when the picture to be compressed belongs to a first preset range threshold, the length-width ratio of the picture is in the range of [1:1-9:16), when the picture to be compressed belongs to a second preset range threshold, the length-width ratio of the picture is in the range of [9:16-1:2), and when the picture to be compressed belongs to a third preset range, the length-width ratio of the picture is in the range of [1: 2-1: infinity).
And step two, acquiring a preset range threshold to which the compression reference proportion belongs according to the first preset range threshold, the second preset range threshold and the third preset range threshold. For example: when x is less than or equal to 0.5625 and less than or equal to 1, x represents a compression reference ratio of the picture to be compressed, and at this time, the picture to be compressed belongs to an interval of a first preset range threshold, when x is less than or equal to 0.5 and less than or equal to 0.5625, the picture to be compressed belongs to an interval of a second preset range threshold, and when x is less than or equal to 0.5, the picture to be compressed belongs to an interval of a third preset range threshold.
And thirdly, acquiring a first edge length value of each picture to be compressed corresponding to the compression reference proportion according to the preset range threshold value of the compression reference proportion. Here, the first edge length value of each picture to be compressed is greater than the second edge length value, i.e., the length is greater than the width.
And fourthly, obtaining a preset compression reference identifier corresponding to the first edge length value according to the first edge length value. The default compression reference mark herein will be different in different default ranges to which the compression reference ratio belongs.
For example: when 0.5625 ≦ x <1, the first edge length value may typically be 1920,4128,6433, these three first edge length values being the prevalent edge length values of the picture. When the first edge length value is smaller than or equal to 1920, the default compression reference flag corresponding to the first edge length value 1920 can be obtained as 1, when the first edge length value is equal to 4128, the default compression reference flag corresponding to the first edge length value 4128 can be obtained as 2, and when the first edge length value is equal to 6433, the default compression reference flag corresponding to the first edge length value 6433 can be obtained as 4.
For example: when 0.5 ≦ x <0.5625, the first edge length value is usually 1080, and the first edge length value may be a value near 1080, and when the first edge length value is 1080, the first edge length value/1280 ≈ 0, a preset compression reference mark corresponding to the first edge length value is 1, and when the first edge length value is not equal to 1080 when 0.5 ≦ x <0.5625, the preset compression reference mark corresponding to the first edge length is a first edge length value/1280. The preset compression reference mark can directly assist in calculating the compression value by summarizing the characteristics of the preset compression reference mark in advance according to the second preset range to which the compression reference proportion belongs and the characteristics of the first edge length value in the preset range.
For example: when 0 ≦ x <0.5, the first edge length value is usually 1280/compression reference ratio, and when the first edge length value is 1280/compression reference ratio, the default compression reference identifier corresponding to the first edge length value is obtained as the first edge length value/(1280/compression reference ratio). Similarly, the preset compression reference identifier here may directly assist in calculating the compression value by summarizing the characteristics of the preset compression reference identifier in advance according to the third preset range to which the compression reference ratio belongs and the characteristics of the first edge length value within the preset range.
The step S3 of obtaining the preset compression ratio of each to-be-compressed picture according to the compression reference ratio value includes:
the method comprises the following steps of firstly, presetting a first preset range threshold, a second preset range threshold and a third preset range threshold. For example: the first preset range threshold is [0.5625,1 ], the second preset range threshold is [0.5,0.5625 ], and the third preset range threshold is [0, 0.5). Here, the first preset range threshold, the second preset range threshold, and the third preset range threshold are set according to the zoom size of the picture, for example: when the picture to be compressed belongs to a first preset range threshold, the length-width ratio of the picture is in the range of [1:1-9:16), when the picture to be compressed belongs to a second preset range threshold, the length-width ratio of the picture is in the range of [9:16-1:2), and when the picture to be compressed belongs to a third preset range, the length-width ratio of the picture is in the range of [1: 2-1: infinity).
And step two, acquiring a preset range threshold to which the compression reference proportion belongs according to the first preset range threshold, the second preset range threshold and the third preset range threshold. For example: when x is less than or equal to 0.5625 and less than or equal to 1, x represents a compression reference ratio of the picture to be compressed, and at this time, the picture to be compressed belongs to an interval of a first preset range threshold, when x is less than or equal to 0.5 and less than or equal to 0.5625, the picture to be compressed belongs to an interval of a second preset range threshold, and when x is less than or equal to 0.5, the picture to be compressed belongs to an interval of a third preset range threshold.
And thirdly, acquiring a first edge length value and/or a second edge length value of each picture to be compressed corresponding to the compression reference ratio according to the preset range threshold value to which the compression reference ratio belongs. Here, the first edge length value of each picture to be compressed is greater than the second edge length value. I.e. longer than wider.
And fourthly, obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value. The preset compression ratio here is also a preset compression ratio characteristic value summarized from the preset range to which the compression reference ratio belongs and the characteristics of the first margin value and/or the second margin value.
For example: when 0.5625 ≦ x <1, the first edge length of the picture to be compressed is usually 1920,4128,6433, when the first edge length is 1920, the corresponding preset compression ratio is 150, when the first edge length is 4128, the corresponding preset compression ratio is 300, and when the first edge length is 6433, the corresponding preset compression ratio is 300.
For example: when 0.5 ≦ x <0.5625, the first side length is usually 3096, and the second side length is usually 4128, a preset compression ratio of 200 corresponding to the first side length and the second side length, respectively, can be obtained.
For example: when 0 ≦ x <0.5, the first side length is usually 1280, and the second side length is usually 1280/compression reference ratio, and then the corresponding preset compression ratio is 500.
And S4, calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier. The first target compression edge length value is an actual value of compression required by the first edge length value of each picture to be compressed, and the second target compression edge length value is an actual value of compression required by the second edge length value of each picture to be compressed.
The above-mentioned first target compressed edge length value and the second target compressed edge length value of each picture are calculated by the following formula:
Figure DEST_PATH_IMAGE014
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE016
the edge length value is compressed for the first target,
Figure DEST_PATH_IMAGE018
is a second target compression edge length value, n is a preset compression reference mark,
Figure DEST_PATH_IMAGE020
is the first side length value and is the second side length value,
Figure DEST_PATH_IMAGE022
is the second edge length value.
For example: when 0 ≦ x<At 0.5, the first edge length value is normally 1920, and at this time, the preset compression reference flag corresponding to the first edge length 1920 is 1, so that the first target compression edge length value of the first edge length value is calculated by the above formula
Figure DEST_PATH_IMAGE024
And S5, calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed.
The compression value of each picture to be compressed is calculated according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed by the following formula:
Figure DEST_PATH_IMAGE026
wherein, the size is the compression value,
Figure 715960DEST_PATH_IMAGE016
the edge length value is compressed for the first target,
Figure 60354DEST_PATH_IMAGE018
the edge length value is compressed for the second target,
Figure 151806DEST_PATH_IMAGE020
is the first side length value and is the second side length value,
Figure 392295DEST_PATH_IMAGE022
and m is a preset compression ratio, and is a second edge length value.
And S6, compressing each picture to be compressed according to the compression value. And after the file size of each picture to be compressed is obtained, directly compressing the pictures. The embodiment of the invention obtains the reference values related to the compression value for assisting in calculating the picture to be compressed, such as the compression reference ratio value, the preset compression reference mark and the preset compression ratio, through artificial pre-experiments, and further can directly assist in calculating the compression value of each picture to be compressed, and simultaneously integrates the length-width ratio of each picture to be compressed, so that the compression accuracy of the picture to be compressed is obviously improved, namely the compression quality of the picture is improved, the proper compression ratio of each picture to be compressed is not required to be calculated by multiple attempts, and the calculation amount of a processor is reduced, therefore, the picture compression method in the embodiment also improves the compression speed. Therefore, the picture compression method in this embodiment not only ensures the compression quality of the picture, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the transmission of redundant data of a network, and further improves the transmission speed of the picture to be compressed.
As shown in fig. 2, the method for compressing pictures in the embodiment of the present invention further includes, after the step of compressing each picture to be compressed according to the compression value:
and S7, judging whether the compression value is less than or equal to the preset compression value. The preset compression value is a reference compression value, so that the phenomenon that the quality of the picture to be compressed is poor and a fuzzy or mosaic phenomenon occurs due to the fact that the compression value of the picture to be compressed is too small is prevented, and therefore the preset reference value is set to be compared with the calculated compression value.
And S8, if the compression value is less than or equal to the preset compression value, compressing the picture to be compressed by using the preset compression value. When the compression value is too small, the preset compression value is directly utilized to carry out picture compression.
Specifically, when 0.5625 ≦ x <1, the preset compression value is 60 when the first edge length value is 1920, 60 when the first edge length value is 4128, and 100 when the first edge length value is 6433. The predetermined compression values are all 100 when 0.5 ≦ x <0.5625, and 100 when 0 ≦ x < 0.5.
According to the picture compression method in the embodiment of the invention, different preset compression values are set through different preset ranges to which the compression reference ratios belong, so that the phenomenon that the picture to be compressed is fuzzy or mosaic due to the fact that the compression value of the picture to be compressed is too small can be prevented. Therefore, the quality of the picture to be compressed is improved.
Example 2
An embodiment of the present invention provides a picture compression apparatus, as shown in fig. 3, including:
the first obtaining module 31 is configured to obtain a plurality of pictures to be compressed, and obtain a first edge length value and a second edge length value of each picture to be compressed;
the first calculating module 32 is configured to calculate compression reference ratio values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed;
the second obtaining module 33 is configured to obtain a preset compression reference identifier and a preset compression ratio of each to-be-compressed picture according to the compression reference ratio value;
the second calculating module 34 is configured to calculate a first target compression edge length value and a second target compression edge length value of each to-be-compressed picture according to the compression reference identifier;
the third calculating module 35 is configured to calculate a compression value of each to-be-compressed picture according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each to-be-compressed picture;
and the first compression module 36 is configured to compress each picture to be compressed according to the compression value.
The image compression device provided by the embodiment of the invention further comprises the following steps after the step of compressing each image to be compressed according to the compression value:
a judging module 37, configured to judge whether the compression value is smaller than or equal to a preset compression value;
and a second compression module 38, configured to compress the picture to be compressed by using the preset compression value if the compression value is smaller than or equal to the preset compression value.
In the image compression apparatus provided in the embodiment of the present invention, the first calculating module 32 includes:
the selecting submodule is used for selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
and the calculation submodule is used for calculating a quotient of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain a compression reference proportion value.
In the image compression apparatus according to the embodiment of the present invention, as shown in fig. 4, the second obtaining module 33 includes:
the first setting submodule 331 is configured to preset a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the first obtaining submodule 332 is configured to obtain a preset range threshold to which the compression reference ratio belongs according to a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the second obtaining sub-module 333 is configured to obtain, according to a preset range threshold to which the compression reference ratio belongs, a first edge length value of each to-be-compressed picture corresponding to the compression reference ratio;
the first corresponding sub-module 334 is configured to obtain a preset compression reference identifier corresponding to the first edge length value according to the first edge length value.
In the image compression apparatus in the embodiment of the present invention, the second obtaining module 33 further includes:
a second setting submodule 335 that presets a first preset range threshold, a second preset range threshold, and a third preset range threshold;
the third obtaining sub-module 336 is configured to obtain a preset range threshold to which the compression reference ratio belongs according to the first preset range threshold, the second preset range threshold, and the third preset range threshold;
the fourth obtaining submodule 337 is configured to obtain a first edge length value and/or a second edge length value of each to-be-compressed picture corresponding to the compression reference ratio according to the preset range threshold to which the compression reference ratio belongs;
and a second corresponding sub-module 338, configured to obtain a preset compression reference ratio corresponding to the first side length value and/or the second side length value.
In the image compression apparatus according to the embodiment of the present invention, the second calculating module 34 calculates the first target compression edge length value and the second target compression edge length value of each image according to the following formulas:
Figure DEST_PATH_IMAGE028
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE030
the edge length value is compressed for the first target,
Figure DEST_PATH_IMAGE032
is a second target compression edge length value, n is a preset compression reference mark,
Figure DEST_PATH_IMAGE034
is the first side length value and is the second side length value,
Figure DEST_PATH_IMAGE036
is the second edge length value.
In the image compression apparatus in the embodiment of the present invention, the third calculation module 35 calculates the compression value of each image to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each image to be compressed, and by using the following formula:
Figure DEST_PATH_IMAGE038
wherein, the size is the compression value,
Figure 31349DEST_PATH_IMAGE030
the edge length value is compressed for the first target,
Figure 507329DEST_PATH_IMAGE032
the edge length value is compressed for the second target,
Figure 328655DEST_PATH_IMAGE034
is the first side length value and is the second side length value,
Figure 864679DEST_PATH_IMAGE036
and m is a preset compression ratio, and is a second edge length value.
The picture compression device in the embodiment of the invention not only ensures the quality of the picture, but also accurately compresses the file compression value of the picture, improves the processing speed of the picture to be compressed, reduces the transmission of redundant data of a network and further improves the transmission speed of the picture to be compressed.
Example 3
Embodiments of the present invention provide a computer-readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of embodiment 1. The storage medium further stores a first edge length value, a second edge length value, a compression reference proportion value, a preset compression reference identifier, a preset compression ratio, a first target compression edge length value, a second target compression edge length value, a compression value and the like of each picture to be compressed.
The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard disk (Hard disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like.
Example 4
An embodiment of the present invention provides a picture compression apparatus, as shown in fig. 5, which includes a memory 520, a processor 510, and a computer program stored in the memory 520 and executable on the processor 510, and when the processor 510 executes the computer program, the steps of the method in embodiment 1 are implemented.
Fig. 5 is a schematic diagram of a hardware structure of a picture compression device for executing a processing method for list item operations according to an embodiment of the present invention, as shown in fig. 5, the picture compression device includes one or more processors 510 and a memory 520, where one processor 510 is taken as an example in fig. 5.
The apparatus for performing the processing method of the list item operation may further include: the obtaining means 530.
The processor 510, the memory 520, and the obtaining device 530 may be connected by a bus or other means, and fig. 5 illustrates the connection by the bus as an example.
Processor 510 may be a Central Processing Unit (CPU). The Processor 510 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.

Claims (5)

1. A picture compression method is characterized by comprising the following steps:
acquiring a plurality of pictures to be compressed, and acquiring a first edge length value and a second edge length value of each picture to be compressed;
calculating compression reference proportion values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed; the step of calculating the compression reference ratio values of the plurality of pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed comprises:
selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
calculating a quotient value of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain the compression reference proportion value; acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value;
acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value; the step of obtaining the preset compression reference identifier of each picture to be compressed according to the compression reference ratio value comprises the following steps:
acquiring a compression reference ratio x of a picture to be compressed and a first edge length value of the picture to be compressed, wherein the first edge length value of each picture to be compressed is greater than a second edge length value, a first preset range threshold, a second preset range threshold and a third preset range threshold are preset to be [0.5625,1 ], [0.5,0.5625 ], [0,0.5 ], a preset range threshold to which the compression reference ratio of the picture to be compressed belongs is acquired, and a corresponding preset compression reference identifier is acquired according to the first edge length value:
when 0.5625 ≦ x < l, when the first edge length value is less than or equal to 1920, the corresponding default compression reference flag is 1, when the first edge length value is equal to 4128, the corresponding default compression reference flag is 2, and when the first edge length value is equal to 6433, the corresponding default compression reference flag is 4; when 0.5 ≦ x <0.5625, when the first edge length value is 1080, the corresponding default compression reference identifier is 1, and when the first edge length value is not equal to 1080, the corresponding default compression reference identifier is the first edge length value/1280; when 0 ≦ x <0.5, the first edge length value is 1280/compression reference ratio, and the corresponding preset compression reference identifier is the first edge length value/(1280/compression reference ratio);
the step of obtaining the preset compression ratio of each picture to be compressed according to the compression reference ratio value comprises the following steps:
acquiring a preset range threshold to which the compression reference ratio of the picture to be compressed belongs, and obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value:
when 0.5625 ≦ x <1, when the first side length value is 1920, the corresponding preset compression ratio is 150, when the first side length value is 4128, the corresponding preset compression ratio is 300, and when the first side length value is 6433, the corresponding preset compression ratio is 300; when x is less than or equal to 0.5 and less than 0.5625, the first edge length value is 3096, and the second edge length value is 4128, a preset compression ratio corresponding to the first edge length value and the second edge length value is 200; when x is less than or equal to 0.5, the first edge length value is 1280, the second edge length value is 1280/compression reference ratio, and the corresponding preset compression ratio is 500;
calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier; wherein, according to the preset compression reference identifier, the calculation of the first target compression edge length value and the second target compression edge length value of each picture is performed through the following formulas:
Figure DEST_PATH_IMAGE001
wherein the content of the first and second substances,
Figure 16567DEST_PATH_IMAGE002
compressing the edge length value for the first target,
Figure DEST_PATH_IMAGE003
is the second target compression edge length value, n is the preset compression reference mark,
Figure 394721DEST_PATH_IMAGE004
is the value of the first side length,
Figure DEST_PATH_IMAGE005
is the second edge length value;
calculating the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed; wherein, according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each picture to be compressed, calculating the compression value of each picture to be compressed by the following formula:
Figure 279501DEST_PATH_IMAGE006
wherein the size is the compression value,
Figure DEST_PATH_IMAGE007
compressing the edge length value for the first target,
Figure 405589DEST_PATH_IMAGE003
compressing the edge length value for the second target,
Figure 73330DEST_PATH_IMAGE004
is the value of the first side length,
Figure 335684DEST_PATH_IMAGE005
the second edge length value is set, and m is the preset compression ratio;
and compressing each picture to be compressed according to the compression value.
2. The picture compression method according to claim 1, further comprising, after the step of compressing each picture to be compressed according to the compression value:
judging whether the compression value is less than or equal to a preset compression value or not;
and if the compression value is less than or equal to a preset compression value, compressing the picture to be compressed by using the preset compression value.
3. A picture compression apparatus, comprising:
the first acquisition module is used for acquiring a plurality of pictures to be compressed and acquiring a first edge length value and a second edge length value of each picture to be compressed;
the first calculation module is used for calculating compression reference proportion values of the multiple pictures to be compressed according to the first edge length value and the second edge length value of each picture to be compressed; the first calculation module includes:
the selecting submodule is used for selecting a maximum first edge length value and a minimum second edge length value according to the first edge length value and the second edge length value of each picture to be compressed, wherein the first edge length value is larger than the second edge length value;
the calculation submodule is used for calculating a quotient of the minimum second edge length value and the maximum first edge length value according to the maximum first edge length value and the minimum second edge length value to obtain a compression reference proportion value;
the second acquisition module is used for acquiring a preset compression reference identifier and a preset compression ratio of each picture to be compressed according to the compression reference proportion value; the second obtaining module is used for:
acquiring a compression reference ratio x of a picture to be compressed and a first edge length value of the picture to be compressed, wherein the first edge length value of each picture to be compressed is greater than a second edge length value, a first preset range threshold, a second preset range threshold and a third preset range threshold are preset to be [0.5625,1 ], [0.5,0.5625 ], [0,0.5 ], a preset range threshold to which the compression reference ratio of the picture to be compressed belongs is acquired, and a corresponding preset compression reference identifier is acquired according to the first edge length value:
when 0.5625 ≦ x < l, when the first edge length value is less than or equal to 1920, the corresponding default compression reference flag is 1, when the first edge length value is equal to 4128, the corresponding default compression reference flag is 2, and when the first edge length value is equal to 6433, the corresponding default compression reference flag is 4; when 0.5 ≦ x <0.5625, when the first edge length value is 1080, the corresponding default compression reference identifier is 1, and when the first edge length value is not equal to 1080, the corresponding default compression reference identifier is the first edge length value/1280; when 0 ≦ x <0.5, the first edge length value is typically 1280/compression reference ratio, and the corresponding pre-set compression reference identifier is the first edge length value/(1280/compression reference ratio);
the second obtaining module is further configured to:
acquiring a preset range threshold to which the compression reference ratio of the picture to be compressed belongs, and obtaining a preset compression reference ratio corresponding to the first side length value and/or the second side length value according to the first side length value and/or the second side length value:
when 0.5625 ≦ x <1, when the first side length value is 1920, the corresponding preset compression ratio is 150, when the first side length value is 4128, the corresponding preset compression ratio is 300, and when the first side length value is 6433, the corresponding preset compression ratio is 300; when x is less than or equal to 0.5 and less than 0.5625, the first edge length value is 3096, and the second edge length value is 4128, a preset compression ratio corresponding to the first edge length value and the second edge length value is 200; when x is less than or equal to 0.5, the first side length value is usually 1280, the second side length value is usually 1280/compression reference ratio, and the corresponding preset compression ratio is 500;
the second calculation module is used for calculating a first target compression edge length value and a second target compression edge length value of each picture to be compressed according to the preset compression reference identifier; the second calculation module calculates the first target compression edge length value and the second target compression edge length value of each picture according to a preset compression reference identifier through the following formula:
Figure 797890DEST_PATH_IMAGE008
wherein the content of the first and second substances,
Figure DEST_PATH_IMAGE009
the edge length value is compressed for the first target,
Figure 118931DEST_PATH_IMAGE010
is a second target compression edge length value, n is a preset compression reference mark,
Figure DEST_PATH_IMAGE011
is the first side length value and is the second side length value,
Figure 574052DEST_PATH_IMAGE012
is a second edge length value;
a third calculating module, configured to calculate a compression value of each to-be-compressed picture according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value, and the second target compression edge length value of each to-be-compressed picture; the third calculation module calculates the compression value of each picture to be compressed according to the first edge length value, the second edge length value, the preset compression ratio, the first target compression edge length value and the second target compression edge length value of each picture to be compressed by the following formula:
Figure DEST_PATH_IMAGE013
wherein, the size is the compression value,
Figure 395639DEST_PATH_IMAGE014
the edge length value is compressed for the first target,
Figure DEST_PATH_IMAGE015
the edge length value is compressed for the second target,
Figure 887801DEST_PATH_IMAGE016
is the first side length value and is the second side length value,
Figure DEST_PATH_IMAGE017
is a second edge length value, and m is a preset compression ratio;
and the first compression module is used for compressing each picture to be compressed according to the compression value.
4. A computer readable storage medium having stored thereon computer instructions, characterized in that the instructions, when executed by a processor, carry out the steps of the picture compression method according to any of claims 1-2.
5. A picture compression device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the picture compression method as claimed in any one of claims 1-2 are implemented when the processor executes the program.
CN201811184045.3A 2018-10-11 2018-10-11 Picture compression method and device Active CN109167919B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811184045.3A CN109167919B (en) 2018-10-11 2018-10-11 Picture compression method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811184045.3A CN109167919B (en) 2018-10-11 2018-10-11 Picture compression method and device

Publications (2)

Publication Number Publication Date
CN109167919A CN109167919A (en) 2019-01-08
CN109167919B true CN109167919B (en) 2020-05-15

Family

ID=64877816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811184045.3A Active CN109167919B (en) 2018-10-11 2018-10-11 Picture compression method and device

Country Status (1)

Country Link
CN (1) CN109167919B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110809162B (en) * 2020-01-07 2020-04-03 南京甄视智能科技有限公司 Picture compression method, compression device, computer system and computer readable medium
CN113489644A (en) * 2021-06-25 2021-10-08 南京诺源医疗器械有限公司 Data information transmission method for medical optical imaging system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1976446A (en) * 2005-12-02 2007-06-06 索尼株式会社 Multi-coded camera system and image acquisition program
CN102905045A (en) * 2012-10-26 2013-01-30 北京奇虎科技有限公司 Method and server for providing picture data to computing terminal
CN102946419A (en) * 2012-10-26 2013-02-27 北京奇虎科技有限公司 Picture server and picture data providing method
CN104113759A (en) * 2013-04-17 2014-10-22 展讯通信(上海)有限公司 Video system and method and device for buffering and recompressing/decompressing video frames
CN105787868A (en) * 2016-02-18 2016-07-20 北京金山安全软件有限公司 Picture compression method and device and electronic equipment
CN107925418A (en) * 2015-05-21 2018-04-17 零点科技公司 Method, apparatus and system for hybrid data compression and decompression
CN108399052A (en) * 2018-02-07 2018-08-14 深圳壹账通智能科技有限公司 Picture compression method, apparatus, computer equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9319576B2 (en) * 2014-01-29 2016-04-19 Google Technology Holdings LLC Multi-processor support for array imagers

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1976446A (en) * 2005-12-02 2007-06-06 索尼株式会社 Multi-coded camera system and image acquisition program
CN102905045A (en) * 2012-10-26 2013-01-30 北京奇虎科技有限公司 Method and server for providing picture data to computing terminal
CN102946419A (en) * 2012-10-26 2013-02-27 北京奇虎科技有限公司 Picture server and picture data providing method
CN104113759A (en) * 2013-04-17 2014-10-22 展讯通信(上海)有限公司 Video system and method and device for buffering and recompressing/decompressing video frames
CN107925418A (en) * 2015-05-21 2018-04-17 零点科技公司 Method, apparatus and system for hybrid data compression and decompression
CN105787868A (en) * 2016-02-18 2016-07-20 北京金山安全软件有限公司 Picture compression method and device and electronic equipment
CN108399052A (en) * 2018-02-07 2018-08-14 深圳壹账通智能科技有限公司 Picture compression method, apparatus, computer equipment and storage medium

Also Published As

Publication number Publication date
CN109167919A (en) 2019-01-08

Similar Documents

Publication Publication Date Title
CN111028189B (en) Image processing method, device, storage medium and electronic equipment
US20180227478A1 (en) Image preview method, apparatus and terminal
US9756243B2 (en) Imaging controller and imaging control method and program
JP5226805B2 (en) Method and apparatus with depth map generation
EP2849431B1 (en) Method and apparatus for detecting backlight
CN107071272B (en) Method and device for controlling brightness of camera fill-in light and terminal
EP2993888A1 (en) Method, device, and terminal for image processing
CN109167919B (en) Picture compression method and device
CN108053438B (en) Depth of field acquisition method, device and equipment
CN109598763B (en) Camera calibration method, device, electronic equipment and computer-readable storage medium
CN111385461B (en) Panoramic shooting method and device, camera and mobile terminal
US8358368B2 (en) Image processing device and image processing method thereof for picking up images of scene of high luminance difference
CN112449117A (en) Focusing step length determining method and device, storage medium and electronic device
CN109257540B (en) Photographing correction method of multi-photographing lens group and photographing device
CN109697737B (en) Camera calibration method, device, electronic equipment and computer-readable storage medium
CN112422942B (en) White balance synchronization method, lens module and electronic equipment
US20170310872A1 (en) Image dynamic range adjustment method, terminal, and storage medium
CN109168001B (en) Method and device for detecting video scene change and video acquisition equipment
CN111885371A (en) Image occlusion detection method and device, electronic equipment and computer readable medium
US20220232173A1 (en) Method and device of image processing, imaging system and storage medium
US8797419B2 (en) Image processing apparatus and image processing method
CN111614865B (en) Multi-shot brightness synchronization method, equipment, device and storage medium
CN114500968A (en) Color temperature estimation method, white balance adjustment device and storage medium
CN109600547B (en) Photographing method and device, electronic equipment and storage medium
CN116996766A (en) Image focusing method and device, electronic device and 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
TR01 Transfer of patent right

Effective date of registration: 20210126

Address after: 247100 workshop C2, science and Technology Incubation Park, Jiangnan industrial concentration zone, Chizhou City, Anhui Province

Patentee after: Anhui Wenxiang Information Technology Co.,Ltd.

Address before: 100176 11th floor, block B, AVIC Plaza, 15 ronghua South Road, economic and Technological Development Zone, Daxing District, Beijing

Patentee before: BEIJING WENXIANG INFORMATION TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A method and device for image compression

Granted publication date: 20200515

Pledgee: Anhui Jiangnan Industrial Concentration Zone Construction Investment Development (Group) Co.,Ltd.

Pledgor: Anhui Wenxiang Information Technology Co.,Ltd.

Registration number: Y2024980010826

PE01 Entry into force of the registration of the contract for pledge of patent right