A method for determining image similarity, an electronic device, and a storage medium

By sliding across the image and gradually expanding the detection window, the similarity of sub-images of the APP icon is calculated, solving the misjudgment problem in image similarity detection in the prior art and achieving higher accuracy.

CN117173435BActive Publication Date: 2026-04-10ZHEJIANG MEIRI HUDONG NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-13
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing image similarity detection methods are prone to misjudgment when detecting app icons, especially due to high similarity in local structure of icons or system differences.

Method used

After preprocessing the images to be compared, a sliding image set is generated by sliding a set of basic detection windows on the images and gradually expanding it in the x and y directions. The similarity of each sub-image is calculated, and the maximum similarity is finally obtained as the image similarity.

Benefits of technology

It improves the accuracy of image similarity calculation and avoids misjudgments caused by spatial differences in image components, especially when detecting APP icons.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117173435B_ABST
    Figure CN117173435B_ABST
Patent Text Reader

Abstract

The application provides a method for determining image similarity, an electronic device and a storage medium. The method comprises the following steps: firstly, based on a set basic detection window, sliding on two images to be compared according to a set sliding step, a plurality of sliding images are obtained; then, for each sliding image, gradually expanding along the x-axis direction and the y-axis direction according to the set sliding step, a plurality of sub-images are finally obtained; then, the similarity of the corresponding sub-images of the two images to be compared is obtained respectively, and the maximum of the similarity of all sub-images is taken as the similarity of the two images to be compared. The sub-image of the application is obtained by traversing the regions of different positions and different sizes of the two images, so that the problem of inaccurate similarity judgment caused by the spatial difference of image elements and the like can be avoided, and the accuracy of image similarity calculation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing, and in particular to a method for determining image similarity, an electronic device and a storage medium. BACKGROUND

[0002] In some application scenarios, it is often necessary to determine the similarity of two images to determine whether the two images are the same image. Existing image similarity detection methods mainly include image global similarity detection methods such as SSIM and image local similarity detection methods such as HOG. The image global similarity detection method focuses on global similarity, however, for certain specific images, such as APP icons, since two APP icons are often highly similar only in local structure, thus, using the traditional image global similarity detection method for detection will result in inaccurate detection results. In addition, in different systems, APP icons will change, such as from square to rectangle, etc., but they are actually the same icon, if the image global similarity detection method is used for similarity calculation, it will be judged that the two icons are not the same icon, thus resulting in misjudgment. SUMMARY

[0003] In view of the above technical problems, the technical scheme adopted by the present application is as follows:

[0004] The embodiment of the present application provides a method for determining image similarity, which comprises the following steps:

[0005] S100, pre-processing a first image and a second image to be compared to obtain a first binary image and a second binary image with a preset size G, as a first target image and a second target image respectively, G=m*m pixels, m is a set pixel value;

[0006] S200, obtaining a first basic detection window W1 from the first target image, and taking W1 as a sliding window, sliding W1 along the x-axis direction of the first target image according to a set sliding step △d to obtain a corresponding basic sliding image set I1 T ={I1 T1 ,I1 T2 ,……,I1 Ti ,……,I1 Tn};and obtaining a second basic detection window W2 from the second target image, and taking W2 as a sliding window, sliding W2 along the x-axis direction of the second target image according to △d to obtain a corresponding basic sliding image set I2 T ={I2 T1 ,I2 T2 ,……,I2 Ti ,……,I2 Tn}; where W1 and W2 are both a*a pixels in size, a = m*k, and k is a preset coefficient, 0 < k < 1; I1 Ti For I1 T The i-th image in the dataset, I1 T1 The coordinates of the top left corner are the same as the coordinates of the top left corner of the first target image, I2 Ti For I2 T The i-th image in the dataset, I2 T1 The coordinates of the top left corner of the image are the same as those of the top left corner of the second target image. The value of i ranges from 1 to n, where n = m / △d.

