Picture structure comparison method and apparatus
By comparing the positional distribution of target pixels in an image, this method solves the problem of existing technologies being unable to identify consistent image structures, enabling accurate judgment of image structure and making it suitable for structural comparison in graphical user interfaces.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2026-03-31
AI Technical Summary
Current technology cannot determine whether the structures of images are consistent; it can only assess the overall similarity of images but cannot identify structural differences.
The consistency of image structures is determined by comparing the positional distribution of target pixels in two images, where the target pixel has the same pixel value as its neighboring pixels.
It achieves accurate judgment of image structure, can identify whether the image structure is consistent, and is suitable for structural comparison in graphical user interfaces.
Smart Images

Figure CN115393607B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of image processing, and more particularly to an image structure comparison method, apparatus, electronic device, and machine-readable storage medium. Background Technology
[0002] In practical applications, the similarity between images is usually assessed by finding a pattern in the pixels of the images to be evaluated, and then comparing the similarity between the images based on the pattern.
[0003] For example, taking a first image and a second image that need to be evaluated for similarity as an example, the following two methods are usually used to evaluate the similarity between the first image and the second image:
[0004] 1. Mean Hash Algorithm: Calculate the average pixel value of the image, then iterate through each pixel in the image, and calculate the relationship between the pixel value of each pixel and the average pixel value of the image. If the pixel value of a pixel is greater than the average pixel value, the corresponding statistical result for that pixel is 1; otherwise, if the pixel value of a pixel is less than or equal to the average pixel value, the corresponding statistical result for that pixel is 0. The above statistical results are then combined into a hash sequence to describe the relationship between the pixel values of each pixel in the image and the average pixel value of the image.
[0005] Based on this method, the first hash sequence corresponding to the first image and the second hash sequence corresponding to the second image can be obtained respectively. Then, the similarity between the first image and the second image can be evaluated by calculating the Hamming distance between the first hash sequence and the second hash sequence.
[0006] The smaller the Hamming distance between the first hash sequence and the second hash sequence, the higher the similarity between the first image and the second image.
[0007] 2. Differential Hash Algorithm: Traverse each pixel in the image, and calculate the relationship between the pixel value of the pixel preceding the target pixel in each row and the pixel value of the target pixel. If the pixel value of the target pixel is greater than the pixel value of the target pixel, the corresponding statistical result is 1; otherwise, if the pixel value of the target pixel is less than or equal to the pixel value of the target pixel, the corresponding statistical result is 0. Combine the above statistical results into a hash sequence that describes the relationship between the pixel value of each pixel in the image and the pixel value of the pixel preceding it.
[0008] Based on this method, the first hash sequence corresponding to the first image and the second hash sequence corresponding to the second image can be obtained respectively. Then, the similarity between the first image and the second image can be evaluated by calculating the Hamming distance between the first hash sequence and the second hash sequence.
[0009] The smaller the Hamming distance between the first hash sequence and the second hash sequence, the higher the similarity between the first image and the second image.
[0010] However, while the above method can determine whether there are differences between the first image and the second image as a whole, it cannot determine whether there are differences in the image structure of the images. Summary of the Invention
[0011] This application provides a method for comparing image structures, the method comprising:
[0012] Get the first image and the second image;
[0013] The first position distribution and the second position distribution of the target pixels contained in the first image and the second image are determined respectively; wherein the pixel value of the target pixel is equal to that of other pixels adjacent to it; the first position distribution and the second position distribution are compared, and the image structure of the first image and the second image is determined based on the comparison result.
[0014] Optionally, before determining the first and second position distributions of the target pixels contained in the first and second images respectively, the method further includes: forming a first sequence of pixel values to describe the structural features of the pixels contained in the first image according to the order of the pixels contained in the first image; and forming a second sequence of pixel values to describe the structural features of the pixels contained in the second image according to the order of the pixels contained in the second image.
[0015] Optionally, determining the first and second position distributions of the target pixels contained in the first and second images respectively includes: traversing each pixel value in the first sequence, counting whether there are other pixel values in the first sequence that are adjacent to the traversed pixel value and have the same size; if so, determining the pixel corresponding to the pixel value as the target pixel in the first image, and determining the statistical result corresponding to the pixel value as the first statistical result; if not, determining the statistical result corresponding to the pixel value as the second statistical result; and arranging the statistical results corresponding to each pixel value contained in the first sequence into a third number according to the order of the pixel values in the first sequence. The method involves: 1) traversing the second sequence of pixel values to obtain a first positional distribution describing the target pixel in the first image; 2) counting the number of other pixel values in the second sequence that are adjacent to the traversed pixel value and have the same size; 3) determining the pixel corresponding to the traversed pixel value as the target pixel in the second image and determining the statistical result corresponding to the pixel value as the first statistical result; 4) organizing the statistical results corresponding to each pixel value in the second sequence into a fourth sequence according to the order of the pixel value in the second sequence to obtain a second positional distribution describing the target pixel in the second image.
[0016] Optionally, other pixels adjacent to the target pixel include: other pixels at the position before the target pixel, and / or other pixels at the position after the target pixel.
[0017] Optionally, comparing the first position distribution and the second position distribution, and determining whether the image structures of the first image and the second image are consistent based on the comparison result, includes: comparing the statistical results at corresponding positions in the third sequence and the fourth sequence; if the statistical results at corresponding positions in the third sequence and the fourth sequence are consistent, then the image structures of the first image and the second image are consistent; otherwise, the image structures of the first image and the second image are inconsistent.
[0018] Optionally, the first statistical result is 0 or 1; the second statistical result is 1 or 0; the third and fourth sequences are both binary strings composed of the values 0 and 1; comparing the statistical results at corresponding positions in the third and fourth sequences; if the statistical results at corresponding positions in the third and fourth sequences are consistent, then the image structures of the first and second images are determined to be consistent; otherwise, the image structures of the first and second images are determined to be inconsistent, including: calculating the Hamming distance between the third and fourth sequences; if the calculated Hamming distance is 0, then the image structures of the first and second images are determined to be consistent; otherwise, the image structures of the first and second images are determined to be inconsistent.
[0019] Optionally, the first image includes an interface image corresponding to the graphical user interface output by the software under test to the user; the second image includes a expected interface image corresponding to the graphical user interface of the software under test.
[0020] Optionally, the first image and the second image have the same resolution.
[0021] Optionally, the resolution may include 8*8 pixels or 16*16 pixels.
[0022] This application also provides an image structure comparison device, the device comprising:
[0023] The image acquisition module is used to acquire the first image and the second image.
[0024] The position distribution determination module is used to determine the first position distribution and the second position distribution of the target pixels contained in the first image and the second image, respectively; wherein the pixel value of the target pixel is equal to that of other pixels adjacent to it.
[0025] The comparison module is used to compare the first position distribution and the second position distribution, and determine whether the image structures of the first image and the second image are consistent based on the comparison result.
[0026] Optionally, the position distribution determination module is further configured to, according to the order of each pixel contained in the first image, form a first sequence of pixel values to describe the structural features of the pixels contained in the first image; and, according to the order of each pixel contained in the second image, form a second sequence of pixel values to describe the structural features of the pixels contained in the second image.
[0027] Optionally, the position distribution determination module is further configured to traverse each pixel value in the first sequence, count whether there are other pixel values in the first sequence that are adjacent to the traversed pixel value and have the same size; if so, determine the pixel corresponding to the pixel value as the target pixel in the first image, and determine the statistical result corresponding to the pixel value as the first statistical result; if not, determine the statistical result corresponding to the pixel value as the second statistical result; and arrange the statistical results corresponding to each pixel value in the first sequence into a third sequence according to the order of the pixel value in the first sequence, so as to obtain a sequence describing the target pixel in the first image. The first position distribution; and, traversing each pixel value in the second sequence, counting whether there are other pixel values in the second sequence that are adjacent to the traversed pixel value and have the same size; if they exist, then the pixel corresponding to the pixel value is determined as the target pixel in the second image, and the statistical result corresponding to the pixel value is determined as the first statistical result; if they do not exist, then the statistical result corresponding to the pixel value is determined as the second statistical result; and the statistical results corresponding to each pixel value contained in the second sequence are arranged into a fourth sequence according to the order of the pixel value in the second sequence, so as to obtain the second position distribution used to describe the target pixel in the second image.
[0028] Optionally, other pixels adjacent to the target pixel include: other pixels at the position before the target pixel, and / or other pixels at the position after the target pixel.
[0029] Optionally, the comparison module is further configured to compare the statistical results at corresponding positions in the third and fourth sequences; if the statistical results at corresponding positions in the third and fourth sequences are consistent, then the image structures of the first image and the second image are determined to be consistent; otherwise, the image structures of the first image and the second image are determined to be inconsistent.
[0030] Optionally, the first statistical result is 0 or 1; the second statistical result is 1 or 0; the third and fourth sequences are both binary strings composed of the values 0 and 1;
[0031] The comparison module is further configured to calculate the Hamming distance between the third sequence and the fourth sequence; if the calculated Hamming distance is 0, it is determined that the image structures of the first image and the second image are consistent; otherwise, it is determined that the image structures of the first image and the second image are inconsistent.
[0032] Optionally, the first image includes an interface image corresponding to the graphical user interface output by the software under test to the user; the second image includes a expected interface image corresponding to the graphical user interface of the software under test.
[0033] Optionally, the first image and the second image have the same resolution.
[0034] Optionally, the resolution may include 8*8 pixels or 16*16 pixels.
[0035] The above technical solutions have the following technical effects:
[0036] In this application, by comparing whether the distribution of target pixels in two images is consistent, wherein the pixel value of the target pixel is equal to that of other pixels adjacent to it, it can be determined whether the image structure of the two images is consistent. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating an exemplary embodiment of an image structure comparison method;
[0038] Figure 2 This is a schematic diagram illustrating an image structure comparison method as an exemplary embodiment;
[0039] Figure 3 This is a schematic diagram illustrating an image structure comparison method as an exemplary embodiment;
[0040] Figure 4 This is a schematic diagram of the structure of an electronic device containing an image structure comparison device, as shown in an exemplary embodiment.
[0041] Figure 5 This is a block diagram illustrating an image structure comparison device as an exemplary embodiment. Detailed Implementation
[0042] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0043] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0044] When evaluating the similarity of multiple images, the common practice is to find patterns in each image and then compare the similarity between these patterns to assess the overall similarity between the images.
[0045] The patterns contained in the above images may include the patterns between the pixels contained in the images.
[0046] In practical applications, the patterns among the pixels in the aforementioned image can include the positional patterns among the pixels; and / or the magnitude patterns among the pixel values; and / or a combination of both. Examples include mean hashing and difference hashing algorithms.
[0047] The above method can be used to evaluate the similarity between multiple target images to determine whether there are at least two completely identical images among them.
[0048] When testing the software under test, it is necessary to determine whether the image structure of the graphical user interface corresponding to the graphical user interface output by the software under test to the user is consistent with the image structure of the expected interface image corresponding to the graphical user interface of the software under test.
[0049] In this process, determining whether the image structure of the interface image is consistent with that of the expected interface image is to further determine whether the graphical user interface output by the software under test to the user is consistent with the interface structure of the expected graphical user interface of the software under test.
[0050] In practical applications, users can determine whether the interface structure of the user interface of the software under test meets the expected results by comparing the interface image corresponding to the graphical user interface output by the software under test to the user and the image structure of the expected user interface of the software under test. Then, other tests can be performed.
[0051] There may be differences in image color and image structure between the determined image with the test software user interface and the predicted image with the test software user interface.
[0052] For example, the differences in graphic colors mentioned above can be reflected in: the different background colors of the user interface of the aforementioned testing software, the different theme colors of the user interface of the aforementioned testing software, and the different graphic colors included in the graphical user interface of the aforementioned testing software.
[0053] The differences in the aforementioned image structure can be reflected in the different interface structures of the user interface of the software under test.
[0054] When comparing the structural features of the aforementioned user interface image with the predicted user interface image of the aforementioned software under test, the method described above, which assesses the similarity between the actual interface image and the expected interface image, obviously cannot determine whether the image structures are consistent. Therefore, the above method is not applicable to this scenario and cannot solve the problem of whether the image structures are consistent in this scenario.
[0055] In view of this, this specification aims to propose a method to determine whether the image structures of the two images are consistent by comparing whether the positional distribution of target pixels in two images is consistent, wherein the pixel value of the target pixel is equal to that of other pixels adjacent to it.
[0056] In implementation, a first image and a second image whose image structures need to be determined to be consistent can be obtained respectively. Then, the positional distribution of the target pixels contained in the images can be determined, wherein the pixel value of the target pixel and its adjacent pixels are equal, thereby determining the first positional distribution of the target pixel in the first image and the second positional distribution of the target pixel in the second image. The first positional distribution and the second positional distribution are compared, and the image structures of the first image and the second image can be determined based on the comparison result.
[0057] Therefore, by comparing whether the distribution of target pixels in two images is consistent, where the target pixel has the same pixel value as its neighboring pixels, it is possible to determine whether the image structures of the two images are consistent.
[0058] The present application will now be described through specific embodiments and in conjunction with specific application scenarios.
[0059] Please see Figure 1 , Figure 1 This is a flowchart illustrating an exemplary embodiment of an image structure comparison method, in which the method performs the following steps:
[0060] S102, Obtain the first image and the second image.
[0061] The number of images obtained is not limited in this specification. It can be two images, three images, etc. Since it involves image comparison, the minimum number of images obtained is two. In this specification, two images are obtained, namely the first image and the second image, to illustrate the image structure comparison method.
[0062] In practical applications, the aforementioned first image and the method for obtaining the aforementioned second image may include images uploaded by users, screenshots located on computing devices, etc., and this specification does not impose any other restrictions on them.
[0063] In one embodiment shown, the first image may include an interface image corresponding to the graphical user interface output by the software under test to the user; the second image may include a anticipated interface image corresponding to the graphical user interface of the software under test.
[0064] The graphical user interface (GUI) of the software under test can be screenshotted to obtain the interface image corresponding to the GUI as the first image; the expected interface image corresponding to the GUI of the software under test uploaded by the user can be obtained as the second image.
[0065] The image size, image quality, image color, and image resolution of the first image and the second image may be the same or different. This embodiment does not impose any other limitations on this.
[0066] In one embodiment shown, the first image and the second image have the same resolution.
[0067] Same resolution means that the number of pixels in the first image and the second image above are equal in both the horizontal and vertical directions.
[0068] In practical applications, if the resolution of the first image and the second image are equal, then step 102 is executed directly to obtain the first image and the second image.
[0069] If the resolutions of the first image and the second image are not equal, then before performing step 102, the following may also be included:
[0070] Obtain the first original image corresponding to the first image, and obtain the second original image corresponding to the second image, wherein the first original image and the second original image have different resolutions;
[0071] Then, the first original image and the second original image are respectively normalized to obtain a first image and a second image with the same image resolution.
[0072] In practical applications, the shapes of the first image and the second image can be regular shapes with the same resolution or irregular shapes with the same resolution. In this specification, the shapes of the first image and the second image are not limited, as long as the first image and the second image have the same resolution.
[0073] For example, it can be a circle, a triangle, a parallelogram, a rectangle, a square, a polygon, or an irregular polygon.
[0074] In this embodiment, by acquiring standardized images, it is more convenient and faster to compare the features of the pixels contained in the images, especially to facilitate the determination of the position distribution of the target pixels in step 104.
[0075] In one embodiment shown, the same resolution described above may include 8*8 pixels or 16*16 pixels.
[0076] For example, see Figure 2 , Figure 2 This is a schematic diagram illustrating an image structure comparison method as an exemplary embodiment.
[0077] like Figure 2 As shown in a, Figure 2 'a' refers to the first image obtained above. The resolution of the first image is 3*3, and the pixel values of each pixel in the first image are: a1, a2, a3, ..., a9.
[0078] like Figure 2 As shown in b, Figure 2 b represents the second image obtained above. The resolution of the second image is 3*3, and the pixel values of each pixel in the second image are: b1, b2, b3, ..., b9.
[0079] In practical applications, the resolution of the first and second images mentioned above is not limited in this specification. Users can set the resolution according to their needs.
[0080] When the resolution value is lower, there are fewer pixels in the image, and fewer pixels are used for comparison. This reduces the amount of data to be compared and allows for faster comparison results. However, the fewer pixels used for comparison can lead to lower comparison accuracy and make the comparison results less accurate.
[0081] When the resolution value is higher, there are more pixels in the image, and more pixels are used for comparison. This leads to more data for comparison and a longer time to obtain the comparison results. However, because there are more pixels for comparison, the comparison precision is higher and the comparison results are more accurate.
[0082] S104, determine the first position distribution and the second position distribution of the target pixels contained in the first image and the second image respectively; wherein, the pixel value of the target pixel is equal to that of other pixels adjacent to its position.
[0083] The positional distribution of the target pixels contained in the first image is determined, and the positional distribution of the target pixels contained in the second image is determined, wherein the target pixels and other pixels adjacent to them have the same pixel value.
[0084] In one embodiment shown, other pixels adjacent to the target pixel position may include: other pixels at the position before the target pixel, and / or other pixels at the position after the target pixel.
[0085] In practical applications, the target pixel includes pixels that are adjacent to it and have the same pixel value.
[0086] For example, please continue to see Figure 2 ,like Figure 2 As shown in a, if the pixel values of the 2nd, 3rd, 5th and 7th pixels in the first image above are equal, i.e., a2 = a3 = a5 = a7, and the adjacent pixels among the pixels with equal pixel values are the 2nd and 3rd pixels, then the 2nd and 3rd pixels in the first image above are target pixels that are adjacent in position and have equal pixel values.
[0087] The target pixel locations in the first image above are: the 2nd and 3rd pixels.
[0088] like Figure 2 As shown in b, if the pixel values of the 2nd, 4th, 5th, and 8th pixels in the second image above are equal, i.e., b2 = b4 = b5 = b8, and the adjacent pixels among the pixels with equal pixel values are the 4th and 5th pixels, then based on the same method, it can be determined that the 4th and 5th pixels in the second image above are the target pixels. Therefore, the position distribution of the target pixels in the second image above is: the 4th and 5th pixels.
[0089] In one embodiment shown, before determining the positional distribution of the target pixels in the image, the method may further include:
[0090] According to the order of the pixels contained in the first image above, the pixel values of the pixels are arranged into a first sequence to describe the structural features of the pixels contained in the first image above;
[0091] Furthermore, according to the order of the pixels contained in the second image, the pixel values of the pixels are arranged into a second sequence to describe the structural features of the pixels contained in the second image.
[0092] The pixel values of the pixels in the aforementioned images are arranged in order within the images to form a sequence describing the structural features of the pixels in the images. A first sequence corresponding to the first image is obtained, and a second sequence corresponding to the second image is obtained.
[0093] In practical applications, the order of the pixels can be from left to right, from right to left, from top to bottom, or from bottom to top in the above images. This manual does not restrict the order of the pixels, and the order can also be customized by the user, as long as the order of the pixels in the first image is the same as the order of the pixels in the second image.
[0094] For example, please refer to Figure 3 , Figure 3 This is a schematic diagram illustrating an image structure comparison method as an exemplary embodiment. For example... Figure 3 As shown in ac, the three possible orders of the pixels in the first image are represented respectively. The dashed lines in the figure indicate the order of the pixels in the image, and the arrows on the dashed lines indicate the direction of the order.
[0095] but, Figure 3 The first sequence corresponding to 'a' could be: {a1, a2, a3, a4, a5, a6, a7, a8, a9};
[0096] but, Figure 3 The first sequence corresponding to b could be: {a1, a2, a3, a6, a5, a4, a7, a8, a9};
[0097] but, Figure 3 The first sequence corresponding to c could be: {a1, a4, a7, a2, a5, a8, a3, a6, a9}.
[0098] For example, please continue to refer to Figure 2 The order of the pixels contained in the first image above and Figure 3For example, the order of 'a' is the same.
[0099] The first sequence is {a1, a2, ..., a9}, and the second sequence is {b1, b2, ..., b9}.
[0100] In one embodiment shown, determining the first position distribution and the second position distribution of target pixels contained in the first image and the second image respectively includes:
[0101] Iterate through each pixel value in the first sequence and count whether there are other pixel values in the first sequence that are adjacent to the traversed pixel value and have the same size. If there are, the pixel corresponding to the pixel value is determined as the target pixel in the first image, and the statistical result corresponding to the pixel value is determined as the first statistical result. If there are no other pixel values, the statistical result corresponding to the pixel value is determined as the second statistical result. Then, the statistical results corresponding to each pixel value in the first sequence are arranged into a third sequence according to the order of the pixel values in the first sequence to obtain a first position distribution describing the target pixel in the first image.
[0102] Furthermore, the system iterates through each pixel value in the second sequence and counts whether there are other pixel values in the second sequence that are adjacent to the traversed pixel value and have the same size. If such a pixel exists, the pixel corresponding to that pixel value is determined as the target pixel in the second image, and the statistical result corresponding to that pixel value is determined as the first statistical result. If such a pixel does not exist, the statistical result corresponding to that pixel value is determined as the second statistical result. The statistical results corresponding to each pixel value contained in the second sequence are then arranged into a fourth sequence according to the order of the pixel values in the second sequence to obtain a second position distribution describing the target pixel in the second image.
[0103] In practical applications, we can count each pixel value in the first sequence above to see if there are other pixel values that are adjacent to the pixel value and have the same pixel value. If there are, the pixel point corresponding to the pixel value is determined as the target pixel point, and the statistical result corresponding to the pixel value is determined as the first statistical result. Otherwise, the statistical result corresponding to the pixel value is determined as the second statistical result.
[0104] Furthermore, the statistical results are arranged in order of the pixel values corresponding to the statistical results in the first sequence to form a third sequence. This third sequence is used to describe the positional distribution of the target pixels in the first image.
[0105] Using the same method, the target pixels in the second image can be determined, as well as the fourth sequence used to describe the positional distribution of the target pixels in the second image.
[0106] The first statistical result mentioned above may include True or False, and correspondingly, the second statistical result mentioned above may include False or True; the first statistical result mentioned above may include "consistent" or "inconsistent", and correspondingly, the second statistical result mentioned above may include "inconsistent" or "consistent"; this application specification does not impose too many restrictions on the values and expression methods of the first and second statistical results mentioned above, as long as they can be used to distinguish the first and second statistical results mentioned above.
[0107] S106, compare the first position distribution and the second position distribution, and determine whether the image structures of the first image and the second image are consistent based on the comparison result.
[0108] By comparing the first position distribution of the target pixels in the first image and the second position distribution of the target pixels in the second image, and based on the comparison result, it is determined whether the image structures of the first image and the second image are consistent.
[0109] The image structure refers to the interface structure on the graphical user interface with the aforementioned testing software.
[0110] In one embodiment shown, comparing the first position distribution and the second position distribution, and determining whether the image structures of the first image and the second image are consistent based on the comparison result, may include:
[0111] Compare the statistical results at corresponding positions in the third and fourth sequences above. If the statistical results at corresponding positions in the third and fourth sequences are consistent, then the image structures of the first and second images are consistent. Otherwise, the image structures of the first and second images are inconsistent.
[0112] In practical applications, we can compare the statistical results of each digit in the third and fourth sequences above to see if they are consistent.
[0113] For example, we can compare whether the statistical result of the first digit in the third sequence is consistent with the statistical result of the first digit in the fourth sequence.
[0114] If the comparison results are consistent, then the image structure of the first image corresponding to the third sequence is consistent with that of the second image corresponding to the fourth sequence; if the comparison results are inconsistent, then the image structure of the first image corresponding to the third sequence is inconsistent with that of the second image corresponding to the fourth sequence.
[0115] In practical applications, if the image structures of the above images are consistent, it indicates that the interface structure of the graphical user interface in the test software is consistent; otherwise, it indicates that the interface structure of the graphical user interface in the test software is inconsistent.
[0116] In one embodiment shown, the first statistical result can be 0 or 1; the second statistical result can be 1 or 0; the third and fourth sequences can both be binary strings composed of the values 0 and 1.
[0117] The above compares the statistical results at corresponding positions in the third and fourth sequences. If the statistical results at corresponding positions in the third and fourth sequences are consistent, then the image structures of the first and second images are determined to be consistent; otherwise, the image structures of the first and second images are determined to be inconsistent, including:
[0118] The Hamming distance between the third and fourth sequences can be calculated.
[0119] If the calculated Hamming distance is 0, it can be determined that the first image and the second image have the same image structure; otherwise, it can be determined that the first image and the second image have different image structures.
[0120] The Hamming distance mentioned above refers to the number of different characters at corresponding positions in two strings of the same length.
[0121] In practical applications, if the above statistical results are set to "0" or "1", then the third and fourth sequences can both be binary strings containing only "1" and "0". Therefore, by calculating the Hamming distance between the third and fourth sequences, it can be quickly determined whether the statistical results at corresponding positions in the third and fourth sequences are consistent, thereby quickly determining whether the image structures of the first and second images are consistent.
[0122] Corresponding to the embodiments of the image structure comparison method described above, this specification also provides an embodiment of an image structure comparison device.
[0123] Please see Figure 4 , Figure 4This is an exemplary embodiment illustrating the hardware structure of an electronic device housing an image structure comparison device. At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, memory 408, and non-volatile memory 410, and may also include other hardware required for various services. One or more embodiments of this specification can be implemented in software, for example, the processor 402 reads the corresponding computer program from the non-volatile memory 410 into memory 408 and then runs it. Of course, besides software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0124] Please see Figure 5 , Figure 5 This is a block diagram illustrating an image structure comparison device as an exemplary embodiment. This webpage classification and recognition device can be applied to, for example... Figure 4 The electronic device shown implements the technical solution of this specification. The image structure comparison device may include:
[0125] Image acquisition module 502 is used to acquire the first image and the second image;
[0126] The position distribution determination module 504 is used to determine the first position distribution and the second position distribution of the target pixels contained in the first image and the second image, respectively; wherein the pixel value of the target pixel is equal to that of other pixels adjacent to its position;
[0127] The comparison module 506 is used to compare the first position distribution and the second position distribution, and determine whether the image structures of the first image and the second image are consistent based on the comparison result.
[0128] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0129] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0130] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0131] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0132] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0133] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0134] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0135] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0136] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0137] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."
[0138] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification.
Claims
1. A method for comparing picture structures, the method comprising: obtaining a first picture and a second picture having the same resolution; determining a first position distribution and a second position distribution of a target pixel point included in the first picture and the second picture respectively, wherein the target pixel point has the same pixel value as other pixel points adjacent to the target pixel point; comparing the first position distribution and the second position distribution, and determining whether the picture structures of the first picture and the second picture are consistent based on a result of the comparison. 2.The method of claim 1, wherein before the determining a first position distribution and a second position distribution of a target pixel point included in the first picture and the second picture respectively, the method further comprises: forming pixel values of each pixel point included in the first picture into a first sequence for describing structural features of the pixel points included in the first picture according to an order of the pixel points; and forming pixel values of each pixel point included in the second picture into a second sequence for describing structural features of the pixel points included in the second picture according to an order of the pixel points. 3.The method of claim 2, wherein the determining a first position distribution and a second position distribution of a target pixel point included in the first picture and the second picture respectively comprises: traversing each pixel value in the first sequence, and counting whether there is another pixel value adjacent to the traversed pixel value and having the same size in the first sequence; if there is, determining the pixel point corresponding to the pixel value as the target pixel point in the first picture, and determining a counting result corresponding to the pixel value as a first counting result; if there is not, determining the counting result corresponding to the pixel value as a second counting result; and forming counting results corresponding to each pixel value in the first sequence into a third sequence according to an order of the pixel values in the first sequence, to obtain the first position distribution of the target pixel point in the first picture; and traversing each pixel value in the second sequence, and counting whether there is another pixel value adjacent to the traversed pixel value and having the same size in the second sequence; if there is, determining the pixel point corresponding to the pixel value as the target pixel point in the second picture, and determining a counting result corresponding to the pixel value as a first counting result; if there is not, determining the counting result corresponding to the pixel value as a second counting result; and forming counting results corresponding to each pixel value in the second sequence into a fourth sequence according to an order of the pixel values in the second sequence, to obtain the second position distribution of the target pixel point in the second picture. 4.The method of claim 1, wherein the other pixel points adjacent to the target pixel point comprise: a pixel point at a position before the target pixel point, and / or a pixel point at a position after the target pixel point. 5. The method of claim 3, wherein the comparing the first position distribution and the second position distribution, and determining whether the picture structure of the first picture and the second picture is consistent based on the result of the comparison comprises: comparing the statistical results at corresponding positions in the third number sequence and the fourth number sequence; if the statistical results at corresponding positions in the third number sequence and the fourth number sequence are consistent, determining that the picture structure of the first picture and the second picture is consistent; otherwise, determining that the picture structure of the first picture and the second picture is inconsistent.
6. The method of claim 5, wherein the first statistical result is 0 or 1; the second statistical result is 1 or 0; the third number sequence and the fourth number sequence are both binary strings composed of the values 0 and 1; and the determining that the picture structure of the first picture and the second picture is inconsistent comprises: calculating the Hamming distance between the third number sequence and the fourth number sequence; and if the calculated Hamming distance is 0, determining that the picture structure of the first picture and the second picture is consistent; otherwise, determining that the picture structure of the first picture and the second picture is inconsistent.
7. The method of claim 1, wherein the first picture comprises an interface image corresponding to a graphical user interface output by a software to be tested; and the second picture comprises an expected interface image corresponding to the graphical user interface of the software to be tested.
8. The method of claim 1, wherein the resolution comprises: 8*8 pixels or 16*16 pixels.
9. A picture structure comparison device, the device comprising: a picture acquisition module configured to acquire a first picture and a second picture having the same resolution; a position distribution determination module configured to determine a first position distribution and a second position distribution of a target pixel point included in the first picture and the second picture, respectively, in the first picture and the second picture, respectively; wherein the target pixel point has a pixel value equal to that of a pixel point adjacent to the target pixel point in position; and a comparison module configured to compare the first position distribution and the second position distribution, and determine whether the picture structure of the first picture and the second picture is consistent based on the result of the comparison. The comparison of the statistical results of the corresponding positions in the third number sequence and the fourth number sequence; if the statistical results of the corresponding positions in the third number sequence and the fourth number sequence are consistent, it is determined that the picture structures of the first picture and the second picture are consistent.
10. An electronic device comprising a communication interface, a processor, a memory, and a bus, the communication interface, the processor, and the memory being connected to each other through the bus; the memory storing machine readable instructions; and the processor executing the method of any one of claims 1 to 8 by invoking the machine readable instructions.
11. A machine readable storage medium storing machine readable instructions, the machine readable instructions, when invoked and executed by a processor, implementing the method of any one of claims 1 to 8.
Citation Information
Patent Citations
Image similarity judgment method, electronic equipment and storage medium
CN109948653A
Image processing method and device, equipment and storage medium
CN114596224A