CN115601697A - A preprocessing method for terahertz security images - Google Patents

A preprocessing method for terahertz security images Download PDF

Info

Publication number
CN115601697A
CN115601697A CN202211208439.4A CN202211208439A CN115601697A CN 115601697 A CN115601697 A CN 115601697A CN 202211208439 A CN202211208439 A CN 202211208439A CN 115601697 A CN115601697 A CN 115601697A
Authority
CN
China
Prior art keywords
image
sample
connected domain
terahertz security
security inspection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211208439.4A
Other languages
Chinese (zh)
Inventor
李羿璋
刘陵玉
王忠民
李珂
徐文青
郭永斌
刘伦彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New Material Institute of Shandong Academy of Sciences
Original Assignee
New Material Institute of Shandong Academy of Sciences
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New Material Institute of Shandong Academy of Sciences filed Critical New Material Institute of Shandong Academy of Sciences
Priority to CN202211208439.4A priority Critical patent/CN115601697A/en
Publication of CN115601697A publication Critical patent/CN115601697A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/50Context or environment of the image
    • G06V20/52Surveillance or monitoring of activities, e.g. for recognising suspicious objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/30Noise filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • G06V10/457Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components by analysing connectivity, e.g. edge linking, connected component analysis or slices

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a pretreatment method and system for a terahertz security inspection image, electronic equipment and a computer readable storage medium, and belongs to the technical field of terahertz waveband digital image analysis. The method comprises the steps of obtaining a terahertz security inspection image not containing a sample and a terahertz security inspection image containing the sample; performing histogram analysis on the terahertz security inspection image without the sample to acquire a gray value with the maximum number of corresponding pixels; carrying out corrosion operation on the terahertz security inspection image containing the sample, and carrying out binarization gray scale transformation on the processed image by taking the gray scale value with the maximum number of corresponding pixels as a threshold value; performing connected domain analysis on the image subjected to the binary gray processing to obtain a boundary of a sample, and performing burr trimming on the boundary; and acquiring a corrected image according to the image after the burr trimming. The interference of packages such as paper boxes, envelopes and the like is eliminated, and researchers can conveniently identify suspicious dangerous goods in the paper boxes and the envelopes visually or through an image recognition algorithm.

Description

一种面向太赫兹安检图像的前处理方法A preprocessing method for terahertz security images

技术领域technical field

本申请涉及太赫兹波段数图像分析技术领域,特别是涉及一种面向太赫兹安检图像的前处理方法。The present application relates to the technical field of terahertz band number image analysis, in particular to a pre-processing method for terahertz security images.

背景技术Background technique

本部分的陈述仅仅是提到了与本申请相关的背景技术,并不必然构成现有技术。The statements in this section merely mention the background art related to this application, and do not necessarily constitute the prior art.

纸壳包装材料对太赫兹具有高透过性、金属对太赫兹波有强反射特性、水等极性液体对太赫兹波具有强吸收特性、不规则界面及曲面对太赫兹波散射作用较强,因此,太赫兹连续波成像系统对纸壳包覆下的金属、瓶中极性液体有较强的探测能力,对各类物体的边界敏感,初步应用于包裹、信封的危险物品检查。Paper shell packaging materials have high permeability to terahertz waves, metals have strong reflection characteristics on terahertz waves, polar liquids such as water have strong absorption characteristics on terahertz waves, and irregular interfaces and curved surfaces have a relatively strong scattering effect on terahertz waves. Therefore, the terahertz continuous wave imaging system has a strong detection ability for metals covered by paper shells and polar liquids in bottles, and is sensitive to the boundaries of various objects. It is initially applied to the inspection of dangerous goods in packages and envelopes.

太赫兹安检的发展方向是智能化,基于太赫兹图像特征和先进的人工智能算法,不仅需要实现内部危险品的定位,还要完成危险品种类的识别。然而现阶段,可见光波段下的图像识别算法在太赫兹波段效果不佳,原因是太赫兹波长较长,衍射分辨极限较大。The development direction of terahertz security inspection is intelligence. Based on terahertz image features and advanced artificial intelligence algorithms, it is not only necessary to realize the positioning of internal dangerous goods, but also to complete the identification of dangerous goods. However, at this stage, the image recognition algorithm in the visible light band is not effective in the terahertz band, because the terahertz wavelength is longer and the diffraction resolution limit is larger.

此外,太赫兹源的功率较低,成像器件的像元数目较少、像元的空间尺度较大,都导致太赫兹连续波图像辨识难度高。In addition, the power of the terahertz source is low, the number of pixels in the imaging device is small, and the spatial scale of the pixels is large, all of which make it difficult to identify terahertz continuous wave images.

而基于太赫兹连续波成像的安检中获取的太赫兹安检图像,如纸箱、信封,有其独特特点:潜在目标位于纸箱、信封内部,尽管包装材料本身对太赫兹波吸收较弱,纸箱、信封边缘对太赫兹波散射作用强,因此,纸箱边缘和内部潜在目标的图像容易出现粘连,对研究人员目视或后期通过图像识别算法辨识纸盒、信封内的可疑危险物品都极为不利;在训练图像分类器时,需要测试人员在图像训练过程中始终保持目标和纸箱、信封边缘具有一定的距离。The terahertz security images obtained in the security inspection based on terahertz continuous wave imaging, such as cartons and envelopes, have unique characteristics: potential targets are located inside cartons and envelopes, although the packaging materials themselves have weak absorption of terahertz waves, cartons, envelopes The edge has a strong effect on the scattering of terahertz waves. Therefore, the images of the edge of the carton and the potential targets inside are prone to adhesion, which is extremely unfavorable for researchers to identify suspicious and dangerous items in cartons and envelopes visually or later through image recognition algorithms; When using an image classifier, testers are required to keep a certain distance between the target and the edges of cartons and envelopes during the image training process.

发明内容Contents of the invention

发明人发现,太赫兹安检图像辨识的一种理想方式是:首先检测出纸箱、信封的完整边界,对纸箱、信封进行定位,然后通过算法进行处理,最后再通过目视或图像识别算法辨识纸箱、信封内部物品的图像。然而,目前鲜有研究者基于此思路提出针对性的太赫兹安检图像处理方法,限制了危险品图像识别的准确度提升。The inventor found that an ideal method for terahertz security inspection image recognition is: first detect the complete boundaries of cartons and envelopes, locate the cartons and envelopes, then process them through algorithms, and finally identify the cartons through visual or image recognition algorithms , an image of the contents of the envelope. However, few researchers have proposed targeted terahertz security image processing methods based on this idea, which limits the accuracy of dangerous goods image recognition.

为了解决现有技术的不足,本申请提供了一种面向太赫兹安检图像的前处理方法、系统、电子设备及计算机可读存储介质,用于剔除纸盒、信封等包装的干扰,方便研究人员目视或通过图像识别算法辨识纸盒、信封内的可疑危险物品。In order to solve the deficiencies of the prior art, this application provides a pre-processing method, system, electronic equipment and computer-readable storage medium for terahertz security images, which are used to eliminate the interference of packaging such as cartons and envelopes, which is convenient for researchers Identify suspicious and dangerous items in cartons and envelopes visually or through image recognition algorithms.

第一方面,本申请提供了一种面向太赫兹安检图像的前处理方法;In the first aspect, the present application provides a preprocessing method for terahertz security images;

