Method and device for detecting logo deviation

By determining the boundary and distance difference values ​​under the white background of the logo image, we can determine whether there is an offset in the logo entity, which solves the problem that the logo offset cannot be effectively detected in the prior art, and achieves a fast and accurate detection effect.

CN114943827BActive Publication Date: 2025-02-11BEIJING JINTI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210329634.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-30
Publication Date
2025-02-11
Estimated Expiration
2042-03-30

AI Technical Summary

Technical Problem

Existing image offset detection technology cannot effectively detect the offset of company logos, especially among hundreds of millions of images, artificial inspection is extremely difficult.

Method used

By determining the four boundaries and their distance to the logo entity under the white background of the logo image, calculate the distance difference between the upper and lower boundaries and the left and right boundaries, and determine whether there is an offset in the logo entity. For non-white backgrounds, clustering is performed before detection.

Benefits of technology

It realizes rapid and efficient offset detection of hundreds of millions of logo images, saves human resources, and is compatible with special logo images, achieving accuracy that is not inferior to manual division.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114943827B_ABST
    Figure CN114943827B_ABST
Patent Text Reader

Abstract

A method and device for detecting logo offset, the method comprising: when the background of the logo image is a white background, determining four boundaries of the logo image, wherein the four boundaries include upper and lower boundaries and left and right boundaries; respectively determining the distance from each of the four boundaries to the logo entity in the logo image; and determining whether the logo entity in the logo image is offset according to the difference between the distances from the upper and lower boundaries to the logo entity and the difference between the distances from the left and right boundaries to the logo entity. The method and device provided by the embodiment of the present invention solves the problem that the existing image offset detection technology cannot realize logo offset detection, and can quickly and effectively realize offset detection of hundreds of millions of logo images, that is, realize compliance detection, which can greatly save the manpower of the enterprise, and at the same time is compatible with special logo images, and can achieve an accuracy that is not inferior to manual division.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image detection technology, and in particular to a method, device, computer-readable storage medium and electronic device for detecting logo offset. Background Art

[0002] Some websites will attach logo images for each company on their company details page. Some of these logos are uploaded by the company itself, while others are crawled from the Internet by company staff using crawler technology. When checking the company logos in the database, we found that a large number of logos were offset, and it is very difficult to filter out offset logos from hundreds of millions of images through manual inspection.

[0003] In existing image processing technologies, to detect whether a target image is offset, it is usually necessary to compare or overlay the target image with the entire frame of the standard image to directly obtain the boundary position of the image. By using image processing algorithms to simultaneously process the target image and the standard image and perform image registration, it is possible to determine whether the target image is offset and calculate the offset value. Since there is usually no complete company logo standard image library, the existing solution of determining whether an image is offset through image registration is not suitable for the scenario of company logo offset detection. Summary of the invention

[0004] In view of this, the present invention proposes a method and device for detecting logo offset, so as to solve the problem that the existing image offset detection technology cannot realize logo offset detection.

[0005] In a first aspect, an embodiment of the present invention provides a method for detecting logo offset, characterized in that the method comprises: when the background of the logo image is a white background, determining four boundaries of the logo image, wherein the four boundaries include upper and lower boundaries and left and right boundaries; respectively determining the distance from each of the four boundaries to a logo entity in the logo image; and determining whether the logo entity in the logo image is offset based on the difference in distances from the upper and lower boundaries to the logo entity and the difference in distances from the left and right boundaries to the logo entity.

[0006] Further, whether the background of the logo image is a white background is determined in the following manner: calculating the proportion of white pixels in the logo image; and when the calculation result indicates that the proportion of white pixels in the logo image is greater than a first threshold, determining that the background of the logo image is a white background.

[0007] Further, the distance from each of the four boundaries to the logo entity in the logo image is determined respectively, including: for a first boundary among the four boundaries, starting from the first boundary and traversing row by row toward the logo entity, whether the pixel values ​​of all pixels in each row are all background pixel values, and when there are pixels that are not background pixel values ​​in the first row traversed, the row number of the row is used as the distance from the first boundary to the logo entity, wherein the first boundary is an upper boundary or a lower boundary; and / or for a second boundary among the four boundaries, starting from the second boundary and traversing column by column toward the logo entity, whether the pixel values ​​of all pixels in each column are all background pixel values, and when there are pixels that are not background pixel values ​​in the first column traversed, the column number of the column is used as the distance from the second boundary to the logo entity, wherein the second boundary is a left boundary or a right boundary.

[0008] Further, determining whether the logo entity in the logo image is offset is based on the difference in distances from the upper and lower boundaries to the logo entity and the difference in distances from the left and right boundaries to the logo entity, including: determining that the logo entity in the logo image is not offset when the difference in distances from the upper and lower boundaries to the logo entity is less than or equal to one-Nth of the height of the logo image and the difference in distances from the left and right boundaries to the logo entity is less than or equal to one-Mth of the width of the logo image, wherein M and N are integers.

[0009] Further, the method also includes: in a case where it is determined that the logo entity in the logo image is offset, performing contour detection on the logo entity in the logo image; in a case where the number of detected contours is greater than or equal to a second threshold, calculating the ratio of the area of ​​the main logo in the logo entity to the area of ​​the logo entity, wherein the main logo is the logo portion corresponding to the largest contour; and in a case where the ratio is greater than or equal to a third threshold, the logo entity in the logo image is re-determined as not having an offset.

[0010] Further, the method also includes: when it is determined that the logo entity in the logo image is offset, and when the ratio is less than the third threshold, the logo entity in the logo image is finally determined to be offset.

[0011] Further, the method also includes: when it is determined that the logo entity in the logo image is offset, and when the number of contours detected is less than the second threshold, the logo entity in the logo image is finally determined to be offset.

[0012] Furthermore, the method also includes: when the background of the logo image is a non-white background, first clustering the logo image to determine the background part and the foreground logo part in the logo image, and then using a logo offset detection method similar to the white background logo image to perform logo offset detection.

[0013] Furthermore, before clustering the logo image, the method further includes: first reducing the resolution of the logo image.

[0014] Further, reducing the resolution of the logo image includes: dividing the logo image into (w / step_X)*(h / step_Y) squares, and averaging the pixel values ​​in each square, wherein w is the width of the logo image, h is the height of the logo image, step_X is a preset horizontal step length, and step_Y is a preset vertical step length.

[0015] In a second aspect, an embodiment of the present invention further provides a device for detecting logo offset, characterized in that the device comprises: a boundary determination unit, for determining four boundaries of the logo image when the background of the logo image is a white background, wherein the four boundaries include upper and lower boundaries and left and right boundaries; a distance determination unit, for respectively determining the distance from each of the four boundaries to the logo entity in the logo image; and a first offset determination unit, for determining whether the logo entity in the logo image is offset based on the difference in distances from the upper and lower boundaries to the logo entity and the difference in distances from the left and right boundaries to the logo entity.

[0016] Further, whether the background of the logo image is a white background is determined in the following manner: calculating the proportion of white pixels in the logo image; and when the calculation result indicates that the proportion of white pixels in the logo image is greater than a first threshold, determining that the background of the logo image is a white background.

[0017] Furthermore, the distance determination unit is also used for: for a first boundary among the four boundaries, traversing row by row from the first boundary toward the direction of the logo entity to determine whether the pixel values ​​of all pixels in each row are all background pixel values, and when there are pixels that are not background pixel values ​​in the first row traversed, using the row number of the row as the distance from the first boundary to the logo entity, wherein the first boundary is an upper boundary or a lower boundary; and / or for a second boundary among the four boundaries, traversing column by column from the second boundary toward the direction of the logo entity to determine whether the pixel values ​​of all pixels in each column are all background pixel values, and when there are pixels that are not background pixel values ​​in the first column traversed, using the column number of the column as the distance from the second boundary to the logo entity, wherein the second boundary is a left boundary or a right boundary.

[0018] Furthermore, the first offset determination unit is also used to determine that there is no offset of the logo entity in the logo image when the difference between the distances from the upper and lower boundaries to the logo entity is less than or equal to one-Nth of the height of the logo image, and the difference between the distances from the left and right boundaries to the logo entity is less than or equal to one-Mth of the width of the logo image, wherein M and N are integers.

[0019] Further, the device also includes a second offset determination unit, which is used to: when it is determined that the logo entity in the logo image has an offset, perform contour detection on the logo entity in the logo image; when the number of detected contours is greater than or equal to a second threshold, calculate the ratio of the area of ​​the main logo in the logo entity to the area of ​​the logo entity, wherein the main logo is the logo part corresponding to the largest contour; and when the ratio is greater than or equal to a third threshold, the logo entity in the logo image is re-determined as not having an offset.

[0020] Furthermore, the device also includes a third offset determination unit, which is used to: when it is determined that the logo entity in the logo image is offset, and when the ratio is less than the third threshold, the logo entity in the logo image is finally determined to be offset.

[0021] Furthermore, the device also includes a fourth offset determination unit, which is used to: when it is determined that the logo entity in the logo image is offset, and when the number of contours detected is less than the second threshold, the logo entity in the logo image is finally determined to be offset.

[0022] Furthermore, the device also includes a clustering processing unit, which is used to: when the background of the logo image is a non-white background, first cluster the logo image to determine the background part and the foreground logo part in the logo image, and then use a logo offset detection method similar to the white background logo image to perform logo offset detection.

[0023] Furthermore, before clustering the logo image, the method further includes: first reducing the resolution of the logo image.

[0024] Further, reducing the resolution of the logo image includes: dividing the logo image into (w / step_X)*(h / step_Y) squares, and averaging the pixel values ​​in each square, wherein w is the width of the logo image, h is the height of the logo image, step_X is a preset horizontal step length, and step_Y is a preset vertical step length.

[0025] In a third aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the methods provided in the embodiments of the present invention.

[0026] In a fourth aspect, an embodiment of the present invention further provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement the methods provided in each embodiment of the present invention.

[0027] The state data management method and device provided by the embodiment of the present invention determine the four boundaries of the logo image and the distance from each boundary to the logo entity in the logo image, and determine whether the logo entity in the logo image is offset according to the difference in the distances from the upper and lower boundaries to the logo entity and the difference in the distances from the left and right boundaries to the logo entity, thereby solving the problem that the existing image offset detection technology cannot realize logo offset detection, and can quickly and effectively realize offset detection of logo images of the order of hundreds of millions, that is, realize compliance detection, which can greatly save the manpower of the enterprise, and at the same time is compatible with special logo images, and can achieve an accuracy that is not inferior to manual division. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A schematic diagram of a system architecture provided for an exemplary embodiment of the present invention;

[0029] Figure 2 A flowchart of a method for detecting logo offset provided by an exemplary embodiment of the present invention;

[0030] Figure 3 A schematic structural diagram of a device for detecting logo offset provided in another exemplary embodiment of the present invention;

[0031] Figure 4 A block diagram of an electronic device is provided for an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0032] Now, exemplary embodiments of the present invention are described with reference to the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely and to fully convey the scope of the present invention to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not intended to limit the present invention. In the accompanying drawings, the same units / elements are marked with the same reference numerals.

[0033] Unless otherwise specified, the terms (including technical terms) used herein have the commonly understood meanings to those skilled in the art. In addition, it is understood that the terms defined in commonly used dictionaries should be understood to have the same meanings as those in the context of the relevant fields, and should not be understood as idealized or overly formal meanings.

[0034] Figure 1 A schematic diagram of a system architecture provided for an exemplary embodiment of the present invention.

[0035] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and servers 105, 106, 107, and 108. The network 103 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the servers 105, 106, 107, 108. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0036] The user 110 can use the terminal devices 101, 102, 103 to interact with the servers 105, 106, 107, 108 through the network 104 to access various services, such as browsing web pages, downloading data, etc. Various client applications can be installed on the terminal devices 101, 102, 103, such as applications that can access the uniform resource locator URL cloud service, including but not limited to browsers, security applications, etc.

[0037] The terminal devices 101, 102, 103 may be various electronic devices, including but not limited to personal computers, smart phones, smart TVs, tablet computers, personal digital assistants, e-book readers, etc.

[0038] Servers 105, 106, 107, and 108 may be servers that provide various services. A server may provide services in response to a user's service request. It is understood that a server may provide one or more services, and the same service may also be provided by multiple servers.

[0039] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0040] Figure 2 A flowchart of a method for detecting logo deviation is provided according to an exemplary embodiment of the present invention.