[0007] S300, with I1 Ti For a sliding window, set I1 Ti By sliding along the y-axis of the first target image according to △d, the corresponding vertical sliding image set I1 is obtained. V Ti ={I1 V1 Ti I1 V2 Ti , ..., I1 Vj Ti , ..., I1 Vn Ti}; and, with I2 Ti For a sliding window, use I2 Ti By sliding along the y-axis of the second target image according to △d, the corresponding vertical sliding image set I2 is obtained. V Ti ={I2 V1 Ti I2 V2 Ti , ..., I2 Vj Ti , ..., I2 Vn Ti};I1 Vj Ti For I1 V Ti The j-th image in I2 Vj Ti For I2 V Ti The j-th image in the dataset, where j ranges from 1 to n;

[0008] S400, Obtain the first sub-image set I1 = {I11, I12, ..., I1...} r , ..., I1 h}=(I1 V T1 ∪I1 V T2 ∪……∪I1 VTi …∪I1 V Tn ), and obtaining a second sub-image set I2 = {I21, I22, …, I2 r , …, I2 h} = (I2 V T1 ∪I2 V T2 ∪ … ∪I2 V Ti … ∪I2 V Tn ), I1 r is the rth image in I1, I2 r is the rth image in I2, r is 1 to h, h = n*n;

[0009] S500, taking I1 r as the source extended image, I1 r is extended by △d in one of the x-axis direction and the y-axis direction to both sides while keeping the size unchanged in the other direction, to obtain the corresponding extended image set I1 E r = {I1 E r1 , I1 E r2 , …, I1 E ru , …, I1 E rf(r)}, and taking I2 r as the source extended image, I2 r is extended by △d in one of the x-axis direction and the y-axis direction to both sides while keeping the size unchanged in the other direction, to obtain the corresponding extended image set I2 E r = {I2 E r1 , I2 E r2 , …, I2 E ru , …, I2 E rf(r)}; I1 E ru is the u-th extended image in I1 E r , I2 E ru is the u-th extended image in I2 E r , I1 E r1 is I1r , I2 E r1 is I2 r , u is 1 to f(r), f(r) is the number of extended images in the extended image set; S600, based on I1 E r and I2 E r , obtain the rth similarity set S 12 r ={S 12 r1 , S 12 r2 , …, S 12 ru , …, S 12 rf(r)}, S 12 r 12 ru is the similarity between I1 E ru and I2 E ru ;

[0010] S700, obtain the similarity corresponding to max(S 12 1, S 12 2, …, S 12 r , …, S 12 h ) as the similarity between the first image and the second image.

[0011] The embodiment of the application further provides a non-transitory computer readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the foregoing method.

[0012] The embodiment of the application further provides an electronic device, comprising a processor and the foregoing non-transitory computer readable storage medium.

[0013] The application has at least the following beneficial effects:

[0014] ​The method for determining image similarity provided by the embodiment of the present application firstly performs sliding on two images to be compared according to a set sliding step based on a set basic detection window, to obtain a plurality of sliding images, then, for each sliding image, gradually expands along the x-axis direction and the y-axis direction respectively according to the set sliding step, to finally obtain a plurality of sub-images, then, respectively obtains the similarity of the corresponding sub-images of the two images to be compared, and takes the maximum of the similarities of all the sub-images as the similarity of the two images to be compared. The sub-image of the present application is obtained by traversing the regions of different positions and different sizes of the two images, thus, the problem of inaccurate similarity judgment caused by spatial difference of image constituent elements and the like can be avoided, and the accuracy of image similarity calculation can be improved. BRIEF DESCRIPTION OF DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.

[0016] Figure 1 The flow chart of the method for determining image similarity provided by the embodiment of the present application.

[0017] Figure 2 The schematic diagram for obtaining the set of basic sliding images.

[0018] Figure 3 The schematic diagram for obtaining the set of sub-region images. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings of the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present application.