一种面向太赫兹安检图像的前处理方法,包括:A preprocessing method for terahertz security images, including:

获取不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像;其中,所述样本为可能包含危险品的纸箱或信封;Obtaining a terahertz security check image that does not contain a sample and a terahertz security check image that contains a sample; wherein the sample is a carton or envelope that may contain dangerous goods;

对不包含样本的太赫兹安检图像进行直方图分析,获取对应像素数目最多的灰度值;Perform histogram analysis on the terahertz security inspection image that does not contain samples, and obtain the gray value with the largest number of corresponding pixels;

对包含样本的太赫兹安检图像进行腐蚀操作,以对应像素数目最多的灰度值为阈值,对处理后的图像进行二值化灰度变换;Corrosion operation is performed on the terahertz security inspection image containing the sample, and the gray value corresponding to the largest number of pixels is used as the threshold value, and the processed image is subjected to binary gray scale transformation;

对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪;Perform connected domain analysis on the image after binary grayscale processing, obtain the boundary of the sample, and perform burr trimming on the boundary;

根据毛刺修剪后的图像,获取修正图像。According to the burr-trimmed image, a corrected image is obtained.

第二方面,本申请提供了一种面向太赫兹安检图像的前处理系统;In the second aspect, the present application provides a pre-processing system for terahertz security images;

一种面向太赫兹安检图像的前处理系统,包括:A pre-processing system for terahertz security images, including:

图像获取模块,被配置为:获取不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像;其中,所述样本为可能包含危险品的纸箱或信封;The image acquisition module is configured to: acquire a terahertz security check image that does not contain a sample and a terahertz security check image that contains a sample; wherein the sample is a carton or envelope that may contain dangerous goods;

背景图片分析模块,被配置为:对不包含样本的太赫兹安检图像进行直方图分析,获取对应像素数目最多的灰度值;The background image analysis module is configured to: perform histogram analysis on the terahertz security inspection image that does not contain samples, and obtain the gray value corresponding to the largest number of pixels;

降噪模块,被配置为:对包含样本的太赫兹安检图像进行腐蚀操作,以对应像素数目最多的灰度值为阈值,对处理后的图像进行二值化灰度变换;The noise reduction module is configured to: perform a corrosion operation on the terahertz security inspection image containing the sample, use the gray value corresponding to the largest number of pixels as the threshold value, and perform binary gray-scale transformation on the processed image;

毛刺修剪模块,被配置为:对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪;The burr pruning module is configured to: perform connected domain analysis on the binary grayscale processed image, obtain the boundary of the sample, and perform burr pruning on the boundary;

修正图像获取模块,被配置为:根据毛刺修剪后的图像,获取修正图像。The corrected image acquisition module is configured to: acquire the corrected image according to the image trimmed by the burr.

第三方面,本申请提供了一种电子设备;In a third aspect, the present application provides an electronic device;

一种电子设备,包括存储器和处理器以及存储在存储器上并在处理器上运行的计算机指令,所述计算机指令被处理器运行时,完成上述面向太赫兹安检图像的前处理方法的步骤。An electronic device includes a memory, a processor, and computer instructions stored in the memory and run on the processor. When the computer instructions are run by the processor, the steps of the above-mentioned preprocessing method for terahertz security images are completed.

第四方面,本申请提供了一种计算机可读存储介质;In a fourth aspect, the present application provides a computer-readable storage medium;

一种计算机可读存储介质,用于存储计算机指令,所述计算机指令被处理器执行时,完成上述面向太赫兹安检图像的前处理方法的步骤。A computer-readable storage medium is used for storing computer instructions, and when the computer instructions are executed by a processor, the steps of the above-mentioned preprocessing method for terahertz security images are completed.

与现有技术相比,本申请的有益效果是:Compared with prior art, the beneficial effect of the present application is:

1、本申请基于包含样本的太赫兹安检图像和不包含样本的太赫兹安检图像的特点,对包含样本的太赫兹安检图像进行处理,剔除了纸箱或信封等包装边界的干扰,便于研究人员目视或通过图像识别算法辨识包装内的可疑危险物品,提高了危险品图像识别的准确度;1. Based on the characteristics of terahertz security inspection images containing samples and terahertz security inspection images not containing samples, this application processes the terahertz security inspection images containing samples to eliminate the interference of packaging boundaries such as cartons or envelopes, which is convenient for researchers to see Identify suspicious dangerous goods in the package visually or through image recognition algorithms, improving the accuracy of dangerous goods image recognition;

2、本申请在毛刺修剪的过程中标记了连通域的边界,便于与其他边缘增强算法相结合;无需额外进行求梯度:对于二值图像来说,相对搜索方向左侧的梯度永远等于-255;保持原搜索方向搜索失败时,该像素朝该行进方向的梯度为 -255。除此之外,图像其它地方的任何方向灰度值梯度都为0,显著简化了求梯度的计算量。2. This application marks the boundary of the connected domain during the burr pruning process, which is convenient for combining with other edge enhancement algorithms; no additional gradient calculation is required: for binary images, the gradient on the left side of the search direction is always equal to -255 ; When the search fails in the original search direction, the gradient of the pixel toward the direction of travel is -255. In addition, the gradient of the gray value in any direction elsewhere in the image is 0, which significantly simplifies the calculation of the gradient.

附图说明Description of drawings

构成本申请的一部分的说明书附图用来提供对本申请的进一步理解,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。The accompanying drawings constituting a part of the present application are used to provide further understanding of the present application, and the schematic embodiments and descriptions of the present application are used to explain the present application, and do not constitute improper limitations to the present application.

图1为本申请实施例提供的一种面向太赫兹安检图像的前处理方法的流程示意图;FIG. 1 is a schematic flow chart of a preprocessing method for terahertz security images provided in the embodiment of the present application;

图2为本申请实施例提供的对包含样本的太赫兹安检图像进行腐蚀操作的示意图;其中,(a)为腐蚀前的图像,(b)为结构元素,(c)为腐蚀后的图像;Fig. 2 is a schematic diagram of the corrosion operation on the terahertz security image containing the sample provided by the embodiment of the present application; wherein, (a) is the image before corrosion, (b) is the structural element, and (c) is the image after corrosion;

图3为本申请实施例提供的包含样本的太赫兹图像的连通域示意图;Fig. 3 is a schematic diagram of connected domains of a terahertz image including samples provided by the embodiment of the present application;

图4为本申请实施例提供的毛刺修剪前后的对比示意图;其中,(a)为连通域初始外边界队列示意图,(b)为毛刺修剪后的外边界队列示意图;4 is a schematic diagram of comparison before and after burr pruning provided by the embodiment of the present application; wherein, (a) is a schematic diagram of an initial outer boundary queue of a connected domain, and (b) is a schematic diagram of an outer boundary queue after burr pruning;

图5为本申请实施例提供的连通域初始外边界队列生成的流程示意图;FIG. 5 is a schematic flow diagram of the generation of the initial outer boundary queue of the connected domain provided by the embodiment of the present application;

图6为本申请实施例提供的连通域外边界队列调整的流程示意图;FIG. 6 is a schematic flow diagram of queue adjustment outside the connected domain provided by the embodiment of the present application;

