Image processing method and device, equipment, chip, storage medium and product

By dividing the image into multiple regions and adjusting the grayscale value according to the region characteristics, the problem of local adaptive adjustment in the prior art is solved, and a more natural and smooth image grayscale adjustment effect is achieved.

CN119991532APending Publication Date: 2025-05-13GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510058902.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The existing image brightness adjustment scheme cannot adaptive brightness adjustment based on the local characteristics of the image, resulting in changes in image contrast, excessive brightness or excessive darkness.

Method used

The target image is obtained by dividing the image into K areas based on the grayscale value of pixel points in the image and adjusting the grayscale value based on the weights of each area.

Benefits of technology

The targeted optimization of the grayscale in different areas of the image is achieved, which improves the local adaptability of image grayscale adjustment, and makes the adjusted image visual effect more natural and smooth.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991532A_ABST
    Figure CN119991532A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method and apparatus, a device, a chip, a storage medium and a product. The method comprises the steps of obtaining a to-be-processed image; dividing the image into K areas according to gray values of pixel points in the image; based on the weights corresponding to the K areas, adjusting the gray values of the K areas to obtain a target image; wherein K is an integer greater than 1. According to the method provided by the embodiment of the invention, the gray value of the region can be adjusted based on the weight corresponding to each image region, so that the gray levels of different regions of the image can be specifically optimized, and better local adaptability to gray level adjustment of the image is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to but is not limited to the field of computer technology, and in particular to an image processing method, device, equipment, chip, storage medium and product. Background Art

[0002] At present, the commonly used image brightness adjustment schemes include: schemes based on pixel value adjustment, histogram equalization, gamma correction, etc. Among them, the scheme based on pixel value adjustment is to uniformly perform linear operations on the entire pixel of the image; histogram equalization is to calculate the frequency of occurrence of pixels of each gray level in the image, and then remap the gray value according to the cumulative distribution function to make the gray distribution of the image more uniform; gamma correction is to use the gamma function to perform nonlinear transformation on the pixel value of the image, thereby changing the brightness of the image.

[0003] However, the above-mentioned image brightness adjustment solutions are all brightness adjustment solutions for the entire image, and cannot perform adaptive brightness adjustment according to local features of the image. Summary of the invention

[0004] The present application at least provides an image processing method, device, equipment, chip, storage medium and product.

[0005] The technical solution of this application is implemented as follows:

[0006] In a first aspect, the present application provides an image processing method, the method comprising: obtaining an image to be processed; dividing the image into K regions according to the grayscale values ​​of pixels in the image; adjusting the grayscale values ​​of the K regions based on the weights corresponding to each of the K regions to obtain a target image; wherein K is an integer greater than 1.

[0007] In second aspect, an embodiment of the present application provides an image processing device, which includes: an acquisition unit, used to acquire an image to be processed; a division unit, used to divide the image into K regions according to the grayscale values ​​of pixels in the image; an adjustment unit, used to adjust the grayscale values ​​of each of the K regions based on the weights corresponding to each of the K regions, so as to obtain a target image; wherein K is an integer greater than 1.

[0008] In a third aspect, an embodiment of the present application provides an image processing device, which includes a memory and a processor; wherein the memory is used to store computer-executable instructions; the processor is connected to the memory and is used to implement the method described in the first aspect by executing the computer-executable instructions.

[0009] In a fourth aspect, an embodiment of the present application provides a chip, which includes: a processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes the method described in the first aspect.

[0010] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by at least one processor, it implements the method described in the first aspect.

[0011] In a sixth aspect, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the method described in the first aspect.

[0012] In the embodiment of the present application, the image to be processed can be divided into K regions according to the grayscale values ​​of the pixels in the image, and then the grayscale values ​​of the K regions can be adjusted based on the weights corresponding to the K regions to obtain the target image. According to the method of the embodiment of the present application, since the grayscale value of each image region can be adjusted based on the weight corresponding to the region, it is possible to achieve targeted optimization of the grayscale of different regions of the image, thereby having better local adaptability to the grayscale adjustment of the image.

[0013] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] 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.

[0015] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;

[0016] Figure 2 A possible implementation flow diagram of the image processing method provided in the embodiment of the present application;

[0017] Figure 3 A schematic diagram of a flow chart of a histogram clustering algorithm provided in an embodiment of the present application;

[0018] Figure 4 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;

[0019] Figure 5 A hardware entity schematic diagram of an image processing device in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.

[0021] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0022] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is 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. It should also be noted that the terms "first\second\third" involved in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second\third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0023] It should be understood that the term "and / or" in the embodiments of the present application is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0024] At present, the commonly used image brightness adjustment schemes include: schemes based on pixel value adjustment, histogram equalization, gamma correction and local contrast enhancement. Among them, the scheme based on pixel value adjustment is to change the brightness of the image by increasing or decreasing the pixel values ​​of the image at the same time; the brightness adjustment scheme based on histogram equalization is more common, mainly by calculating the frequency of occurrence of pixels of each gray level in the image, and then remapping the gray value according to the cumulative distribution function, stretching the gray value distribution of the original image, making the gray distribution of the image more uniform, and then enhancing the contrast and brightness of the image; the brightness adjustment scheme based on gamma correction can use the gamma function to perform nonlinear transformation on the pixel value of the image, and can change the brightness and contrast of the image by adjusting the gamma value. In addition, there is another type of scheme based on local contrast enhancement method, in which the image can be divided into multiple local areas, and each local area is subjected to histogram equalization processing, and then the processed local areas are merged into the final image.

