Image processing method, computer program product and equipment
By performing bit layering and similarity analysis on the image, and selecting the most similar bit plane as the compressed image, the problem of fixed image compression ratio in the prior art is solved, and a more flexible and efficient image compression effect is achieved.
Patent Information
- Application Number
- CN202411629643.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-04
AI Technical Summary
The prior art when compressing images, the compression ratio is fixed at 50%, which lacks flexibility and cannot be personalized compression according to the characteristics of different images.
By bit layering the image, the similarity between each bit plane and the original image is determined, and the most similar bit plane is selected as the compressed image, thereby achieving a more flexible compression ratio.
The flexibility of image compression ratio is achieved, and personalized compression can be carried out according to the characteristics of different images. The data size after compression can be reduced to 75%, without affecting the image quality after decompression.
Smart Images

Figure CN119559270A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to image technology, and relates to but is not limited to image processing methods, computer program products, and devices. Background Art
[0002] The main driving force behind the industry's research on image compression efficiency comes from the application of mobile media sharing. As smartphones have become a collection of media acquisition and applications, smartphone cameras can capture high-resolution images; images have become the most important media form in the rich media format of the mobile Internet, and mobile web browsing contains a large number of images; the popularity of social media applications such as Weibo and WeChat has also made the rapid sharing of images a necessity. Therefore, how to improve the image compression ratio is of certain value in saving image storage space and saving image transmission resource costs. Summary of the invention
[0003] In a first aspect, an embodiment of the present application provides an image processing method, comprising: performing bit plane slicing on a first image to obtain multiple bit planes; determining the similarities between the multiple bit planes and the first image respectively; determining at least one target plane from the multiple bit planes based on the similarities between the multiple bit planes and the first image respectively, and using the at least one target plane as a compressed image of the first image.
[0004] In a second aspect, an embodiment of the present application provides an image processing device, comprising: a bit layering module, configured to perform bit layering on a first image to obtain multiple bit planes; a determination module, configured to determine the similarities between the multiple bit planes and the first image respectively; and an image compression module, configured to: determine at least one target plane from the multiple bit planes based on the similarities between the multiple bit planes and the first image respectively, and use the at least one target plane as a compressed image of the first image.
[0005] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, the method described in the first aspect is implemented.
[0006] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the computer program is executed by a processor.
[0007] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising computer program instructions, which enable an electronic device to execute the method described in the first aspect.
[0008] In a sixth aspect, an embodiment of the present application provides a computer program, which enables an electronic device to execute the method described in the first aspect.
[0009] In the related art, usually after the first image is bit-stratified to obtain multiple bit planes, the upper four bit planes are used as the compressed image of the first image. However, there is a defect that for all the images to be compressed, since the upper four bit planes are used as the compressed image of the first image, the compression ratio is fixed at 50%, which is obviously inflexible.
[0010] In view of this, in an embodiment of the present application, after bit-layering the first image to obtain multiple bit planes, a fixed layer (i.e., a bit plane with fixed bit positions) among the multiple bit planes is not directly used as a compressed image of the first image, but the similarities between the multiple bit planes and the first image are determined, and at least one target plane is selected from the multiple bit planes as a compressed image of the first image based on the similarity; in this way, compared with using the high four-bit bit plane as the compressed image of the first image, the first image has the opportunity to be compressed into less data.
[0011] For example, if the target plane selected based on the similarity is the bit plane of the 7th bit and the 6th bit, the compressed image has a data size reduced by 75% compared with the first image, and the compressed image with the upper four bit planes fixedly used as the first image has a data size reduced by 50% compared with the first image.
[0012] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0014] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0015] Figure 1A schematic diagram of the implementation flow of the image processing method provided in the embodiment of the present application;
[0016] Figure 2 A schematic diagram of a flow chart of a method for determining the similarity between a bit plane and a first image provided in an embodiment of the present application;
[0017] Figure 3 A schematic diagram of an image compression process provided by an embodiment of the present application;
[0018] Figure 4 A schematic diagram of an image decompression process provided in an embodiment of the present application;
[0019] Figure 5 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0020] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0023] In the following description, reference is made to “some embodiments”, “this embodiment”, “embodiments of the present application” and examples, etc., which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0024] The descriptions of “first, second, third” etc. that appear in the embodiments of the present application are only for illustration and distinction of the description objects. There is no distinction of order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0025] The present application provides an image processing method. Figure 1 A schematic diagram of the implementation flow of the image processing method provided in the embodiment of the present application; Figure 1 As shown, the method may include the following steps 101 to 103:
[0026] Step 101, performing bit layering on a first image to obtain a plurality of bit planes;
[0027] Step 102, determining similarities between the plurality of bit planes and the first image respectively;
[0028] Step 103: Determine at least one target plane from the multiple bit planes according to the similarities between the multiple bit planes and the first image, and use the at least one target plane as a compressed image of the first image.
[0029] In the related art, the first image is usually bit-stratified to obtain multiple bit planes, and the upper four bit planes are used as the compressed image of the first image. However, there is a defect that for all the images to be compressed, since the upper four bit planes are used as the compressed image of the first image, the compression ratio is fixed at 50% for any image to be compressed, which is obviously inflexible.
[0030] In view of this, in an embodiment of the present application, after the first image is bit-stratified to obtain multiple bit planes, the fixed stratification (i.e., the bit plane with fixed bit position) in the multiple bit planes is not directly used as the compressed image of the first image, but the similarity between the multiple bit planes and the first image is determined, and at least one target plane is selected from the multiple bit planes based on the similarity as the compressed image of the first image; in this way, compared with using the high four-bit bit plane as the compressed image of the first image, the first image has the opportunity to be compressed to less data. For example, the target plane selected based on the similarity is the bit plane of the 7th bit position and the 6th bit position, and the compressed image has a data size reduced by 75% compared with the first image. And the fixed use of the high four-bit bit plane as the compressed image of the first image reduces the data size by 50% compared with the first image. And by using the image processing method provided in the embodiment of the present application, for different images to be compressed, the compression ratio after the final compression may be different, and the compression ratio is more flexible, instead of the compression ratio being the same and fixed for different images to be compressed.
[0031] The following describes further optional implementations and related terms of each of the above steps.
[0032] Step 101: perform bit layering on a first image to obtain a plurality of bit planes.
[0033] The bit layering of the first image can also be understood as processing the first image using a bit layering algorithm. In some embodiments, step 101 may include: performing binary conversion on the pixel values in the first image to obtain a second image; and dividing the pixel values in the second image into the plurality of bit planes by bit.
[0034] It can be understood that for an image, the pixel value of each pixel can be represented by an 8-bit binary number (usually in the range of 0 to 255). The bit layering algorithm splits these 8-bit binary numbers into 8 independent planes (ie, bit planes), each of which corresponds to a specific binary bit.
[0035] Specifically, for a pixel value p, its 8-bit binary representation is:
[0036] p = b7b6b5b4b3b2b1b0;
[0037] Where b7 represents the highest bit and b0 represents the lowest bit. Then the i-th bit plane (i=0,1,…,7) can be expressed as Pi(x,y)=bi, where (x,y) is the pixel coordinate in the image.
[0038] For example:
[0039] Let the first image be The pixel values in the image matrix are converted into binary one by one, and the resulting binary matrix (i.e., an example of the second image) is:
[0040] The pixel values in the binary matrix are divided into the following 8 bit planes (ie, bit plane matrices) by bit:
[0041] The 8th bit plane (L7 / bit plane 7) is:
[0042] The 7th bit plane (L6 / bit plane 6) is:
[0043] The sixth bit plane (L5 / bit plane 5) is:
[0044] The fifth bit plane (L4 / bit plane 4) is:
[0045] The 4th bit plane (L3 / bit plane 3) is:
[0046] The third bit plane (L2 / bit plane 2) is:
[0047] The second bit plane (L1 / bit plane 1) is:
[0048] The first bit plane (L0 / bit plane 0) is:
[0049] In the embodiment of the present application, the bit layering may also be understood as bit plane layering. The bit plane obtained by performing bit layering on the first image may also be understood as bit layering, bit layered image, etc.
[0050] Step 102: Determine the similarities between the plurality of bit planes and the first image respectively.
[0051] In the embodiment of the present application, the bit plane can also be understood as a bit-layered image, and the similarity between the bit plane and the first image refers to the degree of proximity between the two images in terms of content, visual features or semantics. This similarity can be determined by a variety of methods. In the embodiment of the present application, there is no limitation on the method for determining the similarity between the bit plane and the first image. Three methods for determining the similarity are given below, one is a method for determining the similarity based on a hash value, one is a method for determining the similarity based on a normalized correlation coefficient, and the other is a method for determining the similarity based on information entropy. However, it is not limited to these three methods. In short, the determined parameter value can characterize the similarity (that is, the degree of similarity) between the bit plane and the first image.
[0052] In some embodiments, Figure 2 As shown, step 102 may include the following steps 201 and 202:
[0053] Step 201: determine a first hash value of the bit plane and a second hash value of the first image.
[0054] It can be understood that the hash value of an image is a numerical identifier assigned to the image through a specific hash algorithm. This identifier is a binary code of a fixed length, also known as the "digital fingerprint" of the image. In the embodiment of the present application, there is no limitation on the further implementation of step 201. The first hash value of the bit plane can be determined by an average hash algorithm (aHash), a perceptual hash algorithm (pHash), or a differential hash algorithm (dHash). The second hash value of the first image is determined by an average hash algorithm (aHash), a perceptual hash algorithm (pHash), or a differential hash algorithm (dHash).
[0055] Exemplarily, in some embodiments, the first hash value of the bit plane may be determined in this way: the bit plane is processed using a dHash algorithm to obtain the first hash value of the bit plane.
[0056] Likewise, in some embodiments, the second hash value of the first image may be determined by processing the first image using the dHash algorithm to obtain the second hash value of the first image.
[0057] It can be understood that compared with the pHash algorithm, the dHash algorithm is much faster, and compared with the aHash algorithm, the dHash algorithm has a better effect under the condition of almost the same efficiency, and it is implemented based on gradient; therefore, in the embodiment of the present application, the dHash algorithm can efficiently and more accurately obtain the first hash value of the bit plane and the second hash value of the first image, which is beneficial to efficiently determine a more accurate similarity, and then to efficiently select a bit plane (i.e., the target plane) that is more similar to the first image as a compressed image. This is obviously very beneficial for subsequent decompression to obtain a high-quality decompressed image.
[0058] Step 202: Determine the similarity between the bit plane and the first image according to the first Hash value and the second Hash value.
[0059] In the embodiment of the present application, there is no limitation on the further implementation of step 201. The Hamming distance, cosine distance or other distance between the first hash value and the second hash value may be determined to characterize the similarity between the bit plane and the first image.
[0060] In a possible implementation, step 202 may include: determining a Hamming distance between the first hash value and the second hash value, and using the Hamming distance as the similarity between the bit plane and the first image.
[0061] It can be understood that the Hamming distance refers to the number of different characters in corresponding positions between two strings of equal length. Therefore, the more similar the images are, the smaller their Hamming distance is. As mentioned above, the hash values of the images, that is, the first hash value and the second hash value are both binary codes, so the calculation of the Hamming distance between the two strings of binary codes involves bit operations. Therefore, compared with other methods, the time complexity is small and the method is simple and easy to implement.
[0062] For example, in a possible implementation, calculating the Hamming distance between two binary codes mainly involves an exclusive OR operation (XOR) and counting the number of 1s.
[0063] Among them, the XOR operation is a basic binary operation. For each bit, if the two binary numbers are the same at that bit, the result is 0; if they are different, the result is 1. When calculating the Hamming distance, first perform a bit-by-bit XOR operation on two equal-length binary codes to obtain a new binary number. Each bit of this number indicates whether the original two binary codes are the same at that bit (1 means different, 0 means the same). After obtaining the result of the XOR operation, it is necessary to count the number of 1s in this binary number. The number of 1s is equal to the number of different characters in the corresponding positions between the original two binary codes, that is, the Hamming distance.
[0064] In some other embodiments, step 102 may include: determining a normalized correlation coefficient between the bit plane and the first image, and using the normalized correlation coefficient as the similarity between the bit plane and the first image.
[0065] As you can understand, the Normalized Correlation Coefficient (NC) is a method of measuring image similarity, which is used to compare the similarity between two images. The NC value ranges from [0,1]. The closer the value is to 1, the more similar the images are, and the closer the value is to 0, the less similar the images are. Before calculating the NC value, the two images need to be preprocessed, such as converting the images to grayscale images, resizing the images, etc.
[0066] The calculation formula of NC value is shown in the following formula (1):
[0067] NC=∑((I1[i]-μ1)*(I2[i]-μ2)) / (σ1*σ2) (1);
[0068] Among them, I1[i] and I2[i] represent the pixel values of corresponding positions in the two images, μ1 and μ2 represent the means of the two images, and σ1 and σ2 represent the standard deviations of the two images.
[0069] In some further embodiments, step 102 may include: determining a first information entropy of the bit plane and a second information entropy of the first image; determining a first difference between the first information entropy and the second information entropy, and using the first difference as the similarity between the bit plane and the first image. In a possible implementation, the first difference is an absolute value.
[0070] Step 103: Determine at least one target plane from the multiple bit planes according to the similarities between the multiple bit planes and the first image, and use the at least one target plane as a compressed image of the first image.
[0071] In some embodiments, step 103 may include: determining a bit plane whose similarity satisfies a similarity condition among the multiple bit planes as the target plane.
[0072] In the embodiment of the present application, there is no limitation on the similarity condition, which can be various. In short, the selected target plane (ie, bit plane) can be one or more bit planes that are most similar to the first image.
[0073] It can be understood that in the embodiment of the present application, after the first image is bit-layered to obtain multiple bit planes, the bit planes with fixed layers / fixed bits in the multiple bit planes are not directly used as the compressed image of the first image, but one or more bit planes (i.e., the at least one target plane) in the multiple bit planes that are most similar to the first image are used as the compressed image of the first image; in this way, the flexibility of image compression can be enhanced, so that the first image has the opportunity to be compressed to a smaller amount of data, and because the bit planes used as the compressed image are one or more bit planes that are most similar to the first image, it is beneficial to obtain a higher quality decompressed image when decompressing the compressed image, that is, the image obtained after decompression is closer to the first image. In short, in the embodiment of the present application, the bit layering is used to obtain one or more bit planes that are most similar to the first image in the multiple bit planes as the compressed image of the first image, so that while improving the compression ratio of the first image, it is beneficial for the decompression end to obtain a higher quality decompressed image.
[0074] It can be understood that the more similar the images are, the smaller their Hamming distance is. The larger the NC value of two images is, the more similar they are; the smaller the difference in information entropy between the two images is, the more similar the grayscale distribution of the two images is, and thus the higher the similarity of the images is.
[0075] In possible implementation method 1, the similarity condition includes that the Hamming distance is less than or equal to a first threshold, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose Hamming distance is less than or equal to the first threshold among the multiple bit planes as the target plane.
[0076] In possible implementation method 2, the similarity condition includes the minimum Hamming distance, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first N bit planes with the minimum Hamming distance among the multiple bit planes as the target plane; wherein N is greater than or equal to 1.
[0077] It can be understood that the Hamming distance refers to the number of different characters in corresponding positions between two strings of equal length. Therefore, the more similar the images are, the smaller their Hamming distance is. As mentioned above, the hash values of the images, that is, the first hash value and the second hash value are both binary codes, so the calculation of the Hamming distance between the two binary codes involves bit operations, so the time complexity is small and the method is simple and easy to implement.
[0078] In view of this, in an embodiment of the present application, the Hamming distance between the first hash value of the bit plane and the second hash value of the first image is determined, and the Hamming distance is used as the similarity between the two; the bit plane whose Hamming distance satisfies the similarity condition among the multiple bit planes is used as the compressed image of the first image; in this way, since the calculation time complexity of the Hamming distance is relatively small, the image processing method can improve the image compression ratio without consuming almost any computing resources, and at the same time, the selected target plane is also beneficial for the decompression end to obtain a decompressed image with better quality.
[0079] In possible implementation method 3, the similarity condition includes that the normalized correlation coefficient is greater than or equal to a second threshold value, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose normalized correlation coefficient is greater than or equal to the second threshold value among the multiple bit planes as the target plane.
[0080] In possible implementation method 4, the similarity condition includes the maximum normalized correlation coefficient, and the bit plane whose similarity satisfies the similarity condition among the multiple bit planes is determined as the target plane, including: determining the first M bit planes among the multiple bit planes whose normalized correlation coefficients are the largest as the target planes; wherein M is greater than or equal to 1.
[0081] In possible implementation method 5, the similarity condition includes that the first difference is less than or equal to a third threshold value, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose first difference is less than or equal to the third threshold value among the multiple bit planes as the target plane.
[0082] In possible implementation method 6, the similarity condition includes that the first difference is minimized, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first K bit planes whose first difference is minimized among the multiple bit planes as the target plane; wherein K is greater than or equal to 1.
[0083] An embodiment of the present application also provides an image decompression method, which includes: decompressing the compressed image (ie, the at least one target plane) to obtain a decompressed image.
[0084] Further, in some embodiments, decompressing the compressed image (i.e., the at least one target plane) to obtain a decompressed image includes: determining a corresponding scaling factor according to the bit layer where the target plane is located; restoring the target plane according to the scaling factor to obtain a corresponding restored image; and accumulating pixel values of the restored images corresponding to the at least one target plane according to pixel positions to obtain a decompressed image.
[0085] For example, assuming that the target planes selected by the above image processing method are L6 and L7, then during the image decompression process, the bit plane L6 is multiplied by the corresponding scaling factor 2^(7-1) to obtain restored L6; the bit plane L7 is multiplied by the corresponding 2^(8-1) to obtain restored L7; the image matrices restored L6 and restored L7 obtained after the multiplication are added according to the pixel position to obtain the decompressed image (restored image).
[0086] In an embodiment of the present application, the above-mentioned image processing method and image decompression method can be applied to the same device or to different devices respectively. In the case of being applied to different devices, the image processing method further includes: encoding the at least one target plane to generate a code stream for transmission to the opposite end.
[0087] In this way, the opposite end receives and decodes the code stream to obtain the at least one target plane, and decompresses the at least one target plane to obtain a decompressed image.
[0088] The following examples describe possible implementations of the image processing methods described in one or more of the above embodiments.
[0089] For image compression, the bit-layered algorithm is either as simple as directly using the image with the highest four bit layers (i.e., the 8th bit plane to the 5th bit plane) as the compressed image; or introducing an algorithm based on deep learning, which can also achieve the purpose of greatly compressing the image, but greatly increases the complexity of the algorithm. The image processing method provided in the embodiment of the present application can achieve a simple and efficient effect.
[0090] The solution provided by the embodiment of the present application is generally divided into two parts. The first part is called image compression (i.e., image processing method), and the second part is called image decompression (which can be on the same device as the image compression or on a different device).
[0091] Figure 3 A schematic diagram of an image compression process provided in an embodiment of the present application; Figure 3 As shown, the image compression process mainly includes the following steps 301 and 302:
[0092] Step 301, performing a bit plane slicing algorithm on the input image to obtain 8 bit planes, namely, bit plane 0 to bit plane 7 as shown in the figure.
[0093] For the bit layering algorithm described in step 301, reference may be made to the above description.
[0094] Step 302: perform bit plane selector on the eight bit planes to obtain selected bit planes; the selected bit planes may also be understood as target planes.
[0095] The bit plane selector described in step 302 is described below.
[0096] In order to balance speed and accuracy, the dHash algorithm is used to generate a hash value for each bit plane, and a hash value is also generated for the original image (i.e., the input image of step 301), and then the Hamming distance between the hash value of each bit plane and the hash value of the original image is calculated. The bit plane is selected by this Hamming distance, and the more similar the images, the smaller the Hamming distance.
[0097] Here is a brief description of the dHash algorithm process. Taking the Lena image as an example, the matrix shown in Table 1 below is the matrix of the image grayscale value. The matrix is the 8*8 Lena image data matrix obtained by calculation. Starting from the second row of the matrix, the operation of subtracting the previous row is performed to obtain the difference matrix shown in Table 2 below. Set the elements greater than or equal to 0 in the matrix shown in Table 2 to 1, and set the elements less than 0 to 0, to obtain the matrix shown in Table 3.
[0098] Table 1
[0099] 167 103 130 126 124 161 153 134 147 104 110 165 206 154 141 45 146 96 118 168 176 184 192 161 148 96 133 76 189 111 50 159 143 98 72 110 117 66 129 156 129 107 72 93 125 52 150 193 138 49 201 70 149 105 151 212 101 43 147 83 148 220 136 100
[0100] Table 2
[0101] -20 1 -20 39 82 -7 -12 -89 -1 -8 8 3 -30 30 51 116 2 0 15 -92 13 -73 -142 -2 -5 2 -61 34 -72 -45 79 -3 -14 9 0 -17 8 -14 21 37 9 -58 129 -23 24 53 1 19 -37 -6 -54 13 -1 115 -15 -112 -14 19 -55 34 -9 -19 -61 -24
[0102] Table 3
[0103] 0 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0
[0104] As can be seen from Table 3, the dHash sequence of the Lena image is:
[0105] 0101100000110111111010000101001001101011101011110001010001010000 Figure 4 A schematic diagram of the image decompression process provided in the embodiment of the present application; Figure 4 As shown, the image decompression process mainly includes the following steps 401 to 402:
[0106] Step 401, multiply the selected bit plane L6 by the corresponding 2^(7-1) to obtain restored L6; multiply the selected bit plane L7 by the corresponding 2^(8-1) to obtain restored L7;
[0107] like Figure 4 As shown, assuming that Figure 3 The bit planes finally selected in the image compression process shown are L6 and L7.
[0108] Step 402, the image matrices restored L6 and restored L7 obtained after the multiplication are added according to their positions to obtain a final restored image (restored image).
[0109] It can be understood that in the embodiment of the present application, the bit plane is selected as the compressed image based on the similarity between the bit plane and the original image, rather than a fixed number of bit planes as the compressed image. For example, if a fixed 4-7 layers (i.e., bit planes) are selected as the compressed image, no matter what image content is input, the compression ratio is fixed at 50%. In the embodiment of the present application, instead of selecting a fixed number of bit planes as the compressed image, the bit plane is selected as the compressed image based on the similarity between the bit plane and the original image; thus, this simple and efficient method can be used to improve the image compression ratio without consuming any computing resources. Assuming that the final layers / planes are selected as layers 6 and 7 by the bit plane selection module (bit plane selector), the image storage can be reduced by 75%.
[0110] In the embodiment of the present application, a bit plane selection algorithm is added after the input image is bit-stratified, thereby improving the image storage compression ratio. This bit plane selection algorithm does not involve a complex artificial intelligence algorithm, but only traverses the image and calculates the difference between rows to obtain a hash value, and then calculates the Hamming distance of the hash value. The algorithm can run very fast.
[0111] In the embodiment of the present application, the bit-plane selection algorithm may also be supplemented with some other algorithms, such as a normalized correlation coefficient, or an entropy method.
[0112] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.; or, steps in different embodiments may be combined into a new technical solution.
[0113] Based on the foregoing embodiments, an embodiment of the present application provides an image processing device, which includes the modules included and the units included in the modules, which can be implemented by a processor; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be an AI acceleration engine (such as NPU, etc.), GPU, central processing unit (CPU), microprocessor (MPU), digital signal processor (DSP) or field programmable gate array (FPGA), etc.
[0114] Figure 5 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the image processing apparatus 500 includes a bit layering module 501, a determination module 502 and an image compression module 503, wherein:
[0115] The bit layering module 501 is configured to perform bit layering on the first image to obtain a plurality of bit planes;
[0116] A determination module 502, configured to determine similarities between the plurality of bit planes and the first image respectively;
[0117] The image compression module 503 is configured to: determine at least one target plane from the multiple bit planes according to the similarities between the multiple bit planes and the first image respectively, and use the at least one target plane as a compressed image of the first image.
[0118] In some embodiments, determining at least one target plane from the multiple bit planes based on the similarities between the multiple bit planes and the first image respectively includes: determining the bit plane whose similarity meets the similarity condition among the multiple bit planes as the target plane.
[0119] In some embodiments, determining the similarity between the multiple bit planes and the first image respectively includes: determining a first hash value of the bit plane and a second hash value of the first image; and determining the similarity between the bit plane and the first image based on the first hash value and the second hash value.
[0120] Further, in some embodiments, determining the first hash value of the bit plane and the second hash value of the first image includes: processing the bit plane using a dHash algorithm to obtain the first hash value of the bit plane; processing the first image using the dHash algorithm to obtain the second hash value of the first image.
[0121] Exemplarily, in some embodiments, determining the similarity between the bit plane and the first image based on the first hash value and the second hash value includes: determining the Hamming distance between the first hash value and the second hash value, and using the Hamming distance as the similarity between the bit plane and the first image.
[0122] Exemplarily, in some embodiments, the similarity condition includes that the Hamming distance is less than or equal to a first threshold, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose Hamming distance among the multiple bit planes is less than or equal to the first threshold as the target plane.
[0123] Exemplarily, in some other embodiments, the similarity condition includes the minimum Hamming distance, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first N bit planes with the minimum Hamming distance among the multiple bit planes as the target plane; wherein N is greater than or equal to 1.
[0124] Exemplarily, in some embodiments, determining the similarity between the multiple bit planes and the first image respectively includes: determining a normalized correlation coefficient between the bit plane and the first image, and using the normalized correlation coefficient as the similarity between the bit plane and the first image.
[0125] Exemplarily, in some embodiments, the similarity condition includes that the normalized correlation coefficient is greater than or equal to a second threshold, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose normalized correlation coefficient is greater than or equal to the second threshold among the multiple bit planes as the target plane.
[0126] Exemplarily, in some other embodiments, the similarity condition includes the maximum normalized correlation coefficient, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first M bit planes whose normalized correlation coefficients among the multiple bit planes are the largest as the target planes; wherein M is greater than or equal to 1.
[0127] Exemplarily, in some embodiments, determining the similarity between the multiple bit planes and the first image respectively includes: determining a first information entropy of the bit plane and a second information entropy of the first image; determining a first difference between the first information entropy and the second information entropy, and using the first difference as the similarity between the bit plane and the first image.
[0128] Exemplarily, in some embodiments, the similarity condition includes that the first difference is less than or equal to a third threshold value, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose first difference is less than or equal to the third threshold value among the multiple bit planes as the target plane.
[0129] Exemplarily, in some other embodiments, the similarity condition includes that the first difference is minimized, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first K bit planes among the multiple bit planes whose first difference is minimized as the target plane; wherein K is greater than or equal to 1.
[0130] In some embodiments, bit-stratifying the first image to obtain multiple bit planes includes: converting pixel values in the first image into binary to obtain a second image; and bit-segmenting the pixel values in the second image into the multiple bit planes.
[0131] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0132] It should be noted that the division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. It may also be implemented in the form of a combination of software and hardware.
[0133] It should be noted that in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0134] An embodiment of the present application provides an electronic device, Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application; Figure 6 As shown, the electronic device 600 includes a memory 601 and a processor 602, wherein the memory 601 stores a computer program that can be run on the processor 602, and the processor 602 implements the steps in the method provided in the above embodiment when executing the program.
[0135] It should be noted that the memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or processed by the processor 602 and various modules in the electronic device 600 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0136] In the embodiments of the present application, there is no limitation on the type of electronic device, and the electronic device may be any device with image processing capability, such as a smart phone, a laptop, a tablet computer, a computer device, a television, or a smart watch.
[0137] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0138] Optionally, the computer-readable storage medium can be applied to the electronic device in the embodiments of the present application, and the computer program enables the electronic device to execute the various methods in the embodiments of the present application, which will not be described in detail here for the sake of brevity.
[0139] An embodiment of the present application also provides a computer program product, including computer program instructions.
[0140] Optionally, the computer program product may be applied to the electronic device in the embodiments of the present application, and the computer program instructions enable the electronic device to execute the various methods in the embodiments of the present application, which will not be described in detail here for the sake of brevity.
[0141] The embodiment of the present application also provides a computer program.
[0142] Optionally, the computer program may be applied to the electronic device in the embodiments of the present application. When the computer program runs on the electronic device, the electronic device executes the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present application. For the sake of brevity, they are not described here.
[0143] It should be noted here that the description of the above electronic device, storage medium, computer program product and computer program embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the electronic device, storage medium, computer program product and computer program embodiment of this application, please refer to the description of the method embodiment of this application for understanding.
[0144] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. The above description of each embodiment tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. For the sake of brevity, this article will not repeat them.
[0145] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, object A and / or object B can represent three situations: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0146] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0147] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0148] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0149] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0150] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0151] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0152] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0153] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0154] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0155] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image processing method, characterized in that: The method comprises: Performing bit layering on the first image to obtain a plurality of bit planes; Determining similarities between the plurality of bit planes and the first image respectively; At least one target plane is determined from the multiple bit planes according to the similarities between the multiple bit planes and the first image respectively, and the at least one target plane is used as a compressed image of the first image.
2. The method according to claim 1, characterized in that The determining at least one target plane from the multiple bit planes according to the similarities between the multiple bit planes and the first image respectively includes: A bit plane whose similarity satisfies a similarity condition among the multiple bit planes is determined as the target plane.
3. The method according to claim 2, characterized in that The determining the similarities between the plurality of bit planes and the first image respectively comprises: determining a first hash value for the bit-plane and a second hash value for the first image; A similarity between the bit plane and the first image is determined according to the first hash value and the second hash value.
4. The method according to claim 3, characterized in that The determining the first hash value of the bit plane and the second hash value of the first image includes: Processing the bit plane using a dHash algorithm to obtain a first hash value of the bit plane; The first image is processed using the dHash algorithm to obtain a second hash value of the first image.
5. The method according to claim 3 or 4, characterized in that: The determining, according to the first Hash value and the second Hash value, the similarity between the bit plane and the first image includes: determining a Hamming distance between the first hash value and the second hash value, and using the Hamming distance as a similarity between the bit plane and the first image; The similarity condition includes that the Hamming distance is less than or equal to a first threshold, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit plane whose Hamming distance is less than or equal to the first threshold among the multiple bit planes as the target plane; or The similarity condition includes the minimum Hamming distance, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first N bit planes with the minimum Hamming distance among the multiple bit planes as the target plane; wherein N is greater than or equal to 1.
6. The method according to claim 2, characterized in that The determining the similarities between the plurality of bit planes and the first image respectively comprises: Determine a normalized correlation coefficient between the bit plane and the first image, and use the normalized correlation coefficient as the similarity between the bit plane and the first image; The similarity condition includes that the normalized correlation coefficient is greater than or equal to a second threshold value, and the bit plane whose similarity satisfies the similarity condition among the multiple bit planes is determined as the target plane, comprising: determining the bit plane whose normalized correlation coefficient among the multiple bit planes is greater than or equal to the second threshold value as the target plane; or The similarity condition includes that the normalized correlation coefficient is maximum, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first M bit planes whose normalized correlation coefficients among the multiple bit planes are maximum as the target planes; wherein M is greater than or equal to 1.
7. The method according to claim 2, characterized in that The determining the similarities between the plurality of bit planes and the first image respectively comprises: Determine a first information entropy of the bit plane and a second information entropy of the first image; determine a first difference between the first information entropy and the second information entropy, and use the first difference as the similarity between the bit plane and the first image; The similarity condition includes that the first difference is less than or equal to a third threshold value, and determining the bit planes whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the bit planes whose first difference is less than or equal to the third threshold value among the multiple bit planes as the target plane; or The similarity condition includes that the first difference is the smallest, and determining the bit plane whose similarity satisfies the similarity condition among the multiple bit planes as the target plane includes: determining the first K bit planes whose first difference is the smallest among the multiple bit planes as the target plane; wherein K is greater than or equal to 1.
8. The method according to any one of claims 1 to 7, characterized in that The bit layering of the first image to obtain a plurality of bit planes includes: Performing binary conversion on pixel values in the first image to obtain a second image; The pixel values in the second image are bit-wise split into the plurality of bit planes.
9. A computer program product, characterized in that The computer program product comprises computer program instructions, which enable an electronic device to perform the method according to any one of claims 1-8.
10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.