Image detection method and device

By dividing the image to be detected into multiple macroblocks, and calculating its pixel mean and variance, the problems of low image detection efficiency and bad point aggregation in the prior art are solved, and fast and high-precision image detection is achieved.

CN114782331BActive Publication Date: 2025-05-13SHANGHAI MIHA YOUHAIYUANCHENG TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210348101.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-29
Publication Date
2025-05-13
Estimated Expiration
2042-03-29

AI Technical Summary

Technical Problem

In the prior art, during the video picture rendering process, decoder exceptions or rendering exceptions cause the image to be inconsistent with the original image, and the pixel-by-pixel scanning method is time-consuming and the gathering of bad points cannot be effectively avoided, resulting in low recognition accuracy.

Method used

The image to be detected is divided into multiple macroblocks, the pixel mean and variance of each macroblock are calculated, and whether the macroblock is valid is determined based on the comparison result of the mean and variance and the set threshold value, and the validity of the image to be detected is determined.

Benefits of technology

Through macroblock division and parallel computing, the calculation speed is significantly improved, processing delay is reduced, and bad point aggregation problem is effectively avoided, and detection accuracy is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114782331B_ABST
    Figure CN114782331B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of electronic information, and specifically discloses an image detection method and device. The method comprises: dividing the image to be detected into multiple macroblocks; calculating the pixel mean of each macroblock, comparing the pixel mean of each macroblock with the mean threshold, judging whether each macroblock is a valid macroblock according to the mean comparison result, and obtaining the initial judgment result of each macroblock; calculating the pixel variance of each macroblock, comparing the pixel variance of each macroblock with the variance threshold, judging whether each macroblock is a valid macroblock according to the variance comparison result, and obtaining the secondary judgment result of each macroblock; determining whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock. The method in the present invention takes the macroblock as the minimum detection object, so as to effectively avoid the problem of bad pixel aggregation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of electronic information, and in particular to an image detection method and device. Background Art

[0002] At present, during the rendering process of the video screen, if the decoder is abnormal, the decoded image will be inconsistent with the original image. For example, if the original image is a black image, but if the decoder is abnormal, it will cause visible mottled spots (such as white spots) on the black image. In addition, even if the decoder is normal, during the rendering process of the decoded image, the rendered image may be inconsistent with the original image due to rendering abnormalities.

[0003] In order to solve the above problems, it is necessary to check the image and determine whether the image to be detected is consistent with the original image based on the inspection results. In the related art, it is necessary to scan the image to be detected pixel by pixel to determine whether the pixel value of each pixel is consistent with the original image based on the scanning results. If the pixel value of a pixel is inconsistent with the original image, the pixel is judged as a bad pixel. After scanning the entire image, the proportion of bad pixels in the entire image is calculated, and whether the image to be detected is consistent with the original image is determined based on whether the proportion of bad pixels exceeds a certain threshold.

[0004] However, the inventors found that the above method has at least the following defects in the process of implementing the present invention: on the one hand, the method of scanning the entire image pixel by pixel requires a lot of processing time, resulting in low processing efficiency. On the other hand, the method of calculating the bad pixel ratio for the entire image cannot effectively avoid the problem of bad pixel aggregation, and leads to low recognition accuracy. Summary of the invention

[0005] In view of the above problems, the present invention is proposed to provide an image detection method and device that overcome the above problems or at least partially solve the above problems.

[0006] According to one aspect of the present invention, there is provided an image detection method, the method comprising:

[0007] Divide the image to be detected into multiple macroblocks;

[0008] Calculate the pixel mean of each macroblock, compare the pixel mean of each macroblock with the mean threshold, determine whether each macroblock is a valid macroblock based on the mean comparison result, and obtain the initial determination result of each macroblock;

[0009] Calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, determine whether each macroblock is a valid macroblock based on the variance comparison result, and obtain a secondary determination result of each macroblock;

[0010] Whether the image to be detected is a valid image is determined according to the initial determination results of the macroblocks and the secondary determination results of the macroblocks.

[0011] According to another aspect of the present invention, there is provided an image detection device, the device comprising:

[0012] A division module, adapted to divide the image to be detected into a plurality of macroblocks;

[0013] The mean value judgment module is adapted to calculate the pixel mean value of each macroblock, compare the pixel mean value of each macroblock with the mean value threshold value, judge whether each macroblock is a valid macroblock according to the mean value comparison result, and obtain the initial judgment result of each macroblock;

[0014] A variance judgment module is adapted to calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, judge whether each macroblock is a valid macroblock according to the variance comparison result, and obtain a secondary judgment result of each macroblock;

[0015] The detection module is adapted to determine whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock.

[0016] According to another aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;

[0017] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the above method.

[0018] According to another aspect of the embodiments of the present invention, a computer storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables a processor to execute the above method.

[0019] In the image detection method and device provided by the present invention, by dividing the video image into multiple macroblocks, the pixel mean and pixel variance of each macroblock can be quickly calculated in units of macroblocks, so as to quickly determine whether the pixel value of each macroblock is normal. Compared with the pixel-by-pixel judgment method, since the calculation process between each macroblock can be implemented in parallel, the calculation speed can be greatly improved and the processing delay can be reduced. In addition, compared with the method of calculating the bad pixel ratio for the entire image, the method in the present invention uses the macroblock as the minimum detection object, and therefore can effectively detect the bad pixels that appear continuously in the macroblock (because the number of pixels contained in the macroblock is smaller, the bad pixel detection is more accurate), thereby effectively avoiding the problem of bad pixel aggregation.

