Image detection method, device, electronic device and storage medium
By extracting texture information and color information from the image, generating texture energy maps and color distribution maps, and fusion detection, the problem of low black edge detection accuracy in the existing technology is solved, and higher detection accuracy and application range are achieved.
Patent Information
- Application Number
- CN202011063232.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-30
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-09-30
AI Technical Summary
The existing technology has low accuracy when detecting black edges in video images, is difficult to adapt to the differences in the definition of black in different application scenarios, and is difficult to determine the threshold, resulting in situations where the black edges perceived by the human eye are detected as non-black edges by the algorithm.
By extracting the texture information in the image to generate a texture energy map and color information to generate a color distribution map, and fusing the two for black edge detection, it overcomes the shortcomings of counting the number of black pixels and the sum of squares of pixels.
The accuracy of black edge detection is improved, the detection complexity is reduced, and a higher applicable range and detection accuracy are achieved.
Smart Images

Figure CN112184837B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and further to the field of image processing technology, and in particular to an image detection method, device, electronic device and storage medium. Background Art
[0002] With the development of mobile Internet, the short video industry has developed rapidly. Video producers can shoot with a variety of shooting devices, so the number of short video uploaders is also increasing. Usually, the terminal display platform has certain requirements for the video format. The uploaded video may have black edges due to incompatibility with the format, which will cause poor video quality and affect the viewing experience. Therefore, it is necessary to establish image black edge detection capabilities to determine whether there are black edge images in the video during the material review stage before terminal display; if there are black edge images in the video, the video will not be displayed on the terminal platform.
[0003] In the prior art, the following two methods are usually used to detect black-edge images: (1) Detect black-edge images by counting the number of black pixels: On a grayscale image, determine whether the pixel value of the current pixel is less than a predetermined threshold in the row direction or column direction. If the pixel value of the current pixel is less than the predetermined threshold, the current pixel is determined to be a black pixel; then count the number of black pixels in each row or column; if the number of black pixels in each row is greater than a certain threshold; or if the number of black pixels in each column is greater than a certain threshold, the row or column is a black edge; otherwise, the row or column is not a black edge. (2) Detect black-edge images based on the sum of squares of pixels: Under the premise that a pixel value of zero represents black, calculate the square of the pixel value of the current pixel one by one in the row direction or column direction, and add up the sum of squares of all pixels in the row or column; compare the calculated sum of squares with a certain threshold to determine whether the row or column is a black edge.
[0004] The above method has the following disadvantages: When using the above method 1) to detect black-edge images, theoretically, a pixel value of zero represents black, but the black judged by the human eye in the actual video image is not a fixed pixel, but a pixel range; and different application scenarios have different definitions of black, and the threshold is difficult to determine, which leads to low accuracy in black edge detection; When using the above method 2) to detect black-edge images, since non-black pixels are greater than zero, the distance between non-black pixels close to black pixels can be further increased by the square sum method. However, since the black judged by the human eye is not a fixed pixel, but a pixel range. If the pixel value is forcibly set to zero to represent black, the black judged by the human eye will also participate in the square sum calculation, resulting in the square sum increase to meet the threshold, and the black edge perceived by the human eye is detected as a non-black edge by the algorithm, which will also lead to the problem of low detection accuracy. Summary of the invention
[0005] The present application provides an image detection method, device, electronic device and storage medium, which can effectively improve the accuracy of black edge detection and reduce the complexity of black edge detection.
[0006] In a first aspect, the present application provides an image detection method, the method comprising:
[0007] Extracting texture information from the image to be detected, and generating a texture energy map corresponding to the image to be detected based on the texture information;
[0008] Extracting color information from the image to be detected, and generating a color distribution map corresponding to the image to be detected based on the color information;
[0009] Based on the texture energy map and the color distribution map, it is detected whether the image to be detected has a black edge.
[0010] In a second aspect, the present application provides an image detection device, the device comprising: a texture energy map generation module, a color distribution map generation module and a detection module; wherein,
[0011] The texture energy map generation module is used to extract texture information from the image to be detected, and generate a texture energy map corresponding to the image to be detected based on the texture information;
[0012] The color distribution map generating module is used to extract color information from the image to be detected, and generate a color distribution map corresponding to the image to be detected based on the color information;
[0013] The detection module is used to detect whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] A storage device for storing one or more programs;
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the image detection method described in any embodiment of the present application.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the image detection method described in any embodiment of the present application is implemented.
[0019] The embodiments of the present application provide an image detection method, device, electronic device, and storage medium, which generate a texture energy map based on image texture information and a color distribution map based on image color information, and detect whether there are black edges in the image to be detected by fusing the texture energy map and the color distribution map. The embodiments of the present application can effectively improve the accuracy of black edge detection and reduce the complexity of black edge detection.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0022] Figure 1 It is a first flow chart of the image detection method provided in an embodiment of the present application;
[0023] Figure 2 is a second flow chart of the image detection method provided in an embodiment of the present application;
[0024] Figure 3 is a third flow chart of the image detection method provided in an embodiment of the present application;
[0025] Figure 4 is a fourth flow chart of the image detection method provided in an embodiment of the present application;
[0026] Figure 5 is a schematic diagram of the structure of an image detection device provided in an embodiment of the present application;
[0027] Figure 6 It is a block diagram of an electronic device used to implement the image detection method of an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0029] Embodiment 1
[0030] Figure 11 is a first flow chart of the image detection method provided by the embodiment of the present application. The method can be executed by an image detection device or electronic device. The device or electronic device can be implemented by software and / or hardware. The device or electronic device can be integrated in any smart device with network communication function. Figure 1 As shown, the image detection method may include the following steps:
[0031] S101 . Extracting texture information from an image to be detected, and generating a texture energy map corresponding to the image to be detected based on the texture information.
[0032] In a specific embodiment of the present application, the image to be detected may be a single image or each frame of an image in a video. Image texture is a visual feature that reflects homogeneous phenomena in an image, and is expressed by the grayscale distribution of pixels and their surrounding spatial neighborhoods. Image texture information reflects the surface structure organization and arrangement properties of the surface of an object in the image that have slow or periodic changes. The texture information of the image is extracted from the image to be detected, and a texture energy map corresponding to the image to be detected is generated based on the texture information. Among them, the texture energy map of the image is generated by a certain image processing technology, which can be used for quantitative or qualitative description of the image texture. Exemplarily, if a video image has a black-bordered area, correspondingly, the texture information of the black-bordered area is very little. If the image texture information at a certain position in the video image is richer, the position is a non-black-bordered position; if the image texture information at a certain position in the video image is less, the position is a black-bordered position.
[0033] S102: extracting color information from the image to be detected, and generating a color distribution map corresponding to the image to be detected based on the color information.
[0034] In a specific embodiment of the present application, compared with other visual features, color features are less dependent on the size, direction, and viewing angle of the image itself, and have higher robustness. Therefore, the color information of the image is the most widely used visual feature in image detection. Color information is extracted from the image to be detected. Optionally, the expression mode of color information can be RGB color space, CMY color space, LAB color space, HSV color space, HSL color space, etc. Among them, the digital image color information is presented in RGB color space. A color distribution map corresponding to the image to be detected is generated based on the color information of the image. The color distribution map can be used to reflect the statistical distribution and basic tone of the image color.
[0035] S103 , based on the texture energy map and the color distribution map, detecting whether the image to be detected has a black edge.
[0036] In a specific embodiment of the present application, a fusion feature is obtained by fusing texture information and color information, and then the black edge position information is obtained through the contour information of the fusion feature, and finally it is determined whether to display the video image. Optionally, the basis for determining whether to display the video image can be the ratio of the black edge area to the size of the video image surface.
[0037] The technical solution provided by this embodiment first extracts texture information from the image to be detected, and generates a texture energy map corresponding to the image to be detected based on the texture information; then extracts color information from the image to be detected, and generates a color distribution map corresponding to the image to be detected based on the color information; then detects whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map. That is to say, the present application can generate a texture energy map and a color distribution map for the image to be detected, and then perform black edge detection based on the texture energy map and the color distribution map. In the existing image detection method, the black edge image is detected by counting the number of black pixels or based on the square sum of pixels, and the detection accuracy is low. Because the present application adopts the technical means of generating a texture energy map and a color distribution map for the image to be detected, and then performing black edge detection based on the texture energy map and the color distribution map, it overcomes the technical problem of low detection accuracy caused by counting the number of black pixels or based on the square sum of pixels in the prior art. The technical solution provided by the present application not only effectively improves the accuracy of black edge detection, but also reduces the complexity of black edge detection; and the technical solution of the embodiment of the present application is simple and convenient to implement, easy to popularize, and has a wider range of application.
[0038] Embodiment 2
[0039] Figure 2 1 is a second flow chart of the image detection method provided in the embodiment of the present application. The embodiment of the present application is optimized on the basis of the above embodiment. Optionally, the present embodiment provides a detailed explanation of the texture energy map generation process. Figure 2 As shown, the image detection method provided in this embodiment includes but is not limited to the following steps:
[0040] S201, calculating the horizontal gradient and the vertical gradient of the image to be detected.
[0041] In a specific embodiment of the present application, the preset method is a preset method for calculating the image gradient. Optionally, the gradient of a certain point can be obtained by forward difference quotient, backward difference quotient or center difference quotient method. The image can be regarded as a two-dimensional discrete function, and the image gradient is actually the derivative of this two-dimensional discrete function. The gradient of the image in the horizontal direction represents the rate of change of the image pixel value in the horizontal direction; the gradient of the image in the vertical direction represents the rate of change of the image pixel value in the vertical direction.
[0042] S202 , calculating the texture energy value of each pixel in the image to be detected according to the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction, and the pixel value of each pixel in the image to be detected.
[0043] In a specific embodiment of the present application, the electronic device can calculate the texture energy value of each pixel in the image to be detected based on the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction, and the pixel value of each pixel in the image to be detected. Exemplarily, the electronic device can use a gradient template to calculate the gradient of the image to be detected.
[0044]
[0045]
[0046] Among them, represents the horizontal gradient template; represents the vertical gradient template.
[0047] Next, the electronic device can calculate the gradient of the image to be detected, and the formula is as follows:
[0048] G x =X*I
[0049] G y =Y*I
[0050] Among them, G x Represents the horizontal gradient; G y Represents the vertical gradient; represents the pixel value of each pixel in the image to be detected.
[0051] It can be understood that the texture energy value of each pixel in the image to be detected can be calculated, and the formula is as follows:
[0052] E(i,j)=|G x (i,j)|+|G y (i,j)|
[0053] Where E(i,j) represents the texture energy value of the pixel with row i and column j in the image to be detected; G x (i,j) represents the horizontal gradient of pixel i and pixel j in row i and column j in the image to be detected; G y (i,j) represents the vertical gradient of the pixel at row i and column j in the image to be detected.
[0054] S203 , obtaining a texture energy map corresponding to the image to be detected according to the texture energy value of each pixel point in the image to be detected.
[0055] In a specific embodiment of the present application, the texture energy value of each pixel in the image to be detected can be obtained according to the above steps, and the electronic device can obtain a texture energy map corresponding to the image to be detected. Each point value in the texture energy map represents the intensity of the texture information contained in the point. Exemplarily, if the texture intensity value of a pixel is smaller, the less texture information contained in the pixel, the greater the probability that the pixel is a black pixel; if the texture intensity value of a pixel is larger, the more texture information contained in the pixel, the greater the probability that the pixel is a non-black pixel.
[0056] Preferably, before generating the texture energy map of the image to be detected, the image may be preprocessed. The advantage of preprocessing the image to be detected is that it can not only reduce the interference of noise, but also better maintain the edge contour details.
[0057] Optionally, the preprocessing algorithm may be a median filtering algorithm with a filter window size of 3×3.
[0058] Further, in response to the presence of at least one isolated point noise in the texture energy map, based on a predetermined erosion operator window and a dilation operator window, at least one isolated point noise is removed from the texture energy map to obtain a texture energy map after the isolated point noise is removed. Since different shooting devices are used to shoot videos, the quality of the generated video images is also different. Therefore, it is difficult to avoid the phenomenon that the video image has noise. The presence of noise will interfere with the positioning of black edges. If it is not processed, the accuracy of black edge detection will be low. In a specific embodiment of the present application, before generating a texture energy map of the image to be detected, the electronic device can preprocess the image to reduce the interference of noise. In addition, if there is isolated point noise in the texture energy map of the generated image to be detected, the electronic device can use an image morphological algorithm to remove the isolated point noise. For example: the electronic device can adopt an algorithm of first corrosion and then expansion. That is, the isolated point noise is first removed based on the erosion operator window, and then the isolated point noise is removed based on the dilation operator window. Optionally, the size of the erosion operator window is 3×3, and the window of the dilation operator is 3×3. After removing the isolated point noise from the texture energy map, a texture energy map after the isolated point noise is removed is obtained.
[0059] Preferably, the electronic device can also extract a pixel point as the current pixel point in the texture energy map after removing isolated point noise; in response to the texture energy value corresponding to the current pixel point being greater than or equal to a preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as the first texture energy value; in response to the texture energy value corresponding to the current pixel point being less than a preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as the second texture energy value; and the above operations are repeated until the texture energy value corresponding to each pixel point in the texture energy map after removing isolated point noise is taken as the first texture energy value or the second texture energy value.
[0060] In a specific embodiment of the present application, if there is noise in a video image to be detected, it is difficult to set a reasonable threshold for determining the black edge of the video image. After removing isolated point noise from the texture energy map of the image through the above steps, a suitable texture energy threshold can be set. The texture energy value corresponding to the current pixel is compared with the pre-set texture energy threshold, and each pixel is taken as the first texture energy value or the second texture energy value.
[0061] S204: extracting color information from the image to be detected, and generating a color distribution map corresponding to the image to be detected based on the color information.
[0062] S205 : Based on the texture energy map and the color distribution map, detect whether the image to be detected has a black edge.
[0063] The technical solution provided by this embodiment first extracts texture information from the image to be detected, and generates a texture energy map corresponding to the image to be detected based on the texture information; then extracts color information from the image to be detected, and generates a color distribution map corresponding to the image to be detected based on the color information; then detects whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map. That is to say, the present application can generate a texture energy map and a color distribution map for the image to be detected, and then perform black edge detection based on the texture energy map and the color distribution map. In the existing image detection method, the black edge image is detected by counting the number of black pixels or based on the square sum of pixels, and the detection accuracy is low. Because the present application adopts the technical means of generating a texture energy map and a color distribution map for the image to be detected, and then performing black edge detection based on the texture energy map and the color distribution map, it overcomes the technical problem of low detection accuracy caused by counting the number of black pixels or based on the square sum of pixels in the prior art. The technical solution provided by the present application not only effectively improves the accuracy of black edge detection, but also reduces the complexity of black edge detection; and the technical solution of the embodiment of the present application is simple and convenient to implement, easy to popularize, and has a wider range of application.
[0064] Embodiment 3
[0065] Figure 3 3 is a schematic diagram of the third process of the image detection method provided in the embodiment of the present application. The embodiment of the present application is optimized on the basis of the above embodiment. Optionally, the present embodiment provides a detailed explanation of the color distribution map generation process. Figure 3 As shown, the image detection method provided in this embodiment includes but is not limited to the following steps:
[0066] S301 : extracting texture information from an image to be detected, and generating a texture energy map corresponding to the image to be detected based on the texture information.
[0067] S302 , normalizing the image to be detected in the three color channels of red, green and blue respectively, to obtain a normalized image to be detected in each color channel.
[0068] In a specific embodiment of the present application, the function of normalizing the image color feature information of the image to be detected is to summarize the distribution of the statistical image color information. Optionally, the statistical probability distribution can be normalized between 0 and 1. The image to be detected is normalized in the three color channels of red, green and blue respectively to obtain the normalized image to be detected in each color channel.
[0069] S303 , binarizing the normalized image to be detected of each color channel to obtain the binarized image to be detected of each color channel.
[0070] In the specific embodiment of the present application, image binarization is the most common and important processing method in image analysis and processing. Optionally, the maximum inter-class variance method, iterative threshold method, P quantile method, global threshold method based on minimum error, local threshold method and other methods can be used to perform binarization processing on the normalized image to be detected of each color channel to obtain the binarized image to be detected of each color channel. The more accurate the binary processing method, the greater the amount of calculation.
[0071] S304 , generating a color distribution map based on the binarized image to be detected for each color channel.
[0072] In a specific embodiment of the present application, the binary images of the three color channels are fused to obtain the color distribution map of the image to be detected. The formula of the color distribution value is as follows:
[0073]
[0074] Among them, C(i,j) represents the color distribution value of pixel i in row i and pixel j in column j in the image. R (i,j) indicates the pixel value of the R channel image row i and column j, P G (i,j) indicates the pixel value of the G channel image row i and column j, P B(i,j) represents the pixel value of the B channel image row i and column j, and | represents the OR operation.
[0075] It should be noted that a C(i,j) value of 1 indicates that the point is a non-black pixel; a C(i,j) value of 0 indicates that the point is a black pixel. The color distribution integrates information from multiple color channels, which is more stable and more accurate than the algorithm based on the theoretical black pass threshold for video black edge detection.
[0076] Furthermore, a color distribution map is generated based on the image to be detected after binarization of each color channel, including: extracting a pixel point from the image to be detected as the current pixel point; based on the image to be detected after binarization of each color channel, calculating the color distribution value of the current pixel point in the image to be detected; wherein the color distribution value includes: a first color distribution value or a second color distribution value; in response to the color distribution value corresponding to the current pixel point being the first color distribution value, the color information of the current pixel point is a non-black pixel point; in response to the color distribution value corresponding to the current pixel point being the second color distribution value, the color information of the current pixel point is a black pixel point; repeatedly performing the above operations until the color information of each pixel point in the image to be detected is determined; and obtaining a color distribution map based on the color information of each pixel point in the image to be detected.
[0077] S305 : Based on the texture energy map and the color distribution map, detect whether the image to be detected has a black edge.
[0078] The technical solution provided by this embodiment first extracts texture information from the image to be detected, and generates a texture energy map corresponding to the image to be detected based on the texture information; then extracts color information from the image to be detected, and generates a color distribution map corresponding to the image to be detected based on the color information; then detects whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map. That is to say, the present application can generate a texture energy map and a color distribution map for the image to be detected, and then perform black edge detection based on the texture energy map and the color distribution map. In the existing image detection method, the black edge image is detected by counting the number of black pixels or based on the square sum of pixels, and the detection accuracy is low. Because the present application adopts the technical means of generating a texture energy map and a color distribution map for the image to be detected, and then performing black edge detection based on the texture energy map and the color distribution map, it overcomes the technical problem of low detection accuracy caused by counting the number of black pixels or based on the square sum of pixels in the prior art. The technical solution provided by the present application not only effectively improves the accuracy of black edge detection, but also reduces the complexity of black edge detection; and the technical solution of the embodiment of the present application is simple and convenient to implement, easy to popularize, and has a wider range of application.
[0079] Embodiment 4
[0080] Figure 44 is a schematic diagram of the fourth process of the image detection method provided in the embodiment of the present application. The embodiment of the present application is optimized on the basis of the above embodiment. Optionally, the present embodiment provides a detailed explanation of the image black edge detection process. Figure 4 As shown, the image detection method provided in this embodiment includes but is not limited to the following steps:
[0081] S401 : extracting texture information from an image to be detected, and generating a texture energy map corresponding to the image to be detected based on the texture information.
[0082] S402: extract color information from the image to be detected, and generate a color distribution map corresponding to the image to be detected based on the color information.
[0083] S403: Fusing the texture energy map and the color distribution map to obtain a fused feature map corresponding to the image to be detected.
[0084] In a specific embodiment of the present application, the electronic device may fuse the texture information and the color information to obtain a fused feature map. Optionally, the fusion method may be an OR operation, an AND operation, etc. Exemplarily, when the fusion method is an OR operation, the formula is as follows:
[0085] F(i,j)=E(i,j)|(i,j)
[0086] Among them, F(i,j) represents the fusion feature of row i and column j in the image, E(i,j) represents the texture energy value of row i and column j in the image, C(i,j) represents the color distribution value of row i and column j in the image, and | represents the OR operation.
[0087] S404: Determine non-black contour information in the image to be detected based on the fused feature map.
[0088] In a specific embodiment of the present application, the electronic device can determine the non-black contour information in the image to be detected based on the fused feature map. Specifically, the electronic device can determine the contour information of the non-black pixel by the minimum bounding rectangle of the fused feature. The minimum bounding rectangle refers to the maximum range of several two-dimensional shapes represented by two-dimensional coordinates. Among them, the two-dimensional shape can be a point, a straight line, a polygon, etc.
[0089] S405 , detecting whether the image to be detected has black outline information based on the non-black outline information.
[0090] In a specific embodiment of the present application, the electronic device can detect whether the black outline information of the image to be detected exists based on the non-black outline information. In general, the non-black area is usually located in the center of the image; and the black area is usually located at the edge of the image, so the present application can detect whether the black outline information of the image to be detected exists based on the non-black outline information. Furthermore, after obtaining the position of the black-bordered area, the electronic device determines whether the image to be detected is a black-bordered image based on the ratio of the area of the black area to the area of the image to be detected. If the ratio of the area of the black-bordered area to the area of the image to be detected is greater than or equal to a preset threshold, the image to be detected will not be displayed on the terminal video platform; if the ratio of the area of the black-bordered area to the area of the image to be detected is less than a preset threshold, the image to be detected will be displayed on the terminal video platform.
[0091] The technical solution provided by this embodiment first extracts texture information from the image to be detected, and generates a texture energy map corresponding to the image to be detected based on the texture information; then extracts color information from the image to be detected, and generates a color distribution map corresponding to the image to be detected based on the color information; then detects whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map. That is to say, the present application can generate a texture energy map and a color distribution map for the image to be detected, and then perform black edge detection based on the texture energy map and the color distribution map. In the existing image detection method, the black edge image is detected by counting the number of black pixels or based on the square sum of pixels, and the detection accuracy is low. Because the present application adopts the technical means of generating a texture energy map and a color distribution map for the image to be detected, and then performing black edge detection based on the texture energy map and the color distribution map, it overcomes the technical problem of low detection accuracy caused by counting the number of black pixels or based on the square sum of pixels in the prior art. The technical solution provided by the present application not only effectively improves the accuracy of black edge detection, but also reduces the complexity of black edge detection; and the technical solution of the embodiment of the present application is simple and convenient to implement, easy to popularize, and has a wider range of application.
[0092] Embodiment 5
[0093] Figure 5 is a schematic diagram of the structure of the image detection device provided in the embodiment of the present application, such as Figure 5 As shown, the device 500 may include: a texture energy map generation module 501, a color distribution map generation module 502 and a detection module 503; wherein,
[0094] The texture energy map generation module 501 is used to extract texture information from the image to be detected, and generate a texture energy map corresponding to the image to be detected based on the texture information;
[0095] The color distribution map generating module is used to extract color information from the image to be detected, and generate a color distribution map corresponding to the image to be detected based on the color information;
[0096] The detection module is used to detect whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map.
[0097] Furthermore, the texture energy map generation module 501 is specifically used to calculate the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction; calculate the texture energy value of each pixel in the image to be detected according to the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction, and the pixel value of each pixel in the image to be detected; and obtain the texture energy map corresponding to the image to be detected according to the texture energy value of each pixel in the image to be detected.
[0098] Furthermore, the texture energy map generation module 501 is also specifically used to, in response to the presence of at least one isolated point noise in the texture energy map, remove the at least one isolated point noise in the texture energy map based on a predetermined erosion operator window and a dilation operator window, so as to obtain a texture energy map after removing the isolated point noise.
[0099] Furthermore, the texture energy map generation module 501 is also specifically used to extract a pixel point as the current pixel point in the texture energy map after removing the isolated point noise; in response to the texture energy value corresponding to the current pixel point being greater than or equal to a preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as a first texture energy value; in response to the texture energy value corresponding to the current pixel point being less than the preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as a second texture energy value; and the above operations are repeated until the texture energy value corresponding to each pixel point in the texture energy map after removing the isolated point noise is taken as the first texture energy value or the second texture energy value.
[0100] Furthermore, the color distribution map generating module 502 is specifically used to normalize the image to be detected in the three color channels of red, green and blue respectively to obtain the normalized image to be detected for each color channel; binarize the normalized image to be detected for each color channel to obtain the binarized image to be detected for each color channel; and generate the color distribution map based on the binarized image to be detected for each color channel.
[0101] Furthermore, the color distribution map generating module 502 is specifically used to extract a pixel point as the current pixel point in the image to be detected; based on the image to be detected after binarization of each color channel, calculate the color distribution value of the current pixel point in the image to be detected; wherein the color distribution value includes: a first color distribution value or a second color distribution value; in response to the color distribution value corresponding to the current pixel point being the first color distribution value, the color information of the current pixel point is a non-black pixel point; in response to the color distribution value corresponding to the current pixel point being the second color distribution value, the color information of the current pixel point is a black pixel point; repeatedly perform the above operations until the color information of each pixel point in the image to be detected is determined; and obtain the color distribution map based on the color information of each pixel point in the image to be detected.
[0102] Furthermore, the detection module 503 is specifically used to fuse the texture energy map and the color distribution map to obtain a fused feature map corresponding to the image to be detected; determine the non-black contour information in the image to be detected based on the fused feature map; and detect whether the image to be detected has black contour information based on the non-black contour information.
[0103] The above-mentioned image detection device can execute the method provided by any embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the image detection method provided by any embodiment of the present application.
[0104] Embodiment 6
[0105] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0106] like Figure 6 , it is a block diagram of an electronic device according to the image detection method of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described herein and / or required.
[0107] like Figure 6As shown, the electronic device includes: one or more processors 601, a memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 601 is taken as an example.
[0108] The memory 602 is a non-transient computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the image detection method provided in the present application. The non-transient computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the image detection method provided in the present application.
[0109] The memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the image detection method in the embodiment of the present application (for example, the attached Figure 5 The processor 601 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 602, that is, the image detection method in the above method embodiment is implemented.
[0110] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device for image detection, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device for image detection via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0111] The electronic device for image detection may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0112] The input device 603 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for image detection, such as input devices such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0113] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0114] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0115] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0116] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0117] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0118] According to the technical solution of the embodiment of the present application, texture information is first extracted from the image to be detected, and a texture energy map corresponding to the image to be detected is generated based on the texture information; then color information is extracted from the image to be detected, and a color distribution map corresponding to the image to be detected is generated based on the color information; then, based on the texture energy map and the color distribution map, whether there is a black edge in the image to be detected is detected. That is to say, the present application can generate a texture energy map and a color distribution map for the image to be detected, and then perform black edge detection based on the texture energy map and the color distribution map. In the existing image detection method, the black edge image is detected by counting the number of black pixels or based on the square sum of pixels, and the detection accuracy is low. Because the present application adopts the technical means of generating a texture energy map and a color distribution map for the image to be detected, and then performing black edge detection based on the texture energy map and the color distribution map, the technical problem of low detection accuracy caused by counting the number of black pixels or based on the square sum of pixels in the prior art is overcome. The technical solution provided by the present application not only effectively improves the accuracy of black edge detection, but also reduces the complexity of black edge detection; and the technical solution of the embodiment of the present application is simple and convenient to implement, easy to popularize, and has a wider range of application.
[0119] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0120] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. An image detection method, the method comprising: Extracting texture information from the image to be detected, and generating a texture energy map corresponding to the image to be detected based on the texture information; Extracting color information from the image to be detected, and generating a color distribution map corresponding to the image to be detected based on the color information; Based on the texture energy map and the color distribution map, detecting whether the image to be detected has a black edge; Among them, each point value in the texture energy map represents the texture energy value of the current pixel point in the image to be detected, indicating the intensity of the texture information contained in the point; the color distribution map is generated based on the color information of each pixel point in the image to be detected, and each point value in the color distribution map represents the color distribution value of the current pixel point in the image to be detected.
2. According to the method of claim 1, generating a texture energy map corresponding to the image to be detected based on the texture information comprises: Calculating the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction; Calculating the texture energy value of each pixel in the image to be detected according to the gradient in the horizontal direction and the gradient in the vertical direction of the image to be detected and the pixel value of each pixel in the image to be detected; According to the texture energy value of each pixel in the image to be detected, a texture energy map corresponding to the image to be detected is obtained.
3. The method according to claim 2, further comprising: In response to at least one isolated point noise existing in the texture energy map, the at least one isolated point noise is removed from the texture energy map based on a predetermined erosion operator window and a dilation operator window to obtain a texture energy map after the isolated point noise is removed.
4. The method according to claim 3, further comprising: Extracting a pixel point from the texture energy map after removing isolated point noise as the current pixel point; In response to the texture energy value corresponding to the current pixel being greater than or equal to a preset texture energy threshold, the texture energy value corresponding to the current pixel is taken as a first texture energy value; in response to the texture energy value corresponding to the current pixel being less than the preset texture energy threshold, the texture energy value corresponding to the current pixel is taken as a second texture energy value; the above operation is repeated until the texture energy value corresponding to each pixel in the texture energy map after removing isolated point noise is taken as the first texture energy value or the second texture energy value.
5. The method according to claim 1, wherein generating a color distribution map corresponding to the image to be detected based on the color information comprises: Normalizing the image to be detected in three color channels, red, green and blue, respectively, to obtain a normalized image to be detected in each color channel; Binarizing the normalized image to be detected of each color channel to obtain a binarized image to be detected of each color channel; The color distribution map is generated based on the image to be detected after binarization of each color channel.
6. The method according to claim 5, wherein generating the color distribution map based on the image to be detected after binarization of each color channel comprises: Extracting a pixel point from the image to be detected as the current pixel point; Based on the image to be detected after binarization of each color channel, calculate the color distribution value of the current pixel in the image to be detected; wherein the color distribution value includes: a first color distribution value or a second color distribution value; In response to the color distribution value corresponding to the current pixel being the first color distribution value, the color information of the current pixel is a non-black pixel; in response to the color distribution value corresponding to the current pixel being the second color distribution value, the color information of the current pixel is a black pixel; the above operation is repeatedly performed until the color information of each pixel in the image to be detected is determined; The color distribution map is obtained based on the color information of each pixel in the image to be detected.
7. The method according to claim 1, wherein the step of detecting whether the image to be detected has a black edge based on the texture energy map and the color distribution map comprises: The texture energy map and the color distribution map are fused to obtain a fusion feature map corresponding to the image to be detected; Determine non-black contour information in the image to be detected based on the fused feature map; It is detected whether the image to be detected has black outline information based on the non-black outline information.
8. An image detection device, comprising: Texture energy map generation module, color distribution map generation module and detection module; wherein, The texture energy map generation module is used to extract texture information from the image to be detected, and generate a texture energy map corresponding to the image to be detected based on the texture information; The color distribution map generating module is used to extract color information from the image to be detected, and generate a color distribution map corresponding to the image to be detected based on the color information; The detection module is used to detect whether there is a black edge in the image to be detected based on the texture energy map and the color distribution map; Among them, each point value in the texture energy map represents the texture energy value of the current pixel point in the image to be detected, indicating the intensity of the texture information contained in the point; the color distribution map is generated based on the color information of each pixel point in the image to be detected, and each point value in the color distribution map represents the color distribution value of the current pixel point in the image to be detected.
9. According to the device according to claim 8, the texture energy map generation module is specifically used to calculate the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction; calculate the texture energy value of each pixel in the image to be detected based on the gradient of the image to be detected in the horizontal direction and the gradient in the vertical direction, and the pixel value of each pixel in the image to be detected; and obtain the texture energy map corresponding to the image to be detected based on the texture energy value of each pixel in the image to be detected.
10. According to the device of claim 9, the texture energy map generation module is further specifically used to, in response to the presence of at least one isolated point noise in the texture energy map, remove the at least one isolated point noise in the texture energy map based on a predetermined erosion operator window and a dilation operator window to obtain the texture energy map after the isolated point noise is removed.
11. According to the device of claim 10, the texture energy map generation module is further specifically used to extract a pixel point as the current pixel point in the texture energy map after removing isolated point noise; in response to the texture energy value corresponding to the current pixel point being greater than or equal to a preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as a first texture energy value; in response to the texture energy value corresponding to the current pixel point being less than the preset texture energy threshold, the texture energy value corresponding to the current pixel point is taken as a second texture energy value; and the above operations are repeated until the texture energy value corresponding to each pixel point in the texture energy map after removing isolated point noise is taken as the first texture energy value or the second texture energy value.
12. According to the device according to claim 8, the color distribution map generating module is specifically used to normalize the image to be detected in the three color channels of red, green and blue respectively to obtain the normalized image to be detected in each color channel; binarize the normalized image to be detected in each color channel to obtain the binarized image to be detected in each color channel; and generate the color distribution map based on the binarized image to be detected in each color channel.
13. The device according to claim 12, wherein the color distribution map generating module is specifically used to extract a pixel point from the image to be detected as the current pixel point; based on the image to be detected after binarization of each color channel, calculate the color distribution value of the current pixel point in the image to be detected; wherein, The color distribution value includes: a first color distribution value or a second color distribution value; in response to the color distribution value corresponding to the current pixel being the first color distribution value, the color information of the current pixel is a non-black pixel; in response to the color distribution value corresponding to the current pixel being the second color distribution value, the color information of the current pixel is a black pixel; repeatedly performing the above operations until the color information of each pixel in the image to be detected is determined; and obtaining the color distribution map based on the color information of each pixel in the image to be detected.
14. According to the device according to claim 8, the detection module is specifically used to fuse the texture energy map and the color distribution map to obtain a fusion feature map corresponding to the image to be detected; determine the non-black contour information in the image to be detected based on the fusion feature map; and detect whether the image to be detected has black contour information based on the non-black contour information.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method of any one of claims 1 to 7.
