Image detection method and system
By reducing the resolution of high-resolution images, segmenting them, and performing two detections, the problem of low efficiency in detecting small defects in high-resolution images is solved, achieving efficient and accurate defect detection.
Patent Information
- Application Number
- CN202411391509.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-07
AI Technical Summary
When using a high-resolution camera to acquire images, the information available for detection is reduced after scaling, making it impossible to detect small defects in high-resolution images. Furthermore, traditional methods such as sliding window processing are time-consuming and cannot meet the time constraints of actual projects.
After reducing the resolution of the image to be detected, it is divided into the first image block. The image detection model is used to perform coarse-grained detection to identify the abnormal region. Then, the second image block is extracted from the image to be detected for fine-grained detection. The final abnormal detection result is determined by combining the results of the two detections.
It improves detection efficiency and accuracy, avoids the problem of small defects not being detected after scaling, and reduces detection time.
Smart Images

Figure CN119273663A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an image detection method and system. Background Art
[0002] In recent years, high-resolution cameras have gradually been widely used. Using a high-resolution camera can capture more detailed information.
[0003] If a high-resolution camera is used to acquire images, and when defect detection is performed on the acquired images, if the images are scaled to an appropriate size and then input into the detection model to detect image defects, the information in the scaled image is significantly less than the information in the high-resolution image. Using the scaled image for detection will result in the inability to detect smaller defects in the high-resolution image. Summary of the invention
[0004] In view of this, the present application provides an image detection method and system, the specific scheme of which is as follows:
[0005] An image detection method, comprising:
[0006] Processing the image to be detected to obtain a first number of first image blocks;
[0007] Based on a first detection result of detecting the first number of first image blocks by an image detection model, determining a second number of second image blocks from the image to be detected, wherein the areas of the second image blocks are smaller than those of the first image blocks; wherein the first detection result represents first abnormal area information of the first image block, and the second image block includes at least one area corresponding to the first abnormal area information;
[0008] Obtaining a second detection result of the image detection model detecting the at least one second image block, wherein the second detection result represents second abnormal region information of the at least one second image block;
[0009] An abnormality detection result in the image to be detected is determined based on the first abnormal area information and the second abnormal area information.
[0010] Furthermore, the first image block is of a target size, a resolution of the first image block is lower than a resolution of the image to be detected, the first detection result is a coarse-grained detection result, and the second detection result is a fine-grained detection result.
[0011] Furthermore, obtaining a second detection result of the image detection model detecting the at least one second image block includes:
[0012] splicing the second number of second image blocks into at least one spliced image;
[0013] A second detection result of the image detection model detecting the at least one stitched image is obtained.
[0014] Furthermore, the first detection result of detecting the first number of first image blocks based on the image detection model, determining a second number of second image blocks from the image to be detected, includes:
[0015] Detect the first number of first image blocks based on the image detection model to obtain the first detection result;
[0016] Based on the fact that the first image block indicated by the first abnormal area information includes a first area set whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold, a second image block is intercepted from a target area of the image to be detected, where the target area is an area in the image to be detected corresponding to an area whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold.
[0017] Further, the determining the abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information includes:
[0018] Based on the position information of each second area in the second area set and the position information of each third area in the third area set, the abnormality detection result in the image to be detected is determined; wherein the second area is a region in the first image block indicated by the first abnormal area information, the area of which is greater than a specific area threshold and the defect confidence is greater than a second threshold, and the third area is a region in the stitched image indicated by the second abnormal area information, the defect confidence is greater than the second threshold.
[0019] Further, the determining the abnormality detection result in the image to be detected based on the position information of each second area in the second area set and the position information of each third area in the third area set includes:
[0020] Determine the position information of each second region in the second region set based on the position information of the first image block corresponding to each second region in the second region set in the image to be detected and the position information of each second region in the second region set in the first image block where the second region is located;
[0021] Determine the position information of each third region in the third region set based on the position information of each third region in the stitched image, the identifier of the second image block corresponding to the second abnormal region information, and the position of the second image block corresponding to the second abnormal region information at the image to be detected;
[0022] An abnormality detection result in the image to be detected is determined based on the position information of each second area in the second area set and the position information of each third area in the third area set.
[0023] Furthermore, stitching the second number of second image blocks into at least one stitched image includes:
[0024] determining a size parameter of each second image block in the second number of second image blocks;
[0025] Sequentially stitching the second number of second image blocks according to the size parameter to form at least one stitched image, where the at least one stitched image is of a target size;
[0026] Wherein, the target size is determined based on the target parameters of the image detection model.
[0027] Furthermore, it also includes:
[0028] Get the image template;
[0029] The step of sequentially splicing the second number of second image blocks according to the size parameter to form at least one spliced image includes:
[0030] Arranging the second number of second image blocks sorted according to the size parameter in sequence on the image template to form at least one spliced image;
[0031] Wherein, if the size parameter of the current second image block to be arranged does not match the current position of the image block to be arranged on the image template, determining whether the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template;
[0032] If it is determined that the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template, arranging the next second image block to the current position of the image block to be arranged on the image template;
[0033] If the positions of the image blocks to be arranged on the image template do not match the size parameters of the plurality of second image blocks to be arranged, the image template currently arranged with the second image blocks is determined as a spliced image.
[0034] Furthermore, it also includes:
[0035] If it is determined that the size parameter of the second image block to be arranged currently does not match the current position of the image block to be arranged on the image template, arrange the second image block to be arranged currently to a position in a row next to the current position of the image block to be arranged on the image template, or arrange the second image block to be arranged currently to a next image template;
[0036] If the size parameters of the third number of second image blocks to be arranged determined according to the sorting do not match the current positions of the image blocks to be arranged on the image template, it is determined that the current positions of the image blocks to be arranged on the image template are free.
[0037] An image detection system, comprising:
[0038] A processing unit, configured to process the image to be detected to obtain a first number of first image blocks;
[0039] A first determining unit is configured to determine a second number of second image blocks from the image to be detected based on a first detection result of detecting the first number of first image blocks by an image detection model, wherein the areas of the second image blocks are smaller than those of the first image blocks; wherein the first detection result represents first abnormal region information of the first image block, and the second image block includes at least one region corresponding to the first abnormal region information;
[0040] An obtaining unit, configured to obtain a second detection result of the image detection model detecting the at least one second image block, wherein the second detection result represents second abnormal region information of the at least one second image block;
[0041] The second determining unit is used to determine the abnormality detection result in the image to be detected based on the first abnormal area information and the second abnormal area information. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are 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 creative work.
[0043] Figure 1 A flowchart of an image detection method disclosed in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of segmenting an image after resolution reduction processing disclosed in an embodiment of the present application;
[0045] Figure 3A flowchart of an image detection method disclosed in an embodiment of the present application;
[0046] Figure 4 A flowchart of an image detection method disclosed in an embodiment of the present application;
[0047] Figure 5 A schematic diagram of determining two regions with abnormalities in an image to be detected to be the same second image block disclosed in an embodiment of the present application;
[0048] Figure 6 A schematic diagram of a correspondence between a second area, a first image block and an image to be detected disclosed in an embodiment of the present application;
[0049] Figure 7 A flowchart of an image detection method disclosed in an embodiment of the present application;
[0050] Figure 8 A complete flow chart of an image detection method disclosed in an embodiment of the present application;
[0051] Fig. 9 A schematic diagram of determining a second image block from an image to be detected, forming a spliced image and detecting the image is disclosed in an embodiment of the present application;
[0052] Fig.10a A schematic diagram of an arrangement on an image template according to size parameters of a second image block disclosed in an embodiment of the present application;
[0053] Fig.10b A schematic diagram of an arrangement on an image template according to size parameters of a second image block disclosed in an embodiment of the present application;
[0054] Fig.10c A schematic diagram of an arrangement on an image template according to size parameters of a second image block disclosed in an embodiment of the present application;
[0055] Fig.10d A schematic diagram of an arrangement on an image template according to size parameters of a second image block disclosed in an embodiment of the present application;
[0056] Fig.11 A schematic diagram of the structure of an image detection system disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0058] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0059] 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 need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0060] The present application discloses an image detection method, and its flow chart is as follows: Figure 1 As shown, including:
[0061] Step S11, processing the image to be detected to obtain a first number of first image blocks;
[0062] Step S12: based on the first detection result of detecting the first number of first image blocks by the image detection model, determine a second number of second image blocks from the image to be detected, where the area of the second image blocks is smaller than that of the first image blocks; wherein the first detection result represents first abnormal area information of the first image block, and the second image block includes at least one area corresponding to the first abnormal area information;
[0063] Step S13, obtaining a second detection result of the image detection model detecting at least one second image block, where the second detection result represents second abnormal region information of the at least one second image block;
[0064] Step S14: determining an abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information.
[0065] In recent years, high-resolution cameras have gradually been widely used. Using a high-resolution camera can capture more detailed information.
[0066] If a high-resolution camera is used to acquire images, and when defect detection is performed on the acquired images, if the images are scaled to an appropriate size and then input into the detection model to detect image defects, the information in the scaled image is significantly less than the information in the high-resolution image. Using the scaled image for detection will result in the inability to detect smaller defects in the high-resolution image, and the inability to maximize the use of the information in the high-resolution image, thus losing the value of using a high-cost camera. Alternatively, sliding window processing can be used for detection, such as dividing the acquired images into different sliding window blocks, and then individually detecting each sliding window block. Although this method can make full use of the high-resolution image, it is time-consuming and cannot meet the time requirements of actual projects.
[0067] Based on this, in this scheme, after obtaining the image to be detected, it is first processed to obtain a first number of first image blocks, the first image blocks are detected using an image detection model to obtain a first detection result, and the first detection result is used to determine a second number of second image blocks from the image to be detected, the second image blocks include an area corresponding to the first abnormal area information determined by the first detection result, and then the image detection model is used to detect at least one second image block to obtain a second detection result, and finally the two detection results are used to determine the abnormality in the image to be detected, first use the image block for detection, and then on this basis determine the second image block from the image to be detected for further detection, while ensuring the detection efficiency, while improving the detection accuracy.
[0068] When an image needs to be detected, the image to be detected is first determined, and then the image to be detected is processed to obtain a first number of first image blocks.
[0069] The step of processing the image to be detected to obtain a first number of first image blocks may specifically include: reducing the resolution of the image to be detected, and then segmenting the image with the reduced resolution to obtain the first number of first image blocks.
[0070] After the resolution of the image to be detected is reduced, it is divided into a first image block and input into the image detection model, which can improve the detection efficiency of the image detection model. After the abnormality is detected, the second image block is determined from the original image of the image to be detected for accurate detection, thereby improving the detection efficiency and ensuring the detection accuracy.
[0071] The image to be detected may be scaled to a specific size, and the resolution corresponding to the specific size may be 3072×1920 pixels. Of course, other sizes may also be used, which are not specifically limited here.
[0072] After the image to be detected is processed by reducing the resolution, the image after the resolution reduction processing is segmented. At this time, the image after the resolution reduction processing can be segmented into a first number of first image blocks, each of which has the same size, and there are overlapping parts between adjacent first image blocks to ensure that even when there are abnormal areas in adjacent parts, they can still be detected from adjacent first image blocks.
[0073] like Figure 2 As shown, it is a schematic diagram of dividing an image after resolution reduction processing, the first number is 2, and the image after resolution reduction processing is divided into 2 first image blocks, the image includes an abnormal area 21, a left first image block 22 and a right first image block 23, and the abnormal area is located in the middle of the image.
[0074] If the image is segmented according to the average segmentation, it is segmented into two first image blocks of exactly the same size according to the dotted line in the figure, and the two first image blocks are spliced to form a complete image after the resolution reduction processing; however, in this embodiment, the average segmentation is not performed directly, but according to Figure 2 The solid line in the dotted line is used as the boundary line of the first image block on the left, and the solid line on the left of the dotted line is used as the boundary line of the first image block on the right. The area between the two solid lines is in both the first image block on the left and the first image block on the right.
[0075] Since the abnormal area is located at the position of the dotted line, if the image is evenly divided into two first image blocks according to the dotted line, the abnormal area will be divided into two different first image blocks, which will increase the difficulty of determining the abnormal area. Figure 2 The first image block is segmented as shown by the solid line. After segmentation in this way, the abnormal area is not divided into two parts, but is located in two first image blocks as a complete whole, which reduces the difficulty of determining the abnormal area.
[0076] In addition, determination of the first number may be related to the size of the image after the resolution is reduced. The larger the size of the image after the resolution is reduced, the greater the first number, and the smaller the size of the image after the resolution is reduced, the smaller the first number.
[0077] A first number of first image blocks are input into an image detection model, and the image detection model detects whether there are abnormal areas in the first number of first image blocks, thereby obtaining a first detection result.
[0078] Since the first image block is obtained by dividing the image to be detected after reducing its resolution, the first detection result obtained by detecting the first image block at a lower resolution is a coarse-grained detection result, that is, the first detection result is not accurate, but a coarse-grained result, which is used to quickly determine the approximate location of the abnormal area, so that when performing fine-grained detection, there is no need to detect the entire image to be detected, but only to detect some areas where abnormalities may exist, thereby improving detection efficiency.
[0079] The first detection result can characterize the first abnormal region information of the first image block, and the first abnormal region information is the relevant information of the region with abnormality in the first image block. After determining the first abnormal region information in the first image block, the second image block is determined from the image to be detected based on the first abnormal region information, and the second image block may include at least one region corresponding to the first abnormal region information. That is, the relevant information of the region with abnormality in the first image block is determined according to the first detection result, and then the region with abnormality is determined and segmented from the image to be detected according to the relevant information of the region with abnormality in the first image block indicated in the first detection result, that is, the position of the region with abnormality in the first image block in the image to be detected is determined, and it is segmented into the second image block.
[0080] The area of the second image block is smaller than that of the first image block. Since the first image block is directly obtained by dividing the image to be detected with a reduced resolution, each first image block includes more areas without abnormalities. Therefore, the size of the first image block will be larger. The second image block is obtained by roughly determining which areas in the first image block may contain abnormal areas, and then dividing the areas in the image to be detected that may contain abnormalities. This means that there are not many areas without abnormalities in the second image block. Therefore, the size of the second image block is smaller than that of the first image block.
[0081] Of course, when segmenting the second image block, if it is determined based on the first detection result that the distance between at least two abnormal areas in the image to be detected is less than a certain threshold, then at least two abnormal areas in the image to be detected whose distance is less than the certain threshold can be segmented into the same second image block. This will not increase the number of non-abnormal areas and can also reduce the number of second image blocks.
[0082] The abnormal region may be an irregular region, and the second image block is a regular image block. Therefore, each complete abnormal region must be included in a second image block. However, a second image block may include no less than one complete abnormal region.
[0083] The second image block is directly cut out from the original image of the image to be detected. After the second image block is used for anomaly detection, the result obtained can ensure that it has high accuracy, thereby achieving the goal of improving detection accuracy while ensuring detection efficiency.
[0084] After a second number of second image blocks are cut out from the image to be detected, at least one second image block is input into the image detection model so that the image detection model performs fine-grained detection based on the high-resolution second image block to obtain a fine-grained detection result, and the second detection result is the fine-grained detection result. The second detection result characterizes the second abnormal region information of the at least one second image block, that is, the relevant information of the region where the abnormality exists in the at least one second image block.
[0085] After obtaining the second detection result, the first detection result may be combined with the second detection result to obtain a complete abnormality detection result of the image to be detected, wherein the abnormality detection result represents relevant information of an abnormal region in the image to be detected.
[0086] The image detection method disclosed in the present embodiment first detects a first image block obtained by processing the image to be detected using an image detection model, and determines a second number of second image blocks from the image to be detected using the obtained first detection result, and detects at least one second image block using the image detection model again to obtain a second detection result, and can determine an abnormal detection result in the image to be detected based on the detection results of the two detections. By detecting an image obtained by performing two different processings on the image to be detected, the detection accuracy of the image to be detected is improved, and the problem of being unable to detect smaller defects in a large-resolution image due to directly scaling the image to be detected is avoided; and block detection is performed first, and then the area corresponding to the abnormal area information detected by the block detection is further accurately detected, thereby ensuring the detection accuracy while improving the detection efficiency.
[0087] The image detection method disclosed in this embodiment has a flow chart as shown in FIG. Figure 3 As shown, including:
[0088] Step S31, processing the image to be detected to obtain a first number of first image blocks;
[0089] Step S32: Detect a first number of first image blocks based on the image detection model to obtain first detection results, where the first detection results represent first abnormal region information of the first image blocks;
[0090] Step S33, based on the fact that the first image block indicated by the first abnormal region information includes a first region set whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold, a second image block is intercepted from a target region of the image to be detected, where the target region is a region in the image to be detected corresponding to a region whose area is smaller than the specific area region and whose defect confidence is greater than the first threshold;
[0091] Step S34, obtaining a second detection result of the image detection model detecting at least one second image block, where the second detection result represents second abnormal region information of the at least one second image block;
[0092] Step S35: determining an abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information.
[0093] The image to be detected is processed to obtain a first number of first image blocks, and the first number of first image blocks are detected using an image detection model to obtain a first detection result, which represents the first abnormal area information in the second number of first image blocks, that is, the relevant information of the area where the abnormality exists in the first image block.
[0094] Specifically, the first abnormal region information represented by the first detection result includes not only the region where the abnormality exists in the first image block, but also the position of the region where the abnormality exists in the first image block, the area of the region where the abnormality exists in the first image block, the defect confidence and defect type of the region, etc.
[0095] The defect confidence indicates the credibility of the abnormality in the region. When the defect confidence of a region is lower than the first threshold, it can be determined that the defect confidence of the region is too low. At this time, it can be directly determined that there is no abnormality in the region, and there is no need to perform a secondary inspection on the region, that is, there is no need to determine the second image block based on the region, and the region can be directly ignored;
[0096] When the defect confidence of a certain area reaches the first threshold, it indicates that there may be an abnormality in the area. Therefore, a secondary inspection is required, that is, a second image block needs to be determined based on the area, and a fine-grained inspection is performed to determine the area as the first area. When there are multiple first areas in the first image block, a first area set can be obtained.
[0097] Therefore, the areas that need to be subjected to secondary inspection can be determined from the first image block directly based on the defect confidence of the abnormal areas in the first image block determined in the first detection result, and then these areas that need to be subjected to secondary inspection are determined from the image to be inspected to obtain the second image block, and at least one second image block is input into the image detection model for secondary inspection to ensure the accuracy of the detection result.
[0098] When determining the area requiring secondary inspection based on the defect confidence level, two or more thresholds may be set for the defect confidence level. The setting of two thresholds is taken as an example for explanation, namely, a first threshold and a second threshold.
[0099] The first detection result can determine the defect confidence of the area with abnormalities in the first image block, and can determine which areas with abnormalities in the first image block have defect confidences reaching the first threshold and which areas have defect confidences reaching the second threshold, wherein the first threshold is less than the second threshold, such as: the first threshold is 5%, and the second threshold is 30%; or, the first threshold is 4%, and the second threshold is 20%, etc.
[0100] If it is determined that the first image block includes a certain area, the defect confidence of the abnormality in the area is a first value, the first value is greater than the first threshold and less than the second threshold, the area is determined as the first area; the first image block includes a certain area, the defect confidence of the abnormality in the area is a second value, the second value is greater than the second threshold, the area is determined as the second area, then the defect confidence of the second area is greater, based on the defect confidence of the first area, it can be determined that the first area is an area that needs to be tested for secondary detection, and the area greater than the second threshold, such as the second area, can be directly determined to have an abnormality without secondary detection, after determining the second image block from the image to be detected based on at least one first area in the first image block, and detecting the second image block based on the image detection model, after determining the second detection result, the area with abnormality determined in the second detection result is merged with at least one second area, and an abnormality detection result is generated based on the information of these areas, that is, the abnormality detection result that finally determines the area information representing the abnormality in the image to be detected includes the second abnormal area information of at least one second image block represented in the second detection result, and also includes the area information of the area in at least one first image block represented in the first detection result whose defect confidence is greater than the second threshold.
[0101] Alternatively, the area in the first image block that needs to be re-detected may be determined based on the area of the abnormal region in the first image block determined in the first detection result and the defect confidence.
[0102] Specifically, a first threshold, a second threshold and a specific area threshold are set, wherein the first threshold and the second threshold are thresholds of defect confidence, the first threshold is smaller than the second threshold, and the specific area threshold is a threshold corresponding to the area.
[0103] If it can be determined based on the first detection result that there is a first region in the first image block whose defect confidence is greater than the first threshold and less than the second threshold, and the area of the first region is less than the specific area threshold, then it is determined that the first region in the first image block is a region that needs to be subjected to secondary detection, and it is necessary to determine a region corresponding to the region from the image to be detected, that is, a target region, and obtain a second image block from the target region;
[0104] If it can be determined based on the first detection result that there is a second region in the first image block whose defect confidence is greater than a second threshold, and the area of the second region is greater than a specific area threshold, then the second region in the first image block is determined to be a region where the abnormality can be determined without performing a secondary detection, and the region can be directly determined as a region where the abnormality exists. After obtaining the second detection result, the final abnormality detection result of the image to be detected is jointly determined based on the second abnormal region information represented by the second detection result and the information of the second region, as well as the information of other regions in the first image block with the same judgment conditions as the second region.
[0105] For other areas in which, based on the first detection result, it can be determined that the defect confidence level in the first image block is greater than the second threshold and the area is smaller than the specific area threshold, the area can be directly determined as an area where the abnormality can be determined without secondary detection; or, for other areas in which, based on the first detection result, it can be determined that the defect confidence level in the first image block is greater than the first threshold and smaller than the second threshold and the area is larger than the specific area threshold, the area can also be determined as an area that requires secondary detection to determine whether it has an abnormality.
[0106] Furthermore, when determining the abnormality detection result in the image to be detected, it can be:
[0107] Based on the position information of each second area in the second area set and the position information of each third area in the third area set, the abnormality detection result in the image to be detected is determined, wherein the second area is a region included in the first image block indicated by the first abnormal area information, whose area is greater than a specific area threshold and whose defect confidence is greater than a second threshold, and the third area is a region included in at least one second image block indicated by the second abnormal area information, whose defect confidence is greater than the second threshold.
[0108] When determining the area that needs secondary inspection, that is, the first area, it is determined from the image to be inspected based on the area in the first image block indicated by the first abnormal area information that is smaller than a specific area threshold and the defect confidence is greater than the first threshold. The first abnormal area information can not only indicate the area in the first image block that is smaller than the specific area threshold and the defect confidence is greater than the first threshold, but also can indicate the area that is larger than the specific area threshold and the defect confidence is greater than the second threshold. These areas are determined as the second area in the second area set. The second area is an area that does not need to undergo secondary inspection, while the area in the first area set is an area that needs secondary inspection. The second image block intercepted from the target area of the image to be inspected based on the area in the first area set is inspected to obtain the result of the secondary inspection, that is, the second inspection result.
[0109] The second detection result represents the second abnormal area information of at least one second image block, and the second abnormal area information can indicate the area in at least one second image block where the defect confidence is greater than the second threshold, and these areas are determined as the third area in the third area set. It can also indicate the area in at least one second image block where the defect confidence is less than the second threshold. In this embodiment, it can be directly determined that there is no abnormality in the area where the defect confidence indicated by the second abnormal area information is less than the second threshold, and it is not determined as the abnormal area in the area to be detected, but it is determined that there is an abnormality in the area where the defect confidence indicated by the second abnormal area information is greater than the second threshold.
[0110] Therefore, when finally determining the abnormality detection result of the image to be inspected, it is necessary to consider not only the third area in the third area set obtained by the secondary detection, but also the second area in the second area set whose area obtained in the first detection is greater than the specific area threshold and whose defect confidence is greater than the second threshold. Therefore, the abnormality detection result needs to include not only the position information of each third area in the third area set, but also the position information of each second area in the second area set.
[0111] The image detection method disclosed in the present embodiment determines the first abnormal region information of the first image block after detecting the first number of first image blocks, and based on the fact that the first abnormal region information indicates that the first image block includes a first region set whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold, a second image block is intercepted from a target region of the first region set, that is, when the image detection model is used for detection for the second time, only the second image block intercepted from the region with a smaller area and a defect confidence greater than the first threshold determined in the first detection result is detected, so that, based on the first detection result, a second detection is performed on the region with a smaller area and a defect confidence that meets the conditions, so as to improve the detection accuracy while ensuring the detection efficiency, and avoid the occurrence of erroneous detection such as failure to detect an abnormality when there is one, or detecting an abnormality when there is no abnormality.
[0112] The image detection method disclosed in this embodiment has a flow chart as shown in FIG. Figure 4 As shown, including:
[0113] Step S41, processing the image to be detected to obtain a first number of first image blocks;
[0114] Step S42: based on the first detection result of detecting the first number of first image blocks by the image detection model, determine a second number of second image blocks from the image to be detected, where the areas of the second image blocks are smaller than the first image blocks; the first detection result represents first abnormal region information of the first image block, and the second image block includes at least one region corresponding to the first abnormal region information;
[0115] Step S43, stitching the second number of second image blocks into at least one stitched image;
[0116] Step S44, obtaining a second detection result of the image detection model detecting at least one stitched image, where the second detection result represents second abnormal region information of the stitched image;
[0117] Step S45: determining an abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information.
[0118] After processing the image to be detected to obtain a first number of first image blocks, the first number of first image blocks are input into the image detection model, and the image detection model determines the relevant information of the abnormal area in each first image block. Then, the relevant information is used to determine a second number of second image blocks from the image to be detected, and each second image block includes at least one abnormal area existing in the first image block. This will result in a large number of second image blocks. If the determined second image blocks are directly input into the image detection model for detection in sequence, the detection will take a long time and be inefficient.
[0119] Therefore, in order to solve this problem, in this embodiment, the second image blocks are not directly input into the image detection model, but the second image blocks are spliced to obtain at least one spliced image, each of which includes at least one second image block.
[0120] The image detection model detects the first image block to obtain a first detection result, which represents the first abnormal region information of the first image block, that is, the information of the region where the abnormality exists in the first image block. Based on this information, multiple second image blocks are directly determined from the image to be detected, and the second image block includes at least one region corresponding to the first abnormal region information.
[0121] Since the sizes of the regions with abnormalities in the image to be detected are different, if each second image block includes an abnormal region in the image to be detected, the number of the second image blocks is the same as the number of regions with abnormalities in the first number of first image blocks detected by the first detection result, and the sizes of the plurality of second image blocks are different, and the size of each second image block is related to the size of the abnormal region included in the second image block;
[0122] In addition, since the distances between the regions with abnormalities in the image to be detected are different, when determining the second image block from the image to be detected, at least two regions with abnormalities in the image to be detected whose distance is less than a certain threshold determined based on the first detection result can be determined to be in the same second image block. Figure 5 As shown, it is a schematic diagram of determining two abnormal areas in the image to be detected into the same second image block, including: a first abnormal area 51, a second abnormal area 52 and a second image block 53, wherein the first abnormal area 51 and the second abnormal area 52 are both determined based on the first detection result, and if the interval between the first abnormal area 51 and the second abnormal area 52 is less than a specific threshold, the first abnormal area 51 and the second abnormal area 52 are divided into the same second image block, and the second image block is determined from the image to be detected.
[0123] Furthermore, when analyzing the first detection result to determine the second image block, if the following situation exists in the first detection result: there is an abnormal area in the first image block a, and there is another abnormal area in the first image block b, and these two abnormal areas are a complete abnormal area in the image to be detected, that is, when the image to be detected is processed to obtain a first number of first image blocks, a complete abnormal area is divided into two parts, which are respectively located in different first image blocks, then, when determining the second image block, it is necessary to first merge the abnormal areas divided into two parts respectively located in the first image block a and the first image block b, and determine the size of the complete abnormal area and the position of the complete abnormal area in the image to be detected, so as to determine the second image block from the image to be detected based on the size of the complete abnormal area and its position in the image to be detected, and the determined second image block includes the complete abnormal area, thereby avoiding the problem of increased detection difficulty caused by determining an abnormal area in the image to be detected in different second image blocks.
[0124] The image detection method disclosed in this embodiment processes the image to be detected to obtain a first number of first image blocks, then detects the first number of first image blocks using an image detection model to obtain a first detection result, determines a second number of second image blocks from the image to be detected based on the first detection result, splices the second number of second image blocks into at least one spliced image, detects the at least one spliced image using the image detection model to obtain a second detection result, and determines the final abnormality detection result of the image to be detected using information in the first detection result and the second detection result. In this solution, the second number of second image blocks determined from the image to be detected are spliced to obtain at least one spliced image, so as to perform model detection on the spliced image, so that when the second number of second image blocks determined from the image to be detected are detected, multiple second image blocks are spliced into one spliced image, and only a small number of spliced images need to be input into the model, which shortens the detection time and improves the detection efficiency while ensuring the detection accuracy.
[0125] Furthermore, in the image detection method disclosed in this embodiment, the abnormality detection result in the image to be detected can be determined as follows:
[0126] Based on the position information of each second area in the second area set and the position information of each third area in the third area set, the abnormality detection result in the image to be detected is determined; wherein the second area is an area included in the first image block indicated by the first abnormal area information, and the area has an area greater than a specific area threshold, and the defect confidence is greater than the second threshold, and the third area is an area included in the stitched image indicated by the second abnormal area information, and the defect confidence is greater than the second threshold.
[0127] The first input to the image detection model is a first number of first image blocks obtained by processing the image to be detected to obtain a first detection result, and based on the first detection result, a second number of second image blocks are determined from the image to be detected, and the second number of second image blocks are spliced to obtain at least one spliced image. The second input to the image detection model is at least one spliced image to obtain a second detection result, and then the abnormal detection result of the image to be detected is determined based on the first abnormal area information represented by the first detection result and the second abnormal area information represented by the second detection result.
[0128] Since not all the areas with abnormalities corresponding to the first abnormal area information represented by the first detection result are determined as the second image blocks when the second image block is determined and stitched to obtain the stitched image, only the areas on the image to be detected corresponding to the first area in the first abnormal area information whose defect confidence is greater than the first threshold and whose area is less than the specific area threshold are determined as the second image blocks, while the areas in the first abnormal area information whose defect confidence is less than the first threshold are considered to have no abnormalities and no secondary detection is required, and the areas in the first abnormal area information whose defect confidence is greater than the second threshold and whose area is greater than the specific area threshold are considered to have abnormalities and no secondary detection is required, then, when determining the abnormal detection result of the image to be detected, it is necessary to combine the position information corresponding to the second area in the first abnormal area information whose defect confidence is greater than the second threshold and whose area is greater than the specific area threshold, and the position information corresponding to the third area in the second abnormal area information whose defect confidence is greater than the second threshold, so as to obtain a complete detection result of the image to be detected.
[0129] Further, based on the position information of each second region in the second region set and the position information of each third region in the third region set, determining the abnormality detection result in the image to be detected includes:
[0130] Determine the position information of each second region in the second region set based on the position information of the first image block corresponding to each second region in the second region set in the image to be detected and the position information of each second region in the second region set in the first image block where the second region is located;
[0131] Determine the position information of each third region in the third region set based on the position information of each third region in the stitched image, the second image block corresponding to the second abnormal region information, and the position of the second image block corresponding to the second abnormal region information in the image to be detected;
[0132] An abnormality detection result in the image to be detected is determined based on the position information of each second area in the second area set and the position information of each third area in the third area set.
[0133] The second area is directly determined based on the first abnormal area information represented by the first detection result, and the first detection result is obtained by detecting the first image block, and the first image block is obtained by processing the image to be detected.
[0134] like Figure 6 As shown, the correspondence between the second region and the first image block and the image to be detected includes: the image to be detected 61, the first image block 62, and the second region 63. Therefore, when determining the position information of the second region, it is necessary not only to determine the position information of the second region in the first image block, but also to determine the position information of the first image block in the image to be detected. Based on the position information of the second region in the first image block and the position information of the first image block in the image to be detected, based on the correspondence between the above two pieces of position information, the position information of the second region in the image to be detected can be determined.
[0135] The position information of the second region is the position information of the second region in the image to be detected. In this way, the position information of each second region in the second region set can be determined.
[0136] The third area is determined based on the second abnormal area information represented by the second detection result, and the second detection result is obtained by detecting the stitched image, and the stitched image is stitched using the second image blocks determined from the image to be detected. Therefore, when determining the position information of the third area, it is necessary to first determine the position information of the third area in the stitched image, and then determine which second image block the position information of the third area in the stitched image corresponds to, that is, determine the identifier of the second image block. After determining the identifier of the second image block, determine the position information of the second image block in the image to be detected based on the representation, and based on the correspondence between the above-mentioned position information, the position information of the third area in the image to be detected can be determined.
[0137] The position information of the third region is the position information of the third region in the image to be detected. In this way, the position information of each third region in the third region set can be determined.
[0138] After determining the position information of each second region in the second region set and the position information of each third region in the third region set, the abnormality detection result in the image to be detected can be determined, that is, the position information of the region with abnormality in the image to be detected.
[0139] Among them, the position information of the second area, or the position information of the third area, can be represented by the coordinate information of the second area or the third area in the image to be detected, and the coordinate information can be the coordinate information of the vertex of the diagonal of the second area or the third area, or the coordinate information of the center point of the second area or the third area. When the coordinate information is the coordinate information of the center point of the area, the length and width of the area need to be added. The position information of the area is represented by the coordinate information of the center point of the area, the length of the area and the width of the area; or, the position information of the area can also be represented by other methods, which are not specifically limited here.
[0140] This embodiment discloses an image detection method, and its flow chart is as follows: Figure 7 As shown, including:
[0141] Step S71, processing the image to be detected to obtain a first number of first image blocks;
[0142] Step S72: based on a first detection result of detecting a first number of first image blocks by an image detection model, determining a second number of second image blocks from the image to be detected, where the area of the second image block is smaller than that of the first image block, the first detection result represents first abnormal region information of the first image block, and the second image block includes at least one region corresponding to the first abnormal region information;
[0143] Step S73: determining a size parameter of each second image block in the second number of second image blocks;
[0144] Step S74: stitching the second number of second image blocks in sequence according to the size parameter to form at least one stitched image, wherein the at least one stitched image is of a target size, wherein the target size is determined based on the target parameter of the image detection model;
[0145] Step S75, obtaining a second detection result of the image detection model detecting at least one stitched image, where the second detection result represents second abnormal region information of at least one second image block;
[0146] Step S76: determine an abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information.
[0147] After processing the image to be detected to obtain a first number of first image blocks, the first number of first image blocks are input into an image detection model, and the image detection model determines relevant information of abnormal areas in each first image block. Then, the relevant information is used to determine a second number of second image blocks from the image to be detected, and the second number of second image blocks are spliced to form at least one spliced image, so that fine-grained detection can be performed using the spliced images and the image detection model.
[0148] When stitching the second number of second image blocks into at least one stitched image, the size parameters of each second image block in the second number of second image blocks may be first determined, such as aspect ratio, area size and other parameters, and then the second number of second image blocks may be stitched in sequence according to the size parameters to form at least one stitched image, and then the at least one stitched image may be input into the image detection model for detection.
[0149] like Figure 8 As shown, it is a complete flow chart of the image detection method disclosed in this embodiment. First, an image to be detected is determined. The image to be detected is a high-resolution image, such as: 11700×7500. Then, the image to be detected is processed to obtain a first number of first image blocks. The processing of the image to be detected can be specifically: scaling the image to be detected to reduce the resolution of the image to be detected, and then segmenting the scaled image to be detected to obtain a first number of first image blocks. For example, the resolution of the image obtained after scaling the image to be detected is: 3072×1920, and the resolution of the first image block can be: 1024×1024;
[0150] Inputting a first number of first image blocks into an image detection model, such as Model A, to perform a first detection (Task 1). Since the first number of first image blocks have the same size, the image detection model can detect the first number of first image blocks in parallel to obtain a detection result for each first image block in parallel, and combining a plurality of detection results obtained by detecting the first number of first image blocks to obtain a first detection result;
[0151] Mapping the first abnormal region information represented by the first detection result to the image to be detected, only the region indicated by the first abnormal region information and having a defect confidence greater than a first threshold value may be mapped to the image to be detected, representing all regions with a defect confidence greater than the first threshold value obtained by the first detection in the image to be detected, performing a secondary detection on the region in the image to be detected whose defect confidence value is greater than the first threshold value and whose area is less than a specific area threshold value, and cropping these regions from the image to be detected to obtain a second number of second image blocks;
[0152] The second number of second image blocks are sequentially stitched together according to the size parameter of each second image block to obtain at least one stitched image, such as obtaining n stitched images, each of which may have a resolution of 1024×1024, and the at least one stitched image is input into an image detection model, such as Model A, to perform a second detection (Task 2). Since the second number of stitched images have the same size, the image detection model may detect the second number of stitched images in parallel to obtain detection results for the stitched images in parallel, and a plurality of detection results obtained by detecting the second number of stitched images are combined to obtain a second detection result.
[0153] After obtaining the second detection result, the position information of each third area indicated by the second abnormal area information represented by the second detection result in its corresponding second image block is calculated, and then mapped to the image to be detected. At the same time, since the first abnormal area information represented by the first detection result contains an area with a defect confidence greater than the second threshold and an area greater than the specific area threshold, the position of this part of the area is also directly mapped to the image to be detected, and the abnormal detection result of the image to be detected can be obtained.
[0154] Specifically, the size of each stitched image in the at least one stitched image is a target size, and the target size is determined based on a target parameter of the image detection model.
[0155] Among them, the target parameters of the image detection model can be parameters such as the feature distribution of the image detection model. The size of the image detected by the image detection model is determined as the target size based on the feature distribution of the image detection model. When the image of the target size is input into the image detection model, the feature distribution in the image is consistent with the feature distribution of the image when the image detection model is trained. At this time, the image detection model can have faster detection efficiency and accuracy when detecting the image.
[0156] Based on this, when determining the target size based on the feature distribution of the image detection model, the second number of second image blocks may be spliced to form at least one spliced image of the target size;
[0157] In addition, when the image to be detected is processed to obtain a first number of first image blocks, since the first image blocks are to be input into the image detection model, the size of the first image blocks can be determined as the target size, that is, after determining the image to be detected, the image to be detected is scaled, and the scaled image is divided into the first number of first image blocks of the target size. At this time, the first number may be related to the size of the scaled image, or may be related to the original size of the image to be detected and the scaling ratio.
[0158] In the image detection method disclosed in this embodiment, when stitching to obtain at least one stitched image, the following steps may be performed:
[0159] An image template of the target size is obtained in advance, and then a second number of second image blocks are spliced on the image target to obtain a spliced image of the target size.
[0160] An image template of a target size is initialized, and then a second number of second image blocks are arranged in sequence on the image template according to a size parameter of each second image block to form at least one spliced image.
[0161] Specifically, Fig. 9 As shown, it is a schematic diagram of determining the second image block from the image to be detected, forming a spliced image and detecting. The image detection model (such as: Model A) detects the first number of first image blocks to obtain a first detection result, marks the abnormal area in the first abnormal area information represented by the first detection result in the image to be detected, and then determines the second number of second image blocks from the image to be detected according to the first abnormal area information, and then arranges the second number of second image blocks according to the size parameter of each second image block, and arranges the second number of second image blocks in sequence on the image target according to the size parameter of each second image block to obtain at least one spliced image, and records the position of each second image block on the spliced image, which can be recorded as L1. In addition, it is also necessary to record which spliced image each second image block is on;
[0162] Then, at least one stitched image is input into an image detection model (such as Model A) to obtain a second detection result. Based on the second abnormal area information indicated by the second detection result, it is possible to determine which positions on each stitched image have abnormal areas, and the positions of the abnormal areas on the stitched image are recorded as L2. Then, the position L1 of each second image block on the stitched image is matched with the position L2 of the abnormal area on the stitched image to determine a matching pair of the two positions L1 and L2, and the position of the abnormal area in the second image block is determined. Based on the matching pair of L1 and L2 and the position of the abnormal area in the second image block, the position of each abnormal area determined by the second detection result on the image to be detected is determined. At the same time, it is also necessary to superimpose the area whose defect confidence determined by the first detection result is greater than the second threshold and whose area is greater than the specific area threshold, so as to obtain the abnormal detection result of the image to be detected.
[0163] When the second image blocks of the second image are sequentially arranged on the image template according to the size parameter to form at least one stitched image, if the size parameter of the second image block to be currently arranged does not match the current position of the image block to be arranged on the image template, determining whether the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template;
[0164] If it is determined that the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template, the next second image block is arranged to the current position of the image block to be arranged on the image template.
[0165] like Fig.10a As shown, it is a schematic diagram of arranging on an image template according to the size parameters of the second image blocks, including: an image template 101, on which 6 second image blocks have been arranged according to the size parameters, a current second image block 102 to be arranged according to the size parameters, and a next second image block 103 after the current second image block 102 according to the size parameters. If the arrangement is performed according to the positions of the image blocks to be arranged on the image template, the current second image block 102 should be arranged at the position of the image blocks to be arranged on the image template, but the sizes of the current second image block 102 and the positions of the image blocks to be arranged on the image template do not match, such as Fig.10a As shown by the dotted line in the middle, if the current second image block 102 is arranged at this position, the size of this position will be smaller than the size parameter of the current second image block 102, and will exceed the range of the image template, so it does not match. At this time, the next second image block 103 can be determined. This position can be used to place the next second image block 103 and will not exceed the range of the image template. Therefore, the next second image block 103 is placed at this position, as shown in FIG. Fig.10b shown.
[0166] Further, such as Fig.10c As shown, the next second image block 103 is placed at Fig.10b The position shown in FIG. 1 is not shown in FIG. 1 , but the current second image block 102 still exists. At this time, it can be determined whether the position where the image block is currently to be placed matches the size parameter of the current second image block 102, such as Fig.10c As shown, the position where the image block is currently to be placed matches the size parameter of the current second image block 102, so the current second image block 102 is placed at this position;
[0167] Further, if the next second image block 103 is placed at Fig.10b The position shown in the figure, but there is still a current second image block 102. At this time, it can be determined whether the position where the current image block needs to be placed matches the size parameter of the current second image block 102. If they do not match, it is determined whether the position in the next column of the position where the current image block needs to be placed matches the size parameter of the current second image block 102. If they still do not match, the current second image block 102 can be placed in the next image template.
[0168] That is, if it is determined that the size parameter of the second image block to be arranged currently does not match the current position of the image block to be arranged on the image template, the second image block to be arranged currently is arranged to a position in the next row of the current position of the image block to be arranged on the image template, or the second image block to be arranged currently is arranged to the next image template.
[0169] Further, if the size parameters of the third number of second image blocks to be arranged determined according to the sorting do not match the current positions of the image blocks to be arranged on the image template, it is determined that the current positions of the image blocks to be arranged on the image template are free.
[0170] like Fig.10d As shown, it includes: an image template 101 and a position 104 of the image blocks to be arranged on the image template. The size of the position 104 of the image blocks to be arranged on the image template is relatively small, and the second image block to be arranged currently and multiple second image blocks after the second image block to be arranged currently, a total of a third number of second image blocks, are compared with the position 104 of the image blocks to be arranged on the image template, and it is determined that the size parameters of each second image block in the third number of second image blocks do not match the position 104. In order to save computing power, the position 104 is no longer used as the position of the current image block to be arranged, but the image blocks are no longer arranged at this position, and the arrangement continues from the next row or the next image template.
[0171] As shown in Fig.10d As shown, if the positions of the image blocks to be arranged on the image template do not match the size parameters of the multiple second image blocks to be arranged, the image template currently arranged with the second image blocks is determined as a spliced image, and the splicing is continued from the next image template, wherein the multiple second image blocks to be arranged can be a third number of second image blocks to be arranged.
[0172] The image detection method disclosed in the present embodiment processes the image to be detected to obtain a first number of first image blocks, then detects the first number of first image blocks using an image detection model to obtain a first detection result, determines a second number of second image blocks from the image to be detected based on the first detection result, splices the second image blocks in sequence according to the size parameters of each second image block to form at least one spliced image of a target size, wherein the target size is determined based on the target parameters of the image detection model, detects at least one spliced image using the image detection model to obtain a second detection result, and determines a final abnormality detection result of the image to be detected using information in the first detection result and the second detection result. In this scheme, a second number of second image blocks determined from the image to be detected are spliced according to size parameters to obtain at least one spliced image of a target size, so as to perform model detection on the spliced image. The spliced image of the target size is input into the image detection model, and the target size conforms to the target parameters of the image detection model. Therefore, inputting the spliced image of the target size into the image detection model can improve the efficiency and accuracy of detection. In addition, the spliced image is obtained by splicing according to the size parameters of the second image blocks, which is convenient for determining the position information, and ensures that each spliced image can splice more second image blocks according to the size parameters of the second image blocks, thereby reducing the number of spliced images and improving the detection efficiency.
[0173] This embodiment discloses an image detection system, and its structural diagram is shown in FIG. Fig.11 As shown, including:
[0174] A processing unit 111 , a first determining unit 112 , an obtaining unit 113 and a second determining unit 114 .
[0175] The processing unit 111 is used to process the image to be detected to obtain a first number of first image blocks;
[0176] The first determination unit 112 is used to determine a second number of second image blocks from the image to be detected based on a first detection result of the image detection model for detecting a first number of first image blocks, and the area of the second image blocks is smaller than that of the first image blocks; wherein the first detection result represents first abnormal region information of the first image block, and the second image block includes at least one region corresponding to the first abnormal region information;
[0177] The obtaining unit 113 is used to obtain a second detection result of the image detection model detecting at least one second image block, where the second detection result represents second abnormal region information of the at least one second image block;
[0178] The second determining unit 114 is used to determine an abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information.
[0179] Furthermore, the first image block is of a target size, a resolution of the first image block is lower than a resolution of the image to be detected, the first detection result is a coarse-grained detection result, and the second detection result is a fine-grained detection result.
[0180] Furthermore, the obtaining unit is used to:
[0181] A second number of second image blocks are stitched together into at least one stitched image; and a second detection result of the image detection model detecting the at least one stitched image is obtained.
[0182] Further, the first determining unit is used for:
[0183] Based on the image detection model, a first number of first image blocks are detected to obtain a first detection result; based on the first abnormal area information indicating that the first image blocks include a first area set whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold, a second image block is intercepted from a target area of the image to be detected, where the target area is an area in the image to be detected corresponding to an area whose area is smaller than the specific area threshold and whose defect confidence is greater than the first threshold.
[0184] Further, the second determining unit is used for:
[0185] Based on the position information of each second area in the second area set and the position information of each third area in the third area set, the abnormality detection result in the image to be detected is determined; wherein the second area is an area included in the first image block indicated by the first abnormal area information, and the area has an area greater than a specific area threshold, and the defect confidence is greater than the second threshold, and the third area is an area included in the stitched image indicated by the second abnormal area information, and the defect confidence is greater than the second threshold.
[0186] Further, the second determining unit is used for:
[0187] Based on the position information of the first image block corresponding to each second area in the second area set in the image to be detected, and the position information of each second area in the second area set in the first image block where it is located, determine the position information of each second area in the second area set; based on the position information of each third area in the third area set in the stitched image, the identifier of the second image block corresponding to the second abnormal area information, and the position of the second image block corresponding to the second abnormal area information in the image to be detected, determine the position information of each third area in the third area set; based on the position information of each second area in the second area set and the position information of each third area in the third area set, determine the abnormality detection result in the image to be detected.
[0188] Furthermore, the obtaining unit is used to:
[0189] Determine a size parameter of each second image block in the second number of second image blocks; stitch the second number of second image blocks in sequence according to the size parameter to form at least one stitched image, and at least one stitched image is a target size; wherein the target size is determined based on the target parameter of the image detection model.
[0190] Furthermore, the obtaining unit is also used for:
[0191] Get the image template;
[0192] Furthermore, the obtaining unit is used to:
[0193] Arranging a second number of second image blocks sorted according to the size parameter in sequence on the image template to form at least one spliced image;
[0194] Among them, if the size parameter of the second image block to be arranged currently does not match the current position of the image block to be arranged on the image template, determine whether the size parameter of the next second image block of the second image block to be arranged currently matches the current position of the image block to be arranged on the image template; if it is determined that the size parameter of the next second image block of the second image block to be arranged currently matches the current position of the image block to be arranged on the image template, arrange the next second image block to the current position of the image block to be arranged on the image template; if the position of the image block to be arranged on the image template does not match the size parameters of multiple second image blocks to be arranged, determine the image template currently arranged with the second image block as a spliced image.
[0195] Further:
[0196] If it is determined that the size parameters of the second image blocks to be arranged currently do not match the current positions of the image blocks to be arranged on the image template, the second image blocks to be arranged currently are arranged to a position in a row below the current positions of the image blocks to be arranged on the image template, or the second image blocks to be arranged currently are arranged in the next image template; if it is determined according to the sorting that the size parameters of the third number of second image blocks to be arranged do not match the current positions of the image blocks to be arranged on the image template, it is determined that the current positions of the image blocks to be arranged on the image template are idle.
[0197] The image detection system disclosed in this embodiment is implemented based on the image detection method disclosed in the above embodiment, which will not be described in detail here.
[0198] The image detection system disclosed in the present embodiment first detects a first image block obtained by processing an image to be detected using an image detection model, and determines a second number of second image blocks from the image to be detected using the obtained first detection result, and detects at least one second image block using the image detection model again to obtain a second detection result, and can determine an abnormal detection result in the image to be detected based on the detection results of the two detections. By detecting an image obtained by performing two different processings on the image to be detected, the detection accuracy of the image to be detected is improved, and the problem of being unable to detect smaller defects in a large-resolution image due to directly scaling the image to be detected is avoided; and block detection is performed first, and then the area corresponding to the abnormal area information detected by the block detection is further accurately detected, thereby ensuring the detection accuracy while improving the detection efficiency.
[0199] This embodiment discloses an electronic device, including:
[0200] A processor is used to process an image to be detected to obtain a first number of first image blocks; based on a first detection result of an image detection model detecting the first number of first image blocks, determine a second number of second image blocks from the image to be detected, wherein the area of the second image blocks is smaller than that of the first image blocks; wherein the first detection result represents first abnormal area information of the first image block, and the second image block includes at least one area corresponding to the first abnormal area information; obtain a second detection result of the image detection model detecting at least one second image block, wherein the second detection result represents second abnormal area information of at least one second image block; and determine an abnormal detection result in the image to be detected based on the first abnormal area information and the second abnormal area information.
[0201] The memory is used to store the program required by the processor to execute the above processing process.
[0202] The electronic device disclosed in this embodiment is implemented based on the image detection method disclosed in the above embodiments, which will not be described in detail here.
[0203] The electronic device disclosed in the present embodiment first detects a first image block obtained by processing an image to be detected using an image detection model, and determines a second number of second image blocks from the image to be detected using the obtained first detection result, and detects at least one second image block using the image detection model again to obtain a second detection result, and can determine an abnormal detection result in the image to be detected based on the detection results of the two detections. By detecting an image obtained by performing two different processings on the image to be detected, the detection accuracy of the image to be detected is improved, and the problem of being unable to detect smaller defects in a large-resolution image due to directly scaling the image to be detected is avoided; and block detection is performed first, and then the area corresponding to the abnormal area information detected by the block detection is further accurately detected, thereby ensuring the detection accuracy while improving the detection efficiency.
[0204] An embodiment of the present application also provides a readable storage medium on which a computer program is stored. The computer program is loaded and executed by a processor to implement the steps of the above-mentioned image detection method. The specific implementation process can refer to the description of the corresponding part of the above-mentioned embodiment, and this embodiment will not repeat it.
[0205] The present application also proposes a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the method provided in various optional implementations of the above-mentioned image detection method or image detection system. The specific implementation process can refer to the description of the above-mentioned corresponding embodiment, and will not be repeated.
[0206] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0207] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0208] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0209] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. An image detection method, comprising: Processing the image to be detected to obtain a first number of first image blocks; Based on a first detection result of detecting the first number of first image blocks by an image detection model, determining a second number of second image blocks from the image to be detected, wherein the areas of the second image blocks are smaller than those of the first image blocks; wherein the first detection result represents first abnormal area information of the first image block, and the second image block includes at least one area corresponding to the first abnormal area information; Obtaining a second detection result of the image detection model detecting the at least one second image block, wherein the second detection result represents second abnormal region information of the at least one second image block; An abnormality detection result in the image to be detected is determined based on the first abnormal area information and the second abnormal area information.
2. According to the method of claim 1, the first image block is of a target size, the resolution of the first image block is lower than the resolution of the image to be detected, the first detection result is a coarse-grained detection result, and the second detection result is a fine-grained detection result.
3. According to the method of claim 1, obtaining a second detection result of the image detection model detecting the at least one second image block comprises: splicing the second number of second image blocks into at least one spliced image; A second detection result of the image detection model detecting the at least one stitched image is obtained.
4. The method according to claim 1, wherein the first detection result of detecting the first number of first image blocks based on the image detection model, and determining the second number of second image blocks from the image to be detected comprises: Detect the first number of first image blocks based on the image detection model to obtain the first detection result; Based on the fact that the first image block indicated by the first abnormal area information includes a first area set whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold, a second image block is intercepted from a target area of the image to be detected, where the target area is an area in the image to be detected corresponding to an area whose area is smaller than a specific area threshold and whose defect confidence is greater than a first threshold.
5. The method according to claim 3, wherein determining the abnormality detection result in the image to be detected based on the first abnormal region information and the second abnormal region information comprises: Based on the position information of each second area in the second area set and the position information of each third area in the third area set, the abnormality detection result in the image to be detected is determined; wherein the second area is a region in the first image block indicated by the first abnormal area information, the area of which is greater than a specific area threshold and the defect confidence is greater than a second threshold, and the third area is a region in the stitched image indicated by the second abnormal area information, the defect confidence is greater than the second threshold.
6. The method according to claim 5, wherein determining the abnormality detection result in the image to be detected based on the position information of each second area in the second area set and the position information of each third area in the third area set comprises: Determine the position information of each second region in the second region set based on the position information of the first image block corresponding to each second region in the second region set in the image to be detected and the position information of each second region in the second region set in the first image block where the second region is located; Determine the position information of each third region in the third region set based on the position information of each third region in the stitched image, the identifier of the second image block corresponding to the second abnormal region information, and the position of the second image block corresponding to the second abnormal region information at the image to be detected; An abnormality detection result in the image to be detected is determined based on the position information of each second area in the second area set and the position information of each third area in the third area set.
7. The method according to claim 3, wherein stitching the second number of second image blocks into at least one stitched image comprises: determining a size parameter of each second image block in the second number of second image blocks; Sequentially stitching the second number of second image blocks according to the size parameter to form at least one stitched image, where the at least one stitched image is of a target size; Wherein, the target size is determined based on the target parameters of the image detection model.
8. The method according to claim 7, further comprising: Get the image template; The step of sequentially splicing the second number of second image blocks according to the size parameter to form at least one spliced image includes: Arranging the second number of second image blocks sorted according to the size parameter in sequence on the image template to form at least one spliced image; Wherein, if the size parameter of the current second image block to be arranged does not match the current position of the image block to be arranged on the image template, determining whether the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template; If it is determined that the size parameter of the next second image block of the current second image block to be arranged matches the current position of the image block to be arranged on the image template, arranging the next second image block to the current position of the image block to be arranged on the image template; If the positions of the image blocks to be arranged on the image template do not match the size parameters of the plurality of second image blocks to be arranged, the image template currently arranged with the second image blocks is determined as a spliced image.
9. The method according to claim 8, further comprising: If it is determined that the size parameter of the second image block to be arranged currently does not match the current position of the image block to be arranged on the image template, arrange the second image block to be arranged currently to a position in a row next to the current position of the image block to be arranged on the image template, or arrange the second image block to be arranged currently to a next image template; If the size parameters of the third number of second image blocks to be arranged determined according to the sorting do not match the current positions of the image blocks to be arranged on the image template, it is determined that the current positions of the image blocks to be arranged on the image template are free.
10. An image detection system, comprising: A processing unit, configured to process the image to be detected to obtain a first number of first image blocks; A first determining unit is configured to determine a second number of second image blocks from the image to be detected based on a first detection result of detecting the first number of first image blocks by an image detection model, wherein the areas of the second image blocks are smaller than those of the first image blocks; wherein the first detection result represents first abnormal region information of the first image block, and the second image block includes at least one region corresponding to the first abnormal region information; An obtaining unit, configured to obtain a second detection result of the image detection model detecting the at least one second image block, wherein the second detection result represents second abnormal region information of the at least one second image block; The second determining unit is used to determine the abnormality detection result in the image to be detected based on the first abnormal area information and the second abnormal area information.
Citation Information
Cited By
Defect detection method and system
CN120891006A