[0025] However, the brightness adjustment scheme based on pixel value adjustment is a linear operation on all pixels, which is prone to image contrast changes and overbrightness or overdarkness. The histogram equalization scheme will reduce the image detail information due to the merging or loss of some gray levels, resulting in gray level loss or over-enhancement, and it is impossible to adjust local areas. The gamma correction brightness adjustment scheme requires manual selection of the appropriate gamma value, is highly dependent on the image scene, and is difficult to select parameters. In addition, gamma correction is a global brightness adjustment method that cannot effectively handle images with uneven lighting.

[0026] It can be seen that the current brightness adjustment schemes (such as histogram equalization, gamma correction, etc.) are usually brightness adjustment schemes for the global image, and cannot perform adaptive brightness adjustment according to local features of the image.

[0027] In view of this, the embodiments of the present application provide an image processing method, device, equipment, chip, storage medium and product. In this method, the image to be processed can be divided into K regions according to the grayscale values ​​of the pixels in the image, and then the grayscale values ​​of the K regions can be adjusted based on the weights corresponding to the K regions to obtain the target image.

[0028] According to the method of the embodiment of the present application, since the grayscale value of each image region can be adjusted based on the weight corresponding to the region, it is possible to achieve targeted optimization of the grayscale of different regions of the image, thereby having better local adaptability to the grayscale adjustment of the image. In addition, since the K regions are obtained by dividing according to the grayscale values ​​of the pixels, grayscale adjustments can be made for different grayscale regions. For example, if the image is divided into three regions: dark, medium, and bright, grayscale adjustments can be made for the three regions: dark, medium, and bright, so as to better adapt to the characteristics of different grayscale regions and make the adjusted image more natural and smooth in visual effect.

[0029] It should be noted that in some scenarios, the "grayscale" in the embodiments of the present application can also be understood as (or replaced by) "brightness". In other words, the "grayscale" and "brightness" in the embodiments of the present application can be replaced with each other.

[0030] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0031] The present application embodiment provides an image processing method. Figure 1 As shown, the method may include:

[0032] S101, obtaining an image to be processed.

[0033] Exemplarily, an input image may be read from a sensor as the image to be processed.

[0034] S102, dividing the image into K regions according to the grayscale values ​​of pixels in the image.

[0035] In this step, the image can be divided into K regions according to the grayscale values ​​of the pixels in the image, so that pixels with similar grayscale features can be divided into the same region, where K is an integer greater than 1.

[0036] It should be noted that in some scenarios, the "gray value" in the embodiments of the present application can also be understood as (or replaced by) "gray level". In other words, the "gray value" and "gray level" in the embodiments of the present application can be replaced with each other.

[0037] In some embodiments, the image is divided into K regions according to the grayscale values ​​of the pixels in the image, including: using a clustering algorithm to divide the grayscale values ​​of the pixels in the image into K categories (or called K clusters or K cluster clusters); dividing the pixels in the image into K regions according to the category to which the grayscale values ​​of each pixel in the image belong.

[0038] That is to say, when dividing an image into K regions according to the grayscale values ​​of the pixels in the image, the grayscale values ​​of the pixels in the image can first be divided into K categories through a clustering algorithm, and then the pixels in the image can be divided into K regions according to the category to which the grayscale values ​​of each pixel in the image belong.

[0039] For example, assuming K = 3, the grayscale values ​​of the pixels in the image are divided into three classes, where the grayscale value range of the first class is [a, b], the grayscale value range of the second class is [c, d], and the grayscale value range of the third class is [e, f]. In this case, if the grayscale value of a pixel belongs to [a, b] (that is, it belongs to the first class), the pixel can be divided into the area corresponding to the first class; if the grayscale value of a pixel belongs to [c, d] (that is, it belongs to the second class), the pixel can be divided into the area corresponding to the second class; if the grayscale value of a pixel belongs to [e, f] (that is, it belongs to the third class), the pixel can be divided into the area corresponding to the third class.

[0040] In this way, by traversing the classes to which the grayscale values ​​of each pixel in the image belong, the pixels in the image can eventually be divided into K regions, where the pixels in the same region have similar grayscale features.

[0041] It should be noted that the above K=3 is only an example, and the embodiment of the present application does not limit the value of K.

[0042] It should also be noted that the embodiments of the present application do not limit the clustering algorithm used. For example, a K-means clustering algorithm, a threshold-based clustering algorithm, a hierarchical clustering algorithm, or a fuzzy C-means clustering algorithm may be used.

[0043] In one implementation, in order to divide the image into K regions according to the grayscale values ​​of the pixels in the image, the number of times each grayscale value appears in the image can be counted to obtain a grayscale histogram of the image. In the grayscale histogram, the horizontal axis can represent each grayscale value of the image, and the vertical axis can represent the number of times each grayscale value appears in the image. Furthermore, the grayscale values ​​of the pixels in the image can be divided into K categories by applying a clustering algorithm to the grayscale histogram.

[0044] As an example, the following introduces an implementation process of applying the K-means clustering algorithm to the grayscale histogram. The implementation process may include steps 11) to 15).

[0045] 11) Determine the number of clusters K.

[0046] For example, considering that the image can be divided into three levels: dark, medium, and bright for adjustment, K=3 can be set.

[0047] 12) Initialize cluster centers.

[0048] For example, a random initialization method may be used to select K different grayscale values ​​in the grayscale histogram as initial cluster centers. For example, three grayscale values ​​representing dark, medium, and bright may be selected as initial cluster centers.

[0049] 13) Assign the grayscale values ​​in the grayscale histogram to K classes.

[0050] As an implementation method, the Euclidean distance from each grayscale value in the grayscale histogram to the K cluster centers may be calculated, and clustering may be performed based on the calculated Euclidean distance.

