Image difference detection method, device and terminal
Through principal component analysis technology and positioning kernel sequence correlation, the problem of edge area registration of multi-print prints and image distortion of flexible prints is solved, achieving high accuracy and completeness of image difference detection.
Patent Information
- Application Number
- CN202411287979.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-10-29
AI Technical Summary
Existing image difference detection technology is difficult to accurately register the pattern edge areas of multi-print printed matter and deal with the image distortion problem of flexible printed matter.
Using principal component analysis technology and algorithm operations, through positioning calculation and sub-pixel offset, the positioning kernel sequence and detection area correlation are established, data reconstruction and point-by-point comparison are performed, and image differences are judged.
It improves the accuracy and completeness of image registration, can effectively detect image differences, and is suitable for image detection of multi-print printed matter and flexible printed matter.
Smart Images

Figure CN118864446A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image difference detection, and in particular to an image difference detection method, device and terminal. Background Art
[0002] In the existing image difference detection process, the real-time image needs to be accurately aligned with the reference image and compared point by point. When the difference in point-by-point comparison is greater than a certain threshold, it is considered that there is a difference in the corresponding position of the real-time image. Defect detection can be performed after a series of processing (such as binary morphological filtering, BLOB analysis, etc.) on the difference image. At present, the key to this detection method is accurate image alignment. The real-time image and the reference image must be completely aligned (sub-pixel level) before detection can be performed. There are several difficulties in the alignment process:
[0003] 1. For multi-print prints, it is difficult to align the edge areas of different prints.
[0004] 2. Printed products are often flexible products with distorted images. When one position is registered, areas farther away from it are often not registered.
[0005] In view of this, the present invention provides an image difference detection method, device and terminal to solve the above technical problems. Summary of the invention
[0006] The present invention provides an image difference detection method, device and terminal, which use principal component analysis technology and algorithm operation to solve the problem that for multi-print printed products, the edge areas of patterns of different prints are difficult to align, and the printed products are often flexible products with image distortion. When a position is aligned, the areas farther away are often not aligned.
[0007] The present invention provides an image difference detection method, the method is as follows Figure 3 Said, including:
[0008] S101: performing positioning calculation on each inspected image, and performing sub-pixel shift on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image;
[0009] S102: Reconstruct the data of each detection area of the detected image x by using principal component analysis to obtain the reconstructed detected image ;
[0010] S103: Reconstructing the inspected image A point-by-point comparison is performed with the aligned image to be inspected x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the image to be inspected based on the analysis result.
[0011] Furthermore, in some embodiments, performing positioning calculation on each inspected image and performing sub-pixel shift on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image specifically includes:
[0012] Modeling process:
[0013] Step 1: Determine multiple positioning kernels on the reference image, select multiple positioning kernels, and divide the reference image into multiple detection areas;
[0014] Step 2: According to the distance relationship, each detection area and the positioning kernel are associated to obtain the modeling result, and multiple positioning kernels are stored as a positioning kernel sequence, and the corresponding coordinates on the reference map are recorded to generate a coordinate array;
[0015] Training process:
[0016] Step 3: Traverse all images in the training set, and use each positioning kernel in the positioning kernel sequence to perform positioning calculations in a certain range near the original coordinates of the reference image in turn. Use the positioning results to perform sub-pixel shifts on the associated detection area images. The sub-pixel part is calculated using bilinear interpolation, and finally a training set of all training images aligned with the reference image is obtained;
[0017] Step 4: Loop through each detection area on the training set image and perform the following calculations for any detection area:
[0018]
[0019] Where: ——is the sample mean of the training image set;
[0020] ——Number of training images;
[0021] ——the i-th training image;
[0022] Among them, loop each detection area, for any detection area Rect[r]0≤r Λ , let its training set be a set of A set of n-dimensional training images, denoted by , calculate the sample mean μ of the detection area for each pixel in the training image set;
[0023] Calculate the covariance C of the detection area for each pixel with respect to the training image set;
[0024] Perform eigendecomposition on the covariance C, solve the eigenvalue eigenvector U, and retain the first k eigenvalues to obtain the eigenvector U k .
[0025] [ U , eig ] = Rect[r]0≤r Rect[r]0≤r Λ ( lC )
[0026] Where: eig() – calculates the eigenvalues and eigenvectors of a matrix;
[0027] C – covariance of the training image set;
[0028] ——Eigenvalues and eigenvectors of the training image set;
[0029] Furthermore, the covariance C is subjected to eigendecomposition to solve the eigenvalue eigenvector U, and the first k eigenvalues are retained to obtain the eigenvector U k include:
[0030] Calculate the variance contribution rate of each eigenvalue. The variance contribution rate refers to the ratio of a single eigenvalue to the sum of all eigenvalues.
[0031]
[0032] Where: ——the mth eigenvalue;
[0033] w – the number of eigenvalues;
[0034] ——The variance contribution rate of the mth eigenvalue;
[0035] in, is the mth eigenvalue, w is the number of eigenvalues, is the variance contribution rate of the mth eigenvalue,
[0036] Calculate the cumulative variance contribution of the eigenvalue:
[0037]
[0038] Where: ——The cumulative variance contribution rate of the mth eigenvalue;
[0039] ——The variance contribution rate of the nth eigenvalue;
[0040] in, is the cumulative variance contribution rate of the mth eigenvalue. Usually, when When it is greater than 95%, take k=m.
[0041] Furthermore, in some embodiments, the principal component analysis is used to reconstruct the data of each detection area of the detected image x to obtain the reconstructed detected image include:
[0042] Loop through each detection zone. For any detection zone eig , use principal component analysis to reconstruct the data of the image x, project it into the trained subspace, and get y:
[0043]
[0044] Where: x——aligned image to be detected;
[0045] ——the sample mean of the training image set;
[0046] ——Keep the eigenvectors of the first k eigenvalues; ——the transpose of the eigenvectors of the first k eigenvalues;
[0047] For the detection area, the eigenvectors of the first k eigenvalues are used to reconstruct the original space to obtain the reconstructed detected image. :
[0048]
[0049] Where: ——The reconstructed image of the inspected object;
[0050] ——the sample mean of the training image set;
[0051] ——Keep the eigenvectors of the first k eigenvalues;
[0052] Further, according to the reconstructed image Compare the aligned image x point by point to obtain the difference result, analyze the difference result, and determine whether there is a difference on the image x according to the analysis result, including:
[0053] The difference images are analyzed, and the area, energy, discreteness, and position factors of each difference image are compared with the thresholds set during modeling, and whether there is a difference is determined based on the comparison results.
[0054] The present invention also provides an image difference detection device, characterized in that it comprises:
[0055] A positioning module is used to perform positioning calculation on each inspected image, and perform sub-pixel shift on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image;
[0056] The reconstruction module is used to reconstruct the data of each detection area of the detected image x by using principal component analysis to obtain the reconstructed detected image ;
[0057] Comparison module, used to reconstruct the inspected image A point-by-point comparison is performed with the aligned image to be inspected x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the image to be inspected based on the analysis result.
[0058] Furthermore, an image difference detection device, wherein the positioning module comprises:
[0059] Modeling module, which is used to perform the following steps:
[0060] Step 1: Determine multiple positioning kernels on the reference image, select multiple positioning kernels, and divide the reference image into multiple detection areas;
[0061] Step 2: According to the distance relationship, each detection area and the positioning kernel are associated to obtain the modeling result, and multiple positioning kernels are stored as a positioning kernel sequence, and the corresponding coordinates on the reference map are recorded to generate a coordinate array;
[0062] The training module is used to perform the following steps:
[0063] Step 3: Traverse all images in the training set, and use each positioning kernel in the positioning kernel sequence to perform positioning calculations in a certain range near the original coordinates of the reference image in turn. Use the positioning results to perform sub-pixel shifts on the associated detection area images. The sub-pixel part is calculated using bilinear interpolation, and finally a training set of all training images aligned with the reference image is obtained;
[0064] Step 4: Loop through each detection area on the training set image and perform the following calculations for any detection area:
[0065] Loop through each detection zone. For any detection zone Rect[r]0≤rFigure 1 , let its training set be a set of A set of n-dimensional training images, denoted by , calculate the sample mean μ of the detection area for each pixel in the training image set.
[0066]
[0067] Calculate the covariance C of the detection area for each pixel with respect to the training image set;
[0068] Perform eigendecomposition on the covariance C, solve the eigenvalue eigenvector U, and retain the first k eigenvalues to obtain the eigenvector U k .
[0069] [ U , Figure 2 ] = Figure 3 ( lC )
[0070] Furthermore, an image difference detection device is characterized in that the training module comprises:
[0071]
[0072] Where: ——the mth eigenvalue;
[0073] w – the number of eigenvalues;
[0074] ——The variance contribution rate of the mth eigenvalue;
[0075] in, is the mth eigenvalue, w is the number of eigenvalues, is the variance contribution rate of the mth eigenvalue, and the cumulative variance contribution rate of the eigenvalue is calculated:
[0076]
[0077] Where: ——The cumulative variance contribution rate of the mth eigenvalue;
[0078] ——The variance contribution rate of the nth eigenvalue;
[0079] Select the feature vector dimension k. If the k value is too large, that is, too many principal components, it may cause the model to overfit and produce false detection; if the k value is too small, that is, too few principal components, it may lose important information and cause missed detection. When it is greater than 95%, take k=m, where k is the feature vector dimension.
[0080] Furthermore, an image difference detection device, wherein the reconstruction module comprises:
[0081] The loop module is used to loop each detection zone. Figure 4 , use principal component analysis to reconstruct the data of the image x, project it into the trained subspace, and get y:
[0082] Where: x——aligned image to be detected; ——the sample mean of the training image set; ——Keep the eigenvectors of the first k eigenvalues; ——the transpose of the eigenvectors of the first k eigenvalues;
[0083] The reconstruction submodule is used to reconstruct the eigenvectors of the first k eigenvalues of the detection area into the original space to obtain the reconstructed image under inspection. :
[0084]
[0085] Where: ——The reconstructed image of the inspected object;
[0086] ——the sample mean of the training image set;
[0087] ——Keep the eigenvectors of the first k eigenvalues;
[0088] A terminal comprises a memory and a processor, wherein the memory stores computer instructions executable on the processor, and wherein the processor executes the above method when executing the computer instructions. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0090] Figure 5 It is a schematic diagram of a positioning kernel and a detection area based on an image difference detection method provided by the present invention;
[0091] Figure 6 It is a training flow chart of an image difference detection method provided by the present invention;
[0092] Figure 3 It is one of the flow charts of an image difference detection method provided by the present invention;
[0093] Figure 1 This is the second flow chart of an image difference detection method provided by the present invention;
[0094] Figure 2 is a relationship diagram of an image difference detection terminal provided by the present invention;
[0095] Rect[r]0≤r Λ The present invention provides a flow chart of an image difference detection device. DETAILED DESCRIPTION
[0096] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0097] Before describing the embodiments, the abbreviations and key terms are defined as follows:
[0098] Principal Component Analysis
[0099] Principal Component Analysis (PCA) is a classic method for processing high-dimensional data in pattern recognition and mathematical statistics. This method projects high-dimensional data into a low-dimensional space (linear subspace). The goal of the projection is to find the projection method that best represents the data in terms of mean square error. In the subspace, principal component analysis retains the potential structure and other information between data in high-dimensional data, and discards some random parts between data. Principal component analysis can be used for face recognition, feature extraction of high-dimensional data, etc. For example, consider the following example: a 100×100 face image contains a total of 10,000-dimensional features. 10,000-dimensional data is too high for the classifier and contains a lot of useless information. Using principal component analysis, 10,000-dimensional data can be compressed to a small number of dimensions, such as 100 dimensions, and these 100 dimensions contain the most critical part of the data, thereby achieving the purpose of recognition.
[0100] Since principal component analysis retains the principal components and common changes in the training set, and removes the irrelevant data in the training set, the principal component analysis can be used to reconstruct the inspected image. The reconstructed inspected image retains the data part related to the training set and removes the irrelevant part of the inspected image. Since the difference (also called "defect") in the inspected image does not appear in the training set, the difference part will not be retained. The image reconstructed from the inspected image can be considered as a "perfect" (no difference) image. The difference image can be obtained by comparing the inspected image with the inspected reconstructed image point by point. Further analysis of the difference image can determine whether it is a real difference.
[0101] eig As described in the example of the present invention, a flow chart of an image difference detection method includes:
[0102] S101 performs positioning calculation on each inspected image, and performs sub-pixel shift on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image;
[0103] S102 uses principal component analysis to reconstruct data for each detection area of the detected image x to obtain a reconstructed detected image ;
[0104] S103 reconstructs the inspected image A point-by-point comparison is performed with the aligned image to be inspected x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the image to be inspected based on the analysis result.
[0105] First, in S101, positioning calculation is performed on each image to be inspected, and sub-pixel shift is performed on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image. The inspection method includes:
[0106] Modeling process:
[0107] Step 1: Determine multiple positioning kernels on the reference image, select multiple positioning kernels, and divide the reference image into multiple detection areas;
[0108] The specific modeling implementation method is to first perform modeling on the reference image. The modeling process is to select multiple positioning kernels and divide the reference image into multiple small areas (for example, 200×200 in size). According to the distance relationship, each small area is associated with the positioning kernel. The positioning kernel is used for positioning calculations during training and detection, and its positioning results are used to offset the small area so as to align the training image and the image to be tested with the reference image. The small area is referred to as the detection area below, which is the smallest unit for offsetting and related calculations of the image based on the positioning results.
[0109] Step 2: According to the distance relationship, each detection area and the positioning kernel are associated to obtain the modeling result, and multiple positioning kernels are stored as a positioning kernel sequence, and the corresponding coordinates on the reference map are recorded to generate a coordinate array;
[0110] The distribution diagram of the positioning core and the detection area is shown in Rect[r]0≤rFigure 6 As shown in the figure. The dotted box is the detection area, and the solid box is the positioning kernel. The positioning kernel is selected in the area containing horizontal and vertical texture information for more accurate positioning calculation; the detection area should cover the entire inspected area of the image. Selecting multiple positioning kernels and dividing multiple detection areas at the same time is to solve the registration problem of flexible inspected products.
[0111] After modeling is completed, the selected a positioning kernels are stored as a positioning kernel image sequence of length a, recorded as KernelImg[a], and their coordinates on the reference image are recorded. The divided b detection areas are stored as a detection area coordinate array of length b, recorded as Rect[b].
[0112] Training process:
[0113] All images in the training set are traversed, and each positioning kernel in the positioning kernel sequence is used in turn to perform positioning calculations within a certain range near the original coordinates of the reference image. The positioning results are used to perform sub-pixel shifts on the associated detection area images, and the sub-pixel part is calculated using bilinear interpolation. Finally, a training set of all training images aligned with the reference image is obtained.
[0114] like Figure 4 As shown, in a specific example, the training process includes the following steps:
[0115] 21 Read a training image;
[0116] 22 All positioning cores perform positioning calculations;
[0117] 23 All detection areas are offset;
[0118] 24 Obtain the training image aligned with the reference image;
[0119] 25. Whether all training image calculations are completed;
[0120] 26 Calculate the mean of all aligned samples;
[0121] 27 Calculate the covariance matrix of all aligned training images;
[0122] 28Solve the eigenvalue and the eigenvector Uk.
[0123] The training process of a method for detecting image differences is specifically implemented as follows: looping through all images in the training set. For each training image, looping through each positioning kernel of the positioning kernel sequence KernelImg[a], performing positioning calculations within a certain range near the original coordinates of its reference image, using the positioning results (the deviation between the positioning coordinates of the training image and the original coordinates of the reference image) to perform sub-pixel shifts on the associated detection area image, and using bilinear interpolation to calculate the sub-pixel portion, finally obtaining the training image aligned with the reference image. When all training images are aligned with the reference image, proceed to the following steps.
[0124] Loop through each detection area in the training set, loop through each detection area, and for any detection area Figure 5 , let its training set be a set of A set of n-dimensional training images, denoted by , calculate the sample mean μ of the detection area for each pixel in the training image set:
[0125]
[0126] Where: ——is the sample mean of the training image set;
[0127] ——Number of training images;
[0128] ——the i-th training image;
[0129] Calculate the covariance C of the detection area for each pixel of the training image set:
[0130]
[0131] Where: ——the i-th training image;
[0132] ——the sample mean of the training image set;
[0133] C – covariance of the training image set;
[0134] ——Number of training images.
[0135] After that, perform eigendecomposition to solve the eigenvalue eigenvector U, and retain the first k eigenvectors to obtain U k , so we have completed all the steps of training.
[0136] [ U , ] = ( lC )
[0137] Where: eig() – function used to calculate the eigenvalues and eigenvectors of a matrix;
[0138] C – covariance of the training image set;
[0139] ——Eigenvalue eigenvector of the training image set;
[0140] Particular emphasis should be placed on the selection of the feature vector dimension k. If the k value is too large, that is, too many principal components, the model may be overfitted and cause false detection; if the k value is too small, that is, too few principal components, important information may be lost, resulting in missed detection.
[0141] We should first calculate the variance contribution of each eigenvalue, which is the ratio of a single eigenvalue to the sum of all eigenvalues.
[0142]
[0143] Where: ——the mth eigenvalue;
[0144] w – the number of eigenvalues;
[0145] ——The variance contribution rate of the mth eigenvalue;
[0146] in, is the mth eigenvalue, w is the number of eigenvalues, is the variance contribution rate of the mth eigenvalue.
[0147] Then we need to calculate the cumulative variance contribution of the eigenvalue:
[0148]
[0149] Where: ——The cumulative variance contribution rate of the mth eigenvalue;
[0150] ——The variance contribution rate of the nth eigenvalue;
[0151] in, is the cumulative variance contribution rate of the mth eigenvalue. Usually, when When it is greater than 95%, we take k=m.
[0152] Furthermore, in step S102, data of each detection area of the detected image x is reconstructed based on principal component analysis to obtain a reconstructed detected image ;
[0153] Specifically, before the detection, the relevant steps of the above modeling and training process must be completed. During the detection process, for each image to be detected, each positioning kernel of the positioning kernel sequence KernelImg[a] is used cyclically to perform positioning calculations within a certain range near the original coordinates of its reference image. The positioning results (the deviation between the positioning coordinates of the training image and the original coordinates of the reference image) are used to perform sub-pixel shifts on the associated detection area image. The sub-pixel part is calculated using bilinear interpolation, and finally the detected image x aligned with the reference image is obtained. After that, each detection area is looped, and for any detection area , use the principal component analysis technology to reconstruct the data of the inspected image x, project it into the trained subspace, and obtain y.
[0154]
[0155] Where: x——aligned image to be detected;
[0156] ——the sample mean of the training image set;
[0157] k – feature vector dimension;
[0158] ——Keep the eigenvectors of the first K eigenvalues;
[0159] For the detection area, the vectors of the first k features are used to reconstruct the original space to obtain the reconstructed image of the detection area. :
[0160]
[0161] Where: ——The reconstructed image of the inspected object;
[0162] ——the sample mean of the training image set;
[0163] k – feature vector dimension;
[0164] ——Keep the eigenvectors of the first k eigenvalues;
[0165] The specific operation is as follows: in step S103, the inspected image is compared point by point with the aligned inspected image x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the inspected image according to the analysis result. The specific steps are as follows:
[0166] The reconstructed image Compare the image x with the aligned image x point by point to get the difference image (also called BLOB image). Analyze the BLOB image and judge whether there is a real difference in the image based on the area, energy, discreteness, position and other factors of each BLOB. For example, we can loop all BLOBs and compare the area, energy, discreteness and other parameters of each BLOB with the threshold set during modeling. If all meet the difference requirements, the location of the BLOB will be judged as having a difference.
[0167] The present invention also provides an image difference detection device, wherein the device, one of which is an image difference detection device, can execute the content of the above-mentioned image difference detection method and adopt the following technical solution:
[0168] An image difference detection device, see shown.
[0169] Image reading module: responsible for reading the detected image from the input source;
[0170] Positioning calculation module: responsible for using all positioning kernels to accurately locate the detection image. This module is used for feature extraction algorithm and positioning kernel calculation;
[0171] Detection area offset correction module: This module is used to calculate the offset of each detection area and adjust the alignment of each area with the reference image;
[0172] Image alignment module: stitching and adjusting all offset-corrected detection areas to the original image space to generate an aligned image;
[0173] Subspace projection module: Based on the subspace projection results, the reconstructed image under inspection is calculated and the projection data in the low-dimensional space is reconstructed into an approximate original image;
[0174] Reconstruction analysis module: Compare the reconstructed image with the aligned original image and calculate the error.
[0175] A workflow of an image difference detection device, the specific steps are as follows As shown, including:
[0176] 410 reading the detected image;
[0177] 420 performs positioning calculation on all positioning kernels;
[0178] 430 All detection areas are offset;
[0179] 440 obtaining the detected image aligned with the reference image;
[0180] 450 projecting the aligned inspected image into the trained subspace;
[0181] 460 calculating the reconstructed image;
[0182] 470 contrast differences.
[0183] According to another aspect of the present invention, the present invention further provides a terminal product, the terminal product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium and a memory and a processor, when the computer program and the storage are executed by the processor, the computer can perform the above method, with reference to As shown. 500 Modeling module, modeling is performed on the reference image. After modeling is completed, the selected a positioning kernels are stored as a positioning kernel image sequence of length a, recorded as KernelImg[a], and their coordinates on the reference image are recorded. The divided b detection areas are stored as a detection area coordinate array of length b, recorded as Rect[b];
[0184] 510 training module, loops through all the images in the training set. For each training image, loops through each positioning kernel of the positioning kernel sequence KernelImg[a], performs positioning calculations within a certain range near the original coordinates of the reference image, and obtains the training image aligned with the reference image. 520 inspection module, reconstructs the inspected image Compare it point by point with the aligned image x to get the difference image, and analyze the image.
[0185] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting image differences, characterized in that ,include: Perform positioning calculation on each inspected image, perform sub-pixel shift on the associated inspection area image according to the positioning result, and obtain the inspected image aligned with the reference image; The principal component analysis technique is used to reconstruct the data of each detection area of the detected image x to obtain the reconstructed detected image ; After reconstruction, the detected image A point-by-point comparison is performed with the aligned image to be inspected x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the image to be inspected based on the analysis result.
2. The detection method according to claim 1, characterized in that: Before performing positioning calculation on each inspected image and performing sub-pixel shifting on the associated inspection area image according to the positioning result to obtain the inspected image aligned with the reference image, the detection method includes: Modeling process: Step 1: Determine multiple positioning kernels on the reference image, select multiple positioning kernels, and divide the reference image into multiple detection areas; Step 2: According to the distance relationship, each detection area and the positioning kernel are associated to obtain the modeling result, and multiple positioning kernels are stored as a positioning kernel sequence, and the corresponding coordinates on the reference map are recorded to generate a coordinate array; Training process: Step 3: Traverse all images in the training set, and use each positioning kernel in the positioning kernel sequence to perform positioning calculations in a certain range near the original coordinates of the reference image in turn. Use the positioning results to perform sub-pixel shifts on the associated detection area images. The sub-pixel part is calculated using bilinear interpolation, and finally a training set of all training images aligned with the reference image is obtained; Step 4: Loop through each detection area on the training set image and perform the following calculations for any detection area: Where: ——is the sample mean of the training image set; ——Number of training images; ——the i-th training image; Among them, loop each detection area, for any detection area , let its training set be a set of A set of n-dimensional training images, denoted by , calculate the sample mean μ of the detection area for each pixel in the training image set; Calculate the covariance C of the detection area for each pixel of the training image set; perform eigendecomposition on the covariance C, solve the eigenvalue eigenvector U, and retain the first k eigenvectors to obtain U k ; Where: eig() – calculates the eigenvalues and eigenvectors of the matrix; C – the covariance of the training image set; ——Eigenvalues and eigenvectors of the training image set.
3. The detection method according to claim 2, characterized in that: The covariance C is subjected to eigendecomposition to solve the eigenvalue eigenvector U, and the first k eigenvectors are retained to obtain U k include: Calculate the variance contribution rate of each eigenvalue. The variance contribution rate refers to the ratio of a single eigenvalue to the sum of all eigenvalues. Where: ——mth eigenvalue; w——the number of eigenvalues; ——The variance contribution rate of the mth eigenvalue; in, is the mth eigenvalue, w is the number of eigenvalues, is the variance contribution rate of the mth eigenvalue, and the cumulative variance contribution rate of the eigenvalue is calculated: Where: ——The cumulative variance contribution rate of the mth eigenvalue; ——The variance contribution rate of the nth eigenvalue; Select the feature vector dimension k. If the k value is too large, that is, too many principal components, the model may be overfitted and cause false detection; if the k value is too small, that is, too few principal components, important information may be lost, resulting in missed detection. When it is greater than 95%, take k=m, where k is the dimension of the feature vector.
4. The detection method according to claim 1, characterized in that: The principal component analysis is used to reconstruct the data of each detection area of the detected image x to obtain the reconstructed detected image include: Loop through each detection zone. For any detection zone , use principal component analysis to reconstruct the data of the image x, project it into the trained subspace, and get y: Where: x——aligned image to be detected; ——the sample mean of the training image set; ——Keep the eigenvectors of the first k eigenvalues; ——the transpose of the eigenvectors of the first k eigenvalues; For the detection area, the eigenvectors of the first k eigenvalues are used to reconstruct the original space to obtain the reconstructed detected image. : Where: ——The reconstructed image of the inspected object; ——the sample mean of the training image set; ——Retain the eigenvectors of the first k eigenvalues; obtain the reconstructed image under test Then, perform a difference comparison.
5. The detection method according to claim 1, characterized in that: The detected image Compare the aligned image x point by point to obtain the difference result, analyze the difference result, and determine whether there is a difference on the image x according to the analysis result, including: The difference images are analyzed, and the area, energy, discreteness, and position factors of each difference image are compared with the thresholds set during modeling, and whether there is a difference is determined based on the comparison results.
6. An image difference detection device, characterized in that ,include: A positioning module is used to perform positioning calculation on each inspected image, and perform sub-pixel shift on the associated inspection area image according to the positioning result to obtain the inspected image x aligned with the reference image; The reconstruction module is used to reconstruct the data of each detection area of the detected image x using principal component analysis to obtain the reconstructed detected image ; Comparison module, used to reconstruct the inspected image A point-by-point comparison is performed with the aligned image to be inspected x to obtain a difference result, the difference result is analyzed, and it is determined whether there is a difference on the image to be inspected based on the analysis result.
7. The detection device according to claim 6, characterized in that: The positioning module comprises: Modeling module, which is used to perform the following steps: Step 1: Determine multiple positioning kernels on the reference image, select multiple positioning kernels, and divide the reference image into multiple detection areas; Step 2: According to the distance relationship, each detection area and the positioning kernel are associated to obtain the modeling result, and multiple positioning kernels are stored as a positioning kernel sequence, and the corresponding coordinates on the reference map are recorded to generate a coordinate array; The training module is used to perform the following steps: Step 3: Traverse all images in the training set, and use each positioning kernel in the positioning kernel sequence to perform positioning calculations in a certain range near the original coordinates of the reference image in turn. Use the positioning results to perform sub-pixel shifts on the associated detection area images. The sub-pixel part is calculated using bilinear interpolation, and finally a training set of all training images aligned with the reference image is obtained; Step 4: Loop through each detection area on the training set image and perform the following calculations for any detection area: Loop through each detection zone. For any detection zone , let its training set be a set of A set of n-dimensional training images, denoted by , calculate the detection area; Where: ——is the sample mean of the training image set; ——Number of training images; ——The i-th training image; the sample mean μ of the training image set for each pixel; Calculate the covariance C of the detection area for each pixel of the training image set; perform eigendecomposition on the covariance C, solve the eigenvalue eigenvector U, and retain the first k eigenvectors to obtain U k; Where: eig() – calculates the eigenvalues and eigenvectors of the matrix; C – the covariance of the training image set; ——Eigenvalues and eigenvectors of the training image set.
8. The detection device according to claim 7, characterized in that: The training module includes: The calculation module is used to calculate the variance contribution rate of each eigenvalue, select the eigenvector dimension k, and finally retain the eigenvectors of the first k eigenvalues.
9. The detection device according to claim 6, characterized in that: The reconstruction module includes: The loop module is used to loop each detection zone. , use principal component analysis to reconstruct the data of the image x, project it into the trained subspace, and get y: Where: x——aligned image to be detected; ——the sample mean of the training image set; ——Keep the eigenvectors of the first k eigenvalues; ——the transpose of the eigenvectors of the first k eigenvalues; The reconstruction submodule is used to reconstruct the feature vector composed of the first k eigenvalues into the original space for the detection area to obtain the reconstructed image under inspection. : Where: ——The reconstructed image of the inspected object; ——the sample mean of the training image set; ——Keep the eigenvectors of the first k eigenvalues.
10. A terminal comprising a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, characterized in that: When the processor runs the computer instructions, the steps of the image difference detection method according to any one of claims 1 to 5 are performed.
Citation Information
Patent Citations
Banknote quality detection system and method based on deformation restoration technology
CN105426902A
Pattern quality detection method, device and system based on point-by-point comparison analysis
CN110632094A
Chromatic aberration measurement method and system based on equipment-independent color space
CN114295561A
Time sequence industrial big data feature extraction and anomaly detection method and system
CN118114034A
