Image target comparison method, device, computer equipment and readable storage medium

By cropping and extracting the standard and contrast targets in the image, obtaining their contours and comparing the differences, the inefficiency and inaccuracy of manually processing image target comparison and identification are solved, and efficient and accurate image target comparison is achieved.

CN112784900BActive Publication Date: 2025-03-21ONE CONNECT SMART TECH CO LTD SHENZHEN
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110086294.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-22
Publication Date
2025-03-21
Estimated Expiration
2041-01-22

AI Technical Summary

Technical Problem

In the prior art, the comparison and identification of targets in the image manually processed, making it difficult to accurately compare the targets, and the efficiency of comparison and identification is very low.

Method used

By obtaining standard images and contrast images, cropping standard operation images and contrast images, extracting standard objects and contrast targets, obtaining their contours, and determining whether the targets are the same by comparing outline differences.

Benefits of technology

Accurate and efficient identification of image targets is achieved, and the accuracy and efficiency of comparison between standard targets and contrast targets is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112784900B_ABST
    Figure CN112784900B_ABST
Patent Text Reader

Abstract

The present invention relates to artificial intelligence, and discloses an image target comparison method, device, computer equipment and readable storage medium, including: obtaining a standard image and a comparison image; cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image; extracting the standard target in the standard operation image, and extracting the comparison target in the comparison operation image; obtaining the standard contour of the standard target, and the comparison contour of the comparison target; comparing the difference between the standard contour and the comparison contour, and judging whether the standard target and the comparison target are the same according to the difference. The present invention also relates to blockchain technology, and information can be stored in blockchain nodes. The present invention not only improves the accuracy of the comparison between the standard target and the comparison target, such as the comparison between the standard official seal and the comparison official seal, but also improves the efficiency of the comparison between the standard target and the comparison target.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an image target comparison method, device, computer equipment and readable storage medium. Background Art

[0002] For certain objects in the image, such as official seals and signatures, it is usually necessary to verify the authenticity of the documents obtained by the other party. Especially in financial business, the need to verify the official seals in documents is more urgent, for example:

[0003] In the bank's public business, seal verification is required at the counter, bank-enterprise reconciliation seal verification is required, and the bank's post-event supervision system needs to conduct batch verification;

[0004] In the business scenario of financial leasing, the financial leasing company needs to verify the business situation of its customers and verify the official seal of the information provided by the customers;

[0005] In various loan scenarios, whether for corporate or personal loans, various property certificates are required when applying for loans, many of which involve the need to verify official seals.

[0006] However, the inventors have found that the current work of comparing and identifying targets in images is usually done manually, which not only makes it difficult to accurately compare targets, but also has a very low efficiency in comparison and identification. Summary of the invention

[0007] The purpose of the present invention is to provide an image target comparison method, device, computer equipment and readable storage medium, which are used to solve the problems existing in the prior art that the work of manually processing target comparison and identification in images makes it difficult to accurately compare the targets and the efficiency of comparison and identification is very low.

[0008] To achieve the above object, the present invention provides an image target comparison method, comprising:

[0009] Acquire standard images and comparison images;

[0010] cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image;

[0011] Extracting a standard target in the standard operation image, and extracting a contrast target in the contrast operation image;

[0012] Acquire the standard profile of the standard target and the comparison profile of the comparison target;

[0013] The difference between the standard profile and the comparison profile is compared, and whether the standard target and the comparison target are the same is determined according to the difference.

[0014] In the above solution, before extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image, the method further includes:

[0015] The sizes of the standard operation image and the contrast operation image are adjusted so that the sizes of the standard operation image and the contrast operation image are consistent.

[0016] In the above solution, before extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image, the method further includes:

[0017] The clarity of the standard operation image and the contrast operation image is improved to highlight the contour boundaries of the standard target and the contrast target.

[0018] In the above solution, the step of improving the clarity of the standard operation image and the contrast operation image includes:

[0019] Acquire a preset reference image, and convert the RGB color space of the standard operation image, the contrast operation image, and the reference image into the lαβ color space, respectively, to form a standard conversion image, a contrast conversion image, and a reference conversion image, respectively; wherein the reference image is image information capable of highlighting a reference target therein;

[0020] Calculating a first mean and a first standard deviation of the lαβ color space coordinates of each pixel in the standard conversion image, a second mean and a second standard deviation of the lαβ color space coordinates of each pixel in the contrast conversion image, and a reference mean and a reference standard deviation of the lαβ color space coordinates of each pixel in the reference conversion image;

[0021] The pixels of the standard operation image are adjusted according to the reference mean, the reference standard deviation, the first mean and the first standard deviation to improve the clarity of the standard operation image; the contrast operation image is adjusted according to the reference mean, the reference standard deviation, the second mean and the second standard deviation to improve the clarity of the contrast operation image.

[0022] In the above solution, the step of adjusting the pixels of the standard operation image according to the reference mean, the reference standard deviation, the first mean and the first standard deviation includes:

[0023] Set any pixel in the standard operation image as a first target pixel, and extract the lαβ color space coordinates of the first target pixel;