[0051] As an example, assuming that the grayscale values ​​corresponding to the three current cluster centers are 500, 750, and 1050, respectively, then for a grayscale value in the grayscale histogram, if the grayscale value has the shortest Euclidean distance to cluster center 500, the grayscale value can be assigned to the class where cluster center 500 is located. Similarly, if the grayscale value has the shortest Euclidean distance to cluster center 750, the grayscale value can be assigned to the class where cluster center 750 is located; if the grayscale value has the shortest Euclidean distance to cluster center 1050, the grayscale value can be assigned to the class where cluster center 1050 is located.

[0052] By traversing each grayscale value in the grayscale histogram, the grayscale values ​​in the grayscale histogram can be assigned to K classes.

[0053] 14) Update the cluster center.

[0054] After completing a round of grayscale value to class assignment, the cluster center can be recalculated for each class.

[0055] Exemplarily, for each of the K classes, the average value of all grayscale values ​​contained in the class may be calculated, and the average value may be used as a new cluster center.

[0056] 15) Stop iteration when the conditions are met.

[0057] The above steps 13) and 14) can be repeatedly executed until a certain condition is met (such as the cluster center no longer changes significantly), and then the iteration is stopped.

[0058] As an implementation method, if the difference between the cluster centers obtained in the previous and next two iterations is less than a preset threshold, the iteration can be stopped. For example, assuming that the preset threshold is 20, then if the difference between the current iteration and the previous iteration of all cluster centers is less than 20, it can be considered that the clustering has converged, in which case the iteration can be stopped.

[0059] Through the above iterative process, the clustering results can be gradually stabilized, and the grayscale values ​​in the grayscale histogram can be finally assigned to K classes, that is, the grayscale values ​​of the pixels in the image are divided into K classes, and each class has similar grayscale features.

[0060] S103, adjusting the grayscale values ​​of the K regions based on the weights corresponding to the K regions to obtain a target image; wherein K is an integer greater than 1.

[0061] In this step, the grayscale values ​​of the K regions may be adjusted based on the weights corresponding to the K regions to obtain a target image.

[0062] For example, assuming K=3, the grayscale value of the first region can be adjusted based on the weight corresponding to the first region. Similarly, the grayscale value of the second region can be adjusted based on the weight corresponding to the second region, and the grayscale value of the third region can be adjusted based on the weight corresponding to the third region.

[0063] According to the method of this embodiment, since the grayscale value of each image region can be adjusted based on the weight corresponding to the region, it is possible to achieve targeted optimization of the grayscale of different regions of the image, thereby having better local adaptability to the grayscale adjustment of the image. In addition, since the K regions are obtained by dividing according to the grayscale values ​​of the pixels, grayscale adjustment can be performed for different grayscale regions. For example, if the image is divided into three regions: dark, medium, and bright, grayscale adjustment can be performed for the three regions: dark, medium, and bright, so as to better adapt to the characteristics of different grayscale regions and make the adjusted image more natural and smooth in visual effect.

[0064] In some embodiments, based on the weights corresponding to each of the K regions, the grayscale values ​​of each of the K regions are adjusted to obtain a target image, including: multiplying the weights corresponding to each of the K regions by the grayscale values ​​of the pixels contained in each of the K regions to obtain the target image.

[0065] For example, assuming K=3, then the weight corresponding to the first area can be multiplied by the grayscale value of the pixels contained in the first area, and similarly, the weight corresponding to the second area can be multiplied by the grayscale value of the pixels contained in the second area, and the weight corresponding to the third area can be multiplied by the grayscale value of the pixels contained in the third area. The result of the multiplication is the adjusted grayscale value, and thus, the target image after grayscale adjustment can be obtained.

[0066] According to the method of this embodiment, by multiplying the weights corresponding to the K regions by the grayscale values ​​of the pixels contained in the K regions, the purpose of adjusting the grayscale of the K regions can be achieved.

[0067] In some embodiments, the method may further include: for each of the K regions, determining a weight corresponding to the region based on at least one of the following a) to c):

[0068] a) The number of gray values ​​of pixels in the area.

[0069] The number of grayscale values ​​of pixels in the region can also be understood as how many different grayscale values ​​the region covers. For example, if a region contains pixels with grayscale values ​​of 20, 25, 30, and 35, the number of grayscale values ​​of pixels in the region is 4. It can be seen that the number of grayscale values ​​of pixels in a region reflects the coverage of the region in terms of grayscale values.

[0070] b) The degree of discreteness of the grayscale values ​​of the pixels in the area.

[0071] c) The degree of difference between the grayscale values ​​of pixels in this area and the grayscale values ​​of pixels in other areas.

[0072] According to the method of this embodiment, for each of the K regions, by considering at least one of a) to c), the weight corresponding to the region is determined, and attention can be paid to the different characteristics of each region, so that accurate grayscale adjustment can be performed according to the different characteristics of each region. For example, by considering the factors in a), attention can be paid to the coverage of each region in grayscale value, and by considering the factors in b) and c), the relative position and correlation of each region in the overall image can be understood, so that the coordination of the image can be grasped from a more macro perspective when adjusting the grayscale.

[0073] In some embodiments, the number of grayscale values ​​of pixels in the region is positively correlated with the weight corresponding to the region.

[0074] That is to say, for a certain area among the K areas, if the number of grayscale values ​​of the pixels in the area is greater, the corresponding weight of the area is greater; correspondingly, if the number of grayscale values ​​of the pixels in the area is smaller, the corresponding weight of the area is smaller.

[0075] It is understandable that if the number of grayscale values ​​of pixels in the region is large, it means that the grayscale value coverage of the region is wide, so assigning a larger weight to the region is helpful to avoid loss of image details.

[0076] As an implementation method, assume that there are L grayscale values ​​in the image, that is, the total number of grayscale values ​​of pixels in the K regions is L. Then, for the kth region in the K regions, the weight corresponding to the kth region is It can be expressed as: Among them, l k Indicates the number of grayscale values ​​of pixels in the kth region.

