Image comparison method and related equipment
By performing binary processing, edge detection and morphological expansion on the images, the problem of high error rate in image comparison caused by external factors is solved, and the accuracy of image comparison is significantly improved.
Patent Information
- Application Number
- CN202011585075.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-28
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-12-28
AI Technical Summary
The prior art has a high misjudgment rate due to external factors in image comparison, resulting in inaccurate image comparison.
By acquiring the standard initial image and the initial image to be compared, performing binarization processing, edge detection, morphological expansion and logical XOR calculation, reducing the misjudgment rate caused by external factors and improving the accuracy of image comparison.
It effectively reduces the error rate of image comparison caused by external factors and improves the accuracy of image comparison.
Smart Images

Figure CN114693531B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to an image comparison method, device, computer equipment and computer-readable storage medium. Background Art
[0002] Generally, it is possible to judge whether two objects have the same appearance based on their images. However, some external factors may cause the images of two objects with the same appearance to be different. For example, if the light source changes when photographing two objects, the images of the two objects will be different. Therefore, judging objects based on the usual image comparison method may result in an erroneous judgment result, and two objects with the same appearance may be mistakenly judged to have different appearances.
[0003] How to reduce the misjudgment rate of image comparison caused by external factors and thus increase the accuracy of image comparison has become a problem to be solved. Summary of the invention
[0004] In view of the above, it is necessary to propose an image comparison method, apparatus, computer device and computer-readable storage medium, which can reduce the image comparison misjudgment rate caused by external factors and improve the accuracy of image comparison.
[0005] A first aspect of the present application provides an image comparison method, the image comparison method comprising:
[0006] Obtaining a standard initial image and an initial image to be compared;
[0007] Binarization is performed on the standard initial image and the initial image to be compared to obtain a standard binary image and a binary image to be compared;
[0008] Performing edge detection on the standard binary image and the binary image to be compared to obtain a standard edge image and an edge image to be compared;
[0009] Performing morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0010] Performing a logical OR calculation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared;
[0011] A logical exclusive OR calculation is performed on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0012] In another possible implementation, before binarizing the standard initial image and the initial image to be compared, the image comparison method further includes:
[0013] The standard initial image and the initial image to be compared are converted into grayscale images.
[0014] In another possible implementation, the image comparison method further includes:
[0015] The standard initial image and the initial image to be compared are aligned.
[0016] In another possible implementation, the performing edge detection on the standard binary image and the binary image to be compared includes:
[0017] The edge detection is performed on the standard binary image and the binary image to be compared based on the CANNY edge detection method.
[0018] In another possible implementation, the performing morphological expansion on the standard edge image includes:
[0019] Get the preset structural element;
[0020] The standard edge image is morphologically expanded using the preset structure element.
[0021] In another possible implementation, the standard initial image is a picture of a standard product, the initial image to be compared is a picture of a product to be tested, and the image comparison method further includes:
[0022] Determining whether the standard initial image and the initial image to be compared are the same according to the comparison result image;
[0023] When the standard initial image and the initial image to be compared are the same, determining that the product to be compared is qualified;
[0024] When the standard initial image and the to-be-compared initial image are not identical, it is determined that the to-be-compared product is unqualified.
[0025] In another possible implementation, judging whether the standard initial image and the to-be-compared initial image are the same according to the comparison result image includes:
[0026] Get the preset threshold value;
[0027] Calculating the sum of pixel values in the comparison result image;
[0028] When the sum is greater than the preset threshold, determining that the standard initial image and the initial image to be compared are different;
[0029] When the sum is less than or equal to the preset threshold, it is determined that the standard initial image and the to-be-compared initial image are the same.
[0030] A second aspect of the present application provides an image comparison device, the image comparison device comprising:
[0031] An acquisition module, used for acquiring a standard initial image and an initial image to be compared;
[0032] A preprocessing module, used for performing binarization processing on the standard initial image and the initial image to be compared, to obtain a standard binarized image and a binarized image to be compared respectively;
[0033] A detection module, used for performing edge detection on the standard binary image and the binary image to be compared, to obtain a standard edge image and an edge image to be compared respectively;
[0034] An expansion module, used for performing morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0035] A first calculation module, used for performing a logical OR calculation on the expanded standard edge image and the edge image to be compared, to obtain an expanded edge image to be compared;
[0036] The second calculation module is used to perform a logical XOR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0037] A third aspect of the present application provides a computer device, the computer device comprising a processor, the processor being configured to implement the image comparison method when executing a computer program stored in a memory.
[0038] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the image comparison method when executed by a processor.
[0039] The present invention reduces the image comparison misjudgment rate caused by external factors through edge detection and morphological expansion, thereby improving the accuracy of image comparison. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a flow chart of the image comparison method provided by an embodiment of the present invention.
[0041] Figure 2 is a structural diagram of an image contrast device provided by an embodiment of the present invention.
[0042] Figure 3 It is a schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0044] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. The embodiments described are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0046] Preferably, the image contrast method of the present invention is applied in one or more computer devices. The computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.
[0047] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0048] Embodiment 1
[0049] Figure 1 The flowchart of the image comparison method provided in the first embodiment of the present invention is shown in FIG. The image comparison method is applied to a computer device to compare images and improve the accuracy of image comparison.
[0050] like Figure 1 As shown, the image comparison method includes:
[0051] 101, obtaining a standard initial image and an initial image to be compared.
[0052] The standard initial image and the initial image to be compared uploaded by the user can be received. The standard initial image and the initial image to be compared can be read from a preset database. The standard initial image and the initial image to be compared can be obtained through a shooting device.
[0053] For example, the standard initial image is an image of a standard component, and the initial image to be compared is an image of a product to be inspected. By comparing the standard initial image with the initial image to be compared, it is determined whether the product to be inspected is qualified.
[0054] 102 , binarizing the standard initial image and the initial image to be compared to obtain a standard binarized image and a binarized image to be compared, respectively.
[0055] For example, a preset value is obtained, multiple pixel values of the standard initial image are obtained, pixel values less than the preset value are reassigned to 0, and pixel values greater than the preset value are reassigned to 1. Multiple pixel values of the initial image to be compared are obtained, pixel values less than the preset value are reassigned to 0, and pixel values greater than the preset value are reassigned to 1.
[0056] In another embodiment, before binarizing the standard initial image and the initial image to be compared, the image comparison method further includes:
[0057] The standard initial image and the initial image to be compared are converted into grayscale images.
[0058] In another embodiment, the image comparison method further includes:
[0059] The standard initial image and the initial image to be compared are aligned.
[0060] Specifically, the standard initial image and the initial image to be compared may be aligned with the pixel point at the upper left corner of the image as a base point, so that each pixel point of the two images corresponds to each other one by one.
[0061] 103 , performing edge detection on the standard binary image and the binary image to be compared, to obtain a standard edge image and an edge image to be compared, respectively.
[0062] In a specific embodiment, the performing edge detection on the standard binary image and the binary image to be compared comprises:
[0063] The edge detection is performed on the standard binary image and the binary image to be compared based on the CANNY edge detection method.
[0064] Specifically, edge detection is performed on the standard binary image based on the CANNY edge detection method. The standard binary image is denoised by a Gaussian filter; the gradient value and direction of each pixel in the standard binary image are calculated; non-edge pixels in the standard binary image are filtered according to the gradient value and direction by a non-maximum suppression rule; and edge pixels are determined according to the gradient value by a double-threshold detection method.
[0065] 104 , performing morphological expansion on the standard edge image to obtain an expanded standard edge image.
[0066] The morphological expansion of the standard edge image comprises:
[0067] Get the preset structural element;
[0068] The standard edge image is morphologically expanded using the preset structure element.
[0069] Morphological expansion is also called morphological dilation. The preset structure element may be a 3-dimensional square matrix, in which each value is 1.
[0070] The morphological expansion of the standard edge image through the preset structure element includes: obtaining the origin of the preset structure element; reflecting the preset structure element about the origin to obtain a reflection set; successively translating the reflection set on the standard edge image by a preset displacement threshold to determine the target number of non-zero common elements between the reflection set and the standard edge image, and when the target number is greater than zero, determining the pixel value of the current position of the origin as 1.
[0071] 105 , performing a logical OR operation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared.
[0072] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 0, 1, 0, and 1 respectively; the edge image to be compared includes 4 pixels (the 4 pixels of the expanded standard edge image correspond one-to-one to the 4 pixels of the edge image to be compared), and the values of each pixel are 1, 0, 0, and 1 respectively; the values of the 4 pixels of the expanded edge image to be compared are 1, 1, 0, and 1 respectively.
[0073] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 1, 1, 0, and 1 respectively; the edge image to be compared includes 4 pixels, and the values of each pixel are 1, 0, 0, and 1 respectively; the values of the 4 pixels of the expanded edge image to be compared are 1, 1, 0, and 1 respectively.
[0074] 106 , performing a logical exclusive OR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0075] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 0, 1, 0, and 1 respectively; the expanded edge image to be compared includes 4 pixels (the 4 pixels of the expanded standard edge image correspond one-to-one to the 4 pixels of the expanded edge image to be compared), and the values of each pixel are 1, 1, 0, and 1 respectively, and the 4 pixels of the comparison result image are 1, 0, 0, and 0 respectively.
[0076] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 1, 1, 0, 1 respectively; the expanded edge image to be compared includes 4 pixels, and the values of each pixel are 1, 1, 0, 1 respectively; the 4 pixels of the comparison result image are 0, 0, 0, 0 respectively.
[0077] In another embodiment, the standard initial image is a picture of a standard product, the initial image to be compared is a picture of a product to be tested, and the image comparison method further includes:
[0078] Determining whether the standard initial image and the initial image to be compared are the same according to the comparison result image;
[0079] When the standard initial image and the initial image to be compared are the same, determining that the product to be compared is qualified;
[0080] When the standard initial image and the to-be-compared initial image are not identical, it is determined that the to-be-compared product is unqualified.
[0081] In another embodiment, judging whether the standard initial image and the to-be-compared initial image are the same according to the comparison result image comprises:
[0082] Get the preset threshold value;
[0083] Calculating the sum of pixel values in the comparison result image;
[0084] When the sum is greater than the preset threshold, determining that the standard initial image and the initial image to be compared are different;
[0085] When the sum is less than or equal to the preset threshold, it is determined that the standard initial image and the to-be-compared initial image are the same.
[0086] The image comparison method of the first embodiment reduces the image comparison misjudgment rate caused by external factors through edge detection and morphological expansion, thereby improving the accuracy of image comparison.
[0087] Embodiment 2
[0088] Figure 2 2 is a structural diagram of an image comparison device provided in Embodiment 2 of the present invention. The image comparison device 20 is applied to a computer device. The image comparison device 20 is used to compare images to improve the accuracy of image comparison.
[0089] like Figure 2 As shown, the image contrast device 20 may include an acquisition module 201 , a preprocessing module 202 , a detection module 203 , an expansion module 204 , a first calculation module 205 , and a second calculation module 206 .
[0090] The acquisition module 201 is used to acquire a standard initial image and an initial image to be compared.
[0091] The standard initial image and the initial image to be compared uploaded by the user can be received. The standard initial image and the initial image to be compared can be read from a preset database. The standard initial image and the initial image to be compared can be obtained through a shooting device.
[0092] For example, the standard initial image is an image of a standard component, and the initial image to be compared is an image of a product to be inspected. By comparing the standard initial image with the initial image to be compared, it is determined whether the product to be inspected is qualified.
[0093] The preprocessing module 202 is used to perform binarization processing on the standard initial image and the initial image to be compared, so as to obtain a standard binarized image and a binarized image to be compared respectively.
[0094] For example, a preset value is obtained, multiple pixel values of the standard initial image are obtained, pixel values less than the preset value are reassigned to 0, and pixel values greater than the preset value are reassigned to 1. Multiple pixel values of the initial image to be compared are obtained, pixel values less than the preset value are reassigned to 0, and pixel values greater than the preset value are reassigned to 1.
[0095] In another embodiment, the preprocessing module is further used to convert the standard initial image and the initial image to be compared into grayscale images before binarizing the standard initial image and the initial image to be compared.
[0096] In another embodiment, the preprocessing module is further used to perform alignment processing on the standard initial image and the initial image to be compared.
[0097] Specifically, the standard initial image and the initial image to be compared may be aligned with the pixel point at the upper left corner of the image as a base point, so that each pixel point of the two images corresponds to each other one by one.
[0098] The detection module 203 is used to perform edge detection on the standard binary image and the binary image to be compared, so as to obtain a standard edge image and an edge image to be compared respectively.
[0099] In a specific embodiment, the performing edge detection on the standard binary image and the binary image to be compared comprises:
[0100] The edge detection is performed on the standard binary image and the binary image to be compared based on the CANNY edge detection method.
[0101] Specifically, edge detection is performed on the standard binary image based on the CANNY edge detection method. The standard binary image is denoised by a Gaussian filter; the gradient value and direction of each pixel in the standard binary image are calculated; non-edge pixels in the standard binary image are filtered according to the gradient value and direction by a non-maximum suppression rule; and edge pixels are determined according to the gradient value by a double-threshold detection method.
[0102] The expansion module 204 is used to perform morphological expansion on the standard edge image to obtain an expanded standard edge image.
[0103] The morphological expansion of the standard edge image comprises:
[0104] Get the preset structural element;
[0105] The standard edge image is morphologically expanded using the preset structure element.
[0106] Morphological expansion is also called morphological dilation. The preset structure element may be a 3-dimensional square matrix, in which each value is 1.
[0107] The morphological expansion of the standard edge image through the preset structure element includes: obtaining the origin of the preset structure element; reflecting the preset structure element about the origin to obtain a reflection set; successively translating the reflection set on the standard edge image by a preset displacement threshold to determine the target number of non-zero common elements between the reflection set and the standard edge image, and when the target number is greater than zero, determining the pixel value of the current position of the origin as 1.
[0108] The first calculation module 205 is used to perform a logical OR calculation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared.
[0109] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 0, 1, 0, and 1 respectively; the edge image to be compared includes 4 pixels (the 4 pixels of the expanded standard edge image correspond one-to-one to the 4 pixels of the edge image to be compared), and the values of each pixel are 1, 0, 0, and 1 respectively; the values of the 4 pixels of the expanded edge image to be compared are 1, 1, 0, and 1 respectively.
[0110] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 1, 1, 0, and 1 respectively; the edge image to be compared includes 4 pixels, and the values of each pixel are 1, 0, 0, and 1 respectively; the values of the 4 pixels of the expanded edge image to be compared are 1, 1, 0, and 1 respectively.
[0111] The second calculation module 206 is used to perform a logical XOR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0112] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 0, 1, 0, and 1 respectively; the expanded edge image to be compared includes 4 pixels (the 4 pixels of the expanded standard edge image correspond one-to-one to the 4 pixels of the expanded edge image to be compared), and the values of each pixel are 1, 1, 0, and 1 respectively, and the 4 pixels of the comparison result image are 1, 0, 0, and 0 respectively.
[0113] For example, the expanded standard edge image includes 4 pixels, and the values of each pixel are 1, 1, 0, 1 respectively; the expanded edge image to be compared includes 4 pixels, and the values of each pixel are 1, 1, 0, 1 respectively; the 4 pixels of the comparison result image are 0, 0, 0, 0 respectively.
[0114] In another embodiment, the standard initial image is a picture of a standard product, the initial image to be compared is a picture of a product to be tested, and the image comparison device further includes a determination module for determining whether the standard initial image and the initial image to be compared are the same according to the comparison result image;
[0115] When the standard initial image and the initial image to be compared are the same, determining that the product to be compared is qualified;
[0116] When the standard initial image and the to-be-compared initial image are not identical, it is determined that the to-be-compared product is unqualified.
[0117] In another embodiment, judging whether the standard initial image and the to-be-compared initial image are the same according to the comparison result image comprises:
[0118] Get the preset threshold value;
[0119] Calculating the sum of pixel values in the comparison result image;
[0120] When the sum is greater than the preset threshold, determining that the standard initial image and the initial image to be compared are different;
[0121] When the sum is less than or equal to the preset threshold, it is determined that the standard initial image and the to-be-compared initial image are the same.
[0122] The image comparison device 20 of the second embodiment reduces the image comparison misjudgment rate caused by external factors through edge detection and morphological expansion, thereby improving the accuracy of image comparison.
[0123] Embodiment 3
[0124] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned image comparison method embodiment are implemented, for example: Figure 1 Steps 101-106 shown:
[0125] 101, obtaining a standard initial image and an initial image to be compared;
[0126] 102, performing binarization processing on the standard initial image and the initial image to be compared to obtain a standard binarized image and a binarized image to be compared;
[0127] 103, performing edge detection on the standard binary image and the binary image to be compared to obtain a standard edge image and an edge image to be compared;
[0128] 104, performing morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0129] 105, performing a logical OR operation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared;
[0130] 106 , performing a logical exclusive OR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0131] Alternatively, when the computer program is executed by a processor, the functions of each module in the above-mentioned device embodiment are realized, for example Figure 2 Modules 201-206:
[0132] An acquisition module 201 is used to acquire a standard initial image and an initial image to be compared;
[0133] A preprocessing module 202 is used to perform binarization processing on the standard initial image and the initial image to be compared, so as to obtain a standard binarized image and a binarized image to be compared respectively;
[0134] A detection module 203 is used to perform edge detection on the standard binary image and the binary image to be compared, to obtain a standard edge image and an edge image to be compared respectively;
[0135] An expansion module 204 is used to perform morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0136] A first calculation module 205 is used to perform a logical OR calculation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared;
[0137] The second calculation module 206 is used to perform a logical XOR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0138] Embodiment 4
[0139] Figure 3 Schematic diagram of a computer device provided in Embodiment 3 of the present invention. The computer device 30 includes a memory 301, a processor 302, and a computer program 303 stored in the memory 301 and executable on the processor 302, such as an image comparison program. When the processor 302 executes the computer program 303, the steps in the above-mentioned image comparison method embodiment are implemented, such as Figure 1 101-106 shown:
[0140] 101, obtaining a standard initial image and an initial image to be compared;
[0141] 102, performing binarization processing on the standard initial image and the initial image to be compared to obtain a standard binarized image and a binarized image to be compared;
[0142] 103, performing edge detection on the standard binary image and the binary image to be compared to obtain a standard edge image and an edge image to be compared;
[0143] 104, performing morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0144] 105, performing a logical OR operation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared;
[0145] 106 , performing a logical exclusive OR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0146] Alternatively, when the computer program is executed by a processor, the functions of each module in the above-mentioned device embodiment are realized, for example Figure 2 Modules 201-206:
[0147] An acquisition module 201 is used to acquire a standard initial image and an initial image to be compared;
[0148] A preprocessing module 202 is used to perform binarization processing on the standard initial image and the initial image to be compared, so as to obtain a standard binarized image and a binarized image to be compared respectively;
[0149] A detection module 203 is used to perform edge detection on the standard binary image and the binary image to be compared, to obtain a standard edge image and an edge image to be compared respectively;
[0150] An expansion module 204 is used to perform morphological expansion on the standard edge image to obtain an expanded standard edge image;
[0151] A first calculation module 205 is used to perform a logical OR calculation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared;
[0152] The second calculation module 206 is used to perform a logical XOR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
[0153] Exemplarily, the computer program 303 may be divided into one or more modules, which are stored in the memory 301 and executed by the processor 302 to complete the method. The one or more modules may be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program 303 in the computer device 30. For example, the computer program 303 may be divided into Figure 2 The acquisition module 201, the preprocessing module 202, the detection module 203, the expansion module 204, the first calculation module 205, and the second calculation module 206 in the embodiment, the specific functions of each module refer to the second embodiment.
[0154] Those skilled in the art will understand that the Figure 3It is only an example of the computer device 30 and does not constitute a limitation of the computer device 30. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device 30 may also include input and output devices, network access devices, buses, etc.
[0155] The processor 302 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor 302 may also be any conventional processor, etc. The processor 302 is the control center of the computer device 30, and uses various interfaces and lines to connect various parts of the entire computer device 30.
[0156] The memory 301 can be used to store the computer program 303. The processor 302 implements various functions of the computer device 30 by running or executing the computer program or module stored in the memory 301 and calling the data stored in the memory 301. The memory 301 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the computer device 30, etc. In addition, the memory 301 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0157] If the module integrated in the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory).
[0158] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0159] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0161] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the image comparison method described in various embodiments of the present invention.
[0162] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any accompanying figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other modules or steps, and the singular does not exclude the plural. Multiple modules or devices stated in the system claim can also be implemented by one module or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. An image comparison method, characterized in that: The image comparison method comprises: Obtaining a standard initial image and an initial image to be compared; Binarization is performed on the standard initial image and the initial image to be compared to obtain a standard binary image and a binary image to be compared; Performing edge detection on the standard binary image and the binary image to be compared to obtain a standard edge image and an edge image to be compared; Performing morphological expansion on the standard edge image to obtain an expanded standard edge image; Performing a logical OR calculation on the expanded standard edge image and the edge image to be compared to obtain an expanded edge image to be compared; A logical exclusive OR calculation is performed on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
2. The image comparison method according to claim 1, characterized in that: Before the binarization processing is performed on the standard initial image and the initial image to be compared, the image comparison method further includes: The standard initial image and the initial image to be compared are converted into grayscale images.
3. The image comparison method according to claim 1, characterized in that: The image comparison method further includes: The standard initial image and the initial image to be compared are aligned.
4. The image comparison method according to claim 1, characterized in that: The performing edge detection on the standard binary image and the binary image to be compared comprises: The edge detection is performed on the standard binary image and the binary image to be compared based on the CANNY edge detection method.
5. The image comparison method according to claim 1, characterized in that: The morphological expansion of the standard edge image comprises: Get the preset structural element; The standard edge image is morphologically expanded using the preset structure element.
6. The image comparison method according to claim 1, characterized in that: The standard initial image is a picture of a standard product, the initial image to be compared is a picture of a product to be tested, and the image comparison method further includes: Determining whether the standard initial image and the initial image to be compared are the same according to the comparison result image; When the standard initial image and the initial image to be compared are the same, determining that the product to be tested is qualified; or When the standard initial image and the initial image to be compared are not the same, it is determined that the product to be inspected is unqualified.
7. The image comparison method according to claim 6, characterized in that: The determining whether the standard initial image and the initial image to be compared are the same according to the comparison result image comprises: Get the preset threshold value; Calculating the sum of pixel values in the comparison result image; When the sum is greater than the preset threshold, determining that the standard initial image and the initial image to be compared are not the same; or When the sum is less than or equal to the preset threshold, it is determined that the standard initial image and the to-be-compared initial image are the same.
8. An image contrast device, characterized in that: The image contrast device comprises: An acquisition module, used for acquiring a standard initial image and an initial image to be compared; A preprocessing module, used for performing binarization processing on the standard initial image and the initial image to be compared, to obtain a standard binarized image and a binarized image to be compared respectively; A detection module, used for performing edge detection on the standard binary image and the binary image to be compared, to obtain a standard edge image and an edge image to be compared respectively; An expansion module, used for performing morphological expansion on the standard edge image to obtain an expanded standard edge image; A first calculation module, used for performing a logical OR calculation on the expanded standard edge image and the edge image to be compared, to obtain an expanded edge image to be compared; The second calculation module is used to perform a logical XOR calculation on the expanded standard edge image and the expanded edge image to be compared to obtain a comparison result image.
9. A computer device, characterized in that: The computer device comprises a processor, and the processor is used to execute a computer program stored in a memory to implement the image comparison method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image comparison method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Machine vision-based label appearance detection method and terminal device
CN107492091A
Image detection method and device, computer equipment and storage medium
CN108805023A
Stem cell fusion degree detection method and device, computer equipment and storage medium
CN111429429A
Image detection method and apparatus, computer device, and storage medium
WO2019205290A1
