Intelligent image compression method

By constructing image evaluation functions, combined with edge detection and color gradient entropy, the problem of inappropriate color quantization in existing technologies has been solved, more efficient image compression is achieved, and the visual quality and information content of the image are retained.

CN119383342AActive Publication Date: 2025-01-28ZHENGZHOU HAOTIAN INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202411552496.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-01-28
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

In the existing image compression technology, the color quantization method is based on global image differences, resulting in inappropriate color types, affecting the visual quality of the image and the integrity of the information content.

Method used

By obtaining the original image and its gray image, build an image evaluation function, and use the edge detection and color gradient entropy and other technologies to determine the local edge gradient loss of each edge point. number.

Benefits of technology

Achieve more accurately measure the outline of the edge connection direction, avoid redundant calculation of multiple direction templates on the edge point, improve the calculation efficiency, and retain the detail information of the outline edges of different objects in the image, improve image compression compression compression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119383342A_ABST
    Figure CN119383342A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image color quantization processing, in particular to an intelligent image compression method, which comprises the following steps: acquiring a to-be-compressed original image and a grayscale image thereof; obtaining an image contour display graph based on the contour display performance of the edge points in the gradient direction in the gray level image; pixel points in the original image are divided into K types of pixel points according to color values; obtaining a color mapping image of the original image; obtaining an image edge gradient loss graph based on the distribution difference between any edge point of the original image and the window where the corresponding position in the color mapping image is located, the position of the edge point and the color gradient entropy; and combining the image edge gradient loss graph and the image contour display graph to construct an image evaluation function, obtaining the number of color types of the original image, and performing color quantization on the original image. According to the method and the device, the important features in the original image are better reserved while the color information contained in the original image is compressed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image color quantization processing, and in particular to an image intelligent compression method. Background Art

[0002] As one of the most important ways of transmitting information, digital images are frequently used in people's daily lives. However, due to the limitation of device storage space, images often need to be compressed for easy storage.

[0003] In image compression technology, one of the most prominent methods is color quantization technology. Color mapping the colors of pixels in an image to reduce the number of color types in the image is an image compression method that is very easy to implement. Reducing the number of color types means that less color information needs to be stored, thereby reducing the size of the image file. However, existing methods all measure color types based on global image differences, resulting in inappropriate color types in the image, causing the loss of some texture and edge information in the image. This loss will affect the visual quality of the image and the integrity of the information content. Therefore, when color mapping the colors in the image, an inappropriate number of color types is selected, which will cause the important features in the original image to no longer be prominent, affecting the communication effect of the image. Summary of the invention

[0004] In order to solve the above technical problems, the present application provides an image intelligent compression method to solve the existing problems.

[0005] An image intelligent compression method of the present application adopts the following technical solution:

[0006] An embodiment of the present application provides an image intelligent compression method, the method comprising the following steps:

[0007] Obtain the original image to be compressed and its grayscale image;

[0008] Based on the distribution of pixels in the original image and its grayscale image, an image evaluation function is constructed; specifically:

[0009] S1, after edge detection of the grayscale image, the edge points are obtained, and the contour visibility of each edge point is determined according to the grayscale distribution of the surrounding pixel points to obtain the image contour visibility map;

[0010] S2, dividing the pixels in the original image into K categories according to their color values; obtaining the main color value of each category of pixels, and replacing the color values ​​of the pixels in the category to which they belong according to the main color value, to obtain a color mapping image of the original image;

[0011] Based on the distribution difference of the position of the edge point and the distribution difference of the color gradient entropy between the window where any edge point after edge detection of the original image is located and the window where the corresponding position after edge detection of the color mapping image is located, the local edge gradient loss degree of any edge point is determined to obtain an image edge gradient loss map;

[0012] S3, constructing an image evaluation function using the image edge gradient loss map and the image contour appearance map;

[0013] Based on the image evaluation function, the number of color categories when the original image is divided into pixel categories is obtained, and then the color of the original image is quantified.

[0014] Preferably, in step S1, the method for determining the contour visibility is further defined as: according to the gradient direction of the edge point, a Kirsch operator template corresponding to the direction closest to the edge point is selected to perform convolution on the edge point.