[0077] In some embodiments, the discreteness of the grayscale values ​​of the pixels in the region is negatively correlated with the weight corresponding to the region.

[0078] That is to say, for a certain area among the K areas, if the discrete degree of the grayscale values ​​of the pixels in the area is higher (that is, the grayscale value distribution of the pixels in the area is more discrete), the corresponding weight of the area is smaller; correspondingly, if the discrete degree of the grayscale values ​​of the pixels in the area is lower (that is, the grayscale value distribution of the pixels in the area is more concentrated), the corresponding weight of the area is larger.

[0079] It can be understood that, when the grayscale value distribution of the pixels in the region is relatively discrete, it can be considered that the importance of the pixels in the region is relatively low, and thus a relatively small weight can be assigned to the region.

[0080] As an implementation method, assuming K = 3, the discrete degree of the grayscale value of the pixels in the first area is represented by d1, the discrete degree of the grayscale value of the pixels in the second area is represented by d2, and the discrete degree of the grayscale value of the pixels in the third area is represented by d3. Then, the weight corresponding to the kth (k = 1, 2 or 3) area is As shown in formula (1):

[0081]

[0082] Among them, sum intra It can be calculated by formula (2):

[0083]

[0084] In some embodiments, the degree of difference between the grayscale values ​​of pixels in the region and the grayscale values ​​of pixels in other regions is positively correlated with the weight corresponding to the region.

[0085] That is to say, for a certain area among the K areas, the greater the difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas, the greater the weight corresponding to the area; correspondingly, the smaller the difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas, the smaller the weight corresponding to the area.

[0086] It can be understood that the greater the difference between the grayscale values ​​of pixels in the area and those in other areas, the higher the distinction between the area and other areas, and the more unique the overall feature representation is, so a higher weight can be assigned.

[0087] As an implementation method, assuming K = 3, the difference between the grayscale value of the pixel in the kth region and the grayscale value of the pixel in the ith region is expressed as D ki Indicates that the difference between the grayscale value of the pixel in the kth region and the grayscale value of the pixel in the jth region is expressed as D kj Indicates that the difference between the grayscale value of the pixel in the i-th region and the grayscale value of the pixel in the j-th region is expressed by D ij Indicates that, then, the weight corresponding to the kth region As shown in formula (3):

[0088]

[0089] Among them, sum inter =D ki +D kj +D ki +D ij +D kj +Dij , k = 1, 2 or 3. When k = 1, i and j may be, for example, equal to 2 and 3 respectively, when k = 2, i and j may be, for example, equal to 1 and 3 respectively, and when k = 3, i and j may be, for example, equal to 1 and 2 respectively.

[0090] It should be noted that, for the kth area among the K areas, if two or three factors from a) to c) are comprehensively considered to determine the weight corresponding to the kth area, then the weight obtained for each considered factor can be assigned a corresponding weight coefficient.

[0091] For example, if the factors a), b) and c) above are considered simultaneously when determining the weight corresponding to the kth region, then A weight coefficient α can be assigned to A weight coefficient β can be assigned to A weight coefficient γ can be assigned. Thus, the weight W corresponding to the kth region is k As shown in formula (4):

[0092]

[0093] In some embodiments, in order to determine the discrete degree of the grayscale values ​​of pixels in a region, the method may further include steps 21) to 23):

[0094] 21) Determine the average gray value of the pixels in the area.

[0095] 22) Determine the difference between each grayscale value of the pixel points in the area and the average grayscale value to obtain a set of first difference values.

[0096] For example, assuming that the average gray value of the pixels in the region is μ, then by calculating the difference between each gray value of the pixels in the region and μ, a set of first difference values ​​can be obtained, such as m1-μ, m2-μ, ..., m p -μ. Among them, m1, m2, ..., m p It represents the p different grayscale values ​​corresponding to the pixels in the area, that is, the p grayscale values ​​covered by the area.

[0097] 23) Based on the first difference, determine the degree of discreteness of the grayscale values ​​of the pixels in the area.

[0098] After the first difference is calculated, the discrete degree of the grayscale values ​​of the pixels in the area can be determined according to the first difference.

[0099] As an implementation method, the sum of squares of the first differences (denoted as d) may be calculated, for example, d = (m1-μ) 2 +(m2-μ) 2 +……+(mp -μ) 2 . The value of d can represent the degree of discreteness of the grayscale values ​​of the pixels in the region. For example, the larger the value of d, the greater the degree of discreteness of the grayscale values ​​of the pixels in the region; the smaller the value of d, the smaller the degree of discreteness of the grayscale values ​​of the pixels in the region.

[0100] In some embodiments, the process of calculating d can also be considered as the process of calculating the intra-class distance.

[0101] According to the method of this embodiment, the first difference value can be used to measure the discreteness of the grayscale values ​​of the pixels in the region, and then the weight corresponding to the region can be determined based on the discreteness of the grayscale values ​​of the pixels in the region.

[0102] It should be noted that the method of determining the discrete degree of the grayscale values ​​of the pixels in the region through the above steps 21) to 23) is only exemplary. For example, in some scenarios, the discrete degree of the grayscale values ​​of the pixels in the region can also be determined by other methods (such as calculating the variance or standard deviation of the grayscale values ​​in the region).

[0103] In some embodiments, in order to determine the difference between the grayscale values ​​of pixels in one area and the grayscale values ​​of pixels in other areas, the method may further include steps 31) and 32):

[0104] 31) Determine the difference between the average grayscale value of the pixels in the area and the average grayscale value of the pixels in other areas to obtain a second difference; and / or determine the difference between the standard deviation of the grayscale values ​​of the pixels in the area and the standard deviation of the grayscale values ​​of the pixels in other areas to obtain a third difference.