[0041] like Figure 2 As shown, the method includes:

[0042] Step S201: when the background of the logo image is a white background, four boundaries of the logo image are determined, wherein the four boundaries include an upper boundary, a lower boundary, and a left boundary, and a right boundary.

[0043] The logo images come from the database. The logo images in the database include both logo images uploaded by the enterprises themselves and logo images crawled from the Internet using crawler technology.

[0044] Furthermore, whether the background of the logo image is a white background is determined in the following manner:

[0045] Calculate the percentage of white pixels in the logo image; and

[0046] When the calculation result indicates that the proportion of white pixels in the logo image is greater than the first threshold, it is determined that the background of the logo image is a white background.

[0047] Whether the background of the logo image is white can be determined by traversing all pixels of the image. If the pixel value is (255, 255, 255), white is increased by one, so that all white pixels in the entire image can be counted, and then the proportion of white pixels can be obtained. The first threshold can be adjusted according to the actual parameters of the logo image to be detected and the classification effect. Preferably, the first threshold is 30%.

[0048] Step S202: respectively determining the distance between each of the four boundaries and the logo entity in the logo image.

[0049] Further, step S202 includes:

[0050] For the first boundary among the four boundaries, starting from the first boundary and moving toward the logo entity, traverse each row line by line to determine whether all pixels in each row are background pixel values. When there are pixels in the first row that are not background pixel values, use the row number of the row as the distance from the first boundary to the logo entity, wherein the first boundary is the upper boundary or the lower boundary; and / or

[0051] For the second boundary among the four boundaries, start from the second boundary and traverse column by column toward the logo entity to determine whether the pixel values ​​of all pixels in each column are background pixel values. When there are pixels in the first column that are not background pixel values, the column number of the column is used as the distance from the second boundary to the logo entity, where the second boundary is the left boundary or the right boundary.

[0052] In the embodiment of the present invention, the distances from the four boundaries of the logo image to the logo entity can be determined, in addition to being applicable to images with white backgrounds, and can also be applicable to images with backgrounds of various other colors. The background pixel value can select the pixel value at any position of the logo image background. Preferably, the background pixel value selects the pixel values ​​at the four corners of the logo image background.

[0053] Step S203: Determine whether the logo entity in the logo image is offset according to the difference between the distances from the upper and lower boundaries to the logo entity and the difference between the distances from the left and right boundaries to the logo entity.

[0054] Further, step S203 includes:

[0055] When the difference between the distances from the upper and lower boundaries to the logo entity is less than or equal to one-Nth of the logo image height, and the difference between the distances from the left and right boundaries to the logo entity is less than or equal to one-Mth of the logo image width, it is determined that there is no offset in the logo entity in the logo image, where M and N are integers.

[0056] M and N can be set to any integer as required.

[0057] Preferably, M=N=5.

[0058] For a logo image, when the image meets the requirements of the following formula, it is determined that the logo entity has no offset; otherwise, it is determined that the logo entity has an offset.

[0059]

[0060] Among them, S tb The distance d from the upper boundary to the logo entity t The distance d from the bottom edge to the logo entity b The difference, S lrThe distance d from the left border to the logo entity l The distance d from the right edge to the logo entity r The difference between the two, h is the height of the logo image to be detected, and w is the width of the logo image to be detected.

[0061] Furthermore, the method further includes: when it is determined that the logo entity in the logo image is offset,

[0062] Perform contour detection on the logo entity in the logo image;

[0063] When the number of contours detected is greater than or equal to the second threshold, calculating the ratio of the area of ​​the main logo in the logo entity to the area of ​​the logo entity, wherein the main logo is the logo portion corresponding to the largest contour; and

[0064] When the ratio is greater than or equal to the third threshold, the logo entity in the logo image is re-determined as having no offset.

[0065] The contour detection function of OpenCV can be used to detect the logo image with offset. The second threshold can be adjusted according to the actual parameters and classification effect of the logo image. Preferably, the second threshold is 1. The third threshold can be adjusted according to the actual parameters and classification effect of the logo image. Preferably, the third threshold is 0.8.

[0066] Furthermore, the method further includes: when it is determined that the logo entity in the logo image is offset,

[0067] And when the ratio is smaller than the third threshold, the logo entity in the logo image is finally determined to be offset.

[0068] Furthermore, the method further includes: when it is determined that the logo entity in the logo image is offset,

[0069] And when it is detected that the number of contours is less than the second threshold, the logo entity in the logo image is finally determined to be offset.

[0070] Furthermore, the method further includes: when the background of the logo image is a non-white background,

[0071] First, the logo image is clustered to determine the background part and the foreground logo part in the logo image, and then the logo offset detection method similar to the white background logo image is used to perform logo offset detection.

[0072] By clustering logo images with non-white backgrounds and then detecting them, compatibility with special logo images can be achieved, ensuring the accuracy of detection.

[0073] Preferably, the clustering process is a K-means algorithm.

[0074] The number of cluster centroids can be set to 2, and the K-means algorithm can be used to cluster the image into the background part and the foreground logo part.

[0075] By using the K-means algorithm for clustering, the operation is simple and the clustering effect is good, especially for big data processing, it can ensure good scalability.

[0076] Furthermore, before clustering the logo image, the following steps are also included:

[0077] First, reduce the resolution of the logo image.

[0078] By reducing the resolution of the logo image, the clustering efficiency can be improved and the noise can be reduced.

[0079] Furthermore, the resolution of the logo image can be reduced, including:

[0080] Divide the logo image into (w / step_X)*(h / step_Y) squares and average the pixel values ​​in each square, where w is the width of the logo image, h is the height of the logo image, step_X is the preset horizontal step size, and step_Y is the preset vertical step size.

[0081] Set the horizontal step size step_X and the vertical step size step_Y, divide the logo image into (w / step_X)*(h / step_Y) squares, and average the pixel values ​​in each square. Taking the red channel pixel R as an example, the average formula is as follows:

[0082]

[0083] Among them, w x =step_X and h y =step_Y are the width and height of a single square respectively.

[0084] The equalization method of the green channel pixel G and the blue pixel channel B can be obtained in the same way.

[0085] The above embodiment determines the distance between the four boundaries of the logo image and each of the boundaries and the logo entity in the logo image, and determines whether the logo entity in the logo image is offset according to the difference between the distances between the upper and lower boundaries and the logo entity and the difference between the distances between the left and right boundaries and the logo entity. This solves the problem that the existing image offset detection technology cannot realize logo offset detection, and can quickly and effectively realize offset detection for logo images of the order of hundreds of millions, that is, realize compliance detection, which can greatly save the manpower of the enterprise. At the same time, it is compatible with special logo images and can achieve an accuracy that is not inferior to manual division.

[0086] Figure 3 A schematic structural diagram of a device for detecting logo offset provided in accordance with an exemplary embodiment of the present invention.

[0087] like Figure 3 As shown, the device comprises:

[0088] The boundary determination unit 301 is used to determine four boundaries of the logo image when the background of the logo image is a white background, wherein the four boundaries include an upper boundary, a lower boundary, and a left boundary, and a right boundary.

[0089] The logo images come from the database. The logo images in the database include both logo images uploaded by the enterprises themselves and logo images crawled from the Internet using crawler technology.

[0090] Furthermore, whether the background of the logo image is a white background is determined in the following manner:

[0091] Calculate the percentage of white pixels in the logo image; and

[0092] When the calculation result indicates that the proportion of white pixels in the logo image is greater than the first threshold, it is determined that the background of the logo image is a white background.

[0093] Whether the background of the logo image is white can be determined by traversing all pixels of the image. If the pixel value is (255, 255, 255), white is increased by one, so that all white pixels in the entire image can be counted, and then the proportion of white pixels can be obtained. The first threshold can be adjusted according to the actual parameters of the logo image to be detected and the classification effect. Preferably, the first threshold is 30%.

[0094] The distance determining unit 302 is used to respectively determine the distance between each of the four boundaries and the logo entity in the logo image.

[0095] Further, the distance determining unit 302 is further configured to:

[0096] For the first boundary among the four boundaries, starting from the first boundary and moving toward the logo entity, traverse each row line by line to determine whether all pixels in each row are background pixel values. When there are pixels in the first row that are not background pixel values, use the row number of the row as the distance from the first boundary to the logo entity, wherein the first boundary is the upper boundary or the lower boundary; and / or

[0097] For the second boundary among the four boundaries, start from the second boundary and traverse column by column toward the logo entity to determine whether the pixel values ​​of all pixels in each column are background pixel values. When there are pixels in the first column that are not background pixel values, the column number of the column is used as the distance from the second boundary to the logo entity, where the second boundary is the left boundary or the right boundary.

[0098] In the embodiment of the present invention, the distances from the four boundaries of the logo image to the logo entity can be determined, in addition to being applicable to images with white backgrounds, and can also be applicable to images with backgrounds of various other colors. The background pixel value can select the pixel value at any position of the logo image background. Preferably, the background pixel value selects the pixel values ​​at the four corners of the logo image background.

[0099] The first offset determination unit 303 is used to determine whether the logo entity in the logo image is offset according to the difference between the distances from the upper and lower boundaries to the logo entity and the difference between the distances from the left and right boundaries to the logo entity.

[0100] Further, the first offset determining unit 303 is further configured to:

[0101] When the difference between the distances from the upper and lower boundaries to the logo entity is less than or equal to one-Nth of the logo image height, and the difference between the distances from the left and right boundaries to the logo entity is less than or equal to one-Mth of the logo image width, it is determined that there is no offset in the logo entity in the logo image, where M and N are integers.

[0102] M and N can be set to any integer as required.

[0103] Preferably, M=N=5.

[0104] For a logo image, when the image meets the requirements of the following formula, it is determined that the logo entity has no offset; otherwise, it is determined that the logo entity has an offset.

[0105]

[0106] Among them, S tb The distance d from the upper boundary to the logo entity t The distance d from the bottom edge to the logo entity bThe difference, S lr The distance d from the left border to the logo entity l The distance d from the right edge to the logo entity r The difference between the two, h is the height of the logo image to be detected, and w is the width of the logo image to be detected.

[0107] Furthermore, the device further includes a second offset determining unit, configured to:

[0108] In the case where it is determined that the logo entity in the logo image is offset,

[0109] Perform contour detection on the logo entity in the logo image;

[0110] When the number of contours detected is greater than or equal to the second threshold, calculating the ratio of the area of ​​the main logo in the logo entity to the area of ​​the logo entity, wherein the main logo is the logo portion corresponding to the largest contour; and

[0111] When the ratio is greater than or equal to the third threshold, the logo entity in the logo image is re-determined as having no offset.

[0112] The contour detection function of OpenCV can be used to detect the logo image with offset. The second threshold can be adjusted according to the actual parameters and classification effect of the logo image. Preferably, the second threshold is 1. The third threshold can be adjusted according to the actual parameters and classification effect of the logo image. Preferably, the third threshold is 0.8.

[0113] Furthermore, the device further includes a third offset determining unit, configured to:

[0114] In the case where it is determined that the logo entity in the logo image is offset,

[0115] And when the ratio is smaller than the third threshold, the logo entity in the logo image is finally determined to be offset.

[0116] Furthermore, the device further includes a fourth offset determining unit, configured to:

[0117] In the case where it is determined that the logo entity in the logo image is offset,

[0118] And when it is detected that the number of contours is less than the second threshold, the logo entity in the logo image is finally determined to be offset.

[0119] Furthermore, the device further includes a clustering processing unit, which is used to:

[0120] When the background of the logo image is not white,

[0121] First, the logo image is clustered to determine the background part and the foreground logo part in the logo image, and then the logo offset detection method similar to the white background logo image is used to perform logo offset detection.

[0122] By clustering logo images with non-white backgrounds and then detecting them, compatibility with special logo images can be achieved, ensuring the accuracy of detection.

[0123] Preferably, the clustering process is a K-means algorithm.

[0124] The number of cluster centroids can be set to 2, and the K-means algorithm can be used to cluster the image into the background part and the foreground logo part.

[0125] By using the K-means algorithm for clustering, the operation is simple and the clustering effect is good, especially for big data processing, it can ensure good scalability.

[0126] Furthermore, before clustering the logo image, the following steps are also included:

[0127] First, reduce the resolution of the logo image.

[0128] By reducing the resolution of the logo image, the clustering efficiency can be improved and the noise can be reduced.