[0020] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0022] Figure 1 A flowchart of an image detection method provided by an embodiment of the present invention is shown;

[0023] Figure 2 A flowchart of an image detection method provided by another embodiment of the present invention is shown;

[0024] Figure 3 A schematic diagram showing a macroblock division method of an image to be detected;

[0025] Figure 4 A schematic structural diagram of an image detection device provided by another embodiment of the present invention is shown;

[0026] Figure 5 A schematic structural diagram of an electronic device provided by yet another embodiment of the present invention is shown. DETAILED DESCRIPTION

[0027] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0028] Figure 1 FIG. 1 is a flow chart of an image detection method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0029] S110: Divide the image to be detected into multiple macroblocks.

[0030] The image to be detected includes: video image frames, static images and other types of images output to the display screen after being rendered by the graphics card. Since the image to be detected contains multiple pixels, the pixel-by-pixel serial calculation method will take a lot of time. To this end, in this embodiment, the video image to be detected is first divided into multiple macroblocks, so that the pixel mean of each macroblock is calculated in parallel in units of macroblocks. There can be multiple macroblock division methods, and those skilled in the art can flexibly set the macroblock division step size and macroblock size according to the accuracy requirements in the actual scene.

[0031] S120: Calculate the pixel mean of each macroblock, compare the pixel mean of each macroblock with the mean threshold, determine whether each macroblock is a valid macroblock based on the mean comparison result, and obtain the initial determination result of each macroblock.

[0032] The pixel mean of a macroblock is determined according to the pixel values ​​of each pixel contained in the macroblock. For example, for any macroblock, the pixel values ​​of each pixel contained in the macroblock are obtained, and the pixel values ​​of each pixel are averaged to obtain the pixel mean of the macroblock. It can be seen that the pixel mean of a macroblock can reflect the average size of the pixel values ​​in the macroblock.

[0033] In addition, the mean threshold is determined based on a standard image corresponding to the image to be detected. The image to be detected is usually an image obtained after decoding and / or rendering operations are performed on the standard image. Accordingly, the standard image corresponding to the image to be detected refers to: the original image before decoding and / or graphics card rendering. According to the color distribution of the standard image, the mean threshold can be set. Accordingly, the pixel mean of each macroblock is compared with the mean threshold, and whether each macroblock is a valid macroblock can be determined based on the mean comparison result, thereby obtaining the initial judgment result of each macroblock.

[0034] S130: Calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, determine whether each macroblock is a valid macroblock according to the variance comparison result, and obtain a secondary determination result of each macroblock.

[0035] Since the initial comparison result between the pixel mean of each macroblock and the mean threshold may have errors due to various reasons, in order to improve the judgment accuracy, the pixel variance of each macroblock is further calculated. The pixel variance of the macroblock is determined according to the pixel values ​​of each pixel contained in the macroblock. For example, for any macroblock, the pixel values ​​of each pixel contained in the macroblock are obtained, and the variance operation is performed on the pixel values ​​of each pixel to obtain the pixel variance of the macroblock. Optionally, the above variance operation can be a mean square error operation. It can be seen that the pixel variance of the macroblock can reflect the degree to which each pixel in the macroblock deviates from the mean. Among them, the variance threshold can also be determined according to the standard image corresponding to the image to be detected. Of course, since the variance is used to reflect the degree to which the actual value of the pixel deviates from the expected value, the variance threshold can also be set to a fixed smaller value, for example, fixed to 5. When the pixel variance of the macroblock is less than 5, the macroblock is determined to be a valid macroblock; otherwise, the macroblock is determined to be an invalid macroblock. A valid macroblock refers to a macroblock whose pixel values ​​match the pixel values ​​at the corresponding position in the standard image, that is, a macroblock without any abnormality in the decoding process and / or rendering process. Similarly, an invalid macroblock refers to a macroblock whose pixel values ​​do not match the pixel values ​​at the corresponding position in the standard image, that is, a macroblock with abnormality in the decoding process and / or rendering process. The calculation process between each macroblock can be implemented in parallel, thereby achieving the purpose of fast calculation.

[0036] S140: Determine whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock.

[0037] Among them, the initial judgment result of each macroblock is used to describe the pixel distribution of each macroblock from the perspective of pixel mean, and the secondary judgment result of each macroblock is used to describe the pixel distribution of each macroblock from the perspective of pixel variance. If both the initial judgment result and the secondary judgment result show that each macroblock is a valid macroblock, the image to be detected is determined to be a valid image. If at least one macroblock is judged to be an invalid macroblock in the initial judgment result or the secondary judgment result, the image to be detected is determined to be an invalid image.

[0038] In the image detection method provided by the embodiment of the present invention, by dividing the video image into a plurality of macroblocks, the pixel mean and pixel variance of each macroblock can be quickly calculated in units of macroblocks, so as to quickly determine whether the pixel value of each macroblock is normal. Compared with the pixel-by-pixel judgment method, since the calculation process between each macroblock can be implemented in parallel, the calculation speed can be greatly improved and the processing delay can be reduced. In addition, compared with the method of calculating the bad pixel ratio for the entire image, the method in the present invention uses the macroblock as the minimum detection object, so that the bad pixels that appear continuously in the macroblock can be effectively detected (because the number of pixels contained in the macroblock is smaller, the bad pixel detection is more accurate), so the problem of bad pixel aggregation can be effectively avoided. In addition, dual judgment can be achieved through the pixel mean and pixel variance, thereby avoiding the problem of inaccurate results caused by judging only according to a single condition, thereby achieving efficient detection.