[0105] Taking K=3 as an example, assuming that this area is the first area among the K areas, and the average grayscale value of the pixels in this area is μ1; assuming that the average grayscale value of the pixels in the second area among the K areas is μ2, and the average grayscale value of the pixels in the third area is μ3, then the second difference (μ1-μ2) and (μ1-μ3) can be obtained.

[0106] Taking K=3 as an example, assuming that this area is the first area among the K areas, and the standard deviation of the grayscale values ​​of the pixels in this area is σ1; assuming that the standard deviation of the grayscale values ​​of the pixels in the second area among the K areas is σ2, and the standard deviation of the grayscale values ​​of the pixels in the third area is σ3, then the third difference (σ1-σ2) and (σ1-σ3) can be obtained.

[0107] 32) Based on the second difference and / or the third difference, determine the degree of difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas.

[0108] As an implementation method, the difference D between the grayscale value of the pixel in the area (the first area) and the grayscale value of the pixel in the second area 12 It can be expressed by formula (5):

[0109]

[0110] Among them, D 12 The larger the value of is, the greater the difference between the grayscale values ​​of the pixels in the first area and the grayscale values ​​of the pixels in the second area is. 12 The smaller the value is, the smaller the difference between the grayscale values ​​of the pixels in the first area and the grayscale values ​​of the pixels in the second area is.

[0111] Similarly, the difference between the grayscale value of the pixel in this area (the first area) and the grayscale value of the pixel in the third area is D 13 It can be expressed by formula (6):

[0112]

[0113] Among them, D 13 The larger the value of is, the greater the difference between the grayscale values ​​of the pixels in the first area and the grayscale values ​​of the pixels in the third area is. 13 The smaller the value is, the smaller the difference between the grayscale values ​​of the pixels in the first area and the grayscale values ​​of the pixels in the third area is.

[0114] In some embodiments, D is calculated 12 and D 13 The process can also be considered as the process of calculating the distance between classes.

[0115] According to the method of this embodiment, the second difference and / or the third difference can be used to measure the difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas, and then the weight corresponding to the area can be determined based on the difference.

[0116] It should be noted that the method of determining the difference between the grayscale values ​​of the pixels in the region and the grayscale values ​​of the pixels in other regions through the above steps 31) and 32) is only exemplary. For example, in some scenarios, the difference between the grayscale values ​​of the pixels in the region and the grayscale values ​​of the pixels in other regions can also be determined by other methods.

[0117] To facilitate understanding of the embodiments of the present application, a possible implementation process of the image processing method provided in the embodiments of the present application is introduced below.

[0118] Figure 2A schematic diagram of a possible implementation flow of the image processing method provided in an embodiment of the present application.

[0119] like Figure 2 As shown, the implementation process may include:

[0120] S201, read the image.

[0121] In this step, the input image information can be read from the sensor to prepare data information for the subsequent grayscale histogram calculation.

[0122] S202, calculating the grayscale histogram of the image.

[0123] By counting the number of times each gray value appears in the image, the gray histogram of the image can be obtained. In the gray histogram, the horizontal axis can represent the gray values ​​of the image, and the vertical axis can represent the number of times each gray value appears in the image, that is, the number of pixels corresponding to each gray value.

[0124] Exemplarily, it is assumed that the grayscale value range of the image is 0 to L-1, where L is the total number of grayscale values ​​(eg, for a 10-bit image, L=1024).

[0125] Assume n i represents the number of pixels with gray value i, so the gray histogram h(i) can be calculated according to formula (7):

[0126] h(i)=n i , i=0,1,…,L-1 (7)

[0127] S203, applying a histogram clustering algorithm.

[0128] In this step, a histogram clustering algorithm may be applied to cluster the grayscale histogram distribution obtained in S202, wherein each cluster represents a different grayscale interval in the grayscale histogram.

[0129] Figure 3 The following is a flow chart of a histogram clustering algorithm provided in an embodiment of the present application. Figure 3 As shown, the histogram clustering algorithm may include S301 to S306.

[0130] S301, reading the grayscale histogram of the image.

[0131] After the grayscale histogram of the image is prepared in S202 , the grayscale histogram may be read.

[0132] S302, determining the number of clusters.

[0133] As an implementation method, the K-means clustering algorithm can be used to divide the grayscale values ​​of the image into K clusters (referred to as clusters for short). Each cluster represents a grayscale interval (or brightness interval) in the image. For example, the grayscale histogram can be divided into three levels: dark, medium, and bright for adjustment, so K=3 can be set, that is, the number of clusters is 3.

[0134] It should be noted that the above number of clusters is 3 for example only, and the embodiment of the present application does not limit the number of clusters. For example, in some scenarios, it can be determined whether the number of clusters needs to be adjusted according to the clustering error index. For example, if the calculated clustering error is large, the number of clusters can be adjusted. Among them, the clustering error can be evaluated, for example, by the sum of squares of the intra-cluster errors.

[0135] It should also be noted that the use of the K-means clustering algorithm in this embodiment is only exemplary, and the present application embodiment does not limit the clustering algorithm used. For example, a threshold-based clustering method, hierarchical clustering, and fuzzy C-means clustering methods may also be used.

[0136] S303, initializing cluster centers.

[0137] For example, a random initialization method may be used to select three grayscale values ​​representing dark, medium, and bright areas from the L grayscale values ​​(respectively denoted as l lower , l normal , l higher ) as the initial cluster center.

[0138] S304, assigning gray values ​​in the gray histogram to clusters.

[0139] In this step, each grayscale value (data point) in the grayscale histogram can be assigned to a corresponding cluster.