[0015] Preferably, the division range of the pixel point category number K is further limited as follows: the difference between the main color number and the preset color range value is taken as the lower limit value of K, and the sum of the main color number and the preset color range value is taken as the upper limit value of K.

[0016] Preferably, the method for obtaining the number of primary colors is further defined as:

[0017] Reshape the original image to obtain the pixel values ​​of all pixels;

[0018] Clustering the results after sampling the pixel values ​​of all pixels;

[0019] The number of clusters after clustering is taken as the number of main colors of the original image.

[0020] Preferably, the main color value is further obtained by an average level of the product of all color values ​​in each type of pixel and their corresponding occurrence frequencies.

[0021] Preferably, the calculation method of the color gradient entropy is further determined as follows:

[0022] For each edge point, the distance between the color values ​​of a preset number of adjacent pixels is calculated;

[0023] All distances are quantified according to preset intervals;

[0024] The information entropy of all quantized values ​​is used as the color gradient entropy of each edge point.

[0025] Preferably, the local edge gradient loss degree is determined by a result of forward fusion of a distribution difference of edge point positions and a distribution difference of color gradient entropy.

[0026] Preferably, the method for obtaining the image edge gradient loss map is: assigning a local edge gradient loss value of 0 to the local edge gradient loss of the original image that is not an edge point after edge detection; and constructing an image edge gradient loss map according to the local edge gradient loss of all pixel points according to their coordinate positions in the original image.

[0027] Preferably, the method for constructing the image evaluation function is:

[0028] The image feature loss evaluation map is obtained by multiplying the values ​​of the corresponding positions of the image edge gradient loss map and the image contour appearance map;

[0029] The image evaluation function is constructed using the average level of all element values ​​in the image feature loss evaluation graph.

[0030] Preferably, on the basis of constructing the image evaluation function, the number of pixel point categories in the original image is further added to the process of constructing the image evaluation function.

[0031] This application has at least the following beneficial effects:

[0032] 1. The present application selects template operators in different directions to calculate contour visibility by analyzing the edge connection direction of pixel points. The beneficial effect is that it can more accurately measure the contour visibility of each edge point in the edge connection direction, while avoiding redundant calculation of templates in multiple directions of edge points, thereby improving calculation efficiency. It also takes into account the impact of contour edge pixel differences on the degree of human visual attention, and distinguishes the degree to which the contour edges of different objects that contain important scene structural information in the image are paid attention to by human vision, thereby achieving a more detailed division of the importance of image features carried by each position in the image.

[0033] 2. The present application determines the local edge gradient loss of each edge point by measuring the spatial distribution of the edge and the degree of color gradient of the edge. The beneficial effect is that it takes into account the continuity of the contour edges of objects in the image and the hierarchical gradient of visual colors. The pattern recognition technology is used to improve the degree of retention of detail information of the contour edges of different objects in the image during the color quantization process, thereby avoiding the problem of missing detail information caused by the prior art.

[0034] 3. The present application constructs an image evaluation function through local edge gradient loss and image contour appearance map to obtain the color type of the original image when the color is quantized, which can effectively compress the color information in the original image without losing the detail information in the image. It can be widely used in various Internet scenarios and ultra-high-definition images. At the same time, the present application obtains the interval of quantized color types through sampling and clustering methods, which can greatly shorten the time for optimizing color types and improve the efficiency of image compression. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. 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.

[0036] Figure 1 A flowchart of an image intelligent compression method provided by one embodiment of the present application;

[0037] Figure 2 A flowchart of a process for constructing an image evaluation function provided in one embodiment of the present application;

[0038] Figure 3 A flow chart of a method for determining contour visibility provided in one embodiment of the present application;

[0039] Figure 4 A flow chart of a method for obtaining an image edge gradient loss map provided in one embodiment of the present application;

[0040] Figure 5 A schematic diagram of image size comparison before and after color quantization provided in one embodiment of the present application;

[0041] Figure 6 A comparison chart of the same image before and after color quantization provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] In order to further explain the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation, structure, features and effects of an image intelligent compression method proposed by the present application in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0043] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.

[0044] The specific scheme of an image intelligent compression method provided by the present application is described in detail below with reference to the accompanying drawings.

