A method for calculating an image hash value using a neural network

By utilizing image classification neural networks and autoencoder neural networks to extract and compress image features, the problem of unsatisfactory image hash value retrieval results in existing technologies is solved, and fast retrieval of similar images is achieved.

CN117292189BActive Publication Date: 2026-01-06BEIJING INST OF COMP TECH & APPL +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311267758.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2026-01-06
Estimated Expiration
2043-09-28

AI Technical Summary

Technical Problem

Existing image hash value calculation methods utilize less image semantic information, resulting in unsatisfactory retrieval results. Existing technologies fail to fully leverage the advantages of neural networks, leading to poor retrieval performance.

Method used

A pre-trained image classification neural network is used to extract high-dimensional features. The feature dimension is compressed by an autoencoder neural network. Low-dimensional features are obtained by using the output of the intermediate layer of the autoencoder neural network and binarized to obtain the image hash value. The hash value of the image database is then used.

Benefits of technology

By effectively utilizing the feature and semantic information extracted by neural networks, similar images can have similar hash values, thereby improving the retrieval efficiency of image databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117292189B_ABST
    Figure CN117292189B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of method for calculating image hash value using neural network, belong to image processing field.The present application selects an already trained image classification neural network, using this neural network, the high-dimensional feature of specified image is extracted;Using the high-dimensional feature of multiple images, an auto-encoding neural network is trained, the dimension of image feature is compressed, to obtain the low-dimensional feature of image;Using the foregoing image classification neural network and auto-encoding neural network, the low-dimensional feature of image is obtained, the low-dimensional feature is binarized, to obtain the hash value of image.The method for calculating image hash value proposed in the present application can effectively utilize the feature information and semantic information of input image extracted by neural network, so that the hash value of similar image is similar, which is helpful for fast retrieval of image database, and has important application value in image retrieval application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing, and specifically relates to a method for calculating image hash values ​​using neural networks. Background Technology

[0002] In archival management, images are a crucial type of data, and their quantity is enormous. In archival work, it's often necessary to retrieve similar images from an image database based on a given image. As image databases continue to grow, the rapid retrieval of similar images has become a problem that needs to be solved.

[0003] One solution is to first calculate the image's hash value. A hash value is a bit string consisting of 0s and 1s, which can be represented as a long integer or a byte array. Comparing the differences between two hash values ​​involves counting the number of different bits in the two hash values, a calculation that can be done quickly. Therefore, hash values ​​are commonly used for image retrieval.

[0004] Conventional image hashing involves reducing the image to a smaller 8x8 or 16x16 grid, calculating the discrete cosine transform of the smaller image, and then binarizing the transformed coefficients. This method of calculating image hashes utilizes relatively little semantic information about the image, resulting in less than ideal retrieval results.

[0005] Using neural networks to extract image features can preserve the semantic information of an image, and then calculating the image hash value can yield good results. However, directly calculating the hash value of an image using a neural network is very difficult because the hash value of the image is unknown beforehand. Therefore, it is common to use a trained neural network to extract high-dimensional features of the image, and then reduce the dimensionality of these high-dimensional features. For example, this type of method is used in the application with application number 202210247400.7, "A Method for Calculating Image Hash Values ​​Using Convolutional Neural Networks and Orthogonal Transformations". This type of method is not a fully neural network-based approach and still cannot fully utilize the advantages of neural networks; the accuracy of the retrieval results still needs to be improved.

[0006] Therefore, there is a need for a hash value calculation method that fully utilizes neural networks to extract semantic features from images, so that visually similar images also have similar hash values. This invention is based on this real-world need. Summary of the Invention

[0007] (a) Technical problems to be solved

[0008] The technical problem to be solved by this invention is how to provide a method for calculating image hash values ​​using neural networks, so as to solve the problem that existing methods for calculating image hash values ​​utilize less semantic information of the image and the retrieval results are not ideal.

[0009] (II) Technical Solution

[0010] To address the aforementioned technical problems, this invention proposes a method for calculating image hash values ​​using a neural network, comprising the following steps:

[0011] S1. Image feature extraction steps: Select a pre-trained image classification neural network and use the selected image classification neural network to extract high-dimensional features of the specified image;

[0012] S2. Image feature compression step: Using the high-dimensional features of multiple images, train an autoencoder neural network to compress the dimensionality of the image features to obtain the low-dimensional features of the image.