[0024] After subtracting the lαβ color space coordinate from the first mean, the resultant is divided by the first standard deviation to obtain a first standard score, wherein the first standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the standard operation image;

[0025] A standard reference coordinate obtained by multiplying the first standard score by the reference mean value, and a standard adjusted coordinate obtained by adding the standard reference coordinate to the reference standard deviation;

[0026] Setting the lαβ color space coordinates of the first target pixel as the standard adjustment coordinates to adjust the first target pixel of the standard operation image;

[0027] The step of adjusting the pixels of the contrast operation image according to the reference mean, the reference standard deviation, the second mean and the second standard deviation comprises:

[0028] Set any pixel in the contrast operation image as a second target pixel, and extract the lαβ color space coordinates of the second target pixel;

[0029] After subtracting the lαβ color space coordinate from the second mean, the resultant is divided by the second standard deviation to obtain a second standard score, wherein the second standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the contrast operation image;

[0030] A comparison reference coordinate obtained by multiplying the second standard score by the reference mean value, and a comparison adjustment coordinate obtained by adding the comparison reference coordinate to the reference standard deviation;

[0031] The lαβ color space coordinates of the second target pixel are set as the contrast adjustment coordinates to adjust the second target pixel of the contrast operation image.

[0032] In the above solution, the steps of extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image include:

[0033] Convert the standard operation image from the RGB color space to the HSV color space;

[0034] Set any pixel in the standard operation image as a third target pixel, and determine whether the HSV color space of the third target pixel belongs to a preset color threshold; if so, adjust the HSV color space to a preset extremely low value; if not, adjust the HSV color space to a preset extremely high value;

[0035] Obtaining pixels with extremely low values ​​in the HSV color space from the standard operation image and summing them up to obtain the standard target;

[0036] Convert the contrast operation image from the RGB color space to the HSV color space;

[0037] Set any pixel in the contrast operation image as a fourth target pixel, and determine whether the HSV color space of the fourth target pixel belongs to a preset color threshold; if so, adjust the HSV color space to a preset extremely low value; if not, adjust the HSV color space to a preset extremely high value;

[0038] Pixels with extremely low values ​​in the HSV color space are obtained from the contrast operation image and summarized to obtain the contrast target.

[0039] In the above solution, the step of comparing the difference between the standard profile and the comparison profile, and judging whether the standard target and the comparison target are the same according to the difference, comprises:

[0040] Obtaining a standard vector of each pixel in the standard contour and a comparison vector of each pixel in the comparison contour, and entering the standard vector and the comparison vector into the recognition neural network, wherein the standard vector represents the position coordinates of the pixels in the standard contour, and the comparison vector represents the position coordinates of the pixels in the comparison contour;

[0041] The recognition neural network is called to extract the standard vectors of two adjacent pixels in the standard contour, calculate the Euclidean distance between the two standard vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the standard contour, and summarize to form a standard distance vector; and extract the contrast vectors of two adjacent pixels in the contrast contour, calculate the Euclidean distance between the two contrast vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the contrast contour, and summarize to form a contrast distance vector;

[0042] Calculating the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain a comparison similarity value, wherein the comparison similarity value represents the difference between the standard profile and the comparison profile; determining whether the comparison similarity value exceeds a preset similarity threshold; if so, determining that the standard target and the comparison target are different; if not, determining that the standard target and the comparison target are the same;

[0043] After calculating the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain the comparison similarity value, the method includes:

[0044] The comparison similarity value is uploaded to the blockchain.

[0045] To achieve the above object, the present invention further provides an image target comparison device, comprising:

[0046] An input module, used to obtain a standard image and a comparison image;

[0047] A cropping module, used for cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image;

[0048] A target extraction module, used for extracting a standard target in the standard operation image and extracting a contrast target in the contrast operation image;

[0049] A contour extraction module, used to obtain the standard contour of the standard target and the comparison contour of the comparison target;

[0050] The target comparison module is used to compare the difference between the standard profile and the comparison profile, and determine whether the standard target and the comparison target are the same according to the difference.

[0051] To achieve the above objectives, the present invention also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor of the computer device implements the steps of the above image target comparison method when executing the computer program.

[0052] To achieve the above objectives, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program stored in the computer-readable storage medium is executed by a processor, the steps of the above-mentioned image target comparison method are implemented.

[0053] The image target comparison method, device, computer equipment and readable storage medium provided by the present invention can judge whether the standard target and the comparison target are the same by comparing the standard outline of the standard target in the standard image with the difference of the comparison outline of the comparison target in the comparison image, thereby realizing accurate and efficient identification of whether the standard target and the comparison target are consistent, which not only improves the accuracy of the comparison between the standard target and the comparison target, such as the comparison between the standard official seal and the comparison official seal, but also improves the efficiency of the comparison between the standard target and the comparison target. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 This is a flow chart of a first embodiment of the image target comparison method of the present invention;

[0055] Figure 2This is a schematic diagram of an environmental application of the image target comparison method in Embodiment 2 of the image target comparison method of the present invention;

[0056] Figure 3 is a specific method flow chart of the image target comparison method in Embodiment 2 of the image target comparison method of the present invention;