[0045] An embodiment of the present application provides an image intelligent compression method.

[0046] Specifically, the following image intelligent compression method is provided, see Figure 1 , the method comprises the following steps:

[0047] The first step is to obtain the original image to be compressed and its grayscale image.

[0048] The RGB three-channel image of the original image to be compressed is obtained, and the obtained RGB three-channel image is converted into a grayscale image A. The conversion of the grayscale image is a well-known technology, and the specific process is not repeated here.

[0049] The second step is to construct an image evaluation function based on the distribution of pixels in the original image and its grayscale image.

[0050] Since the human visual system (HVS) is highly sensitive to edges and contours, and edges and contours can also provide important structural information in the scene, this application analyzes image structural information through pattern recognition and pattern clustering to achieve fast and accurate quantification of images.

[0051] In order to identify important structural information in the scene, the embodiment of the present application uses an edge detection algorithm to extract edge image B from grayscale image A, and extracts all edge contours in edge image B, and records the grayscale value of the pixel point at the corresponding position of any pixel point in edge image B in grayscale image A as the grayscale value of any pixel point in edge image B.

[0052] As an implementation of the embodiment of the present application, the Canny edge detection algorithm is used to extract the edge image B of the grayscale image A, wherein the Canny edge detection algorithm is a well-known technology and the specific process is not repeated. As other implementations of the embodiment of the present application, the edge detection algorithm such as the Sobel operator and the Scharr algorithm can also be used to extract the edge image B of the grayscale image A.

[0053] In the embodiment of the present application, the flowchart of the construction process of the image evaluation function is as shown in the attached Figure 2 As shown, specifically:

[0054] S1, after edge detection of the grayscale image, the edge points are obtained, and the contour visibility of each edge point is determined according to the grayscale distribution of the surrounding pixel points to obtain the image contour visibility map.

[0055] When there is a clear color contrast between an object and its background, this contrast will form a strong gradient change at the edge of the object's outline in the image to highlight the edge of the object's outline. The more uniform the color distribution on both sides of the object's outline in the image and the greater the color difference on both sides, the more obvious this edge will appear and the easier it will become a person's visual focus. Therefore, when performing color mapping on the original image, the color detail information of the edge area should be retained.

[0056] Based on the above analysis, taking the jth edge point B(i,j) on the i-th edge contour B(i) in the edge image B as an example, the contour visibility of the edge point B(i,j) is analyzed as follows:

[0057] First, the gradient direction of each edge point is calculated. The gradient direction is calculated using the Sobel operator. The principle will not be repeated here. The gradient direction represents the local pixel change direction of each pixel, which can refer to the edge connection direction in this application.

[0058] Then, according to the gradient direction of each edge point, a suitable operator template is selected to calculate the contour visibility of the edge point, specifically:

[0059] If the gradient direction is between 0° and 22.5° or between 337.5° and 360°, the 0° template of the Kirsch operator is selected;

[0060] If the gradient direction is between 22.5° and 67.5°, the 45° template of the Kirsch operator is selected;

[0061] If the gradient direction is between 67.5° and 112.5°, the 90° template of the Kirsch operator is selected;

[0062] If the gradient direction is between 112.5° and 157.5°, the 135° template of the Kirsch operator is selected;

[0063] If the gradient direction is between 157.5° and 202.5°, the 180° template of the Kirsch operator is selected;

[0064] If the gradient direction is between 202.5° and 247.5°, the 225° template of the Kirsch operator is selected;

[0065] If the gradient direction is between 247.5° and 292.5°, the 270° template of the Kirsch operator is selected;

[0066] If the gradient direction is between 292.5° and 337.5°, the 315° template of the Kirsch operator is selected.

[0067] The left side of the interval of the above gradient direction is a closed interval, and the right side is an open interval. In addition, the special 360° value is also a closed interval. The Kirsch operator is a well-known technology and will not be described in detail.

[0068] Finally, the corresponding operator template is selected to perform convolution operation with the edge point to obtain the contour visibility. Since the convolution calculation may have negative values, it is also necessary to use range normalization on the result after the convolution operation, and the value after range normalization is used as the final contour visibility of each edge point.

