Method for detecting foreign matter in product with accessory and X-ray detection instrument

By pre-treating the attachment area with accessories products, the gray value is close to the gray value of the product, the problems of false detection and missed detection of foreign matter detection in the prior art are solved, and the accuracy and efficiency of detection are improved.

CN120020535APending Publication Date: 2025-05-20METTLER TOLEDO (CHANGZHOU) MEASUREMENT TECH CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311552735.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-20
Publication Date
2025-05-20

AI Technical Summary

Technical Problem

Existing foreign object detection methods are prone to missed detection or missed detection when detecting products with accessories, resulting in high false detection rates and missed detection rates.

Method used

By obtaining the grayscale image of the attachment product, selecting the center point of the attachment area and pre-processing, the grayscale value of the attachment area is close to the grayscale value of the product, thereby reducing false detection and missed detection in subsequent foreign matter detection.

Benefits of technology

It improves the accuracy of foreign object detection, reduces the error detection rate and missed detection rate, and enhances the detection ability of foreign objects in products with accessories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120020535A_ABST
    Figure CN120020535A_ABST
Patent Text Reader

Abstract

The invention provides a method for detecting foreign matters in a product with accessories and an X-ray detection instrument. The foreign matter detection method comprises the steps that a first product image of the product with the accessory is obtained, the first product image is a gray image, and the accessory is located in an accessory area in the first product image; obtaining a gray scale range of the attachment area; selecting a central point of the attachment area according to the gray scale range, and obtaining a contour of the attachment area; the accessory area is preprocessed, so that the accessory gray value of the accessory area is close to the product gray value of the product, and a processed second product image is obtained; and performing foreign matter detection on the second product image. The accuracy of foreign matter detection can be improved, and the false detection rate and the omission ratio can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application mainly relates to the technical field of product detection, and particularly to a foreign object detection method for products with accessories and an X-ray detection instrument applying the same. Background Art

[0002] During the production process of products, detecting products is an important step. Taking food as an example, an X-ray detector is usually used to detect whether there are foreign objects in the food. The foreign objects are, for example, metals, glasses, or anything irrelevant to the product. Desiccants are usually placed in packaged foods. The desiccant is an important accessory of the product and not a foreign object. In the existing detection methods, taking two of them as examples, Method 1 is to participate in the detection with the desiccant as part of the product. The problem with this method is that since the gray value of the desiccant in the X-ray image is relatively close to that of the foreign object, if the detection parameters in the detection method are set for foreign objects and are sensitive to foreign object detection, it is easy to detect the desiccant as a foreign object, resulting in a relatively high false detection rate, causing waste, affecting production efficiency, and possibly causing complaints from operators. Method 2 is to first locate the desiccant area and remove the desiccant area during the detection of foreign objects. The problem with this method is that since the desiccant area is removed, if the foreign object is exactly in the desiccant area, that part of the foreign object cannot be detected, resulting in missed detection, affecting product quality, and triggering customer complaints.

[0003] Therefore, an effective detection method is needed to overcome the above problems, improve the accuracy of foreign object detection, and reduce the false detection rate and missed detection rate. Summary of the Invention

[0004] The technical problem to be solved by this application is that the false detection rate or missed detection rate of the current foreign object detection method is relatively high.

[0005] To solve the above technical problem, this application provides a foreign object detection method for products with accessories, including: obtaining a first product image of the product with accessories, the first product image being a grayscale image, and the accessory being in an accessory area in the first product image; obtaining the gray range of the accessory area; selecting the center point of the accessory area according to the gray range, and obtaining the contour of the accessory area; preprocessing the accessory area to make the accessory gray value in the accessory area close to the product gray value of the product, obtaining a processed second product image; and performing foreign object detection on the second product image.

[0006] In an embodiment of this application, the step of preprocessing the accessory area includes:

[0007] Step S21: calculating the average gray value of the first product image;

[0008] Step S22: Starting from the center point, the accessory gray values in the accessory area change sequentially outward from the center point. When the average gray value is greater than the accessory gray value, the change trend of the accessory gray value is increasing; when the average gray value is less than the accessory gray value, the change trend of the accessory gray value is decreasing.

[0009] Step S23: Repeat Step S21 and Step S22 until the accessory gray values in the accessory area are close to the average gray value.