[0020] The embodiment of the present application provides a method for determining image similarity, as shown in the figure, the method can include the following steps: Figure 1

[0021] S100, pre-processes a first image and a second image to be compared, to obtain a first binary image and a second binary image with a preset size G, as a first target image and a second target image respectively, G=m*m pixels, and m is a set pixel value.

[0022] ​In this embodiment of the invention, the first and second images to be compared are preprocessed, including adjusting the two images to a uniform size and performing binarization. Those skilled in the art will understand that any binarized image with a preset size G obtained by adjusting two images to a uniform size and performing binarization falls within the protection scope of this invention. In this embodiment of the invention, because the images are binarized, only structural information is retained, thus making subsequent comparisons of image structural similarity independent of color.

[0023] In this embodiment of the invention, m can be set based on actual needs. In one illustrative embodiment, m = 64 pixels.

[0024] S200, obtain a first basic detection window W1 from the first target image, and use W1 as a sliding window to slide W1 along the x-axis direction of the first target image according to a set sliding step size Δd, to obtain the corresponding basic sliding image set I1. T ={I1 T1 I1 T2 , ..., I1 Ti , ..., I1 Tn}; and obtain a second basic detection window W2 from the second target image, and use W2 as a sliding window to slide W2 along the x-axis of the second target image according to △d to obtain the corresponding basic sliding image set I2. T ={I2 T1 I2 T2 , ..., I2 Ti , ..., I2 Tn}; where W1 and W2 are both a*a pixels in size, a = m*k, and k is a preset coefficient, 0 < k < 1; I1 Ti For I1 T The i-th image in the dataset, I1 T1 The coordinates of the top left corner are the same as the coordinates of the top left corner of the first target image, I2 Ti For I2 T The i-th image in the dataset, I2 T1 The coordinates of the top-left corner of the image are the same as those of the top-left corner of the second target image. The value of i ranges from 1 to n, where n is the number of images in the basic sliding image set. In one illustrative embodiment, n satisfies the following condition: (n-1)*△d=ma.

[0025] Specifically, such as Figure 2 As shown, W1 is placed at the top left corner of the first target image as the first sliding image, that is, the top left corner coordinate of W1 is the same as the top left corner coordinate of the first target image. Then, the first sliding image is moved to the right by △d pixels along the x-axis to obtain the second sliding image, and so on, to obtain the corresponding n sliding images.

[0026] Similarly, W2 is placed at the top left corner of the second target image as the first sliding image, that is, the top left corner coordinate of W2 is the same as the top left corner coordinate of the second target image. Then, the first sliding image is moved to the right by Δd pixels along the x-axis to obtain the second sliding image, and so on, to obtain the corresponding n sliding images.

[0027] Therefore, we can know that the i-th image Ig in the basic sliding image set Ti The size is equal to the size of the corresponding base detection window, and g takes the value of 1 or 2, and Ig Ti The coordinates of the four vertices satisfy the following: the x-coordinate of the top-left vertex is... gTi L1 = (i-1)*△d, where y is the ordinate of the top-left vertex. gTi L1 =0; x-coordinate of the top right vertex gTi R1 = a + (i-1) * △d, where y is the ordinate of the top right vertex. gTi R1 =0; x-coordinate of the lower left vertex gTi L2 = (i-1)*△d, where y is the ordinate of the lower left vertex. gTi L2 =a; x-coordinate of the lower right vertex gTi R2 = a + (i-1) * △d, where y is the ordinate of the lower right vertex. gTi R2 =a.

[0028] In this embodiment of the invention, △d can be set according to actual needs. In one illustrative embodiment, △d = 2 pixels.