[0069] It should be understood that the Kirsch operator template has direction selectivity, and each template can be used to detect contours in a specific direction. By selecting the template that best matches the gradient direction, the degree of contour appearance of each edge point in the edge connection direction can be more accurately measured. The larger the value, the more obvious the contour, and the corresponding image position is more likely to become the image position that the human eye pays attention to, and the more it should be retained during the color quantization process.

[0070] In other embodiments of the present application, the Sobel operator or other gradient operators may be used to calculate the contour visibility. For example, the gradient amplitude calculated by the Sobel operator may be used as the contour visibility of the pixel point. The use of the Sobel operator can improve the running speed. The implementer can freely select the method for calculating the contour visibility according to the situation.

[0071] In the embodiment of the present application, the flow chart of the method for determining contour visibility is shown in the attached Figure 3 shown.

[0072] Furthermore, after calculating the corresponding contour visibility for each edge pixel point, a new image is obtained, which is recorded as the image contour visibility map C, which is used to characterize the degree of difference in grayscale distribution of pixels on the contour edges of all objects in the grayscale image A in the direction of their contour edge connection and the degree of contour highlighting, so as to reflect the distribution of pixels containing different important image features in the grayscale image A.

[0073] S2, divide the pixels in the original image into K categories according to their color values; obtain the main color value of each category of pixels, and replace the color value of the pixels in its category according to the main color value to obtain a color mapping image of the original image; based on the distribution difference of the position of the edge point between the window where any edge point after edge detection of the original image is located and the window where the corresponding position after edge detection of the color mapping image is located, and the distribution difference of the color gradient entropy, determine the local edge gradient loss degree of any edge point to obtain an image edge gradient loss map.

[0074] When color mapping is performed on an original image to reduce the file storage size of the original image, it is usually necessary to map the R, G, and B color values ​​of the pixels in the original image to achieve image compression.

[0075] In the embodiment of the present application, the flowchart of the method for obtaining the image edge gradient loss map is as shown in the attached Figure 4As shown, specifically:

[0076] S201, dividing the pixels in the original image into K types of pixels according to their color values.

[0077] Preferably, in an embodiment of the present application, a clustering algorithm is used to divide the color values ​​of pixels in the original image.

[0078] As an implementation of the embodiment of the present application, the K-Means clustering algorithm is selected to cluster the color values ​​of the pixels in the original image. As other implementations of the embodiment of the present application, other suitable clustering algorithms may also be used, such as: K-means algorithm, hierarchical clustering algorithm and fuzzy C-means algorithm.

[0079] In other embodiments of the present application, the range of pixel values ​​of the pixel points in each channel may be divided by using a median quantization method.

[0080] The specific implementation method is as follows: the pixel value range of the pixel point in each channel of the original image is 0-255, which is evenly divided into a preset number of M parts, and all the pixel points in each part are mapped to the median of the range.

[0081] For example, the preset number M is set to 4, and 0-255 is divided into four parts: 0-63, 64-127, 128-191, and 192-255. The color values ​​of the pixels in these four parts are mapped to 32, 96, 160, and 224 respectively.

[0082] Furthermore, in order to preserve as much as possible the main color information in the original image when subsequently color mapping is performed on the original image, and to increase the speed of finding the optimal number of color types preserved in the color mapping result of the original image.

[0083] In the embodiment of the present application, the original image is first reshaped, i.e., reshaped, to obtain the pixel values ​​of all pixels, and then the pixel values ​​of all pixels are sampled, the sampling is a preset ratio value of the number of pixels, the sampled results are clustered, and the number of clusters after clustering is used as the number of main colors of the original image, thereby obtaining the range of K:

[0084] The difference between the number of main colors and the preset color range value N is used as the lower limit of K, and the sum of the number of main colors and the preset color range value N is used as the upper limit of K. In this embodiment, the preset ratio value is 0.05, the preset color range value N is 5, and the clustering algorithm adopts the DBSCAN algorithm, which is a well-known technology and will not be described in detail. Obtaining the value range of K by the above method can greatly improve the operation speed (because the maximum value of the number of image colors is the cube of 256) and improve the accuracy of quantization.