[0140] As an implementation method, the Euclidean distance from each grayscale value in the grayscale histogram to the K cluster centers may be calculated, and clustering may be performed based on the calculated Euclidean distance.

[0141] The Euclidean distance formula is shown in formula (8), where d represents the Euclidean distance between x and c. In this embodiment, x represents the gray value, and c represents the cluster center.

[0142]

[0143] In one-dimensional histogram calculation, formula (8) can be simplified to the form of formula (9).

[0144] |xc|(9)

[0145] As an example, assuming that the grayscale values ​​corresponding to the three current cluster centers are 500, 750, and 1050, respectively, then for a data point with a grayscale value of 600 in the grayscale histogram, according to formula (9), the Euclidean distances from the data point to the three cluster centers can be calculated to be |600-500|=100, |600-750|=150, and |600-1050|=450, respectively.

[0146] Furthermore, each data point (grayscale value) can be assigned to the cluster with the closest cluster center according to the calculated Euclidean distance. For example, according to the above calculation results, the data point with a grayscale value of 600 is closest to the cluster center 500, so the data point (grayscale value) can be assigned to the cluster corresponding to the cluster center 500.

[0147] By performing such an operation on all data points (grayscale values) in the grayscale histogram, a round of assignment of data points (grayscale values) to clusters can be completed.

[0148] S305, update the cluster center.

[0149] After completing a round of assignment of data points (grayscale values) to clusters, the cluster center of each cluster can be recalculated.

[0150] As an implementation method, the average value of all data points (grayscale values) in the cluster can be calculated as the new cluster center. For example, a cluster contains grayscale values ​​20, 25, 30, and 35, then the new cluster center is the average value of the grayscale values ​​in the cluster, that is, (20+25+30+35) / 4.

[0151] By updating the cluster center of each cluster in the above manner, the cluster center can better represent the overall characteristics of the data points in the cluster.

[0152] S306, stop iteration after the condition is met.

[0153] In this embodiment, steps S304 and S305 may be repeated until a certain condition is met (eg, the cluster center no longer changes significantly), and then the iteration is stopped.

[0154] As an implementation method, if the difference between the cluster centers obtained in the previous and next two iterations is less than a preset threshold, the iteration can be stopped. For example, assuming that the preset threshold is 20, then if the difference between the current iteration and the previous iteration of all cluster centers is less than 20, it can be considered that the clustering has converged, in which case the iteration can be stopped.

[0155] Through the above iterative process, the clustering results can be gradually stabilized, and finally a relatively good clustering division is obtained, and the grayscale histogram data of the image is divided into K different clusters according to the set K value, and each cluster represents a group of data points with similar grayscale features (grayscale values ​​and their corresponding pixels). In other words, each cluster can correspond to a set of pixels in the image with similar grayscale features.

[0156] S204: Allocate weights according to the clustering results.

[0157] After obtaining the clustering results, the weight based on the number of bins, the weight based on the intra-class distance, and the weight based on the inter-class distance can be calculated respectively, and then the weight of the gray value assigned to the cluster can be comprehensively evaluated by these three weights.

[0158] Wherein, bin refers to the interval for dividing the data range, and the number of bins determines how many intervals the histogram divides the data into. In this embodiment, since the grayscale histogram divides the grayscale value into 1024 intervals, each interval corresponds to a grayscale value, the total number of bins is 1024.

[0159] For example, in order to obtain the weight based on the number of bins, we can first count the number of bins l1, l2, and l3 contained in the three clusters. Among them, l1, l2, and l3 can also be understood as the number of gray values ​​contained in the three clusters. For example, l1 represents the number of gray values ​​contained in the first cluster, l2 represents the number of gray values ​​contained in the second cluster, and l3 represents the number of gray values ​​contained in the third cluster. In this way, the sum of the number of bins in the three clusters is sum bin =l1+l2+l3, then the weights of the three clusters based on the number of bins are:

[0160]

[0161] For example, in order to obtain the weight based on the intra-class distance, the intra-class distance of each cluster can be calculated, that is, the distance measure between the pixel information related to the grayscale value covered by the corresponding bin. Among them, the intra-class distance reflects the compactness or discreteness of the grayscale values ​​of the pixels in the cluster. The smaller the intra-class distance, the more similar the grayscale values ​​of the pixels in the cluster are and the more concentrated the distribution is. The commonly used method for calculating the intra-class distance is to calculate the sum of the squares of the difference between the mean grayscale value of each bin in the cluster and the grayscale value in each bin.

[0162] Assume that the calculated intra-class distances of the three clusters are d1, d2, and d3 respectively. Here, we can first take the inverse of the intra-class distances, that is, 1 / d1, 1 / d2, and 1 / d3, and then the sum of the distances is as shown in formula (10):

[0163]

[0164] Therefore, the intra-class distance weights of the three clusters are shown in formulas (11), (12) and (13) respectively:

[0165]

[0166] Similarly, the inter-class distance (or inter-cluster distance) can also be used to measure the degree of difference between different clusters. The larger the inter-class distance, the more distinguishable the cluster is from other clusters, and the more unique it is in the overall feature representation, so it can be given a higher weight.

[0167] When calculating the weight based on the inter-class distance, the inter-class distance needs to be calculated first. Here, the average grayscale values ​​μ1, μ2, μ3 and the standard deviations σ1, σ2, σ3 of the grayscale values ​​in the three clusters need to be calculated. Furthermore, the inter-class distances of the three clusters can be calculated using the Euclidean distance.

[0168] Among them, the inter-class distance between cluster 1 and cluster 2 is shown in formula (14):

[0169]

[0170] The inter-class distance between cluster 1 and cluster 3 is shown in formula (15):

[0171]

[0172] The inter-class distance between cluster 2 and cluster 3 is shown in formula (16):