[0057] Figure 4 This is a schematic diagram of program modules of the third embodiment of the image object comparison device of the present invention;

[0058] Figure 5 Schematic diagram of the hardware structure of the computer device in the fourth embodiment of the computer device of the present invention. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0060] The image target comparison method, device, computer equipment and readable storage medium provided by the present invention are applicable to the field of image detection technology of artificial intelligence, and provide an image target comparison method based on an input module, a cropping module, a target extraction module, a contour extraction module and a target comparison module. The present invention forms a standard operation image by cropping the area showing the standard target in the standard image, and obtains a comparison operation image by cropping the area showing the comparison target in the comparison image; extracts the standard target in the standard operation image, and extracts the comparison target in the comparison operation image; obtains the standard contour of the standard target, and the comparison contour of the comparison target; compares the difference between the standard contour and the comparison contour, and judges whether the standard target and the comparison target are the same according to the difference.

[0061] Embodiment 1:

[0062] See also Figure 1 , an image target comparison method of this embodiment includes:

[0063] S101: Acquire a standard image and a comparison image.

[0064] S102: cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image.

[0065] S105: extracting the standard target in the standard operation image, and extracting the contrast target in the contrast operation image.

[0066] S106: Acquire the standard profile of the standard target and the comparison profile of the comparison target.

[0067] S107: Compare the difference between the standard profile and the comparison profile, and determine whether the standard target and the comparison target are the same according to the difference.

[0068] In an exemplary embodiment, the standard image is picture information displaying a standard target, for example: a legal scanned version of a contract with a certified official seal, wherein the official seal is the standard target and the legal scanned version of the contract is the standard image; the comparison image is image information displaying a comparison target, for example: a pending scanned version of a contract with an uncertified official seal, wherein the official seal is the comparison target and the pending scanned version of the contract is not the comparison image.

[0069] The standard area showing the standard target in the standard image and the contrast area showing the contrast target in the contrast image are identified; when the standard target in the standard image is identified, a standard anchor frame encircling the standard target will be generated on the standard image, and the standard anchor frame is the standard area; at the same time, when the contrast target in the contrast image is identified, a contrast anchor frame encircling the contrast target will be generated on the contrast image, and the contrast anchor frame is the contrast area. In this way, the area with the standard target in the standard image and the area with the contrast target in the contrast image are identified, and the standard target and the contrast target are separately compared, which avoids interference of other pixels in the standard image and the contrast image except the standard target and the contrast target on the subsequent contrast operation.

[0070] The standard operation image and the contrast operation image are respectively converted from the RGB color space to the HSV color space, wherein the HSV color space intuitively expresses the hue, vividness and brightness of the color, including: H (Hue), S (Saturation), V (Value); the pixels belonging to the preset color threshold in the standard operation image and the contrast operation image are adjusted to extremely low values, and the pixels not belonging to the color threshold are adjusted to extremely high values, so as to highlight the color and brightness differences between the standard target and other pixels in the standard operation image except the standard target, and the color and brightness differences between the contrast target and other pixels in the contrast operation image except the contrast target. The pixels belonging to extremely low values ​​in the standard operation image and the contrast operation image are respectively summarized to obtain the standard target and the contrast target, respectively, so as to achieve the technical effect of accurately and completely extracting the standard target and the contrast target from the standard operation image and the contrast operation image.

[0071] Use the cv2.findContours function in Python to obtain the standard contour of the standard target and the contrast contour of the contrast target, wherein the standard contour is the pixel points at the edge position of the standard target, and the contrast contour is the pixel points at the edge position of the contrast target.

[0072] By obtaining the standard vector of each pixel in the standard contour and the comparison vector of each pixel in the comparison contour; calculating the Euclidean distance between the standard vectors of any two adjacent pixels in the standard contour to obtain the spatial distance and summarizing them to form a standard distance vector, calculating the Euclidean distance between the comparison vectors of any two adjacent pixels in the comparison contour to obtain the spatial distance and summarizing them to form a comparison distance vector; comparing the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain the difference between the standard contour and the comparison contour, and judging whether the standard target and the comparison target are the same based on the difference, a technical effect of accurately and efficiently identifying whether the standard target and the comparison target are consistent is achieved.

[0073] Therefore, the present application not only improves the accuracy of the comparison between the standard target and the comparison target, such as the comparison between the standard official seal and the comparison official seal, but also improves the efficiency of the comparison between the standard target and the comparison target.

[0074] Embodiment 2:

[0075] This embodiment is a specific application scenario of the above-mentioned embodiment 1. Through this embodiment, the method provided by the present invention can be explained more clearly and specifically.

[0076] In the following, the method provided in this embodiment is specifically described by comparing the difference between the standard contour of the standard target in the standard image and the contrast contour of the contrast target in the contrast image in the comparison image in a server running the image target contrast method to determine whether the standard target and the contrast target are the same as an example. It should be noted that this embodiment is only exemplary and does not limit the scope of protection of the embodiment of the present invention.

[0077] Figure 2 The following is a schematic diagram showing an environmental application of the image target comparison method according to the second embodiment of the present application.