[0085] The range of K is limited by the lower limit and upper limit of K, and the division of the pixels in the original image under different values ​​is realized in turn according to the value range of K. In other embodiments of the present application, peak detection can also be selected to obtain the number of main colors of the original image, specifically: the grayscale frequency of all grayscale values ​​of the grayscale image of the original image is peak detected, and the number of peaks is used as the number of main colors. The peak detection method is a well-known technology and its principle is not repeated here.

[0086] S202, obtaining the main color value of each type of pixel, and replacing the color value of the pixel in the corresponding type according to the main color value, to obtain a color mapping image of the original image.

[0087] In the present application, taking the k-th pixel in the original image as an example, the main color value r(k) of the k-th pixel is calculated to characterize the main color of the k-th pixel in the original image when the pixels in the original image are divided into K categories.

[0088] Preferably, in the embodiment of the present application, the main color value is obtained by the average level of the product of all color values ​​in each type of pixel and their corresponding occurrence frequency.

[0089] As an implementation of an embodiment of the present application, the expression of the main color value r(k) of the k-th type of pixel is: Where w1(m) and w2(m) represent the mth color value and the frequency of occurrence of the mth color value in the kth pixel in the original image, respectively; M represents the number of color values ​​in the kth pixel in the original image; and round() is the rounding function.

[0090] It should be understood that the greater the frequency of occurrence of the mth color value in the kth pixel in the original image, that is, the larger w2(m), which means that the mth color value can better reflect the main color of the kth pixel, and r(k) should be closer to w1(m).

[0091] As another implementation of the embodiment of the present application, the main color value r(k) of the k-th type of pixel may also be set to the color value that appears most frequently in the K-th type of pixel.

[0092] In other embodiments of the present application, the main color value r(k) of the k-th type of pixel may also be obtained according to the centroid of the color values ​​of all the pixels in the k-th type of pixel.

[0093] Furthermore, the color values ​​of the pixels in each category of pixels in the original image are replaced with the main color values ​​corresponding to each category of pixels, and the color types of the pixels in each category of pixels are reduced by using the main color values ​​of the pixels in each category as the color values ​​of the pixels in each category of pixels, and the replacement result of the original image is recorded as the color mapping image R(K) of the original image, which is used to represent the original image mapped when the pixels in the original image are divided into K categories, that is, when the color values ​​of the pixels in the original image are mapped to K color values.

[0094] S203, based on the distribution difference of the position of the edge point between the window where any edge point after edge detection of the original image is located and the window where the corresponding position after edge detection of the color mapping image is located, and the distribution difference of the color gradient entropy, determine the local edge gradient loss degree of any edge point to obtain the image edge gradient loss map.

[0095] The edge detection algorithm is used to extract the edge image BR of the original image and the edge image BR(K) of the color mapping image R(K), and all edge contours in the edge image BR and the edge image BR(K) are extracted respectively. Then, the color gradient entropy of the edge points on the edge contours in the edge image BR and the edge image BR(K) is calculated.

[0096] In the embodiment of the present application, the Canny edge detection algorithm is used to perform edge detection on the edge image BR of the original image and the edge image BR(K) of the color mapping image R(K). The Canny edge detection algorithm is a well-known technology, and the specific process is not repeated here.

[0097] The calculation method of the distribution difference of the edge point position is specifically as follows:

[0098] In the present application, taking the j-th edge point BR(i,j) on the i-th edge contour BR(i) in the edge image BR as an example, a window matrix of size W×W is constructed with the edge point BR(i,j) as the center, and is recorded as the edge distribution matrix h(i,j) of the edge point BR(i,j), which is used to characterize the position distribution of the edge contour of the pixel point BR(i,j) in its window.

[0099] Get the pixel point BR(K,i,j) with the same coordinates as the edge point BR(i,j) in the edge image BR(K), and record the window matrix of the pixel point BR(K,i,j) with a size of W×W as the edge distribution matrix h(K,i,j) of the pixel point BR(K,i,j).

[0100] The distance between the edge distribution matrices h(K,i,j) and h(i,j) is recorded as the edge continuity difference value of the edge point BR(i,j), which is used to characterize the degree of change in the continuity of the contour edge information of the edge point BR(i,j) in its window when the color value of the edge point in the original image is mapped to K color values, that is, the distribution difference of the position of the edge point, such as the absence or increase of pixels in the contour edge. The greater the distance between the matrices, the greater the degree of change. The above window size W is taken as 3 in this embodiment, that is, the smallest local window, to improve the calculation speed.