[0173]

[0174] In this way, the inter-class distance between cluster 1 and other clusters can be expressed as: D 12 +D 13 ; The inter-class distance between cluster 2 and other clusters can be expressed as: D 12 +D 23 ; The inter-class distance between cluster 3 and other clusters can be expressed as: D 13 +D 23 . After summing, we get: sum inter =D 12 +D 13 +D 12 +D 23 +D 13 +D 23 Therefore, the inter-class distance weights of the three clusters are shown in formulas (17), (18) and (19), respectively:

[0175]

[0176] Furthermore, the weights calculated based on the number of bins, intra-class distance, and inter-class distance can be combined. As an example, the weight coefficient α based on the number of bins can be set to 0.4, the weight coefficient β based on the intra-class distance can be set to 0.3, and the weight coefficient γ based on the inter-class distance can be set to 0.3. Thus, the final weights of the three clusters are shown in formulas (20), (21), and (22), respectively:

[0177]

[0178] S205, adjusting the image brightness.

[0179] In this step, the grayscale values ​​classified into the cluster may be recalculated according to the cluster weight calculated in S204 to achieve the purpose of grayscale adjustment (ie, brightness adjustment).

[0180] As an implementation method, the grayscale value of each pixel in the image can be traversed. If the grayscale value of a pixel belongs to cluster 1, the grayscale value of the pixel can be multiplied by W1; if the grayscale value of a pixel belongs to cluster 2, the grayscale value of the pixel can be multiplied by W2; if the grayscale value of a pixel belongs to cluster 3, the grayscale value of the pixel can be multiplied by W3. In this way, the brightness of the image can be adjusted to improve the contrast and detail performance of the image.

[0181] According to the method of this embodiment, the grayscale values ​​of the image can be divided into different clusters by clustering, and each cluster corresponds to a specific area in the image or a set of pixels with similar features.

[0182] This method uses clustering as the basis for statistical analysis and constructs a brightness adjustment scheme. The clustering algorithm can group and balance the grayscale values ​​of the image more specifically, so that the adjusted image is often more natural and smooth in visual effect. This scheme can make the entire brightness adjustment process adaptive and have better local adaptability to image brightness adjustment.

[0183] Furthermore, different from the traditional method of determining the intensity of image brightness adjustment based on a single factor (such as a simple average gray value, number of pixels, etc.), the method of this embodiment combines the features of three different dimensions, namely the number of bins, intra-class distance and inter-class distance, to calculate the weight corresponding to each cluster.

[0184] By considering factors such as the number of bins, intra-class distance and inter-class distance, we not only focus on the grayscale value of the pixel itself, but also further consider the relationship between image pixels and different regions, understand the relative position and correlation of each cluster in the overall image, and thus grasp the coordination of the image from a more macro perspective when adjusting the brightness.

[0185] In addition, by adjusting the brightness after calculating weights based on the number of bins, intra-class distance and inter-class distance, it is possible to accurately adjust the brightness according to the different characteristics of each cluster, thereby achieving targeted optimization of different areas of the image, avoiding the "one-size-fits-all" approach of traditional global brightness adjustment methods that causes detail loss or overexposure in some areas.

[0186] Among them, the number of bins reflects the coverage of each cluster in terms of grayscale values, the intra-class distance reflects the discrete degree of the grayscale values ​​of pixels within the cluster, and the inter-class distance represents the degree of difference between different clusters. These factors are combined to calculate the weight and adjust the brightness, taking full account of the characteristic distribution of the image itself. Appropriate brightness adjustment is made according to the distribution law of the image pixel features, which is more in line with the actual image, can better restore the original visual effect of the image, and retain the unique texture and detail information of the image.

[0187] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the idea of ​​the present application, they should also be regarded as the contents disclosed in the present application. For another example, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in the present application can be arbitrarily combined with the prior art, and the technical solution obtained after the combination should also fall within the protection scope of the present application.

[0188] Based on the above embodiments, the embodiments of the present application provide a corresponding image processing device. The device includes the modules included, and the submodules included in each module, which can be implemented by a processor in a computer device with information processing capabilities; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0189] The present application embodiment provides an image processing device. Figure 4 As shown, the image processing device 400 may include:

[0190] The acquisition unit 410 is used to acquire the image to be processed; the division unit 420 is used to divide the image into K areas according to the grayscale values ​​of the pixels in the image; the adjustment unit 430 is used to adjust the grayscale values ​​of the K areas based on the weights corresponding to the K areas to obtain the target image; wherein K is an integer greater than 1.

[0191] In some embodiments, the image processing device 400 also includes a first determination unit, which is used to: for each of the K regions, determine the weight corresponding to the region based on at least one of the following: the number of grayscale values ​​of pixels in the region; the degree of discreteness of the grayscale values ​​of the pixels in the region; the degree of difference between the grayscale values ​​of the pixels in the region and the grayscale values ​​of the pixels in other regions.

[0192] In some embodiments, the number of grayscale values ​​of pixels in the area is positively correlated with the weight corresponding to the area; the discreteness of the grayscale values ​​of pixels in the area is negatively correlated with the weight corresponding to the area; the difference between the grayscale values ​​of pixels in the area and the grayscale values ​​of pixels in other areas is positively correlated with the weight corresponding to the area.

[0193] In some embodiments, the image processing device 400 also includes a second determination unit, which is used to: determine the average grayscale value of the pixels within the area; determine the difference between each grayscale value of the pixels within the area and the average grayscale value to obtain a set of first difference values; based on the first difference values, determine the degree of discreteness of the grayscale values ​​of the pixels within the area.

