Image detection method and device based on mosaic detection filter
By using an image detection method based on a mosaic detection filter in an intelligent autonomous driving system, the problem of mosaic affecting analysis accuracy in image data is solved, fast and accurate mosaic recognition is achieved, the efficiency and accuracy of image detection are improved, and image quality assurance is provided for the autonomous driving system.
Patent Information
- Application Number
- CN202411852512.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-11
AI Technical Summary
In intelligent autonomous driving systems, low-quality image data, especially mosaics, will affect the accuracy of subsequent intelligent image analysis, and traditional image detection methods are difficult to meet real-time requirements.
The image detection method based on a mosaic detection filter is adopted, and the mosaic in the image is quickly identified by dividing the target image into image blocks and using the image block detection function and the pixel point detection function for detection.
It realizes the rapid and accurate identification of mosaics in the image, improves the efficiency and accuracy of image detection, and provides image quality assurance for intelligent image analysis in autonomous driving systems.
Smart Images

Figure CN119810042A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing, and in particular, relates to an image detection method and device based on a mosaic detection filter. Background Art
[0002] With the development of intelligent autonomous driving systems, cameras with multiple angles are often installed in intelligent autonomous driving systems, including front view, rear view, surround view, and perimeter view. Through multi-angle image data acquisition and intelligent image analysis, driving trajectory decisions are made in real time based on the vehicle's surrounding environment information. However, when the quality of the collected image data is poor, such as mosaics, it will have an adverse effect on the accuracy of subsequent intelligent image analysis. Therefore, it is necessary to perform image detection before image analysis.
[0003] In traditional solutions, image detection often relies on detection operators or deep learning models, which makes it difficult to meet the real-time requirements of intelligent autonomous driving systems.
[0004] Therefore, how to quickly and accurately perform image detection and identify mosaics in images is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present application provides an image detection method and device based on a mosaic detection filter, which can perform image detection based on the mosaic detection filter, thereby quickly and accurately identifying mosaics in the image, and providing image quality assurance for subsequent intelligent image analysis during autonomous driving.
[0006] On the one hand, an embodiment of the present application provides an image detection method based on a mosaic detection filter, the method comprising:
[0007] Acquire a target image and a mosaic detection filter; the mosaic detection filter includes an image block detection function and a pixel point detection function;
[0008] Dividing the target image into a preset number of image blocks to obtain an image block set;
[0009] The image blocks in the image block set are traversed in sequence, and for each traversed current image block, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness;
[0010] If the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold, determining that there is no mosaic in the target image;
[0011] If there is an image block whose image block discreteness is less than the first detection threshold in the image block set, determine the image block whose image block discreteness is less than the first detection threshold as a target image block, and call the pixel point detection function to perform pixel point mosaic detection on each pixel point in the target image block to obtain a pixel difference value of each pixel point in the target image block;
[0012] If the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold, it is determined that mosaic exists in the target image block.
[0013] In an exemplary embodiment, the method for constructing the mosaic detection filter includes:
[0014] Constructing a mosaic detection source file; the mosaic detection source file defines a preset name of the mosaic detection filter, the image block detection function and the pixel point detection function;
[0015] Based on the preset name, adding a declaration statement for the mosaic detection filter in a registration file to obtain a target registration file;
[0016] Adding a compilation target statement in a compilation content configuration file to obtain a target compilation configuration file; the target compilation configuration file is used to instruct to compile the mosaic detection source file into a mosaic detection filter;
[0017] A compile option statement is added to the filter configuration file to obtain a target filter configuration file; and the mosaic detection source file is compiled based on the target filter configuration file, the target compile configuration file and the target registration file to obtain the mosaic detection filter.
[0018] In an exemplary embodiment, before sequentially traversing the image blocks in the image block set and, for each traversed current image block, calling the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness, the method further includes:
[0019] In response to an image detection request for the target image, initializing the mosaic detection filter based on a filter description statement carried in the image detection request; the filter description statement includes a preset name corresponding to the mosaic detector, the first detection threshold, and the second detection threshold;
[0020] When the configuration verification function is called to determine that the mosaic detection filter is successfully initialized, the image blocks in the image block set are traversed in sequence, and for each current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness.
[0021] In an exemplary embodiment, dividing the target image into a preset number of image blocks to obtain an image block set includes:
[0022] Acquire brightness component data of the target image in a preset color space coordinate system;
[0023] generating a luminance image according to the luminance component data;
[0024] The brightness image is divided into a preset number of image blocks to obtain the image block set.
[0025] In an exemplary implementation, calling the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness includes:
[0026] Obtaining the brightness component of each pixel of the current image block;
[0027] Determine a brightness average value according to the brightness components of each pixel;
[0028] Determine the absolute value of the difference between the brightness component of each pixel and the brightness average value as an initial discrete value;
[0029] The average value of the initial discrete values is determined as the image discreteness.
[0030] In an exemplary embodiment, calling the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain a pixel difference value of each pixel in the target image block includes:
[0031] Traversing each pixel point in the target image block in turn, and for each traversed current pixel point, obtaining the brightness component of the current pixel point;
[0032] Determine a pixel point adjacent to the current pixel point as a target pixel point, and obtain a brightness component of the target pixel point;
[0033] Based on the brightness component of the current pixel and the brightness component of the target pixel, a pixel difference corresponding to the current pixel is determined.
[0034] In an exemplary embodiment, there are multiple target pixels; determining the pixel difference corresponding to the current pixel based on the brightness component of the current pixel and the brightness component of the target pixel includes:
[0035] Obtaining differences between the brightness component of the current pixel and the brightness components of the plurality of target pixels to obtain a difference set;
[0036] The minimum value in the difference value set is determined as the pixel difference value corresponding to the current pixel point.
[0037] On the other hand, the present application also provides an image detection device based on a mosaic detection filter, the device comprising:
[0038] An acquisition module, used for acquiring a target image and a mosaic detection filter; the mosaic detection filter includes an image block detection function and a pixel point detection function;
[0039] An image division module, used for dividing the target image into a preset number of image blocks to obtain an image block set;
[0040] An image block mosaic detection module is used to sequentially traverse the image blocks in the image block set, and for each traversed current image block, call the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness;
[0041] A first threshold comparison module, configured to determine that no mosaic exists in the target image if the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold;
[0042] a pixel mosaic detection module, configured to, if there is an image block whose image block discreteness is less than the first detection threshold in the image block set, determine the image block whose image block discreteness is less than the first detection threshold as a target image block, and call the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain a pixel difference value of each pixel in the target image block;
[0043] The second threshold comparison module is used to determine that mosaic exists in the target image block if the pixel difference value of each pixel point in the target image block is greater than or equal to a second detection threshold.
[0044] On the other hand, the present application also provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the image detection method based on the mosaic detection filter as described above.
[0045] On the other hand, the present application also provides a computer storage medium, which stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the image detection method based on the mosaic detection filter as described above.
[0046] On the other hand, the present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the image detection method based on the mosaic detection filter as described above.
[0047] The method for constructing a mosaic detection filter provided in this application has the following technical effects:
[0048] The present application first obtains a target image and a mosaic detection filter; wherein the mosaic detection filter includes an image block detection function and a pixel point detection function; the target image is divided into a preset number of image blocks to obtain an image block set; then the image blocks in the image block set are traversed in sequence, and for each current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain image block discreteness; if the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold, it is determined that there is no mosaic in the target image; if there is an image block in the image block set whose image block discreteness is less than the first detection threshold, the image block whose image block discreteness is less than the first detection threshold is determined as the target image block, and the pixel point detection function is called to perform pixel point mosaic detection on each pixel point in the target image block to obtain the pixel difference value of each pixel point in the target image block; if the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold, it is determined that there is a mosaic in the target image block. This application uses a block processing method to first use the image block detection function in the mosaic detection filter to perform image block detection, and then use the pixel point detection function in the mosaic detection filter to further detect the target image block without traversing and comparing the pixels of the entire image, thereby shortening the processing time of image detection and improving the accuracy of mosaic detection. Image detection based on the mosaic detection filter can quickly and accurately identify mosaics in the image, providing image quality assurance for subsequent intelligent image analysis during autonomous driving. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0050] Figure 1 is an application environment diagram of the image detection method based on the mosaic detection filter provided in an embodiment of the present application;
[0051] Figure 2 is a flow chart of an image detection method based on a mosaic detection filter provided in an embodiment of the present application;
[0052] Figure 3 It is a flow chart of a method for constructing a mosaic detection filter provided in an embodiment of the present application;
[0053] Figure 4 It is a schematic diagram of the overall process of initializing the FFmpeg custom filter provided in an embodiment of the present application;
[0054] Figure 5 It is a schematic diagram of the process of pixel mosaic detection provided in an embodiment of the present application;
[0055] Figure 6 is a schematic diagram of the positions of adjacent pixels provided in an embodiment of the present application;
[0056] Figure 7 It is a schematic diagram of the flow of the mosaic detection method provided in the embodiment of the present application;
[0057] Figure 8 is a structural schematic diagram of an image detection device based on a mosaic detection filter provided in an embodiment of the present application;
[0058] Fig. 9 This is a hardware structure block diagram of a server of an image detection method based on a mosaic detection filter provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0060] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0061] Figure 1 01 is an application environment diagram of an image detection method based on a mosaic detection filter provided in an embodiment of the present application. The application environment may at least include a server 01 and a terminal device 02.
[0062] In an optional embodiment, server 01 can be used to perform image detection on the image captured by terminal device 02 based on a mosaic detection filter. Server 01 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0063] In an optional embodiment, the terminal device 02 can be used to capture images. The terminal device 02 is provided with an image capture device. Specifically, the terminal device 02 may include but is not limited to electronic devices such as smart phones, desktop computers, tablet computers, laptop computers, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, smart wearable devices, vehicle terminals, smart TVs, etc.; it may also be software running on the above electronic devices, such as applications, applets, etc. The operating system running on the electronic device in the embodiment of the present application may include but is not limited to Android system, IOS system, Linux, Windows, etc.
[0064] It should be noted that the image detection method based on the mosaic detection filter of the present application can be applied to the field of autonomous driving. The mosaic detection filter is used to perform mosaic detection on the images collected by the autonomous driving vehicle, thereby providing image quality assurance for the subsequent intelligent image analysis during the autonomous driving process.
[0065] Figure 2 It is a flow chart of an image detection method based on a mosaic detection filter provided in an embodiment of the present application.
[0066] S201: Acquire a target image and a mosaic detection filter.
[0067] Among them, the mosaic detection filter includes an image block detection function and a pixel point detection function;
[0068] The target image can be Figure 1 The target image may be an image captured by the terminal device 02. Specifically, the target image may be an image captured by an image capture device mounted on a vehicle in an intelligent automatic driving system.
[0069] It should be noted that the target image may also be a frame image obtained by decomposing a video stream.
[0070] The mosaic detection filter can be a custom filter based on the Fast Forward MPEG (FFmpeg) framework, which is an open source tool library for processing video and audio. In this application, the mosaic detection filter used includes an image block detection function and a pixel point detection function.
[0071] S203: Divide the target image into a preset number of image blocks to obtain an image block set.
[0072] In one implementation, the target image may be evenly divided into a preset number of image blocks. In one example, assuming that the size of the target image is 640*640 pixels and the preset number is 64, the target image may be divided into 8 equal parts in length and width to obtain 64 image blocks of 80*80 pixels each, thereby obtaining an image block set.
[0073] S205: traversing the image blocks in the image block set in sequence, and for each traversed current image block, calling the image block detection function to perform image block mosaic detection on the current image block to obtain image block discreteness.
[0074] In one implementation, the traversal may be performed in row order, first traversing the image blocks in the first row of the target image, then traversing the image blocks in the second row of the target image, and so on, until the traversal end condition is met, that is, all image blocks are traversed.
[0075] In another implementation, the image blocks may be traversed sequentially in column order. It should be noted that the present application does not specifically limit the traversal order of the image blocks.
[0076] For the current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness.
[0077] S207: If the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold, determining that there is no mosaic in the target image;
[0078] It should be noted that if the target image is a normal image without mosaics, the value distribution range of the brightness component of each pixel in each image block is large and relatively uniform. In this case, the image discreteness is large. Therefore, by determining whether the image discreteness of each image block is greater than or equal to the first detection threshold, it can be determined that the target image does not have mosaics.
[0079] In one example, the specific value of the first detection threshold may be 18. The specific value of the first detection threshold may be adjusted according to the actual acquisition environment of the target image.
[0080] S209: If there is an image block in the image block set whose image block discreteness is less than the first detection threshold, determine the image block whose image block discreteness is less than the first detection threshold as the target image block, and call the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain the pixel difference value of each pixel in the target image block.
[0081] If the target image is an abnormal image, that is, mosaics appear, during the traversal process, the brightness component values of each pixel in the current image block are often fixed values that appear multiple times. In this case, the image discreteness is small. Therefore, the present application determines the image block whose image block discreteness is less than the first detection threshold as the target image block for further detection.
[0082] S211: If the pixel difference value of each pixel point in the target image block is greater than or equal to a second detection threshold, it is determined that mosaic exists in the target image block.
[0083] In order to make the image detection more accurate, the present application further determines the mosaic detection result of the target image block according to the pixel difference of each pixel in the target image block. Specifically, the pixel difference of a pixel can be understood as the pixel value difference between a pixel and its adjacent pixels.
[0084] It should be noted that the specific value of the second detection threshold may be the same as or different from the value of the first detection threshold, and may be set according to actual needs.
[0085] If the pixel difference value of each pixel in the target image block is greater than or equal to the second detection threshold, it can be determined that there is a mosaic in the target image block, and further it can be determined that there is a mosaic in the target image.
[0086] The present application first obtains a target image and a mosaic detection filter; wherein the mosaic detection filter includes an image block detection function and a pixel point detection function; the target image is divided into a preset number of image blocks to obtain an image block set; then the image blocks in the image block set are traversed in sequence, and for each current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain image block discreteness; if the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold, it is determined that there is no mosaic in the target image; if there is an image block in the image block set whose image block discreteness is less than the first detection threshold, the image block whose image block discreteness is less than the first detection threshold is determined as the target image block, and the pixel point detection function is called to perform pixel point mosaic detection on each pixel point in the target image block to obtain the pixel difference value of each pixel point in the target image block; if the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold, it is determined that there is a mosaic in the target image block. This application uses a block processing method to first use the image block detection function in the mosaic detection filter to perform image block detection, and then use the pixel point detection function in the mosaic detection filter to further detect the target image block without traversing and comparing the pixels of the entire image, thereby shortening the processing time of image detection and improving the accuracy of mosaic detection. Image detection based on the mosaic detection filter can quickly and accurately identify mosaics in the image, providing image quality assurance for subsequent intelligent image analysis during autonomous driving.
[0087] Figure 3 : is a flow chart of a method for constructing a mosaic detection filter provided in an embodiment of the present application. The method for constructing the mosaic detection filter may include:
[0088] S301: Build mosaic detection source file;
[0089] The mosaic detection source file defines the preset name of the mosaic detection filter, the image block detection function and the pixel point detection function; in one example, the mosaic detection source file can be pre-written and placed in a specified directory; the mosaic detection source file vf_mosaicframe.c is customized and placed in the libavfilter directory according to the organizational format of the FFmpeg file, and the image block detection function and the pixel point detection function are called in the filter_frame function, where mosaicframe is the preset name of the mosaic detection filter. The constructed mosaic detection source file is used to implement the mosaic detection filter.
[0090] It should be noted that the mosaic detection source file and the preset name can also be named with other characters, and the present application does not limit the specific naming of the mosaic detection source file and the preset name. S303: Based on the preset name, add a declaration statement of the mosaic detection filter in the registration file to obtain a target registration file;
[0091] The registration file is the allfilters.c file in the libavfilter folder, which contains the registration of all filters. In an example, based on the preset name mosaicframe, the declaration statement added to the allfilters.c file can be extern AVFilter ff_vf_mosaicframe.
[0092] S305: Add a compilation target statement to the compilation content configuration file to obtain a target compilation configuration file;
[0093] The target compilation configuration file is used to instruct to compile the mosaic detection source file into a mosaic detection filter;
[0094] In one example, the target compilation configuration file is a Makefile file in the libavfilter folder, which is used to control the compilation process and target according to the configuration. In one example, the Makefile file can be modified to generate a library file with a suffix of .o corresponding to the mosaic detection source file to obtain a mosaic detection filter.
[0095] In an example, the compilation target statement may be OBJS-$(CONFIG_MOSAICFRAME_FILTER)+=vf_mosaicframe.o, which indicates that during the compilation process, the filter corresponding to the source file named mosaicframe is compiled and linked to generate a target file named vf_mosaicframe.o, i.e., a mosaic detection filter.
[0096] It should be noted that the value of $(CONFIG_MOSAICFRAME_FILTER) can be y to compile into the kernel, or the value of $(CONFIG_MOSAICFRAME_FILTER) can be m to compile into a module.
[0097] S307: Adding a compilation option statement to the filter configuration file to obtain a target filter configuration file; and compiling the mosaic detection source file based on the target filter configuration file, the target compilation configuration file and the target registration file to obtain the mosaic detection filter.
[0098] In an example, the filter configuration file is an FFmpeg configure file, and the compile option statement may be --enable-filter=mosaicframe, so as to support the compilation of a filter named mosaicframe.
[0099] Based on the target filter configuration file, target compilation configuration file and target registration file obtained by the above modifications, the mosaic detection source file can be compiled to obtain a library file with the suffix .o, such as the target file named vf_mosaicframe.o in the above example, which is the constructed mosaic detection filter.
[0100] This application builds a mosaic detection filter based on FFmpeg, which can be easily maintained and expanded; and based on FFmpeg, a mosaic detection filter can be quickly established to quickly realize image detection of images or videos, and efficiently realize mosaic analysis of real-time images of autonomous driving, so as to timely discover and locate problems. In addition, the mosaic detection filter constructed by this application has the characteristics of easy maintenance and expansion, and can provide more accurate sensor-related events and their data at the chip level, effectively support function development and performance optimization, ensure that the autonomous driving system can obtain clear and accurate visual information, and ensure the picture quality during the visual analysis process of the autonomous driving system. Compared with traditional methods, the image is first detected at the source, which is convenient for early detection and location of problems, so as to improve the accuracy of autonomous driving visual analysis.
[0101] Figure 4 It is a schematic diagram of the overall process of initializing the FFmpeg custom filter provided in an embodiment of the present application.
[0102] S401: filter initialization;
[0103] Initialize and call the avfilter_register_all function to register the filter.
[0104] S403: Allocate memory for the filter graph (FilterGraph);
[0105] Call the avfilter_graph_alloc function to allocate memory for FilterGraph, where FilterGraph is used to manage filters.
[0106] S405: Create and add a filter instance.
[0107] Call avfilter_graph_create_filter function to create and add a filter instance in FilterGraph.
[0108] S407: incoming detection threshold;
[0109] Call the avfilter_graph_parse_ptr function to add the filter described in the string form to the FilterGraph; it should be noted that the detection threshold in this application may include a first detection threshold and a second detection threshold. In an example, the detection threshold 18 can be passed into the FilterGraph through the filter description statement "-vf mosaicframe=18", and the filter instance added in the above step is determined as a filter named mosaicframe, that is, a mosaic detection filter.
[0110] S409: Check the configuration of FilterGraph;
[0111] Call avfilter_graph_config function to check the configuration of FilterGraph.
[0112] It should be noted that, before sequentially traversing the image blocks in the image block set and, for each traversed current image block, calling the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness, the method further includes:
[0113] In response to an image detection request for the target image, the mosaic detection filter is initialized based on a filter description statement carried in the image detection request; the filter description statement includes a preset name corresponding to the mosaic detector, the first detection threshold, and the second detection threshold; this process refers to steps S401 to S407 and will not be repeated here.
[0114] When the configuration verification function is called to determine that the mosaic detection filter is successfully initialized, the image blocks in the image block set are traversed in sequence, and for each traversed current image block, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness. The process of calling the configuration verification function is referred to step S409, which will not be repeated here.
[0115] When applying the mosaic detection filter for image detection, the present application first initializes the filter to conform to the organizational form of FFmpeg, making the call more convenient and universal, and easy to maintain and expand.
[0116] In one embodiment, dividing the target image into a preset number of image blocks to obtain the image block set may include: obtaining luminance component data of the target image in a preset color space coordinate system; generating a luminance image based on the luminance component data; dividing the luminance image into a preset number of image blocks to obtain the image block set.
[0117] The color space coordinate system is used to describe and represent colors. For example, in the RGB color space, any color can be represented by a combination of red, green, and blue components. In the embodiment of the present application, the preset color space can be a YUV color space, which represents colors by a combination of luminance (Luminance or Luma) and chrominance (Chrominance or Chroma).
[0118] After retaining only the brightness component of the target image, the corresponding brightness image can be obtained, that is, only the grayscale value of the target image is retained in the brightness image, and the color information in the target image is removed. In the present application, subsequent image detection can be performed based on the brightness image, thereby avoiding the interference of irrelevant color components on image detection, and the accuracy of image detection can be effectively improved. In addition, using the brightness image for image detection can greatly reduce the amount of calculation and improve the processing speed of image detection.
[0119] In one embodiment, calling the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness includes:
[0120] Obtaining a brightness component of each pixel of the current image block; and determining a brightness average value according to the brightness component of each pixel;
[0121] In one embodiment, the brightness average value can be determined according to the following formula:
[0122]
[0123] in, Indicates the average brightness, y i represents the brightness component of the i-th pixel in the current image block, and n represents the number of pixels contained in the current image block.
[0124] The absolute value of the difference between the brightness component of each pixel point and the brightness average value is determined as an initial discrete value; and the average value of the initial discrete value is determined as the image discreteness.
[0125] Specifically, the image discreteness can be determined according to the following formula:
[0126]
[0127] Among them, T a represents the image discreteness, Indicates the average brightness, y i represents the brightness component of the i-th pixel in the current image block, and n represents the number of pixels contained in the current image block.
[0128] In another implementation, the image discreteness may be represented by indicators such as variance and standard deviation.
[0129] In an embodiment of the present application, the average difference is used to represent the discrete degree of the brightness component of each pixel in the current image block, so that the image discreteness can accurately express the pixel distribution of each image block in the target image, so that the image blocks suspected of mosaics can be preliminarily screened out by subsequently using the image discreteness indicator and the relationship between the first detection threshold. The image discreteness of the present application is simple to calculate and has a fast processing speed.
[0130] The above method uses image discreteness to judge whether mosaics appear in the current image block from an overall perspective. If the image discreteness of all image blocks in the image block set is greater than or equal to the first detection threshold, it can be determined that there are no mosaics in the target image. During the traversal process, if the image discreteness of the current image block is less than the first detection threshold, it can be explained that mosaics may exist in the current image block. On this basis, the present application further determines the current image block as the target image block, and further detects the pixels contained in the target image block.
[0131] Figure 5 : is a flowchart of pixel mosaic detection provided by an embodiment of the present application. In one embodiment, calling the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain the pixel difference value of each pixel in the target image block may include:
[0132] S501: traversing each pixel point in the target image block in sequence, and for each traversed current pixel point, obtaining a brightness component of the current pixel point;
[0133] In one implementation, the pixels may be traversed in row order; in another implementation, the pixels may be traversed in column order. The present application does not limit the traversal order of the pixels.
[0134] S503: Determine a pixel point adjacent to the current pixel point as a target pixel point, and obtain a brightness component of the target pixel point;
[0135] The target pixel is a pixel adjacent to the current pixel, wherein the adjacent position may be adjacent to the upper edge of the current pixel, adjacent to the lower edge of the current pixel, adjacent to the left edge of the current pixel, and adjacent to the right edge of the current pixel. Figure 6 Schematic diagram of the positions of adjacent pixels provided in the embodiment of the present application. Figure 6 As shown, in the current image block, if the current pixel is A, the target pixel can be B and E; if the current pixel is C, the target pixel can be B, D and G; if the current pixel is F, the target pixel can be B, E, G and J.
[0136] S505: Determine a pixel difference value corresponding to the current pixel based on the brightness component of the current pixel and the brightness component of the target pixel.
[0137] In one embodiment, the pixel difference corresponding to the current pixel may be determined by calculating the difference between the brightness component of the current pixel and the brightness component of the target pixel.
[0138] It should be noted that there are multiple target pixels. In one embodiment, the difference between the brightness component of the current pixel and each target pixel can be compared with the second detection threshold.
[0139] In one embodiment, when the following conditions are met, it can be determined that mosaics exist in the target image block;
[0140] y j -y top ≥T s &&y j -y left ≥T s &&y j -y right ≥T s &&y j -y bottom ≥T s
[0141] Among them, y j represents the current pixel, j ranges from 1 to m, m is the number of pixels contained in the current image block, T s represents the second detection threshold, y top Indicates the target pixel adjacent to the upper edge of the current pixel, y left Indicates the target pixel adjacent to the left edge of the current pixel, y right Indicates the target pixel adjacent to the right edge of the current pixel, y bottom Indicates the target pixel adjacent to the lower edge of the current pixel.
[0142] Still Figure 6 Taking the image block shown in the figure as an example, if the current pixel is F, the target pixels are B, E, G and J. When the brightness component difference between the pixels F and B is greater than or equal to the second detection threshold T s , and the brightness component difference between pixels F and E is greater than or equal to the second detection threshold T s , and the brightness component difference between pixel points F and G is greater than or equal to the second detection threshold T s , and the brightness component difference between pixels F and J is also greater than or equal to the second detection threshold T s , then the pixel F is a mosaic point.
[0143] If the pixel difference values of all pixels in the target image block are greater than or equal to the second detection threshold, it can be determined that the target image block has mosaics; if the pixel difference values of some pixels are less than the second detection threshold, it can be determined that the target image block does not have mosaics.
[0144] Still Figure 6 Taking the image block shown in the figure as an example, if the current pixel is F, the target pixels are B, E, G and J. If the difference in the brightness component of the pixels F and B is less than the second detection threshold T s , or the brightness component difference between pixels F and E is less than the second detection threshold T s , or the brightness component difference between pixels F and G is less than the second detection threshold T s , or the brightness component difference between pixels F and J is less than the second detection threshold T s , it can be determined that there is no mosaic in the target image block.
[0145] In an embodiment, determining the pixel difference value corresponding to the current pixel based on the brightness component of the current pixel and the brightness component of the target pixel may include:
[0146] Obtaining differences between the brightness component of the current pixel and the brightness components of the plurality of target pixels to obtain a difference set;
[0147] The minimum value in the difference value set is determined as the pixel difference value corresponding to the current pixel point.
[0148] In an embodiment of the present application, by determining the minimum value in the difference set as the pixel difference, each pixel point only needs to be compared once when comparing with the second detection threshold, which can effectively reduce the number of comparisons, thereby saving computing resources and improving detection speed.
[0149] It is understandable that if the image block is an image block with mosaics, the brightness component of each pixel therein varies greatly. Based on this feature, the present application further compares the pixel difference between each pixel and the adjacent pixel with the second detection threshold, thereby quickly and accurately determining whether the target image block has mosaics.
[0150] Figure 7 It is a flow chart of the mosaic detection method provided in the embodiment of the present application. Figure 7 Can be seen as Figure 2 A specific example of the method shown.
[0151] S701: Acquire YUV data; wherein the YUV data is a target image in a YUV format.
[0152] S703: intercepting all data of the Y component;
[0153] The Y component, namely the brightness component, can be regarded as a specific example of the above embodiment and will not be described in detail here.
[0154] S705: Decompose the Y component data into 8*8 macroblock regions; this step can be regarded as a specific example of the above embodiment and will not be described in detail here.
[0155] S707: Calculate the average difference of all Y components in the current region by region; this step can be regarded as a specific example of the above embodiment and will not be described in detail here.
[0156] S709: If the average difference is greater than the set threshold, jump to step S701; otherwise, execute step S711; the set threshold can be regarded as a specific example of the first detection threshold in step S207.
[0157] If the average difference is greater than the set threshold, it can be determined that there is no mosaic in the area. If the average difference of all areas is greater than the set threshold, it means that there is no mosaic in the target image, and the next target image can be detected.
[0158] S711: Calculate the difference between the Y component of the current pixel and its surrounding neighboring points; the surrounding neighboring points may include pixel points adjacent to the upper edge of the current pixel point, pixel points adjacent to the lower edge of the current pixel point, pixel points adjacent to the left edge of the current pixel point, and pixel points adjacent to the right edge of the current pixel point. This step can be regarded as a specific example of step S505.
[0159] S713: If the difference exceeds the set threshold, execute step S715; otherwise, jump to step S701; if the difference of each pixel in the current image block exceeds the set threshold, it can be determined that there is mosaic in the current image block. The threshold set in this step can be regarded as a specific example of step S211.
[0160] S715: Generate a mosaic alarm. As long as there is a mosaic in one image block, a mosaic alarm is given to notify maintenance personnel in time for debugging, ensuring that the intelligent autonomous driving system can obtain clear and accurate image information.
[0161] It can be seen from the technical solution provided by the above embodiments of the present application that the present application uses a block processing method to first use the image block detection function in the mosaic detection filter to perform image block detection, and then use the pixel point detection function in the mosaic detection filter to further detect the target image block, without the need to traverse and compare the pixels of the entire image, thereby shortening the processing time of image detection and improving the accuracy of mosaic detection. Image detection based on the mosaic detection filter can quickly and accurately identify mosaics in the image, providing image quality assurance for subsequent intelligent image analysis during autonomous driving.
[0162] Figure 8 It is a structural schematic diagram of an image detection device based on a mosaic detection filter provided in an embodiment of the present application.
[0163] like Figure 8 As shown, the device 800 includes:
[0164] An acquisition module 801 is used to acquire a target image and a mosaic detection filter; the mosaic detection filter includes an image block detection function and a pixel point detection function;
[0165] An image division module 802 is used to divide the target image into a preset number of image blocks to obtain an image block set;
[0166] An image block mosaic detection module 803 is used to sequentially traverse the image blocks in the image block set, and for each traversed current image block, call the image block detection function to perform image block mosaic detection on the current image block to obtain image block discreteness;
[0167] A first threshold comparison module 804 is used to determine that there is no mosaic in the target image if the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold;
[0168] A pixel mosaic detection module 805 is configured to, if there is an image block whose image block discreteness is less than the first detection threshold in the image block set, determine the image block whose image block discreteness is less than the first detection threshold as a target image block, and call the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain a pixel difference value of each pixel in the target image block;
[0169] The second threshold comparison module 806 is used to determine that mosaic exists in the target image block if the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold.
[0170] In some embodiments, the apparatus 800 may further include:
[0171] A source file construction module, used to construct a mosaic detection source file; the mosaic detection source file defines a preset name of the mosaic detection filter, the image block detection function and the pixel point detection function;
[0172] A declaration statement adding module, used for adding a declaration statement for the mosaic detection filter in a registration file based on the preset name to obtain a target registration file;
[0173] A compilation target statement adding module is used to add a compilation target statement in a compilation content configuration file to obtain a target compilation configuration file; the target compilation configuration file is used to instruct to compile the mosaic detection source file into a mosaic detection filter;
[0174] The compiling and building module is used to add a compiling option statement in a filter configuration file to obtain a target filter configuration file; and compile the mosaic detection source file based on the target filter configuration file, the target compiling configuration file and the target registration file to obtain the mosaic detection filter.
[0175] In some embodiments, the apparatus further comprises:
[0176] an initialization module, configured to respond to an image detection request for the target image and initialize the mosaic detection filter based on a filter description statement carried in the image detection request; the filter description statement includes a preset name corresponding to the mosaic detector, the first detection threshold, and the second detection threshold;
[0177] A configuration verification module is used to, when calling the configuration verification function to determine that the mosaic detection filter is successfully initialized, sequentially traverse the image blocks in the image block set, and for each traversed current image block, call the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness.
[0178] In some embodiments, the image segmentation module may include:
[0179] A luminance component data acquisition submodule, used to acquire luminance component data of the target image in a preset color space coordinate system;
[0180] A brightness image generation submodule, used to generate a brightness image according to the brightness component data;
[0181] The image division submodule is used to divide the brightness image into a preset number of image blocks to obtain the image block set.
[0182] In some embodiments, the image block mosaic detection module may include:
[0183] A pixel brightness acquisition submodule, used to acquire the brightness component of each pixel of the current image block;
[0184] A brightness average value determination submodule, used to determine the brightness average value according to the brightness components of each pixel point;
[0185] An initial discrete value determination submodule, used to determine the absolute value of the difference between the brightness component of each pixel and the brightness average value as an initial discrete value;
[0186] The image discreteness determination submodule is used to determine the average value of the initial discrete values as the image discreteness.
[0187] In some embodiments, the pixel mosaic detection module may include:
[0188] A pixel traversal submodule, used to traverse each pixel in the target image block in turn, and for each traversed current pixel, obtain a brightness component of the current pixel;
[0189] A target pixel point determination submodule is used to determine a pixel point adjacent to the current pixel point as a target pixel point, and obtain a brightness component of the target pixel point;
[0190] The pixel difference determination submodule is used to determine the pixel difference corresponding to the current pixel based on the brightness component of the current pixel and the brightness component of the target pixel.
[0191] In some embodiments, the pixel difference determination submodule may include:
[0192] A difference value set determining unit, used to obtain the difference between the brightness component of the current pixel and the brightness components of the plurality of target pixels, to obtain a difference value set;
[0193] The pixel difference determination unit is used to determine the minimum value in the difference set as the pixel difference corresponding to the current pixel.
[0194] The device and method embodiments in the described device embodiments are based on the same inventive concept.
[0195] An embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the method provided in the above method embodiment.
[0196] An embodiment of the present application also provides a computer storage medium, which can be set in a terminal to store at least one instruction or at least one program related to a method provided in the above method embodiment for implementing a method embodiment, and the at least one instruction or at least one program is loaded and executed by the processor to implement the method provided in the above method embodiment.
[0197] The embodiments of the present application also provide a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the method provided in the above method embodiment.
[0198] Optionally, in the embodiment of the present application, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in the present embodiment, the storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0199] The memory described in the embodiment of the present application can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0200] The method provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Fig. 9 1 is a hardware structure block diagram of a server of an image detection method based on a mosaic detection filter provided in an embodiment of the present application. Fig. 9 As shown, the server 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 910 (the central processing unit 910 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 930 for storing data, and one or more storage media 920 (such as one or more mass storage devices) for storing application programs 923 or data 922. Among them, the memory 930 and the storage medium 920 can be short-term storage or permanent storage. The program stored in the storage medium 920 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 910 can be configured to communicate with the storage medium 920 and execute a series of instruction operations in the storage medium 920 on the server 900. The server 900 may also include one or more power supplies 960, one or more wired or wireless network interfaces 950, one or more input and output interfaces 940, and / or one or more operating systems 921, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0201] The input / output interface 940 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the server 900. In one example, the input / output interface 940 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 940 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0202] It can be understood by those skilled in the art that Fig. 9 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig. 9 More or fewer components as shown, or with Fig. 9 Different configurations are shown.
[0203] It can be seen from the embodiments of the image detection method, device and storage medium based on the mosaic detection filter provided by the present application that the present application first obtains a target image and a mosaic detection filter; wherein the mosaic detection filter includes an image block detection function and a pixel point detection function; the target image is divided into a preset number of image blocks to obtain an image block set; then the image blocks in the image block set are traversed in sequence, and for each current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness; if the image discreteness of each image block in the image block set is greater than or equal to the first detection threshold, it is determined that there is no mosaic in the target image; if there is an image block in the image block set whose image block discreteness is less than the first detection threshold, the image block whose image block discreteness is less than the first detection threshold is determined as the target image block, and the pixel point detection function is called to perform pixel point mosaic detection on each pixel point in the target image block to obtain the pixel difference value of each pixel point in the target image block; if the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold, it is determined that there is a mosaic in the target image block. This application uses a block processing method to first use the image block detection function in the mosaic detection filter to perform image block detection, and then use the pixel point detection function in the mosaic detection filter to further detect the target image block without traversing and comparing the pixels of the entire image, thereby shortening the processing time of image detection and improving the accuracy of mosaic detection. Image detection based on the mosaic detection filter can quickly and accurately identify mosaics in the image, providing image quality assurance for subsequent intelligent image analysis during autonomous driving.
[0204] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of this specification are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0205] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0206] A person skilled in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0207] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. An image detection method based on a mosaic detection filter, characterized in that: The method comprises: Acquire a target image and a mosaic detection filter; the mosaic detection filter includes an image block detection function and a pixel point detection function; Dividing the target image into a preset number of image blocks to obtain an image block set; The image blocks in the image block set are traversed in sequence, and for each traversed current image block, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness; If the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold, determining that there is no mosaic in the target image; If there is an image block whose image block discreteness is less than the first detection threshold in the image block set, determine the image block whose image block discreteness is less than the first detection threshold as a target image block, and call the pixel point detection function to perform pixel point mosaic detection on each pixel point in the target image block to obtain a pixel difference value of each pixel point in the target image block; If the pixel difference value of each pixel point in the target image block is greater than or equal to the second detection threshold, it is determined that mosaic exists in the target image block.
2. The method according to claim 1, characterized in that The method for constructing the mosaic detection filter comprises: Constructing a mosaic detection source file; the mosaic detection source file defines a preset name of the mosaic detection filter, the image block detection function and the pixel point detection function; Based on the preset name, adding a declaration statement for the mosaic detection filter in a registration file to obtain a target registration file; Adding a compilation target statement in a compilation content configuration file to obtain a target compilation configuration file; the target compilation configuration file is used to instruct to compile the mosaic detection source file into a mosaic detection filter; A compile option statement is added to the filter configuration file to obtain a target filter configuration file; and the mosaic detection source file is compiled based on the target filter configuration file, the target compile configuration file and the target registration file to obtain the mosaic detection filter.
3. The method according to claim 1, characterized in that Before sequentially traversing the image blocks in the image block set and, for each traversed current image block, calling the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness, the method further includes: In response to an image detection request for the target image, initializing the mosaic detection filter based on a filter description statement carried in the image detection request; the filter description statement includes a preset name corresponding to the mosaic detector, the first detection threshold, and the second detection threshold; When the configuration verification function is called to determine that the mosaic detection filter is successfully initialized, the image blocks in the image block set are traversed in sequence, and for each current image block traversed, the image block detection function is called to perform image block mosaic detection on the current image block to obtain the image block discreteness.
4. The method according to claim 1, characterized in that: The step of dividing the target image into a preset number of image blocks to obtain an image block set includes: Acquire brightness component data of the target image in a preset color space coordinate system; generating a luminance image according to the luminance component data; The brightness image is divided into a preset number of image blocks to obtain the image block set.
5. The method according to claim 1, characterized in that The calling of the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness includes: Obtaining the brightness component of each pixel of the current image block; Determine a brightness average value according to the brightness components of each pixel; Determine the absolute value of the difference between the brightness component of each pixel and the brightness average value as an initial discrete value; The average value of the initial discrete values is determined as the image discreteness.
6. The method according to claim 1, characterized in that The calling of the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain a pixel difference value of each pixel in the target image block includes: Traversing each pixel point in the target image block in turn, and for each traversed current pixel point, obtaining the brightness component of the current pixel point; Determine a pixel point adjacent to the current pixel point as a target pixel point, and obtain a brightness component of the target pixel point; Based on the brightness component of the current pixel and the brightness component of the target pixel, a pixel difference corresponding to the current pixel is determined.
7. The method according to claim 6, characterized in that There are multiple target pixels; and determining the pixel difference corresponding to the current pixel based on the brightness component of the current pixel and the brightness component of the target pixel, comprises: Obtaining differences between the brightness component of the current pixel and the brightness components of the plurality of target pixels to obtain a difference set; The minimum value in the difference value set is determined as the pixel difference value corresponding to the current pixel point.
8. An image detection device based on a mosaic detection filter, characterized in that: The device comprises: An acquisition module, used for acquiring a target image and a mosaic detection filter; the mosaic detection filter includes an image block detection function and a pixel point detection function; An image division module, used for dividing the target image into a preset number of image blocks to obtain an image block set; An image block mosaic detection module is used to sequentially traverse the image blocks in the image block set, and for each traversed current image block, call the image block detection function to perform image block mosaic detection on the current image block to obtain the image block discreteness; A first threshold comparison module, configured to determine that no mosaic exists in the target image if the image discreteness of each image block in the image block set is greater than or equal to a first detection threshold; a pixel mosaic detection module, configured to, if there is an image block whose image block discreteness is less than the first detection threshold in the image block set, determine the image block whose image block discreteness is less than the first detection threshold as a target image block, and call the pixel detection function to perform pixel mosaic detection on each pixel in the target image block to obtain a pixel difference value of each pixel in the target image block; The second threshold comparison module is used to determine that mosaic exists in the target image block if the pixel difference value of each pixel point in the target image block is greater than or equal to a second detection threshold.
9. An electronic device, characterized in that: The electronic device includes: a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the image detection method based on the mosaic detection filter as described in any one of claims 1-7.
10. A computer storage medium, characterized in that: The computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the image detection method based on the mosaic detection filter as described in any one of claims 1-7.