[0101] In the embodiment of the present application, the method for calculating the distance between matrices includes but is not limited to Euclidean distance, Manhattan distance and Chebyshev distance. The calculation of Euclidean distance, Manhattan distance and Chebyshev distance are all well-known technologies, and the specific process will not be repeated here.

[0102] Preferably, in an embodiment of the present application, the method for calculating the color gradient entropy is specifically as follows: for each edge point, respectively calculate the distance between the color values ​​of a preset number of pixel points adjacent to it; quantize all distances according to preset intervals; and use the information entropy of all quantized values ​​as the color gradient entropy of each edge point.

[0103] As an implementation method of the present application, the preset number is set to 8, and the distance is calculated using the L2 distance. For each edge point, the L2 distance of the color values ​​of the 8 adjacent pixels is calculated respectively, and then the L2 distance is quantized according to a preset interval, wherein one quantization interval is: the L2 distance less than or equal to G1 is quantized to 1, the L2 distance in the range of [G1, 2*G1) is quantized to 2, the L2 distance in the range of [2*G1, 3*G1) is quantized to 3, and the L2 distance greater than or equal to 3*G1 is quantized to 4. G1 is 30 in this embodiment. The calculation process of the L2 distance and the calculation process of the information entropy are both well-known technologies and will not be repeated here.

[0104] At this point, each of the eight adjacent pixels has a quantized value, and then the information entropy of the eight quantized values ​​is calculated and used as the color gradient entropy of the central pixel. The larger the value, the more layered the color gradient around the pixel, and the more complex the gradient.

[0105] In other embodiments of the present application, the following method can also be used for calculation: for each edge point, the color values ​​of the eight adjacent pixels are compared with it. If the L2 distance between the adjacent pixel value and the central pixel value is greater than the preset comparison threshold G2, the position of the pixel is marked as 1, otherwise it is marked as 0.

[0106] In this way, the 8 pixels in the 3*3 neighborhood can generate an 8-bit binary number after comparison, which is then converted into a decimal number as the color gradient entropy of the edge point, where G2 is 30 in this embodiment.

[0107] At this point, the color gradient entropy of each edge point can be obtained, and the distance between the color gradient entropies of pixels at the same position before and after quantization can be calculated, which is recorded as the color gradient difference value of the edge point BR(i,j). It is used to characterize the degree of change in the color gradient of the contour edge information of the edge point BR(i,j) in its window when the color value of the pixel in the original image is mapped to K color values, that is, the distribution difference of the color gradient entropy of the edge point. The larger the distance between the two matrices caused by it, the greater the degree of change.

[0108] Preferably, in an embodiment of the present application, the local edge gradient loss degree is determined by a result of forward fusion of a distribution difference of edge point positions and a distribution difference of color gradient entropy.

[0109] It can be understood that forward fusion is a fusion method such as addition and multiplication between data. The specific forward fusion method is determined by the implementer according to the actual situation, and this application does not impose any special restrictions.

[0110] As an implementation method of an embodiment of the present application, the product of the edge continuity difference value and the color gradient difference value of the edge point BR(i,j) is used as the local edge gradient loss of the edge point BR(i,j), which is used to characterize the continuity of the contour edge and the color gradient loss degree of the edge point BR(i,j) in its window when the color value of the pixel point in the original image is mapped to K color values. The worse the continuity of the contour edge and the greater the loss of color gradient, the less completely the contour edge is retained, and the greater the loss degree, that is, the greater the local edge gradient loss degree.

[0111] As another implementation of the embodiment of the present application, the sum of the edge continuity difference value and the color gradient difference value of the edge point BR(i,j) may be used as the local edge gradient loss of the edge point BR(i,j).

[0112] Wherein, the method for obtaining the image edge gradient loss map is:

[0113] In addition, after edge detection of the original image, the local edge gradient loss of non-edge points is assigned to 0; the local edge gradient loss of all pixels is constructed according to their coordinate positions in the original image to construct an image edge gradient loss map.