图7为本申请实施例提供的连通域内边界标记示意图;其中(a)为连通域示意图,(b)为计算关键数值统计表,(c)为判断是否为真实空洞连通域的流程示意图。Fig. 7 is a schematic diagram of boundary markers in a connected domain provided by the embodiment of the present application; wherein (a) is a schematic diagram of a connected domain, (b) is a statistical table for calculating key values, and (c) is a schematic flow chart for judging whether it is a real empty connected domain.

具体实施方式detailed description

应该指出,以下详细说明都是示例性的,旨在对本申请提供进一步的说明。除非另有指明,本申请使用的所有技术和科学术语具有与本申请所属技术领域的普通技术人员通常理解的相同含义。It should be pointed out that the following detailed description is exemplary and is intended to provide further explanation to the present application. Unless defined otherwise, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.

需要注意的是,这里所使用的术语仅是为了描述具体实施方式,而非意图限制根据本申请的示例性实施方式。如在这里所使用的,除非上下文另外明确指出,否则单数形式也意图包括复数形式,此外,还应当理解的是,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terminology used here is only for describing specific implementations, and is not intended to limit the exemplary implementations according to the present application. As used herein, unless the context clearly dictates otherwise, the singular is intended to include the plural, and it should also be understood that the terms "comprising" and "having" and any variations thereof are intended to cover a non-exclusive Comprising, for example, a process, method, system, product, or device comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include steps or units not explicitly listed or for these processes, methods, Other steps or units inherent in a product or equipment.

在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。In the case of no conflict, the embodiments and the features in the embodiments of the present invention can be combined with each other.

实施例一Embodiment one

现有技术中,基于太赫兹连续波成像进行安检时获取的太赫兹图像有其独特的特点,信封或纸箱包装边缘和内部潜在目标的图像容易出现粘连,对于研究人员通过目视或图像识别算法进行危险品识别极为不利;因此,本申请提供了一种面向太赫兹安检图像的前处理方法,剔除纸盒、信封等包装的干扰,便于研究人员进行危险品识别,提高识别的准确度。In the existing technology, the terahertz images obtained during security inspection based on terahertz continuous wave imaging have their unique characteristics. The images of the edges of envelopes or carton packaging and the images of potential targets inside are prone to adhesion. It is extremely disadvantageous to identify dangerous goods; therefore, this application provides a pre-processing method for terahertz security images, which eliminates the interference of packaging such as cartons and envelopes, so that researchers can identify dangerous goods and improve the accuracy of identification.

一种面向太赫兹安检图像的前处理方法,包括:A preprocessing method for terahertz security images, including:

获取不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像;其中,样本为可能包含危险品的纸箱或信封;Obtain terahertz security inspection images that do not contain samples and terahertz security inspection images that contain samples; where the samples are cartons or envelopes that may contain dangerous goods;

对不包含样本的太赫兹安检图像进行直方图分析,获取对应像素数目最多的灰度值;Perform histogram analysis on the terahertz security inspection image that does not contain samples, and obtain the gray value with the largest number of corresponding pixels;

对包含样本的太赫兹安检图像进行腐蚀操作,以对应像素数目最多的灰度值为阈值,对处理后的图像进行二值化灰度变换;Corrosion operation is performed on the terahertz security inspection image containing the sample, and the gray value corresponding to the largest number of pixels is used as the threshold value, and the processed image is subjected to binary gray scale transformation;

对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪;Perform connected domain analysis on the image after binary grayscale processing, obtain the boundary of the sample, and perform burr trimming on the boundary;

根据毛刺修剪后的图像,获取修正图像。According to the burr-trimmed image, a corrected image is obtained.

进一步的,对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪包括:Further, the connected domain analysis is performed on the binary grayscale processed image, the boundary of the sample is obtained, and the burr trimming of the boundary includes:

对二值灰度处理后的图像进行连通域分析,获取样本的外边界,对外边界进行毛刺修剪;Perform connected domain analysis on the image after binary grayscale processing, obtain the outer boundary of the sample, and perform burr trimming on the outer boundary;

检测连通域内是否存在内边界;Detect whether there is an inner boundary in the connected domain;

若连通域内存在内边界,对内边界进行毛刺修剪。If there is an inner boundary in the connected domain, burr pruning is performed on the inner boundary.

优选的,对二值灰度处理后的图像进行连通域分析,获取样本的外边界的具体步骤为:Preferably, the connected domain analysis is carried out to the image after binary grayscale processing, and the specific steps of obtaining the outer boundary of the sample are:

基于二值灰度处理后的图像,获取灰度值为255的连通域,剔除异常区域,获取样本的外边界。Based on the image after binary grayscale processing, the connected domain with a grayscale value of 255 is obtained, the abnormal region is eliminated, and the outer boundary of the sample is obtained.

优选的,对外边界进行毛刺修剪的具体步骤为:Preferably, the specific steps for performing burr trimming on the outer boundary are:

标记连通域的初始外边界队列;Mark the initial outer boundary queue of the connected domain;

基于初始外边界队列,根据队列索引,查找队列索引对应的像素坐标;若不同的队列索引对应的像素坐标相同,则在初始外边界队列中删除索引值在删除两个队列索引之间的像素坐标;Based on the initial outer boundary queue, according to the queue index, find the pixel coordinates corresponding to the queue index; if the pixel coordinates corresponding to different queue indexes are the same, delete the index value in the initial outer boundary queue and delete the pixel coordinates between the two queue indexes ;

遍历搜索调整后的外边界队列,直至整个队列处理完毕。Traverse and search the adjusted outer boundary queue until the entire queue is processed.

优选的,标记连通域的初始外边界队列的具体步骤为:Preferably, the specific steps of marking the initial outer boundary queue of the connected domain are:

找到连通域中x坐标或y坐标最小的像素,将该像素坐标作为初始外边界队列的首位;Find the pixel with the smallest x-coordinate or y-coordinate in the connected domain, and set the pixel coordinate as the first of the initial outer boundary queue;

以向右为起始搜索方向,相对搜索方向以左、前、右、后的顺序开展搜索;若搜素的像素在该连通域内,则将该像素坐标加入初始外边界队列中,同时更新搜索方向;Start the search direction to the right, and search in the order of left, front, right, and back relative to the search direction; if the searched pixel is in the connected domain, add the pixel coordinates to the initial outer boundary queue, and update the search at the same time direction;

若添加的像素坐标与起始点坐标相同,则搜索终止。进一步的,以对应像素数目最多的灰度值为阈值,对处理后的图像进行二值化灰度变换的具体步骤为:If the added pixel coordinates are the same as the starting point coordinates, the search is terminated. Further, the specific steps for performing binary grayscale transformation on the processed image are as follows:

将所有大于等于阈值的像素的灰度值调整为0,将灰度值低于阈值的像素灰度值调整为255。Adjust the gray value of all pixels greater than or equal to the threshold to 0, and adjust the gray value of pixels whose gray value is lower than the threshold to 255.

进一步的,根据毛刺修剪后的图像,获取修正图像的具体步骤为:Further, according to the burr-trimmed image, the specific steps for obtaining the corrected image are:

将毛刺修剪后的连通域中每个坐标对应的像素灰度值恢复为与包含样本的太赫兹安检图像中对应像素灰度值;Restoring the pixel gray value corresponding to each coordinate in the connected domain after burr pruning to the corresponding pixel gray value in the terahertz security image containing the sample;