[0078] In an exemplary embodiment, the server 2 where the image target comparison method is located is connected to the client 4 through a network 3; the server 2 can provide services through one or more networks 3, and the network 3 can include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices and / or the like. The network 3 can include physical links, such as coaxial cable links, twisted pair cable links, optical fiber links, combinations thereof and / or the like. The network 3 can include wireless links, such as cellular links, satellite links, Wi-Fi links and / or the like; the client 4 can be a computer device such as a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.

[0079] Figure 3 It is a specific method flow chart of an image target comparison method provided by an embodiment of the present invention, and the method specifically includes steps S201 to S207.

[0080] S201: Acquire a standard image and a comparison image.

[0081] In this step, a connection is established with the client to obtain the standard image and the comparison image, wherein the standard image is picture information showing a standard target, for example: a legal scanned version of a contract with a certified official seal, wherein the official seal is the standard target and the legal scanned version of the contract is the standard image; the comparison image is image information showing a comparison target, for example: a pending scanned version of a contract with an uncertified official seal, wherein the official seal is the comparison target and the pending scanned version of the contract is not the comparison image.

[0082] S202: cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image.

[0083] In order to identify the area with the standard target in the standard image and the area with the comparison target in the comparison image, the standard target and the comparison target are separately compared to avoid interference between the standard image and the comparison image on the subsequent comparison operation; this step uses the image target recognition module to identify the standard area showing the standard target in the standard image and the comparison area showing the comparison target in the comparison image. In this embodiment, the image target recognition module recognizes the image by comparing the stored information with the current information, wherein a neural network model such as Faster R-CNN, Mask R-CNN, or RFCN can be used as the image target recognition module; when the image target recognition module recognizes the standard target in the standard image, a standard anchor frame encircling the standard target will be generated on the standard image, and the standard anchor frame is the standard area; at the same time, when the comparison target in the comparison image is identified, a comparison anchor frame encircling the comparison target will be generated on the comparison image, and the comparison anchor frame is the comparison area.

[0084] Furthermore, the standard area is cropped from the standard image through a cropping module to obtain a standard operation image, and the contrast area is cropped from the contrast image to obtain a contrast operation image. In this embodiment, image cropping software, such as Jpegcrop, is used to crop the standard image and the contrast image to obtain a standard operation image and the contrast operation image. Among them, Jpegcrop realizes lossless cutting of the image, thereby ensuring that the standard target and the operation target in the standard operation image and the contrast operation image will not be distorted, thereby improving the accuracy of the comparison.

[0085] S203: Adjusting the sizes of the standard operation image and the contrast operation image so that the sizes of the standard operation image and the contrast operation image are consistent.

[0086] In order to ensure the accuracy of the subsequent comparison between the standard target and the comparison target, this step adjusts the size of the standard operation image and the comparison operation image to a preset standard size while ensuring that the aspect ratio of the standard operation image and the comparison operation image remains unchanged, so that the size of the standard operation image and the comparison operation image are consistent.

[0087] S204: Improving the clarity of the standard operation image and the contrast operation image to highlight the contour boundaries of the standard target and the contrast target.

[0088] In order to respectively define the boundary between the standard target and other pixels of the standard operation image, and the boundary between the contrast target and other pixels of the contrast operation image, and thereby achieve the technical effect of improving the clarity of the detailed shadow textures and contour boundaries of the standard target and the contrast target, this step converts the RGB color space of the standard operation image and the contrast operation image into the lαβ color space, and adjusts the spatial components of the lαβ color space of the standard operation image and the contrast operation image, so as to improve the clarity of the detailed shadow textures and contour boundaries of the standard target and the contrast target. Since the lαβ color space not only basically eliminates the strong correlation between color components, but also effectively separates the grayscale information and color information of the image, it is conducive to improving the technical effect of the clarity of each detailed shadow texture and its boundary of the standard target and the contrast target.

[0089] In a preferred embodiment, the step of improving the clarity of the standard operation image and the contrast operation image includes:

[0090] S41: Obtain a preset reference image, and convert the RGB color space of the standard operation image, the contrast operation image and the reference image into the lαβ color space respectively, so as to form a standard conversion image, a contrast conversion image and a reference conversion image respectively; wherein the reference image is image information capable of highlighting a reference target therein.

[0091] In this step, the RGB color space of the standard operation image is converted to the lαβ color space to form a standard conversion image, and the RGB color space of the contrast operation image is converted to the lαβ color space to form a contrast conversion image; the RGB color space of the reference image is converted to the lαβ color space to form a reference conversion image. The RGB color space of the standard operation image and the contrast operation image is converted to the lαβ color space by image drawing software or open source image processing software (for example: phtoshope, matlab, etc.).

[0092] Specifically, obtaining a preset reference image includes:

[0093] A preset reference device is called to generate a reference image and obtain the reference image; the reference image generated by the reference device can clearly delineate the detailed shadow pattern and contour boundary of the reference target in the reference image, for example: a scanner.