[0013] S3. Image hash value calculation steps: Using the aforementioned image classification neural network and autoencoder neural network, select the output of an intermediate layer with an appropriate dimension of the autoencoder neural network, obtain the low-dimensional features of the image appropriately, binarize the low-dimensional features, and obtain the image hash value.

[0014] Furthermore, in step S1, the image classification neural network is AlexNet.

[0015] Furthermore, in step S1, the image classification neural network is VggNet.

[0016] Furthermore, in step S1, the image classification neural network is GoogLeNet.

[0017] Furthermore, the dimension of the high-dimensional features is not less than 1000.

[0018] Furthermore, the image classification neural network includes: convolutional and pooling layers, fully connected layers, and class probability layers. The first few layers are convolutional and pooling layers, the later layers are fully connected layers, and the output of the last fully connected layer directly enters the class probability layer. After an image is input into these pre-trained image classification neural networks, the output of the last fully connected layer is the high-dimensional feature of the image.

[0019] Furthermore, in step S2, the number of nodes in each layer of the autoencoder neural network are: N0, N1, N2, ..., N k N k-1 ...,N1,N0; where N0>N1>N2,...>N k Then the Nth k N k-1 The output of the layer is the low-dimensional features of the image.

[0020] Furthermore, if the high-dimensional features of the image are D-dimensional, at least 2*D different high-dimensional features of the image should be selected to train an autoencoder neural network.

[0021] Furthermore, N0 = 1000, N1 = 256, N2 = 64, N1 = 256, N0 = 1000. The autoencoder neural network has 5 layers. The first and fifth layers both have a dimension of 1000, the third layer has a dimension of 64, and the fourth layer has a dimension of 256. The outputs of the third and fourth layers are the low-dimensional features of the image.