[0029] S300, with I1 Ti For a sliding window, set I1 Ti By sliding along the y-axis of the first target image according to △d, the corresponding vertical sliding image set I1 is obtained. V Ti ={I1 V1 Ti I1 V2 Ti , ..., I1 Vj Ti , ..., I1 Vn Ti}; and, with I2 Ti For a sliding window, use I2 Ti By sliding along the y-axis of the second target image according to △d, the corresponding vertical sliding image set I2 is obtained. VTi ={I2 V1 Ti I2 V2 Ti , ..., I2 Vj Ti , ..., I2 Vn Ti};I1 Vj Ti For I1 V Ti The j-th image in I2 Vj Ti For I2 V Ti The j-th image in the dataset, where j can range from 1 to n.

[0030] Specifically, such as Figure 3 As shown, with Ig Ti As the first vertical sliding image, i.e., I1 V1 Ti For I1 Ti I2 V1 Ti For I2 Ti Next, the first vertical sliding image is moved downwards by Δd pixels along the y-axis to obtain the second vertical sliding image, and so on, to obtain the corresponding n vertical sliding images. S400, obtain the first sub-image set I1 = {I11, I12, ..., I1...} r , ..., I1 h}=(I1 V T1 ∪I1 V T2 ∪……∪I1 V Ti ……∪I1 V Tn ), and obtain the second sub-image set I2 = {I21, I22, ..., I2} r , ..., I2 h}=(I2 V T1 ∪I2 V T2 ∪……∪I2 V Ti ...∪I2 V Tn ), I1 r Let I1 be the r-th image, and I2 be the r-th image. r Let r be the r-th image in I2, where r ranges from 1 to h, and h = n*n.

[0031] S500, with I1 r To expand the source image, use I1r In one of the x-axis direction and the y-axis direction, the expansion is simultaneously performed to both sides with a step of △d, while keeping the size unchanged in the other direction, to obtain a corresponding expansion image set I1 E r = {I1 E r1 , I1 E r2 , …, I1 E ru , …, I1 E rf(r)} and I2 r is the source expansion image, I2 r In one of the x-axis direction and the y-axis direction, the expansion is simultaneously performed to both sides with a step of △d, while keeping the size unchanged in the other direction, to obtain a corresponding expansion image set I2 E r = {I2 E r1 , I2 E r2 , …, I2 E ru , …, I2 E rf(r)}; I1 E ru is the u-th expansion image in I1 E r , I2 E ru is the u-th expansion image in I2 E r , I1 E r1 is I1 r , I2 E r1 is I2 r , and u takes values from 1 to f(r), f(r) is the number of expansion images in the expansion image set.

[0032] Further, in the embodiment of the present application, each expansion image set Ig E r is obtained based on the following steps:

[0033] S510, taking Ig r as the source expansion image, expanding the left and right sides of Ig r along the x-axis direction of the corresponding target image by △d step by step to obtain a corresponding first expansion image set Ig E1 r .

[0034] S520, taking Ig rAs the source extended image, Ig r The top and bottom sides are expanded stepwise along the y-axis of the corresponding target image according to △d to obtain the corresponding second expanded image set Ig. E2 r .

[0035] S530, Get Ig E r =Ig E1 r ∪Ig E2 r .

[0036] Those skilled in the art will understand that S510 and S520 can be executed simultaneously or sequentially, and the present invention does not impose any particular limitation.

[0037] Furthermore, S510 may specifically include:

[0038] S5101, set the x-axis direction expansion number variable c = 1.

[0039] S5102, for Ig r The c-th expansion along the x-axis is performed on both sides to obtain the corresponding expanded image Pg. rc Among them, Pg rc The distance between the left side of the image and the left side of the corresponding target image (DXg) 1 rc =DXg r 1 (c-1) -△d, Pg rc The distance DXg between the right side of the target image and the right side of the corresponding target image. 2 rc =DXg r 2 (c-1) -△d,DXg r 1 (c-1) For Ig r The target extended image Pg is obtained by extending the left and right sides along the x-axis for the (c-1)th time. A r(c-1) The distance between the left side of the DXG image and the left side of the corresponding target image. 2 r(c-1) For Pg A r(c-1) The distance between the right side of the image and the right side of the corresponding target image.

[0040] The person skilled in the art knows that the distance between the left side of the extended image and the left side of the corresponding target image can be equal to the value of the left side horizontal coordinate of the extended image, and the distance between the right side of the extended image and the right side of the corresponding target image can be equal to the difference between m and the right side horizontal coordinate of the extended image.

[0041] S5104, if DXg 1 rc ≤0, or DXg 2 rc ≤0, S5106 is executed; if DXg 1 rc >0, and DXg 2 rc >0, S5105 is executed.

[0042] In the embodiment of the present application, if DXg 1 rc ≤0, or DXg 2 rc ≤0, it indicates that the left side or the right side of the current extended image has reached or exceeded the left side or the right side of the corresponding target image, and considering that each source extended image is obtained by sliding the sliding window according to the set step size, it is unnecessary to continue the extension, and the extension needs to be stopped. If DXg 1 rc >0, and DXg 2 rc >0, it indicates that the left and right sides of the current extended image have not reached the left and right sides of the corresponding target image, and the extension needs to be continued until reaching or exceeding.

[0043] S5105, Pg rc is set as the target extended image Pg A rc of the cth time of extension, and is stored in the current first target extended image set; c is set as c+1, and S5102 is executed; the initial value of the first target extended image set is Ig r .

[0044] S5106, the current first target extended image set is set as Ig E1 r .

[0045] Further, S520 can specifically include:

[0046] S5201, a y-axis direction extension times variable d is set as 1.

[0047] S5202, the upper and lower sides of Ig r are extended along the y-axis direction for the dth time to obtain the corresponding extended image Pg rd , wherein Pgrd the distance between the upper side of the corresponding target image and the upper side of the target image 1 rd = DYg r 1 (d-1) -△d, Pg rd the distance between the lower side of the corresponding target image and the lower side of the target image 2 rd = DYg r 2 (d-1) -△d, DYg r 1 (d-1) is the target image obtained by expanding the upper and lower sides of Ig r along the y-axis direction for the d-1th time A r(d-1) the distance between the upper side of the corresponding target image and the upper side of the target image, DYg 2 r(d-1) is the target image Pg A r(d-1) the distance between the lower side of the corresponding target image and the lower side of the target image.

[0048] The distance between the upper side of the corresponding target image and the upper side of the target image can be equal to the value of the vertical coordinate of the upper side of the target image, and the distance between the lower side of the corresponding target image and the lower side of the target image can be equal to the difference between m and the vertical coordinate of the lower side of the target image, which is known to those skilled in the art.

[0049] S5204, if DYg 1 rd ≤0, or DYg 2 rd ≤0, S5206 is executed; if DYg 1 rd >0, and DYg 2 rd >0, S5205 is executed.

[0050] In the embodiments of the present application, if DYg 1 rd ≤0, or DYg 2 rd ≤0, it indicates that the upper side or the lower side of the current target image has reached or exceeded the upper side or the lower side of the corresponding target image, and considering that each source target image is obtained by sliding the sliding window according to the set step size, it is unnecessary to continue to expand. If DYg 1 rd >0, and DYg 2 rd> 0, which means that the upper and lower sides of the current extended image do not reach the upper and lower sides of the corresponding target image, and the extension needs to be continued until it reaches or exceeds.

[0051] S5205, setting Pg rd as the target extended image of the dth extension A rd and storing it in the current second target extended image set; setting d = d + 1 and performing S5202; the initial value of the second target extended image set is Ig r ;

[0052] S5206, taking the current second target extended image set as Ig E2 r .

[0053] S600, obtaining the rth similarity set S E r and I2 E r based on I1 12 r = {S 12 r1 , S 12 r2 , …, S 12 ru , …, S 12 rf(r)} where the uth similarity S 12 r in S 12 ru is the similarity between I1 E ru and I2 E ru .

[0054] In the embodiments of the present application, the similarity between I1 E ru and I2 E ru may be obtained based on existing similarity algorithms, for example, the similarity between the direction gradient histogram features of two images or the structural similarity between two images.