[0094] S42: Calculate the first mean and first standard deviation of the lαβ color space coordinates of each pixel in the standard conversion image, the second mean and second standard deviation of the lαβ color space coordinates of each pixel in the contrast conversion image, and the reference mean and reference standard deviation of the lαβ color space coordinates of each pixel in the reference conversion image.

[0095] S43: adjusting pixels of the standard operation image according to the reference mean, the reference standard deviation, the first mean, and the first standard deviation to improve the clarity of the standard operation image;

[0096] Adjusting the contrast operation image according to the reference mean, the reference standard deviation, the second mean, and the second standard deviation to improve the clarity of the contrast operation image;

[0097] In this step, the step of adjusting the pixels of the standard operation image according to the reference mean, the reference standard deviation, the first mean and the first standard deviation includes:

[0098] S43-01: setting any pixel in the standard operation image as a first target pixel, and extracting the lαβ color space coordinates of the first target pixel;

[0099] S43-02: subtracting the lαβ color space coordinate from the first mean value and dividing the resultant value by the first standard deviation to obtain a first standard score, wherein the first standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the standard operation image;

[0100] In this step, the first standard score measures how many standard deviations the lαβ color space coordinate of the first target pixel is above or below the first mean of the standard operation image in units of standard deviation. Generally, a larger standard score indicates a larger distance between the lαβ color space coordinate of the first target pixel and the first mean.

[0101] S43-03: multiplying the first standard score by the reference mean to obtain a standard reference coordinate, and adding the standard reference coordinate to the reference standard deviation to obtain a standard adjustment coordinate;

[0102] In this step, the standard reference coordinates are adjusted to the lαβ color space coordinates of the first target pixel according to the reference image to reflect the initial position of the first target pixel in the lαβ color space when the first target pixel is mapped to the reference image; the standard adjustment coordinates are adjusted to the standard reference coordinates to reflect the accurate position of the first target pixel in the lαβ color space when the first target pixel is mapped to the reference image.

[0103] S43-04: Setting the lαβ color space coordinates of the first target pixel as the standard adjustment coordinates to adjust the first target pixel of the standard operation image.

[0104] The step of adjusting the pixels of the contrast operation image according to the reference mean, the reference standard deviation, the second mean and the second standard deviation comprises:

[0105] S43-11: setting any pixel in the contrast operation image as a second target pixel, and extracting the lαβ color space coordinates of the second target pixel;

[0106] S43-12: subtracting the lαβ color space coordinate from the second mean, and dividing the resultant result by the second standard deviation to obtain a second standard score, wherein the second standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the contrast operation image;

[0107] In this step, the second standard score is a measure of how many standard deviations the lαβ color space coordinate of the second target pixel is above or below the second mean of the contrast operation image in units of standard deviation. Generally, a larger standard score indicates a larger distance between the lαβ color space coordinate of the second target pixel and the second mean.

[0108] S43-13: multiplying the second standard score by the reference mean to obtain a comparison reference coordinate, and adding the comparison reference coordinate to the reference standard deviation to obtain a comparison adjustment coordinate;

[0109] In this step, the contrast reference coordinates are adjusted to the lαβ color space coordinates of the second target pixel according to the reference image to reflect the initial position of the second target pixel in the lαβ color space when the second target pixel is mapped to the reference image; the contrast adjustment coordinates are adjusted to the contrast reference coordinates to reflect the exact position of the second target pixel in the lαβ color space when the second target pixel is mapped to the reference image.

[0110] S43 - 14 : Setting the lαβ color space coordinates of the second target pixel as the contrast adjustment coordinates to adjust the second target pixel of the contrast operation image.

[0111] In summary, the lαβ color space coordinates of each pixel in the standard conversion image and the contrast conversion image are adjusted respectively to enhance the clarity of the standard operation image and the standard target and the contrast target in the contrast operation image, so as to highlight the contour boundary of the standard target and the contrast target.

[0112] For example, the following is an example of adjusting the first mean and the first standard deviation, and the second mean and the second standard deviation to a normal distribution through Python code:

[0113]

[0114]

[0115] S205: extracting the standard target in the standard operation image, and extracting the contrast target in the contrast operation image.

[0116] In order to completely extract the standard target and the contrast target from the standard operation image and the contrast operation image, this step converts the standard operation image and the contrast operation image from the RGB color space to the HSV color space, wherein the HSV color space intuitively expresses the hue, vividness and brightness of the color, including: H (Hue), S (Saturation), V (Value); the pixels belonging to the preset color threshold in the standard operation image and the contrast operation image are adjusted to extremely low values, and the pixels not belonging to the color threshold are adjusted to extremely high values, so as to highlight the color and brightness differences between the standard target and other pixels in the standard operation image except the standard target, and the color and brightness differences between the contrast target and other pixels in the contrast operation image except the contrast target. The pixels belonging to extremely low values ​​in the standard operation image and the contrast operation image are respectively summarized to obtain the standard target and the contrast target, respectively, so as to achieve the technical effect of accurately and completely extracting the standard target and the contrast target from the standard operation image and the contrast operation image.

[0117] In a preferred embodiment, the steps of extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image include:

[0118] S51: Convert the standard operation image from the RGB color space to the HSV color space.