[0129] Furthermore, the resolution of the logo image can be reduced, including:

[0130] Divide the logo image into (w / step_X)*(h / step_Y) squares and average the pixel values ​​in each square, where w is the width of the logo image, h is the height of the logo image, step_X is the preset horizontal step size, and step_Y is the preset vertical step size.

[0131] Set the horizontal step size step_X and the vertical step size step_Y, divide the logo image into (w / step_X)*(h / step_Y) squares, and average the pixel values ​​in each square. Taking the red channel pixel R as an example, the average formula is as follows:

[0132]

[0133] Among them, w x =step_X and h y =step_ are the width and height of a single square respectively.

[0134] The equalization method of the green channel pixel G and the blue pixel channel B can be obtained in the same way.

[0135] The above embodiment determines the distance between the four boundaries of the logo image and each of the boundaries and the logo entity in the logo image, and determines whether the logo entity in the logo image is offset according to the difference between the distances between the upper and lower boundaries and the logo entity and the difference between the distances between the left and right boundaries and the logo entity. This solves the problem that the existing image offset detection technology cannot realize logo offset detection, and can quickly and effectively realize offset detection for logo images of the order of hundreds of millions, that is, realize compliance detection, which can greatly save the manpower of the enterprise. At the same time, it is compatible with special logo images and can achieve an accuracy that is not inferior to manual division.

[0136] Figure 4 FIG. 1 is a block diagram of an electronic device provided for an exemplary embodiment of the present invention. Figure 4 As shown, the electronic device includes one or more processors 410 and memory 420 .

[0137] The processor 410 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.

[0138] The memory 420 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 410 may run the program instructions to implement the state data management method of the software program of each embodiment of the present invention described above and / or other desired functions. In one example, the electronic device may also include: an input device 430 and an output device 440, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0139] In addition, the input device 430 may also include, for example, a keyboard, a mouse, and the like.

[0140] The output device 440 can output various information to the outside. The output device 440 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.

[0141] Of course, to simplify, Figure 4Only some of the components related to the present invention in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device may also include any other appropriate components.

[0142] Exemplary computer program product and computer-readable storage medium In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, cause the processor to perform the steps in the method for detecting logo offset according to various embodiments of the present invention described in the above "Exemplary Method" section of this specification.

[0143] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0144] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, wherein when the computer program instructions are executed by a processor, the processor executes the steps of the method for detecting logo offset according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0145] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0146] The basic principle of the present invention is described above in conjunction with specific embodiments. However, it should be pointed out that the advantages, strengths, effects, etc. mentioned in the present invention are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. must be possessed by each embodiment of the present invention. In addition, the specific details disclosed above are only for the purpose of illustration and facilitation of understanding, rather than limitation, and the above details do not limit the present invention to being implemented by adopting the above specific details.

[0147] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0148] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present invention are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The word "such as" used here refers to the phrase "such as but not limited to", and can be used interchangeably with it.

[0149] The method and apparatus of the present invention may be implemented in many ways. For example, the method and apparatus of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, firmware. The above order of steps for the method is only for illustration, and the steps of the method of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present invention may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.

[0150] It should also be noted that in the apparatus, equipment and method of the present invention, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present invention. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined here can be applied to other aspects without departing from the scope of the present invention. Therefore, the present invention is not intended to be limited to the aspects shown here, but in accordance with the widest range consistent with the principles and novel features disclosed here.

[0151] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present invention to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A method for detecting logo offset, characterized in that: include: In the case where the background of the logo image is a white background, four boundaries of the logo image are determined, wherein the four boundaries include an upper boundary, a lower boundary, and a left boundary, and a right boundary; respectively determining the distance between each of the four boundaries and the logo entity in the logo image; and Determining whether the logo entity in the logo image is offset according to the difference between the distances from the upper and lower boundaries to the logo entity and the difference between the distances from the left and right boundaries to the logo entity; The step of respectively determining the distance between each of the four boundaries and the logo entity in the logo image includes: For a first boundary among the four boundaries, starting from the first boundary and traversing toward the logo entity, determine whether all pixel values ​​in each row are background pixel values. When there are pixels in the first row that are not background pixel values, use the row number of the row as the distance from the first boundary to the logo entity, wherein the first boundary is an upper boundary or a lower boundary; and / or For the second boundary among the four boundaries, starting from the second boundary, traverse each column column by column toward the logo entity to determine whether the pixel values ​​of all pixels in each column are background pixel values. When there are pixels in the first column that are not background pixel values, the column number of the column is used as the distance from the second boundary to the logo entity, wherein the second boundary is the left boundary or the right boundary.

