Method for detecting difference of two images
Through image registration and blocking methods, the problem of automatically detecting differences between the same spectrum, different spectrum and large-size images in the prior art is solved, and fast and automatic image difference detection is achieved, suitable for remote sensing and medical images deal with.
Patent Information
- Application Number
- CN202411116455.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-08
AI Technical Summary
The prior art is difficult to automatically detect differences between homospectral, heterospectral and large-size images, especially in remote sensing and medical image processing. Manual detection requires expertise and machine learning methods require large amounts of samples and time.
Using image registration, blocking, calculating significant difference blocks and subdividing differences blocks, the two images are aligned through image registration, calculating similarity in blocks, dividing significant difference blocks, and subdividing them according to size, quickly Detect image differences.
It realizes fast automatic difference detection of large images, which is suitable for remote sensing and medical image processing, and improves detection efficiency and accuracy.
Smart Images

Figure CN118918157A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of image processing, and in particular relates to a method for detecting the difference between two images. Background Art
[0002] In the field of remote sensing image processing and medical image processing, it is usually necessary to compare two images from different spectra or different times to detect the difference for further processing. The difference detection between two images is usually performed on the common part of the two images after registering them.
[0003] In order to detect the difference between two images, image subtraction is usually used. This method is only suitable for images with the same spectrum and similar grayscale, for example, both are visible light images, optical images, synthetic aperture radar images, etc. If the two images are different spectra, image fusion is usually used first, and then other machine learning methods are used to detect the difference or manual detection of the difference. If manual detection is used, the inspector needs rich professional knowledge. If machine learning is used, a large number of sample images need to be collected to train the machine model, which is difficult to do in practice. In addition, when the two images are large, it takes a lot of time to detect the difference using machine learning methods.
[0004] Therefore, there is an urgent need for an automatic image difference detection method that can detect the same-spectrum, different-spectrum images and large-size images. This method is developed to meet this practical need. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] The technical problem to be solved by the present invention is how to provide a method for detecting the difference between two images to solve the problem of automatic image difference detection.
[0007] (II) Technical solution
[0008] In order to solve the above technical problem, the present invention proposes a method for detecting the difference between two images, which comprises the following steps:
[0009] S1. Image Registration
[0010] An image registration method is used to perform image registration so that the same or similar parts of two images are aligned;
[0011] S2. Image segmentation
[0012] Divide the common parts of the two aligned images into several blocks and treat them as difference blocks;
[0013] S3. Calculate significant difference blocks
[0014] Calculate the similarity of the corresponding difference blocks of the two images. The blocks with similarity lower than the average similarity are significant difference blocks.
[0015] S4. Subdivision of significant difference blocks
[0016] If the size of the significant difference block is smaller than the predetermined value, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks, upper, lower, left and right, as difference blocks, and the process goes to step S3 to continue calculating new significant difference blocks.
[0017] (III) Beneficial effects
[0018] The present invention proposes a method for detecting the difference between two images. The present invention adopts a block method to calculate the difference between the two images, which can quickly detect and mark the difference between two large images. It has wide application value in the fields of remote sensing image processing, medical image processing, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flow chart of a method for detecting differences between two images according to the present invention;
[0020] Figure 2 A block diagram of the method for detecting the difference between two images. DETAILED DESCRIPTION
[0021] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0022] The purpose of the present invention is to provide a method for automatically detecting the difference between two images with the same spectrum, different spectrum and large size images to meet the needs of image comparison.
[0023] The present invention discloses a method for detecting the difference between two images, the method comprising the following steps: (1) image registration. A conventional image registration method is used to align the same or similar parts of the two images. (2) image segmentation. The common parts of the two aligned images are divided into a plurality of blocks and regarded as difference blocks. (3) significant difference blocks are calculated. The similarity of the corresponding difference blocks of the two images is calculated, and the blocks with similarity lower than the average similarity are significant difference blocks. (4) significant difference block subdivision. If the size of the significant difference block is smaller than a predetermined value, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks of upper, lower, left and right as difference blocks, and the process goes to step (3) to continue calculating new significant difference blocks. The present invention adopts a segmentation method to calculate the difference between the two images, which can quickly detect and mark the difference between the two large images, and has a wide range of application value in the fields of remote sensing image processing, medical image processing, etc.
[0024] To achieve the above object, the present invention proposes a method for detecting the difference between two images, the method comprising:
[0025] S1. Image Registration
[0026] Using conventional image registration methods, image registration aligns the same or similar parts of two images.
[0027] S2. Image segmentation
[0028] The common parts (ie, the same or similar parts) of the two aligned images are divided into several blocks and regarded as difference blocks.
[0029] S3. Calculate significant difference blocks
[0030] The similarity of the corresponding difference blocks of the two images is calculated, and the blocks with similarity lower than the average similarity are significant difference blocks.
[0031] S4. Subdivision of significant difference blocks
[0032] If the size of the significant difference block is smaller than the predetermined value, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks, upper, lower, left and right, as difference blocks, and the process goes to step S3 to continue calculating new significant difference blocks.
[0033] Embodiment 1:
[0034] Figure 1 FIG. 1 is a flow chart of a method for detecting the difference between two images of the present invention. Figure 1 As shown, the method includes:
[0035] (1) Image registration: Using conventional image registration methods, image registration aligns the same or similar parts of two images.
[0036] In the specific implementation, an image A with a size of K×L is used as the reference image, and another image B with a size of M×N is used as the floating image. According to the image registration method, image B is placed on image A, the centers of the two images coincide, and image B is scaled, rotated, translated, etc. relative to image A, so that the same or similar parts of image B and image A overlap, and the overlapping part is the common part with a size of P×Q (pixels).
[0037] (2) Image segmentation: The common parts of the two aligned images are divided into several blocks and treated as difference blocks.
[0038] In specific implementation, the common part of image B and image A is divided into blocks of size p×q (pixels), 16≤p≤128 (pixels) and 16≤q≤128 (pixels), a total of s×t blocks, P=p×s, Q=q×t. The inner part of the common part of image B and image A that is away from the common part boundary (p / 2, q / 2) is also divided into blocks of size p×q, a total of (s-1)×(t-1) blocks. In this way, the common part of image B and image A forms a total of n=s×t+(s-1)×(t-1) difference block pairs, and the two blocks in a difference block pair come from image A and image B respectively.
[0039] like Figure 2 As shown, the solid lines represent the blocks of the common part of the image, and the dotted lines represent the blocks inside the common part. The common part of image B and image A is divided into blocks of size p×q (pixels), for a total of 3×3 blocks. The internal part away from the boundary of the common part (p / 2, q / 2) (pixels) is also divided into blocks of size p×q (pixels), for a total of 2×2 blocks. In this way, the common part of image B and image A forms a total of n=9+4=13 difference block pairs, and the two blocks in a difference block pair come from image A and image B respectively.
[0040] (3) Calculate the significant difference blocks. Calculate the similarity of the corresponding difference blocks in the two images. The blocks with similarity lower than the average similarity are significant difference blocks.
[0041] In the specific implementation, the two image blocks U in each pair of n difference block pairs are calculated. k 、V k The similarity S k (U k ,V k ), k=1,2,…,n.
[0042] If image B and image A are the same spectral images, the similarity is calculated using the normalized product correlation method:
[0043]
[0044] If image B and image A are heterospectral images, the similarity is calculated using mutual information. If the image grayscale ranges from 0 to 255, then:
[0045] S k (U k ,V k )=(H(U k )+H(V k )) / H(U k ,V k ),
[0046]
[0047] p i is the pixel with gray value i in image block U k The probability of occurrence, p j is the pixel with gray value j in image block V k The probability of occurrence; p ij It is the probability that a pair of pixels with grayscale values i and j in the two image blocks appear in the two image blocks.
[0048] Average similarity
[0049] If S k (U k ,V k )≤S, then the kth block of image B is a significant difference block; otherwise, it is not a significant difference block.
[0050] (4) Subdivision of significant difference blocks. If the size of the significant difference block is smaller than a predetermined value, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks, namely, upper, lower, left and right sub-blocks, as difference blocks, and the process goes to step (3) to continue calculating new significant difference blocks.
[0051] In a specific implementation, if the number of pixels of the significant difference block k = p × q ≤ a predetermined value, for example, the predetermined value is 256, then the detection is stopped; if the similarity is less than a threshold value (for example, the threshold value = the average similarity mean), then it is marked as a significant difference block on the image B, otherwise it is not marked;
[0052] If the number of pixels of the significant difference block k = p×q> the predetermined value, the significant difference block k is evenly divided into four sub-blocks, namely, upper, lower, left and right sub-blocks, as new difference blocks, and the sizes p and q of the new difference blocks are replaced with 1 / 2 of the original sizes p and q respectively. The number of difference block pairs n is replaced with the new number of difference block pairs, and the process goes to step (3) to continue calculating new significant difference blocks.
[0053] Embodiment 2:
[0054] A method for detecting a difference between two images, comprising:
[0055] (1) Image registration.
[0056] (2) Image segmentation.
[0057] (3) Calculate the significant difference blocks.
[0058] (4) Subdivision of blocks with significant differences.
[0059] Furthermore, in step (2), the common part of image B and image A is divided into blocks of size p×q (pixels), for a total of s×t blocks. 16≤p≤128 and 16≤q≤128, P=p×s, Q=q×t. The inner part of the common part of image B and image A that is away from the common part boundary (p / 2, q / 2) is also divided into blocks of size p×q, for a total of (s-1)×(t-1) blocks. In this way, the common part of image B and image A forms a total of n=s×t+(s-1)×(t-1) difference block pairs, and the two blocks in a difference block pair come from image A and image B respectively.
[0060] Furthermore, in step (3), two U k 、V k The similarity S of the image blocks k (U k ,V k ). Average similarity If S k (U k ,V k )≤S, then the kth block of image B is a significant difference block; otherwise, it is not a significant difference block.
[0061] Furthermore, in step (4), if the number of pixels of the significant difference block is less than a predetermined value of 256, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks, namely, upper, lower, left and right sub-blocks, as new difference blocks, and the size of the difference block and the number of difference block pairs are modified, and the process goes to step (3) to continue calculating new significant difference blocks.
[0062] The present invention adopts a block method to calculate the difference between two images, which can quickly detect and mark the difference between two large images and has wide application value in the fields of remote sensing image processing, medical image processing, etc.
[0063] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for detecting the difference between two images, characterized in that: The method comprises the following steps: S1. Image Registration An image registration method is used to perform image registration so that the same or similar parts of two images are aligned; S2. Image segmentation Divide the common parts of the two aligned images into several blocks and treat them as difference blocks; S3. Calculate significant difference blocks Calculate the similarity of the corresponding difference blocks of the two images. The blocks with similarity lower than the average similarity are significant difference blocks. S4. Subdivision of significant difference blocks If the size of the significant difference block is smaller than the predetermined value, the detection is stopped and the position of the significant difference block is marked on the image; otherwise, the significant difference block is evenly divided into four sub-blocks, upper, lower, left and right, as difference blocks, and the process goes to step S3 to continue calculating new significant difference blocks.
2. The method for detecting the difference between two images as claimed in claim 1, characterized in that: The S1 includes: taking an image A with a size of K×L as a reference image and another image B with a size of M×N as a floating image, placing image B on image A according to an image registration method, with the centers of the two images overlapping, performing scaling, rotation, and translation operations on image B relative to image A, so that the same or similar parts of image B and image A overlap, and the overlapping part is a common part with a size of P×Q.
3. The method for detecting the difference between two images as claimed in claim 2, characterized in that: The S2 includes: the common part of image B and image A is divided into blocks of size p×q, with a total of s×t blocks, P=p×s, Q=q×t; the internal part of the common part of image B and image A, which is p / 2 and q / 2 away from the boundary of the common part, is also divided into blocks of size p×q, with a total of (s-1)×(t-1) blocks; in this way, the common part of image B and image A forms a total of n=s×t+(s-1)×(t-1) difference block pairs, and the two blocks in a difference block pair come from image A and image B respectively.
4. The method for detecting the difference between two images as claimed in claim 3, characterized in that: 16≤p≤128 and 16≤q≤128.
5. The method for detecting the difference between two images as claimed in claim 3, characterized in that: The S3 includes: Calculate the two image blocks U in each pair of n difference blocks k 、V k The similarity S k (U k ,V k ), k=1,2,…,n; Average similarity If S k (U k ,V k )≤S, then the kth block of image B is a significant difference block; otherwise, it is not a significant difference block.
6. The method for detecting the difference between two images as claimed in claim 5, characterized in that: If image B and image A are the same spectral images, the similarity is calculated using the normalized product correlation method:
7. The method for detecting the difference between two images as claimed in claim 5, characterized in that: If image B and image A are heterospectral images, the similarity is calculated using mutual information. If the image grayscale ranges from 0 to 255, then: S k (U k ,V k )=(H(U k )+H(V k )) / H(U k ,V k ), p i is the pixel with gray value i in image block U k The probability of occurrence, p j is the pixel with gray value j in image block V k The probability of occurrence; p ij It is the probability that a pair of pixels with grayscale values i and j in the two image blocks appear in the two image blocks.
8. The method for detecting the difference between two images as claimed in claim 5, characterized in that: The S4 includes: If the number of pixels of the significant difference block k = p×q≤predetermined value, stop the detection; if the similarity is less than the threshold, mark it as a significant difference block on the image B, otherwise do not mark it; If the number of pixels of the significant difference block k = p×q> the predetermined value, the significant difference block k is evenly divided into four sub-blocks, namely, upper, lower, left and right sub-blocks, as new difference blocks. The sizes p and q of the new difference blocks are respectively replaced with 1 / 2 of the original sizes p and q. The number of difference block pairs n is replaced with the new number of difference block pairs, and the process goes to step S3 to continue calculating new significant difference blocks.
9. The method for detecting the difference between two images as claimed in claim 8, characterized in that: The preset value is 256.
10. The method for detecting the difference between two images as claimed in claim 8, characterized in that: Threshold = average similarity.