[0022] Further, in step S3, if the low-dimensional features of the image are F = (f1, f2, ..., f m The average value of the low-dimensional feature components is f = (f1 + f2 + ... + f m If ) / m, then the hash value of the image is H=(h1,h2,…,h m If f i If h ≥ f, then h i =1, otherwise h i =0.

[0023] (III) Beneficial Effects

[0024] This invention proposes a method for calculating image hash values ​​using neural networks. The proposed method utilizes neural networks throughout the entire process, effectively leveraging the feature and semantic information extracted from the input image by the neural network. This results in similar images having similar hash values, which facilitates rapid retrieval of image databases and has significant application value in image retrieval applications. Attached Figure Description

[0025] Figure 1 This is a flowchart of the method for calculating image hash values ​​using a neural network according to the present invention. Detailed Implementation

[0026] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.

[0027] This invention relates to a method for calculating image hash values ​​using neural networks, specifically, to a method for calculating image hash values ​​using image classification neural networks and autoencoder neural networks, which facilitates rapid determination of similarity between images.

[0028] The purpose of this invention is to provide a method for calculating image hash values ​​using neural networks, which fully considers the semantic features of images and satisfies the requirement that visually similar images have similar hash values.

[0029] This invention discloses a method for calculating image hash values ​​using a neural network. The method includes: (1) an image feature extraction step. A pre-trained image classification neural network is selected, and the high-dimensional features of a specified image are extracted using this neural network. (2) an image feature compression step. An autoencoder neural network is trained using the high-dimensional features of multiple images to compress the dimensionality of the image features to obtain the low-dimensional features of the image. (3) an image hash value calculation step. The low-dimensional features of the image are obtained using the aforementioned image classification neural network and autoencoder neural network, and the low-dimensional features are binarized to obtain the image hash value. The method for calculating image hash values ​​proposed in this invention can effectively utilize the feature information and semantic information of the input image extracted by the neural network, making the hash values ​​of similar images similar, which helps in the rapid retrieval of image databases and has important application value in image retrieval applications.

[0030] To achieve the above objectives, this invention proposes a method for calculating image hash values ​​using a neural network, the method comprising:

[0031] S1. Image Feature Extraction Steps. Select a pre-trained image classification neural network, such as AlexNet, VggNet, and GoogLeNet. Using the selected image classification neural network, extract high-dimensional features from the specified image; the feature dimension is generally no less than 1000.

[0032] S2. Image Feature Compression Step. Using the high-dimensional features of multiple images, an autoencoder neural network is trained to compress the dimensionality of the image features, resulting in low-dimensional image features. The input and output dimensions of the autoencoder neural network are the same, while the intermediate layers have lower dimensionality, which can be considered as the image features.

[0033] S3. Image hash value calculation steps. Using the aforementioned image classification neural network and autoencoder neural network, select the output of an intermediate layer with an appropriate dimension in the autoencoder neural network to obtain appropriate low-dimensional features of the image. Binarize the low-dimensional features to obtain the image hash value.

[0034] Example 1:

[0035] Figure 1 This is a flowchart of a method for calculating image hash values ​​using a neural network according to the present invention. The following is in conjunction with... Figure 1 The embodiments of the present invention will be described below. For example... Figure 1 As shown, the method includes:

[0036] (1) Image feature extraction steps. Select a pre-trained image classification neural network, such as AlexNet, VggNet, GoogLeNet, etc. Use the selected image classification neural network to extract high-dimensional features of the specified image. The dimension of the features is generally not less than 1000.

[0037] In practice, one can choose from pre-trained neural networks such as AlexNet, VggNet, and GoogLeNet, depending on the needs. Image classification neural networks include: convolutional and pooling layers, fully connected layers, and class probability layers. The first few layers are convolutional and pooling layers, the later layers are fully connected layers, and the output of the final fully connected layer directly enters the class probability layer (i.e., the SoftMax loss function layer). After an image is input into these pre-trained image classification neural networks, the output of the last fully connected layer (the input to the loss function layer) becomes the high-dimensional features of the image, typically with a feature dimension of 1000.

[0038] (2) Image feature compression step. Using the high-dimensional features of multiple images, an autoencoder neural network is trained to compress the dimensionality of the image features to obtain low-dimensional features of the image. The input layer dimension and output layer dimension of the autoencoder neural network are the same, and the output dimension of the intermediate layers is lower, which can be regarded as the features of the image.

[0039] In practice, if the high-dimensional features of the image are D-dimensional, at least 2*D different images with high-dimensional features should be selected to train an autoencoder neural network. When D=1000, at least 2000 or more different images with high-dimensional features should be selected to train an autoencoder neural network. The number of nodes in each layer of the autoencoder neural network are: N0, N1, N2, ..., N k N k-1 ...,N1,N0. Where N0>N1>N2,...>N k Then the Nth k N k-1 The output of the layer is the low-dimensional features of the image.

[0040] For example, with N0 = 1000, N1 = 256, N2 = 64, N1 = 256, and N0 = 1000, this autoencoder neural network has 5 layers. The input layer (first layer) and the output layer (fifth layer) both have a dimension of 1000. The dimension (number of nodes) of the third layer is 64, and the dimension (number of nodes) of the fourth layer is 256. The outputs of the third and fourth layers are the low-dimensional features of the image.

[0041] (3) Image hash value calculation steps. Using the aforementioned image classification neural network and autoencoder neural network, select the output of an intermediate layer with an appropriate dimension of the autoencoder neural network, obtain the low-dimensional features of the image appropriately, binarize the low-dimensional features, and obtain the image hash value.

[0042] In practice, an image is input into a pre-trained image classification neural network to obtain high-dimensional features of 1000 dimensions or more. These high-dimensional features are then input into a pre-trained autoencoder neural network to obtain low-dimensional features of the image. For example, in the aforementioned 5-layer autoencoder neural network, the output of the third layer can be used to obtain 64-dimensional low-dimensional features of the image, or the output of the fourth layer can be used to obtain 256-dimensional low-dimensional features of the image.

[0043] If the low-dimensional features of the image are F = (f1, f2, ..., f m The average value of the low-dimensional feature components is f = (f1 + f2 + ... + f m If ) / m, then the hash value of the image is H=(h1,h2,…,h m If f i If h ≥ f, then h i =1, otherwise h i =0.

[0044] Example 2:

[0045] A method for calculating image hash values ​​using a neural network includes:

[0046] (1) Image feature extraction steps. Select a pre-trained image classification neural network and use this neural network to extract high-dimensional features of the specified image.

[0047] (2) Image feature compression step. Using the high-dimensional features of multiple images, an autoencoder neural network is trained to compress the dimensionality of the image features to obtain the low-dimensional features of the image.

[0048] (3) Image hash value calculation steps. Using the aforementioned image classification neural network and autoencoder neural network, the low-dimensional features of the image are obtained, and the low-dimensional features are binarized to obtain the image hash value.

[0049] Furthermore, in step (2), if the high-dimensional features of the image are D-dimensional, at least 2*D different images with high-dimensional features are selected to train an autoencoder neural network. The number of nodes in each layer of the autoencoder neural network are: N0, N1, N2, ..., N k N k-1 ...,N1,N0. Where N0>N1>N2,...>N k The dimensions of both the input layer (first layer) and the output layer (last layer) are the number of high-dimensional features of the image. The output of the intermediate layers closest to the output layer is the low-dimensional feature of the image. You can choose one of the low-dimensional features output by the intermediate layer as needed.

[0050] Further, in step (3), an image is input into a pre-trained image classification neural network to obtain high-dimensional features, and then these high-dimensional features are input into a pre-trained autoencoder neural network to obtain low-dimensional features of the image. If the selected low-dimensional features of the image are F = (f1, f2, ..., f...), then... m The average value of the low-dimensional feature components is f = (f1 + f2 + ... + f m If ) / m, then the hash value of the image is H=(h1,h2,…,h m If f i If h ≥ f, then h i =1, otherwise h i =0.

[0051] The method for calculating image hash values ​​proposed in this invention uses neural networks throughout the process, which can effectively extract feature information of the input image extracted by the convolutional neural network, making the hash values ​​of similar images similar. This helps with the rapid retrieval of image databases and has important application value in image database applications.

[0052] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method of calculating an image hash value using a neural network, characterized by, The method comprises the following steps: S1, an image feature extraction step: selecting an already trained image classification neural network, using the selected image classification neural network to extract high-dimensional features of a specified image; S2, an image feature compression step: using high-dimensional features of multiple images to train an auto-encoding neural network to compress the dimension of the image features to obtain low-dimensional features of the image; S3, an image hash value calculation step: using the aforementioned image classification neural network and auto-encoding neural network, selecting the output of an intermediate layer with appropriate dimension of the auto-encoding neural network to appropriately obtain low-dimensional features of the image, binarizing the low-dimensional features to obtain a hash value of the image; Wherein, The image classification neural network comprises: convolution and pooling layers, fully connected layers and class probability layers, the former several layers are convolution and pooling layers, the latter several layers are fully connected layers, and the output of the last fully connected layer directly enters the class probability layer; after inputting an image into these already trained image classification neural networks, the output of the last fully connected layer is the high-dimensional features of the image; The step S3, if the low-dimensional feature of the image is F = (f1, f2, …, f m ), the average value of the low-dimensional feature component is f = (f1+f2+…+f m ) / m, then the hash value of the image is H = (h1, h2, …, h m ), if f i ≥f, then h i =1, otherwise h i =0. 2.The method of claim 1, wherein, In the step S1, the image classification neural network is AlexNet. 3.The method of claim 1, wherein, In the step S1, the image classification neural network is VggNet. 4.The method of claim 1, wherein, In the step S1, the image classification neural network is GoogLeNet. 5.The method of claim 1, wherein, The dimension of the high-dimensional features is not less than 1000.

6. The method of claim 1-5, wherein, The node numbers of each layer of the self-encoding neural network in the step S2 are respectively: N0, N1, N2, …, N k , k-1 …, N1, N0; Wherein, N0>N1>N2,>…>N k Then the N k , N k-1 The output of the layer is the low-dimensional feature of the image.

7. The method of claim 6, wherein the neural network is trained using a loss function that is based on a Hamming distance between the hash value and a ground truth hash value. If the high-dimensional features of the image are D-dimensional, at least 2*D different high-dimensional features of images are selected to train an auto-encoding neural network. 8.The method of claim 6, wherein, N0=1000, N1=256, N2=64, N1=256, N0=1000, the auto-encoding neural network has 5 layers, the dimensions of the first layer and the fifth layer are both 1000, the dimension of the third layer is 64, the dimension of the fourth layer is 256, and the outputs of the third layer and the fourth layer are the low-dimensional features of the image.

Citation Information

Patent Citations

  • Cross-modal retrieval method and device based on deep adversarial discrete hash learning

    CN111597298A

  • Method for calculating Hash value of image by using convolutional neural network and orthogonal transformation

    CN114648652A