2. The method according to claim 1, characterized in that Determine whether the background of the logo image is a white background by: Calculate the proportion of white pixels in the logo image; and When the calculation result indicates that the proportion of white pixels in the logo image is greater than a first threshold, it is determined that the background of the logo image is a white background.

3. The method according to claim 1, characterized in that Determining whether the logo entity in the logo image is offset according to the difference between the distances between the upper and lower boundaries and the logo entity and the difference between the distances between the left and right boundaries and the logo entity includes: When the difference between the distances from the upper and lower boundaries to the logo entity is less than or equal to one-Nth of the height of the logo image, and the difference between the distances from the left and right boundaries to the logo entity is less than or equal to one-Mth of the width of the logo image, it is determined that there is no offset of the logo entity in the logo image, where M and N are integers.

4. The method according to claim 1, further comprising: In the case where it is determined that the logo entity in the logo image is offset, Performing contour detection on a logo entity in the logo image; When the number of contours detected is greater than or equal to the second threshold, calculating the ratio of the area of ​​the main logo in the logo entity to the area of ​​the logo entity, wherein the main logo is the logo portion corresponding to the largest contour; as well as In the case that the ratio is greater than or equal to a third threshold, the logo entity in the logo image is re-determined as having no offset.

5. The method according to claim 4, further comprising: In the case where it is determined that the logo entity in the logo image is offset, And when the ratio is smaller than the third threshold, the logo entity in the logo image is finally determined to be offset.

6. The method according to claim 4, further comprising: In the case where it is determined that the logo entity in the logo image is offset, And when it is detected that the number of contours is less than the second threshold, the logo entity in the logo image is finally determined to be offset.

7. The method according to claim 1, further comprising: When the background of the logo image is not a white background, First, clustering processing is performed on the logo image to determine the background part and the foreground logo part in the logo image, and then logo offset detection is performed using a logo offset detection method similar to that of the white background logo image.

8. The method according to claim 7, characterized in that Before clustering the logo image, the method further includes: First, reduce the resolution of the logo image.

9. The method according to claim 8, characterized in that Reducing the resolution of the logo image, including: The logo image is divided into (w / step_X)*(h / step_Y) squares, and the pixel values ​​in each square are averaged, where w is the width of the logo image, h is the height of the logo image, step_X is the preset horizontal step length, and step_Y is the preset vertical step length.

10. A device for detecting logo deviation, characterized in that: The device comprises: A boundary determination unit, configured to determine four boundaries of the logo image when the background of the logo image is a white background, wherein the four boundaries include an upper boundary, a lower boundary, and a left boundary, and a right boundary; a distance determining unit, configured to respectively determine the distance between each of the four boundaries and the logo entity in the logo image; and an offset determination unit, configured to determine whether the logo entity in the logo image is offset according to a difference between the distances from the upper and lower boundaries to the logo entity and a difference between the distances from the left and right boundaries to the logo entity; Wherein, the distance determination unit is further used for: For a first boundary among the four boundaries, starting from the first boundary and traversing toward the logo entity, determine whether all pixel values ​​in each row are background pixel values. When there are pixels in the first row that are not background pixel values, use the row number of the row as the distance from the first boundary to the logo entity, wherein the first boundary is an upper boundary or a lower boundary; and / or For the second boundary among the four boundaries, starting from the second boundary, traverse each column column by column toward the logo entity to determine whether the pixel values ​​of all pixels in each column are background pixel values. When there are pixels in the first column that are not background pixel values, the column number of the column is used as the distance from the second boundary to the logo entity, wherein the second boundary is the left boundary or the right boundary.

11. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 9.

12. An electronic device comprising: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and device for searching for enterprise logo and computer readable storage medium

    CN108182293A

  • Product image boundary detection method and electronic equipment

    CN112634235A