[0114] Taking the edge image BR after edge detection of the original image as an example, the local edge gradient loss of the non-edge points in the edge image BR is assigned to 0. The values ​​of each pixel in the edge image BR are replaced with the local edge gradient loss corresponding to each pixel, and the reassigned image is recorded as the image edge gradient loss map RC(K). At this point, the feature information of the image is obtained through image pattern recognition, which is used to characterize the distribution of the loss degree of the contour edge information around the edge points containing the contour edge information of the object in the original image in the color mapping image when the color values ​​of the pixel points in the original image are mapped to K color values.

[0115] S3, constructing an image evaluation function using the image edge gradient loss map and the image contour appearance map.

[0116] The values ​​of the pixels at the corresponding positions in the image edge gradient loss map RC(K) and the image contour appearance map C are multiplied, and the resulting image is recorded as the image feature loss evaluation map RD(K) of the original image, which is used to characterize the loss of image detail information of the pixels in the original image that contain important feature information of the original image when the color values ​​of the pixels in the original image are mapped to K color values.

[0117] In the present application, an image evaluation function FR(K) of the original image is constructed based on the image feature loss evaluation graph RD(K), which is used to obtain the optimal number of color types retained in the color mapping result of the original image when the original image is color mapped, wherein the independent variable K when the function value of the image evaluation function FR(K) is the smallest is used as the number of color types of the original image.

[0118] Preferably, in an embodiment of the present application, the image evaluation function is constructed by an average level of values ​​of all elements in an image feature loss evaluation graph.

[0119] As an implementation method of an embodiment of the present application, the construction expression of the image evaluation function FR(K) of the original image is: FR(K)=rd(K), wherein FR(K) represents the image evaluation function of the original image; rd(K) represents the mean value of all element values ​​in the image feature loss evaluation graph RD(K); wherein the independent variable of the image evaluation function FR(K) of the original image is K, and the dependent variable is the function value of FR(K) when the independent variable is K.

[0120] It should be understood that in order to effectively reduce the color information that needs to be stored in the original image, when mapping the color values ​​of the pixels in the original image, the number of color value types in the mapping result should be smaller, that is, K should be smaller. At the same time, in order to retain the important image feature information in the original image, the overall loss of image detail information of the pixels in the original image containing the image feature information should be smaller, that is, rd(K) should be smaller.

[0121] As other implementation methods of the embodiments of the present application, the image evaluation function can continue to consider the size of the independent variable K based on the image feature loss evaluation graph RD(K), that is, consider the number of pixel point categories in the original image. Therefore, the construction expression of the image evaluation function FR(K) of the original image can also be set to: FR(K)=rd(K)+K; FR(K)=β1*rd(K)+β2*K, β1 and β2 are weight coefficients, and the values ​​are set by the implementer, and β1+β2=1.

[0122] It should be understood that one of the application methods of constructing the image feature loss evaluation map is to determine the optimal number of color types retained in the color mapping result when the image is color mapped in the embodiment of the present application, thereby achieving image compression. In addition, the image feature loss evaluation map can also be applied to the field of image evaluation.

[0123] The third step is to obtain the number of color categories when the original image is divided into pixel categories based on the image evaluation function, and then perform color quantization on the original image.

[0124] In the present application, taking the original image as an example, the value of the independent variable K when the image evaluation function FR(K) takes the minimum value is obtained, which is recorded as the number of color types KM of the original image, and the color mapping image R(KM) of the original image when K=KM is obtained as the final mapping image RM of the original image, thereby realizing the compression of the color information in the original image.

[0125] In the embodiment of the present application, a schematic diagram of image size comparison before and after color quantization is shown in the attached figure. Figure 5 shown.

[0126] In the attached Figure 5 In the example, the horizontal axis is the sample number of the original image to be compressed, and the vertical axis is the size difference between the image before and after color quantization for each sample, in KB. In this example, 75 samples are selected to compare the size difference of the image before and after.

[0127] In the embodiment of the present application, the comparison diagram of the same image before and after color quantization is shown in the attached figure. Figure 6 As shown, Image 1 is the image before color quantization, and Image 2 is the image after color quantization.

