Laser field mirror dirt detection method, detection system and dirt identification device
Through grayscale processing and screening of the laser field mirror image, combined with local threshold screening, the laser field mirror contamination detection is realized, which solves the problem of contamination affecting image quality during the welding process and provides a fast and accurate detection method.
Patent Information
- Application Number
- CN202310810326.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-03
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2043-07-03
AI Technical Summary
In the field of intelligent welding, welding slag particles are adsorbed on the surface of the laser field mirror and affect image quality. A fast and effective dirt detection method is needed to ensure image quality.
By acquiring the dirty image, convert it into a grayscale image, perform binarization and foreground area connection processing, combine the grayscale average value, maximum value and area filtering to remove clear and dirty areas, perform local threshold filtering, and merge clear and blurry areas. Dirty areas, generate detection results.
It can quickly and accurately detect the location of dirt on the laser field mirror, provide assistance for subsequent cleaning work, ensure image quality, and have low computing power costs.
Smart Images

Figure CN116823788B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision detection, and in particular to a laser field mirror dirt detection method, a detection system and a dirt recognition device. Background Art
[0002] Laser field mirror is a kind of precision optical component, which is widely used in various machine vision fields. When laser field mirror is used in the field of intelligent welding, welding will produce welding slag particles, which will be adsorbed on the surface of laser field mirror and affect the image quality captured by laser field mirror.
[0003] How to detect dirt on the surface of the laser field mirror to ensure the quality of subsequent images is a technical problem that needs to be solved in this field. Summary of the invention
[0004] Based on this, the purpose of the present invention is to provide a laser field mirror contamination detection method which is quick, convenient and can achieve better detection effect.
[0005] A method for detecting contamination of a laser field mirror comprises the following steps:
[0006] S1, obtain a dirty image;
[0007] S2, converting the dirty image into a grayscale image;
[0008] S3, performing binarization and foreground area connectivity processing on the grayscale image to obtain a primary screening foreground image;
[0009] S4, performing grayscale average value screening, grayscale maximum value screening and area screening on the primary screening foreground image to obtain a clear dirty area;
[0010] S5, removing the clear and dirty areas of the grayscale image, leaving the background image;
[0011] S6, performing local threshold screening on the background image to obtain a blurred dirty area;
[0012] S7, merging the clear dirty area and the fuzzy dirty area to obtain a detection result.
[0013] This laser field mirror dirt detection method can quickly determine the location of dirt on the laser field mirror based on a photo of the laser field mirror, providing assistance for subsequent cleaning work.
[0014] Furthermore, the step S4 comprises the following steps:
[0015] S41, performing grayscale average screening on the primary screening foreground image to obtain a second foreground image;
[0016] S42, performing grayscale maximum value screening on the second foreground image to obtain a third foreground image;
[0017] S43, performing area screening on the third foreground image to obtain a clear dirty area;
[0018] The grayscale average screening is performed by the following method: comparing the grayscale average of each connected region in the image with a set grayscale average interval, and if the grayscale average of the connected region is within the grayscale average interval, the connected region is selected;
[0019] The grayscale maximum value screening is performed by the following method: comparing the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected;
[0020] The area screening is performed by the following method: comparing the area of each connected region in the image with a set area interval, and if the area of the connected region is within the area interval, the connected region is selected.
[0021] Furthermore, step S6 includes the following steps:
[0022] S61, filtering the background image to obtain a filtered image;
[0023] S62, comparing the difference between the filtered image and the background image to obtain a blurred dirty area;
[0024] The step S62 is specifically as follows: subtract the grayscale values of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; and perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area.
[0025] Furthermore, the step S2 comprises the following steps:
[0026] S21, defining a region of interest on the dirty image to obtain a region of interest image;
[0027] S22, performing contrast enhancement on the image of the region of interest to obtain an enhanced image;
[0028] S23, calculating the grayscale of the enhanced image, and removing data with a grayscale less than a grayscale threshold, to obtain a grayscale image.
[0029] Furthermore, the step S3 is specifically as follows: binarizing the grayscale image through an automatic threshold selection algorithm to segment a number of background areas and foreground areas; performing regional connectivity processing on the foreground areas to obtain a first foreground set; cropping the grayscale image according to the first foreground set to obtain a preliminary screening foreground image; the automatic threshold selection algorithm automatically selects a suitable threshold to segment the image into foreground and background when processing the image.
[0030] A laser field mirror dirt detection system, characterized in that it comprises a camera and a dirt recognition device; the camera captures a dirt image of the laser field mirror and transmits the dirt image to the dirt recognition device; the dirt recognition device comprises:
[0031] A dirty image acquisition module, used for acquiring a dirty image;
[0032] A grayscale image acquisition module, used for converting the dirty image into a grayscale image;
[0033] A preliminary screening module, used for performing binarization and foreground area connectivity processing on the grayscale image to obtain a preliminary screening foreground image;
[0034] A secondary screening module is used to perform grayscale average screening, grayscale maximum screening and area screening on the primary screening foreground image to obtain a clear dirty area;
[0035] A background image acquisition module, used to remove the clear dirty areas of the grayscale image, leaving the background image;
[0036] A local threshold screening module, used for performing local threshold screening on the background image to obtain a fuzzy dirty area;
[0037] The result output module is used to merge the clear dirty area with the fuzzy dirty area to obtain a detection result.
[0038] Further, the secondary screening module includes: a grayscale average screening unit, a grayscale maximum screening unit and an area screening unit;
[0039] The grayscale average screening unit is used to perform grayscale average screening on the primary screening foreground image to obtain a second foreground image; wherein the grayscale average screening is to compare the grayscale average of each connected area in the image with a set grayscale average interval, and if the grayscale average of the connected area is within the grayscale average interval, the connected area is selected.
[0040] The grayscale maximum screening unit is used to perform grayscale maximum screening on the second foreground image to obtain a third foreground image; wherein the grayscale maximum screening is to compare the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected;
[0041] The area screening unit is used to perform area screening on the third foreground image to obtain a clear dirty area; wherein the area screening is to compare the area of each connected area in the image with a set area interval, and if the area of the connected area is within the area interval, the connected area is selected.
[0042] Further, the local threshold screening module includes: a filtering unit and a local threshold extraction unit;
[0043] The filtering unit is used to filter the background image to obtain a filtered image;
[0044] The local threshold extraction unit is used to subtract the grayscale values of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; and perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area.
[0045] A dirt identification device, comprising:
[0046] A dirty image acquisition module, used for acquiring a dirty image;
[0047] A grayscale image acquisition module, used for converting the dirty image into a grayscale image;
[0048] A preliminary screening module, used for performing binarization and foreground area connectivity processing on the grayscale image to obtain a preliminary screening foreground image;
[0049] A secondary screening module is used to perform grayscale average screening, grayscale maximum screening and area screening on the primary screening foreground image to obtain a clear dirty area;
[0050] A background image acquisition module, used to remove the clear dirty areas of the grayscale image, leaving the background image;
[0051] A local threshold screening module, used for performing local threshold screening on the background image to obtain a fuzzy dirty area;
[0052] The result output module is used to merge the clear dirty area with the fuzzy dirty area to obtain a detection result.
[0053] Further, the secondary screening module includes: a grayscale average screening unit, a grayscale maximum screening unit and an area screening unit;
[0054] The grayscale average screening unit is used to perform grayscale average screening on the primary screening foreground image to obtain a second foreground image; wherein the grayscale average screening is to compare the grayscale average of each connected area in the image with a set grayscale average interval, and if the grayscale average of the connected area is within the grayscale average interval, the connected area is selected.
[0055] The grayscale maximum screening unit is used to perform grayscale maximum screening on the second foreground image to obtain a third foreground image; wherein the grayscale maximum screening is to compare the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected;
[0056] The area screening unit is used to perform area screening on the third foreground image to obtain a clear dirty area; wherein the area screening is to compare the area of each connected area in the image with a set area interval, and if the area of the connected area is within the area interval, the connected area is selected.
[0057] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a schematic diagram of the laser field mirror dirt detection system of the present invention;
[0059] Figure 2 It is a schematic diagram of a module of the dirt identification device of the present invention;
[0060] Figure 3 for Figure 2 The flowchart of the laser field mirror dirt detection method performed by the dirt recognition device shown. DETAILED DESCRIPTION
[0061] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0062] See also Figure 1 , Figure 1 Schematic diagram of the laser field mirror contamination detection system of the present invention.
[0063] The laser field mirror dirt detection system of the present invention comprises: a light source 2, a camera 3 and a dirt recognition device. The light source 2 is aimed at the laser field mirror 1 to provide bright light. The camera 3 faces the laser field mirror 1 to capture a dirt image and transmits the dirt image to the dirt recognition device. The dirt recognition device detects the dirt area on the laser field mirror 1 and transmits the detection result to the host computer.
[0064] See also Figure 2 and Figure 3 , Figure 2 This is a module diagram of a dirt recognition device. Figure 3 for Figure 2 The flowchart of the laser field mirror dirt detection method performed by the dirt recognition device shown.
[0065] Specifically, the dirt identification device includes a dirt image acquisition module G1, a grayscale image acquisition module G2, a primary screening module G3, a secondary screening module G4, a background image acquisition module G5, a local threshold screening module G6 and a result output module G7.
[0066] The dirty image acquisition module G1 is used to execute step S1: acquiring a dirty image.
[0067] The grayscale image acquisition module G2 is used to execute step S2: converting the dirty image into a grayscale image. The grayscale image acquisition module G2 includes an area of interest acquisition unit, a contrast enhancement unit, and a grayscale processing unit.
[0068] Specifically, the region of interest acquisition unit is used to execute step S21: delineate a region of interest on the dirty image to obtain an image of the region of interest. The reason for delineating the region of interest is that the photo-taking position where the product arrives each time is relatively fixed, and the position of the area to be detected in each image remains basically unchanged, so delineating the region of interest can reduce the workload. Specifically in the field of laser field mirror dirt detection, metal reflections may appear at the edge of the laser field mirror, resulting in a light spot shaped like dirt in the image. Failure to delineate the region of interest will affect the detection accuracy. The shape and size of the region of interest need to match the laser field mirror. In this embodiment, since the laser field mirror is circular, the region of interest is also circular.
[0069] The contrast enhancement unit is used to perform step S22: contrast enhancement of the image of the region of interest to obtain an enhanced image. Contrast enhancement is to adjust the image contrast through a matrix composed of horizontal parameters and vertical parameters and a contrast factor. The specific parameters of contrast enhancement are manually set in the software interface according to the lighting conditions on site, so that the dirty foreground and background can be clearly distinguished.
[0070] The grayscale processing unit is used to perform step S23: calculate the grayscale of the enhanced image and remove data with grayscale less than the grayscale threshold to obtain a grayscale image. Since the brightness of the dirty foreground is relatively bright, it is basically located in the section with grayscale above 45% on the grayscale histogram. Therefore, in this embodiment, the grayscale threshold is set to 45%. Removing data with grayscale between 0% and 45% can remove most of the background that does not contain dirt.
[0071] The preliminary screening module G3 is used to execute step S3: binarize the grayscale image and connect the foreground area to obtain a preliminary screening foreground image. Specifically, step S3 uses an automatic threshold selection algorithm to binarize the grayscale image to segment a number of background areas and foreground areas; perform regional connectivity processing on the foreground area to obtain a first foreground set; and crop the grayscale image according to the first foreground set to obtain a preliminary screening foreground image. When processing images of different brightness, the automatic threshold selection algorithm automatically selects a suitable threshold to segment the image into foreground and background without manually selecting a threshold.
[0072] The secondary screening module G4 is used to execute step S4: grayscale average screening, grayscale maximum screening and area screening are performed on the primary screening foreground image to obtain a clear dirty area. The secondary screening module includes a grayscale average screening unit, a grayscale maximum screening unit and an area screening unit.
[0073] Specifically, the grayscale average screening unit is used to perform step S41: grayscale average screening of the primary screening foreground image to obtain a second foreground image. The grayscale average screening is performed by the following method: comparing the grayscale average of each connected area in the image with a set grayscale average interval, if the grayscale average of the connected area is within the grayscale average interval, then the connected area is selected, otherwise the connected area is not selected.
[0074] The step S41 is specifically as follows: setting a grayscale average value interval; calculating the grayscale average value of each connected area in the preliminary screening foreground image, and comparing the grayscale average value of each connected area with the grayscale average value interval; if the grayscale average value of the connected area is within the grayscale average value interval, the connected area is selected; if the grayscale average value of the connected area is outside the grayscale average value interval, the connected area is not selected; after traversing each connected area in the preliminary screening foreground image, all selected connected areas constitute a second foreground image.
[0075] Specifically, the grayscale maximum screening unit is used to execute step S42: performing grayscale maximum screening on the second foreground image to obtain a third foreground image. The grayscale maximum screening is performed by the following method: comparing the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, if the grayscale maximum value of the connected area is within the grayscale maximum value interval, then the connected area is selected, otherwise the connected area is not selected.
[0076] The step S42 is specifically as follows: setting a grayscale maximum interval; calculating the grayscale maximum value of each connected area in the second foreground image, and comparing the grayscale maximum value of each connected area with the grayscale maximum interval; if the grayscale maximum value of the connected area is within the grayscale maximum interval, the connected area is selected; if the grayscale maximum value of the connected area is outside the grayscale maximum interval, the connected area is not selected; after traversing each connected area in the second foreground image, all selected connected areas form the third foreground image. In this embodiment, the upper limit of the maximum grayscale interval is set to 255, and the lower limit is set to 180.
[0077] Specifically, the area screening unit is used to execute step S43: performing area screening on the third foreground image to obtain a clear dirty area. The area screening is performed by the following method: comparing the area of each connected area in the image with a set area interval, and if the area of the connected area is within the area interval, the connected area is selected, otherwise the connected area is not selected.
[0078] The step S43 is specifically as follows: setting an area interval; calculating the area of each connected region in the third foreground image; comparing the area of each connected region with the area interval, if the area of the connected region is within the area interval, then the connected region is selected; if the area of the connected region is outside the area interval, then the connected region is not selected; after traversing each connected region in the third foreground image, all selected connected regions form a clear dirty region. Since the light spot caused by metal reflection is often large in area, while the light spot caused by dirt is relatively small in area, and the area with a very small area is often noise, area screening can effectively eliminate the errors caused by metal reflection and noise.
[0079] The background image acquisition module G5 is used to execute step S5: remove the clear dirty area of the grayscale image and leave the background image. The step S5 is specifically: slightly dilate the clear dirty area to obtain the dilated foreground area; take the complement of the dilated foreground area to obtain the background area; and crop the grayscale image according to the background area to obtain the background image. The reason why the clear dirty area is first dilated and then taken the complement is to avoid some unclear dirty edge information in the background image due to direct complement, which affects the effect of subsequent local threshold screening.
[0080] The local threshold screening module G6 is used to execute step S6: perform local threshold screening on the background image to obtain a blurred dirty area. The local threshold screening module G6 includes a filtering unit and a local threshold extraction unit.
[0081] Specifically, the filtering unit is used to perform step S61: filtering the background image to obtain a filtered image. The step S61 is specifically: selecting a convolution kernel with a size similar to that of the dirt, performing mean filtering on the background image to obtain a filtered image. In other embodiments, other filtering methods may be selected, such as median filtering and Gaussian filtering.
[0082] Specifically, the local threshold extraction unit is used to execute step S62: compare the difference between the filtered image and the background image to obtain a blurred dirty area. The step S62 is specifically: subtract the grayscale value of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area. The local threshold extraction algorithm segments the image by detecting the change in grayscale value at the edge of the object, and is suitable for segmenting images with blurred object edges.
[0083] The result output module G7 is used to execute step S7: merging the clear dirty area with the fuzzy dirty area to obtain a detection result.
[0084] Compared with the prior art, the laser field mirror dirtiness detection method of the present invention solves the problem of how to automatically detect dirtiness on the surface of the laser field mirror to ensure the quality of subsequent images taken. It is quick and convenient, and can achieve better detection effects with less computing power cost.
[0085] Based on a laser field mirror dirt detection method provided in this embodiment, this embodiment further provides a computer device, which may be a terminal device such as a server, a desktop computing device, or a mobile computing device (for example, a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.), and includes:
[0086] processor;
[0087] a memory for storing a computer program executed by the processor;
[0088] Wherein, when the processor executes the computer program, the laser field mirror contamination detection method of the present invention is implemented.
[0089] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the laser field mirror contamination detection method described in the embodiment of the present invention is implemented.
[0090] The present application may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Computer-usable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0091] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A method for detecting contamination of a laser field mirror, comprising the following steps: Step S1, obtaining a dirty image; Step S2, converting the dirty image into a grayscale image; Step S3, binarizing the grayscale image and performing foreground area connectivity processing to obtain a primary screening foreground image; Step S4, performing grayscale average value screening, grayscale maximum value screening and area screening on the primary screening foreground image to obtain a clear dirty area; Step S5, removing the clear dirty areas of the grayscale image, leaving the background image; Step S6, performing local threshold screening on the background image to obtain a blurred dirty area; Step S7, merging the clear dirty area with the fuzzy dirty area to obtain a detection result; The grayscale average screening is performed by the following method: comparing the grayscale average of each connected region in the image with a set grayscale average interval, and if the grayscale average of the connected region is within the grayscale average interval, the connected region is selected; The grayscale maximum value screening is performed by the following method: comparing the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected; The area screening is performed by the following method: comparing the area of each connected region in the image with a set area interval, and if the area of the connected region is within the area interval, the connected region is selected; In addition, the step S6 includes the following steps: Step S61, filtering the background image to obtain a filtered image; Step S62, comparing the difference between the filtered image and the background image to obtain a blurred dirty area; The step S62 is specifically as follows: subtract the grayscale values of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; and perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area.
2. The laser field mirror contamination detection method according to claim 1, characterized in that: The step S4 comprises the following steps: Step S41, performing grayscale average screening on the primary screening foreground image to obtain a second foreground image; Step S42, performing grayscale maximum value screening on the second foreground image to obtain a third foreground image; Step S43: performing area screening on the third foreground image to obtain a clear dirty area.
3. The laser field mirror contamination detection method according to claim 1, characterized in that: The step S2 specifically includes: defining a region of interest on the dirty image to obtain a region of interest image; performing contrast enhancement on the region of interest image to obtain an enhanced image; The grayscale of the enhanced image is calculated, and data with a grayscale less than a grayscale threshold is removed to obtain a grayscale image.
4. The laser field mirror contamination detection method according to claim 3, characterized in that: The step S3 is specifically as follows: binarizing the grayscale image through an automatic threshold selection algorithm to segment a number of background areas and foreground areas; performing regional connectivity processing on the foreground areas to obtain a first foreground set; cropping the grayscale image according to the first foreground set to obtain a preliminary screening foreground image; the automatic threshold selection algorithm automatically selects a suitable threshold to segment the image into foreground and background when processing the image.
5. A laser field mirror dirt detection system, characterized in that: It includes a camera and a dirt recognition device; the camera captures a dirt image of the laser field mirror and transmits the dirt image to the dirt recognition device; The dirt identification device comprises: A dirty image acquisition module, used for acquiring a dirty image; A grayscale image acquisition module, used for converting the dirty image into a grayscale image; A preliminary screening module, used for performing binarization and foreground area connectivity processing on the grayscale image to obtain a preliminary screening foreground image; A secondary screening module is used to perform grayscale average screening, grayscale maximum screening and area screening on the primary screening foreground image to obtain a clear dirty area; A background image acquisition module, used to remove the clear dirty areas of the grayscale image, leaving the background image; A local threshold screening module, used for performing local threshold screening on the background image to obtain a fuzzy dirty area; A result output module, used for merging the clear dirty area with the fuzzy dirty area to obtain a detection result; The grayscale average screening is to compare the grayscale average of each connected area in the image with a set grayscale average interval, and if the grayscale average of the connected area is within the grayscale average interval, the connected area is selected; The grayscale maximum value screening is to compare the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected; The area screening is to compare the area of each connected region in the image with a set area interval, and if the area of the connected region is within the area interval, the connected region is selected; In addition, the local threshold screening module includes: a filtering unit and a local threshold extraction unit; The filtering unit is used to filter the background image to obtain a filtered image; The local threshold extraction unit is used to subtract the grayscale values of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; and perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area.
6. The laser field mirror dirt detection system according to claim 5, characterized in that: The secondary screening module includes: a grayscale average screening unit, a grayscale maximum screening unit and an area screening unit; The grayscale average screening unit is used to perform grayscale average screening on the primary screening foreground image to obtain a second foreground image; the grayscale maximum screening unit is used to perform grayscale maximum screening on the second foreground image to obtain a third foreground image; The area screening unit is used to perform area screening on the third foreground image to obtain a clear dirty area.
7. A dirt identification device, comprising: A dirty image acquisition module, used for acquiring a dirty image; A grayscale image acquisition module, used for converting the dirty image into a grayscale image; A preliminary screening module, used for performing binarization and foreground area connectivity processing on the grayscale image to obtain a preliminary screening foreground image; A secondary screening module is used to perform grayscale average screening, grayscale maximum screening and area screening on the primary screening foreground image to obtain a clear dirty area; A background image acquisition module, used to remove the clear dirty areas of the grayscale image, leaving the background image; A local threshold screening module, used for performing local threshold screening on the background image to obtain a fuzzy dirty area; A result output module, used for merging the clear dirty area with the fuzzy dirty area to obtain a detection result; The grayscale average screening is to compare the grayscale average of each connected area in the image with a set grayscale average interval, and if the grayscale average of the connected area is within the grayscale average interval, the connected area is selected; The grayscale maximum value screening is to compare the grayscale maximum value of each connected area in the image with a set grayscale maximum value interval, and if the grayscale maximum value of the connected area is within the grayscale maximum value interval, the connected area is selected; The area screening is to compare the area of each connected region in the image with a set area interval, and if the area of the connected region is within the area interval, the connected region is selected; In addition, the local threshold screening module includes: a filtering unit and a local threshold extraction unit; The filtering unit is used to filter the background image to obtain a filtered image; The local threshold extraction unit is used to subtract the grayscale values of the filtered image from the background image to obtain a difference image; perform edge extraction on the difference image through a local threshold extraction algorithm to obtain a blurred area; crop the background image according to the blurred area to obtain a blurred area image; and perform grayscale average value screening, grayscale maximum value screening and area screening on the blurred area image again to obtain a blurred dirty area.
8. The dirt identification device according to claim 7, characterized in that: The secondary screening module includes: a grayscale average screening unit, a grayscale maximum screening unit and an area screening unit; The grayscale average screening unit is used to perform grayscale average screening on the primary screening foreground image to obtain a second foreground image; The grayscale maximum screening unit is used to perform grayscale maximum screening on the second foreground image to obtain a third foreground image; The area screening unit is used to perform area screening on the third foreground image to obtain a clear dirty area.