[0039] Figure 2 FIG. 4 is a flow chart showing an image detection method provided by another embodiment of the present invention. Figure 2 As shown, the method includes:

[0040] S210: Acquire an image to be detected.

[0041] In the process of displaying the video image, the decoder needs to decode the original image to be rendered, and render the decoded image to obtain the image output to the display screen. Accordingly, in this step, the video image to be detected can be an image output to the display screen after being rendered by the graphics card, or it can also be an image obtained after being decoded by the decoder.

[0042] It can be seen that no matter an error occurs in the decoding link or in the rendering link, the image to be detected will be inconsistent with the original image stored in the memory. The original image can also be called a standard image.

[0043] S220: performing grayscale calculation on the original pixel value of each pixel in the image to be detected to obtain the grayscale pixel value of each pixel in the image to be detected.

[0044] The grayscale information of the image can be used to quickly identify whether the image is abnormal. Therefore, in this embodiment, in order to improve processing efficiency, grayscale calculation is performed on the original pixel value of each pixel in the image to be detected to obtain the grayscale pixel value of each pixel in the image to be detected. Among them, the image to be detected contains multiple pixels, and the original pixel value of each pixel is usually a color pixel value stored in an RGB three-channel manner. The grayscale pixel value of each pixel can be obtained by performing grayscale calculation through a grayscale algorithm. Since the grayscale pixel value only describes the image features through grayscale information and does not contain color information, the amount of data processing can be greatly reduced. In addition, the interference of other colors can be removed through grayscale calculation, and the calculation accuracy can be improved in the scene where the standard image is a solid color image.

[0045] It should be noted that step S220 is an optional step. In other embodiments of the present invention, if the real-time calculation requirement is not high, or the standard image is not a solid color image, step S220 can be omitted, and the pixel mean and pixel variance can be directly calculated based on the original pixel value of each pixel. The present invention does not limit this.

[0046] S230: Divide the image to be detected into a plurality of macroblocks according to a first division method.

[0047] For example, the image to be detected can be divided into multiple 4x4 or 8x8 macroblocks. Among them, a 4x4 macroblock contains 16 pixels, and an 8x8 macroblock contains 64 pixels. Among them, the larger the macroblock size, the fewer macroblocks are obtained by division, and accordingly, the longer the calculation time of a single macroblock is, and the fewer the number of calculation threads required; the smaller the macroblock size, the more macroblocks are obtained by division, and accordingly, the shorter the calculation time of a single macroblock is, and the more the number of calculation threads required is. Those skilled in the art can flexibly determine the macroblock division method according to the delay requirements and the performance of the hardware equipment. For example, when the user has high real-time requirements and the system performance is good, the macroblock size can be reduced to divide more macroblocks, and the processing efficiency can be greatly improved through parallel computing.

[0048] In addition, the macroblock division method is not only related to the calculation time and device performance, but also to the calculation accuracy: the smaller the macroblock is, the easier it is to detect abnormal pixels in the smaller macroblock. Therefore, the macroblock size can be flexibly set according to the detection accuracy requirements.

[0049] S240: Calculate the pixel mean of each macroblock in parallel, compare the pixel mean of each macroblock with the mean threshold, determine whether each macroblock is a valid macroblock based on the mean comparison result, and obtain the initial determination result of each macroblock.

[0050] For example, taking a 4x4 macroblock as an example, for each macroblock, the pixel value of each pixel contained in the macroblock is obtained. In this embodiment, the pixel value is a grayscale pixel value. Of course, in other embodiments, the pixel value can also be an original pixel value. Accordingly, the values ​​of each pixel value (such as grayscale pixel value) are accumulated and summed, and divided by the number of pixels (such as 16), to obtain the pixel mean value of the macroblock.

[0051] In order to achieve the purpose of parallel computing, in this embodiment, a computing thread is allocated to each macroblock, and the computing threads corresponding to each macroblock are managed based on a thread pool, so as to achieve parallel computing through multithreading. It can be seen that this method is based on the thread pool technology, and the pixel mean and pixel variance of each macroblock are calculated in parallel, achieving high concurrency.

[0052] In this embodiment, the image to be detected is an image output to the display screen after being rendered by a graphics card, and the mean threshold and the variance threshold are set in the following manner: a standard image corresponding to the image to be detected is obtained, and the mean threshold and the variance threshold are set according to the image features of the standard image. In the application scenario of this embodiment, the image features of the standard image are pure color features, and accordingly, the mean thresholds corresponding to each macroblock are equal, and the variance thresholds corresponding to each macroblock are equal.

[0053] For example, assuming that the standard image is a pure black image, and the gray value corresponding to black is 0, the mean threshold can be set to 10 or 15. Correspondingly, if the pixel mean of the macroblock is less than the mean threshold, the macroblock is considered to be a valid macroblock (i.e., a correctly rendered pure black image); if the pixel mean of the macroblock is greater than the mean threshold, the macroblock is considered to be an invalid macroblock (containing noise pixels).

