Method, equipment, device and medium for determining image quality
By comparing the differences in image pixel distribution, an algorithm can detect image quality on industrial production lines in real time, solving the problem of visual feature recognition caused by low-quality images, reducing reliance on AI models and the demand for high-end GPUs, and improving production efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies struggle to detect and process low-quality images captured by cameras on industrial production lines in real time, resulting in poor visual feature recognition. Furthermore, the high cost of training and maintaining AI models makes it unaffordable for small and medium-sized companies to afford high-end GPU-optimized models.
By comparing the pixel distribution in the color mode of the test image with that of the reference image, the algorithm determines the image quality, reducing the reliance on AI models and using a small amount of reference data for real-time image quality monitoring.
It enables real-time, low-cost image quality inspection, avoids dependence on high-end GPUs, improves production line efficiency, and reduces AI model training and maintenance costs.
Smart Images

Figure CN121773607A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer vision (CV) technology, and more particularly to methods, apparatus, devices, and media for determining image quality. Background Technology
[0002] Camera issues frequently plague field engineers. Due to factors such as equipment aging, lighting conditions, camera focal length, and human error, cameras may capture low-quality images for visual analysis. These low-quality images ultimately lead to poor visual feature recognition. More importantly, low-quality images can also be generated if camera settings or positioning change during production line operation. Because changes in camera settings and positioning are often unexpected, field engineers are unaware of when cameras begin acquiring low-quality images, and a large number of products on the production line may be produced with low-quality visual data input. Summary of the Invention
[0003] Embodiments of this disclosure provide a method, apparatus, device, and medium for determining image quality.
[0004] In a first aspect, a method for determining image quality is provided. The method includes: Determine the first pixel distribution in the color mode of the image to be tested; Determine a first difference between the first pixel distribution and a second pixel distribution in the color mode of the reference image; and The quality of the image to be tested is determined based on the first difference.
[0005] In a second aspect, an apparatus for determining image quality is provided. The apparatus includes: A first determining module is configured to determine a first pixel distribution in a color mode of the image to be tested; A second determining module is configured to determine a first difference between the first pixel distribution and a second pixel distribution in a color mode of a reference image; and A third determining module is configured to determine the quality of the image to be tested based on the first difference.
[0006] In a third aspect, an electronic device is provided. The electronic device includes a processor and a memory, wherein an application program executable by the processor is stored in the memory to cause the processor to perform a method for determining image quality as described in any of the preceding embodiments.
[0007] In a fourth aspect, a computer-readable medium is provided that includes computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by a processor, implement a method for determining image quality as described in any of the preceding items.
[0008] In a fifth aspect, a computer program product comprising a computer program that, when executed by a processor, performs a method for determining image quality as described in any of the preceding items.
[0009] Based on the above technical solutions, algorithm-based image quality determination can reduce the reliance on AI models and the cost of training and maintaining AI models, which is particularly suitable for real-time computer vision monitoring in industrial production lines. Attached Figure Description
[0010] To make the technical solutions of the embodiments of this disclosure clearer, only the accompanying drawings used to describe the embodiments will be included below. Obviously, the drawings described below are only some examples of this disclosure. Those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0011] Figure 1 This is an example image of a low-quality image.
[0012] Figure 2 This is an exemplary flowchart of a method for determining image quality according to embodiments of the present disclosure.
[0013] Figure 3A This is a first example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure.
[0014] Figure 3B This is a second example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure.
[0015] Figure 3C This is a third example diagram of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure.
[0016] Figure 3D This is a fourth example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure.
[0017] Figure 3E This is a fifth example diagram of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure.
[0018] Figure 3F This is a first example diagram of an RGB distribution pattern with a significantly different pattern according to an embodiment of the present disclosure.
[0019] Figure 3G This is a second example diagram with a slightly different RGB distribution pattern according to an embodiment of the present disclosure.
[0020] Figure 4 This is an example diagram illustrating the process of determining image quality using sub-block images according to embodiments of the present disclosure.
[0021] Figure 5 This is an exemplary structural diagram of a device for determining image quality according to embodiments of the present disclosure.
[0022] Figure 6 This is an exemplary structural diagram of an electronic device according to embodiments of the present disclosure.
[0023] List of reference numerals in the attached diagram: Detailed Implementation
[0024] To make the purpose, technical solutions and advantages of this disclosure clearer, the following examples are given to further explain this disclosure in detail.
[0025] For the sake of brevity and intuitiveness, the present disclosure is described below through several representative embodiments. Many details in the embodiments are only used to aid in understanding the present disclosure. However, it is obvious that the technical solutions of the present disclosure can be implemented without being limited to these details. To avoid unnecessarily obscuring the present disclosure, some embodiments are not described in detail, but only a framework is given. In the following text, "comprising" means "including but not limited to," and "according to..." means "at least according to..., but not limited to...". When the number of elements is not specifically specified below, it means that an element can be one or more, or can be understood as at least one.
[0026] Figure 1 This is an example image of a low-quality image. (Example image follows) Figure 1 As shown, normal image 10 shows a dog captured using a camera with predetermined camera parameters. Images 12-18 are abnormal images caused by corresponding problems. Among them: blurry image 12, object-shifted image 13, color-distorted image 14, highly saturated image 15, noisy image 16, data-corrupted image 17, and color-aberration image 18.
[0027] The above exemplary description describes the cause of the abnormal image, and those skilled in the art will recognize that the description is merely exemplary and is not intended to limit the scope of protection of the embodiments of this disclosure.
[0028] In CV-related production lines, abnormal images can be caused by various reasons. There is an urgent need to introduce the concept of data quality monitoring into CV-related production lines, whether using artificial intelligence (AI) methods or traditional vision methods, to ensure that field engineers are notified as soon as possible when the system detects changes in image input from the camera.
[0029] Many IT giants and startups have begun using AI models to monitor tabular data. Very few are conducting visual data monitoring. Typically, these startups focus on model drift monitoring rather than data quality monitoring. Some companies do perform data quality monitoring, but they attempt to train AI models to identify anomalous images in the input. However, this approach has two problems: (1) Accuracy can only be improved by training AI models on relatively large-scale data. Companies that take this approach need to hire / outsource to AI scientists and spend a lot of time on labeling data, training models, and tuning parameters, which is expensive both economically and in terms of time. If they want to change the products in their factories, they will likely need to train new models specifically for the new products.
[0030] (2) For some production lines owned by small and medium-sized companies, they cannot afford high-end GPUs to optimize models and speed up inference. Without high-end GPUs, inference may take about 100-300 milliseconds, which will significantly reduce the efficiency of the production line, since vision algorithms can complete their work in only about 20 milliseconds.
[0031] Embodiments of this disclosure provide an algorithm-based image quality detection method that can check whether a given image deviates from a reference image. Furthermore, unlike AI methods that require a large number of training images, embodiments of this disclosure require only a small number of images as reference data, which has almost no impact on real-time runtime and therefore does not affect production line efficiency. The key aspect of this algorithm is comparing the pixel distribution (e.g., RGB distribution) of the image to be tested with the pixel distribution of the reference image.
[0032] Figure 2 This is a flowchart of a method for determining image quality according to embodiments of the present disclosure. Figure 2 As shown, the method includes: Step 101: Determine the first pixel distribution in the color mode of the image to be tested.
[0033] A color model is an algorithm for representing colors in the digital world. In the digital world, colors are divided into several components to represent various colors. Due to the different principles of color synthesis, there are differences in how colors are generated between color devices that directly synthesize colors using colored light (such as monitors, projectors, and scanners) and printing devices that use pigments (such as printers).
[0034] In one embodiment, the color mode includes RGB color mode, CMYK color mode, HSB color mode, Lab color mode, indexed color mode, bitmap color mode, and grayscale color mode, etc.
[0035] 1. RGB color mode
[0036] The RGB color mode is currently the most widely used color mode, and it is supported by many browsers and monitors. The RGB mode uses three color components (or channels)—R (red), G (green), and B (blue)—to represent the color of each pixel in a color image. These three components assign an intensity value between 0 (black) and 255 (white) for each pixel.
[0037] For example, the value of the R component for bright red is 246, the value of the G component is 20, and the value of the B component is 50. When all three component values are equal, the result is neutral gray. When all component values are 255, the result is pure white; when these values are all 0, the result is pure black. RGB images reproduce colors on the screen using three colors, or three channels. For a 24-bit image, these three channels convert each pixel into 24 bits of color information, where each channel is represented by 8 bits, and can reproduce up to 16.7 million colors. For a 48-bit image, each channel is represented by 16 bits, allowing for the reproduction of even more colors.
[0038] 2. CMYK color mode
[0039] The CMYK mode is primarily used for printing. This mode specifies a percentage value for each type of printing ink for each pixel. The percentage of printing ink color assigned to the brightest highlight colors is relatively low, while the percentage assigned to darker shades is relatively high. For example, bright red includes 2% cyan, 93% magenta, 90% yellow, and 0% black. In a CMYK image, pure white is generated when all four components have a value of 0%. Although CMYK is a standard color model, the exact range of colors it represents varies depending on printing conditions. Furthermore, CMYK images contain at least four channels. Therefore, their file size is typically larger than the same image represented in RGB mode.
[0040] 3. Indexed Color Mode
[0041] Indexed color mode generates 8-bit image files with up to 256 colors. When converting an RGB image to indexed color, a color lookup table is built to store and index the colors in the image. If a color in the original image does not appear in the table, the program selects the closest color or uses analog colors to simulate an existing color. Indexed color can reduce file size while maintaining sufficient visual quality by limiting the color palette. Limited editing is possible in this mode. For further editing, it should be temporarily converted to RGB mode.
[0042] 4. Grayscale color mode
[0043] Grayscale color mode uses 256 levels of gray to represent an image. In this mode, the brightness value of each pixel in the image ranges from 0 (black) to 255 (white). Although grayscale color mode may not produce images with the same rich colors as RGB color mode, it can be used in certain situations due to the smaller file size of grayscale images.
[0044] The above exemplary description provides typical examples of color modes, and those skilled in the art will recognize that the description is merely exemplary and is not intended to limit the scope of protection of the embodiments of this disclosure.
[0045] Here, pixel distribution refers to the statistical representation of the value of each pixel in the image. Preferably, the pixel distribution is implemented as a pixel probability distribution. The first pixel distribution in the image to be tested can be a single pixel distribution corresponding to a single channel, or multiple pixel distributions corresponding to multiple channels respectively.
[0046] Step 102: Determine the first difference between the first pixel distribution and the second pixel distribution in the color mode of the reference image.
[0047] In one embodiment, determining a first difference between a first pixel distribution and a second pixel distribution in a color mode of a reference image includes: determining a corresponding pixel distribution of the test image in a corresponding channel of the color mode; determining a corresponding pixel distribution of the reference image in a corresponding channel of the color mode; determining a corresponding difference between the pixel distribution of the test image in the corresponding channel and the pixel distribution of the reference image in the corresponding channel; and combining the corresponding differences into a difference group. In one embodiment, the channel includes at least one of the following: a color channel; a chroma channel; a hue channel; a saturation channel; a lightness channel; and a colorless channel.
[0048] Taking RGB mode as an example, the color of each pixel can be converted into an RGB value. RGB values always fall within the range of 0 to 255. First, by calculating the probability of each value between 0 and 255, and then calculating the RGB value separately, we can obtain the RGB distribution. More specifically, we first determine the corresponding pixel distributions in the R, G, and B channels of the image under test. Then, we determine the corresponding pixel distributions in the R, G, and B channels of the reference image. Second, we determine the differences between the pixel distributions in the R channels of the image under test and those in the R channels of the reference image, the differences between the pixel distributions in the G channels of the image under test and those in the G channels of the reference image, and the differences between the pixel distributions in the B channels of the image under test and those in the B channels of the reference image. Third, we combine these three differences into a difference group.
[0049] In one embodiment, the method includes: acquiring a corresponding available reference image; determining a corresponding pixel distribution in the color mode of the corresponding available reference image; calculating an average value of the corresponding pixel distribution; and determining the average value as a second pixel distribution. Therefore, by calculating the average pixel distribution of multiple available reference images, the accuracy of the second pixel distribution can be improved.
[0050] For example, suppose there are three available reference images: image 1, image 2, and image 3. Calculate the pixel distribution of the R, G, and B channels for each of image 1, image 2, and image 3. Then, calculate the average pixel distribution of the R channels for each of image 1, image 2, and image 3 as the pixel distribution of the R channels for the reference images; calculate the average pixel distribution of the G channels for each of image 1, image 2, and image 3 as the pixel distribution of the G channels for the reference images; and calculate the average pixel distribution of the B channels for each of image 1, image 2, and image 3 as the pixel distribution of the B channels for the reference images.
[0051] In one embodiment, determining the first difference between the first pixel distribution and the second pixel distribution includes: determining the dispersion between the first pixel distribution and the second pixel distribution; and determining the first difference based on the dispersion. Dispersion is a metric that measures the magnitude of risk by the difference between randomly observed variable values. In one embodiment, the degree of dispersion includes: KL dispersion; JS divergence; dispersion determined based on an entropy function; dispersion determined based on a cross-entropy loss function; and the Kolmogorov-Smirnov test.
[0052] Step 103: Determine the quality of the image to be tested based on the first difference.
[0053] In one embodiment, determining the quality of the image under test based on a first difference includes: determining the quality of the image under test based on a comparison between at least one difference in a group of differences and a first threshold; when the at least one difference is greater than or equal to the first threshold, the quality of the image under test is determined to be abnormal, or when the at least one difference is less than the first threshold, the quality of the image under test is determined to be normal. Users can determine the first threshold based on specific scenario requirements. For example, the value of the first threshold may range from [0, 1]. Preferably, the first threshold is adjustable.
[0054] Here, the image quality of the image to be tested is directly determined based on at least one difference extracted from the difference group.
[0055] In one embodiment, determining the quality of the image under test based on a first difference includes: determining at least one transform value based on at least one difference in a group of differences; determining the quality of the image under test based on a comparison between the at least one transform value and a second threshold; wherein the quality of the image under test is determined to be abnormal when the at least one transform value is greater than or equal to the second threshold, or the quality of the image under test is determined to be normal when the at least one transform value is less than the second threshold.
[0056] The transform value can be determined based on the difference group in several ways. For example, the average of all differences in the difference group can be used to determine the transform value. Alternatively, the average of a subset of differences in the difference group can be used to determine the transform value. Here, image quality is determined based on the transform value determined from the difference group, thus providing more options.
[0057] In certain situations, the quality of a test image cannot be accurately determined based on the first difference or transformation value. For example, the pixel distribution of the test image and the reference image may be the same, but their patterns may be completely different. Therefore, based on the quality determination method described above, the quality of the test image may be incorrectly determined to be normal.
[0058] After determining that the test image is normal based on the first difference or transformation value, the image quality is further evaluated by comparing the pixel distribution of the sub-block image extracted from the test image with the pixel distribution of the corresponding sub-block image extracted from the reference image. The extracted sub-block image can have any proportion of the original image, such as 1 / 16, 1 / 8, 1 / 4, 1 / 2, etc.
[0059] In one embodiment, the method includes: extracting a first sub-block image from a test image; extracting a second sub-block image corresponding to the first sub-block image from a reference image; determining a third pixel distribution in a color mode of the first sub-block image; determining a fourth pixel distribution in a color mode of the second sub-block image; determining a second difference between the third pixel distribution and the fourth pixel distribution; and determining the quality of the test image based on the second difference when the image quality has previously been determined to be normal based on the first difference, wherein the quality of the test image is determined to be abnormal when the second difference is greater than or equal to a third threshold, or the quality of the test image is determined to be normal when the second difference is less than the third threshold. If the image is determined to be abnormal based on the second difference after the first difference has determined it to be normal, then the image is considered abnormal.
[0060] The embodiments disclosed herein can be applied to various scenarios, particularly industrial ones, especially in the application of quality inspection of input data for AI models in industrial settings. For example, the AI model may include: a workpiece classification model, a workpiece quality inspection model, a product quality inspection model, a product defect inspection model, etc.
[0061] In one embodiment, the method includes: when the quality of a real-time image is determined to be normal, assigning a first label to the real-time image indicating normal quality; when the quality of a real-time image is determined to be abnormal, assigning a second label to the real-time image indicating abnormal quality; and determining whether to input the real-time image into an industrial AI model by identifying whether the label of the real-time image is the first label or the second label. Normally, when the identification result is the first label, sending the real-time image to the AI model is allowed; and when the identification result is the second label, sending the real-time image to the AI model is refused, and an alarm message is issued.
[0062] In one embodiment, the reference image is an image of a workpiece captured using an industrial camera with predetermined camera parameters, and the image to be tested is a real-time image of the workpiece captured using the industrial camera. When embodiments of this disclosure are applied to a production line scenario, costs can be significantly reduced by eliminating the need to train an AI model to detect the quality of the input image data. Furthermore, it avoids the detection distortion problems caused by repeatedly using various AI models.
[0063] The following will use RGB mode and industrial scenarios as examples to provide a detailed explanation of embodiments of this disclosure.
[0064] Figure 3A This is a first example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure; Figure 3B This is a second example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure; Figure 3CThis is a third example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure; Figure 3D This is a fourth example image of an image with slight positional shift and its RGB distribution according to an embodiment of the present disclosure; Figure 3E This is a fifth example image of an image with slight positional shift and its RGB distribution according to embodiments of the present disclosure. In these examples, the camera position, lighting conditions, and focal length are fixed. The position of the box below the camera is slightly shifted, but this ensures that all symbols, text, and shapes in the image can still be clearly observed. Figures 3A to 3D In the histogram coordinate system, the horizontal axis represents pixel value, and the vertical axis represents the number of pixels. In fact, the vertical axis can be changed to the probability of a pixel in the entire image, thus forming a pixel probability distribution map.
[0065] exist Figures 3A to 3D In the diagram, curve 21 represents the pixel distribution of the R channel, curve 22 represents the pixel distribution of the G channel, and curve 23 represents the pixel distribution of the B channel. Through analysis... Figures 3A to 3D We found that for images of the same object with the same camera settings, all RGB distributions were very similar. According to Figures 3A to 3D From these distributions, we can clearly see a common pattern: for all three colors, the peak appears around 20-25; the red peak appears around 200, followed by the green peak around 220; and finally, the blue peak appears.
[0066] Figure 3F and Figure 3G There is another instance in the comparison of different images. Figure 3F This is a first example diagram of an RGB distribution pattern with a significantly different pattern according to an embodiment of the present disclosure. Figure 3G This is a second example image with a slightly different RGB distribution pattern according to an embodiment of this disclosure. The reference image has a similar pattern to... Figure 3A Similar distribution. Figure 3G The image was taken from the camera when the lighting was slightly brighter, resulting in glowing white spots appearing on the box. We can also observe some changes in distribution characteristics, such as peak contraction in regions 43 and 44, and a slight shift in the green peak in region 45. Similarly, if we observe... Figure 3F Different objects will also produce different distributions; for example, the peak value expands in region 40, increases in region 41, and is lost in region 42. Generally, if the image under test is different from the reference image, the RGB distribution will also change.
[0067] Since the RGB distribution can be used to explain variations in image content, we can summarize the distribution pattern from a reference dataset. When we receive a runtime image, we can also analyze the RGB distribution of the test image, compare it with the summarized pattern, and calculate the difference.
[0068] Preferably, the difference is compared with a warning threshold and an error threshold, respectively. If it exceeds the warning threshold but does not reach the error threshold, the algorithm will display a warning that the image has changed slightly but there is no significant difference; if it exceeds the error threshold, the algorithm will indicate that the input image differs significantly from the expected value and request a camera check. Therefore, the visual data monitoring method from embodiments of this disclosure includes: Step 1: Standardize the image Image files can have different color modes, such as CMYK, Lab, HSB, etc., and RGB is one of them. Therefore, the algorithm will check the color mode and convert the image to RGB (if it wasn't originally RGB).
[0069] Step 2: Calculate the RGB distribution of the reference image
[0070] In this step, the algorithm calculates the RGB distribution for each reference image. Although the reference images share a similar RGB distribution pattern, they will inevitably have slight differences. The algorithm aims to summarize a common pattern from the reference images. The algorithm will then take the average of the RGB distribution values from all the reference images.
[0071] Step 3: Normalize the RGB distribution
[0072] Next, the algorithm normalizes the average RGB distribution from step 2 and instead creates a probability distribution. This step has two advantages: First, the probability distribution is more standardized and can be applied to many statistical tools when the algorithm later calculates the difference between the reference image pattern and the runtime real image. Second, it allows the algorithm to work with images of different sharpness. For example, if there are two images that are identical except for sharpness: one is 1280... 1024, the other is 1920 1280. Assuming 15% of its color is pure red, then the statistics for the R channel at 255 for both images should be 1280. 1024 0.15 = 196,608 and 1920 1280 0.15 = 368,640. This difference can be an obstacle when analyzing data, but if a probability distribution is used, it should always be 15%. Therefore, images of varying sharpness can be easily handled.
[0073] Step 4: Calculate the difference between the reference pattern and the runtime image.
[0074] Because we have a summary RGB distribution pattern of the reference image and the RGB distribution of the input image, we need an appropriate method to evaluate the difference between the two patterns and use a parameter to describe the degree of difference. Various statistical tools are available, such as entropy, cross-entropy loss function, Kullback-Leibler divergence (KL divergence), Jensen-Shannon divergence (JS divergence), etc., each with its own advantages and disadvantages. After evaluating the specific use case scenario, we can choose an appropriate method to calculate the difference between the reference pattern and the runtime image pattern.
[0075] Here is an example of using JS divergence: KL divergence:
[0076] JS divergence:
[0077] in: P The image to be tested. Q For reference image, P(x) For each pixel in the image under test, the corresponding pixel value on the horizontal axis is... x The probability of; Q(x) For each pixel in the reference image, the corresponding pixel value on the horizontal axis is... x The probability of.
[0078] Based on the properties of JavaScript divergence, the smaller the result, the smaller the difference between the two distributions. Users need to set thresholds based on this result to define how much difference they will accept as a warning, and how much difference they will not accept and mark as an error. If another statistical method is applied here, the thresholds should also be set based on the chosen method.
[0079] Step 5: (Optional) Sub-block cross-validation
[0080] In extreme cases (which are not common in practice), the RGB distributions may be the same or very similar, but the image patterns may differ.
[0081] Figure 4 This is an example diagram illustrating the process of determining image quality using sub-block images according to embodiments of this disclosure. For Figure 4 In the example, the RGB statistics of reference image 51 and test image 50 are the same, but the two images are not the same.
[0082] In this case, to ensure the integrity of the algorithm, more runtime is needed to study the sub-blocks of the image. First, the size of the overlay layer is defined. Then, the algorithm uses the overlay layer to examine only certain sub-parts of the test image 50 and the reference image 51, and then repeats steps 1-4 on that sub-block image. As a result, the first sub-blocks of the 2×2 and 3×3 instances show significant differences: one image still has half blue and half white, while the other is pure blue. In this way, we can distinguish the RGB distribution of the image more accurately.
[0083] Performing the first process 52 includes: extracting a 1 / 4 image region from the upper left corner of the image to be tested 50 and calculating the probability distribution of the region; extracting a 1 / 4 image region from the upper left corner of the reference image 51 and calculating the probability distribution of the region; comparing the difference between the probability distributions of the two 1 / 4 regions and determining the image quality based on the difference.
[0084] Alternatively, a second process 53 is performed, comprising: extracting a 1 / 9 image region from the upper left corner of the image to be tested 50 and calculating a probability distribution of that region; extracting a 1 / 9 image region from the upper left corner of the reference image 51 and calculating a probability distribution of that region; comparing the difference between the probability distributions of the two 1 / 9 regions and determining the image quality based on the difference.
[0085] However, keep in mind that the larger the size, the more sub-blocks the algorithm will check, resulting in more accurate results, but also a longer processing time. Therefore, it's a trade-off between accuracy and runtime. The algorithm stores this as a parameter, allowing the user to choose whether to perform sub-block checks and which sizes to use in the algorithm.
[0086] Step 5: Compare the entropy difference with the threshold to generate the result.
[0087] Following steps 1-5, we will obtain the difference levels for all three colors: RGB. The algorithm then compares the results to a user-defined threshold. If any RGB result exceeds the threshold, the algorithm will send a warning message or an error message.
[0088] Based on the above analysis, it can be concluded that the embodiments of this disclosure have at least the following advantages: (1) The embodiments of this disclosure provide a novel method for detecting abnormal images from reference image data. (2) The embodiments of this disclosure provide algorithms that can be easily applied to both AI vision use cases and traditional vision use cases. (3) The embodiments of this disclosure provide a novel method for real-time model monitoring of visual data.
[0089] Figure 5This is an exemplary structural diagram of a device for determining image quality according to embodiments of the present disclosure. Figure 5 As shown, An apparatus 500 for determining image quality includes: a first determining module 501 configured to determine a first pixel distribution in a color mode of an image to be tested; a second determining module 502 configured to determine a first difference between the first pixel distribution and a second pixel distribution in a color mode of a reference image; and a third determining module 503 configured to determine the quality of the image to be tested based on the first difference.
[0090] In one embodiment, the first determining module 501 is configured to: determine the corresponding pixel distribution of the image to be tested in the corresponding channel of the color mode; determine the corresponding pixel distribution of the reference image in the corresponding channel of the color mode; determine the corresponding difference between the pixel distribution of the image to be tested in the corresponding channel and the pixel distribution of the reference image in the corresponding channel; and combine the corresponding differences into a difference group.
[0091] In one embodiment, the channel includes at least one of the following: a color channel; a chroma channel; a hue channel; a saturation channel; a brightness channel; and a colorless channel.
[0092] In one embodiment, the second determining module 502 is configured to determine the dispersion between the first pixel distribution and the second pixel distribution, and to determine a first difference based on the dispersion.
[0093] In one embodiment, the third determining module 503 is configured to: determine the quality of the image to be tested based on a comparison between at least one difference in the difference group and a first threshold; wherein when the at least one difference is greater than or equal to the first threshold, the quality of the image to be tested is determined to be abnormal, or when the at least one difference is less than the first threshold, the quality of the image to be tested is determined to be normal.
[0094] In one embodiment, the third determining module 503 is configured to: determine at least one transform value based on at least one difference in the difference group; determine the quality of the image to be tested based on a comparison result between the at least one transform value and a second threshold; wherein when the at least one transform value is greater than or equal to the second threshold, the quality of the image to be tested is determined to be abnormal, or when the at least one transform value is less than the second threshold, the quality of the image to be tested is determined to be normal.
[0095] In one embodiment, the third determining module 503 is configured to: extract a first sub-block image from the image to be tested; extract a second sub-block image corresponding to the first sub-block image from a reference image; determine a third pixel distribution in the color mode of the first sub-block image; determine a fourth pixel distribution in the color mode of the second sub-block image; determine a second difference between the third pixel distribution and the fourth pixel distribution; and determine the quality of the image to be tested based on the second difference when the image quality has been previously determined to be normal based on the first difference.
[0096] In one embodiment, the second determining module 502 is configured to: acquire a plurality of available reference images; determine the corresponding pixel distribution in the color mode of the plurality of available reference images; calculate the average value of the corresponding pixel distribution; and determine the average value as the second pixel distribution.
[0097] Embodiments of this disclosure also propose an electronic device having a processor-memory architecture. Figure 6 This is an exemplary structural diagram of an electronic device having a processor-memory architecture according to embodiments of the present disclosure. Figure 6 As shown, electronic device 600 includes processor 601, memory 602, and a computer program stored on memory 602 that can run on processor 601. When the computer program is executed by processor 601, a method for determining image quality as described in any of the foregoing items is implemented. Memory 602 can be implemented as various storage media, such as electrically erasable programmable read-only memory (EEPROM), flash memory, programmable programmable read-only memory (PROM), etc. Processor 601 can be implemented as including one or more central processing units (CPUs) or one or more field-programmable gate arrays (FPGAs), wherein the FPGA integrates one or more CPU cores. Specifically, the central processing unit or core can be implemented as a CPU, MCU, DSP, etc.
[0098] It should be noted that not all steps and modules in the above process and structural diagrams are mandatory, and some steps or modules may be omitted as needed. The execution order of each step is not fixed and can be adjusted as required. The division of each module is only for the convenience of describing the functional division used. In actual implementations, modules can be divided into multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or different devices.
[0099] The hardware modules in each implementation scheme can be implemented mechanically or electronically. For example, a hardware module may include specially designed permanent circuitry or logic devices (such as dedicated processors, FPGAs, or ASICs) to perform specific operations. A hardware module may also include programmable logic devices or circuitry (such as general-purpose processors or other programmable processors) temporarily configured by software to perform specific operations. The specific use of mechanical methods can be determined based on cost and time considerations, deciding whether to implement the hardware module with dedicated permanent circuitry or temporarily configured circuitry (such as software configuration).
[0100] The above are merely preferred embodiments of this disclosure and are not intended to limit the scope of protection of this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for determining image quality, the method comprising: Determine (101) the first pixel distribution in the color mode of the image to be tested; Determine (102) a first difference between the first pixel distribution and the second pixel distribution in the color mode of the reference image; and The quality of the image to be tested (103) is determined based on the first difference.
2. The method of claim 1, wherein determining (102) the first difference between the first pixel distribution and the second pixel distribution in the color mode of the reference image comprises: Determine the corresponding pixel distribution of the image under test in the corresponding channel of the color mode; Determine the corresponding pixel distribution of the reference image in the corresponding channel of the color mode; Determine the corresponding difference between the pixel distribution of the image to be tested in the corresponding channel and the pixel distribution of the reference image in the corresponding channel; The corresponding differences are grouped into a difference group.
3. The method of claim 2, wherein the channel comprises at least one of the following: Color channels; chroma channels; hue channels; saturation channels; brightness channels; achromatic channels.
4. The method of claim 1, wherein determining (102) the first difference between the first pixel distribution and the second pixel distribution comprises: Determine the dispersion between the first pixel distribution and the second pixel distribution; The first difference is determined based on the dispersion.
5. The method of claim 2, wherein determining the quality of the image to be tested (103) based on the first difference comprises: The quality of the image to be tested is determined based on the comparison result between at least one difference in the difference group and a first threshold. When the at least one difference is greater than or equal to the first threshold, the quality of the image under test is determined to be abnormal, or when the at least one difference is less than the first threshold, the quality of the image under test is determined to be normal.
6. The method according to claim 2, comprising: At least one transformation value is determined based on at least one difference in the group of differences; The quality of the image under test is determined based on the comparison between the at least one transform value and the second threshold. When the at least one transformation value is greater than or equal to the second threshold, the quality of the image under test is determined to be abnormal; or when the at least one transformation value is less than the second threshold, the quality of the image under test is determined to be normal.
7. The method of claim 1, comprising: Extract the first sub-block image from the image to be tested; Extract a second sub-block image corresponding to the first sub-block image from the reference image; Determine the distribution of the third pixel in the color mode of the first sub-block image; Determine the fourth pixel distribution in the color mode of the second sub-block image; Determine the second difference between the third pixel distribution and the fourth pixel distribution; If the image quality has already been determined to be normal based on the first difference, the quality of the image to be tested is determined based on the second difference.
8. The method according to any one of claims 1 to 7, comprising: Obtain multiple available reference images; Determine the corresponding pixel distribution in the color mode of the plurality of available reference images; Calculate the average value of the corresponding pixel distribution; The average value is determined as the second pixel distribution.
9. The method according to any one of claims 1 to 7, wherein the reference image is an image of a workpiece captured by an industrial camera having predetermined camera parameters.
10. The method of claim 9, wherein the image to be tested is a real-time image of the workpiece captured by the industrial camera.
11. The method of claim 10, comprising: When the quality of the real-time image is determined to be normal, a first label indicating that the quality of the real-time image is normal is set for the real-time image; When the quality of the real-time image is determined to be abnormal, a second label indicating the quality abnormality of the real-time image is set for the real-time image; The decision to input the real-time image into the industrial artificial intelligence model is made by identifying whether the label of the real-time image is the first label or the second label.
12. An apparatus for determining image quality, the apparatus comprising: A first determining module (501) is configured to determine a first pixel distribution in the color mode of the image to be tested; A second determining module (502) is configured to determine a first difference between the first pixel distribution and a second pixel distribution in the color mode of the reference image; as well as A third determining module (503) is configured to determine the quality of the image to be tested based on the first difference.
13. An electronic device comprising a processor (601) and a memory (602), wherein an application program executable by the processor (601) is stored in the memory (602) to cause the processor (601) to perform a method for determining image quality according to any one of claims 1 to 11.
14. A computer-readable medium comprising computer-readable instructions stored thereon, wherein the computer-readable instructions are configured to perform a method for determining image quality according to any one of claims 1 to 11.
15. A computer program product comprising a computer program, which, when executed by a processor, performs a method for determining image quality according to any one of claims 1 to 11.