[0055] S700, taking the similarity corresponding to max (S 12 1, S 12 2, …, S 12 r , …, S 12 h ) as the similarity between the first image and the second image.

[0056] That is, S12 1, S 12 2, …, S 12 r , …, S 12 h the maximum similarity in the group of {S1, S2, …, S

[0057] Further, in the embodiment of the present application, a is set to make the obtained sub-region contain partial structure information of the image and not occupy most or even the whole size of the image. Specifically, a can be obtained based on the following steps:

[0058] S10, set a candidate data set F = {f1, f2, …, f q , …, f z}, the qth candidate value f q = q*f0, f0 is a set initial value, q takes values from 1 to z, z is a preset candidate value number, which can be set based on actual needs, as long as z*f0 < m is met.

[0059] In the embodiment of the present application, f0 can be a self-defined value, which can be an integer divisible by m. When m = 64, f0 can be set to 8.

[0060] S20, set f q *f q as the size of the basic detection window, and obtain the similarity SI q between the first sample image and the second sample image according to S100 to S600.

[0061] In the embodiment of the present application, the first sample image and the second sample image are two images with known high similarity. In an illustrative embodiment, the first sample image and the second sample image can be APP icons.

[0062] S30, obtain the candidate value corresponding to the basic detection window corresponding to max(SI1, SI2, …, SI q , …, SI z ) as a, that is, obtain the candidate value with the maximum accuracy as a.

[0063] In the embodiment of the present application, in the case of m = 64, a = 32 is obtained according to S10 to S30.

[0064] One specific application scenario of the method for determining the image similarity provided by the embodiments of the present application is to detect a pirated APP icon from a large number of APP icons. Specifically, a library of genuine APP icons can be pre-set, and each APP icon in the icon library is obtained according to the method described in S100 to S500 to obtain a corresponding set of sub-regions, and a feature vector of each sub-region, so that a feature vector of each sub-region of each APP icon is obtained. When it is necessary to determine whether a to-be-detected APP icon is a pirated APP icon, the to-be-detected APP icon is first obtained according to the method described in S100 to S500 to obtain a corresponding set of sub-regions, and a feature vector of each sub-region, then the similarity between the to-be-detected APP icon and each genuine APP icon is obtained according to the method described in S600 and S700, and finally, the maximum value in the obtained similarities is compared with a set similarity threshold value, if the maximum value is greater than the set similarity threshold value, a first prompt information is output, otherwise, a second prompt information is output. The first prompt information is used to represent that the to-be-detected APP icon is suspected to be a pirated APP icon of the genuine APP icon corresponding to the maximum value, and the second prompt information is used to represent that the to-be-detected APP icon is not a pirated APP icon.

[0065] The embodiments of the present application also provide a non-transitory computer readable storage medium, which can be arranged in an electronic device to save at least one instruction or at least one program related to a method in the method embodiments, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided by the above embodiments.

[0066] The embodiments of the present application also provide an electronic device, which comprises a processor and the aforementioned non-transitory computer readable storage medium.

[0067] The embodiments of the present application also provide a computer program product, which comprises program code, and when the program product is run on an electronic device, the program code is used to make the electronic device execute the steps in the method according to various exemplary embodiments of the present application described in the specification.

[0068] Although some specific embodiments of the present application have been described in detail by examples, those skilled in the art should understand that the above examples are only for illustration, but not for limiting the scope of the present application. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the present application. The scope of the present application is defined by the appended claims.

Claims

1. A method of determining image similarity, characterized by, The image is an APP icon, and the method comprises the following steps: S100, pre-processing the first image and the second image to be compared to obtain a first binary image and a second binary image with a preset size G, as a first target image and a second target image respectively, G=m*m pixels, and m is a set pixel value; S200, obtain a first basic detection window W1 from the first target image, and take W1 as a sliding window, slide W1 along the x-axis direction of the first target image according to a set sliding step △d to obtain a corresponding basic sliding image set I1 T ={I1 T1 , I1 T2 , …, I1 Ti , …, I1 Tn}; and obtain a second basic detection window W2 from the second target image, and take W2 as a sliding window, slide W2 along the x-axis direction of the second target image according to △d to obtain a corresponding basic sliding image set I2 T ={I2 T1 , I2 T2 , …, I2 Ti , …, I2 Tn}; wherein the size of W1 and W2 is a×a pixels, a=m×k, k is a preset coefficient, 0 Ti is the i-th image in I1 T , the upper left corner coordinate of I1 T1 is the same as the upper left corner coordinate of the first target image, I2 Ti is the i-th image in I2 T , the upper left corner coordinate of I2 T1 is the same as the upper left corner coordinate of the second target image, and the value of i is 1 to n, and n is the number of images in the basic sliding image set. S300, with I1 Ti as a sliding window, I1 Ti is obtained by sliding along the y-axis direction of the first target image according to △d, to obtain the corresponding longitudinal sliding image set I1 V Ti = {I1 V1 Ti , I1 V2 Ti , …, I1 Vj Ti , …, I1 Vn Ti}; and with I2 Ti as a sliding window, I2 Ti is obtained by sliding along the y-axis direction of the second target image according to △d, to obtain the corresponding longitudinal sliding image set I2 V Ti = {I2 V1 Ti , I2 V2 Ti , …, I2 Vj Ti , …, I2 Vn Ti}; I1 Vj Ti is the jth image in I1 V Ti , I2 Vj Ti is the jth image in I2 V Ti , and j takes values from 1 to n. S400, acquire a first sub-image set I1={I11, I12, …, I1 r , …, I1 h}= (I1 V T1 ∪I1 V T2 ∪…∪I1 V Ti …∪I1 V Tn ), and acquire a second sub-image set I2={I21, I22, …, I2 r , …, I2 h}= (I2 V T1 ∪I2 V T2 ∪…∪I2 V Ti …∪I2 V Tn ), I1 r is the rth image in I1, I2 r is the rth image in I2, r is 1 to h, h=n×n; S500, with I1 r as the source expansion image, I1 r is expanded by a step △d to both sides in one of the x-axis direction and the y-axis direction while keeping the size unchanged in the other direction, to obtain a corresponding expansion image set I1 E r ={I1 E r1 , I1 E r2 , …, I1 E ru , …, I1 E rf(r)}, and with I2 r as the source expansion image, I2 r is expanded by a step △d to both sides in one of the x-axis direction and the y-axis direction while keeping the size unchanged in the other direction, to obtain a corresponding expansion image set I2 E r ={I2 E r1 , I2 E r2 , …, I2 E ru , …, I2 E rf(r)}; I1 E ru is the u-th expansion image in I1 E r , I2 E ru is the u-th expansion image in I2 E r , I1 E r1 is I1 r , I2 E r1 is I2 r , and u takes values from 1 to f(r), where f(r) is the number of expansion images in the expansion image set. S600, based on I1 E r and I2 E r , obtain the rth similarity set S 12 r = {S 12 r1 , S 12 r2 ,..., S 12 ru ,..., S 12 rf(r)}, S 12 r = S 12 ru is a similarity between I1 E ru and I2 E ru ; S700, obtaining max(S 12 1, S 12 2, …, S 12 r , …, S 12 h ) as the similarity between the first image and the second image.

2. The method of claim 1, wherein, each extended image set Ig E r is obtained based on the following steps, g = 1 or 2: S510, expanding Ig r As the source extended image, Ig r is expanded step by step along the x-axis direction of the corresponding target image by △d on the left and right sides, to obtain a corresponding first extended image set Ig E1 r ; S520, Ig r As the source extended image, Ig r is gradually extended along the y-axis direction of the corresponding target image by △d, to obtain a corresponding second extended image set Ig E2 r ; S530, obtaining Ig E r = Ig E1 r ∪ Ig E2 r .

3. The method of claim 2, wherein, S510 specifically comprises: S5101, setting an x-axis direction expansion frequency variable c=1; S5102, for Ig r The c-th expansion along the x-axis is performed on both sides to obtain the corresponding expanded image Pg. rc Among them, Pg rc The distance between the left side of the image and the left side of the corresponding target image (DXg) 1 rc =DXg r 1 (c-1) -△d, Pg rc The distance DXg between the right side of the target image and the right side of the corresponding target image. 2 rc =DXg r 2 (c-1) -△d,DXg r 1 (c-1) For Ig r The target extended image Pg is obtained by extending the left and right sides along the x-axis for the (c-1)th time. A r(c-1) The distance between the left side of the DXG image and the left side of the corresponding target image. 2 r(c-1) For Pg A r(c-1) The distance between the right side of the image and the right side of the corresponding target image; S5104, if DXg 1 rc ≤ 0, perform S5106; if DXg 2 rc ≤ 0, perform S5106; if DXg 1 rc > 0, and DXg 2 rc > 0, perform S5105; S5105, set Pg rc as the target expansion image of the cth expansion A rc and stored in the current first target expansion image set; set c = c + 1, execute S5102; the initial value of the first target expansion image set is Ig r ; S5106, the current first target extended image set is taken as Ig E1 r .

4. The method of claim 2, wherein, S520 specifically comprises: S5201, setting a y-axis direction expansion frequency variable d=1; S5202, for Ig r The top and bottom sides are expanded along the y-axis for the dth time to obtain the corresponding expanded image Pg. rd Among them, Pg rd The distance DYg between the top edge of the target image and the top edge of the corresponding target image. 1 rd =DYg r 1 (d-1) -△d, Pg rd The distance DYg between the bottom edge of the image and the bottom edge of the corresponding target image. 2 rd =DYg r 2 (d-1) -△d,DYg r 1 (d-1) For Ig r The target extended image Pg is obtained by extending the top and bottom sides along the y-axis for the (d-1)th time. A r(d-1) The distance between the top edge of DYg and the top edge of the corresponding target image. 2 r(d-1) For Pg A r(d-1) The distance between the bottom of the image and the bottom of the corresponding target image; S5204, if DYg 1 rd ≤ 0, or DYg 2 rd ≤ 0, perform S5206; if DYg 1 rd > 0, and DYg 2 rd > 0, perform S5205; S5205, set Pg rd as the target expansion image of the dth expansion A rd and stored in the current second target expansion image set; set d = d + 1, and execute S5202; the initial value of the second target expansion image set is Ig r ; S5206, the current second target extended image set is taken as Ig E2 r .

5. The method of claim 1, wherein, a is obtained based on the following steps: S10, setting a candidate data set F={f1, f2, …, f q , …, f z}, the qth candidate value f q =q×f0, f0 is a set initial value, q is 1 to z, and z is a preset candidate value number; S20, f q x f q The size of the base detection window, and the similarity SI between the first sample image and the second sample image is obtained according to S100 to S600 q ; S30, obtaining the candidate value corresponding to the basic detection window corresponding to max (SI1, SI2, …, SIn) as a. q , …, SI z n) as a.

6. The method of claim 1, wherein, △d=2 pixels.

7. The method of claim 1, wherein, m=64。 8. The method of claim 7, wherein, a=32。 9.A non-transitory computer-readable storage medium having stored therein at least one instruction or at least one piece of program, characterized in that, The at least one instruction or the at least one program is loaded and executed by the processor to realize the method as claimed in any one of claims 1-8.

10. An electronic device, comprising: It comprises a processor and a non-transient computer readable storage medium as claimed in claim 9.

Citation Information

Patent Citations

  • Image similarity judgment method, electronic equipment and storage medium

    CN109948653A

  • Image processing method and device, electronic equipment and medium

    CN116778197A