[0054] For another example, assuming that the standard image is a pure white image, the grayscale value corresponding to white is 255, and the mean threshold can be set to 240. Correspondingly, if the pixel mean of the macroblock is greater than the mean threshold, the macroblock is considered to be a valid macroblock (that is, a correctly rendered pure white image); if the pixel mean of the macroblock is less than the mean threshold, the macroblock is considered to be an invalid macroblock (containing noise pixels).

[0055] Figure 3 A schematic diagram of a macroblock division method of an image to be detected is shown. Figure 3 Each square in corresponds to a pixel in the image to be detected. Figure 3 Take an image of 8*8 pixels as an example for schematic illustration. Figure 3 The image in is divided into four 4*4 macroblocks. The four macroblocks are: the first macroblock at the upper left corner of the image, the second macroblock at the upper right corner, the third macroblock at the lower left corner, and the fourth macroblock at the lower right corner, and each macroblock contains 16 pixels in total.

[0056] When the image feature is a pure color feature, the mean value thresholds corresponding to each macroblock are equal. In actual situations, there may be a situation where the pixel mean of a part of the macroblocks matches the threshold range of the mean value threshold, and the pixel mean of another part of the macroblocks does not match the threshold range of the mean value threshold, that is, some macroblocks are valid macroblocks, while some macroblocks are invalid macroblocks. In the method of this embodiment, as long as there are invalid macroblocks, the calculation is terminated and the image to be detected is directly determined to be an invalid image. In other words, only when all macroblocks are valid macroblocks, the subsequent steps are executed. Otherwise, as long as there is an invalid macroblock, the image to be detected is directly determined to be an invalid image.

[0057] S250: Calculate the pixel variance of each macroblock in parallel, compare the pixel variance of each macroblock with the variance threshold, determine whether each macroblock is a valid macroblock according to the variance comparison result, and obtain a secondary determination result of each macroblock.

[0058] Among them, whether each macroblock is a valid macroblock is determined according to the preliminary judgment result of each macroblock. If there is no invalid macroblock, this step is executed; if there is at least one invalid macroblock, the image to be detected is directly determined to be an invalid image.

[0059] For each macroblock, the pixel value (e.g., grayscale pixel value) of each pixel in the macroblock is obtained, and the pixel value of each pixel is subjected to variance operation to obtain the pixel variance of each macroblock. The pixel variance of the macroblock is used to reflect the degree to which the pixel value of each pixel in the macroblock deviates from the expected value. The smaller the variance, the smaller the degree to which each pixel in the macroblock deviates from the expected value. Optionally, the variance operation can be a mean square error operation, and accordingly, the pixel variance of the macroblock can reflect the degree to which the pixel value of each pixel in the macroblock deviates from the mean value.

[0060] Among them, when the image feature is a pure color image feature, the variance thresholds corresponding to each macroblock are equal. Regardless of whether the standard image is a pure black image or a pure white image, the variance threshold can be set to 5. Correspondingly, if the pixel variance of the macroblock is less than 5, it means that the macroblock does not contain pixels with obviously abnormal pixel values, thereby determining that the macroblock is a valid macroblock; if the pixel variance of the macroblock is greater than 5, it means that the macroblock contains pixels with obviously abnormal pixel values, thereby determining that the macroblock is an invalid macroblock. Among them, in this embodiment, the pixel mean and the pixel variance are determined according to the grayscale pixel value of each pixel; and the mean threshold is the macroblock grayscale mean threshold, and the variance threshold is the macroblock grayscale variance threshold.

[0061] S260: Determine whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock.

[0062] Among them, whether each macroblock is a valid macroblock is determined according to the secondary judgment result of each macroblock. If there is no invalid macroblock, the image to be detected is determined to be a valid image; if there is at least one invalid macroblock, the image to be detected is determined to be an invalid image.

[0063] This embodiment can effectively improve the judgment accuracy by combining the mean method with the variance method through a secondary judgment method. For a macroblock, it is determined to be a valid macroblock only when it satisfies both the mean judgment condition and the variance judgment condition. Otherwise, it is determined to be an invalid macroblock (also called a bad block). When an image contains at least one invalid macroblock, the image is determined to be an invalid image. Among them, the invalid image may be an image with decoding errors or rendering errors, specifically refers to an image that is inconsistent with the standard image.

[0064] In order to facilitate understanding of the advantages of the present invention, Figure 3 Take this as an example for detailed description:

[0065] In the prior art, Figure 3 For the image to be detected shown, it is necessary to determine pixel by pixel whether the pixel value of each pixel is greater than a preset threshold. For example, if the standard image corresponding to the image to be detected is a pure black image, it is necessary to determine whether the grayscale pixel value of each pixel is greater than a preset threshold (for example, 15). If not, the pixel is determined to be a normal pixel; if so, the pixel is determined to be an abnormal pixel (also called a bad pixel). Finally, the proportion of abnormal pixels in the entire image is calculated. If the proportion of abnormal pixels in the entire image is greater than the preset ratio threshold, the image is determined to be an invalid image. Among them, an invalid image refers to: an image that is inconsistent with the original image to be decoded or rendered (i.e., the standard image), that is, an image with decoding errors or rendering errors. A valid image refers to: an image that is consistent with the original image to be decoded or rendered, that is, an image that is decoded correctly or rendered correctly.