[0119] S52: Set any pixel in the standard operation image as a third target pixel, and determine whether the HSV color space of the third target pixel belongs to the color threshold; if so, adjust the HSV color space to a preset extremely low value; for example: [0,0,0]; if not, adjust the HSV color space to a preset extremely high value; for example: [255,255,255];

[0120] S53: Obtaining pixels with extremely low values ​​in the HSV color space from the standard operation image and summing them up to obtain the standard target;

[0121] S54: Convert the contrast operation image from the RGB color space to the HSV color space.

[0122] S55: Set any pixel in the contrast operation image as the fourth target pixel, and determine whether the HSV color space of the fourth target pixel belongs to a preset color threshold; if so, adjust the HSV color space to a preset extremely low value; for example: [0,0,0]; if not, adjust the HSV color space to a preset extremely high value; for example: [255,255,255].

[0123] S56: Obtain pixels with extremely low values ​​in the HSV color space from the contrast operation image and summarize them to obtain the contrast target.

[0124] Exemplarily, the HSV color space of the third target pixel and the fourth target pixel is adjusted using Python code as follows:

[0125]

[0126] S206: Acquire the standard profile of the standard target and the comparison profile of the comparison target.

[0127] In this embodiment, the cv2.findContours function in Python is used to obtain the standard contour of the standard target and the comparison contour of the comparison target. The standard contour is the pixel points located at the edge position of the standard target, and the comparison contour is the pixel points located at the edge position of the comparison target.

[0128] Exemplarily, the following codes can be used to extract the pixel points located at the edge of the standard target and the comparison target respectively, so as to obtain the standard contour and the comparison contour respectively:

[0129] #kernel=np.ones((10,10),np.uint8)

[0130] #closing=cv2.morphologyEx(thresh,cv2.MORPH_CLOSE,kernel)

[0131] #contours,hierarchy=cv2.findContours(closing,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)

[0132] S207: Compare the difference between the standard profile and the comparison profile, and determine whether the standard target and the comparison target are the same according to the difference.

[0133] In order to accurately and efficiently identify whether the standard target and the comparison target are consistent, this step obtains the standard vector of each pixel in the standard contour and the comparison vector of each pixel in the comparison contour; calculates the Euclidean distance between the standard vectors of any two adjacent pixels in the standard contour to obtain the spatial distance and summarizes them to form a standard distance vector, calculates the Euclidean distance between the comparison vectors of any two adjacent pixels in the comparison contour to obtain the spatial distance and summarizes them to form a comparison distance vector; compares the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain the difference between the standard contour and the comparison contour, and judges whether the standard target and the comparison target are the same based on the difference.

[0134] In a preferred embodiment, the step of comparing the difference between the standard profile and the comparison profile, and judging whether the standard target and the comparison target are the same according to the difference, comprises:

[0135] S71: Obtain a standard vector of each pixel in the standard contour and a comparison vector of each pixel in the comparison contour, and enter the standard vector and the comparison vector into the recognition neural network, wherein the standard vector represents the position coordinates of the pixels in the standard contour, and the comparison vector represents the position coordinates of the pixels in the comparison contour;

[0136] S72: calling the recognition neural network to extract the standard vectors of two adjacent pixels in the standard contour, calculate the Euclidean distance between the two standard vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the standard contour, and summarize to form a standard distance vector; and extracting the contrast vectors of two adjacent pixels in the contrast contour, calculate the Euclidean distance between the two contrast vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the contrast contour, and summarize to form a contrast distance vector;

[0137] S73: Calculate the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain a comparison similarity value, wherein the comparison similarity value represents the difference between the standard profile and the comparison profile; determine whether the comparison similarity value exceeds a preset similarity threshold; if so, determine that the standard target and the comparison target are different; if not, determine that the standard target and the comparison target are the same.

[0138] Preferably, after calculating the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain the comparison similarity value, the method includes:

[0139] The comparison similarity value is uploaded to the blockchain.

[0140] It should be noted that the corresponding summary information is obtained based on the comparison of similarity values. Specifically, the summary information is obtained by hashing the comparison of similarity values, such as using the sha256s algorithm. Uploading the summary information to the blockchain can ensure its security and fairness and transparency to users. The user device can download the summary information from the blockchain to verify whether the comparison of similarity values ​​has been tampered with. The blockchain referred to in this example is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0141] Furthermore, training the recognition neural network specifically includes:

[0142] M1: Obtain training samples, where the training samples include similar image pairs and non-similar image pairs;

[0143] M2: Processing the first standard image and the first comparison image in the similar image pair according to the steps S201-S206 to obtain a first standard profile and a first comparison profile; creating a similar sample with the first standard profile and the first comparison profile as first input information and a similar label as first output information;

[0144] M3: Processing the second standard image and the second comparison image in the non-similar image pair according to the steps S201-S206 to obtain a second standard contour and a second comparison contour; creating a non-similar sample with the second standard contour and the second comparison contour as second input information and a non-similar label as second output information;

[0145] M4: training the initial neural network using the similar samples and the non-similar samples to obtain a comparative neural network.

