Image contrast determination method, device, equipment and storage medium
By obtaining the grayscale value, hue value and brightness value of the target image, determining the brightness parameter and color parameter, and performing weighted summation in combination with the weight of the distribution parameter, the problem of low contrast accuracy in the existing technology is solved, and a more accurate and comprehensive contrast determination is achieved.
Patent Information
- Application Number
- CN202510941838.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-07-09
AI Technical Summary
The existing technology considers relatively few factors when determining image contrast, resulting in low contrast accuracy.
By obtaining the grayscale value, hue value and brightness value of each pixel in the target image, determining the brightness parameter, color parameter and distribution parameter, and combining the weights of these parameters for weighted summation, the contrast of the image is comprehensively determined.
The accuracy and comprehensiveness of determining image contrast are improved, and the visual effect of the image can be better reflected.
Smart Images

Figure CN120451028B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for determining image contrast. Background Art
[0002] Image contrast has a significant impact on both visual and application effects. For example, when training large image models, image contrast directly impacts the training results. Therefore, it's crucial to determine image contrast.
[0003] In related technologies, when determining the contrast of an image, the number of pixels of different gray levels in the image is generally counted, and the contrast is determined based on the distribution of pixels at different gray levels in the image. However, this method considers relatively few factors when determining the contrast, resulting in low accuracy of the determined contrast. Summary of the Invention
[0004] The present disclosure provides a method, apparatus, device, and storage medium for determining image contrast. The technical solution of the present disclosure is as follows.
[0005] According to one aspect of an embodiment of the present disclosure, a method for determining image contrast is provided, the method comprising:
[0006] Get the grayscale value, hue value, saturation value and brightness value of each pixel in the target image;
[0007] Determining a brightness parameter based on the grayscale value of each pixel in the target image, wherein the brightness parameter is used to represent the degree of brightness change of the target image in the grayscale space;
[0008] Determining a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image, wherein the color parameter is used to represent the degree of color change of the target image, and the distribution parameter is used to represent the distribution of multiple hues in the target image;
[0009] The contrast of the target image is determined based on the brightness parameter, the color parameter, and the distribution parameter.
[0010] In some embodiments, determining the contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter includes:
[0011] Based on the target image, determining weights corresponding to the brightness parameter, the color parameter, and the distribution parameter;
[0012] Based on the weights corresponding to the brightness parameter, the color parameter and the distribution parameter, the brightness parameter, the color parameter and the distribution parameter are weightedly summed to obtain the contrast of the target image.
[0013] In some embodiments, determining the weights corresponding to the brightness parameter, the color parameter, and the distribution parameter based on the target image includes:
[0014] Determining the perceived saturation of the target image based on the brightness value and saturation value of each pixel in the target image;
[0015] Based on the perceived saturation and the corresponding relationships between the weights of the brightness parameter, the color parameter, and the distribution parameter and the perceived saturation, the weights corresponding to the brightness parameter, the color parameter, and the distribution parameter are determined.
[0016] In some embodiments, the brightness parameter includes a first sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes:
[0017] Determining a grayscale standard deviation based on the grayscale value of each pixel in the target image, wherein the grayscale standard deviation is the standard deviation between the grayscale values of each pixel;
[0018] The first sub-parameter is determined based on the grayscale standard deviation, and the first sub-parameter is positively correlated with the grayscale standard deviation.
[0019] In some embodiments, the brightness parameter includes a second sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes:
[0020] Dividing the target image into a plurality of blocks;
[0021] For each image block, determining a modulation contrast of the image block based on the grayscale values of each pixel in the image block, wherein the modulation contrast is used to represent a difference between a maximum grayscale value and a minimum grayscale value among the grayscale values of each pixel in the image;
[0022] The second sub-parameter is determined based on the modulation contrast of each of the plurality of image blocks, and the second sub-parameter is positively correlated with the modulation contrast of each of the plurality of image blocks.
[0023] In some embodiments, the method further comprises:
[0024] Based on the grayscale value of each pixel in the image block, the pixel is divided into a plurality of grayscale value intervals, and the plurality of grayscale value intervals are obtained by dividing the grayscale value range;
[0025] determining a first ratio based on a ratio between the number of pixels in a grayscale value interval having the largest number of pixels and the number of pixels in the image block, wherein the first ratio is positively correlated with the ratio;
[0026] The pixels in the image block are sorted based on their grayscale values, and based on the first ratio, the pixels in the image block that are sorted in the front and the pixels in the back of the image block that are sorted in the first ratio are removed, and the modulation contrast of the image block is determined based on the grayscale values of the remaining pixels in the image block.
[0027] In some embodiments, the brightness parameter includes a third sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes:
[0028] Dividing the target image into a plurality of blocks;
[0029] For each image block, determining a grayscale standard deviation corresponding to the image block based on the grayscale values of each pixel in the image block, where the grayscale standard deviation is the standard deviation between the grayscale values of each pixel in the image block;
[0030] The third sub-parameter is determined based on a maximum value and an average value of grayscale standard deviations corresponding to each of the plurality of image blocks, where the third sub-parameter is positively correlated with the maximum value and negatively correlated with the average value.
[0031] In some embodiments, the color parameter includes a fourth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes:
[0032] Determine a plurality of target pixels in the target image, wherein a saturation value of each target pixel reaches a first threshold value and a brightness value reaches a second threshold value;
[0033] Determining a hue standard deviation between the plurality of target pixel points based on the hue values of the plurality of target pixel points, the hue standard deviation being a standard deviation between the chromaticity values of the plurality of target pixel points;
[0034] The fourth sub-parameter is determined based on a ratio between the number of the plurality of target pixels and the number of pixels in the target image and the hue standard deviation, and the fourth sub-parameter is positively correlated with the ratio and the hue standard deviation.
[0035] In some embodiments, the color parameter includes a fifth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes:
[0036] Determining a saturation standard deviation based on the saturation value of each pixel in the target image, where the saturation standard deviation is a standard deviation between the saturation values of each pixel;
[0037] The fifth sub-parameter is determined based on the saturation standard deviation, and the fifth sub-parameter is positively correlated with the saturation standard deviation.
[0038] In some embodiments, the color parameter includes a sixth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes:
[0039] Based on a preset step size, traverse the pixel points in the target image, and for each traversed pixel point, perform the following steps to obtain the average saturation value of the area corresponding to the pixel point: determine an area with the pixel point as the center and a preset length as the radius, and determine the average saturation value of the area based on the saturation values of each pixel point in the area;
[0040] Based on the saturation threshold, multiple target areas are determined from the areas corresponding to the traversed pixel points, where the target areas are areas where the average saturation value reaches the saturation threshold;
[0041] Based on the number of the plurality of target areas, a sixth sub-parameter is determined, the sixth sub-parameter being positively correlated with the number.
[0042] In some embodiments, determining the distribution parameters based on the hue value, saturation value, and brightness value of each pixel in the target image includes:
[0043] Based on a first brightness threshold, a second brightness threshold, and a third brightness threshold, a plurality of first connected domains, a plurality of second connected domains, and a plurality of third connected domains on the target image are respectively determined, wherein the first brightness threshold, the second brightness threshold, and the third brightness threshold decrease in sequence, the pixels in the first connected domain are adjacent and the brightness values are all greater than the first brightness threshold, the pixels in the second connected domain are adjacent and the difference between the brightness value and the second brightness threshold is all less than the difference threshold, and the pixels in the third connected domain are adjacent and the brightness values are all less than the third brightness threshold;
[0044] Determining, based on the plurality of first connected domains, the plurality of second connected domains, and the plurality of third connected domains, a first connectivity value, a second connectivity value, and a third connectivity value, wherein the first connectivity value is used to represent a distribution difference between the plurality of first connected domains and the plurality of second connected domains, the second connectivity value is used to represent a distribution difference between the plurality of second connected domains and the plurality of third connected domains, and the third connectivity value is used to represent a distribution difference between the plurality of first connected domains and the plurality of third connected domains;
[0045] Based on the first connectivity value, the second connectivity value, and the third connectivity value, the distribution parameter is determined, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value, and the third connectivity value.
[0046] In some embodiments, determining the first connectivity value, the second connectivity value, and the third connectivity value based on the plurality of first connected domains, the plurality of second connected domains, and the plurality of third connected domains includes:
[0047] Determining weights corresponding to the respective pixels based on the distances between the respective pixels on the target image and the center point of the target image, wherein the weight corresponding to each pixel is negatively correlated with the corresponding distance;
[0048] weighting the areas of the pixels based on the weights corresponding to the pixels to obtain weighted areas of the pixels;
[0049] For each connected domain, determining a connected area of the connected domain based on the weighted areas of the pixels in the connected domain;
[0050] The first connectivity value, the second connectivity value, and the third connectivity value are determined based on the connectivity areas of the plurality of first connected domains, the connectivity areas of the plurality of second connected domains, and the connectivity areas of the plurality of third connected domains.
[0051] In some embodiments, determining the distribution parameter based on the first connectivity value, the second connectivity value, and the third connectivity value includes:
[0052] determining, based on a fourth brightness threshold, a plurality of fourth connected domains on the target image, wherein pixels in the fourth connected domains are adjacent and have brightness values greater than the fourth brightness threshold, and the fourth brightness threshold is greater than the first brightness threshold;
[0053] Determine a plurality of target connected domains from the plurality of fourth connected domains, wherein the areas of the target connected domains satisfy a first condition and the shapes satisfy a second condition;
[0054] Determining, from the plurality of target connected domains, a plurality of connected domains whose overlap ratio with an edge region in the target image reaches a second ratio, wherein the edge region indicates a boundary of an object in the target image;
[0055] determining a fourth connectivity value based on a ratio between the number of pixels in the plurality of connected domains and the number of pixels in the target image, wherein the fourth connectivity value is positively correlated with the ratio;
[0056] The distribution parameter is determined based on the first connectivity value, the second connectivity value, the third connectivity value, and the fourth connectivity value, the distribution parameter being positively correlated with the fourth connectivity value.
[0057] According to another aspect of an embodiment of the present disclosure, a device for determining image contrast is provided, the device comprising:
[0058] An acquisition unit is configured to acquire the grayscale value, hue value, saturation value and brightness value of each pixel in the target image;
[0059] a determining unit configured to determine a brightness parameter based on the grayscale value of each pixel in the target image, wherein the brightness parameter is used to represent a degree of brightness change of the target image in a grayscale space;
[0060] The determining unit is further configured to determine a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image, wherein the color parameter is used to represent the degree of color change of the target image, and the distribution parameter is used to represent the distribution of multiple hues in the target image;
[0061] The determining unit is further configured to determine the contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter.
[0062] In some embodiments, the determining unit is configured to execute:
[0063] Based on the target image, determining weights corresponding to the brightness parameter, the color parameter, and the distribution parameter;
[0064] Based on the weights corresponding to the brightness parameter, the color parameter and the distribution parameter, the brightness parameter, the color parameter and the distribution parameter are weightedly summed to obtain the contrast of the target image.
[0065] In some embodiments, the determining unit is configured to execute:
[0066] Determining the perceived saturation of the target image based on the brightness value and saturation value of each pixel in the target image;
[0067] Based on the perceived saturation and the corresponding relationships between the weights of the brightness parameter, the color parameter, and the distribution parameter and the perceived saturation, the weights corresponding to the brightness parameter, the color parameter, and the distribution parameter are determined.
[0068] In some embodiments, the brightness parameter includes a first sub-parameter, and the determining unit is configured to perform:
[0069] Determining a grayscale standard deviation based on the grayscale value of each pixel in the target image, wherein the grayscale standard deviation is the standard deviation between the grayscale values of each pixel;
[0070] The first sub-parameter is determined based on the grayscale standard deviation, and the first sub-parameter is positively correlated with the grayscale standard deviation.
[0071] In some embodiments, the brightness parameter includes a second sub-parameter, and the determining unit is configured to perform:
[0072] Dividing the target image into a plurality of blocks;
[0073] For each image block, determining a modulation contrast of the image block based on the grayscale values of each pixel in the image block, wherein the modulation contrast is used to represent a difference between a maximum grayscale value and a minimum grayscale value among the grayscale values of each pixel in the image;
[0074] The second sub-parameter is determined based on the modulation contrast of each of the plurality of image blocks, and the second sub-parameter is positively correlated with the modulation contrast of each of the plurality of image blocks.
[0075] In some embodiments, the apparatus further comprises:
[0076] a dividing unit configured to divide each pixel point in the image block into a plurality of grayscale value intervals based on the grayscale value of each pixel point, wherein the plurality of grayscale value intervals are obtained by dividing the grayscale value range;
[0077] The determining unit is further configured to determine a first ratio based on a ratio between the number of pixels in a grayscale value interval having the largest number of pixels and the number of pixels in the image block, wherein the first ratio is positively correlated with the ratio;
[0078] The determination unit is further configured to sort the pixels in the image block based on their grayscale values, remove the pixels in the image block that are sorted in the first proportion and the pixels in the image block that are sorted in the last proportion based on the first proportion, and determine the modulation contrast of the image block based on the grayscale values of the remaining pixels in the image block.
[0079] In some embodiments, the brightness parameter includes a third sub-parameter, and the determining unit is further configured to execute:
[0080] Dividing the target image into a plurality of blocks;
[0081] For each image block, determining a grayscale standard deviation corresponding to the image block based on the grayscale values of each pixel in the image block, where the grayscale standard deviation is the standard deviation between the grayscale values of each pixel in the image block;
[0082] The third sub-parameter is determined based on a maximum value and an average value of grayscale standard deviations corresponding to each of the plurality of image blocks, where the third sub-parameter is positively correlated with the maximum value and negatively correlated with the average value.
[0083] In some embodiments, the color parameter includes a fourth sub-parameter, and the determining unit is further configured to perform:
[0084] Determine a plurality of target pixels in the target image, wherein a saturation value of each target pixel reaches a first threshold value and a brightness value reaches a second threshold value;
[0085] Determining a hue standard deviation between the plurality of target pixel points based on the hue values of the plurality of target pixel points, the hue standard deviation being a standard deviation between the chromaticity values of the plurality of target pixel points;
[0086] The fourth sub-parameter is determined based on a ratio between the number of the plurality of target pixels and the number of pixels in the target image and the hue standard deviation, and the fourth sub-parameter is positively correlated with the ratio and the hue standard deviation.
[0087] In some embodiments, the color parameter includes a fifth sub-parameter, and the determining unit is further configured to perform:
[0088] Determining a saturation standard deviation based on the saturation value of each pixel in the target image, where the saturation standard deviation is a standard deviation between the saturation values of each pixel;
[0089] The fifth sub-parameter is determined based on the saturation standard deviation, and the fifth sub-parameter is positively correlated with the saturation standard deviation.
[0090] In some embodiments, the color parameter includes a sixth sub-parameter, and the determining unit is further configured to perform:
[0091] Based on a preset step size, traverse the pixel points in the target image, and for each traversed pixel point, perform the following steps to obtain the average saturation value of the area corresponding to the pixel point: determine an area with the pixel point as the center and a preset length as the radius, and determine the average saturation value of the area based on the saturation values of each pixel point in the area;
[0092] Based on the saturation threshold, multiple target areas are determined from the areas corresponding to the traversed pixel points, where the target areas are areas where the average saturation value reaches the saturation threshold;
[0093] Based on the number of the plurality of target areas, a sixth sub-parameter is determined, the sixth sub-parameter being positively correlated with the number.
[0094] In some embodiments, the determining unit is further configured to execute:
[0095] Based on a first brightness threshold, a second brightness threshold, and a third brightness threshold, a plurality of first connected domains, a plurality of second connected domains, and a plurality of third connected domains on the target image are respectively determined, wherein the first brightness threshold, the second brightness threshold, and the third brightness threshold decrease in sequence, the pixels in the first connected domain are adjacent and the brightness values are all greater than the first brightness threshold, the pixels in the second connected domain are adjacent and the difference between the brightness value and the second brightness threshold is all less than the difference threshold, and the pixels in the third connected domain are adjacent and the brightness values are all less than the third brightness threshold;
[0096] Determining, based on the plurality of first connected domains, the plurality of second connected domains, and the plurality of third connected domains, a first connectivity value, a second connectivity value, and a third connectivity value, wherein the first connectivity value is used to represent a distribution difference between the plurality of first connected domains and the plurality of second connected domains, the second connectivity value is used to represent a distribution difference between the plurality of second connected domains and the plurality of third connected domains, and the third connectivity value is used to represent a distribution difference between the plurality of first connected domains and the plurality of third connected domains;
[0097] Based on the first connectivity value, the second connectivity value, and the third connectivity value, the distribution parameter is determined, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value, and the third connectivity value.
[0098] In some embodiments, the determining unit is further configured to execute:
[0099] Determining weights corresponding to the respective pixels based on the distances between the respective pixels on the target image and the center point of the target image, wherein the weight corresponding to each pixel is negatively correlated with the corresponding distance;
[0100] weighting the areas of the pixels based on the weights corresponding to the pixels to obtain weighted areas of the pixels;
[0101] For each connected domain, determining a connected area of the connected domain based on the weighted areas of the pixels in the connected domain;
[0102] The first connectivity value, the second connectivity value, and the third connectivity value are determined based on the connectivity areas of the plurality of first connected domains, the connectivity areas of the plurality of second connected domains, and the connectivity areas of the plurality of third connected domains.
[0103] In some embodiments, the determining unit is further configured to execute:
[0104] determining, based on a fourth brightness threshold, a plurality of fourth connected domains on the target image, wherein pixels in the fourth connected domains are adjacent and have brightness values greater than the fourth brightness threshold, and the fourth brightness threshold is greater than the first brightness threshold;
[0105] Determine a plurality of target connected domains from the plurality of fourth connected domains, wherein the areas of the target connected domains satisfy a first condition and the shapes satisfy a second condition;
[0106] Determining, from the plurality of target connected domains, a plurality of connected domains whose overlap ratio with an edge region in the target image reaches a second ratio, wherein the edge region indicates a boundary of an object in the target image;
[0107] determining a fourth connectivity value based on a ratio between the number of pixels in the plurality of connected domains and the number of pixels in the target image, wherein the fourth connectivity value is positively correlated with the ratio;
[0108] The distribution parameter is determined based on the first connectivity value, the second connectivity value, the third connectivity value, and the fourth connectivity value, the distribution parameter being positively correlated with the fourth connectivity value.
[0109] According to another aspect of an embodiment of the present disclosure, an electronic device is provided, the electronic device including:
[0110] processor;
[0111] a memory for storing instructions executable by the processor;
[0112] The processor is configured to execute the instructions to implement the above-mentioned method for determining image contrast.
[0113] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the above-mentioned method for determining image contrast.
[0114] According to another aspect of an embodiment of the present disclosure, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the computer program implements the above-mentioned method for determining image contrast.
[0115] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0116] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0117] Figure 1 It is a schematic diagram showing an implementation environment according to an exemplary embodiment.
[0118] Figure 2 The figure is a flow chart showing a method for determining image contrast according to an exemplary embodiment.
[0119] Figure 3 The figure is a flow chart showing another method for determining image contrast according to an exemplary embodiment.
[0120] Figure 4 is a flowchart of yet another method for determining image contrast according to an exemplary embodiment.
[0121] Figure 5 The figure is a block diagram of a device for determining image contrast according to an exemplary embodiment.
[0122] Figure 6 It is a block diagram of a terminal according to an exemplary embodiment.
[0123] Figure 7 The figure is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0124] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0125] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0126] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, storage, and display, etc.), and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the images involved in this disclosure were obtained with full authorization.
[0127] The method for determining image contrast provided by the embodiment of the present disclosure can be executed by an electronic device, and the electronic device can be provided as at least one of a terminal and a server. Figure 1 This is a schematic diagram of an implementation environment provided by the embodiment of the present disclosure, see Figure 1 , the implementation environment includes: a terminal 101 and a server 102.
[0128] In an embodiment of the present disclosure, the terminal 101 is used to input a target image. The server 102 is used to process the target image to obtain the contrast of the target image. In some embodiments, the server 102 obtains the grayscale value, hue value, saturation value, and brightness value of each pixel in the target image, and determines the brightness parameters, color parameters, and distribution parameters related to the contrast of the target image based on these characteristic data of the target image. Since the brightness parameter can represent the degree of brightness change of the target image in the grayscale space, the color parameter can represent the degree of color change of the target image, and the distribution parameter can represent the distribution of multiple tones on the target image, and since the degree of brightness change, color change, and hue distribution reflect the contrast of the target image from different dimensions, the contrast of the target image is determined based on these parameters, so that the determined contrast is more comprehensive and accurate.
[0129] Terminal 101 can be at least one of a smartphone, smartwatch, desktop computer, laptop, virtual reality terminal, augmented reality terminal, wireless terminal, and portable computer. Terminal 101 has communication capabilities and can access a wired or wireless network. Terminal 101 can generally refer to one of multiple terminals, and those skilled in the art will appreciate that the number of terminals can be greater or lesser. Server 102 can be a standalone physical server, a server cluster consisting of multiple physical servers, or a distributed file system. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In some embodiments, server 102 is directly or indirectly connected to terminal 101 via wired or wireless communication, which is not limited in this embodiment. Optionally, the number of servers 102 can be greater or lesser, which is not limited in this embodiment. Of course, server 102 can also include other functional servers to provide more comprehensive and diverse services. Among them, the server 102 undertakes the main computing work, and the terminal 101 undertakes the secondary computing work; or, the server 102 undertakes the secondary computing work, and the terminal 101 undertakes the main computing work; or, the server 102 or the terminal 101 can each undertake the computing work independently, and the embodiments of the present disclosure do not limit this.
[0130] Figure 2 FIG. 1 is a flow chart showing a method for determining image contrast according to an exemplary embodiment. Figure 2 As shown, the method is executed by the server and includes the following steps.
[0131] In step S201 , the server obtains the grayscale value, hue value, saturation value, and brightness value of each pixel in the target image.
[0132] In the embodiment of the present application, the target image can be any image whose contrast is to be determined. The target image can be any type of image, such as a landscape image, a person image, an animal image, a map image, etc., and is not specifically limited here.
[0133] In step S202, the server determines a brightness parameter based on the grayscale value of each pixel in the target image. The brightness parameter is used to represent the degree of brightness change of the target image in the grayscale space.
[0134] In the embodiment of the present disclosure, the grayscale value range is 0 to 255. For each pixel, a larger grayscale value indicates a brighter pixel, and a smaller grayscale value indicates a darker pixel. Therefore, the brightness parameter determined based on the grayscale value can represent the degree of brightness change of the target image in the grayscale space.
[0135] In step S203, the server determines color parameters and distribution parameters based on the hue value, saturation value and brightness value of each pixel in the target image. The color parameters are used to represent the degree of color change of the target image, and the distribution parameters are used to represent the distribution of multiple hues on the target image.
[0136] The degree of color variation can include the degree of variation in color types and the degree of variation in color intensity. The degree of variation in color types is related to the hue value, which can indicate whether the color variety is rich or monotonous. The color intensity is related to the saturation value: a larger saturation value indicates a darker color, while a smaller saturation value indicates a lighter color.
[0137] Among them, the various tones include light tones, dark tones, mid-tones, etc. The tones are related to the brightness values of the pixels. Large brightness values correspond to light tones, small brightness values correspond to dark tones, and the tones between the two are mid-tones. Optionally, the various tones can be divided by multiple brightness thresholds.
[0138] In step S204 , the server determines the contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter.
[0139] In the disclosed embodiments, the target image can be an image of any purpose. For example, the target image can be an image in the training data of a large model. Before inputting the image into the large model, the image contrast needs to be determined. After determining the image contrast, images in the training data whose contrast does not meet the preset requirements can be eliminated. Alternatively, images whose contrast does not meet the preset requirements can be adjusted before being input into the large model to improve the quality of the training data for the large model.
[0140] An embodiment of the present disclosure provides a method for determining image contrast, which determines a brightness parameter based on the grayscale value of each pixel in the target image, and determines a color parameter and a distribution parameter based on the hue value, saturation value and brightness value of each pixel in the target image. Since the brightness parameter can represent the degree of brightness change of the target image in the grayscale space, the color parameter can represent the degree of color change of the target image, and the distribution parameter can represent the distribution of multiple hues on the target image, and the brightness change, color change and hue distribution on the image all affect the contrast of the image from a certain dimension, the contrast of the target image is comprehensively determined based on these parameters, so that the contrast can more accurately reflect the visual effect of the image, and the determined contrast is more comprehensive and accurate.
[0141] above Figure 2 The following is only the basic process of the present disclosure. The solution provided by the present disclosure is further described based on a specific implementation method. Figure 3 , Figure 3 The present invention is a flowchart of another method for determining image contrast according to an exemplary embodiment. The method is executed by a server and includes the following steps.
[0142] In step S301 , the server obtains the grayscale value, hue value, saturation value, and brightness value of each pixel in the target image.
[0143] The server converts the pixel values of each pixel in the target image to grayscale space, obtaining the grayscale value of each pixel. The pixel values of each pixel in the target image are then converted to HSV (Hue, Saturation, Value) space, obtaining the hue, saturation, and brightness values of each pixel. In HSV color space, hue is used to distinguish different colors. Hue is an angle value, typically ranging from 0 to 360 degrees. Saturation, typically ranging from 0 to 255, indicates the purity or vividness of the color. Brightness, typically ranging from 0 to 255, indicates the lightness or darkness of the color.
[0144] The pixel value includes the pixel values of three channels in the RGB (Red, Green, Blue) color space, and the grayscale value, hue value, saturation value, and brightness value are obtained based on the pixel value.
[0145] In some embodiments, the server further resizes the acquired initial image to obtain a target image. Resizing the image includes enlarging or reducing the image by a certain ratio, or adjusting the image to a predetermined size, which is not specifically limited herein. In this embodiment, resizing the image facilitates subsequent image processing.
[0146] In step S302, the server determines a brightness parameter based on the grayscale value of each pixel in the target image. The brightness parameter is used to represent the degree of brightness change of the target image in the grayscale space.
[0147] In some embodiments, the brightness parameter includes at least one of a first sub-parameter, a second sub-parameter, and a third sub-parameter, and the first sub-parameter, the second sub-parameter, and the third sub-parameter respectively represent the degree of brightness change of the target image in the grayscale space from different dimensions.
[0148] In some embodiments, the brightness parameter includes a first sub-parameter, and the process of the above-mentioned server determining the brightness parameter based on the grayscale value of each pixel in the target image includes the following steps: the server determines the grayscale standard deviation based on the grayscale value of each pixel in the target image, and the grayscale standard deviation is the standard deviation between the grayscale values of each pixel; the server determines the first sub-parameter based on the grayscale standard deviation, and the first sub-parameter is positively correlated with the grayscale standard deviation.
[0149] In some embodiments, the grayscale standard deviation is normalized to obtain the first sub-parameter. For example, the ratio of the grayscale standard deviation to 100 is used as the first sub-parameter.
[0150] It's important to note that when people look at an image, they typically focus first on changes in brightness. The grayscale standard deviation reflects this brightness variation. A larger standard deviation indicates greater brightness variation and higher contrast. Conversely, a smaller standard deviation indicates less brightness variation and lower contrast. Therefore, determining contrast based on the grayscale standard deviation here provides more accurate contrast. Furthermore, the grayscale standard deviation measures the degree of variation between different grayscale levels in an image. A high grayscale standard deviation indicates greater grayscale value variation and richer detail in the image, while a low grayscale standard deviation indicates less grayscale value variation and less detail. Therefore, determining contrast based on the grayscale standard deviation allows us to quantify the richness of detail in the image.
[0151] In some embodiments, the brightness parameter includes a second sub-parameter, and the process of the above-mentioned server determining the brightness parameter based on the grayscale value of each pixel in the target image includes the following steps: the server divides the target image into multiple blocks; for each block, the modulation contrast of the block is determined based on the grayscale value of each pixel in the block, and the modulation contrast is used to represent the difference between the maximum grayscale value and the minimum grayscale value in the grayscale values of each pixel in the image; based on the modulation contrast of each of the multiple blocks, the second sub-parameter is determined, and the second sub-parameter is positively correlated with the modulation contrast of each of the multiple blocks.
[0152] Optionally, the server determines the size of the sliding window based on the image ratio and a preset minimum size, and determines the multiple tiles based on the sliding window, i.e., the size of each tile is the size of the sliding window. The image ratio is the ratio of the width to the height of the image, such as 16:9, 4:3, etc. In this embodiment, the size of the sliding window is determined based on the image ratio and the preset minimum size, i.e., the ratio of the sliding window is the same as the image ratio and the size of the sliding window is not less than the preset minimum size.
[0153] In some embodiments, when segmenting the image based on the sliding window, the edge region of the target image is also determined. This edge region is the boundary of the foreground region of the target image. The object in the foreground region can be a person, an object, etc. If the object is a person, the edge region is the region corresponding to the person's outline. Optionally, the edge region of the image is determined using a Canny (edge detection algorithm) technique.
[0154] In some embodiments, when processing a block without an edge region, the block is skipped and the next block is processed, i.e., the block is discarded. The absence of an edge region in a block indicates that the block is likely to be the background region of the target image. Background regions excluding edge regions have little impact on the contrast of the target image. Therefore, discarding such a block can improve processing efficiency without affecting contrast.
[0155] Determining the modulation contrast of an image block based on the grayscale values of each pixel in the image block can include the following implementation: determining the maximum and minimum grayscale values among the grayscale values of each pixel in the image block, determining the difference and sum between the maximum and minimum grayscale values, and using the ratio of the difference to the sum as the modulation contrast of the image block. In other words, modulation (Michelson) contrast = (maximum grayscale value - minimum grayscale value) / (maximum grayscale value + minimum grayscale value).
[0156] Determining the second sub-parameter based on the modulation contrasts of the multiple image blocks may include the following implementation: taking the average of the modulation contrasts of the multiple image blocks as the second sub-parameter.
[0157] In this embodiment, modulation contrast is determined in a manner similar to the human visual system's perception of contrast. Human visual perception of changes in brightness and darkness is nonlinear, and modulation contrast, by considering the relative difference between the maximum and minimum grayscale values, can better reflect human visual perception of contrast. Determining image contrast based on this modulation contrast makes image-based contrast more intuitive and accurate when evaluating image visual effects. By dividing the target image into multiple tiles, the modulation contrast of the target image is determined based on the modulation contrast of each tile. The modulation contrast of each tile can reflect the degree of brightness and darkness changes in that local area, allowing for a more detailed and accurate assessment of the overall contrast of the image.
[0158] In some embodiments, when processing each tile, the pixels in the tile are also trimmed, and the process includes the following steps: the server divides each pixel point in the tile into multiple grayscale value intervals based on the grayscale values of each pixel point in the tile, and the multiple grayscale value intervals are obtained by dividing the grayscale value range; the server determines a first ratio based on the ratio between the number of pixels in the grayscale value interval with the largest number of pixels and the number of pixels in the tile, and the first ratio is positively correlated with the ratio; the server sorts each pixel point in the tile based on the grayscale values of each pixel point, removes the pixel points in the tile that are sorted in the first ratio and the pixel points in the tile that are sorted in the last ratio based on the first ratio, and determines the modulation contrast of the tile based on the grayscale values of the remaining pixels in the tile.
[0159] Wherein, the grayscale value range is 0-255, and the grayscale value range is divided equally to obtain multiple grayscale value intervals. For example, the grayscale value range is divided equally to obtain 32 grayscale value intervals, and each grayscale value interval corresponds to 8 grayscale values. Then the first grayscale value interval is [0, 7], the second grayscale value interval is [8, 15], and so on.
[0160] Optionally, the pixel points distributed in each gray value interval are represented by a histogram, so that the gray value interval with the largest number of pixel points can be intuitively determined.
[0161] In the disclosed embodiment, the first ratio is determined based on the ratio. Furthermore, the first ratio can also be determined based on the maximum ratio, the minimum ratio, and the ratio. The maximum ratio and the minimum ratio can be set as needed. The first ratio is greater than the maximum ratio and not less than the minimum ratio. For example, the maximum ratio is 0.2 and the minimum ratio is 0.05. The maximum ratio corresponds to a ratio of 0 and the minimum ratio corresponds to a ratio of 1. When the first ratio is determined based on the ratio, the first ratio can be obtained by interpolating between the maximum ratio and the minimum ratio based on the ratio. For example, if the linear difference between the maximum ratio of 0.2 and the minimum ratio of 0.05 is 0.5, then the first ratio can be 0.125.
[0162] In this embodiment, for the grayscale value interval that includes the largest number of pixels, the larger the corresponding ratio, that is, the closer it is to 1, indicating that most of the pixels of the image block are concentrated in this grayscale value interval, and the grayscale value change rate of the pixels of the image is not high. Therefore, the pixels can be removed at a low ratio. If the corresponding ratio of the grayscale value interval that includes the largest number of pixels is smaller, that is, the closer it is to 0, it means that the proportion of pixels in the image block in multiple grayscale value intervals is more dispersed, and the grayscale value changes of the pixels in the image block are more diverse. Therefore, more pixels need to be removed to avoid the influence of extreme values. In this embodiment, the pixels in the image block are pruned before calculating the modulation contrast, which avoids the influence of extreme values. Since some pixels are removed, data processing efficiency is also improved.
[0163] In some embodiments, the brightness parameter includes a third sub-parameter, and the process of the above-mentioned server determining the brightness parameter based on the grayscale value of each pixel in the target image includes the following steps: the server divides the target image into multiple blocks; for each block, based on the grayscale value of each pixel in the block, determines the grayscale standard deviation corresponding to the block, and the grayscale standard deviation is the standard deviation between the grayscale values of each pixel in the block; based on the maximum value and average value of the grayscale standard deviations corresponding to each of the multiple blocks, determines the third sub-parameter, and the third sub-parameter is positively correlated with the maximum value and negatively correlated with the average value.
[0164] Optionally, the server divides the target image into multiple tiles based on a preset number of tiles. For example, the preset number of tiles is 64. It should be noted that the server processes a batch of images based on this method, and the batch of images corresponds to the same preset number of tiles, so as to obtain feature data of the same dimension for multiple images, thereby facilitating horizontal comparison between the multiple images.
[0165] For example, for a batch of images used as training data for a large model, the server wants to determine the contrast of each image in the batch of images. Then, each image can be processed based on the same preset number of blocks to obtain the third sub-parameter of each image.
[0166] The server determines the third sub-parameter based on the maximum and average grayscale standard deviations corresponding to the multiple tiles, including the following implementation: the server uses the difference between the maximum and average values as the third sub-parameter. Furthermore, the difference may be normalized and the normalized difference used as the third sub-parameter. For example, the ratio of the difference to 70 may be used as the third sub-parameter.
[0167] In this embodiment, the third sub-parameter, i.e., the block contrast difference, divides the image into multiple blocks for local contrast analysis. The grayscale standard deviation of each block can reflect the degree of brightness and darkness variation in the local area, thereby enabling a more detailed and accurate evaluation of the image contrast.
[0168] In the embodiments of the present disclosure, the brightness parameter is determined by the above implementation method as an example. In other embodiments, the brightness parameter can also be determined by other methods, such as using the wavelet transform technology in multi-scale decomposition to determine the brightness parameter. The specific process is not repeated here.
[0169] In step S303, the server determines color parameters based on the hue value, saturation value, and brightness value of each pixel in the target image. The color parameters are used to represent the degree of color change of the target image.
[0170] In some embodiments, the brightness parameter includes at least one of a fourth sub-parameter, a fifth sub-parameter, and a sixth sub-parameter, and the fourth sub-parameter, the fifth sub-parameter, and the sixth sub-parameter respectively represent the degree of color change of the target image from different dimensions.
[0171] In some embodiments, the color parameter includes a fourth sub-parameter, and the process of the above-mentioned server determining the color parameter based on the hue value, saturation value and brightness value of each pixel point in the target image includes the following steps: the server determines multiple target pixel points in the target image, and the saturation value of each target pixel point reaches a first threshold and the brightness value reaches a second threshold; based on the hue values of the multiple target pixel points, the hue standard deviation between the multiple target pixel points is determined, and the hue standard deviation is the standard deviation between the chromaticity values of the multiple target pixel points; based on the ratio between the number of multiple target pixel points and the number of pixels in the target image and the hue standard deviation, the fourth sub-parameter is determined, and the fourth sub-parameter is positively correlated with the ratio and the hue standard deviation.
[0172] The first threshold and the second threshold can be set as needed, can be the same or different, and can be determined based on a preset ratio. The first threshold is the product of the maximum brightness value and the preset ratio, and the second threshold is the product of the maximum saturation value and the preset ratio. For example, if the preset ratio is 20%, the maximum brightness value is 255, and the maximum saturation value is 255, then both the first threshold and the second threshold can be 51.
[0173] Wherein, based on the hue values of the plurality of target pixels, the hue standard deviation between the plurality of target pixels is determined, and the hue value can be converted into radian space to calculate the hue standard deviation.
[0174] Among them, the process of the server determining the fourth sub-parameter based on the ratio between the number of multiple target pixels and the number of pixels in the target image and the hue standard deviation can include the following implementation method: taking the product of the ratio and the hue standard deviation as the fourth sub-parameter.
[0175] In this embodiment, the hue standard deviation measures the degree of difference between different hues in an image. A high hue standard deviation indicates a wide range of colors in the image, while a low hue standard deviation indicates a relatively uniform or concentrated color palette. By calculating the hue standard deviation to determine contrast, the image's color diversity can be quantified based on contrast, leading to a better understanding of the image's visual content.
[0176] In some embodiments, the color parameter includes a fifth sub-parameter. The process of the above-mentioned server determining the color parameter based on the hue value, saturation value and brightness value of each pixel point in the target image includes the following steps: the server determines the saturation standard deviation based on the saturation value of each pixel point in the target image, and the saturation standard deviation is the standard deviation between the saturation values of each pixel point; based on the saturation standard deviation, the fifth sub-parameter is determined, and the fifth sub-parameter is positively correlated with the saturation standard deviation.
[0177] In some embodiments, the saturation standard deviation is normalized to obtain the fifth sub-parameter. For example, the ratio of the saturation standard deviation to 70 is used as the fifth sub-parameter.
[0178] In this embodiment, saturation measures the purity and vividness of colors in an image. Pixels with high saturation have more vivid colors, while pixels with low saturation have colors closer to gray. Since the saturation standard deviation can quantify the degree of variation in color vividness in an image, the saturation standard deviation, which reflects the degree of saturation dispersion, is used to determine contrast. This contrast also reflects the color contrast of the image.
[0179] In some embodiments, the color parameter includes a sixth sub-parameter, and the process of the above-mentioned server determining the color parameter based on the hue value, saturation value and brightness value of each pixel point in the target image includes the following steps: the server traverses the pixel points in the target image based on a preset step size, and for each traversed pixel point, performs the following steps to obtain the average saturation value of the area corresponding to the pixel point: determine an area with the pixel point as the center and a preset length as the radius, and determine the average saturation value of the area based on the saturation value of each pixel point in the area; based on the saturation threshold, determine multiple target areas from the areas corresponding to each traversed pixel point, and the target area is the area whose average saturation value reaches the saturation threshold; based on the number of multiple target areas, determine the sixth sub-parameter, and the sixth sub-parameter is positively correlated with the number.
[0180] The preset step size can be set as needed, such as 2. Optionally, a double loop can be used to traverse the pixels in the target image. For example, if the preset step size is 2, after processing one pixel, the row and column are both spaced by one pixel before processing the next pixel, that is, not all pixels are traversed, so as to improve processing efficiency.
[0181] The preset length can be set as needed. It should be noted that when traversing pixels based on the preset step size, if the traversed pixel is already located in an area corresponding to other pixels and the area is the target area, the target area is skipped and the pixels outside the target area are processed to reduce the number of pixels to be processed and improve the processing speed.
[0182] Determining the sixth sub-parameter based on the number of the plurality of target areas may include the following implementation: determining the number of the plurality of target areas as the sixth sub-parameter, and further normalizing the number to obtain the sixth sub-parameter, such as using a ratio of the number to 5 as the sixth sub-parameter.
[0183] In this embodiment, the target area is also the oversaturated area, and the oversaturated area usually contains rich color information, that is, these areas are more vivid and prominent in the image, and the distribution of the oversaturated area on the target image will affect the overall visual effect and contrast of the image. Therefore, the contrast is determined based on the number of oversaturated areas. The contrast can also reflect the balance between the local contrast and the contrast of the overall image, so that the contrast can more accurately reflect the visual effect of the image.
[0184] In step S304, the server determines distribution parameters based on the hue value, saturation value, and brightness value of each pixel in the target image. The distribution parameters are used to represent the distribution of multiple hues in the target image.
[0185] In some embodiments, the process of determining the distribution parameters of the above-mentioned server based on the hue value, saturation value and brightness value of each pixel in the target image includes the following steps: the server determines multiple first connected domains, multiple second connected domains and multiple third connected domains on the target image based on the first brightness threshold, the second brightness threshold and the third brightness threshold, respectively, the first brightness threshold, the second brightness threshold and the third brightness threshold decrease in sequence, the pixels in the first connected domain are adjacent and the brightness values are all greater than the first brightness threshold, the pixels in the second connected domain are adjacent and the difference between the brightness value and the second brightness threshold is less than the difference threshold, the pixels in the third connected domain are adjacent And the brightness values are all less than the third brightness threshold; the server determines the first connectivity value, the second connectivity value and the third connectivity value based on multiple first connected domains, multiple second connected domains and multiple third connected domains, the first connectivity value is used to represent the distribution difference between the multiple first connected domains and the multiple second connected domains, the second connectivity value is used to represent the distribution difference between the multiple second connected domains and the multiple third connected domains, and the third connectivity value is used to represent the distribution difference between the multiple first connected domains and the multiple third connected domains; the server determines the distribution parameter based on the first connectivity value, the second connectivity value and the third connectivity value, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value and the third connectivity value.
[0186] The first brightness threshold corresponds to the bright area of the target image, the third brightness threshold corresponds to the dark area of the target image, and the second brightness threshold corresponds to the intermediate area between the bright and dark areas. The intermediate area is determined based on the second brightness threshold and the difference threshold. That is, the intermediate area corresponds to a certain range of brightness values, and the brightness values of the pixels in the second connected area are within the range of the second brightness threshold ± the difference threshold.
[0187] The pixels in the connected domain are adjacent, that is, any pixel in the connected domain is adjacent to at least one pixel in the region, so as to form a connected region.
[0188] The server determines a first connectivity value, a second connectivity value, and a third connectivity value based on multiple first connected domains, multiple second connected domains, and multiple third connected domains. The specific process includes the following steps: the server determines the first connectivity value based on the multiple first connected domains and the multiple second connected domains, determines the second connectivity value based on the multiple second connected domains and the multiple third connected domains, and determines the third connectivity value based on the multiple first connected domains and the multiple third connected domains. Furthermore, the connectivity value is determined based on the area of the connected domain. For example, for the first connectivity value, the first connectivity value is determined based on the area of the multiple first connected domains and the area of the multiple second connected domains.
[0189] The first connectivity value indicates the distribution comparison between the bright area and the middle area, the second connectivity value indicates the distribution comparison between the dark area and the middle area, and the third connectivity value indicates the distribution comparison between the bright area and the dark area.
[0190] In this embodiment, the target image's bright, dark, and intermediate regions are identified and their areas compared. By comparing these regions, the distribution of light and dark tones in the target image can be assessed. A large difference indicates high contrast in the target image, while a small difference indicates low contrast. Because the human visual system is highly sensitive to changes in light and dark, comparing the connected domain areas of the bright, dark, and intermediate regions better simulates human visual perception of contrast. Contrast can then be determined based on connectivity, allowing this contrast to more accurately reflect the visual quality of the image.
[0191] In some embodiments, when determining the connectivity value, the weight of each pixel in the target image is also considered. The process in which the server determines the first connectivity value, the second connectivity value, and the third connectivity value based on multiple first connected domains, multiple second connected domains, and multiple third connected domains includes the following steps: the server determines the weight corresponding to each pixel based on the distance between each pixel on the target image and the center point of the target image, and the weight corresponding to each pixel is negatively correlated with the corresponding distance; based on the weight corresponding to each pixel, the area of each pixel is weighted to obtain the weighted area of each pixel; for each connected domain, the connected area of the connected domain is determined based on the weighted area of each pixel on the connected domain; based on the connected areas of multiple first connected domains, the connected areas of multiple second connected domains, and the connected areas of multiple third connected domains, the first connectivity value, the second connectivity value, and the third connectivity value are determined.
[0192] The weights assigned to each pixel are determined, thereby defining the visual center weight distribution map of the target image. The weights associated with pixels are negatively correlated with their distance from the center. The farther the pixel is from the center, the smaller the weight, while the closer the pixel is to the center, the larger the weight. Each pixel has the same area.
[0193] In this embodiment, the weight of each pixel point is determined by distance as an example. In other embodiments, the weight of each pixel point can also be determined by other implementation methods. For example, the weight of each pixel point can also be determined by the perceptible distortion model in the human visual system modeling scheme, which will not be repeated here.
[0194] Wherein, the connected area of the connected domain is determined based on the weighted area of each pixel point on the connected domain, and optionally, the sum of the weighted areas of each pixel point is determined as the connected area of the connected domain.
[0195] Among them, the first connectivity value, the second connectivity value and the third connectivity value are determined based on the connectivity areas of multiple first connected domains, the connectivity areas of multiple second connected domains and the connectivity areas of multiple third connected domains. The specific process includes the following steps: determining the first connectivity value based on the connectivity areas of multiple first connected domains and the connectivity areas of multiple second connected domains; determining the second connectivity value based on the connectivity areas of multiple second connected domains and the connectivity areas of multiple third connected domains; determining the third connectivity value based on the connectivity areas of multiple first connected domains and the connectivity areas of multiple third connected domains.
[0196] For each type of connected domain in the first connected area, the second connected domain, and the third connected domain, the server determines the sum of the connected areas of the multiple connected domains of each type to obtain a first area, a second area, and a third area. A first connectivity value is then determined based on the connected areas of the multiple first connected domains and the connected areas of the multiple second connected domains. Specifically, the first connectivity value is determined based on the first area and the second area. The process for determining other connectivity values is similar and will not be repeated here.
[0197] The connectivity value is determined based on the two areas, including the following implementation: determining the ratio and sum of the first value and the second value in the two areas, and taking the product of the ratio and the sum as the connectivity value. The first value is the smaller of the two areas, and the second value is the larger of the two areas, that is, the connectivity value = , A represents the first value and B represents the second value.
[0198] Among them, the distribution parameter is determined based on the first connectivity value, the second connectivity value and the third connectivity value. The sum of the three can be used as the distribution parameter, or the three can be weighted and summed to obtain the distribution parameter. The weight of each connectivity value can be set as needed, and no specific limitation is given here.
[0199] In this embodiment, when determining the spatial distribution of hue, the central visual weight and the connected domain are combined, so that the distribution parameters can not only indicate the area differences of various hue areas, but also indicate the position differences, making the spatial distribution analysis of hue more comprehensive and accurate.
[0200] In some embodiments, the influence of the edge area in the image on the hue distribution needs to be considered. Then, the process of the server determining the distribution parameters based on the first connectivity value, the second connectivity value and the third connectivity value also includes the following steps: the server determines multiple fourth connected domains on the target image based on the fourth brightness threshold, the pixels in the fourth connected domains are adjacent and the brightness values are all greater than the fourth brightness threshold, and the fourth brightness threshold is greater than the first brightness threshold; determines multiple target connected domains from the multiple fourth connected domains, the area of the target connected domains meets the first condition and the shape meets the second condition; determines multiple connected domains from the multiple target connected domains, the overlapping ratio between which reaches the second ratio with the edge area in the target image, the edge area indicates the boundary of the object in the target image; determines the fourth connectivity value based on the ratio between the number of pixels in the multiple connected domains and the number of pixels in the target image, and the fourth connectivity value is positively correlated with the ratio; determines the distribution parameter based on the first connectivity value, the second connectivity value, the third connectivity value and the fourth connectivity value, and the distribution parameter is positively correlated with the fourth connectivity value.
[0201] Among them, the fourth connected domain is also the highlighted area on the target image. The first condition can be that the area is within the preset area range, that is, not exceeding the preset area. The second condition can be determined based on the circumscribed rectangle corresponding to the connected domain, and the second condition includes at least one of the following: the length of the short side of the circumscribed rectangle is not less than the length threshold, and the aspect ratio of the circumscribed rectangle is greater than the aspect ratio threshold. The aspect ratio threshold can be set as needed to filter out long strip-shaped connected areas and eliminate circumscribed rectangles with shapes close to squares. Since the edge area on the image generally appears in the form of strips, the shape of the connected domain is limited, which facilitates the subsequent better extraction of the highlighted edge area.
[0202] Here, edge detection can be performed on the target image to obtain an edge region, such as using the Canny technique. The edge region indicates the boundary of an object in the target image. The edge region is the area where the foreground and background regions of the target image meet. The object in the foreground region can be a person, an object, etc. If the foreground region includes a person, the edge region is the area corresponding to the person's outline.
[0203] In some embodiments, since the edge area indicates the boundary of an object in the image, the edge area may be small, such as corresponding to only a narrow contour line. Optionally, the edge area can be expanded based on a preset expansion value, and then multiple connected domains can be determined based on the expanded edge area to make the extracted edge wider, thereby facilitating the subsequent better extraction of the highlighted edge area.
[0204] In the embodiment of the present disclosure, the target image includes both a target connected domain and an edge area, and a portion of each target connected domain may overlap with a portion of the edge area. Therefore, the overlapping ratio between the target connected domain and the edge area in the image reaches a second ratio, which means that the ratio of the area of the edge area in the target connected domain to the area of the target connected domain reaches the second ratio.
[0205] In some embodiments, the fourth connectivity value is determined based on a ratio between the number of pixels in the plurality of connected domains and the number of pixels in the target image, and the ratio may be directly used as the fourth connectivity value.
[0206] When determining the distribution parameter based on the first, second, third, and fourth connectivity values, each of the first three connectivity values has a corresponding weight. Optionally, the fourth connectivity value is multiplied by a fixed adjustment factor, and the resulting product and the weighted sum of the first three connectivity values are used as the distribution parameter.
[0207] In this embodiment, the fourth connectivity value indicates the distribution of the highlighted edge area in the target image. The highlight in the edge area causes an obvious brightness contrast between the foreground and background in the image, which has a significant impact on the contrast of the target image. Therefore, the distribution parameter is determined based on the highlighted edge area, and then the contrast is subsequently determined based on the distribution parameter, making the contrast more comprehensive and accurate.
[0208] It should be noted that the serial numbers of steps S302-S304 are only for ease of description and are not used to limit the execution order of the three. If the three can be executed simultaneously, no specific limitation is made here.
[0209] In step S305 , the server determines the contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter.
[0210] In some embodiments, the process of the above-mentioned server determining the contrast of the target image based on the brightness parameter, color parameter and distribution parameter includes the following steps: the server determines the weights corresponding to the brightness parameter, color parameter and distribution parameter based on the target image; based on the weights corresponding to the brightness parameter, color parameter and distribution parameter, the server performs weighted summation of the brightness parameter, color parameter and distribution parameter to obtain the contrast of the target image.
[0211] Among them, the server determines the weights corresponding to the brightness parameters, color parameters and distribution parameters based on the target image, which can include the following implementation methods: the server determines the perceived saturation of the target image based on the brightness value and saturation value of each pixel in the target image; based on the perceived saturation and the correspondence between the weights of the brightness parameters, color parameters and distribution parameters and the perceived saturation, determines the weights corresponding to the brightness parameters, color parameters and distribution parameters.
[0212] Perceived saturation refers to the perceived degree of color purity, reflecting the amount of white in the color, that is, indicating the intensity of saturation under the influence of brightness. Perceived saturation is related to saturation and brightness. Determining perceived saturation may include the following steps: for each pixel, determine the perceived saturation of the pixel based on the brightness value and saturation value of the pixel, where perceived saturation = , Indicates the brightness value, Indicates the saturation value, is a constant, such as 0.55.
[0213] Optionally, the server uses the average of the perceived saturations of each pixel as the perceived saturation of the target image.
[0214] It should be noted that if the brightness parameter includes the first sub-parameter, the second sub-parameter and the third sub-parameter, the weight corresponding to the brightness parameter includes the weights corresponding to each of the three sub-parameters; similarly, if the color parameter includes the fourth sub-parameter, the fifth sub-parameter and the sixth sub-parameter, the weight corresponding to the color parameter includes the weights corresponding to each of the three sub-parameters.
[0215] In some embodiments, two sets of weights are preset, each set of weights including weights corresponding to each of the above parameters. The first set of weights is used when the perceived saturation of the target image is not less than the perceived saturation threshold, and the second set of weights is used when the perceived saturation of the target image is less than the perceived saturation threshold.
[0216] Optionally, the perceived saturation is negatively correlated with the brightness parameter, positively correlated with the color parameter, and negatively correlated with the distribution parameter, respectively. Accordingly, the weight corresponding to the brightness parameter in the first set of weights is smaller than the weight corresponding to the brightness parameter in the second set of weights. The weight corresponding to the color parameter in the first set of weights is larger than the weight corresponding to the color parameter in the second set of weights. The weight corresponding to the distribution parameter in the first set of weights is smaller than the weight corresponding to the distribution parameter in the second set of weights.
[0217] In some embodiments, linear interpolation can be performed between the two sets of weights to establish a correspondence between the weights and the perceived saturation. When the perceived saturation is not less than the perceived saturation threshold, the contrast of the target image is obtained by weighted summing the brightness parameter, color parameter, and distribution parameter based on the weights corresponding to the brightness parameter, color parameter, and distribution parameter in the first set of weights. When the perceived saturation is less than the perceived saturation threshold, the weights corresponding to the brightness parameter, color parameter, and distribution parameter are determined based on the correspondence between the perceived saturation and the weights and the perceived saturation.
[0218] In this embodiment, due to the low perceived saturation, the perception of the color dimension may be weak, the perception of the brightness dimension may be improved, and the perception of the spatial parameters is also improved. Therefore, different weights are set for target images with different perceived saturations, so that the weights of various parameters match the perceived saturation, thereby achieving content perception preprocessing of the target image, and thus making the determined contrast more consistent with human aesthetic perception, that is, making the contrast more accurate.
[0219] In the disclosed embodiment, the judgment and discarding logic of image color and edge information is introduced in the steps of dividing the image blocks, detecting oversaturation, and determining the standard deviation of hue, thereby avoiding the errors and efficiency loss caused by invalid areas, thereby improving the image processing efficiency.
[0220] In the disclosed embodiments, a multi-dimensional image contrast assessment method (brightness, color, and spatial distribution) is constructed, and through dynamic weight interpolation and content-aware preprocessing, the determined image contrast is more closely aligned with human aesthetic perception. Furthermore, this method ensures interpretable, real-time, and data-independent results, improving contrast confidence.
[0221] See also Figure 4 , Figure 4 This is a flowchart illustrating a method for determining image contrast according to an exemplary embodiment. After acquiring an image, the server preprocesses the image. This preprocessing includes image resizing, color space conversion, and generating a visual center weight distribution. The color space conversion includes conversions to grayscale and HSV spaces. Then, brightness parameters, color parameters, and distribution parameters are determined. The brightness parameter includes a first sub-parameter (grayscale standard deviation) reflecting the degree of global brightness variation, as well as second and third sub-parameters reflecting the degree of local brightness variation. The first sub-parameter is determined based on the grayscale standard deviation, the second sub-parameter is determined based on the local modulation contrast, and the third sub-parameter is determined based on the local grayscale standard deviation. The color parameters include a fourth sub-parameter reflecting the degree of hue variation, and fifth and sixth sub-parameters reflecting the degree of saturation variation. The fourth sub-parameter is determined based on the hue standard deviation, the fifth sub-parameter is determined based on the saturation standard deviation, and the sixth sub-parameter is determined based on oversaturated areas. The distribution parameters are determined based on the contrast and center weighting of the connected domain of three dark-light blocks, as well as the special highlight contrast contour (outline light) area. Furthermore, the weights corresponding to various parameters are determined based on perceived saturation. The weights used can be a base weight (the first set of weights), a low saturation weight (the second set of weights), and a weight obtained by linear interpolation based on perceived saturation. The various parameters are then fused using dynamic weights to determine image contrast. Furthermore, when screening images based on contrast, the various parameters and thresholds preset in the above process can be calibrated in conjunction with the annotation results.
[0222] This method and other methods were used to determine contrast on the same batch of annotated images. The other methods scored 52.8% correctly for low-saturation images and 54.8% correctly for high-saturation images. However, this approach significantly improved the accuracy of the scoring to 67.9% for low-saturation images and 71.4% for high-saturation images.
[0223] An embodiment of the present disclosure provides a method for determining image contrast, which determines a brightness parameter based on the grayscale value of each pixel in the target image, and determines a color parameter and a distribution parameter based on the hue value, saturation value and brightness value of each pixel in the target image. Since the brightness parameter can represent the degree of brightness change of the target image in the grayscale space, the color parameter can represent the degree of color change of the target image, and the distribution parameter can represent the distribution of multiple hues on the target image, and the brightness change, color change and hue distribution on the image all affect the contrast of the image from a certain dimension, the contrast of the target image is comprehensively determined based on these parameters, so that the contrast can more accurately reflect the visual effect of the image, and the determined contrast is more comprehensive and accurate.
[0224] Figure 5 FIG. 1 is a block diagram of a device for determining image contrast according to an exemplary embodiment. Figure 5 , the device comprises:
[0225] An acquisition unit 501 is configured to acquire the grayscale value, hue value, saturation value, and brightness value of each pixel in a target image;
[0226] The determining unit 502 is configured to determine a brightness parameter based on the grayscale value of each pixel in the target image, where the brightness parameter is used to represent the degree of brightness change of the target image in the grayscale space;
[0227] The determining unit 502 is further configured to determine a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image, wherein the color parameter is used to represent the degree of color change of the target image, and the distribution parameter is used to represent the distribution of multiple hues in the target image;
[0228] The determining unit 502 is further configured to determine the contrast of the target image based on the brightness parameter, the color parameter and the distribution parameter.
[0229] In some embodiments, the determining unit 502 is configured to perform:
[0230] Based on the target image, determine the weights corresponding to the brightness parameter, color parameter and distribution parameter;
[0231] Based on the corresponding weights of the brightness parameter, color parameter and distribution parameter, the brightness parameter, color parameter and distribution parameter are weighted and summed to obtain the contrast of the target image.
[0232] In some embodiments, the determining unit 502 is configured to perform:
[0233] Determine the perceived saturation of the target image based on the brightness and saturation values of each pixel in the target image;
[0234] Based on the perceived saturation and the corresponding relationships between the weights of the brightness parameter, the color parameter, and the distribution parameter and the perceived saturation, the weights corresponding to the brightness parameter, the color parameter, and the distribution parameter are determined.
[0235] In some embodiments, the brightness parameter includes a first sub-parameter, and the determination unit 502 is configured to perform:
[0236] Based on the grayscale value of each pixel in the target image, the grayscale standard deviation is determined, where the grayscale standard deviation is the standard deviation between the grayscale values of each pixel;
[0237] Based on the grayscale standard deviation, a first sub-parameter is determined, and the first sub-parameter is positively correlated with the grayscale standard deviation.
[0238] In some embodiments, the brightness parameter includes a second sub-parameter, and the determining unit 502 is configured to perform:
[0239] Divide the target image into multiple tiles;
[0240] For each image block, the modulation contrast of the image block is determined based on the grayscale values of each pixel in the image block. The modulation contrast is used to represent the difference between the maximum grayscale value and the minimum grayscale value of each pixel in the image.
[0241] A second sub-parameter is determined based on the modulation contrast of each of the plurality of image blocks, where the second sub-parameter is positively correlated with the modulation contrast of each of the plurality of image blocks.
[0242] In some embodiments, the apparatus further comprises:
[0243] A dividing unit is configured to divide each pixel into a plurality of gray value intervals based on the gray value of each pixel in the image block, wherein the plurality of gray value intervals are obtained by dividing the gray value range;
[0244] The determining unit 502 is further configured to determine a first ratio based on a ratio between the number of pixels in the gray value interval with the largest number of pixels and the number of pixels in the image block, where the first ratio is positively correlated with the ratio;
[0245] The determination unit 502 is further configured to sort each pixel point based on the grayscale value of each pixel point in the block, remove the pixel points in the block that are sorted in the first ratio and the pixel points in the block that are sorted in the first ratio based on the first ratio, and determine the modulation contrast of the block based on the grayscale values of the remaining pixel points in the block.
[0246] In some embodiments, the brightness parameter includes a third sub-parameter, and the determining unit 502 is further configured to perform:
[0247] Divide the target image into multiple tiles;
[0248] For each block, based on the grayscale values of each pixel in the block, determine the grayscale standard deviation corresponding to the block. The grayscale standard deviation is the standard deviation between the grayscale values of each pixel in the block.
[0249] A third sub-parameter is determined based on a maximum value and an average value of grayscale standard deviations corresponding to the plurality of image blocks. The third sub-parameter is positively correlated with the maximum value and negatively correlated with the average value.
[0250] In some embodiments, the color parameter includes a fourth sub-parameter, and the determining unit 502 is further configured to perform:
[0251] Determine a plurality of target pixels in a target image, wherein a saturation value of each target pixel reaches a first threshold value and a brightness value reaches a second threshold value;
[0252] Determining a hue standard deviation between the multiple target pixels based on the hue values of the multiple target pixels, where the hue standard deviation is a standard deviation between the chromaticity values of the multiple target pixels;
[0253] Based on the ratio between the number of the plurality of target pixels and the number of pixels in the target image and the hue standard deviation, a fourth sub-parameter is determined, where the fourth sub-parameter is positively correlated with the ratio and the hue standard deviation.
[0254] In some embodiments, the color parameter includes a fifth sub-parameter, and the determining unit 502 is further configured to perform:
[0255] Determine a saturation standard deviation based on the saturation value of each pixel in the target image, where the saturation standard deviation is the standard deviation between the saturation values of each pixel;
[0256] Based on the saturation standard deviation, a fifth sub-parameter is determined, and the fifth sub-parameter is positively correlated with the saturation standard deviation.
[0257] In some embodiments, the color parameter includes a sixth sub-parameter, and the determining unit 502 is further configured to perform:
[0258] Based on a preset step size, traverse the pixels in the target image, and for each traversed pixel, perform the following steps to obtain the average saturation value of the area corresponding to the pixel: determine an area with the pixel as the center and a preset length as the radius, and determine the average saturation value of the area based on the saturation values of each pixel in the area;
[0259] Based on the saturation threshold, multiple target areas are determined from the areas corresponding to the traversed pixels, where the target area is the area where the average saturation value reaches the saturation threshold;
[0260] A sixth sub-parameter is determined based on the number of the plurality of target areas, and the sixth sub-parameter is positively correlated with the number.
[0261] In some embodiments, the determining unit 502 is further configured to execute:
[0262] Based on the first brightness threshold, the second brightness threshold and the third brightness threshold, a plurality of first connected domains, a plurality of second connected domains and a plurality of third connected domains on the target image are respectively determined, the first brightness threshold, the second brightness threshold and the third brightness threshold decrease in sequence, the pixels in the first connected domain are adjacent and the brightness values are all greater than the first brightness threshold, the pixels in the second connected domain are adjacent and the difference between the brightness value and the second brightness threshold is all less than the difference threshold, and the pixels in the third connected domain are adjacent and the brightness values are all less than the third brightness threshold;
[0263] Determining, based on the plurality of first connected domains, the plurality of second connected domains, and the plurality of third connected domains, a first connectivity value, a second connectivity value, and a third connectivity value, the first connectivity value being used to represent a distribution difference between the plurality of first connected domains and the plurality of second connected domains, the second connectivity value being used to represent a distribution difference between the plurality of second connected domains and the plurality of third connected domains, and the third connectivity value being used to represent a distribution difference between the plurality of first connected domains and the plurality of third connected domains;
[0264] A distribution parameter is determined based on the first connectivity value, the second connectivity value, and the third connectivity value, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value, and the third connectivity value.
[0265] In some embodiments, the determining unit 502 is further configured to execute:
[0266] Based on the distance between each pixel point on the target image and the center point of the target image, the weight corresponding to each pixel point is determined, and the weight corresponding to each pixel point is negatively correlated with the corresponding distance;
[0267] Based on the weight corresponding to each pixel point, the area of each pixel point is weighted to obtain the weighted area of each pixel point;
[0268] For each connected domain, the connected area of the connected domain is determined based on the weighted area of each pixel point in the connected domain;
[0269] A first connectivity value, a second connectivity value, and a third connectivity value are determined based on the connectivity areas of the plurality of first connected domains, the connectivity areas of the plurality of second connected domains, and the connectivity areas of the plurality of third connected domains.
[0270] In some embodiments, the determining unit 502 is further configured to execute:
[0271] Based on the fourth brightness threshold, determining multiple fourth connected domains on the target image, where the pixels in the fourth connected domains are adjacent and have brightness values greater than the fourth brightness threshold, and the fourth brightness threshold is greater than the first brightness threshold;
[0272] Determine a plurality of target connected domains from the plurality of fourth connected domains, wherein the areas of the target connected domains satisfy the first condition and the shapes satisfy the second condition;
[0273] determining, from the plurality of target connected domains, a plurality of connected domains whose overlap ratio with the edge region in the target image reaches a second ratio, the edge region indicating a boundary of an object in the target image;
[0274] Determining a fourth connectivity value based on a ratio between the number of pixels in the plurality of connected domains and the number of pixels in the target image, where the fourth connectivity value is positively correlated with the ratio;
[0275] A distribution parameter is determined based on the first connectivity value, the second connectivity value, the third connectivity value, and the fourth connectivity value, the distribution parameter being positively correlated with the fourth connectivity value.
[0276] An embodiment of the present disclosure provides a device for determining image contrast, which determines a brightness parameter based on the grayscale value of each pixel in a target image, and determines a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image. Since the brightness parameter can represent the degree of brightness change of the target image in the grayscale space, the color parameter can represent the degree of color change of the target image, and the distribution parameter can represent the distribution of multiple hues on the target image, and the brightness change, color change, and hue distribution on the image all affect the contrast of the image from a certain dimension, the contrast of the target image is comprehensively determined based on these parameters, so that the contrast can more accurately reflect the visual effect of the image, and the determined contrast is more comprehensive and accurate.
[0277] Regarding the apparatus in the above embodiment, the specific manner in which each unit performs operations has been described in detail in the embodiment of the method, and will not be elaborated on here.
[0278] In some embodiments, the electronic device is provided as a terminal. Figure 6 The following is a block diagram of a terminal 600 according to an exemplary embodiment of the present disclosure. Terminal 600 may be a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. Terminal 600 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other similar names.
[0279] Typically, the terminal 600 includes a processor 601 and a memory 602 .
[0280] Processor 601 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 601 may be implemented in hardware using at least one of the following: a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), or a PLA (Programmable Logic Array). Processor 601 may also include a main processor and a coprocessor. The main processor is used to process data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing content displayed on the display screen. In some embodiments, processor 601 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0281] Memory 602 may include one or more computer-readable storage media, which may be non-transitory. Memory 602 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 602 is used to store at least one program code, which is executed by processor 601 to implement the method for determining image contrast provided in the method embodiments of the present disclosure.
[0282] In some embodiments, terminal 600 may optionally include a peripheral device interface 603 and at least one peripheral device. Processor 601, memory 602, and peripheral device interface 603 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 603 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 604, a display screen 605, a camera assembly 606, an audio circuit 607, and a power supply 608.
[0283] The peripheral device interface 603 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0284] The RF circuit 604 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 604 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 604 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 604 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 604 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 604 may also include circuitry related to Near Field Communication (NFC), although this disclosure does not limit this.
[0285] Display screen 605 is used to display a user interface (UI). This UI can include graphics, text, icons, videos, or any combination thereof. If display screen 605 is a touchscreen display, it can also detect touch signals on or above the surface of display screen 605. These touch signals can be input as control signals to processor 601 for processing. Display screen 605 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be a single display screen 605, located on the front panel of terminal 600. In other embodiments, there can be at least two display screens 605, located on different surfaces of terminal 600 or in a foldable design. In still other embodiments, display screen 605 can be a flexible display, located on a curved or foldable surface of terminal 600. Display screen 605 can also be configured as a non-rectangular, irregular shape, also known as a special-shaped screen. Display screen 605 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0286] The camera assembly 606 is used to capture images or videos. Optionally, the camera assembly 606 includes a front camera and a rear camera. Typically, the front camera is provided on the front panel of the terminal, and the rear camera is provided on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 606 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0287] The audio circuit 607 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 601 for processing, or input into the radio frequency circuit 604 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 600. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 601 or the radio frequency circuit 604 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 607 may also include a headphone jack.
[0288] Power supply 608 is used to power various components in terminal 600. Power supply 608 can be AC power, DC power, disposable batteries, or rechargeable batteries. When power supply 608 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0289] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the terminal 600, and the terminal 600 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0290] Figure 7 This is a schematic diagram of the structure of a server provided in accordance with an embodiment of the present application. The server 700 may vary significantly due to different configurations or performance. It may include one or more processors (Central Processing Units, CPUs) 701 and one or more memories 702. The memories 702 are used to store executable program code, and the processors 701 are configured to execute the executable program code to implement the methods for determining image contrast provided in the various method embodiments described above. Of course, the server may also include components such as a wired or wireless network interface, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which are not detailed here.
[0291] In an exemplary embodiment, a computer-readable storage medium is also provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the above-described method for determining image contrast. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0292] In an exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program. When the computer program is executed by a processor, the computer program implements the above-mentioned method for determining image contrast.
[0293] In some embodiments, the computer program product involved in the embodiments of the present disclosure may be deployed and executed on one electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected through a communication network. Multiple electronic devices distributed at multiple locations and interconnected through a communication network may constitute a blockchain system.
[0294] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims. All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.
[0295] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for determining image contrast, characterized in that: The method comprises: Get the grayscale value, hue value, saturation value and brightness value of each pixel in the target image; Determining a brightness parameter based on the grayscale value of each pixel in the target image, wherein the brightness parameter is used to represent the degree of brightness change of the target image in the grayscale space; Determining a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image, wherein the color parameter is used to represent the degree of color change of the target image, and the distribution parameter is used to represent the distribution of multiple hues in the target image; determining a contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter; Determining the distribution parameters based on the hue value, saturation value, and brightness value of each pixel in the target image includes: Based on a first brightness threshold, a second brightness threshold, and a third brightness threshold, a plurality of first connected domains, a plurality of second connected domains, and a plurality of third connected domains on the target image are respectively determined, wherein the first brightness threshold, the second brightness threshold, and the third brightness threshold decrease in sequence, pixels in the first connected domain are adjacent and their brightness values are all greater than the first brightness threshold, pixels in the second connected domain are adjacent and the difference between their brightness values and the second brightness threshold is all less than the difference threshold, and pixels in the third connected domain are adjacent and their brightness values are all less than the third brightness threshold; Based on the distances between each pixel point on the target image and the center point of the target image, the weights corresponding to each pixel point are determined, and the weights corresponding to each pixel point are negatively correlated with the corresponding distances; based on the weights corresponding to each pixel point, the areas of each pixel point are weighted to obtain the weighted areas of each pixel point; for each connected domain, the connected area of the connected domain is determined based on the weighted areas of each pixel point on the connected domain; based on the connected areas of the multiple first connected domains, the connected areas of the multiple second connected domains, and the connected areas of the multiple third connected domains, a first connected value, a second connected value, and a third connected value are determined; determining the connected value based on two areas includes: connected value = , A represents the first value, B represents the second value, the first value is the smaller of the two areas, and the second value is the larger of the two areas; Based on the first connectivity value, the second connectivity value, and the third connectivity value, the distribution parameter is determined, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value, and the third connectivity value.
2. The method for determining image contrast according to claim 1, wherein: The determining the contrast of the target image based on the brightness parameter, the color parameter, and the distribution parameter includes: Based on the target image, determining weights corresponding to the brightness parameter, the color parameter, and the distribution parameter; Based on the weights corresponding to the brightness parameter, the color parameter and the distribution parameter, the brightness parameter, the color parameter and the distribution parameter are weightedly summed to obtain the contrast of the target image.
3. The method for determining image contrast according to claim 2, wherein: The determining, based on the target image, weights corresponding to the brightness parameter, the color parameter, and the distribution parameter, respectively, includes: Determining the perceived saturation of the target image based on the brightness value and saturation value of each pixel in the target image; Based on the perceived saturation and the corresponding relationships between the weights of the brightness parameter, the color parameter, and the distribution parameter and the perceived saturation, the weights corresponding to the brightness parameter, the color parameter, and the distribution parameter are determined.
4. The method for determining image contrast according to claim 1, wherein: The brightness parameter includes a first sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes: Determining a grayscale standard deviation based on the grayscale value of each pixel in the target image, wherein the grayscale standard deviation is the standard deviation between the grayscale values of each pixel; The first sub-parameter is determined based on the grayscale standard deviation, and the first sub-parameter is positively correlated with the grayscale standard deviation.
5. The method for determining image contrast according to claim 1, wherein: The brightness parameter includes a second sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes: Dividing the target image into a plurality of blocks; For each image block, determining a modulation contrast of the image block based on the grayscale values of each pixel in the image block, wherein the modulation contrast is used to represent a difference between a maximum grayscale value and a minimum grayscale value among the grayscale values of each pixel in the image; The second sub-parameter is determined based on the modulation contrast of each of the plurality of image blocks, and the second sub-parameter is positively correlated with the modulation contrast of each of the plurality of image blocks.
6. The method for determining image contrast according to claim 5, wherein: The method further comprises: Based on the grayscale value of each pixel in the image block, the pixel is divided into a plurality of grayscale value intervals, and the plurality of grayscale value intervals are obtained by dividing the grayscale value range; determining a first ratio based on a ratio between the number of pixels in a grayscale value interval having the largest number of pixels and the number of pixels in the image block, wherein the first ratio is positively correlated with the ratio; The pixels in the image block are sorted based on their grayscale values, and based on the first ratio, the pixels in the image block that are sorted in the front and the pixels in the back of the image block that are sorted in the first ratio are removed, and the modulation contrast of the image block is determined based on the grayscale values of the remaining pixels in the image block.
7. The method for determining image contrast according to claim 1, wherein: The brightness parameter includes a third sub-parameter, and determining the brightness parameter based on the grayscale value of each pixel in the target image includes: Dividing the target image into a plurality of blocks; For each image block, determining a grayscale standard deviation corresponding to the image block based on the grayscale values of each pixel in the image block, where the grayscale standard deviation is the standard deviation between the grayscale values of each pixel in the image block; The third sub-parameter is determined based on a maximum value and an average value of grayscale standard deviations corresponding to each of the plurality of image blocks, where the third sub-parameter is positively correlated with the maximum value and negatively correlated with the average value.
8. The method for determining image contrast according to claim 1, wherein: The color parameter includes a fourth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes: Determine a plurality of target pixels in the target image, wherein a saturation value of each target pixel reaches a first threshold value and a brightness value reaches a second threshold value; Determining a hue standard deviation between the plurality of target pixel points based on the hue values of the plurality of target pixel points, the hue standard deviation being a standard deviation between the chromaticity values of the plurality of target pixel points; The fourth sub-parameter is determined based on a ratio between the number of the plurality of target pixels and the number of pixels in the target image and the hue standard deviation, and the fourth sub-parameter is positively correlated with the ratio and the hue standard deviation.
9. The method for determining image contrast according to claim 1, wherein: The color parameter includes a fifth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes: Determining a saturation standard deviation based on the saturation value of each pixel in the target image, where the saturation standard deviation is a standard deviation between the saturation values of each pixel; The fifth sub-parameter is determined based on the saturation standard deviation, and the fifth sub-parameter is positively correlated with the saturation standard deviation.
10. The method for determining image contrast according to claim 1, wherein: The color parameter includes a sixth sub-parameter, and determining the color parameter based on the hue value, saturation value, and brightness value of each pixel in the target image includes: Based on a preset step size, traverse the pixel points in the target image, and for each traversed pixel point, perform the following steps to obtain the average saturation value of the area corresponding to the pixel point: determine an area with the pixel point as the center and a preset length as the radius, and determine the average saturation value of the area based on the saturation values of each pixel point in the area; Based on the saturation threshold, multiple target areas are determined from the areas corresponding to the traversed pixel points, where the target areas are areas where the average saturation value reaches the saturation threshold; Based on the number of the plurality of target areas, a sixth sub-parameter is determined, the sixth sub-parameter being positively correlated with the number.
11. The method for determining image contrast according to claim 1, wherein: The determining the distribution parameter based on the first connectivity value, the second connectivity value, and the third connectivity value includes: determining, based on a fourth brightness threshold, a plurality of fourth connected domains on the target image, wherein pixels in the fourth connected domains are adjacent and have brightness values greater than the fourth brightness threshold, and the fourth brightness threshold is greater than the first brightness threshold; Determine a plurality of target connected domains from the plurality of fourth connected domains, wherein the areas of the target connected domains satisfy a first condition and the shapes satisfy a second condition; Determining, from the plurality of target connected domains, a plurality of connected domains whose overlap ratio with an edge region in the target image reaches a second ratio, wherein the edge region indicates a boundary of an object in the target image; determining a fourth connectivity value based on a ratio between the number of pixels in the plurality of connected domains and the number of pixels in the target image, wherein the fourth connectivity value is positively correlated with the ratio; The distribution parameter is determined based on the first connectivity value, the second connectivity value, the third connectivity value, and the fourth connectivity value, the distribution parameter being positively correlated with the fourth connectivity value.
12. A device for determining image contrast, characterized in that: The device comprises: An acquisition unit is configured to acquire the grayscale value, hue value, saturation value and brightness value of each pixel in the target image; a determining unit configured to determine a brightness parameter based on the grayscale value of each pixel in the target image, wherein the brightness parameter is used to represent a degree of brightness change of the target image in a grayscale space; The determining unit is further configured to determine a color parameter and a distribution parameter based on the hue value, saturation value, and brightness value of each pixel in the target image, wherein the color parameter is used to represent the degree of color change of the target image, and the distribution parameter is used to represent the distribution of multiple hues in the target image; The determining unit is further configured to determine the contrast of the target image based on the brightness parameter, the color parameter and the distribution parameter; The determining unit is configured to perform: based on a first brightness threshold, a second brightness threshold and a third brightness threshold, respectively determining a plurality of first connected domains, a plurality of second connected domains and a plurality of third connected domains on the target image, wherein the first brightness threshold, the second brightness threshold and the third brightness threshold decrease in sequence, the pixels in the first connected domain are adjacent and the brightness values are all greater than the first brightness threshold, the pixels in the second connected domain are adjacent and the difference between the brightness value and the second brightness threshold is all less than the difference threshold, and the pixels in the third connected domain are adjacent and the brightness values are all less than the third brightness threshold; based on the respective pixel points on the target image and the target image, The distance between the center points of the target images is calculated, and the weight corresponding to each pixel point is determined, and the weight corresponding to each pixel point is negatively correlated with the corresponding distance; based on the weight corresponding to each pixel point, the area of each pixel point is weighted to obtain the weighted area of each pixel point; for each connected domain, based on the weighted area of each pixel point on the connected domain, the connected area of the connected domain is determined; based on the connected areas of the multiple first connected domains, the connected areas of the multiple second connected domains and the connected areas of the multiple third connected domains, a first connected value, a second connected value and a third connected value are determined; determining the connected value based on two areas, including: connected value = , A represents a first value, B represents a second value, the first value is the smaller value of the two areas, and the second value is the larger value of the two areas; based on the first connectivity value, the second connectivity value and the third connectivity value, the distribution parameter is determined, and the distribution parameter is positively correlated with the first connectivity value, the second connectivity value and the third connectivity value.
13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method for determining image contrast according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method for determining image contrast according to any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method for determining the image contrast according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Contrast adjustment method and device
CN105303531A
Image processing method and device and computing equipment
CN107257452A