[0066] Since the prior art compares the pixel values ​​of each pixel with the preset threshold one by one, the pixel-by-pixel comparison method is relatively time-consuming. In addition, the final calculation is the proportion of abnormal pixels in the entire image. Therefore, if multiple abnormal pixels are clustered together, although the multiple abnormal pixels clustered together appear to be mottled visually, that is, the color does not conform to the standard image, it should be judged as an invalid image. However, when the method in the prior art is adopted, since the number of pixels contained in the entire image is large, the proportion of multiple abnormal pixels clustered together may not exceed the preset ratio threshold, thereby misjudging the image to be detected as a valid image, resulting in an erroneous judgment.

[0067] For example, in Figure 3In the figure, pixel 01, pixel 02, pixel 03, and pixel 04 are four bad pixels, i.e., visually perceptible noise pixels due to decoding errors or rendering errors. In the prior art, the entire image contains 64 pixels in total. Therefore, the four bad pixels account for 6% of the entire image. If the preset ratio threshold is 10%, the image is misjudged as a valid image because the bad pixel ratio is less than the preset ratio threshold. However, in fact, the image is an image with rendering errors that are perceptible to the naked eye and should actually be an invalid image. In addition, Figure 3 The image in the example only uses 64 pixels. In reality, the pixels in the image are usually 1024*768. Therefore, under the premise that the number of pixels contained in the entire image is huge, a small number of abnormal pixels account for a very low proportion and are difficult to be detected by the above method.

[0068] It can be seen that the cause of the above problem is that when the detection object is the entire image, due to the large detection range, a small number of abnormal pixels only account for a small proportion of the entire image, and are therefore easily submerged in the entire image and cannot be effectively detected.

[0069] The macroblock-based detection method in the present invention can better avoid the above problems. Since the minimum detection object of the macroblock detection method is a macroblock rather than the entire image, the range of the detection object is smaller, and a small number of abnormal pixels will occupy a larger proportion in the small range of the macroblock, and thus are easier to detect.

[0070] It can be seen that the macroblock-based detection method in the present invention has at least the following two advantages: on the one hand, by dividing the macroblocks, parallel computing can be achieved and processing efficiency can be improved; on the other hand, by dividing the macroblocks, the minimum detection object can be reduced, thereby facilitating the amplification of abnormal pixels and improving detection accuracy.

[0071] In addition, in the detection method based on macroblocks of the present invention, detection is performed by two methods: the pixel mean of the macroblock and the pixel variance of the macroblock (also called pixel mean square error). Among them, the pixel mean of the macroblock can better reflect the average pixel value distribution in the macroblock. In addition, the pixel mean square error of the macroblock can reflect the degree to which each pixel deviates from the mean. If there are pixels with large pixel value deviations in the macroblock, for example, white pixels are mixed in a black image, the pixel variance of the macroblock will increase significantly, thereby exceeding the variance threshold, and then the macroblock will be detected as an invalid macroblock. It can be seen that the present embodiment can efficiently detect abnormal pixels inside the macroblock by means of the variance method. Compared with the method in the prior art, the detection accuracy can be greatly improved. In short, the variance detection method can efficiently identify abnormal pixels inside the macroblock, and is particularly suitable for application scenarios where the standard image is a pure color image. In a pure color image, the pixel values ​​of each pixel are the same. Once the pixel value deviation of a certain pixel is large, it will have a greater impact on the variance calculation result.

[0072] In addition, the inventors found in the process of implementing the present invention that bad pixels tend to cluster at the boundaries of each macroblock, thus affecting the accuracy of the judgment result. Figure 3 Take pixel 01, pixel 02, pixel 03 and pixel 04 in as an example. Pixel 01 is located at the lower right corner of the macroblock in the upper left corner, pixel 02 is located at the lower left corner of the macroblock in the upper right corner, pixel 03 is located at the upper left corner of the macroblock in the lower left corner, and pixel 04 is located at the upper left corner of the macroblock in the lower right corner. It can be seen that the four bad pixels belong to four different macroblocks. Accordingly, when calculating the macroblock mean and macroblock variance for each macroblock, since most of the pixels in each macroblock are normal pixels and only one pixel is an abnormal pixel, the final calculation result of the macroblock may be close to normal. Therefore, it is difficult to accurately identify the problematic macroblocks through the mean threshold or variance threshold, which results in each macroblock being misjudged as a normal and valid macroblock, which in turn leads to the problem of detection error.

[0073] In order to solve the above problem, in this embodiment, at least two macroblock division operations are performed on the video image in a controllable step size manner, and the operations in the above steps are performed on each macroblock obtained after each macroblock division. Only when the initial judgment result and the secondary judgment result determined after each macroblock division show that each macroblock is a valid macroblock, can the video image be determined to be a valid image. In each macroblock division operation, the macroblock division step size and / or macroblock size are different.

[0074] Optionally, when it is determined in step S260 that the image to be detected is a valid image, this embodiment further includes the following step S270:

[0075] Step S270: adjusting the macroblock division method to re-execute the operation of dividing the image to be detected into multiple macroblocks in step S230 and the subsequent steps S240-S260 according to the second division method.

[0076] The first division method and the second division method have different macroblock division step sizes, and / or the first division method and the second division method have different macroblock sizes. According to the re-divided macroblocks, the mean comparison result between the pixel mean of each macroblock and the mean threshold and the variance comparison result between the pixel variance of each macroblock and the variance threshold are recalculated, and whether the video image is a valid image is determined again according to the recalculated mean comparison result and variance comparison result.