将毛刺修剪后的图像中的其他像素调整为255,获取修正图像。Adjust the other pixels in the glitch-trimmed image to 255 to obtain the corrected image.

接下来,结合图1-7对本实施例公开的一种面向太赫兹安检图像的前处理方法进行详细说明。Next, a preprocessing method for terahertz security images disclosed in this embodiment will be described in detail with reference to FIGS. 1-7 .

本实施例提供了一种面向太赫兹安检图像的前处理方法,该面向太赫兹安检图像的前处理方法,包括:This embodiment provides a preprocessing method for terahertz security images, the preprocessing method for terahertz security images includes:

S1、获取不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像;其中,不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像通过连续波太赫兹安检系统采集,均为太赫兹波段灰度图像;图像采集时外部设备的参数不变:第一次采集获得不包含样本的太赫兹安检图像(即不包含样本的空白背景图片,记为灰度值矩阵P0),第二次采集获得包含样本的太赫兹安检图片(记为灰度值矩阵P1);样本可以为包含一个或多个危险品的一个纸盒或信封,危险品为从形状角度判定具备危险或可疑有待化学分析的物品。S1. Obtain a terahertz security inspection image that does not contain a sample and a terahertz security inspection image that contains a sample; wherein, the terahertz security inspection image that does not contain a sample and the terahertz security inspection image that contains a sample are collected by a continuous wave terahertz security inspection system, both of which are terahertz security inspection images. Hertz band grayscale image; the parameters of the external equipment remain unchanged during image acquisition: the first acquisition obtains a terahertz security image that does not contain samples (that is, a blank background image that does not contain samples, which is recorded as a gray value matrix P0), and the second The terahertz security inspection picture containing the sample is collected for the first time (denoted as the gray value matrix P1); the sample can be a carton or envelope containing one or more dangerous goods, and the dangerous goods are dangerous or suspected to be chemically analyzed items.

在本实施例中,样本为包含一个危险品的纸盒。In this example, the sample is a carton containing one hazardous product.

S2、对P0进行直方图分析,获取对应像素数目最多的灰度值并记该灰度值为g,该灰度值为背景灰度值的众数。S2. Perform a histogram analysis on P0, obtain the gray value corresponding to the largest number of pixels and record the gray value as g, which is the mode of the background gray value.

S3、对P1进行形态学腐蚀操作,结构算子如下:S3. Perform a morphological corrosion operation on P1, and the structure operator is as follows:

Figure RE-GDA0003938133110000081
Figure RE-GDA0003938133110000081

如图2所示,为增加可读性,浅灰色示意灰度值为255,像素之间靠白色细线划分,图2(a)表示腐蚀前的图像,图2(b)表示结构元素,图2(c)表示腐蚀后的图像。As shown in Figure 2, in order to increase readability, the light gray indicates that the gray value is 255, and the pixels are divided by white thin lines. Figure 2(a) shows the image before corrosion, and Figure 2(b) shows the structural elements. Figure 2(c) shows the image after etching.

在本实施例中,假设结构元素中心与图2(a)中某浅灰色色块重合,若结构元素的全部色块都被图2(a)中的浅灰色区域覆盖,则该重合的色块被保留;以结构元素为模板对原图像中的像素进行遍历,处理后得到图2(c)所示的图像。In this embodiment, assuming that the center of the structural element coincides with a light gray color block in Figure 2(a), if all the color blocks of the structural element are covered by the light gray area in Figure 2(a), the overlapping color The block is preserved; the pixels in the original image are traversed using the structural element as a template, and the image shown in Figure 2(c) is obtained after processing.

记腐蚀操作处理后的图像为P2,以g为阈值,对处理后的图像进行二值化灰度变换,将所有大于等于g的像素灰度值都调整为0(“逻辑0”),将灰度值低于g的像素灰度值调整为255(“逻辑1”),得到图像P3。Note that the image processed by the corrosion operation is P2, and g is the threshold value, and the processed image is subjected to binary grayscale transformation, and the grayscale values of all pixels greater than or equal to g are adjusted to 0 ("logic 0"), and the The gray value of the pixel whose gray value is lower than g is adjusted to 255 ("logic 1"), and the image P3 is obtained.

S4、对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪;S4. Perform connected domain analysis on the image after binary grayscale processing, obtain the boundary of the sample, and perform burr trimming on the boundary;

在采用形态学方法处理图像并二值化后,图像边缘可能出现参差不齐的现象,这主要是形态学模板不够理想、太赫兹波在物品边缘散射状况复杂造成的。修剪的目的是用消除边缘留下的“毛刺”,这里定义的毛刺有共通特点是最小宽度等于1个像素。After the image is processed and binarized by the morphological method, the edge of the image may appear uneven, which is mainly caused by the unsatisfactory morphological template and the complex scattering of terahertz waves at the edge of the object. The purpose of trimming is to eliminate the "burrs" left by the edges. The burrs defined here have a common feature that the minimum width is equal to 1 pixel.

具体步骤包括:Specific steps include:

S401、基于二值灰度处理后的图像,获取灰度值为255的连通域,剔除异常区域,获取样本的外边界;具体的,对P3开展连通域分析,寻找逻辑为1的连通域,从结果中剔除大小小于等于4的区域、x方向或y方向小于等于2个像素的区域,将剩余的灰度值为255的连通域标记为有效目标,对应像素的集合依次编号为A1、A2、A3…An,将其它灰度值为0的区域定义为背景,所有像素坐标的集合记为B。S401. Based on the binary grayscale processed image, obtain a connected domain with a grayscale value of 255, remove abnormal regions, and obtain the outer boundary of the sample; specifically, perform connected domain analysis on P3, and find a connected domain with logic 1, From the result, remove the area whose size is less than or equal to 4, and the area whose size is less than or equal to 2 pixels in the x direction or y direction, and mark the remaining connected domain with a gray value of 255 as a valid target, and the corresponding pixel sets are numbered A 1 , A 2 , A 3 . . . An, define other regions with gray value 0 as the background, and record the set of all pixel coordinates as B.

在本实施例中,如图3所示,连通域是浅灰色像素坐标的集合且集合中任一元素与其它元素的最小距离等于1像素。左上、右上、左下、右下的连通域分别标记为A1、A2、A3、A4,由于A3大小等于4被剔除,A4的y方向像素等于1被剔除。In this embodiment, as shown in FIG. 3 , a connected domain is a set of light gray pixel coordinates and the minimum distance between any element in the set and other elements is equal to 1 pixel. The upper left, upper right, lower left, and lower right connected domains are respectively marked as A 1 , A 2 , A 3 , and A 4 . Since the size of A 3 is equal to 4, it is eliminated, and the pixel in the y direction of A 4 is equal to 1.

S402、标记连通域的初始外边界队列;具体的,找到某连通域x坐标最小的像素(若x坐标最小的像素不止一个则找这些点中y坐标最小的像素),记录其坐标(即为起始点坐标)并添加到初始外边界队列首位;以向右为初始搜索方向,相对搜索方向以左、前、右、后的优先级(降序)顺序开展搜索,每次搜索像素坐标步长为1,若搜索的像素在该连通域内,则把该像素的坐标值加入队列中,同时更新搜索方向;每次添加新坐标时检查是否与起始点坐标相同,如队列中再次出现起始点坐标则搜索终止,队列长度也不再发生变化。S402. Mark the initial outer boundary queue of the connected domain; specifically, find the pixel with the smallest x-coordinate of a certain connected domain (if there are more than one pixel with the smallest x-coordinate, then find the pixel with the smallest y-coordinate among these points), and record its coordinates (that is, Starting point coordinates) and added to the first position of the initial outer boundary queue; the initial search direction is to the right, and the relative search direction is searched in the order of priority (descending order) of left, front, right, and back, and the pixel coordinate step size of each search is 1. If the searched pixel is in the connected domain, add the coordinate value of the pixel to the queue, and update the search direction at the same time; check whether it is the same as the starting point coordinate every time a new coordinate is added, if the starting point coordinate appears again in the queue, then The search is terminated and the queue length does not change any more.