[0010] In an embodiment of the present application, in Step S22, the step of making the accessory gray values in the accessory area change sequentially outward from the center point includes: adjusting the gray value change amplitude of the current position according to the current accessory gray value corresponding to the current position in the accessory area. A larger gray value change amplitude corresponds to a larger difference between the current accessory gray value and the average gray value, and a smaller gray value change amplitude corresponds to a smaller difference between the current accessory gray value and the average gray value.

[0011] In an embodiment of the present application, in Step S22, the step of making the accessory gray values in the accessory area change sequentially outward from the center point includes: adjusting the gray value change amplitude of the current position according to the current position in the accessory area. A larger gray value change amplitude corresponds to a current position closer to the center point, and a smaller gray value change amplitude corresponds to a current position farther from the center point.

[0012] In an embodiment of the present application, the step of detecting foreign objects in the second product image includes: using a set of detection parameters for the second product image, and the detection parameters include a gray value threshold.

[0013] In an embodiment of the present application, the step of detecting foreign objects in the second product image includes: using first detection parameters for the accessory area in the second product image, and using second detection parameters for other areas in the second product image except the accessory area. The first detection parameters include a first gray value threshold, and the second detection parameters include a second gray value threshold, where the first gray value threshold is different from the second gray value threshold.

[0014] In an embodiment of the present application, the first product image is an X-ray image obtained by an X-ray detection instrument, and the accessory gray value is less than the product gray value.

[0015] In an embodiment of the present application, the accessory includes any one of a desiccant and a gift.

[0016] In an embodiment of the present application, the product includes food with packaging.

[0017] The present application also provides an X-ray detection instrument to solve the above technical problems. The instrument includes a foreign object detection module for detecting foreign objects using the foreign object detection method described above.

[0018] By using the foreign object detection method of the present application and the X-ray detection instrument applying the method, the accessory area including accessories in the product with accessories is preprocessed, so that the gray value of the accessory area is close to that of the product. Therefore, during subsequent foreign object detection, it is possible to avoid detecting the accessory area as a foreign object, and at the same time, the detection rate of foreign objects near the accessory area can be improved, while the false detection rate and missed detection rate are reduced, the accuracy of foreign object detection is improved, which is beneficial to improving the product detection efficiency, reducing product waste, and enhancing customer satisfaction. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are provided to further understand the present application, and they are incorporated and constitute a part of the present application. The drawings illustrate embodiments of the present application and, together with this specification, serve to explain the principles of the present application. In the drawings:

[0020] Figure 1 is an exemplary flowchart of the foreign object detection method according to an embodiment of the present application;

[0021] Figure 2 is a schematic diagram of the first product image of the product with accessories in the foreign object detection method according to an embodiment of the present application;

[0022] Figure 3 is the actual detection result obtained by using Method 1 described in the background art;

[0023] Figure 4 is the actual detection result obtained by using Method 2 described in the background art;

[0024] Figure 5 is the actual detection result obtained by using the foreign object detection method of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] To more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required for the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application. For those of ordinary skill in the art, without creative efforts, the present application can also be applied to other similar scenarios based on these drawings. Unless obvious from the language context or otherwise stated, the same reference numerals in the drawings represent the same structure or operation.

[0026] As shown in this application, unless the context clearly indicates otherwise, words such as "a", "an", "one", and / or "the" are not specifically singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.

[0027] Unless otherwise specifically stated, the relative arrangements of components and steps, numerical expressions, and numerical values set forth in these embodiments do not limit the scope of this application. At the same time, it should be understood that for the sake of convenience of description, the sizes of the various parts shown in the drawings are not drawn in actual proportional relationships. Technologies, methods, and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, the said technologies, methods, and devices should be regarded as part of the authorized specification. In all the examples shown and discussed here, any specific value should be construed as merely exemplary and not as a limitation. Therefore, other examples of the exemplary embodiments may have different values. It should be noted that like reference numerals and letters denote like items in the following drawings, and thus, once an item is defined in one drawing, further discussion thereof in subsequent drawings is not necessary.

[0028] In addition, it should be noted that the use of words such as "first" and "second" to limit components is only for the convenience of distinguishing the corresponding components. Without further statement, the above words have no special meaning, and thus cannot be construed as limiting the scope of protection of this application. In addition, although the terms used in this application are selected from well-known and commonly used terms, some of the terms mentioned in the specification of this application may be selected by the applicant according to his or her judgment, and their detailed meanings are described in the relevant parts of this description. In addition, it is required to understand this application not only through the actual terms used, but also through the meaning implied by each term.