[0077] Among them, the method for determining the mean comparison result and the variance comparison result is the same as the method described in S240-S250, the only difference is that the macroblock division method is different, so the pixel mean and pixel variance within each macroblock may vary, which may cause the comparison result to also vary.

[0078] Step S270 may be executed repeatedly for a preset number of times, which may be set based on the accuracy requirements in the application scenario. In this embodiment, since the standard image is a pure color image, the mean threshold and variance threshold of each macroblock set in each comparison process are the same.

[0079] Still Figure 3 For example, after re-dividing the macroblock, at least two pixels among pixel 01, pixel 02, pixel 03 and pixel 04 may be divided into the same macroblock, and accordingly, the pixel mean and pixel variance of the macroblock may change significantly, thereby effectively improving the detection accuracy. More preferably, by re-dividing the macroblock, pixel 01, pixel 02, pixel 03 and pixel 04 may be divided into the same macroblock at the same time. At this time, since a macroblock contains four bad pixels, the pixel mean and pixel variance of the macroblock will change significantly, thereby being detected as an invalid image. It can be seen that after re-dividing the macroblock, the bad pixels originally scattered at the boundaries of each macroblock will be gathered in one macroblock, thereby preventing false detection.

[0080] In addition, Figure 2In the illustrated embodiment, the standard image is a pure color image as an example for explanation. In other embodiments of the present invention, the image feature of the standard image may also be a non-pure color feature. In this case, the mean thresholds corresponding to each macroblock are different, and the variance thresholds corresponding to each macroblock are equal. Among them, the non-pure color feature includes: a color distribution feature that contains multiple pure color areas with different colors and can be fitted by a function. Correspondingly, in this embodiment, when the image to be detected is divided into multiple macroblocks, the pure color sub-areas with the same color in the standard image are determined according to the color distribution characteristics of the standard image, and multiple macroblocks are divided according to the distribution of the pure color sub-areas with the same color, so that the sub-area corresponding to each macroblock in the image to be detected in the standard image is a pure color sub-area. For example, it is assumed that the standard image is an image containing N sub-areas of different colors, wherein each sub-area has a pure color sub-area composed of a single color, and the colors between the sub-areas are different. By setting the macroblock division method, the sub-area corresponding to each macroblock in the standard image is a pure color sub-area, which can facilitate the rapid identification of abnormal pixels in the macroblock by means of pixel variance. It can be seen that in this embodiment, since the color distribution of the standard image shows a certain regularity, the image features of the standard image can be fitted by a function, and accordingly, the mean threshold and variance threshold corresponding to each macroblock can be quickly set by a function fitting method. For example, when the standard image contains a red pure color sub-region 1, a green pure color sub-region 2, and a blue pure color sub-region 3, the macroblock is located inside a sub-region as much as possible to ensure that the area inside a macroblock is a pure color sub-region, that is, a macroblock is not allowed to cross two pure color sub-regions as much as possible, so as to avoid the problem of error amplification when calculating the variance.

[0081] In addition, in another embodiment of the present invention, the standard image is an image that does not present a certain regularity. For this type of image, when obtaining a standard image corresponding to the image to be detected, and setting a mean threshold and a variance threshold according to the image characteristics of the standard image, it can be achieved in the following manner: pre-dividing the standard image into multiple macroblocks, calculating the pixel mean of each macroblock in the standard image and the pixel variance of each macroblock; setting the mean threshold of each macroblock and the variance threshold of each macroblock according to the pixel mean of each macroblock in the standard image and the pixel variance of each macroblock. For example, the mean threshold of each macroblock can be set to the pixel mean of the corresponding macroblock in the standard image, and the variance threshold of each macroblock can be set to the pixel variance of the corresponding macroblock in the standard image. In this manner, since the mean threshold of each macroblock and the variance threshold of each macroblock are pre-calculated and stored offline, the comparison speed in the subsequent detection process can be improved.

[0082] In addition, in the embodiment of the present invention, it is not necessary to store the standard image for realizing the comparison function, and it is only necessary to store the mean threshold and variance threshold corresponding to the standard image offline, thereby reducing the amount of data storage and improving the subsequent calculation efficiency. Moreover, it is not necessary to match the standard image pixel by pixel during the comparison process, thereby reducing the calculation complexity.

[0083] In addition, in other embodiments, the image feature of the standard image may also be a gradient color image feature. The so-called gradient color image feature means that the grayscale color of each area of ​​the image presents a gradient rule, for example, the grayscale value of each area increases or decreases from left to right, or increases or decreases from top to bottom. In the case where the image feature of the standard image is a gradient color image feature, the mean threshold corresponding to each macroblock is different, depending on the grayscale distribution of the standard image. For example, the mean threshold corresponding to each macroblock can be calculated by a formula.

[0084] In addition, in other embodiments, the image features of the standard image can also be function fitting features. The so-called function fitting features refer to: the distribution of pixel values ​​of the image can be fitted by a function. Among them, at least one parameter of the function represents the position distribution of the pixel points, and the value of the function represents the pixel value of the corresponding pixel point. By reasonably setting the variables, constants and other parameters contained in the function, the features of the invalid image can be fitted by a function. Among them, the gradient color image feature belongs to a specific case included in the function fitting feature. In addition to the gradient color image feature, the function fitting feature can also describe other standard images with certain mathematical laws, such as a standard image containing multiple squares and the color distribution of each square showing a certain regularity. It can be seen that when the image feature is a function fitting feature, the mean threshold and variance threshold corresponding to each macroblock can be quickly set with the help of the fitting function.