在本实施例中,如图4(a)、图5所示,以A1为例,首先标记A1的外边界,各像素在队列中第一次出现的位置标记在像素内部,队列长度为42。In this embodiment, as shown in Fig. 4(a) and Fig. 5, taking A1 as an example, the outer boundary of A1 is first marked, and the first position of each pixel in the queue is marked inside the pixel, and the queue length for 42.

S403、基于初始外边界队列,根据队列索引,查找队列索引对应的像素坐标;若不同的队列索引对应的像素坐标相同,则在初始外边界队列中删除索引值在删除两个队列索引之间的像素坐标;具体的,从队列的第x个坐标开始搜索x到n0区间段内的坐标值,n为现在队列总长度;若在索引值为x+Δx的位置搜索到索引值为x的坐标,则从队列中删除索引值为x+1到x+Δx的部分,重新构成新队列,记录其长度为n1;原队列第x+1个坐标到第x+Δx-1个坐标计入集合Bn。从n1中当前搜索坐标值的下一个坐标值继续搜索,直到该坐标值在整个队列中搜索完毕。第k次删除得到的新队列为nk,nk≤n;x的初始值为 2,每次搜索到队列末尾后搜索坐标的索引值在当前队列的基础上加1,重复上述搜索过程,直到队列中末尾的坐标值作为搜索对象并完成搜索。设当前处理的连通域为An,全部搜索完成后Bn包含了所有要删减的像素。S403. Based on the initial outer boundary queue, according to the queue index, search for the pixel coordinates corresponding to the queue index; if the pixel coordinates corresponding to different queue indexes are the same, delete the index value in the initial outer boundary queue and delete the pixel coordinates between the two queue indexes Pixel coordinates; specifically, starting from the xth coordinate of the queue to search for coordinate values in the interval from x to n0, n is the total length of the current queue; if a coordinate with an index value of x is found at a position with an index value of x+Δx , then delete the part whose index value is from x+1 to x+Δx from the queue, reconstitute a new queue, and record its length as n1; the x+1th to x+Δx-1 coordinates of the original queue are included in the set B n . Continue searching from the next coordinate value of the current search coordinate value in n1 until the coordinate value has been searched in the entire queue. The new queue obtained by the kth deletion is nk, nk≤n; the initial value of x is 2, and the index value of the search coordinates is added to the current queue after each search to the end of the queue, and the above search process is repeated until the queue The coordinate value at the end of , is used as the search object and the search is completed. Assume that the currently processed connected domain is A n , and B n includes all pixels to be deleted after all searches are completed.

在本实施例中,如图4(b)、图6所示,从队列索引2开始向后搜索第2个像素的坐标,发现该坐标没有出现在队列中;然后从索引3向后搜索第3个像素的坐标,也没有找到。依次类推,从索引9开始向后搜索,发现索引值15对应的坐标和索引9对应的坐标相同,则删去当前队列索引值第10、11、12、13、14、15 的部分,把索引值为10、11、12、13、14对应的坐标(对应三个像素)添加到集合B1中,然后从被删除区间的末尾接着搜索调整后的新队列,直到整个队列处理完毕。根据图4,初始队列的长度共调整了5次,即最后一次调整完队列长度为n5=28,最终结果如图4(b)所示,外边界总共28个像素。图中B1包含7个不同的坐标,它们在第一个队列中首次出现的位置分别是10,11,12,25,30, 33,37。In this embodiment, as shown in Fig. 4(b) and Fig. 6, the coordinates of the second pixel are searched backward from the queue index 2, and it is found that the coordinates do not appear in the queue; then search backward from the index 3 The coordinates of 3 pixels were not found either. By analogy, search backward from index 9, and find that the coordinates corresponding to index 15 are the same as the coordinates corresponding to index 9, then delete the 10th, 11th, 12th, 13th, 14th, 15th part of the current queue index value, and put the index The coordinates corresponding to values 10, 11, 12, 13, and 14 (corresponding to three pixels) are added to the set B 1 , and then the adjusted new queue is searched from the end of the deleted interval until the entire queue is processed. According to Figure 4, the length of the initial queue has been adjusted 5 times in total, that is, the length of the queue after the last adjustment is n5=28, and the final result is shown in Figure 4(b), with a total of 28 pixels on the outer boundary. B 1 in the figure contains 7 different coordinates, and their first appearance positions in the first queue are 10, 11, 12, 25, 30, 33, and 37 respectively.

S404、检测以上连通域中是否存在内边界;具体的,记某连通域最小的x坐标为xmin,最大的x坐标为xmax,最小的y坐标为ymin,最大的y坐标为ymax。从y=ymin开始搜索,假设该连通域内符合从y=ymin的点x坐标集合为R1,对R1内各元素进行升序排列,根据该列x坐标边界找出R1整数不连续的部分并形成包含这些x坐标值的若干集合H1、H2、H3……,并称之为y=1状态下的集合,每个集合内元素之间最小差为1。搜索坐标加1(即执行y=ymin+1),重复以上过程,直至搜素完y=ymax,搜索完毕。初始化i=1,基于集合中各元素x坐标大小对将y=i和y=i+1 状态下H开头命名的集合两两求交集,如两集合中存在相同的x元素则两集合合并,合并后集合以数字小的命名,即记Hc=Ha∪Hb,c=min{a,b};如两集合中元素的x坐标不存在相同数值则y=i状态下集合添加至y=i+1状态下。搜索y=ymin+2, y=ymin+3……直到y=ymax搜索完成,伴随y值增加1完成一级集合的合并(可能合并不止一次),最后得到疑似孔洞的连通域,一个连通域对应一个集合。S404. Detect whether there is an inner boundary in the above connected domain; specifically, remember that the smallest x-coordinate of a certain connected domain is x min , the largest x-coordinate is x max , the smallest y-coordinate is y min , and the largest y-coordinate is y max . Start searching from y=y min , assuming that the set of x-coordinates of points from y=y min in the connected domain is R 1 , arrange the elements in R 1 in ascending order, and find out the integer discontinuity of R 1 according to the boundary of the x-coordinates of this column and form several sets H1, H2, H3... containing these x-coordinate values, which are called sets in the state of y=1, and the minimum difference between elements in each set is 1. Add 1 to the search coordinate (that is, execute y=y min +1), repeat the above process until the search is completed y=y max , and the search is completed. Initialize i=1, and based on the x coordinates of each element in the set, find the intersection of the sets named at the beginning of H in the state of y=i and y=i+1. If the same x element exists in the two sets, the two sets will be merged. After merging, the set is named with the smaller number, that is, Hc=Ha∪Hb, c=min{a,b}; if the x coordinates of the elements in the two sets do not have the same value, the set is added to y=i in the state of y=i +1 status. Search for y=y min +2, y=y min +3...until y=y max search is completed, and the merging of the first-level set is completed with the value of y increasing by 1 (maybe merging more than once), and finally the connected domain of the suspected hole is obtained. A connected domain corresponds to a set.

