Image similarity processing method and device for cigarette box recognition processing
By obtaining the brightness components of the image to be identified and judging the distribution of bright points and dark points, the problem of high consumption and reduced accuracy of image similarity comparison in the prior art is solved, and efficient and accurate image similarity comparison is achieved.
Patent Information
- Application Number
- CN202210161624.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-22
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-02-22
AI Technical Summary
When comparing image similarity, the prior art consumes a lot of computing resources and is not high in computing efficiency. At the same time, the block comparison method reduces the accuracy of image comparison.
By obtaining the brightness component of the image to be identified, it is judged whether each pixel is a bright or dark point, and the degree of similarity of the image is determined based on the distribution relationship between the bright and dark point distribution and the distribution of the standard image.
The calculation efficiency of image similarity comparison is improved, the accuracy of comparison results is ensured, and the accuracy of the chunking comparison method is avoided.
Smart Images

Figure CN114596455B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an image similarity processing method and a device for performing cigarette box recognition processing. Background Art
[0002] Image similarity comparison is used in many fields. For example, it can be used to identify genuine and fake product packaging. The packaging with identification is compared with the packaging of genuine products. If the similarity exceeds a predetermined condition, it can be considered to be the packaging of genuine products. For another example, it can also be applied to graphic retrieval, comparing the image to be retrieved with the images in the database to find images similar to the image to be retrieved.
[0003] When performing image similarity comparison, a pixel-by-pixel comparison method can be used. This comparison method consumes a lot of computing resources and has low computing efficiency. In order to improve computing efficiency and reduce computing complexity, a local comparison method can also be used in the prior art. For example, patent CN107622270A discloses: adaptively partitioning the query image and the reference image respectively; for each small block of the query image, a small block of the reference image is determined as its matching small block; based on the similarity between each small block of the query image and its matching small block, the similarity between the query image and the reference image is determined. Although this block comparison method improves computing efficiency, it reduces the accuracy of image comparison. Summary of the invention
[0004] The embodiments of the present application provide an image similarity processing method and a device for performing cigarette box recognition processing, so as to at least solve the problems existing in the prior art when performing image similarity comparison.
[0005] According to one aspect of the present application, there is provided an image similarity processing method, comprising: obtaining a first image of an image to be identified on a brightness component; determining whether each pixel point of the first image is a bright spot or a dark spot, wherein a pixel point is a bright spot if its pixel value is greater than a first threshold value, and a dark spot if its pixel value is less than a second threshold value, and the first threshold value and the second threshold value corresponding to each pixel point are determined based on the pixel values of the pixel points around the pixel point; determining the degree of similarity between the image to be identified and the standard image based on the relationship between the distribution of bright spots and dark spots in the first image and the distribution of bright spots and dark spots in the standard image.
[0006] Furthermore, determining the degree of similarity between the image to be identified and the standard image based on the relationship between the distribution of bright spots and dark spots in the first image and the distribution of bright spots and dark spots in the standard image includes: connecting adjacent bright spots among all the bright spots to obtain at least one bright spot area, wherein each of the bright spot areas includes a plurality of mutually adjacent bright spots, different bright spot areas are separated by non-bright spot pixels, and the number of the at least one bright spot area is a first number; connecting adjacent dark spots among all the dark spots to obtain at least one dark spot area, wherein each of the dark spot areas includes a plurality of mutually adjacent dark spots, different dark spot areas are separated by non-dark spot pixels, and the number of the at least one dark spot area is a second number; determining the degree of similarity between the image to be identified and the standard image based on the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image.
[0007] Furthermore, determining the degree of similarity between the image to be identified and the standard image based on the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image includes: obtaining the number of bright spot areas and the number of dark spot areas in each of a plurality of standard images; calculating the average value and / or variance of the number of bright spot areas and the number of dark spot areas in the plurality of images; and determining the degree of similarity between the image to be identified and the standard image based on the relationship between the first number and the second number and the average value and / or variance.
[0008] Furthermore, determining the degree of similarity between the image to be identified and the standard image based on the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image includes: determining a first probability that the image to be identified and the standard image are similar based on the first number and the number of bright spot areas in the standard image; determining a second probability that the image to be identified and the standard image are similar based on the second number and the number of dark spot areas in the standard image; and determining a probability that the image to be identified and the standard image are similar based on the first probability and the second probability.
[0009] Furthermore, the first probability is calculated according to the following formula:
[0010] P1 = exp(-(temp_f1–mean1)^2 / K / var1); where P1 is the first probability, temp_f1 is the first quantity, mean1 is the average of the number of bright spot areas of multiple standard images, and var1 is the variance of the number of bright spot areas of multiple standard images;
[0011] The second probability is calculated according to the following formula:
[0012] P2=exp(-(temp_f2–mean2)^2 / K / var2); wherein P2 is the second probability, temp_f2 is the second quantity, mean2 is the average of the number of dark spot areas of multiple standard images, var1 is the variance of the number of dark spot areas of multiple standard images, and K is a constant, preferably 16.
[0013] Further, determining the probability that the image to be identified is similar to the standard image according to the first probability and the second probability includes: taking an average value of the first probability and the second probability as the probability that the image to be identified is similar to the standard image.
[0014] Furthermore, determining whether each pixel point of the first image is a bright spot or a dark spot includes: performing mean filtering in multiple ranges on the first image to obtain corresponding multiple images respectively, wherein the pixel value of the pixel point corresponding to each pixel point in the first image in the multiple images is used to indicate the pixel values of the pixels around the pixel point; determining the first threshold and the second threshold corresponding to each pixel point at least based on the pixel value of the pixel point corresponding to each pixel point in the first image in the multiple images; and determining whether the pixel point is a bright spot or a dark spot based on the first threshold and the second threshold corresponding to each pixel point.
[0015] Furthermore, determining the first threshold and the second threshold corresponding to each pixel point at least based on the pixel value of the pixel point corresponding to each pixel point in the first image in the multiple images includes: performing local contrast processing on the first image to obtain a local contrast map; determining the first threshold and the second threshold corresponding to each pixel point based on the pixel value of the pixel point corresponding to each pixel point in the multiple images and the pixel value of the pixel point corresponding to the local contrast map.
[0016] Furthermore, performing local contrast processing on the first image to obtain a local contrast map includes: performing a dilation operation on the first image within a predetermined range to obtain a dilation map, wherein the dilation map is used to indicate a maximum pixel value of the first image within the predetermined range; performing an erosion operation on the first image within the predetermined range to obtain a erosion map, wherein the erosion map is used to indicate a minimum pixel value of the first image within the predetermined range; and obtaining the local contrast map at least based on a difference between the pixel values of each pixel in the dilation map and the erosion map.
[0017] Further, a 5*5 expansion operation is performed on the first image to obtain an expansion map y_max; a 5*5 erosion operation is performed on the first image to obtain an erosion map y_min; and a local contrast map cl is obtained according to the following formula:
[0018] cl = 0.5 * max(y_max - y_min, 50).
[0019] Further, performing mean filtering on the first image in multiple ranges to respectively obtain a plurality of corresponding images includes: performing N1*N1, N2*N2, and N3*N3 mean filtering on the first image to obtain a second image, a third image, and a fourth image, where N1 is less than N2, N2 is less than N3, and N1, N2, and N3 are natural numbers; determining a first threshold and a second threshold corresponding to each pixel point at least according to the pixel values of the pixel points corresponding to the pixel point in the plurality of images includes: obtaining a first background value corresponding to each pixel point according to the difference between the pixel values of the pixel points in the third image and the second image, obtaining a second background value corresponding to each pixel point according to the difference between the pixel values of the pixel points in the fourth image and the third image, and determining the first threshold and the second threshold corresponding to each pixel point at least according to the first background value and the second background value.
[0020] Further, N1, N2, and N3 form an arithmetic sequence.
[0021] Further, N1 = 3, N2 = 5, N3 = 7; the first image is y1, the second image is y3, the third image is y5, and the fourth image is y7. The following formula is used to obtain the first background value corresponding to each pixel point: loop1 = (y5 * 25 - y3 * 9) / 16, where loop1 is the first background value; the following formula is used to obtain the second background value corresponding to each pixel point: Loop2 = (y7 * 49 - y5 * 25) / 24, where loop2 is the second background value; the first threshold is determined according to the following formula: min(loop1(i), loop2(i)) + cl(i), where i is to traverse each pixel value of the image. If y1(i) > min(loop1(i), loop2(i)) + cl(i), then this point is 1, otherwise this point is 0, and a bright point marking map is obtained; the second threshold is determined according to the following formula: max(loop1(i), loop2(i)) - 0.8 * cl(i). If y1(i) < max(loop1(i), loop2(i)) - 0.8 * cl(i), then this point is 1, otherwise this point is 0, and a dark point marking map is obtained.
[0022] According to another aspect of the present application, there is also provided a device for performing cigarette case recognition processing, including a memory and / or a processor. Among them, the memory is used to store a program, the processor is used to run the program, and the program is used to execute the above method. Among them, the first image is an image of a cigarette case to be recognized, and the standard image is an image of a standard cigarette case.
[0023] In the embodiment of the present application, a first image of the image to be identified in terms of brightness component is obtained; each pixel point of the first image is judged to be a bright spot or a dark spot, wherein the pixel value of the pixel point is greater than a first threshold value if it is a bright spot, and less than a second threshold value if it is a dark spot, and the first threshold value and the second threshold value corresponding to each pixel point are determined according to the pixel values of the pixels around the pixel point; the similarity between the image to be identified and the standard image is determined according to the relationship between the distribution of bright spots and dark spots in the first image and the distribution of bright spots and dark spots in the standard image. The present application solves the problems existing in the prior art when comparing image similarity, thereby ensuring the accuracy of the comparison result to a certain extent on the basis of improving the computational efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 is a flowchart of an image similarity processing method according to an embodiment of the present application.
[0026] Figure 2 is a flow chart of a hole-based image processing method according to an embodiment of the present application.
[0027] Figure 3 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 1 .
[0028] Figure 4 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 2 .
[0029] Figure 5 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 3 .
[0030] Figure 6 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 4 .
[0031] Figure 7 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 5 .
[0032] Figure 8 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 6 .
[0033] Fig. 9 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 7 .
[0034] Fig.10 This is a schematic diagram of an image obtained during the image processing process according to an embodiment of the present application. Figure 8 . DETAILED DESCRIPTION
[0035] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0036] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] In this embodiment, a method for processing image similarity is provided. Figure 1 is a flowchart of an image similarity processing method according to an embodiment of the present application. Figure 1 As shown below, Figure 1 The steps involved are described in detail.
[0038] Step S102, obtaining a first image of the image to be identified in terms of brightness component.
[0039] In this step, in order to save computing resources, the image to be identified is not directly used for calculation, but the brightness component of the image to be identified is used. This can reduce the complexity of the calculation on the one hand; on the other hand, since the method in this embodiment uses bright spots and dark spots as the basis for judgment, the use of the brightness component does not affect the calculation of bright spots and dark spots.
[0040] As an optional implementation, it is also possible to determine whether the size of the first image exceeds a pre-configured value. If it exceeds, the amount of calculation is relatively large. In this case, the first image can be subjected to N*N mean downsampling to obtain a downsampled image. If mean downsampling is used, the first image referred to in this embodiment is an image after mean downsampling. Mean downsampling is to calculate the average value of the pixel values of all pixels in an N*N area, and replace the N*N area with a pixel with the average value, thereby achieving the purpose of reducing the image. Processing the reduced image can improve the calculation efficiency. The value of N can be determined according to the size of the first image, for example, it can be a natural number such as 2, 3, 4, 5, etc.
[0041] Step S104, determine whether each pixel point of the first image is a bright spot or a dark spot, wherein in the first image, a pixel point is a bright spot if its pixel value is greater than a first threshold, and is a dark spot if its pixel value is less than a second threshold. The first threshold and the second threshold corresponding to each pixel point are determined based on the pixel values of the pixel points surrounding the pixel point.
[0042] In this step, the first threshold and the second threshold are related to each pixel, and the first threshold and the second threshold depend on the contrast between the pixel and the surrounding pixels. This can more accurately find bright spots or dark spots compared to using the same threshold for the entire image.
[0043] Step S106 : determining the degree of similarity between the image to be identified and the standard image according to the relationship between the distribution of the bright spots and the dark spots in the first image and the distribution of the bright spots and the dark spots in the standard image.
[0044] Through the above steps, the similarity between images is judged based on the distribution of bright spots and dark spots. This judgment method takes into account the relationship between each pixel and the surrounding pixels to determine the bright spots and dark spots. This judgment method can improve the accuracy of judgment to a certain extent.
[0045] There are many ways to judge similarity based on the distribution of bright spots and dark spots. In this embodiment, the judgment method of connected domain is adopted. The connected domain can be understood as in a binary image, except for the background 0, the foreground pixels are labeled (1, 2, 3...), and the adjacent foreground pixels are marked with the same label, that is, n areas will be marked as 1, 2, ...n. In this embodiment, the adjacent bright spots among all bright spots can be connected to obtain at least one bright spot area, wherein each bright spot area includes a plurality of adjacent bright spots, different bright spot areas are separated by non-bright spot pixels, and the number of at least one bright spot area is a first number; the adjacent dark spots among all dark spots are connected to obtain at least one dark spot area, wherein each dark spot area includes a plurality of adjacent dark spots, different dark spot areas are separated by non-dark spot pixels, and the number of at least one dark spot area is a second number; the similarity between the image to be identified and the standard image is determined according to the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image.
[0046] The bright spots and dark spots are connected into connected domains, and then the similarity is calculated based on the number of connected domains. This calculation method can further save computing resources and improve computing efficiency.
[0047] Relying on the number of bright spot areas and dark spot areas to determine the degree of similarity can be done in a relatively simple way. For example, the number of bright spot areas of the first image is compared with the number of bright spot areas of the standard image, and the number of dark spot areas of the first image is compared with the number of dark spot areas of the standard image. At this time, two similarity probabilities can be obtained respectively, namely, a first probability that the image to be identified and the standard image are similar is determined based on the first number and the number of bright spot areas of the standard image; a second probability that the image to be identified and the standard image are similar is determined based on the second number and the number of dark spot areas of the standard image; and then, a probability that the image to be identified and the standard image are similar is determined based on the first probability and the second probability.
[0048] In order to improve the accuracy of similarity judgment, the bright spot area and dark spot area of the standard image can be obtained through multiple standard images. For example, the number of bright spot areas and the number of dark spot areas in each of the multiple standard images can be obtained; the average value and / or variance of the number of bright spot areas and the number of dark spot areas in the multiple images can be calculated; and the similarity between the image to be identified and the standard image can be determined based on the relationship between the first number and the second number and the average value and / or variance. Through this optional implementation, the calculation of the bright spot area and the dark spot area in the standard image can be made more accurate.
[0049] In the above steps and optional implementations, it is involved to determine whether a pixel is a dark spot or a bright spot. A variety of determination methods can be used. In this embodiment, an optional implementation method is provided. In this optional implementation method, a mean filtering method is used to reflect the pixel value size relationship between a pixel and its surrounding pixels, and then a first threshold and a second threshold are generated. For example, if a 3*3 mean filtering is used to obtain an average pixel value within the 3*3 range, the average pixel value can reflect the pixel values of the surrounding pixels. In order to improve the accuracy of the determination of bright spots or dark spots, in this embodiment, a variety of ranges of mean filtering are used, that is, determining whether each pixel of the first image is a bright spot or a dark spot includes: performing a variety of ranges of mean filtering on the first image to obtain a plurality of corresponding images, wherein the pixel value of each pixel in the first image corresponding to the pixel in the plurality of images is used to indicate the pixel value of the pixel around the pixel; at least according to the pixel value of each pixel in the first image corresponding to the pixel in the plurality of images, the first threshold and the second threshold corresponding to the pixel are determined; according to the first threshold and the second threshold corresponding to each pixel, whether the pixel is a bright spot or a dark spot is determined.
[0050] Mean filtering in multiple ranges can be implemented in multiple ways. For example, performing N1*N1, N2*N2 and N3*N3 mean filtering on the first image to obtain the second image, the third image and the fourth image, wherein N1 is less than N2, N2 is less than N3, and N1, N2 and N3 are natural numbers (for example, N1, N2 and N3 can be an arithmetic progression); determining the first threshold and the second threshold corresponding to each pixel in the first image at least based on the pixel value of the pixel corresponding to the pixel in multiple images includes: obtaining the first background value corresponding to each pixel according to the difference between the pixel values of the pixel in the third image and the second image, obtaining the second background value corresponding to each pixel according to the difference between the pixel values of the pixel in the fourth image and the third image, and determining the first threshold and the second threshold corresponding to each pixel at least based on the first background value and the second background value.
[0051] This method can improve the accuracy of bright spot or dark spot judgment, and the calculation efficiency is also relatively high.
[0052] When generating the first threshold and the second threshold, it is also possible to consider the situation of local contrast. In an optional implementation, a local contrast map is introduced, and the first image is subjected to local contrast processing to obtain the local contrast map; the first threshold and the second threshold corresponding to each pixel are determined according to the pixel value of the pixel corresponding to each pixel in the multiple images and the pixel value of the pixel corresponding to the local contrast map. After the local contrast map is introduced, the calculation of the first threshold and the second threshold will be more accurate.
[0053] There are many ways to generate a local contrast map. In this embodiment, the expansion and erosion methods are used to obtain the local contrast map, where: Erosion: a grayscale image can be regarded as a two-dimensional matrix. Taking the radius r=1 as an example, the minimum value is calculated in the square area of (2*r+1)*(2*r+1) to replace the value of the central pixel of the square; Expansion: a grayscale image can be regarded as a two-dimensional matrix. Taking the radius r=1 as an example, the maximum value is calculated in the square area of (2*r+1)*(2*r+1) to replace the value of the central pixel of the square.
[0054] In this optional manner, a dilation operation is performed on the first image within a predetermined range to obtain a dilation map, wherein the dilation map is used to indicate the maximum pixel value of the first image within the predetermined range; an erosion operation is performed on the first image within a predetermined range to obtain a corrosion map, wherein the corrosion map is used to indicate the minimum pixel value of the first image within the predetermined range; and a local contrast map is obtained based on at least the difference between the pixel values of each pixel in the dilation map and the corrosion map. The local contrast map obtained by corrosion and dilation can better reflect the difference between the maximum pixel value and the minimum pixel value in the local area of the image.
[0055] Through the above steps and optional implementation methods, the accuracy of the comparison result can be ensured to a certain extent on the basis of improving the calculation efficiency. An optional embodiment and accompanying drawings are used for explanation below.
[0056] In this embodiment, the first image may be an image of a cigarette box to be identified, and the standard image may be an image of a standard cigarette box. In this embodiment, the above-mentioned bright spots and dark spots may be understood as a kind of hole. The so-called hole is formed when there is an obvious difference in pixel value between the approximately circular target and the background in the local area of the image, such as a dark spot (i.e., a dark spot) and a bright spot (i.e., a bright spot). That is, the method provided in this optional embodiment may also be understood as a hole counting method, and it may be applied to distinguish true and false packaging boxes, and may also be used in fields such as image retrieval that require image comparison. In this embodiment, the annular background mean is constructed by mean filtering of different scales. When the annular center pixel is significantly higher or lower than the background mean, the center pixel is identified as a bright spot or a dark spot.
[0057] Figure 2 is a flow chart of a hole-based image processing method according to an embodiment of the present application, Figure 2 In the example, the local contrast is used as the adaptive threshold, the annular mean is used as the background mean, and the bright spot and dark spot images that meet the conditions are counted, and then they are counted. Figure 2 This embodiment is described.
[0058] Step 1: perform 4*4 mean downsampling on the y component (n*m) of the image to obtain image y1 (which may correspond to the first image in the above embodiment) (n*m / 16), that is, calculate an average value output for the 4*4 area, such as Figure 3 shown.
[0059] Step 2: Use a 5*5 dilation operation to calculate the local maximum of image y1 and obtain image y_max, as shown in Figure 4 shown.
[0060] Step 3: Use 5*5 corrosion operation to calculate the local minimum of image y1 and obtain image y_min, as shown in Figure 5 shown.
[0061] Step 4: Use 3*3 mean filtering to obtain image y3 from y1, use 5*5 mean filtering to obtain image y5 from y1, and use 7*7 mean filtering to obtain image y7 from y1.
[0062] Step 5: Select the bright spots in the following way to obtain the bright spot marking image bw1:
[0063] (1) Calculate the local contrast map c1 = 0.5*max(y_max–y_min,50), such as Figure 6 as shown
[0064] (2) Calculate the background of the small loop graph loop1 = (y5 * 25 – y3 * 9) / 16, as Figure 7 shown. Calculate the background of the large loop graph loop2 = (y7 * 49 - y5 * 25) / 24, as Figure 8 shown.
[0065] (3) Let i traverse each pixel value of the image in turn. If the pixel value satisfies:
[0066] y1(i) > min(loop1(i), loop2(i)) + c1(i), then bw1(i) = 1 at this point, otherwise bw1(i) = 0. bw1 is as Fig. 9 shown.
[0067] Step 6: Select dark points in the following way to obtain the dark point marking graph bw2.
[0068] Let i traverse each pixel value of the image in turn. If the pixel value satisfies: y1(i) < max(loop1(i), loop2(i)) - 0.8 * c1(i), then bw2(i) = 1 at this point, otherwise bw2(i) = 0. bw2 is as Fig.10 shown.
[0069] Step 7: Perform connected component labeling on bw1 and bw2 respectively, count the number of regions count1 and count2,
[0070] Output the feature values feature1 = count1, feature2 = count2.
[0071] Step 8: Authenticate true and false packages:
[0072] (1) Count the feature values of 10 true package images, that is, there are 10 feature1 and 10 feature2;
[0073] (2) Calculate the mean of 10 feature1 as mean1 and the variance as var1,
[0074] Calculate the mean of 10 feature2 as mean2 and the variance as var2;
[0075] (3) When an unknown package image appears, calculate its feature values temp_f1 and temp_f2;
[0076] (4) Output the probability value P0 = (P1 + P2) / 2;
[0077] P1 = exp(-(temp_f1 – mean1)^2 / K / var1)
[0078] P2=exp(-(temp_f2–mean2)^2 / K / var2)
[0079] The optimal value K=16.
[0080] Through this optional embodiment, the annular background mean is constructed with local means of different scales; then the adaptive threshold is constructed with the local maximum and local minimum, and the probability of similarity between the image to be identified and the standard image is obtained, providing data for subsequent processing.
[0081] In this embodiment, an electronic device or electronic equipment is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the method in the above embodiment.
[0082] The above program can be run in the processor, or it can be stored in the memory (or computer-readable medium), which includes permanent and non-permanent, removable and non-removable media. Information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules 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 technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0083] These computer programs can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in one or more blocks can be implemented by different modules corresponding to different steps.
[0084] Such a system is provided in this embodiment. The system is called an image similarity processing method, including: an acquisition module, used to acquire a first image of the image to be identified on the brightness component; a judgment module, used to judge whether each pixel point of the first image is a bright spot or a dark spot, wherein the pixel point is a bright spot if its pixel value is greater than a first threshold value, and a dark spot if its pixel value is less than a second threshold value, and the first threshold value and the second threshold value corresponding to each pixel point are determined according to the pixel values of the pixel points around the pixel point; a determination module, used to determine the degree of similarity between the image to be identified and the standard image according to the relationship between the distribution of bright spots and dark spots in the first image and the distribution of bright spots and dark spots in the standard image.
[0085] The system is used to implement the functions of the method in the above-mentioned embodiment. Each module in the system corresponds to each step in the method, and those that have been explained in the method will not be repeated here.
[0086] For example, the determination module is used to connect adjacent bright spots among all bright spots to obtain at least one bright spot area, wherein each bright spot area includes multiple bright spots adjacent to each other, different bright spot areas are separated by non-bright spot pixels, and the number of the at least one bright spot area is a first number; connect adjacent dark spots among all dark spots to obtain at least one dark spot area, wherein each dark spot area includes multiple dark spots adjacent to each other, different dark spot areas are separated by non-dark spot pixels, and the number of the at least one dark spot area is a second number; determine the similarity between the image to be identified and the standard image according to the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image. Optionally, the determination module can obtain the number of bright spot areas and the number of dark spot areas in each of the multiple standard images; calculate the average value and / or variance of the number of bright spot areas and the number of dark spot areas in the multiple images; determine the similarity between the image to be identified and the standard image according to the relationship between the first number and the second number and the average value and / or variance.
[0087] Optionally, the determination module is used to determine a first probability that the image to be identified is similar to the standard image based on the first number and the number of bright spot areas of the standard image; determine a second probability that the image to be identified is similar to the standard image based on the second number and the number of dark spot areas of the standard image; and determine a probability that the image to be identified is similar to the standard image based on the first probability and the second probability.
[0088] For another example, the judgment module is used to perform mean filtering in multiple ranges on the first image to obtain corresponding multiple images, wherein the pixel value of the pixel point corresponding to each pixel point in the first image in the multiple images is used to indicate the pixel values of the pixels around the pixel point; at least the first threshold and the second threshold corresponding to each pixel point in the first image are determined based on the pixel value of the pixel point corresponding to the pixel point in the multiple images; and whether the pixel point is a bright spot or a dark spot is determined based on the first threshold and the second threshold corresponding to each pixel point.
[0089] Optionally, the judgment module is used to perform local contrast processing on the first image to obtain a local contrast map; determine the first threshold and the second threshold corresponding to each pixel point according to the pixel value of the pixel point corresponding to each pixel point in the multiple images and the pixel value of the pixel point corresponding to the local contrast map. Optionally, the judgment module is used to perform a dilation operation on the first image within a predetermined range to obtain a dilation map, wherein the dilation map is used to indicate the maximum pixel value of the first image within the predetermined range; perform an erosion operation on the first image within the predetermined range to obtain an erosion map, wherein the erosion map is used to indicate the minimum pixel value of the first image within the predetermined range; obtain the local contrast map at least according to the difference between the pixel values of each pixel in the dilation map and the erosion map.
[0090] Optionally, the judgment module is used to perform N1*N1, N2*N2 and N3*N3 mean filtering on the first image to obtain a second image, a third image and a fourth image, wherein N1 is less than N2, N2 is less than N3, and N1, N2 and N3 are natural numbers; determining a first threshold and a second threshold corresponding to each pixel in the first image at least based on the pixel value of the pixel corresponding to the pixel in the multiple images includes: obtaining a first background value corresponding to each pixel according to the difference between the pixel values of the third image and the pixel in the second image, obtaining a second background value corresponding to each pixel according to the difference between the pixel values of the fourth image and the third image, and determining a first threshold and a second threshold corresponding to each pixel at least based on the first background value and the second background value.
[0091] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for processing image similarity, characterized in that: include: Acquire a first image of the image to be identified in terms of brightness component; Determine whether each pixel of the first image is a bright spot or a dark spot, wherein the pixel is a bright spot if its pixel value is greater than a first threshold, and a dark spot if its pixel value is less than a second threshold, and the first threshold and the second threshold corresponding to each pixel are determined according to the pixel values of the pixel points surrounding the pixel point; Connecting adjacent bright spots among all bright spots to obtain at least one bright spot area, wherein each bright spot area includes a plurality of bright spots adjacent to each other, different bright spot areas are separated by non-bright spot pixels, and the number of the at least one bright spot area is a first number; Connecting adjacent dark dots among all the dark dots to obtain at least one dark dot region, wherein each of the dark dot regions includes a plurality of dark dots adjacent to each other, different dark dot regions are separated by non-dark dot pixels, and the number of the at least one dark dot region is a second number; The similarity between the image to be identified and the standard image is determined according to the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image.
2. The method according to claim 1, characterized in that Determining the similarity between the image to be identified and the standard image according to the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image includes: Obtaining the number of bright spot areas and the number of dark spot areas in each standard image of the plurality of standard images; Calculating the average value and / or variance of the number of bright spot areas and the number of dark spot areas in the plurality of standard images; The degree of similarity between the image to be identified and the standard image is determined according to the relationship between the first number, the second number, and the average value and / or the variance.
3. The method according to claim 1 or 2, characterized in that: Determining the similarity between the image to be identified and the standard image according to the relationship between the first number and the second number and the number of bright spot areas and the number of dark spot areas in the standard image includes: Determining a first probability that the image to be identified is similar to the standard image according to the first number and the number of bright spot areas of the standard image; Determining a second probability that the image to be recognized is similar to the standard image according to the second number and the number of dark spot areas of the standard image; The probability that the image to be recognized is similar to the standard image is determined according to the first probability and the second probability.
4. The method according to claim 3, characterized in that The first probability is calculated according to the following formula: P1 = exp(-(temp_f1–mean1)^2 / K / var1); where P1 is the first probability, temp_f1 is the first quantity, mean1 is the average of the number of bright spot areas of multiple standard images, and var1 is the variance of the number of bright spot areas of multiple standard images; The second probability is calculated according to the following formula: P2=exp(-(temp_f2–mean2)^2 / K / var2); wherein P2 is the second probability, temp_f2 is the second quantity, mean2 is the average of the number of dark spot areas of multiple standard images, var2 is the variance of the number of dark spot areas of multiple standard images, and K is a constant.
5. The method according to claim 4, characterized in that The K is 16.
6. The method according to claim 4, characterized in that Determining the probability that the image to be recognized is similar to the standard image according to the first probability and the second probability includes: An average value of the first probability and the second probability is used as the probability that the image to be recognized is similar to the standard image.
7. The method according to claim 1, characterized in that Determining whether each pixel of the first image is a bright spot or a dark spot includes: Performing mean filtering in multiple ranges on the first image to obtain corresponding multiple images respectively, wherein the pixel value of the pixel point corresponding to each pixel point in the first image in the multiple images is used to indicate the pixel values of the pixel points around the pixel point; Determine a first threshold and a second threshold corresponding to each pixel in the first image at least according to a pixel value of a pixel corresponding to the pixel in the multiple images; Whether each pixel is a bright spot or a dark spot is determined according to the first threshold and the second threshold corresponding to each pixel.
8. The method according to claim 7, characterized in that Determining a first threshold and a second threshold corresponding to each pixel in the first image at least according to a pixel value of a pixel corresponding to the pixel in the multiple images comprises: Performing local contrast processing on the first image to obtain a local contrast image; The first threshold and the second threshold corresponding to each pixel are determined according to the pixel value of the pixel corresponding to the multiple images and the pixel value of the pixel corresponding to the local contrast image.
9. The method according to claim 7, characterized in that: Performing mean filtering of multiple ranges on the first image to obtain corresponding multiple images includes: performing N1*N1, N2*N2 and N3*N3 mean filtering on the first image to obtain a second image, a third image and a fourth image, wherein N1 is less than N2, N2 is less than N3, and N1, N2 and N3 are natural numbers; Determining the first threshold and the second threshold corresponding to each pixel in the first image at least based on the pixel value of the pixel corresponding to the pixel in the multiple images includes: obtaining the first background value corresponding to each pixel according to the difference in pixel values between the third image and the second image, obtaining the second background value corresponding to each pixel according to the difference in pixel values between the fourth image and the third image, and determining the first threshold and the second threshold corresponding to each pixel at least based on the first background value and the second background value.
10. A device for cigarette box identification processing, characterized in that: It includes a memory and / or a processor, wherein the memory is used to store a program, the processor is used to run the program, and the program is used to execute the method according to any one of claims 1 to 9, wherein the first image is an image of a cigarette box to be identified, and the standard image is an image of a standard cigarette box.
Citation Information
Patent Citations
Image similarity calculation method and device and similar image retrieval method and system
CN107622270A
Method and device for detecting similar images
CN106296634A