[0085] In summary, the image detection method in the embodiment of the present invention can reduce the minimum object to be detected by macroblock method, thereby improving the detection accuracy, and can flexibly adjust the macroblock division method by controllable step size method to prevent the problem of false detection caused by bad pixel aggregation and the boundary of each macroblock. In addition, by combining mean comparison and variance comparison, abnormal pixels can be quickly found, and the variance comparison method is particularly suitable for the detection of pure color images.

[0086] In addition, in this embodiment, as long as one macroblock is judged as an invalid macroblock in one judgment process, the calculation can be terminated in advance without waiting for the two judgment processes of all macroblocks to be completed. Therefore, compared with the whole picture comparison method in the prior art, the judgment can be terminated in advance and the judgment efficiency is improved.

[0087] Figure 4 An image detection device provided by another embodiment of the present invention is shown, comprising:

[0088] A division module 41, adapted to divide the image to be detected into a plurality of macroblocks;

[0089] The mean value judgment module 42 is adapted to calculate the pixel mean value of each macroblock, compare the pixel mean value of each macroblock with the mean value threshold value, judge whether each macroblock is a valid macroblock according to the mean value comparison result, and obtain the initial judgment result of each macroblock;

[0090] A variance judgment module 43 is adapted to calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, judge whether each macroblock is a valid macroblock according to the variance comparison result, and obtain a secondary judgment result of each macroblock;

[0091] The detection module 44 is adapted to determine whether the image to be detected is a valid image according to the initial determination result of each macroblock and the secondary determination result of each macroblock.

[0092] Optionally, the image to be detected is an image obtained after decoding and / or rendering operations are performed on a standard image, and the mean threshold and the variance threshold are set according to image features of the standard image, then the valid image is an image that matches the standard image.

[0093] Optionally, when the image feature of the standard image is a pure color feature, the mean thresholds corresponding to the macroblocks are equal, and the variance thresholds corresponding to the macroblocks are equal;

[0094] When the image feature of the standard image is a non-pure color feature, the mean thresholds corresponding to the macroblocks are different, and the variance thresholds corresponding to the macroblocks are equal;

[0095] Among them, the non-pure color features include: color distribution features that contain multiple pure color sub-regions of different colors and can be fitted by a function, and the division module is specifically suitable for: determining the pure color sub-region in the standard image according to the color distribution characteristics of the standard image, and dividing the multiple macroblocks according to the distribution status of the pure color sub-region, so that the sub-region corresponding to each macroblock in the image to be detected in the standard image is a pure color sub-region.

[0096] Optionally, the mean threshold and the variance threshold are set in the following manner:

[0097] Dividing the standard image into a plurality of macroblocks in advance, and calculating the pixel mean and pixel variance of each macroblock in the standard image;

[0098] According to the pixel mean of each macroblock and the pixel variance of each macroblock in the standard image, the mean threshold of each macroblock and the variance threshold of each macroblock are set.

[0099] Optionally, the division module is specifically adapted to: divide the image to be detected into a plurality of macroblocks according to a first division method; and the device further comprises:

[0100] The adjustment module is adapted to adjust the macroblock division method so as to re-execute the operation of dividing the image to be detected into a plurality of macroblocks and subsequent operations according to the second division method.

[0101] The specific structure and working principle of each of the above modules can be referred to the description of the corresponding part of the method embodiment, which will not be repeated here.

[0102] Another embodiment of the present application provides a non-volatile computer storage medium, which stores at least one executable instruction, which can execute the object loading method in the virtual scene in any of the above method embodiments. The executable instruction can be specifically used to enable the processor to execute the corresponding operations in the above method embodiments.

[0103] Figure 5 A schematic structural diagram of an electronic device according to another embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.

[0104] like Figure 5 As shown, the electronic device may include: a processor (processor) 502 , a communication interface (Communications Interface) 506 , a memory (memory) 504 , and a communication bus 508 .

[0105] in:

[0106] The processor 502 , the communication interface 506 , and the memory 504 communicate with each other via a communication bus 508 .

[0107] The communication interface 506 is used to communicate with other devices such as clients or other servers.

[0108] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above-mentioned image detection method embodiment.

[0109] Specifically, the program 510 may include program codes, which include computer operation instructions.

[0110] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs. They may also be processors of different types, such as one or more CPUs and one or more ASICs.

[0111] The memory 504 is used to store the program 510. The memory 504 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0112] The program 510 may be specifically used to enable the processor 502 to execute the corresponding operations in the above-mentioned image detection method embodiment.

[0113] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.

[0114] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0115] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0116] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0117] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.

[0118] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the apparatus according to an embodiment of the present invention. The present invention may also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0119] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

Claims

1. An image detection method, the method comprising: Divide the image to be detected into multiple macroblocks; Calculate the pixel mean of each macroblock, compare the pixel mean of each macroblock with the mean threshold, determine whether each macroblock is a valid macroblock based on the mean comparison result, and obtain the initial determination result of each macroblock; Calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, determine whether each macroblock is a valid macroblock based on the variance comparison result, and obtain a secondary determination result of each macroblock; According to the initial judgment results of each macroblock and the secondary judgment results of each macroblock, determine whether the image to be detected is a valid image; wherein, the image to be detected is an image obtained after decoding operation and / or rendering operation is performed on a standard image, and the mean threshold and the variance threshold are set according to the image characteristics of the standard image, then the valid image is an image that matches the standard image; wherein, when the image characteristics of the standard image are pure color characteristics, the mean thresholds corresponding to each macroblock are equal, and the variance thresholds corresponding to each macroblock are equal; when the image characteristics of the standard image are non-pure color characteristics, the mean thresholds corresponding to each macroblock are different, and the variance thresholds corresponding to each macroblock are equal.

2. The method according to claim 1, wherein: The non-pure color features include: color distribution features that include multiple pure color sub-regions of different colors and can be fitted by a function, and dividing the image to be detected into multiple macroblocks includes: determining the pure color sub-regions in the standard image according to the color distribution features of the standard image, and dividing the multiple macroblocks according to the distribution status of the pure color sub-regions, so that the sub-region corresponding to each macroblock in the image to be detected in the standard image is a pure color sub-region.

3. The method according to claim 1, wherein: The mean threshold and the variance threshold are set in the following manner: Dividing the standard image into a plurality of macroblocks in advance, and calculating the pixel mean and pixel variance of each macroblock in the standard image; According to the pixel mean of each macroblock and the pixel variance of each macroblock in the standard image, the mean threshold of each macroblock and the variance threshold of each macroblock are set.

4. The method according to any one of claims 1 to 3, wherein: The step of dividing the image to be detected into a plurality of macroblocks comprises: Dividing the image to be detected into a plurality of macroblocks according to a first division method; After determining whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock, the method further includes: The macroblock division method is adjusted to re-execute the step of dividing the image to be detected into a plurality of macroblocks and its subsequent steps according to the second division method.

5. The method according to claim 4, wherein: The step of dividing the image to be detected into a plurality of macroblocks comprises: dividing the image to be detected into a plurality of macroblocks in a controllable step size manner; The macroblock division step sizes corresponding to the first division method and the second division method are different, and / or the macroblock sizes corresponding to the first division method and the second division method are different.

6. The method according to any one of claims 1 to 3, wherein: The pixel mean value of the macroblock and the pixel variance of the macroblock are calculated according to the pixel values ​​of each pixel contained in the macroblock; Among them, the pixel value of each pixel contained in the macroblock is a grayscale pixel value; then before dividing the image to be detected into multiple macroblocks, it also includes: performing grayscale calculation on the original pixel value of each pixel in the image to be detected to obtain the grayscale pixel value of each pixel in the image to be detected.

7. The method according to any one of claims 1 to 3, wherein: The calculating of the pixel mean of each macroblock includes: calculating the pixel mean of each macroblock in parallel; and the calculating of the pixel variance of each macroblock includes: calculating the pixel variance of each macroblock in parallel; The parallel computing includes: allocating a computing thread to each macroblock, managing the computing threads corresponding to each macroblock based on a thread pool, so as to realize parallel computing through multi-threading.

8. The method according to any one of claims 1 to 3, wherein: The calculation of the pixel variance of each macroblock includes: Determine whether each macroblock is a valid macroblock according to the preliminary judgment result of each macroblock, and if there is no invalid macroblock, execute the step of calculating the pixel variance of each macroblock; Determining whether the image to be detected is a valid image according to the initial judgment result of each macroblock and the secondary judgment result of each macroblock includes: Whether each macroblock is a valid macroblock is determined according to the secondary judgment result of each macroblock. If there is no invalid macroblock, it is determined that the image to be detected is a valid image.

9. The method according to claim 8, wherein: After determining whether each macroblock is a valid macroblock according to the preliminary judgment result of each macroblock, the method further includes: if there is at least one invalid macroblock, determining that the image to be detected is an invalid image; Furthermore, after determining whether each macroblock is a valid macroblock according to the secondary judgment result of each macroblock, the method further includes: if there is at least one invalid macroblock, determining that the image to be detected is an invalid image.

10. An image detection device, comprising: A division module, adapted to divide the image to be detected into a plurality of macroblocks; The mean value judgment module is adapted to calculate the pixel mean value of each macroblock, compare the pixel mean value of each macroblock with the mean value threshold value, judge whether each macroblock is a valid macroblock according to the mean value comparison result, and obtain the initial judgment result of each macroblock; A variance judgment module is adapted to calculate the pixel variance of each macroblock, compare the pixel variance of each macroblock with the variance threshold, judge whether each macroblock is a valid macroblock according to the variance comparison result, and obtain a secondary judgment result of each macroblock; A detection module, adapted to determine whether the image to be detected is a valid image according to the primary determination result of each macroblock and the secondary determination result of each macroblock; Wherein, the image to be detected is an image obtained after decoding and / or rendering operations are performed on a standard image, and the mean threshold and the variance threshold are set according to the image features of the standard image, then the valid image is an image that matches the standard image; wherein, when the image features of the standard image are pure color features, the mean thresholds corresponding to each macroblock are equal, and the variance thresholds corresponding to each macroblock are equal; when the image features of the standard image are non-pure color features, the mean thresholds corresponding to each macroblock are different, and the variance thresholds corresponding to each macroblock are equal.

11. An electronic device, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the method according to any one of claims 1-9.

12. A computer storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • An image detection method and device

    CN101242542A

  • Image quality evaluation method and device

    CN110443783A