[0029] Flowcharts are used in this application to illustrate the operations performed by the systems according to the embodiments of this application. It should be understood that the operations before or below do not necessarily have to be performed precisely in order. On the contrary, they can be performed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or several steps may be removed from these processes.

[0030] The foreign object detection method for the product with accessories in this application is applicable to any detection instrument that detects foreign objects in products through image methods, including but not limited to X-ray detection instruments. A product with accessories refers to a product that includes accessories. In some embodiments, the accessory is any one of a desiccant and a gift. The gift is, for example, a toy, a card, etc. In some embodiments, the product is a packaged food, and the packaging can be in the form of a bag, a box, a case, etc. This application takes a bagged food product with a desiccant as an accessory as an example for illustration, and is not used to limit the specific types of the product and the accessory.

[0031] Figure 1 is an exemplary flowchart of the foreign object detection method according to an embodiment of this application. Refer to Figure 1 As shown, the foreign object detection method of this embodiment includes the following steps:

[0032] Step S11: Obtain a first product image of the product with accessories. The first product image is a grayscale image, and the accessory is in the accessory area in the first product image;

[0033] Step S12: Obtain the grayscale range of the accessory area;

[0034] Step S13: Select the center point of the accessory area according to the grayscale range, and obtain the contour of the accessory area;

[0035] Step S14: Preprocess the accessory area to make the accessory grayscale value in the accessory area close to the product grayscale value of the product, and obtain a processed second product image; and

[0036] Step S15: Perform foreign object detection on the second product image.

[0037] The above steps S11 - S15 will be described below with reference to the accompanying drawings.

[0038] Figure 2 is a schematic diagram of the first product image of the product with accessories in the foreign object detection method according to an embodiment of this application. As Figure 2 , an exemplary first product image is given, which includes a packaging bag image 210, and in the packaging bag image 210, there are 4 square food images 220, a desiccant image 230, and several foreign object images 240. Figure 2 The illustration shown is only an example and is not used to limit the types and sizes of the products, the relative sizes of the foreign objects and the desiccant, etc.

[0039] In some embodiments, the first product image is an X-ray image obtained by an X-ray detection instrument, and thus it is a grayscale image. Figure 2 Different filling patterns are used in [the figure] to represent different object images, and are not used to represent the grayscale size of the image. In other embodiments, grayscale images of the product can also be obtained using other instruments.

[0040] As Figure 2 such, when a foreign object is blocked by a desiccant, the traditional detection method cannot be used to obtain the foreign object, resulting in missed detection.

[0041] In some embodiments, when the accessory is a desiccant, the gray value of the accessory is usually less than the gray value of the product. For example, the gray value of the desiccant image 230 is less than the gray value of the square food image 220.

[0042] In step S11, a first product image is first obtained, where the accessory is located in the accessory area 231.

[0043] In step S12, the gray range of the accessory area 231 can be obtained according to the gray histogram distribution. Specifically, the gray range corresponding to the accessory area can be obtained according to the gray histogram distribution of the first product image. In some embodiments, an X-ray detection instrument can also be used to obtain an image of the separate desiccant, so that the gray range of the desiccant image 230 can be obtained.

[0044] In step S13, the center point of the accessory area 231 is selected according to the gray range, and the contour of the accessory area 231 is obtained. In this embodiment, a pixel point corresponding to a certain gray value in the gray range can be selected as the center point of the accessory area 231. For example, the pixel point corresponding to the maximum value in the gray range is selected as the center point of the accessory area 231, or the pixel point corresponding to the median of the gray range is selected as the center point of the accessory area 231. Further, morphological processing methods, such as erosion, dilation, etc., can be used to gradually obtain the contour of the accessory area 231 starting from this center point.

[0045] It should be noted that the accessory area 231 includes the desiccant image 230 and can be the circumscribed polygon of the desiccant image 230, such as a circumscribed rectangle, as Figure 2 shown by the dashed box in. Therefore, the accessory area 231 may include other images in addition to the desiccant image 230. Then this center point is essentially the center point of this circumscribed rectangle.