若检测到疑似孔洞的连通域,则执行步骤S405,若无,则执行步骤S5。If a connected domain suspected to be a hole is detected, then step S405 is performed, and if there is no connected domain, then step S5 is performed.

在本实施例中,连通域如图4(b)所示,x坐标不存在整数不连续部分,未检测到疑似空洞的连通域,则执行步骤S5。In this embodiment, the connected domain is shown in FIG. 4( b ), there is no integer discontinuity in the x-coordinate, and no connected domain suspected to be a hole is detected, then step S5 is executed.

示例性的,在一些实施例中,连通域如图7(a)所示,一个目标连通域(浅灰色),上边的一行数字表示y坐标,左边的一列数字表示x坐标。扫描时根据目标连通域y的分布确定范围,显然,2≤y≤11,需要扫描10次。首先扫描y=2 的一列,把目标连通域在该列中涉及到的x坐标记录下来,然后y=y+1,以此类推得到图7(b)表格的第二行;根据该列x坐标边界找出Ri整数不连续的部分并形成若干集合,每个集合内元素之间最小差为1,例如y=2求{4,5,6,7,8,9,10,11,12} 与{4,6,7,8,9,12}差集得到{5}、{10,11},以此类推,每一列搜索完成得到图7(b) 表格的第三行;然后根据这些断开部分的分布构建集合H1、H2……H12,扫描完y=i时生成的集合如图7(b)表格第四行所示,大括号内的数字表示生成该集合的顺序(即H集合的标号);图7(a)中标有白色数字i的像素即集合Hi内的元素。根据集合内像素对应x坐标是否存在交集,将y=i状态下的集合和y=i+1时生成的集合两两开展有条件的合并,得到y=i+1状态下的集合:如y=i状态下的某集合与y=i+1生成的某集合中各元素的x坐标无共同值,则该集合在y=i+1状态下继续存在。以此类推,伴随着y=2增大至y=12,完成集合的9级合并,每一级合后H集合的数目在上一级基础上保持不变或增大,y=12状态下存在的H集合数目最多,最终得到图5(b)表格第五行。第五行每个大括号表示一个空洞或疑似空洞连通域,大括号内数值是连通域包含的H集合标号(图7(a)中白色数字,该标号是集合合并开始及开始重命名前的状况);对图7(b)第五行的大括号数目进行统计,得到该目标连通域对应的空洞或疑似空洞连通域的总数目,如图7(b)表格最后一行所示。表格最后一行中H集合的标号已经不连续了,这是因为随着扫描值的增大发生了集合的合并与重命名,同时,尽管该行多个位置出现了同样的集合名称,右边集合中元素数目等于或多于左边的集合中的元素。然后,执行步骤S405。Exemplarily, in some embodiments, the connected domain is as shown in FIG. 7( a ), a target connected domain (light gray), the upper row of numbers indicates the y coordinate, and the left column of numbers indicates the x coordinate. When scanning, the range is determined according to the distribution of the target connected domain y. Obviously, 2≤y≤11 requires 10 scans. First scan a column of y=2, record the x coordinates involved in the column of the target connected domain, then y=y+1, and so on to get the second row of the table in Figure 7(b); according to the column x Find out the discontinuous part of the Ri integer and form several sets, the minimum difference between the elements in each set is 1, for example, y=2 Find {4,5,6,7,8,9,10,11,12 } and {4,6,7,8,9,12} to get {5}, {10,11}, and so on, each column is searched to get the third row of the table in Figure 7(b); then according to The distribution of these disconnected parts builds sets H1, H2...H12, and the sets generated when y=i is scanned are shown in the fourth row of the table in Figure 7(b). The numbers in curly brackets indicate the order in which the sets are generated (ie The label of the H set); the pixel marked with the white number i in Figure 7(a) is the element in the set Hi. According to whether there is an intersection of the x coordinates corresponding to the pixels in the set, the set in the state of y=i and the set generated when y=i+1 are conditionally merged in pairs to obtain the set in the state of y=i+1: such as y If the x-coordinates of each element in a set in the =i state and a certain set generated by y=i+1 have no common value, then the set continues to exist in the state of y=i+1. By analogy, with the increase of y=2 to y=12, the 9-level combination of sets is completed, and the number of H sets after each level remains unchanged or increases on the basis of the previous level, under the state of y=12 The number of H sets that exist is the largest, and finally the fifth row of the table in Figure 5(b) is obtained. Each curly bracket in the fifth line represents a hole or suspected hole connected domain, and the value in the curly brackets is the label of the H set contained in the connected domain (the white number in Figure 7(a), the label is the state before the start of set merging and renaming ); count the number of curly brackets in the fifth row of Figure 7(b), and obtain the total number of holes or suspected hole connected domains corresponding to the target connected domain, as shown in the last row of the table in Figure 7(b). The label of the H set in the last row of the table is no longer continuous. This is because the merge and renaming of the sets occurred with the increase of the scan value. At the same time, although the same set name appears in multiple positions in the line, the right set The number of elements is equal to or greater than the elements in the collection on the left. Then, step S405 is executed.

S405、检查疑似孔洞连通域,得到真正具有内边界的连通域;具体的,将待分析的疑似连通域与对应的目标连通域取并集,分别验证该疑似连通域向上,向下,向左,向右各平移一个像素后的区域是否完全包含于该并集之内。如果是,则表明该疑似空洞联通域是正在分析的目标连通域Ai内部的一个洞,对应物体本身具有的结构;如果不是,则说明该连通域是外边界的一个槽或凹型结构。S405. Check the suspected connected domain of the hole to obtain the connected domain that actually has an inner boundary; specifically, take the union of the suspected connected domain to be analyzed and the corresponding target connected domain, and respectively verify that the suspected connected domain is upward, downward, and leftward , whether the area after shifting one pixel to the right is completely included in the union. If yes, it indicates that the suspected void connected domain is a hole inside the target connected domain A i being analyzed, which corresponds to the structure of the object itself; if not, it indicates that the connected domain is a groove or concave structure on the outer boundary.

如图7(c)所示,图7(c)中待分析的目标连通域记为Ai,对应的疑似空洞连通域为Hj,Hj向上下左右平移后得到Hj-1、Hj-2、Hj-3、Hj-4。求Ai与Hi并集,然后用Hj-1、Hj-2、Hj-3、Hj-4分别与Ai与Hi的并集求差集,如全部结果均为空集,表明四次平移后的疑似空洞连通域包含于原疑似空洞连通域和待分析目标连通域的并集中,即Hi为Ai内部的空洞;否则是边缘的一个凹形结构。As shown in Figure 7(c), the target connected domain to be analyzed in Figure 7(c) is denoted as A i , and the corresponding suspected hole connected domain is H j , H j is translated up, down, left, and right to obtain H j-1 , H j-2 , H j-3 , H j-4 . Find the union of A i and H i , and then use H j-1 , H j-2 , H j-3 , H j-4 to find the difference with the union of A i and H i respectively, if all the results are empty Set, indicating that the suspected hole connected domain after four translations is included in the union of the original suspected hole connected domain and the target connected domain to be analyzed, that is, H i is the hole inside A i ; otherwise, it is a concave structure on the edge.

