CN115601697A - Pretreatment method for terahertz security inspection image - Google Patents
Pretreatment method for terahertz security inspection image Download PDFInfo
- 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
- security inspection
- terahertz security
- queue
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V20/00—Scenes; Scene-specific elements
- G06V20/50—Context or environment of the image
- G06V20/52—Surveillance or monitoring of activities, e.g. for recognising suspicious objects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/28—Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/30—Noise filtering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local 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/457—Local 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
Technical Field
The application relates to the technical field of terahertz waveband number image analysis, in particular to a pretreatment method for terahertz security check images.
Background
The statements in this section merely provide background information related to the present disclosure and may not constitute prior art.
The paper shell packaging material has high permeability to terahertz, metal has strong reflection characteristic to terahertz waves, polar liquid such as water has strong absorption characteristic to terahertz waves, irregular interfaces and curved surfaces have strong scattering effect on terahertz waves, so that the terahertz continuous wave imaging system has strong detection capability to metal and polar liquid in a bottle coated by the paper shell, is sensitive to the boundaries of various objects, and is preliminarily applied to inspection of dangerous goods such as packages and envelopes.
The development direction of terahertz security inspection is intelligentized, and based on terahertz image features and advanced artificial intelligence algorithms, the positioning of internal dangerous goods needs to be realized, and the identification of dangerous goods types needs to be completed. However, at the present stage, the image recognition algorithm under the visible light band has a poor effect in the terahertz band due to the longer terahertz wavelength and the larger diffraction resolution limit.
In addition, the terahertz source is low in power, the number of pixels of the imaging device is small, the spatial scale of the pixels is large, and the terahertz continuous wave image identification difficulty is high.
And terahertz security check image that obtains in the security check based on terahertz continuous wave formation of image like carton, envelope has its unique characteristics: the potential targets are positioned inside the paper boxes and the envelopes, and although the packaging material per se absorbs the terahertz waves weakly, the edges of the paper boxes and the envelopes have strong scattering effect on the terahertz waves, so that the images of the edges of the paper boxes and the potential targets inside the paper boxes are easy to adhere, and the potential targets are extremely unfavorable for researchers to identify suspicious dangerous articles in the paper boxes and the envelopes visually or later through an image identification algorithm; when training the image classifier, a tester is required to keep a certain distance between the target and the edges of the carton and the envelope all the time in the image training process.
Disclosure of Invention
The inventor finds that an ideal mode of terahertz security image identification is as follows: the method comprises the steps of detecting the complete boundary of a paper box and an envelope, positioning the paper box and the envelope, processing the paper box and the envelope through an algorithm, and identifying images of articles in the paper box and the envelope through visual inspection or an image recognition algorithm. However, at present, few researchers propose a targeted terahertz security inspection image processing method based on the thought, and accuracy improvement of dangerous goods image identification is limited.
In order to solve the defects of the prior art, the application provides a pretreatment method, a pretreatment system, electronic equipment and a computer-readable storage medium for terahertz security inspection images, which are used for eliminating the interference of packages such as paper boxes and envelopes and are convenient for researchers to visually identify suspicious dangerous articles in the paper boxes and the envelopes or through an image recognition algorithm.
In a first aspect, the application provides a pretreatment method for a terahertz security inspection image;
a pretreatment method for a terahertz security inspection image comprises 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 grayscale transformation on the processed image by taking the grayscale 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.
In a second aspect, the application provides a pretreatment system for terahertz security inspection images;
a pretreatment system for a terahertz security inspection image comprises:
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 grayscale transformation on the processed image by taking the grayscale 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 a boundary of a 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.
In a third aspect, the present application provides an electronic device;
an electronic device comprises a memory, a processor and computer instructions stored on the memory and run on the processor, wherein when the computer instructions are run by the processor, the steps of the terahertz security inspection image-oriented preprocessing method 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 terahertz security inspection image-oriented preprocessing method are completed.
Compared with the prior art, the beneficial effects of this application are:
1. according to the method, the terahertz security inspection image containing the sample is processed based on the characteristics of the terahertz security inspection image containing the sample and the terahertz security inspection image not containing the sample, so that the interference of package boundaries such as cartons or envelopes is eliminated, researchers can conveniently identify suspicious dangerous goods in packages visually or through an image identification algorithm, and the accuracy of dangerous goods image identification is improved;
2. the boundary of the connected domain is marked in the process of trimming the burr, so that the method is convenient to combine with other edge enhancement algorithms; no additional gradient is required: for a binary image, the gradient to the left of the search direction is always equal to-255; when the search fails in the original search direction, the gradient of the pixel towards the traveling direction is-255. In addition, the gray value gradient in any direction in other places of the image is 0, and the calculation amount of gradient calculation is remarkably simplified.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application.
Fig. 1 is a schematic flow chart of a preprocessing method for a terahertz security inspection image provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of an etching operation performed on a terahertz security inspection image containing a sample according to an embodiment of the present application; wherein, (a) is the picture before corroding, (b) is the structural element, (c) is the picture after corroding;
fig. 3 is a schematic diagram of a connected domain of a terahertz image including a sample provided by an embodiment of the present application;
FIG. 4 is a schematic diagram comparing before and after trimming of burrs according to an embodiment of the present disclosure; 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 trimming;
fig. 5 is a schematic flowchart of generating a connected domain initial outer boundary queue according to an embodiment of the present disclosure;
fig. 6 is a schematic flowchart of adjusting a connected domain outer boundary queue according to an embodiment of the present application;
FIG. 7 is a schematic diagram of intra-domain boundary labeling provided in an 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 diagram of a process for judging whether the connected domain is a real hole connected domain.
Detailed Description
It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the disclosure. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments according to the present application. As used herein, the singular is intended to include the plural unless the context clearly dictates otherwise, and furthermore, it should be understood that the terms "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The embodiments and features of the embodiments of the present invention may be combined with each other without conflict.
Example one
In the prior art, a terahertz image obtained during security inspection based on terahertz continuous wave imaging has unique characteristics, and images of potential targets at the edges and inside of envelopes or cartons are easy to adhere, so that the method is extremely unfavorable for researchers to identify dangerous goods through visual observation or image identification algorithms; therefore, the application provides a pretreatment method for terahertz security inspection images, which eliminates the interference of packages such as paper boxes and envelopes, facilitates the identification of dangerous goods by researchers, and improves the accuracy of identification.
A pretreatment method for a terahertz security inspection image comprises 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 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 the boundary of the sample, and performing burr trimming on the boundary;
and acquiring a corrected image according to the image after the burr trimming.
Further, performing connected domain analysis on the image after the binary gray processing to obtain a boundary of the sample, and performing burr trimming on the boundary includes:
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.
Preferably, the step of performing connected domain analysis on the binary gray 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.
Preferably, the outer boundary is burred by the following specific steps:
marking an initial outer boundary queue of a connected domain;
based on the initial outer boundary queue, searching pixel coordinates 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 coordinate 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.
Preferably, 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 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. Further, the specific steps of performing binarization grayscale transformation on the processed image by taking 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.
Further, 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.
Next, a preprocessing method for a terahertz security inspection image disclosed in this embodiment is described in detail with reference to fig. 1 to 7.
The embodiment provides a pretreatment method for a terahertz security inspection image, which comprises the following steps:
s1, obtaining a terahertz security check image not containing a sample and a terahertz security check image containing the sample; the terahertz wave band gray level image is acquired by a continuous wave terahertz security inspection system; the parameters of the external equipment are unchanged during image acquisition: the method comprises the steps that a terahertz security check image without a sample (namely a blank background picture without the sample is recorded as a gray value matrix P0) is acquired and obtained for the first time, and a terahertz security check picture with the sample (recorded as a gray value matrix P1) is acquired and obtained for the second time; the sample may be a carton or envelope containing one or more hazardous materials, i.e., materials that are judged from a shape perspective to be dangerous or suspected for chemical analysis.
In this embodiment, the sample is a carton containing a hazardous material.
S2, performing histogram analysis on the P0, acquiring a gray value with the maximum number of corresponding pixels, and recording the gray value as g, wherein the gray value is the mode of background gray values.
S3, performing morphological corrosion operation on the P1, wherein the structural operator is as follows:
as shown in fig. 2, in order to increase readability, the gray scale value is 255, the pixels are divided by white thin lines, fig. 2 (a) shows the image before etching, fig. 2 (b) shows the structural elements, and fig. 2 (c) shows the image after etching.
In this embodiment, it is assumed that the center of the structural element coincides with a light gray color patch in fig. 2 (a), and if all color patches of the structural element are covered by the light gray area in fig. 2 (a), the coinciding color patches are retained; and traversing the pixels in the original image by taking the structural elements as templates, and processing to obtain the image shown in fig. 2 (c).
The image after the etching operation is referred to as P2, g is used as a threshold value, the processed image is subjected to binarization gray scale conversion, all the pixel gray scale values larger than or equal to g are adjusted to 0 ("logical 0"), and the pixel gray scale values lower than g are adjusted to 255 ("logical 1"), so that an image P3 is obtained.
S4, performing connected domain analysis on the image subjected to the binary gray processing to obtain a sample boundary, and performing burr trimming on the boundary;
after the image is processed by a morphological method and binarized, the edge of the image may have a ragged phenomenon, which is mainly caused by the insufficient ideal morphological template and the complex scattering condition of terahertz waves at the edge of an article. The purpose of the trimming is to eliminate the "glitches" left by the edges, which are defined herein as having the common characteristic of a minimum width equal to 1 pixel.
The method comprises the following specific steps:
s401, acquiring a connected domain with a gray value of 255 based on the image subjected to the binary gray processing, eliminating abnormal regions and acquiring the outer boundary of a sample; specifically, the connected component analysis is carried out on the P3, a connected component with the logic of 1 is found, a region with the size of less than or equal to 4 and a region with the size of less than or equal to 2 pixels in the x direction or the y direction are removed from the result, the remaining connected components with the gray value of 255 are marked as effective targets, and the sets of the corresponding pixels are sequentially numbered as A 1 、A 2 、A 3 And 8230an, defining the areas with other gray values of 0 as a background, and marking the set of all pixel coordinates as B.
In this embodiment, as shown in FIG. 3, a connected component is a set of light gray pixel coordinates and the minimum distance of any element in the set from other elements is equal to 1 pixel. The connected domains of the upper left, the upper right, the lower left and the lower right are respectively marked with A 1 、A 2 、A 3 、A 4 Due to A 3 Is eliminated with a size equal to 4, A 4 Equal to 1 is rejected.
S402, marking an initial outer boundary queue of a connected domain; specifically, a pixel with the minimum x coordinate of a connected domain is found (if the pixel with the minimum x coordinate is more than one, the pixel with the minimum y coordinate in the points is found), the coordinate of the pixel (namely the starting point coordinate) is recorded and added to the head of the initial outer boundary queue; taking the right as an initial searching direction, carrying out searching in a left, front, right and rear priority (descending order) sequence relative to the searching direction, wherein the step length of the pixel coordinate searching each time is 1, if the searched pixel is in the connected domain, adding the coordinate value of the pixel into a queue, and updating the searching direction; and checking whether the coordinates are the same as the coordinates of the starting point every time a new coordinate is added, if the coordinates of the starting point appear in the queue again, the searching is ended, and the length of the queue does not change any more.
In this embodiment, as shown in fig. 4 (a) and 5, a 1 For example, first mark A 1 The position at which each pixel first appears in the queue is marked inside the pixel, and the queue length is 42.
S403, based on the initial outer boundary queue, searching pixel coordinates 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; specifically, coordinate values in a range from x to n0 are searched from the x-th coordinate of the queue, wherein n is the total length of the queue at present; if the coordinate with the index value x is searched at the position with the index value x + delta x, deleting the part with the index value x +1 to x + delta x from the queue, reconstructing a new queue and recording the length of the new queue as n1; the x +1 th coordinate to the x + Deltax-1 th coordinate of the original queue are counted into a set B n . And continuing searching from the next coordinate value of the current search coordinate value in the n1 until the coordinate value is searched in the whole queue. The new queue obtained by the k-th deletion is nk, wherein nk is less than or equal to n; and x is set to be 2, the index value of the searching coordinate is added with 1 on the basis of the current queue after the tail of the queue is searched each time, and the searching process is repeated until the coordinate value at the tail of the queue is used as a searching object and the searching is finished. Let the currently processed connected domain be A n After all searches are completed B n All pixels to be pruned are included.
In the present embodiment, as shown in fig. 4 (b) and fig. 6, the coordinate of the 2 nd pixel is searched backward from the queue index 2, and the coordinate is found not to appear in the queue; the coordinates of the 3 rd pixel are then searched backwards from index 3 and are not found. And by analogy, searching backwards from the index 9, deleting the parts of the 10 th, 11 th, 12 th, 13 th, 14 th and 15 th of the current queue index value if the coordinate corresponding to the index value 15 is the same as the coordinate corresponding to the index 9, and adding the coordinates (corresponding to three pixels) with the index values of 10 th, 11 th, 12 th, 13 th and 14 th to the set B 1 Then, the adjusted new queue is searched from the end of the deleted interval until the whole queue is processed. According to FIG. 4, the firstThe length of the start queue is adjusted 5 times in total, i.e. the length of the queue is adjusted to n5=28 for the last time, and the final result is shown in fig. 4 (b), and the outer boundary has 28 pixels in total. In the figure B 1 Contains 7 different coordinates whose first appearance in the first queue is 10,11,12, 25, 30, 33, 37, respectively.
S404, detecting whether an inner boundary exists in the connected domain; specifically, let the minimum x coordinate of a connected domain be x min Maximum x coordinate is x max The smallest y coordinate is y min The maximum y coordinate is y max . From y = y min Start the search, assuming agreement within this connected domain from y = y min Is R 1 To R, to R 1 The inner elements are arranged in ascending order, and R is found out according to the x coordinate boundary of the column 1 The integers are not contiguous and form sets H1, H2, H3 \8230; \8230, and are referred to as sets in the y =1 state, containing these x coordinate values, with the minimum difference between the elements in each set being 1. Search coordinates plus 1 (i.e. perform y = y) min + 1), repeating the above process until the search is finished y = y max And finishing the searching. Initializing i =1, based on the x coordinate of each element in the sets, intersecting the named sets of the beginning of H in the states of y = i and y = i +1 pairwise, if the same x element exists in the two sets, merging the two sets, and naming the merged set with a small number, namely, writing Hc = Ha ∞ Hb and c = min { a, b }; a set in the y = i state is added to the y = i +1 state if the x coordinates of the elements in the two sets do not have the same value. Search y = y min +2, y=y min + 3\8230\ 8230, up to y = y max And (4) completing the search, completing the combination of the primary sets (possibly combining more than once) along with the increase of the y value by 1, and finally obtaining the connected domains of the suspected holes, wherein one connected domain corresponds to one set.
If the connected domain of the suspected hole is detected, step S405 is executed, and if not, step S5 is executed.
In this embodiment, as shown in fig. 4 (b), if there is no integer discontinuous portion in the x coordinate and no connected domain of a suspected cavity is detected, step S5 is executed.
Illustratively, in some embodiments, the connected components are shown in FIG. 7 (a), with a target connected component (light gray), the upper row of numbers representing the y-coordinate and the left column of numbers representing the x-coordinate. During scanning, the range is determined according to the distribution of the target connected domain y, obviously, y is more than or equal to 2 and less than or equal to 11, and the scanning is required for 10 times. Scanning a column of y =2, recording the x coordinate of the target connected component involved in the column, then y = y +1, and so on to obtain the second row of the table in fig. 7 (b); finding out Ri integer discontinuous parts according to the x coordinate boundary of the column and forming a plurality of sets, wherein the minimum difference between elements in each set is 1, for example, y =2, finding a difference set of {4,5,6,7,8,9,10,11,12} and {4,6,7,8,9,12} to obtain {5}, {10,11}, and so on, and each column is searched to obtain the third row of the table in FIG. 7 (b); then, a set H1, H2 \8230; \8230H12 is constructed according to the distribution of the disconnected parts, the set generated when y = i is scanned is shown in the fourth row of the table in FIG. 7 (b), and the numbers in the parenthesis indicate the sequence of generating the set (namely, the reference numbers of the H set); the pixels labelled with the white number i in fig. 7 (a) are the elements within the set Hi. Conditionally merging the set in the state of y = i and the set generated when y = i +1 pairwise according to whether an intersection exists between the x coordinates corresponding to the pixels in the set, so as to obtain the set in the state of y = i + 1: if a set in the y = i state has no common value with the x coordinate of each element in the set generated by y = i +1, the set continues to exist in the y = i +1 state. By analogy, with the increase of y =2 to y =12, 9-level merging of sets is completed, the number of H sets after each level of merging is kept unchanged or increased on the basis of the previous level, the number of H sets existing in the state of y =12 is the largest, and finally the fifth row of the table in fig. 5 (b) is obtained. In the fifth row, each brace indicates a hole or suspected hole connected domain, and the value in the brace is the H set label included in the connected domain (white number in fig. 7 (a), which is the condition before the start of set merging and renaming); the parenthesis number in the fifth row of fig. 7 (b) is counted to obtain the total number of the holes or suspected hole connected domains corresponding to the target connected domain, as shown in the last row of the table of fig. 7 (b). The H sets in the last row of the table have been numbered discontinuously because merging and renaming of sets occurs as the scan value increases, while the number of elements in the right set is equal to or greater than the number of elements in the left set, despite the same set name appearing at multiple locations in the row. Then, step S405 is executed.
S405, checking the suspected hole communication domain to obtain a communication domain with an inner boundary really; specifically, a union set of a suspected connected domain to be analyzed and a corresponding target connected domain is obtained, and whether the regions of the suspected connected domain, which are respectively translated by one pixel upwards, downwards, leftwards and rightwards, are completely contained in the union set is verified respectively. If yes, the suspected cavity communication domain is the target communication domain A which is being analyzed i An internal hole corresponding to the structure of the object itself; if not, it indicates that the connected domain is a groove or concave structure of the outer boundary.
As shown in FIG. 7 (c), the target connected component to be analyzed in FIG. 7 (c) is denoted as A i The corresponding suspected cavity connected domain is H j ,H j H is obtained after the upper, lower, left and right translation j-1 、H j-2 、H j-3 、H j-4 . Calculating A i And H i Union and then H j-1 、H j-2 、H j-3 、H j-4 Are respectively reacted with A i And H i If all the results are empty sets, the result shows that the suspected cavity connected domain after the four translations is contained in the union set of the original suspected cavity connected domain and the target connected domain to be analyzed, namely H i Is A i An internal cavity; otherwise it is a concave structure of the edge.
Illustratively, all pixels labeled 4,6,7,8 in fig. 7 (a) constitute a suspected hollow connected component, and after translating left, right, up and down, the pixel coverage area is the corresponding area of itself and the labeled white circular pixel, obviously they are all completely contained in the union of the gray connected component and itself, and thus it belongs to a hollow in the target connected component; all pixels labeled 2 and 3 in fig. 7 (a) form a suspected hollow connected domain, and the pixel coverage area after the pixels are translated leftwards, rightwards, upwards and downwards is the area corresponding to the pixel marked with the white triangle. It is clear that when it is translated to the left, the pixel with the two marked triangles (coordinates (10, 1), (11, 1)) moves out of its own union with the gray connected components, so that it is not a true hole in the gray connected components, but appears as a concave structure at the border.
After the detection, step S406 is executed.
S406, performing burr trimming on the detected hole communication domain, wherein the trimming principle is the same as that in the step S403, and the details are not repeated here; after pruning is completed, a set C is generated n (ii) a Step S6 is performed.
S5, the final boundary of the nth target is D n =A n -B n D is 1 ,D 2 、D 3 …D n The gray scale of the pixel corresponding to each coordinate in the image is restored to the state in P1, and the other pixels are adjusted to 255, so that a corrected image P4 without the influence of paper packaging is obtained.
S6, the final boundary of the nth target is D n =A n -B n +C n D is 1 ,D 2 、D 3 …D n The gray scale of the pixel corresponding to each coordinate in the image is restored to the state in P1, and the other pixels are adjusted to 255, so that a corrected image P4 without the influence of paper packaging is obtained.
Example two
The embodiment discloses a preceding processing system towards terahertz security inspection image includes:
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;
a background picture analysis module configured to: performing histogram analysis on the terahertz security inspection image without the sample to acquire the 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 a boundary of a 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.
It should be noted here that the image obtaining module, the background picture analyzing module, the noise reducing module, the burr trimming module, and the corrected image obtaining module correspond to the steps in the first embodiment, and the modules are the same as the corresponding steps in the example and the application scenario, but are not limited to the disclosure in the first embodiment. It should be noted that the modules described above as part of a system may be implemented in a computer system such as a set of computer-executable instructions.
EXAMPLE III
The third embodiment of the invention provides electronic equipment which comprises a memory, a processor and a computer instruction stored on the memory and running on the processor, wherein when the computer instruction is run by the processor, the steps of the terahertz security inspection image-oriented preprocessing method are completed.
Example four
The fourth embodiment of the present invention provides a computer-readable storage medium, configured to store a computer instruction, where the computer instruction, when executed by a processor, completes the steps of the preprocessing method for the terahertz security inspection image.
The present invention has been 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 will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In the foregoing embodiments, the descriptions of the embodiments have different emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made to the present application by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present application shall be included in the protection scope of the present 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.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211208439.4A CN115601697A (en) | 2022-09-30 | 2022-09-30 | Pretreatment method for terahertz security inspection image |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211208439.4A CN115601697A (en) | 2022-09-30 | 2022-09-30 | Pretreatment method for terahertz security inspection image |
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 | Pretreatment method for terahertz security inspection image |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115601697A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117132842A (en) * | 2023-10-26 | 2023-11-28 | 江苏鹰创科技有限公司 | Intelligent forbidden article detection method based on terahertz characteristics |
-
2022
- 2022-09-30 CN CN202211208439.4A patent/CN115601697A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117132842A (en) * | 2023-10-26 | 2023-11-28 | 江苏鹰创科技有限公司 | Intelligent forbidden article detection method based on terahertz characteristics |
CN117132842B (en) * | 2023-10-26 | 2024-01-23 | 江苏鹰创科技有限公司 | Intelligent forbidden article detection method based on terahertz characteristics |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108228798B (en) | Method and device for determining matching relation between point cloud data | |
CN107228860B (en) | Gear defect detection method based on image rotation period characteristics | |
CN110942013A (en) | Satellite image feature extraction method and system based on deep neural network | |
Shin et al. | Data augmentation method of object detection for deep learning in maritime image | |
EP3550472B1 (en) | Method and device for obtaining an image of a form sheet | |
CN110570442A (en) | Contour detection method under complex background, terminal device and storage medium | |
CN113158895B (en) | Bill identification method and device, electronic equipment and storage medium | |
CN111382658B (en) | Road traffic sign detection method in natural environment based on image gray gradient consistency | |
CN113191358B (en) | Metal part surface text detection method and system | |
CN109117746A (en) | Hand detection method and machine readable storage medium | |
CN115601697A (en) | Pretreatment method for terahertz security inspection image | |
CN110176020A (en) | A kind of bird's nest impurity method for sorting merging 2D and 3D rendering | |
CN112686265A (en) | Hierarchic contour extraction-based pictograph segmentation method | |
CN114638974A (en) | Target object identification method, system, medium and electronic terminal | |
CN112488983A (en) | Defect identification network obtaining method, defect identification method and grade determining method | |
CN112364863B (en) | Character positioning method and system for license document | |
Manuaba et al. | The object detection system of balinese script on traditional Balinese manuscript with findcontours method | |
CN116661786A (en) | Design page generation method and device | |
CN116485992A (en) | Composite three-dimensional scanning method and device and three-dimensional scanner | |
CN115619799A (en) | Grain image segmentation method and system based on transfer learning | |
Khan et al. | Segmentation of single and overlapping leaves by extracting appropriate contours | |
CN115719355A (en) | Extensible farmland boundary normalization and simplification method, system, equipment and terminal | |
CN112381948B (en) | Semantic-based laser stripe center line extraction and fitting method | |
CN115187744A (en) | Cabinet identification method based on laser point cloud | |
JP2004102402A (en) | Partition data creating method and device |
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 |