[0128] The various embodiments in the present application are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0129] It should be noted that, unless otherwise specified and limited, terms such as "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a circuit structure, 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 article or device. In the absence of further restrictions, an element defined by the sentence "including one..." does not exclude the existence of other identical elements in the article or device including the element. In addition, the term "and\or" used herein includes any and all combinations of one or more related listed items.

[0130] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not invented by the present application.

[0131] It should be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.

Claims

1. An intelligent image compression method, characterized in that: The method comprises the following steps: Obtain the original image to be compressed and its grayscale image; Based on the distribution of pixels in the original image and its grayscale image, an image evaluation function is constructed; specifically: S1, after edge detection of the grayscale image, the edge points are obtained, and the contour visibility of each edge point is determined according to the grayscale distribution of the surrounding pixel points to obtain the image contour visibility map; S2, dividing the pixels in the original image into K categories according to their color values; obtaining the main color value of each category of pixels, and replacing the color values ​​of the pixels in the category to which they belong according to the main color value, to obtain a color mapping image of the original image; Based on the distribution difference of the position of the edge point and the distribution difference of the color gradient entropy between the window where any edge point after edge detection of the original image is located and the window where the corresponding position after edge detection of the color mapping image is located, the local edge gradient loss degree of any edge point is determined to obtain an image edge gradient loss map; S3, constructing an image evaluation function using the image edge gradient loss map and the image contour appearance map; Based on the image evaluation function, the number of color categories when the original image is divided into pixel categories is obtained, and then the color of the original image is quantified.

2. The image intelligent compression method according to claim 1, characterized in that: In step S1, the method for determining the contour visibility is further defined as: according to the gradient direction of the edge point, a Kirsch operator template corresponding to the direction closest to the edge point is selected to perform convolution on the edge point.

3. The image intelligent compression method according to claim 1, characterized in that: The division range of the pixel point category number K is further limited as follows: the difference between the main color number and the preset color range value is used as the lower limit value of K, and the sum of the main color number and the preset color range value is used as the upper limit value of K.

4. The image intelligent compression method according to claim 3, characterized in that: The method for obtaining the number of primary colors is further defined as: Reshape the original image to obtain the pixel values ​​of all pixels; Clustering the results after sampling the pixel values ​​of all pixels; The number of clusters after clustering is taken as the number of main colors of the original image.

5. The image intelligent compression method according to claim 1, characterized in that: The main color value is further obtained by the average level of the product of all color values ​​in each type of pixel and their corresponding occurrence frequency.

6. The image intelligent compression method according to claim 1, characterized in that: The calculation method of the color gradient entropy is further determined as follows: For each edge point, the distance between the color values ​​of a preset number of adjacent pixels is calculated; All distances are quantified according to preset intervals; The information entropy of all quantized values ​​is used as the color gradient entropy of each edge point.

7. The image intelligent compression method according to claim 1, characterized in that: The local edge gradient loss is determined by a result of forward fusion of a distribution difference of edge point positions and a distribution difference of color gradient entropy.

8. The image intelligent compression method according to claim 7, characterized in that: The method for obtaining the image edge gradient loss map is as follows: after edge detection of the original image, the local edge gradient loss of the points that are not edge points is assigned a value of 0; and the local edge gradient loss of all pixel points is constructed according to their coordinate positions in the original image to construct the image edge gradient loss map.

9. The image intelligent compression method according to claim 1, characterized in that: The method for constructing the image evaluation function is: The image feature loss evaluation map is obtained by multiplying the values ​​of the corresponding positions of the image edge gradient loss map and the image contour appearance map; The image evaluation function is constructed using the average level of all element values ​​in the image feature loss evaluation graph.

10. The image intelligent compression method according to claim 9, characterized in that: On the basis of constructing the image evaluation function, the number of pixel categories in the original image is further added into the construction process of the image evaluation function.

Citation Information

Patent Citations

  • Image processing apparatus and method of processing image

    CN102314605A

  • Image edge and line feature based three-dimensional model retrieval method

    CN105930497A

  • High-spectral image classification method

    CN107247966A

  • Method for improving latent image boundary based on edge detection error diffusion algorithm

    CN108921770A

  • Image comparison method, image comparison device, and non-transitory computer-readable recording medium recording image comparison program

    US20240078709A1

Cited By

  • Intelligent image zooming method

    CN120147114A