[0046] In step S14, preprocessing is performed on the attachment area 231 to make the attachment gray value of the attachment area 231 close to the product gray value of the product. It should be noted that "close" here means that after preprocessing, the attachment gray value of the attachment area 231 is equal to the product gray value, or the difference d between the attachment gray value and the product gray value is within a relatively small preset range. For example, assume that the preset range is [-5, 5]. In some embodiments, the attachment gray value represents the average gray value of the attachment area 231, and the product gray value represents the average gray value of the first product image. In the second product image obtained after step S14, it can be considered that the image gray values of the attachment and the product are about the same. Therefore, in step S15, a conventional foreign object detection method can be used to detect foreign objects in the second product image. This application does not limit this conventional foreign object detection method. In some embodiments, a filtering step may also be included between step S14 and step S15 to remove specific noises in the second product image, such as high-frequency noises, to further improve the foreign object detection efficiency in step S15.

[0047] In some embodiments, the preprocessing step in step S14 includes:

[0048] Step S21: Calculate the average gray value G1 of the first product image;

[0049] Step S22: Starting from the center point, make the attachment gray value Ga in the attachment area 231 change sequentially outward from the center point. When the average gray value G1 is greater than the attachment gray value Ga, the change trend of the attachment gray value Ga is to increase; when the average gray value G1 is less than the attachment gray value Ga, the change trend of the attachment gray value Ga is to decrease;

[0050] Step S23: Repeat steps S21 and S22 until the attachment gray value Ga of the attachment area 231 is close to the average gray value G1.

[0051] It can be understood that the gray value represents the light and dark of the image, and the range is generally 0 - 255. The gray value of white is 255, and the gray value of black is 0. In step S22 of the image, the case where the average gray value G1 is greater than the attachment gray value Ga indicates that the attachment image is darker than the product image; the case where the average gray value G1 is less than the attachment gray value Ga indicates that the attachment image is brighter than the product image. The foreign object detection method of this application is applicable to both cases.

[0052] When the first product image is an X-ray image, when the density of the accessory is higher than that of the product, the accessory image is darker than the product image, which conforms to the case where G1>Ga. The desiccant belongs to this case. Taking this case as an example, the step in step S22 where the accessory gray value Ga in the accessory area 231 changes sequentially from the center point outwards means that there are multiple pixel points in the accessory area 231. Starting from the center point, the pixel points around the center point are processed in sequence. The processing includes increasing the gray value of the pixel point to make the pixel point lighter. It should be noted that in some embodiments, the accessory gray value Ga is the average gray value of the accessory area 231.

[0053] In some embodiments, in step S22, the step of making the accessory gray value Ga in the accessory area 231 change sequentially from the center point outwards includes: adjusting the gray change amplitude of the current position P according to the current accessory gray value Gp corresponding to the current position P in the accessory area 231. A larger gray change amplitude corresponds to a larger difference between the current accessory gray value Gp and the average gray value G1, and a smaller gray change amplitude corresponds to a smaller difference between the current accessory gray value Gp and the average gray value G1. These embodiments achieve adaptively adjusting the gray value of the pixel point according to the current accessory gray value Gp of the pixel point at the current position P. Specifically, in some embodiments, a threshold Th can be set. For the pixel point at the current position P, if │Gp - G1│>Th, the gray change amplitude corresponding to the pixel point is the first gray change amplitude, such as A1; if │Gp - G1│≤Th, the gray change amplitude corresponding to the pixel point is the second gray change amplitude, such as A2, and A1>A2. That is, for pixel points with a larger difference, the change amplitude can be larger. For example, the gray value of the pixel point is increased by a larger value A2, making the pixel point relatively lighter to a greater extent; for pixel points with a smaller difference, the change amplitude can be smaller. For example, the gray value of the pixel point is increased by a smaller value A1, making the pixel point relatively lighter to a smaller extent. According to these embodiments, overall, the gray value of the accessory area 231 will approach G1. Compared with the processing of all pixel points in the accessory area 231 with equal amplitude changes, these embodiments can avoid excessive adjustment of some pixel points and at the same time insufficient adjustment of some pixel points.