示例性的,在图7(a)中标号4、6、7、8的所有像素组成了一个疑似空洞连通域,它们向左、向右、向上、向下平移后像素覆盖区域是它自身及标记白色圆形像素对应的区域,显然它们都完全包含于灰色连通域与它自身的并集中,因此它属于目标连通域中的一个空洞;图7(a)中标号2、3的所有像素组成了一个疑似空洞连通域,它们向左、向右、向上、向下平移后像素覆盖区域是它自身及标记白色三角形像素对应的区域。显然,当它向左平移时,有两个标记三角形的像素(坐标为(10,1)、(11,1))移出了它自身和灰色连通域的并集,因此它不是灰色连通域内的一个真正的空洞,而是出现在边界的一个凹形结构。Exemplarily, in Fig. 7 (a), all the pixels labeled 4, 6, 7, and 8 form a suspected hole-connected domain, and after they are translated to the left, right, up, and down, the pixel coverage area is itself and Mark the area corresponding to the white circular pixels, obviously they are completely contained in the union of the gray connected domain and itself, so it belongs to a hole in the target connected domain; all the pixels labeled 2 and 3 in Figure 7(a) consist A suspected hole-connected domain is established. After they are translated to the left, right, up, and down, the pixel coverage area is the area corresponding to itself and the marked white triangle pixel. Obviously, when it translates to the left, two pixels marking the triangle (coordinates (10, 1), (11, 1)) move out of the union of itself and the gray connected domain, so it is not in the gray connected domain A real void, but a concave structure that appears at the border.

检测完毕后,执行步骤S406。After the detection is completed, step S406 is executed.

S406、对检测到的空洞连通域进行毛刺修剪,修剪的原理与步骤S403相同,在此不再赘述;修剪完毕后,生成集合Cn;执行步骤S6。S406. Perform burr pruning on the detected hole connected domains. The principle of pruning is the same as step S403, and will not be repeated here; after pruning is completed, a set C n is generated; and step S6 is executed.

S5、第n个目标的最终边界为Dn=An-Bn,将D1,D2、D3…Dn内各坐标对应的像素灰度恢复为P1中的状况,其它像素调整为255,得到去除纸壳包装影响的修正图像P4。S5. The final boundary of the nth target is D n =A n -B n , restore the gray scale of the pixel corresponding to each coordinate in D 1 , D 2 , D 3 ... D n to the state in P1, and adjust the other pixels to 255. Obtain the corrected image P4 that removes the influence of the carton package.

S6、第n个目标的最终边界为Dn=An-Bn+Cn,将D1,D2、D3…Dn内各坐标对应的像素灰度恢复为P1中的状况,其它像素调整为255,得到去除纸壳包装影响的修正图像P4。S6. The final boundary of the nth object is D n =A n -B n +C n , restore the pixel grayscale corresponding to each coordinate in D 1 , D 2 , D 3 ... D n to the status in P1, and other The pixel is adjusted to 255 to obtain the corrected image P4 that removes the influence of the carton packaging.

实施例二Embodiment two

本实施例公开了一种面向太赫兹安检图像的前处理系统,包括:This embodiment discloses a pre-processing system for terahertz security images, including:

图像获取模块,被配置为:获取不包含样本的太赫兹安检图像和包含样本的太赫兹安检图像;The image acquisition module is configured to: acquire a terahertz security check image not containing a sample and a terahertz security check image containing a sample;

背景图片分析模块,被配置为:对不包含样本的太赫兹安检图像进行直方图分析,获取对应像素数目最多的灰度值;The background image analysis module is configured to: perform histogram analysis on the terahertz security inspection image that does not contain samples, and obtain the gray value corresponding to the largest number of pixels;

降噪模块,被配置为:对包含样本的太赫兹安检图像进行腐蚀操作,以对应像素数目最多的灰度值为阈值,对处理后的图像进行二值化灰度变换;The noise reduction module is configured to: perform a corrosion operation on the terahertz security inspection image containing the sample, use the gray value corresponding to the largest number of pixels as the threshold value, and perform binary gray-scale transformation on the processed image;

毛刺修剪模块,被配置为:对二值灰度处理后的图像进行连通域分析,获取样本的边界,对边界进行毛刺修剪;The burr pruning module is configured to: perform connected domain analysis on the binary grayscale processed image, obtain the boundary of the sample, and perform burr pruning on the boundary;

修正图像获取模块,被配置为:根据毛刺修剪后的图像,获取修正图像。The corrected image acquisition module is configured to: acquire the corrected image according to the image trimmed by the burr.

此处需要说明的是,上述图像获取模块、背景图片分析模块、降噪模块、毛刺修剪模块和修正图像获取模块对应于实施例一中的步骤,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例一所公开的内容。需要说明的是,上述模块作为系统的一部分可以在诸如一组计算机可执行指令的计算机系统中执行。It should be noted here that the above-mentioned image acquisition module, background image analysis module, noise reduction module, burr trimming module and corrected image acquisition module correspond to the steps in Embodiment 1, and the examples and applications realized by the above-mentioned modules and corresponding steps The scenarios are the same, but are not limited to the content disclosed in Embodiment 1 above. It should be noted that, as a part of the system, the above-mentioned modules can be executed in a computer system such as a set of computer-executable instructions.

实施例三Embodiment three

本发明实施例三提供一种电子设备,包括存储器和处理器以及存储在存储器上并在处理器上运行的计算机指令,计算机指令被处理器运行时,完成上述面向太赫兹安检图像的前处理方法的步骤。Embodiment 3 of the present invention provides an electronic device, including a memory, a processor, and computer instructions stored in the memory and run on the processor. When the computer instructions are run by the processor, the above-mentioned preprocessing method for terahertz security images is completed. A step of.

实施例四Embodiment Four

本发明实施例四提供一种计算机可读存储介质,用于存储计算机指令,所述计算机指令被处理器执行时,完成上述面向太赫兹安检图像的前处理方法的步骤。Embodiment 4 of the present invention provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps of the above-mentioned preprocessing method for terahertz security images are completed.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和 /或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/ 或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and a combination of processes and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, and a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device Steps are provided for implementing the functions specified in the flow chart or flow charts and/or block diagram block or blocks.

上述实施例中对各个实施例的描述各有侧重,某个实施例中没有详述的部分可以参见其他实施例的相关描述。The description of each embodiment in the foregoing embodiments has its own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are only preferred embodiments of the present application, and are not intended to limit the present application. For those skilled in the art, various modifications and changes may be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application shall be included within the protection scope of this application.

Claims (10)