[0146] In this embodiment, the initial neural network is a Siamese network, and the initial neural network is trained by the gradient descent method and the similar samples and the non-similar samples to train the initial neural network, and the similarity threshold for dividing the critical point of similarity between the standard operation image and the comparison operation image is found according to the first distance obtained by the first input information and the second vector obtained according to the second input information. Among them, the Siamese network is a similarity measurement method, which can be used for category recognition, classification, etc. when there are many categories but a small number of samples in each category. It learns a similarity measurement from the data, and uses this learned measurement to compare and match new samples of unknown categories. The gradient decent method is an optimization algorithm, also commonly known as the steepest descent method, which is used in machine learning and artificial intelligence to recursively approximate the minimum deviation model.

[0147] Embodiment three:

[0148] See also Figure 4 , an image target comparison device 1 of this embodiment includes:

[0149] An input module 11 is used to obtain a standard image and a comparison image;

[0150] A cropping module 12, used for cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image;

[0151] The target extraction module 15 is used to extract the standard target in the standard operation image and the contrast target in the contrast operation image;

[0152] A contour extraction module 16, used to obtain the standard contour of the standard target and the comparison contour of the comparison target;

[0153] The target comparison module 17 is used to compare the difference between the standard profile and the comparison profile, and determine whether the standard target and the comparison target are the same according to the difference.

[0154] Optionally, the image object comparison device 1 further includes:

[0155] The size adjustment module 13 is used to adjust the sizes of the standard operation image and the contrast operation image so that the sizes of the standard operation image and the contrast operation image are consistent.

[0156] Optionally, the image object comparison device 1 further includes:

[0157] The clarity adjustment module 14 is used to improve the clarity of the standard operation image and the contrast operation image to highlight the contour boundaries of the standard target and the contrast target.

[0158] The technical solution is applied to the field of image detection technology of artificial intelligence, extracting the standard target in the standard operation image and extracting the comparison target in the comparison operation image; obtaining the standard contour of the standard target and the comparison contour of the comparison target; performing distance measurement on the standard contour and the comparison contour to compare the difference between the standard contour and the comparison contour, and judging whether the standard target and the comparison target are the same based on the difference, so as to achieve the technical effect of image matching between the standard target and the comparison target.

[0159] Embodiment 4:

[0160] To achieve the above-mentioned purpose, the present invention further provides a computer device 5. The components of the image target comparison device of the third embodiment can be dispersed in different computer devices. The computer device 5 can be a smart phone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server or cabinet server (including an independent server, or a server cluster composed of multiple application servers) that executes a program. The computer device of this embodiment includes at least but is not limited to: a memory 51 and a processor 52 that can be interconnected through a system bus, such as Figure 5 It should be pointed out that Figure 5 Only a computer device with components is shown, but it should be understood that implementing all of the components shown is not a requirement and more or fewer components may alternatively be implemented.

[0161] In this embodiment, the memory 51 (i.e., readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 51 can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory 51 can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 51 can also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the memory 51 is generally used to store the operating system and various application software installed on the computer device, such as the program code of the image target comparison device of the third embodiment. In addition, the memory 51 can also be used to temporarily store various data that have been output or are to be output.

[0162] The processor 52 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 52 is generally used to control the overall operation of the computer device. In this embodiment, the processor 52 is used to run the program code stored in the memory 51 or process data, such as running the image target comparison device to implement the image target comparison method of the first embodiment and the second embodiment.

[0163] Embodiment five:

[0164] To achieve the above purpose, the present invention also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, a server, an App application store, etc., on which a computer program is stored, and the program realizes corresponding functions when executed by the processor 52. The computer-readable storage medium of this embodiment is used to store an image target comparison device, and when executed by the processor 52, the image target comparison method of the first and second embodiments is realized.

[0165] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0167] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. An image target comparison method, characterized in that: include: Acquire standard images and comparison images; cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image; Extracting a standard target in the standard operation image, and extracting a contrast target in the contrast operation image; Acquire the standard profile of the standard target and the comparison profile of the comparison target; Comparing the difference between the standard profile and the comparison profile, and judging whether the standard target and the comparison target are the same according to the difference; Before extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image, the method further includes: Improving the clarity of the standard operation image and the comparison operation image to highlight the contour boundaries of the standard target and the comparison target; The step of improving the clarity of the standard operation image and the contrast operation image comprises: Acquire a preset reference image, and convert the RGB color space of the standard operation image, the contrast operation image, and the reference image into the lαβ color space, respectively, to form a standard conversion image, a contrast conversion image, and a reference conversion image, respectively; wherein the reference image is image information capable of highlighting a reference target therein; Calculating a first mean and a first standard deviation of the lαβ color space coordinates of each pixel in the standard conversion image, a second mean and a second standard deviation of the lαβ color space coordinates of each pixel in the contrast conversion image, and a reference mean and a reference standard deviation of the lαβ color space coordinates of each pixel in the reference conversion image; Adjusting pixels of the standard operation image according to the reference mean, the reference standard deviation, the first mean, and the first standard deviation to improve the clarity of the standard operation image; adjusting the contrast operation image according to the reference mean, the reference standard deviation, the second mean, and the second standard deviation to improve the clarity of the contrast operation image; The step of adjusting the pixels of the standard operation image according to the reference mean, the reference standard deviation, the first mean and the first standard deviation comprises: Set any pixel in the standard operation image as a first target pixel, and extract the lαβ color space coordinates of the first target pixel; After subtracting the lαβ color space coordinate from the first mean, the resultant is divided by the first standard deviation to obtain a first standard score, wherein the first standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the standard operation image; A standard reference coordinate obtained by multiplying the first standard score by the reference mean value, and a standard adjusted coordinate obtained by adding the standard reference coordinate to the reference standard deviation; Setting the lαβ color space coordinates of the first target pixel as the standard adjustment coordinates to adjust the first target pixel of the standard operation image; The step of adjusting the pixels of the contrast operation image according to the reference mean, the reference standard deviation, the second mean and the second standard deviation comprises: Setting any pixel in the contrast operation image as a second target pixel, and extracting the lαβ color space coordinates of the second target pixel; After subtracting the lαβ color space coordinate from the second mean, the resultant is divided by the second standard deviation to obtain a second standard score, wherein the second standard score reflects the relative position of the lαβ color space coordinate in the normal distribution of the lαβ color space coordinates of all pixels in the contrast operation image; A comparison reference coordinate obtained by multiplying the second standard score by the reference mean value, and a comparison adjustment coordinate obtained by adding the comparison reference coordinate to the reference standard deviation; The lαβ color space coordinates of the second target pixel are set as the contrast adjustment coordinates to adjust the second target pixel of the contrast operation image.

2. The image target comparison method according to claim 1, characterized in that: Before extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image, the method further includes: The sizes of the standard operation image and the contrast operation image are adjusted so that the sizes of the standard operation image and the contrast operation image are consistent.

3. The image target comparison method according to claim 1, characterized in that: The steps of extracting the standard target in the standard operation image and extracting the contrast target in the contrast operation image include: Convert the standard operation image from the RGB color space to the HSV color space; Set any pixel in the standard operation image as a third target pixel, and determine whether the HSV color space of the third target pixel belongs to a preset color threshold; if so, adjust the HSV color space to a preset extremely low value; if not, adjust the HSV color space to a preset extremely high value; Obtaining pixels with extremely low values ​​in the HSV color space from the standard operation image and summing them up to obtain the standard target; Convert the contrast operation image from the RGB color space to the HSV color space; Set any pixel in the contrast operation image as a fourth target pixel, and determine whether the HSV color space of the fourth target pixel belongs to a preset color threshold; if so, adjust the HSV color space to a preset extremely low value; if not, adjust the HSV color space to a preset extremely high value; Pixels with extremely low values ​​in the HSV color space are obtained from the contrast operation image and summarized to obtain the contrast target.

4. The image target comparison method according to claim 1, characterized in that: The step of comparing the difference between the standard profile and the comparison profile, and judging whether the standard target and the comparison target are the same according to the difference, comprises: Obtaining a standard vector of each pixel in the standard contour and a comparison vector of each pixel in the comparison contour, and entering the standard vector and the comparison vector into a recognition neural network, wherein the standard vector represents the position coordinates of the pixels in the standard contour, and the comparison vector represents the position coordinates of the pixels in the comparison contour; The recognition neural network is called to extract the standard vectors of two adjacent pixels in the standard contour, calculate the Euclidean distance between the two standard vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the standard contour, and summarize to form a standard distance vector; and extract the contrast vectors of two adjacent pixels in the contrast contour, calculate the Euclidean distance between the two contrast vectors to obtain the spatial distance between the two adjacent pixels, calculate the spatial distance between each of the two adjacent pixels in the contrast contour, and summarize to form a contrast distance vector; Calculating the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain a comparison similarity value, wherein the comparison similarity value represents the difference between the standard profile and the comparison profile; determining whether the comparison similarity value exceeds a preset similarity threshold; if so, determining that the standard target and the comparison target are different; if not, determining that the standard target and the comparison target are the same; After calculating the Euclidean distance or cosine similarity between the standard distance vector and the comparison distance vector to obtain the comparison similarity value, the method includes: The comparison similarity value is uploaded to the blockchain.

5. An image target comparison device, characterized in that: include: An input module, used to obtain a standard image and a comparison image; A cropping module, used for cropping the area showing the standard target in the standard image to form a standard operation image, and cropping the area showing the comparison target in the comparison image to obtain a comparison operation image; A target extraction module, used for extracting a standard target in the standard operation image and extracting a contrast target in the contrast operation image; A contour extraction module, used to obtain the standard contour of the standard target and the comparison contour of the comparison target; The target comparison module is used to compare the difference between the standard profile and the comparison profile, and determine whether the standard target and the comparison target are the same according to the difference.

6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor of the computer device executes the computer program, the steps of the image target comparison method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program stored in the readable storage medium implements the steps of the image target comparison method according to any one of claims 1 to 4 when executed by a processor.

Citation Information

Patent Citations

  • Face liveness detection method and terminal equipment

    CN107862247A