[0054] In some other embodiments, in step S22, the step of causing the accessory gray values in the accessory area 231 to change sequentially from the center point outwards includes: adjusting the gray value change amplitude of the current position P according to the current position P in the accessory area 231, where a larger gray value change amplitude corresponds to the current position P being closer to the center point, and a smaller gray value change amplitude corresponds to the current position P being farther from the center point. In these embodiments, assuming that the gray value corresponding to the center point selected in step S13 is the largest, that is, its color is the darkest, then the colors of the pixel points from this center point outwards become lighter in sequence. Correspondingly, the closer the pixel point is to the center point, the greater the degree of gray value increase, and the farther the pixel point is from the center point, the smaller the degree of gray value increase. Thus, overall, the gray values of the processed accessory area 231 are relatively uniform. In some embodiments, a correspondence relationship between the distance between the current position P and the center point O and the gray value change amplitude can be established. This correspondence relationship can be a linear relationship or a non-linear relationship. The non-linear relationship can include a quadratic function relationship, an exponential relationship, etc. All can be verified based on actual data according to the actual situation, and the most suitable correspondence relationship for this type of accessory and this product can be selected.

[0055] In step S23 above, steps S21 and S22 are repeatedly executed. It should be noted that when step S21 is executed for the second time, at this time, since the accessory gray values in the accessory area 231 have changed, and the first product image includes this accessory area 231, therefore, the average gray value P1 calculated should also be different from the P1 obtained in the previous calculation. The condition for ending the loop is as described above, that is, the accessory gray value in the accessory area 231 is equal to the product gray value, or the difference d between the accessory gray value and the product gray value is within a relatively small preset range. The first product image including the accessory area 231 that finally meets the condition is used as the second product image.

[0056] In some embodiments, step S15 includes: adopting a set of detection parameters for the second product image, and the detection parameters include a gray value threshold. The conventional foreign object detection method is to use the gray value threshold method to detect foreign objects. This gray value threshold can be a single threshold, or different gray value thresholds can be set for different frequencies and different gray values, all within the protection scope of this application. In this embodiment, only a set of gray value thresholds can be set for this second product image, and such processing has high efficiency, thereby improving the detection efficiency.

[0057] In some other embodiments, step S15 includes: adopting a first detection parameter for the accessory area 231 in the second product image, and adopting a second detection parameter for other areas in the second product image except the accessory area 231. The first detection parameter includes a first grayscale value threshold, and the second detection parameter includes a second grayscale value threshold, where the first grayscale value threshold is different from the second grayscale value threshold. These embodiments adopt different grayscale value thresholds for the accessory area 231 and other areas. Under the same hardware conditions, the processing efficiency may be lower than that of the embodiments with only one set of grayscale thresholds. However, since the grayscale value thresholds are set separately for the accessory area 231 and other areas, it is beneficial to detect foreign objects in the accessory area 231.

[0058] Figure 3 is the actual detection result obtained by using Method 1 described in the background art. The smaller dots are the foreign objects marked by the detection result, and this result indicates that the desiccant 310 is marked as a foreign object, resulting in a false detection. Figure 4 is the actual detection result obtained by using Method 2 described in the background art. Among them, the foreign object blocked by the desiccant 410 is not detected, resulting in a missed detection. Figure 5 is the actual detection result obtained by using the foreign object detection method of the present application. As Figure 5 shown, a foreign object 511 is also detected in the area where the desiccant 510 is located, indicating that the foreign object detection method of the present application has a high detection rate.

[0059] The present application also proposes an X-ray detection instrument, including a foreign object detection module for performing foreign object detection by using the foreign object detection method described above. Using this X-ray detection instrument can improve the foreign object detection rate of products with accessories, reduce the false detection rate and missed detection rate, which is beneficial to improving the product detection efficiency, reducing product waste, and improving customer satisfaction.

[0060] The basic concepts have been described above. Obviously, for those skilled in the art, the above application disclosure is only an example and does not constitute a limitation to the present application. Although not explicitly stated here, those skilled in the art may make various modifications, improvements, and corrections to the present application. Such modifications, improvements, and corrections are proposed in the present application, so such modifications, improvements, and corrections still belong to the spirit and scope of the exemplary embodiments of the present application.

[0061] Meanwhile, this application uses specific terms to describe the embodiments of this application. For example, "an embodiment", "one embodiment", and / or "some embodiments" mean a certain feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that the "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more at different positions in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application can be appropriately combined.

[0062] Similarly, it should be noted that, in order to simplify the presentation of the disclosure of this application and thus help the understanding of one or more embodiments of the invention, in the foregoing description of the embodiments of this application, sometimes multiple features are grouped into one embodiment, drawing, or description thereof. However, this disclosure method does not mean that the features required by the subject matter of this application are more than those mentioned in the claims. In fact, the features of the embodiment are fewer than all the features of the single embodiment disclosed above.

[0063] In some embodiments, numbers are used to describe the components and the quantity of attributes. It should be understood that such numbers used for the description of embodiments are modified by the modifiers "about", "approximately", or "substantially" in some examples. Unless otherwise specified, "about", "approximately", or "substantially" indicate that the said numbers allow a variation of ±20%. Accordingly, in some embodiments, the numerical parameters used in this application are all approximate values, and such approximate values can be changed according to the characteristics required by individual embodiments. In some embodiments, the numerical parameters should consider the specified significant digits and adopt the method of retaining the general number of digits. Although the numerical ranges and parameters used in some embodiments of this application to confirm the breadth of their scope are approximate values, in specific embodiments, such numerical settings are as precise as possible within the feasible range.

Claims

1. A method for detecting foreign matter in a product with accessories, characterized in that: include: Obtaining a first product image of the product with accessories, wherein the first product image is a grayscale image, and the accessories are in an accessories area in the first product image; Obtaining the grayscale range of the attachment area; Selecting a center point of the attachment area according to the grayscale range, and obtaining a contour of the attachment area; Preprocessing the accessory area so that the accessory grayscale value of the accessory area is close to the product grayscale value of the product, and obtaining a processed second product image; as well as The second product image is subjected to foreign matter detection.

2. The foreign body detection method according to claim 1, characterized in that: The step of preprocessing the attachment area comprises: Step S21: calculating the average gray value of the first product image; Step S22: Taking the center point as the starting point, the grayscale value of the attachment in the attachment area changes from the center point outward in sequence, when the average grayscale value is greater than the grayscale value of the attachment, the grayscale value of the attachment changes in a trend of increasing; when the average grayscale value is less than the grayscale value of the attachment, the grayscale value of the attachment changes in a trend of decreasing; Step S23: Repeat the steps S21 and S22 until the attachment grayscale value of the attachment area approaches the average grayscale value.

3. The foreign body detection method according to claim 2, characterized in that: In step S22, the step of making the accessory grayscale value in the accessory area change sequentially from the center point outward includes: adjusting the grayscale change amplitude of the current position according to the current accessory grayscale value corresponding to the current position in the accessory area, a larger grayscale change amplitude corresponds to a larger difference between the current accessory grayscale value and the average grayscale value, and a smaller grayscale change amplitude corresponds to a smaller difference between the current accessory grayscale value and the average grayscale value.

4. The foreign body detection method according to claim 2, characterized in that: In step S22, the step of making the attachment grayscale value in the attachment area change sequentially from the center point outward includes: adjusting the grayscale change amplitude of the current position according to the current position in the attachment area, the current position closer to the center point corresponds to a larger grayscale change amplitude, and the current position farther from the center point corresponds to a smaller grayscale change amplitude.

5. The foreign body detection method according to claim 1, characterized in that: The step of performing foreign matter detection on the second product image includes: A set of detection parameters is applied to the second product image, the detection parameters including a grayscale value threshold.

6. The foreign body detection method according to claim 1, characterized in that: The step of performing foreign matter detection on the second product image includes: A first detection parameter is used for the accessory area in the second product image, and a second detection parameter is used for other areas in the second product image except the accessory area, the first detection parameter includes a first grayscale value threshold, and the second detection parameter includes a second grayscale value threshold, wherein the first grayscale value threshold is different from the second grayscale value threshold.

7. The foreign body detection method according to claim 1, characterized in that: The first product image is an X-ray image obtained by an X-ray detection instrument, and the grayscale value of the accessory is smaller than the grayscale value of the product.

8. The foreign body detection method according to claim 1, characterized in that: The accessories include any of desiccants and gifts.

9. The foreign body detection method according to claim 1, characterized in that: The product comprises a food product in packaging.

10. An X-ray detection instrument, characterized in that: It comprises a foreign body detection module, which is used to perform foreign body detection using the foreign body detection method according to any one of claims 1 to 9.