[0194] In some embodiments, the image processing device 400 also includes a third determination unit, which is used to: determine the difference between the average grayscale value of the pixels in the area and the average grayscale value of the pixels in other areas to obtain a second difference; and / or determine the difference between the standard deviation of the grayscale values ​​of the pixels in the area and the standard deviation of the grayscale values ​​of the pixels in other areas to obtain a third difference; based on the second difference and / or the third difference, determine the degree of difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas.

[0195] In some embodiments, the division unit 420 is specifically used to: use a clustering algorithm to divide the grayscale values ​​of pixels in the image into K categories; and divide the pixels in the image into K regions according to the category to which the grayscale value of each pixel in the image belongs.

[0196] In some embodiments, the adjustment unit 430 is specifically used to: multiply the weights corresponding to the K regions by the grayscale values ​​of the pixels contained in the K regions to obtain the target image.

[0197] 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. In some embodiments, the functions or modules / units included in the device provided in the embodiment of the present application can be used to execute the method described in the above 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.

[0198] 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 is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) 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 disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0199] An embodiment of the present application also provides an image processing device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0200] The embodiment of the present application further provides a chip, which includes: a processor, which is used to call and run a computer program from a memory, so that a device equipped with the chip executes some or all of the steps in the above method.

[0201] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0202] An embodiment of the present application also provides a computer program, including a computer-readable code. When the computer-readable code runs in a device, a processor in the device executes part or all of the steps in the above method.

[0203] The present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0204] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, chip, storage medium, computer program and computer program product embodiments 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 embodiments of the device, chip, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0205] The present application embodiment provides an image processing device. Figure 5 As shown, the image processing device 500 (hereinafter referred to as the device 500) includes a processor 510, and the processor 510 can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0206] In some embodiments, Figure 5 As shown, the device 500 may further include a memory 520. The processor 510 may call and run a computer program from the memory 520 to implement the method in the embodiment of the present application. The memory 520 may be a separate device independent of the processor 510, or may be integrated in the processor 510.

[0207] In some embodiments, Figure 5 As shown, the device 500 may also include a transceiver 530, and the processor 510 may control the transceiver 530 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 530 may include a transmitter and a receiver. The transceiver 530 may further include an antenna, and the number of antennas may be one or more.

[0208] It should be understood that "one embodiment", "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", "in an 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 serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / 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 serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0209] 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.

[0210] 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 device embodiments described above are only schematic. For example, the division of the units or modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple units 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 the devices or units can be electrical, mechanical or other forms.

[0211] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0212] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0213] 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.

[0214] 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 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, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) 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.

[0215] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the 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.

Claims

1. An image processing method, characterized in that: The method comprises: Get the image to be processed; Dividing the image into K regions according to the grayscale values ​​of pixels in the image; Based on the weights corresponding to the K regions, the grayscale values ​​of the K regions are adjusted to obtain a target image; wherein K is an integer greater than 1.

2. The method according to claim 1, characterized in that The method further comprises: For each of the K regions, a weight corresponding to the region is determined based on at least one of the following: The number of grayscale values ​​of pixels in the area; The degree of discreteness of the grayscale values ​​of the pixels in the region; The degree of difference between the grayscale values ​​of the pixels in the region and the grayscale values ​​of the pixels in other regions.

3. The method according to claim 2, characterized in that The number of gray values ​​of pixels in the region is positively correlated with the weight corresponding to the region; The discreteness of the grayscale values ​​of the pixels in the region is negatively correlated with the weight corresponding to the region; The degree of difference between the grayscale values ​​of the pixels in the region and the grayscale values ​​of the pixels in other regions is positively correlated with the weight corresponding to the region.

4. The method according to claim 2 or 3, characterized in that: The method further comprises: Determine the average gray value of pixels in the area; Determine the difference between each grayscale value of the pixel points in the area and the average grayscale value to obtain a set of first difference values; Based on the first difference, a discrete degree of grayscale values ​​of pixels in the area is determined.

5. The method according to claim 2 or 3, characterized in that: The method further comprises: Determine the difference between the average grayscale value of the pixels in the region and the average grayscale value of the pixels in other regions to obtain a second difference; and / or determine the difference between the standard deviation of the grayscale values ​​of the pixels in the region and the standard deviation of the grayscale values ​​of the pixels in other regions to obtain a third difference; Based on the second difference and / or the third difference, the difference between the grayscale values ​​of the pixels in the area and the grayscale values ​​of the pixels in other areas is determined.

6. The method according to any one of claims 1 to 3, characterized in that The step of dividing the image into K regions according to the grayscale values ​​of pixels in the image comprises: Using a clustering algorithm, the grayscale values ​​of pixels in the image are divided into K categories; The pixels in the image are divided into K regions according to the class to which the grayscale value of each pixel in the image belongs.

7. The method according to any one of claims 1 to 3, characterized in that The step of adjusting the grayscale values ​​of the K regions based on the weights corresponding to the K regions to obtain the target image includes: The target image is obtained by multiplying the weights corresponding to the K regions by the grayscale values ​​of the pixels contained in the K regions.

8. An image processing device, characterized in that: The device comprises: An acquisition unit, used for acquiring an image to be processed; A division unit, used for dividing the image into K regions according to the grayscale values ​​of the pixels in the image; An adjustment unit is used to adjust the grayscale values ​​of each of the K regions based on the weights corresponding to each of the K regions to obtain a target image; wherein K is an integer greater than 1.

9. An image processing device, characterized in that: The device comprises: A memory for storing computer executable instructions; A processor, connected to the memory, configured to implement the method according to any one of claims 1 to 7 by executing the computer executable instructions.

10. A chip, characterized in that: The chip comprises: A processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes the method according to any one of claims 1 to 7.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the method according to any one of claims 1 to 7 is implemented.

12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method according to any one of claims 1 to 7 is implemented.