1. A pretreatment method for a terahertz security inspection image is characterized by comprising the following steps:
acquiring a terahertz security check image not containing a sample and a terahertz security check image containing the sample; wherein the sample is a carton or envelope that may contain hazardous materials;
performing histogram analysis on the terahertz security inspection image without the sample to acquire the gray value with the maximum number of corresponding pixels;
carrying out corrosion operation on the terahertz security inspection image containing the sample, and carrying out binarization gray scale transformation on the processed image by taking the gray scale value with the maximum number of corresponding pixels as a threshold value;
performing connected domain analysis on the image subjected to the binary gray processing to obtain a boundary of a sample, and performing burr trimming on the boundary;
and acquiring a corrected image according to the image after the burr trimming.
2. The preprocessing method for the terahertz security inspection image as claimed in claim 1, wherein the performing connected domain analysis on the binary gray processed image to obtain the boundary of the sample, and performing burr trimming on the boundary comprises:
performing connected domain analysis on the image subjected to the binary gray processing to obtain the outer boundary of the sample, and performing burr trimming on the outer boundary;
detecting whether an inner boundary exists in a connected domain;
and if the inner boundary exists in the connected domain, performing burr trimming on the inner boundary.
3. The pretreatment method for the terahertz security inspection image as claimed in claim 2, wherein the step of performing connected domain analysis on the binary gray-scale processed image to obtain the outer boundary of the sample comprises the following specific steps:
and acquiring a connected domain with the gray value of 255 based on the image after the binary gray processing, eliminating abnormal regions and acquiring the outer boundary of the sample.
4. The pretreatment method for the terahertz security inspection image as claimed in claim 2, wherein the specific steps of performing burr trimming on the outer boundary are as follows:
marking an initial outer boundary queue of a connected domain;
based on the initial outer boundary queue, searching a pixel coordinate corresponding to the queue index according to the queue index; if the pixel coordinates corresponding to different queue indexes are the same, deleting the pixel coordinates of the index value between the two deleted queue indexes in the initial outer boundary queue;
and traversing and searching the adjusted outer boundary queue until the whole queue is processed.
5. The pretreatment method for the terahertz security inspection image as claimed in claim 4, wherein the specific steps of marking the initial outer boundary queue of the connected domain are as follows:
finding out the pixel with the minimum x coordinate or y coordinate in the connected domain, and taking the pixel coordinate as the head of the initial outer boundary queue;
taking the right as an initial searching direction, and carrying out searching in the order of left, front, right and back relative to the searching direction; if the pixel of the searched pixel is in the connected domain, adding the pixel coordinate into the initial outer boundary queue, and updating the searching direction;
if the added pixel coordinate is the same as the start point coordinate, the search terminates.
6. The pretreatment method for the terahertz security inspection image as claimed in claim 1, wherein the specific steps of performing binarization grayscale transformation on the processed image by using the grayscale value with the maximum number of corresponding pixels as a threshold value are as follows:
the gray scale values of all pixels with the gray scale values larger than or equal to the threshold are adjusted to be 0, and the gray scale values of the pixels with the gray scale values lower than the threshold are adjusted to be 255.
7. The preprocessing method for the terahertz security inspection image as claimed in claim 1, wherein the specific steps of obtaining the corrected image according to the image after the burr trimming are as follows:
restoring the pixel gray value corresponding to each coordinate in the connectivity domain after the burrs are trimmed to be the pixel gray value corresponding to the terahertz security inspection image containing the sample;
the other pixels in the image after the burr trimming are adjusted to 255, and a corrected image is obtained.
8. A pretreatment system for a terahertz security inspection image is characterized by comprising:
an image acquisition module configured to: acquiring a terahertz security check image not containing a sample and a terahertz security check image containing the sample; wherein the sample is a carton or envelope that may contain hazardous materials;
a background picture analysis module configured to: performing histogram analysis on the terahertz security inspection image without the sample to acquire a gray value with the maximum number of corresponding pixels;
a noise reduction module configured to: carrying out corrosion operation on the terahertz security inspection image containing the sample, and carrying out binarization gray scale transformation on the processed image by taking the gray scale value with the maximum number of corresponding pixels as a threshold value;
a spike trimming module configured to: performing connected domain analysis on the image subjected to the binary gray processing to obtain the boundary of the sample, and performing burr trimming on the boundary;
a modified image acquisition module configured to: and acquiring a corrected image according to the image after the burr trimming.
9. An electronic device comprising a memory and a processor and computer instructions stored on the memory and executed on the processor, the computer instructions when executed by the processor performing the steps of any of claims 1-7.
10. A computer-readable storage medium storing computer instructions which, when executed by a processor, perform the steps of any one of claims 1 to 7.
CN202211208439.4A 2022-09-30 2022-09-30 A preprocessing method for terahertz security images Pending CN115601697A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211208439.4A CN115601697A (en) 2022-09-30 2022-09-30 A preprocessing method for terahertz security images

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211208439.4A CN115601697A (en) 2022-09-30 2022-09-30 A preprocessing method for terahertz security images

Publications (1)

Publication Number Publication Date
CN115601697A true CN115601697A (en) 2023-01-13

Family

ID=84845715

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211208439.4A Pending CN115601697A (en) 2022-09-30 2022-09-30 A preprocessing method for terahertz security images

Country Status (1)

Country Link
CN (1) CN115601697A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117132842A (en) * 2023-10-26 2023-11-28 江苏鹰创科技有限公司 Intelligent detection method of prohibited items based on terahertz characteristics

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117132842A (en) * 2023-10-26 2023-11-28 江苏鹰创科技有限公司 Intelligent detection method of prohibited items based on terahertz characteristics
CN117132842B (en) * 2023-10-26 2024-01-23 江苏鹰创科技有限公司 Intelligent detection method of prohibited items based on terahertz characteristics

Similar Documents

Publication Publication Date Title
JP7073247B2 (en) Methods for generating lane boundary detection models, methods for detecting lane boundaries, devices for generating lane boundary detection models, devices for detecting lane boundaries, equipment, computers readable Storage media and computer programs
CN105261017B (en) The method that image segmentation based on road surface constraint extracts pedestrian's area-of-interest
CN108304765A (en) Multitask detection device for face key point location and semantic segmentation
CN110008900B (en) Method for extracting candidate target from visible light remote sensing image from region to target
CN103424409A (en) Vision detecting system based on DSP
CN109325401A (en) The method and system for being labeled, identifying to title field are positioned based on edge
CN112308872B (en) Image Edge Detection Method Based on Multiscale Gabor First Derivative
CN111461133A (en) Express delivery surface single item name identification method, device, equipment and storage medium
CN114417993A (en) Scratch detection method based on deep convolutional neural network and image segmentation
CN115601697A (en) A preprocessing method for terahertz security images
CN112686265A (en) Hierarchic contour extraction-based pictograph segmentation method
CN118135179B (en) Cascade identification method and device for cutting plate, computer equipment and storage medium
Li et al. Wafer crack detection based on yolov4 target detection method
Gao et al. Extracting closed object contour in the image: remove, connect and fit
CN114926635B (en) Target segmentation method in multi-focus image combined with deep learning method
De Vitis et al. A pre‐processing technique to decrease inspection time in glass tube production lines
Li et al. Graph network refining for pavement crack detection based on multiscale curvilinear structure filter
CN111768436B (en) An Improved Image Feature Block Registration Method Based on Faster-RCNN
CN110807348A (en) Removal of Interference Lines in Document Image Based on Greedy Algorithm
Buck et al. Ship detection and classification from overhead imagery
TWI416432B (en) Method of using singular value decompostion for enhancing and segmenting fingerprint images and a system thereof
Deng et al. The Computer Vision-based Tolerancing Callout Detection Model
Wang et al. Surface crack detection of rubber insulator based on machine vision
Zhang et al. Part Deviation Correction Method Based on Geometric Feature Recognition
Yao et al. A DCNN-based Arbitrarily-Oriented Object Detector for a Quality-Control Application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination