Image retrieval method and image retrieval system based on Android system
By using the HSV blocked color histogram and grayscale symbiosis matrix algorithm on the Android system, and using the genetic algorithm to optimize the weight, image retrieval is directly performed on the mobile terminal, solving the inefficiency problem caused by relying on cloud computing on mobile terminal image retrieval, and efficient and accurate image retrieval is achieved.
Patent Information
- Application Number
- CN202510144849.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-10
- Publication Date
- 2025-05-30
AI Technical Summary
The existing mobile image retrieval technology has the problem of relying on cloud servers to perform complex calculations, resulting in inefficient retrieval.
The image retrieval method based on Android system is adopted, and the color and texture features of the image are extracted through the HSV blocked color histogram algorithm and the grayscale symbiosis matrix algorithm, and the feature weight is calculated in combination with the genetic algorithm, and feature extraction, similarity calculation and optimization are performed directly on the mobile terminal.
It reduces the dependence of image retrieval on cloud servers, reduces the pressure of data transmission and the computing burden of mobile devices, and improves the efficiency and accuracy of image retrieval.
Smart Images

Figure CN120067380A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data retrieval, and particularly to an image retrieval method and an image retrieval system based on the Android system. Background Art
[0002] With the popularization of 5G networks and the improvement of the performance of intelligent terminal devices, the demand for mobile image retrieval is increasing day by day. However, in the related art, the mobile image retrieval method may have the problem of low retrieval efficiency caused by over-reliance on the cloud server for complex calculations. Therefore, how to reduce the dependence of mobile image retrieval on the cloud server and improve the retrieval efficiency has become a problem to be solved. Summary of the Invention
[0003] In view of this, the present disclosure provides an image retrieval method and an image retrieval system based on the Android system to solve the problem of how to reduce the dependence of mobile image retrieval on the cloud server and improve the retrieval efficiency.
[0004] On the one hand, the present disclosure provides an image retrieval method based on the Android system. The method includes: obtaining a color feature vector of an image to be retrieved in the Android system based on the HSV block color histogram algorithm, and obtaining a texture feature vector of the image to be retrieved based on the gray-level co-occurrence matrix algorithm; using the Euclidean distance to determine a color feature similarity value between the color feature vector and a target color feature vector of a target image in the database, and determining a texture feature similarity value between the texture feature vector and a target texture feature vector of the target image; constructing a fitness function, and using a genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function; determining a composite similarity value between the image to be retrieved and the target image based on the target color feature weight, the color feature similarity value, the target texture feature weight, and the texture feature similarity value, and determining at least one target image in the database as the retrieval result of the image to be retrieved based on the sorting result of at least one composite similarity value.
[0005] On the other hand, the present disclosure also provides an image retrieval system, which includes an image processing module, a similarity calculation module, a weight determination module, and an image retrieval module, where: The image processing module is used to obtain the color feature vector of the image to be retrieved in the Android system based on the HSV block color histogram algorithm, and obtain the texture feature vector of the image to be retrieved based on the gray-level co-occurrence matrix algorithm; The similarity calculation module is used to use the Euclidean distance to determine the color feature similarity value between the color feature vector and the target color feature vector of the target image in the database, and determine the texture feature similarity value between the texture feature vector and the target texture feature vector of the target image; The weight determination module is used to construct a fitness function and use the genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function; The image retrieval module is used to determine the composite similarity value between the image to be retrieved and the target image based on the target color feature weight, the color feature similarity value, the target texture feature weight, and the texture feature similarity value, and determine at least one target image in the database as the retrieval result of the image to be retrieved based on the sorting result of at least one composite similarity value.
[0006] On the other hand, the present disclosure also provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to cause a computer to implement the above-mentioned image retrieval method based on the Android system.
[0007] On the other hand, the present disclosure also provides a computer program product, including computer instructions, and the computer instructions are used to cause a computer to execute the above-mentioned image retrieval method based on the Android system.
[0008] Through the above-mentioned image retrieval method and image retrieval system based on the Android system of the present disclosure, by directly completing the feature extraction, similarity calculation, and optimization process on the Android system of the mobile device, the data does not need to be frequently uploaded to the cloud, which greatly reduces the data transmission pressure between the mobile device and the cloud, reduces the dependence of image retrieval on the cloud server, and reduces the computing burden of the mobile device caused by frequent data upload, thereby improving the efficiency of image retrieval.
[0009] In addition, during the image retrieval process, the genetic algorithm is used to ensure finding the optimal combination of feature weights to calculate the composite similarity value, so that it can run efficiently even on resource-constrained mobile devices, further improving the retrieval efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the related art. Obviously, the drawings in the following description are some embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0011] Figure 1a Fig. shows an exemplary schematic diagram of the architecture of an image retrieval system to which an image retrieval method based on the Android system according to an embodiment of the present disclosure is applied;
[0012] Figure 1b Fig. is a schematic flowchart of an image retrieval method based on the Android system provided by an embodiment of the present disclosure;
[0013] Figure 2 Fig. is a schematic diagram of the HSV color model of an image retrieval method based on the Android system provided by an embodiment of the present disclosure;
[0014] Figure 3 Fig. is a schematic diagram of the four-direction spatial relationship of an image retrieval method based on the Android system provided by an embodiment of the present disclosure;
[0015] Figure 4 Fig. is a schematic diagram of the gray-level co-occurrence matrix of an image retrieval method based on the Android system provided by an embodiment of the present disclosure;
[0016] Figure 5 Fig. is a schematic structural diagram of another image retrieval system provided by an embodiment of the present disclosure;
[0017] Figure 6 Fig. is a schematic structural diagram of yet another image retrieval system provided by an embodiment of the present disclosure. Specific Embodiments
[0018] With the popularization of 5G networks and the significant improvement in the performance of intelligent terminal devices, the demand for image retrieval on mobile devices is increasing day by day. Mobile devices such as smartphones and tablets have become important tools for users' daily use, and their application scenarios cover multiple fields such as image search and e-commerce recommendation. However, the existing mobile image retrieval technologies still face many challenges, mainly including computational performance limitations, high latency, energy consumption problems, and insufficient retrieval accuracy.
[0019] In the related art, the following problems often exist:
[0020] 1. Image retrieval technology on the PC side usually relies on high-performance CPUs and GPUs for large-scale image feature extraction and similarity calculation, and uses large databases and cloud servers for storage and retrieval. However, mobile devices are limited by computing power, storage space, and power consumption, and traditional PC-side methods cannot be directly transplanted to mobile devices;
[0021] 2. In related technologies, image retrieval on mobile devices often relies on cloud computing, that is, mobile devices only act as data collection terminals, upload image data to the cloud for feature extraction and similarity calculation, and then return the retrieval results, which may cause problems of high latency and high energy consumption on mobile terminals;
[0022] 3. In related technologies, matching based on single features such as color features, texture features, or shape features is difficult to comprehensively describe the content of an image, resulting in insufficient accuracy of image retrieval.
[0023] To solve the above problems, in various embodiments of the present disclosure, an image retrieval method based on the Android system is provided. The method includes: obtaining a color feature vector of an image to be retrieved in the Android system based on the HSV block color histogram algorithm, and obtaining a texture feature vector of the image to be retrieved based on the gray-level co-occurrence matrix algorithm; using the Euclidean distance to determine the color feature similarity value between the color feature vector and the target color feature vector of the target image in the database, and determining the texture feature similarity value between the texture feature vector and the target texture feature vector of the target image; constructing a fitness function, and using a genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function; based on the target color feature weight, the color feature similarity value, the target texture feature weight, and the texture feature similarity value, determining the composite similarity value between the image to be retrieved and the target image, and based on the sorting result of at least one composite similarity value, determining at least one target image in the database as the retrieval result of the image to be retrieved.
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present disclosure.
[0025] Please refer to Figure 1a , Figure 1a which shows an exemplary schematic diagram of the architecture of an image retrieval system to which an image retrieval method based on the Android system according to an embodiment of the present disclosure is applied. As Figure 1aAs shown in the figure, the Android system can at least include an image retrieval system and a database; the image retrieval system can include an image processing module, a similarity calculation module, a weight determination module, and an image retrieval module.
[0026] Among them, the image processing module can be used to extract features from the image to be detected input to the mobile terminal, the similarity calculation module can be used to calculate the similarity between the image to be detected and the target image, the weight determination module can be used to continuously optimize the weight allocation to improve the accuracy of the image retrieval result, and the image retrieval module can retrieve in the database according to the similarity and the optimized weight to determine the image retrieval result.
[0027] Furthermore, the image retrieval system can be deployed in the Android system of the mobile terminal, so that the entire image retrieval result can be performed locally on the mobile terminal, thus eliminating the need to rely on cloud services to reduce network latency and improve the retrieval result.
[0028] Further reference Figure 1b , Figure 1b is a schematic flowchart of an image retrieval method based on the Android system provided by an embodiment of the present disclosure, which is applied to the image retrieval system shown in the above Figure 1a The process of this method can include the following steps:
[0029] Step S101, based on the HSV block color histogram algorithm, obtain the color feature vector of the image to be retrieved in the Android system, and based on the gray-level co-occurrence matrix algorithm, obtain the texture feature vector of the image to be retrieved.
[0030] In this embodiment, the HSV block color histogram algorithm can be an image processing algorithm for extracting a color histogram according to the color features of an image and analyzing and retrieving the image based on the color histogram. Among them, the color histogram can represent the frequency distribution of each color in the image.
[0031] Furthermore, H in Hue Saturation Value (HSV) represents hue (i.e., the type of color), S represents saturation, and V represents the brightness of the color.
[0032] Furthermore, the color feature vector of the image to be retrieved determined by the HSV block color histogram algorithm can refer to the feature representation of each color component in the HSV color space.
[0033] In a possible implementation, the gray-level co-occurrence matrix (GLCM) algorithm can be a statistical method for extracting texture features by analyzing the spatial relationship of pixel gray values in an image.
[0034] Here, the texture feature vector of the image to be retrieved determined by the gray-level co-occurrence matrix algorithm can refer to the feature representation of the image to be retrieved in the texture space.
[0035] As an example, the input method of the image to be retrieved can include but is not limited to: directly taking pictures or reading local stored photos. For example, the way of reading local stored photos can be to implement reading pictures from a folder and converting them into a Mat matrix by calling the org.opencv.android package of OpenCV.
[0036] Step S102, use the Euclidean distance to determine the color feature similarity value between the color feature vector and the target color feature vector of the target image in the database, and determine the texture feature similarity value between the texture feature vector and the target texture feature vector of the target image.
[0037] In this embodiment, the database can be an information set deployed locally on the mobile terminal. The database can store at least one image and the color feature vector and texture feature vector corresponding to each image.
[0038] In a possible implementation manner of the above embodiment, the Euclidean distance formula for calculating the color feature similarity value and the texture feature similarity value can be as shown in the following formula:
[0039]
[0040] where, x i and y i can represent the i-th component of two feature vectors, and n can represent the dimension of the feature vector.
[0041] In a possible implementation manner, the color feature similarity value can be the reciprocal of the Euclidean distance between the color feature vector and the target color feature vector. Similarly, the texture feature similarity value can be the reciprocal of the Euclidean distance between the texture feature vector and the target texture feature vector.
[0042] Here, by calculating the color feature similarity value and the texture feature similarity value of the image to be retrieved, the limitations of using a single feature extraction method in the related art are avoided, and the accuracy of image retrieval is increased.
[0043] Step S103, construct a fitness function, and use the genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function.
[0044] In this embodiment, the fitness function is used to evaluate the quality of the current solution in the genetic algorithm and measure the quality of the retrieval results in the database in image retrieval.
[0045] In a possible implementation, the genetic algorithm may include selection, crossover, and mutation operations.
[0046] Among them, the selection operation is used to determine which individuals enter the next generation according to the fitness of the individuals in the population, so as to ensure that better solutions can be inherited. As an example, the selection operation can adopt the fitness proportion method, and use the following formula to determine the probability of a certain individual being selected:
[0047]
[0048] Here, P(i) represents the probability that the i-th individual is selected, F(i) represents the fitness value of the i-th individual, and ∑ j F(j) represents the sum of the fitness of the entire population.
[0049] Furthermore, the crossover operation may refer to combining the characteristics of two parent individuals to generate at least one offspring individual. That is, the crossover operation can accelerate the convergence of the genetic algorithm.
[0050] In a possible implementation, the crossover operation can adopt the single-point crossover method. Using a preset crossover probability, when the crossover probability is met, two parent individuals perform the crossover operation to generate offspring. In the remaining probability, the parent individuals are directly copied to the next generation, and the parent genes remain unchanged.
[0051] As an example, the crossover probability can be 0.8, that is, most individuals (80%) can generate new individuals through the crossover operation.
[0052] Even further, the mutation operation can adopt the bit-flip method, and the mutation probability can be set to 0.01. For each gene bit of an individual, the value can be flipped with a mutation probability of 0.01.
[0053] Step S104, based on the target color feature weight, color feature similarity value, target texture feature weight, and texture feature similarity value, determine the composite similarity value between the image to be retrieved and the target image. Based on the sorting result of at least one composite similarity value, determine at least one target image in the database as the retrieval result of the image to be retrieved.
[0054] In this embodiment, based on the target color feature weight, color feature similarity value, target texture feature weight, and texture feature similarity value, to determine the composite similarity value between the image to be retrieved and the target image, the following formula can be used to calculate the composite similarity value between the image to be retrieved and the target image:
[0055]
[0056] Among them, G Fu can represent the composite similarity value, C wcan represent the weight of the target color feature, T w can represent the weight of the target texture feature, G HIS can represent the similarity value of the color feature, G GLCM can represent the similarity value of the texture feature.
[0057] In a possible implementation, obtain the composite similarity values respectively corresponding to the image to be retrieved and each image in the database, sort at least one composite similarity value from largest to smallest, and select the top P images as the retrieval result of the image to be retrieved.
[0058] As an example, P can be 16, and 16 images are selected to be displayed to the user.
[0059] In the image retrieval method and image retrieval system based on the Android system in the above embodiments of the present disclosure, by performing image retrieval on a mobile terminal, the problem that it is difficult to transplant the image retrieval technology on the PC side to the mobile terminal in the related art is solved. By directly completing the feature extraction, similarity calculation, and optimization process on the Android system of the mobile device, the data does not need to be frequently uploaded to the cloud, greatly reducing the data transmission pressure between the mobile device and the cloud, reducing the dependence of image retrieval on the cloud server, and reducing the computing burden of the mobile device caused by frequent data upload, thereby improving the efficiency of image retrieval. During the image retrieval process, a genetic algorithm is used to ensure finding the optimal combination of feature weights to calculate the composite similarity value, enabling efficient operation even on resource-constrained mobile devices and further improving the retrieval efficiency. In this embodiment, by combining color features and texture features for image retrieval, the retrieval system can comprehensively consider various information of the image and improve the accuracy of similarity measurement.
[0060] In a possible implementation of the above step S101, based on the HSV block color histogram algorithm, obtain the color feature vector of the image to be retrieved in the Android system, including:
[0061] Obtain the image to be retrieved, and use the first conversion algorithm to convert the RGB color space of the image to be retrieved into the HSV color space;
[0062] Preprocess the HSV color space of the image to be retrieved, classify the colors that meet the first lightness condition as black, and classify the colors that meet the second lightness condition as white;
[0063] Quantize the preprocessed HSV color space, and based on the preset quantization level, convert the HSV color space into a one-dimensional vector to determine the color feature vector of the image to be retrieved.
[0064] In this embodiment, since the RGB values in the Red Green Blue (RGB) color space cannot accurately reflect colors, it is necessary to convert the RGB color space to the HSV color space.
[0065] As Figure 2 shown, Figure 2 is a schematic diagram of the HSV color model of an image retrieval method provided by an embodiment of the present disclosure based on the Android system. Among them, the long axis V can represent brightness. When V = I on the top surface of the cone, the brightness is brighter at this time.
[0066] The rotation angle around the V axis can represent the hue H. When the rotation angle is 0°, it can represent red; when the rotation angle is 60°, it can represent yellow; when the rotation angle is 120°, it can represent green; when the rotation angle is 180°, it can represent cyan; when the rotation angle is 240°, it can represent blue; when the rotation angle is 320°, it can represent magenta.
[0067] The value of the saturation S can transition from the center of the cone to the circumference, that is, the value range is [0, 1].
[0068] Furthermore, at the vertex of the cone where V = 0, H and S are undefined, representing black: at the center of the top surface of the cone where S = 0, V = I, and H is undefined, it represents white.
[0069] In a possible implementation manner of the above embodiment, the first conversion algorithm can be shown as the following formula:
[0070] V = max(R, G, B)
[0071]
[0072] Let Then there is
[0073]
[0074] H = 60 × H'
[0075] Among them, the value ranges of H, S, and V can be [0, 360], [0, 1], and [0, 1] respectively.
[0076] In a possible implementation manner, the following formula is used to calculate the color histogram of the HSV color space:
[0077]
[0078] Among them, the size of the image can be M*N, and the pixel color value of the i-th row and j-th column is represented by a ij The set S can represent the quantized color channels.
[0079] Furthermore, after converting the RGB color space to the HSV color model and calculating the color histogram, the accuracy of the HSV color model can be further improved and the dimension of the color histogram can be reduced.
[0080] In a possible implementation, preprocessing the HSV color space of the image to be retrieved, classifying the colors that meet the first lightness condition as black, and classifying the colors that meet the second lightness condition as white, may include:
[0081] Classify all colors with V < 15% as black, set H = 0, S = 0, V = 0; classify all colors with S < 10% and V > 80% as white, set H = 0, S = 0, V = 1; keep the HSV values of other colors unchanged.
[0082] Furthermore, performing quantization processing on the preprocessed HSV color space may include:
[0083] Perform quantization processing on the three components of H, S, and V using the following formula.
[0084]
[0085] Among them, divide the color space of hue H into 8 parts, and divide the color spaces of saturation S and brightness V into 3 parts.
[0086] Even further, based on a preset quantization level, converting the HSV color space into a one-dimensional vector to determine the color feature vector of the image to be retrieved may include:
[0087] Construct a one-dimensional feature vector L using the following color components:
[0088] L = HQ s Q v + SQ v + V
[0089] Among them, Q s represents the quantization level of component S, and Q v represents the quantization level of component V. As an example, Q s = Q v = 4. Therefore, the one-dimensional feature vector L can be expressed as: L = 16H + 4S + V.
[0090] Here, according to L = 16H + 4S + V, the one-dimensional color feature vector of the image to be retrieved can be determined. The weights of hue H, saturation S, and brightness V are set to 16, 4, and 1 respectively. This can highlight the image hue while weakening the influence of image saturation and brightness on the retrieval result. Moreover, the value range of L is [0, 1, 2, …, 122], so the HSV color space is divided into 123 colors. These 123 representative colors can effectively represent colors while greatly reducing the computational amount.
[0091] In a possible implementation manner, the method may further include:
[0092] Using the K-means clustering algorithm to cluster the extracted color feature vectors.
[0093] As an example, the initial number of clusters can be set to 10. Using the K-means clustering algorithm, the extracted color feature vectors are clustered into 10 clusters, thereby reducing the data processing amount of image retrieval.
[0094] In the above-mentioned image retrieval method and image retrieval system based on the Android system of the present disclosure, by converting the RGB color space to the HSV color space, complex color information can be better processed, and color preprocessing can be performed to effectively reduce the interference of irrelevant colors, thereby improving the accuracy of color feature extraction. Quantifying the H, S, and V components can effectively reduce the dimension of the color space, while maintaining the integrity of the image color features, reducing the computational complexity, and improving the efficiency of picture retrieval in the mobile terminal. Through the preset quantization level, the HSV color space is mapped from three dimensions to a one-dimensional feature vector, greatly reducing the dimension of the color feature vector of each image and reducing the computational amount. This optimization effectively reduces the resource consumption required for subsequent similarity calculation.
[0095] In a possible implementation manner of the above-mentioned embodiment, based on the gray-level co-occurrence matrix algorithm, obtaining the texture feature vector of the image to be retrieved includes:
[0096] Using a second conversion algorithm to convert the RGB color space of the image to be retrieved into a gray scale space;
[0097] Based on the joint probability between two gray scale pixels satisfying preset conditions in the gray scale space, determining the probability density matrix of the gray scale space;
[0098] Selecting at least one direction in the gray scale space, and based on the probability density matrix of at least one direction, determining the gray-level co-occurrence matrix of each direction in at least one direction;
[0099] Extract the gray-level co-occurrence matrix in each direction, determine at least one characteristic parameter, and based on at least one characteristic parameter, determine the texture feature vector of the image to be retrieved.
[0100] In this embodiment, the second conversion algorithm can be as follows:
[0101] Gray = R × 0.299 + G × 0.587 + B × 0.144
[0102] Using the above second conversion algorithm, convert the RGB color space of the image to be retrieved into a gray-level space.
[0103] In a possible implementation, the joint probability between two gray-level pixels satisfying a preset condition in the gray-level space may refer to the joint probability that two gray-level pixels with a distance of D = (dx, dy) appear simultaneously in the gray-level space.
[0104] Furthermore, determining the probability density matrix of the gray-level space based on the joint probability between two gray-level pixels satisfying a preset condition in the gray-level space may include:
[0105] The probability density matrix of the gray-level space is represented by the following formula:
[0106]
[0107] Where P(u, v) represents the joint probability that the pixel values u and v of two gray-level pixels with a distance of D = (dx, dy) in the gray-level space appear simultaneously; f(x, y) represents the gray-level value of the pixel (x, y) in the image; S represents the set of pixels in the image, and #S represents the total number of pixel pairs in the image; [(x, y), (x + d x , y + d y )] represents the coordinates of the pixel pair at the specified distance (d x , d y ).
[0108] Here, first, by counting the gray-level values of all pixel pairs (x, y) and (x + d x , y + d y ), and then counting the occurrence frequency of each pair of gray-level values (u, v), divide the frequency by the total number of pixel pairs #S to calculate the probability density.
[0109] Furthermore, since the calculation amount of the above formula is too large, the above formula needs to be further simplified.
[0110] Select at least one direction in the gray-level space, and based on the probability density matrix in at least one direction, determine the gray-level co-occurrence matrix in each direction in at least one direction, which may include:
[0111] Four directions are selected in P(u, v) for actual calculation to determine the gray-level co-occurrence matrix in each direction.
[0112] Here, the four directions can be (0°, 45°, 90°, 135°), represented by the distance d. The four directions can be expressed as (0, d), (d, d), (d, 0), (-d, d). The spatial relationship of the four directions can be as Figure 3 shown Figure 3 which is a schematic diagram of the four-direction spatial relationship of an image retrieval method based on the Android system provided by an embodiment of the present disclosure.
[0113] The above P(u, v) is simplified using four directions, and the simplified result can be as follows:
[0114]
[0115] According to the above formula, half of the gray-level co-occurrence matrix in the four directions can be calculated. Since P(u, v) is a symmetric matrix, after flipping and superimposing the above half of the gray-level formula matrix, the complete gray-level co-occurrence matrix can be determined, that is:
[0116] P(u, v, d, θ) = P(u, v, d, θ) + P(u, v, d, θ) T
[0117] Here, θ can take values of 0°, 45°, 90°, and 135° to represent the gray-level co-occurrence matrices in the four directions respectively.
[0118] As an example, assuming that the size of image I is 4*4, the gray level range is 1-6, the unit distance is selected as 1, and the direction is 0°, the calculated gray-level co-occurrence matrix can be as Figure 4 shown Figure 4 which is a schematic diagram of the gray-level co-occurrence matrix of an image retrieval method based on the Android system provided by an embodiment of the present disclosure.
[0119] In the image retrieval method and image retrieval system based on the Android system in the above embodiments of the present disclosure, by selecting four main directions and optimizing with the help of symmetry, both the efficiency of the algorithm and the calculation speed are guaranteed, enabling the image retrieval of the mobile terminal to be performed without relying on a cloud server for complex calculations, reducing the dependence on the cloud for image retrieval. By introducing various feature extraction methods such as HSV color histograms and gray-level co-occurrence matrices, the color and texture information of the image can be fully mined, thereby improving the accuracy of image retrieval. Combining texture features and color features makes this method more efficient and comprehensive than traditional single-feature methods.
[0120] In a possible implementation of the above embodiment, the feature parameters include at least one of the following: energy, contrast, entropy, inverse difference moment, or homogeneity. Extract the gray-level co-occurrence matrix in each direction, and determine at least one feature parameter, including:
[0121] Based on the texture fineness of the image to be retrieved, extract the energy feature parameter among the feature parameters from the gray-level co-occurrence matrix in each direction;
[0122] Based on the texture strength and image sharpness of the image to be retrieved, extract the contrast feature parameter among the feature parameters from the gray-level co-occurrence matrix in each direction;
[0123] Based on the texture complexity of the image to be retrieved, extract the entropy feature parameter among the feature parameters from the gray-level co-occurrence matrix in each direction;
[0124] Based on the local uniformity of the image to be retrieved, extract the inverse difference moment feature parameter among the feature parameters from the gray-level co-occurrence matrix in each direction;
[0125] Based on the distribution tightness of the elements in the gray-level co-occurrence matrix relative to the diagonal of the gray-level co-occurrence matrix, extract the homogeneity feature parameter among the feature parameters from the gray-level co-occurrence matrix in each direction.
[0126] In this embodiment, the energy feature parameter may refer to the Angular Second Moment (ASM), which is used to reflect the uniformity and consistency of the image texture. The smaller the value of the energy, it can indicate that most areas in the image are fine textures or messy; while the larger the value of the energy, it indicates that most of the image areas are rough textures.
[0127] The contrast feature parameter can represent the change range of the pixel gray values in the image to reflect the texture strength and image sharpness. A larger contrast can indicate that the local differences in the image are larger, and there are larger gray differences between adjacent pixels; while a smaller contrast can indicate that the image is more uniform, and the gray differences between adjacent pixels are small.
[0128] The entropy feature parameter can describe the complexity or clutter of the image. The higher the entropy value, the more complex the texture of the image, the more information it contains, the more irregular or detailed the texture; the lower the entropy value, the simpler, more uniform, and lacking in complex information the image is.
[0129] The Inverse Difference Moment (IDM) feature parameter can describe the local uniformity of the image. The higher its value, the more uniform the texture in the local area of the image.
[0130] The homogeneity feature parameter can represent the tightness of the elements in the gray-level co-occurrence matrix relative to the diagonal. Its value range is [0, 1]. The higher the value, the more uniform the gray-level distribution of the image can be represented.
[0131] In the image retrieval method and image retrieval system based on the Android system in the above embodiments of the present disclosure, by simplifying the gray-level co-occurrence matrix in terms of direction and feature parameters, the computational complexity can be significantly reduced, thereby improving the efficiency of image retrieval. By extracting different directions and different feature parameters, complex texture patterns in the image can be captured, improving the accuracy of image retrieval.
[0132] In a possible implementation manner of the above embodiment, a fitness function is constructed, and the genetic algorithm is used to calculate the target color feature weight and target texture feature weight corresponding to the optimal solution of the fitness function, which is implemented based on the following steps:
[0133] In the initial population of the genetic algorithm, initial color feature weights and initial texture feature weights are assigned to at least one individual, and the color feature similarity value and texture feature similarity value between each individual in the at least one individual and at least one target image are determined; the initial color feature weight is used to weight the color feature similarity value, and the initial texture feature weight is used to weight the texture feature similarity value;
[0134] A fitness function is constructed through a preset recall rate and a preset precision rate. Based on the fitness function and the color feature similarity value and texture feature similarity value of each individual in the initial population, selection, crossover, and mutation processing are performed on the initial population to determine the optimal solution of the fitness function, and the target color feature weight and target texture feature weight corresponding to the optimal solution.
[0135] In this embodiment, it is assumed that there are N individuals in the initial population I. The solution space is divided into N groups, and the center of each group is defined as an individual to find the optimal solution more quickly.
[0136] An initial color feature weight C w and an initial texture feature weight T w are assigned to each individual, and the color feature similarity value and texture feature similarity value between each individual and at least one target image in the database are calculated.
[0137] The following formula is used to construct the fitness function:
[0138]
[0139] Among them, R represents the recall rate, and P represents the precision rate.
[0140] Furthermore, the following formulas can be used to calculate the recall rate R and the precision rate P:
[0141]
[0142] Here, when the image retrieved by an individual is relevant to the image to be retrieved, let v i = 1, a represents the number of relevant images retrieved, k represents the number of target images in the database, and M represents taking the top M images among the relevant images.
[0143] Determine the fitness of each individual based on the fitness function, perform selection, crossover, and mutation operations on the population according to the fitness of the individuals, and repeatedly adjust the weights of the individuals in the population to determine the optimal solution of the fitness function, thereby determining the target color feature weight C w * and the target texture feature weight T w * .
[0144] Furthermore, according to the target color feature weight C w * and the target texture feature weight T w * Calculate the composite similarity value of the image to be retrieved corresponding to at least one target image, sort based on at least one composite similarity value, and determine at least one target image relevant to the image to be retrieved as the retrieval result.
[0145] In the image retrieval method and image retrieval system based on the Android system in the above embodiments of the present disclosure, by introducing a genetic algorithm to optimize the final weights of color features and texture features, and by defining a fitness function and performing selection, crossover, and mutation operations, it is ensured that the optimal combination of feature weights can be found to calculate the composite similarity value; this optimization mechanism enables efficient operation even on resource-constrained mobile devices, further improving the retrieval efficiency.
[0146] In a possible implementation manner, the image retrieval method based on the Android system in the embodiments of the present disclosure can adopt an asynchronous task mechanism. Through the built-in AsyncTask mechanism of the Android system, the processes of image preprocessing and image retrieval are encapsulated in a custom AsyncTask class to ensure that long-running tasks do not block the main thread and keep the user interface smooth.
[0147] Here, through the AsyncTask mechanism, long-running operations can be moved to the background thread for execution, thereby avoiding blocking the main thread (UI thread) and causing the application interface to freeze.
[0148] In the image retrieval method and image retrieval system based on the Android system in the above embodiments of the present disclosure, by combining a custom AsyncTask class, the image preprocessing and image retrieval are encapsulated to ensure that long-term tasks do not block the main thread and maintain the smoothness of the user interface, thus solving the problem that the PC-side system is difficult to be transplanted to the mobile side and providing a better interaction experience for users.
[0149] In one embodiment, an image retrieval system 500 is provided. The image retrieval system 500 corresponds one-to-one to the image retrieval method based on the Android system in the above embodiments. As Figure 5 shown, the image retrieval system 500 includes an image processing module 501, a similarity calculation module 502, a weight determination module 503, and an image retrieval module 504. Among them, the detailed descriptions of each functional module are as follows:
[0150] The image processing module 501 is configured to obtain a color feature vector of the image to be retrieved in the Android system based on the HSV block color histogram algorithm, and obtain a texture feature vector of the image to be retrieved based on the gray-level co-occurrence matrix algorithm;
[0151] The similarity calculation module 502 is configured to use the Euclidean distance to determine a color feature similarity value between the color feature vector and the target color feature vector of the target image in the database, and determine a texture feature similarity value between the texture feature vector and the target texture feature vector of the target image;
[0152] The weight determination module 503 is configured to construct a fitness function and use a genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function;
[0153] The image retrieval module 504 is configured to determine a composite similarity value between the image to be retrieved and the target image based on the target color feature weight, the color feature similarity value, the target texture feature weight, and the texture feature similarity value, and determine at least one target image in the database as the retrieval result of the image to be retrieved based on the sorting result of at least one composite similarity value.
[0154] In one embodiment, the image processing module 501 is configured to obtain the image to be retrieved and use a first conversion algorithm to convert the RGB color space of the image to be retrieved into the HSV color space;
[0155] Preprocess the HSV color space of the image to be retrieved, classify the colors that meet the first brightness condition as black, and classify the colors that meet the second brightness condition as white;
[0156] Quantize the preprocessed HSV color space, and convert the HSV color space into a one-dimensional vector based on a preset quantization level to determine the color feature vector of the image to be retrieved.
[0157] In one embodiment, the image processing module 501 is configured to convert the RGB color space of the image to be retrieved into a grayscale space by using a second conversion algorithm;
[0158] Based on the joint probability between two grayscale pixels satisfying a preset condition in the grayscale space, determine the probability density matrix of the grayscale space;
[0159] Select at least one direction in the grayscale space, and based on the probability density matrix in at least one direction, determine the gray-level co-occurrence matrix of each direction in at least one direction;
[0160] Extract the gray-level co-occurrence matrix of each direction, determine at least one type of feature parameter, and based on at least one type of feature parameter, determine the texture feature vector of the image to be retrieved.
[0161] In one embodiment, the image processing module 501 is configured to extract the energy feature parameter in the feature parameters from the gray-level co-occurrence matrix of each direction based on the texture fineness of the image to be retrieved;
[0162] Based on the texture strength and image sharpness of the image to be retrieved, extract the contrast feature parameter in the feature parameters from the gray-level co-occurrence matrix of each direction;
[0163] Based on the texture complexity of the image to be retrieved, extract the entropy feature parameter in the feature parameters from the gray-level co-occurrence matrix of each direction;
[0164] Based on the local uniformity of the image to be retrieved, extract the inverse difference moment feature parameter in the feature parameters from the gray-level co-occurrence matrix of each direction;
[0165] Based on the distribution tightness of the elements in the gray-level co-occurrence matrix relative to the diagonal of the gray-level co-occurrence matrix, extract the homogeneity feature parameter in the feature parameters from the gray-level co-occurrence matrix of each direction.
[0166] In one embodiment, the weight determination module 503 is configured to assign an initial color feature weight and an initial texture feature weight to at least one individual in the initial population of the genetic algorithm, and determine the color feature similarity value and the texture feature similarity value between each individual in at least one individual and at least one target image; the initial color feature weight is used to weight the color feature similarity value, and the initial texture feature weight is used to weight the texture feature similarity value;
[0167] Construct a fitness function through a preset recall rate and a preset precision rate, and based on the fitness function and the color feature similarity value and the texture feature similarity value of each individual in the initial population, perform selection, crossover, and mutation processing on the initial population to determine the optimal solution of the fitness function, and the target color feature weight and the target texture feature weight corresponding to the optimal solution.
[0168] It should be noted that when implementing the corresponding image retrieval method based on the Android system, the image retrieval system provided in the above embodiments is only illustrated by dividing the above program modules. In practical applications, the above processing can be allocated to different program modules according to needs, that is, the internal structure of the above system is divided into different program modules to complete all or part of the processing described above. In addition, the system provided in the above embodiments and the corresponding Figure 1b embodiment of the method shown belong to the same concept. For the specific implementation process, please refer to the method embodiment, which will not be elaborated here.
[0169] The embodiments of the present disclosure also provide a computer device having the above Figure 5 shown image retrieval system.
[0170] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of another image retrieval system provided by the embodiments of the present disclosure. As shown in Figure 6 , the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including a high-speed interface and a low-speed interface. Each component communicates with each other using different buses and can be installed on a common main board or in other ways according to needs. The processor can process instructions executed within the computer device, including instructions stored in the memory or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some alternative embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a set of blade servers, or a multi-processor system). Figure 6 In
[0171] , one processor 10 is taken as an example.
[0172] The processor 10 can be a central processing unit, a network processor, or a combination thereof. Among them, the processor 10 can further include a hardware chip. The above hardware chip can be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The above programmable logic device can be a complex programmable logic device, a field programmable gate array, a general array logic, or any combination thereof.
[0173] The memory 20 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some alternative embodiments, the memory 20 may optionally include a memory remotely provided with respect to the processor 10, and these remote memories may be connected to the computer device through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0174] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, a hard disk, or a solid-state drive; the memory 20 may further include a combination of the above types of memory.
[0175] The computer device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30, and the output device 40 may be connected through a bus or other means. Figure 6 Taking connection through a bus as an example.
[0176] The input device 30 may receive input digital or character information and generate key signal inputs related to the user settings and function controls of the computer device, such as a touch screen, a keypad, a mouse, a trackpad, a touchpad, a pointing stick, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED), and a haptic feedback device (e.g., a vibration motor), etc. The above display device includes but is not limited to a liquid crystal display, a light-emitting diode, a display, and a plasma display. In some alternative embodiments, the display device may be a touch screen.
[0177] The computer device further includes a communication interface for the computer device to communicate with other devices or a communication network.
[0178] Embodiments of the present disclosure also provide a computer-readable storage medium. The methods according to the embodiments of the present disclosure can be implemented in hardware, firmware, or be implemented as computer code that can be recorded on a storage medium, or be implemented as computer code that is originally stored in a remote storage medium or a non-transitory machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the methods described herein can be processed by such software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code, and when the software or computer code is accessed and executed by the computer, the processor, or the hardware, the methods shown in the above embodiments are implemented.
[0179] A part of the present disclosure can be applied as a computer program product, such as computer program instructions, which when executed by a computer, can call or provide the methods and / or technical solutions according to the present disclosure through the operation of the computer. Those skilled in the art should be able to understand that the forms of existence of computer program instructions in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0180] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. An image retrieval method based on Android system, characterized in that: The method comprises: Based on the HSV block color histogram algorithm, the color feature vector of the image to be retrieved in the Android system is obtained, and based on the gray-level co-occurrence matrix algorithm, the texture feature vector of the image to be retrieved is obtained; Using Euclidean distance, determining a color feature similarity value between the color feature vector and a target color feature vector of a target image in a database, and determining a texture feature similarity value between the texture feature vector and a target texture feature vector of the target image; Constructing a fitness function, and using a genetic algorithm to calculate a target color feature weight and a target texture feature weight corresponding to an optimal solution of the fitness function; Based on the target color feature weight, the color feature similarity value, the target texture feature weight and the texture feature similarity value, a composite similarity value between the image to be retrieved and the target image is determined; based on the sorting result of at least one composite similarity value, at least one target image is determined in the database as a retrieval result of the image to be retrieved.
2. The method according to claim 1, characterized in that The method of obtaining the color feature vector of the image to be retrieved in the Android system based on the HSV block color histogram algorithm includes: Acquire the image to be retrieved, and use the first conversion algorithm to convert the RGB color space of the image to be retrieved into the HSV color space; Preprocessing the HSV color space of the image to be retrieved, classifying colors that meet a first brightness condition as black, and classifying colors that meet a second brightness condition as white; The preprocessed HSV color space is quantized, and based on a preset quantization level, the HSV color space is converted into a one-dimensional vector to determine the color feature vector of the image to be retrieved.
3. The method according to claim 1, characterized in that The step of obtaining the texture feature vector of the image to be retrieved based on the gray level co-occurrence matrix algorithm includes: Using a second conversion algorithm, the RGB color space of the image to be retrieved is converted into a grayscale space; Determining a probability density matrix of the grayscale space based on a joint probability between two grayscale pixels that meet a preset condition in the grayscale space; Selecting at least one direction in the grayscale space, and determining a gray level co-occurrence matrix of each direction in the at least one direction based on a probability density matrix of the at least one direction; The gray level co-occurrence matrix of each direction is extracted to determine at least one characteristic parameter, and based on the at least one characteristic parameter, a texture feature vector of the image to be retrieved is determined.
4. The method according to claim 3, characterized in that: The characteristic parameter includes at least one of the following: energy, contrast, entropy, inverse moment or homogeneity, and the extracting of the gray level co-occurrence matrix in each direction to determine at least one characteristic parameter includes: Based on the texture coarseness of the image to be retrieved, extracting energy characteristic parameters from the characteristic parameters in the gray level co-occurrence matrix in each direction; Based on the texture strength and image clarity of the image to be retrieved, extracting contrast feature parameters from the feature parameters in the gray level co-occurrence matrix in each direction; Extracting entropy feature parameters from the feature parameters in the gray level co-occurrence matrix in each direction based on the texture complexity of the image to be retrieved; Based on the local uniformity of the image to be retrieved, extracting the inverse moment feature parameters in the feature parameters in the gray level co-occurrence matrix in each direction; Based on the distribution density of the elements in the gray level co-occurrence matrix relative to the diagonal of the gray level co-occurrence matrix, a homogeneity feature parameter among the feature parameters is extracted in the gray level co-occurrence matrix in each direction.
5. The method according to claim 4, characterized in that Construct a fitness function, and use a genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function, based on the following steps: Assigning an initial color feature weight and an initial texture feature weight to at least one individual in an initialization population of a genetic algorithm, and determining a color feature similarity value and a texture feature similarity value between each individual in the at least one individual and at least one target image; the initial color feature weight is used to weight the color feature similarity value, and the initial texture feature weight is used to weight the texture feature similarity value; A fitness function is constructed by a preset recall rate and a preset precision rate. Based on the fitness function and the color feature similarity value and the texture feature similarity value of each individual in the initialized population, the initialized population is selected, crossed and mutated to determine the optimal solution of the fitness function, as well as the target color feature weight and the target texture feature weight corresponding to the optimal solution.
6. An image retrieval system, characterized in that: The image retrieval system includes an image processing module, a similarity calculation module, a weight determination module and an image retrieval module, wherein: An image processing module is used to obtain the color feature vector of the image to be retrieved in the Android system based on the HSV block color histogram algorithm, and to obtain the texture feature vector of the image to be retrieved based on the gray-level co-occurrence matrix algorithm; A similarity calculation module, used to determine a color feature similarity value between the color feature vector and a target color feature vector of a target image in a database, and to determine a texture feature similarity value between the texture feature vector and a target texture feature vector of the target image, using Euclidean distance; A weight determination module is used to construct a fitness function and use a genetic algorithm to calculate the target color feature weight and the target texture feature weight corresponding to the optimal solution of the fitness function; An image retrieval module is used to determine a composite similarity value between the image to be retrieved and the target image based on the target color feature weight, the color feature similarity value, the target texture feature weight and the texture feature similarity value, and based on a sorting result of at least one composite similarity value, determine at least one target image in the database as a retrieval result of the image to be retrieved.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the Android system-based image retrieval method according to any one of claims 1 to 5.
8. A computer program product, characterized in that It includes computer instructions, and the computer instructions are used to enable a computer to execute the image retrieval method based on the Android system as described in any one of claims 1-5.