Image clustering method, device, electronic device and storage medium
By obtaining the clustering factors and corresponding neighborhood radii of multiple images, setting multiple radius divisions to obtain multiple neighborhoods, and clustering image collections based on these neighborhoods, the inaccuracy in image classification in the existing technology is solved. problem, improving the accuracy of image clustering.
Patent Information
- Application Number
- CN202010917917.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-03
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-09-03
AI Technical Summary
When existing electronic devices cluster images, they only cluster from a fixed dimension, resulting in inaccurate image classification.
By obtaining the clustering factors and corresponding neighborhood radii of multiple images, setting multiple radius divisions to obtain multiple neighborhoods, and clustering image collections based on these neighborhoods, the accuracy of image clustering is improved.
The accuracy of image clustering is improved. By setting multiple radius divisions when using multiple clustering factors, a more accurate image collection is obtained and the accuracy of image classification is enhanced.
Smart Images

Figure CN112070144B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and more specifically, to an image clustering method, device, electronic device and storage medium. Background Art
[0002] With the development of science and technology, electronic devices are used more and more widely and have more and more functions. They have become one of the necessities in people's daily life. Among them, the photo album of electronic devices generally has an image classification function, that is, images are selected from the album according to pre-set conditions and classified. At present, electronic devices are not accurate in image classification. Summary of the invention
[0003] In view of the above problems, the present application proposes an image clustering method, device, electronic device and storage medium to solve the above problems.
[0004] In a first aspect, an embodiment of the present application provides an image clustering method, the method comprising: obtaining multiple images, and obtaining multiple clustering factors for the multiple images, wherein each image in the multiple images serves as a data point; obtaining a target image from the multiple images, and obtaining multiple neighborhood radii corresponding to the multiple clustering factors; taking the target image as the data point center and the multiple neighborhood radii as radii, obtaining multiple neighborhoods of the target image, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii; respectively obtaining images located in each neighborhood of the multiple neighborhoods to obtain multiple image sets; obtaining a target image set based on the multiple image sets, and clustering the images contained in the target image set.
[0005] In a second aspect, an embodiment of the present application provides an image aggregation device, comprising: an image acquisition module, used to acquire multiple images and acquire multiple clustering factors for the multiple images, wherein each of the multiple images serves as a data point; a neighborhood radius acquisition module, used to acquire a target image from the multiple images, and acquire multiple neighborhood radii corresponding to the multiple clustering factors; a neighborhood acquisition module, used to acquire multiple neighborhoods of the target image with the target image as the center of the data point and the multiple neighborhood radii as radii, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii; an image set acquisition module, used to respectively acquire images located in each neighborhood of the multiple neighborhoods to obtain multiple image sets; an image clustering module, used to obtain a target image set based on the multiple image sets, and cluster the images contained in the target image set.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.
[0008] The image clustering method, device, electronic device and storage medium provided in the embodiments of the present application obtain multiple images and obtain multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, and the target image is taken as the center of the data point and the multiple neighborhood radii are taken as radii to obtain multiple neighborhoods of the target image, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii, and images located in each neighborhood of the multiple neighborhoods are respectively obtained to obtain multiple image sets, a target image set is obtained based on the multiple image sets, and the images included in the target image set are clustered, so as to improve the accuracy of image clustering by setting multiple neighborhood radius divisions to obtain multiple neighborhoods when there are multiple clustering factors, and clustering the images included in the target image set obtained based on the multiple image sets corresponding to the multiple neighborhoods. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0010] Figure 1 A schematic diagram of a process of an image clustering method provided by an embodiment of the present application is shown;
[0011] Figure 2 A schematic diagram of a process of an image clustering method provided by another embodiment of the present application is shown;
[0012] Figure 3 A schematic diagram of a process of an image clustering method provided in another embodiment of the present application is shown;
[0013] Figure 4 A schematic diagram of a process of an image clustering method provided by another embodiment of the present application is shown;
[0014] Figure 5 This application shows Figure 4The schematic diagram of the process of step S470 of the image clustering method shown;
[0015] Figure 6 This application shows Figure 5 The schematic diagram of the process of step S472 of the image clustering method shown;
[0016] Figure 7 A module block diagram of an image clustering device provided in an embodiment of the present application is shown;
[0017] Figure 8 A block diagram of an electronic device for executing an image clustering method according to an embodiment of the present application is shown;
[0018] Fig. 9 A storage unit for storing or carrying program codes for implementing the image clustering method according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0020] At present, when electronic devices cluster images in an album, they mainly use the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) clustering algorithm to cluster images according to a clustering condition. For example, the DBSCAN clustering algorithm is used to cluster images according to the shooting location information of the images. However, the inventors have found through research that, because the current image clustering only clusters images from a fixed dimension, and other dimensions are not used as references, the image classification is inaccurate.
[0021] In view of the above problems, the inventors have discovered after long-term research and proposed the image clustering method, device, electronic device and storage medium provided in the embodiments of the present application. When there are multiple clustering factors, multiple neighborhood radius divisions are set to obtain multiple neighborhoods, and the images included in the target image set obtained by clustering the multiple image sets corresponding to the multiple neighborhoods are obtained, thereby improving the accuracy of image clustering. Among them, the specific image clustering method is described in detail in the subsequent embodiments.
[0022] See also Figure 1 , Figure 1The flowchart of an image clustering method provided by an embodiment of the present application is shown. The image clustering method is used to obtain multiple neighborhoods by setting multiple neighborhood radius divisions when there are multiple clustering factors, and clustering the images included in the target image set obtained based on the multiple image sets corresponding to the multiple neighborhoods, so as to improve the accuracy of image clustering. In a specific embodiment, the image clustering method is applied to Figure 7 The image clustering device 200 and the electronic device 100 ( Figure 8 ). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment can be a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the image clustering method may specifically include the following steps:
[0023] Step S110: acquiring a plurality of images, and acquiring a plurality of clustering factors for the plurality of images, wherein each image in the plurality of images is regarded as a data point.
[0024] In this embodiment, multiple images can be obtained, and multiple clustering factors for the multiple images can be obtained. For example, multiple images can be obtained from the photo album of the electronic device, and multiple clustering factors for the multiple images can be obtained, multiple images can be obtained from the cache of the chat application of the electronic device, and multiple clustering factors for the multiple images can be obtained, and multiple images can be obtained from a server connected to the electronic device, and multiple clustering factors for the multiple images can be obtained, etc. Among them, the image can include static pictures, dynamic pictures, videos, etc., which are not limited here. Among them, the corresponding units, spans, and representation methods of the multiple clustering factors may be different. For example, if the multiple clustering factors can include shooting time information and shooting location information, the units, spans, and representation methods of the shooting time information and the shooting location information are different.
[0025] In some embodiments, multiple clustering factors for multiple images can be automatically configured when the electronic device leaves the factory, or can be manually configured by the user during the use of the electronic device, etc., which is not limited here. Among them, the clustering factors for multiple images can be used to characterize clustering conditions that affect the clustering of images. For example, the shooting position information corresponding to the image can affect the clustering of multiple images, and the shooting position information can be used as a clustering factor. The shooting time information corresponding to the image can affect the clustering of multiple images, and the shooting time information can be used as a clustering factor. The shooting object information corresponding to the image can affect the clustering of multiple images, and the shooting object information can be used as a clustering factor, etc., which is not limited here. As a way, multiple clustering factors can include a first clustering factor, a second clustering factor, a point clustering factor...Nth clustering factor, and the specific number of clustering factors can be adjusted and updated according to demand, which is not limited here.
[0026] In some embodiments, after acquiring multiple images, each of the multiple images can be used as a data point. For example, assuming that the multiple images include a first image, a second image, a third image, a fourth image, and a fifth image, the first image, the second image, the third image, the fourth image, and the fifth image can be used as a data point, such as the first image as the first data point, the second image as the second data point, the third image as the third data point, the fourth image as the fourth data point, and the fifth image as the fifth data point.
[0027] Step S120: obtaining a target image from the multiple images, and obtaining multiple neighborhood radii corresponding to the multiple clustering factors.
[0028] In this embodiment, after obtaining multiple images and multiple clustering factors for the multiple images, the multiple images may be screened, a target image may be obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors may be obtained.
[0029] In some embodiments, after acquiring multiple images, an image may be randomly selected from the multiple images as the target image, the images may be sequentially selected as the target image in the sorting order of the multiple images, the images may be sequentially selected as the target image in the sorting order of the multiple images, etc. In some embodiments, after acquiring multiple images, an image that has not been subjected to clustering processing is acquired from the multiple images, and an image is randomly selected from the images that have not been subjected to clustering processing as the target image, the images may be sequentially selected as the target image in the sorting order of the images that have not been subjected to clustering processing, the images may be sequentially selected as the target image in the sorting order of the images that have not been subjected to clustering processing, etc.
[0030] In some embodiments, the electronic device may store multiple clustering factors and multiple neighborhood radii eps, and store the corresponding relationship between the multiple clustering factors and the multiple neighborhood radii, wherein the corresponding relationship may be one clustering factor corresponding to one or more neighborhood radii. The corresponding relationship between the clustering factor and the neighborhood radius may be pre-set by the user and stored in the electronic device, may be pre-set automatically by the electronic device and stored, or may be pre-set by the server and sent to the electronic device, which is not limited here.
[0031] As a method, the electronic device can create a mapping relationship table, which may include the correspondence between multiple clustering factors and multiple neighborhood radii. For example, the mapping relationship table may be as shown in Table 1, wherein the clustering factor is represented by A and the neighborhood radius is represented by B. Then, through the mapping relationship table, the electronic device can set the correspondence between the clustering factor and the neighborhood radius and store it locally in the electronic device.
[0032] Table 1
[0033] Clustering Factor Neighborhood radius A1 B1 A2 B2 A3 B3 A4 B4
[0034] Further, in this embodiment, after obtaining multiple clustering factors, clustering factors that are consistent with multiple clustering factors for multiple images can be searched from the mapping relationship table, and then based on the correspondence between clustering factors and neighborhood radius in the mapping relationship table, neighborhood radius corresponding to clustering factors that are consistent with multiple clustering factors for multiple images can be searched, and multiple neighborhood radius corresponding to multiple clustering factors for multiple images can be determined. For example, when multiple clustering factors for multiple images are consistent with clustering factor A1 and clustering factor A2, the neighborhood radius corresponding to clustering factor A1 can be further determined to be B1 based on the mapping relationship table, and the neighborhood radius B1 can be determined as the neighborhood radius corresponding to clustering factor A1, and the neighborhood radius corresponding to clustering factor A2 can be determined to be B2 based on the mapping relationship table, and the neighborhood radius B2 can be determined as the neighborhood radius corresponding to clustering factor A2.
[0035] Step S130: Taking the target image as the data point center and the multiple neighborhood radii as radii, a plurality of neighborhoods of the target image are acquired, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii.
[0036] In this embodiment, after obtaining the target image and multiple neighborhood radii corresponding to multiple clustering factors, multiple neighborhoods of the data point center can be delineated with the target image as the center of the data point and the multiple neighborhood radii as radii as the multiple neighborhoods of the target image.
[0037] In some embodiments, it is assumed that the plurality of neighborhood radii include a first neighborhood radius, a second neighborhood radius, a third neighborhood radius, ... an Nth neighborhood radius, and the first neighborhood radius, the second neighborhood radius, the third neighborhood radius, ... an Nth neighborhood radius have different units, spans, and representation methods. Then, the first neighborhood of the target image can be obtained by taking the target image as the center of the data point and the first neighborhood radius as the radius, the second neighborhood of the target image can be obtained by taking the target image as the center of the data point and the second neighborhood radius as the radius, the third neighborhood of the target image can be obtained by taking the target image as the center of the data point and the third neighborhood radius as the radius, ... the Nth neighborhood of the target image can be obtained by taking the target image as the center of the data point and the Nth neighborhood radius as the radius.
[0038] Step S140: respectively acquiring images located in each of the plurality of neighborhoods to obtain a plurality of image sets.
[0039] In this embodiment, after obtaining multiple neighborhoods based on multiple clustering factors, images in each of the multiple neighborhoods can be obtained respectively to obtain multiple image sets. After obtaining multiple neighborhoods, images in each of the multiple neighborhoods can be obtained respectively, and the images contained in each neighborhood are taken as an image set, and multiple image sets are obtained based on an image set corresponding to each of the multiple neighborhoods.
[0040] In some embodiments, assuming that the multiple neighborhoods include a first neighborhood, a second neighborhood, a third neighborhood...an Nth neighborhood, an image located in the first neighborhood can be acquired, and a first image set can be obtained based on the image located in the first neighborhood, an image located in the second neighborhood can be acquired, and a second image set can be obtained based on the image located in the second neighborhood, an image located in the third neighborhood can be acquired, and a third image set can be obtained based on the image located in the third neighborhood...an image located in the Nth neighborhood can be acquired, and an Nth image set can be obtained based on the image located in the Nth neighborhood, and multiple image sets can be obtained based on the first image set, the second image set, the third image set...and the Nth image set.
[0041] Step S150: obtaining a target image set based on the multiple image sets, and clustering the images contained in the target image set.
[0042] In this embodiment, after acquiring multiple image sets, a target image set may be obtained based on the multiple image sets, and the images included in the target image set may be clustered.
[0043] In some embodiments, after acquiring multiple image sets, the images included in each image set in the multiple image sets can be acquired respectively, wherein the images included in each image set can include the same image or different images, therefore, the images included in each image set can be compared to acquire images that exist simultaneously in the multiple image sets, and a target image set is obtained based on the images that exist simultaneously in the multiple image sets. In some embodiments, after acquiring multiple image sets, the intersection of the multiple image sets can be acquired, and the intersection is used as the target image set.
[0044] In some embodiments, after obtaining the target image set, the images contained in the target image can be clustered, for example, an image classification set can be created based on the images contained in the target image set, or the images contained in the target image set can be added to a pre-created image classification set, etc. After obtaining the target image set, the clustering factor corresponding to the target image set can be obtained. After obtaining the clustering factor corresponding to the target image set, it can be detected whether the pre-created image classification set includes an image classification set created based on the clustering factor corresponding to the target image set. When it is detected that the pre-created image classification set includes an image classification set created based on the clustering factor corresponding to the target image set, the images contained in the target image set can be added to the pre-created image classification set to which it belongs. When it is detected that the pre-created image classification set does not include an image classification set created based on the clustering factor corresponding to the target image set, an image classification set can be created based on the clustering factor corresponding to the target image set, and the images contained in the target image set can be added to the created image classification set.
[0045] An image clustering method provided by an embodiment of the present application obtains multiple images and obtains multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, multiple neighborhoods of the target image are obtained with the target image as the center of the data point and the multiple neighborhood radii as radii, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii, images located in each neighborhood of the multiple neighborhoods are respectively obtained, multiple image sets are obtained, a target image set is obtained based on the multiple image sets, and images included in the target image set are clustered, so as to improve the accuracy of image clustering by setting multiple neighborhood radii to divide and obtain multiple neighborhoods when there are multiple clustering factors, and clustering images included in the target image set obtained based on the multiple image sets corresponding to the multiple neighborhoods.
[0046] See also Figure 2 , Figure 2 FIG. 2 shows a flow chart of an image clustering method provided by another embodiment of the present application. Figure 2The process shown is described in detail. In this embodiment, the multiple clustering factors include a first clustering factor and a second clustering factor, wherein the first clustering factor corresponds to a first neighborhood radius, and the second clustering factor corresponds to a second neighborhood radius. The image clustering method may specifically include the following steps:
[0047] Step S210: Acquire multiple images, and acquire multiple clustering factors for the multiple images, wherein each image in the multiple images serves as a data point.
[0048] Step S220: obtaining a target image from the multiple images, and obtaining multiple neighborhood radii corresponding to the multiple clustering factors.
[0049] For the detailed description of step S210 to step S220, please refer to step S110 to step S120, which will not be repeated here.
[0050] Step S230: Taking the target image as the data point center and the first neighborhood radius as the radius, obtain the first neighborhood of the target image, and taking the target image as the data point center and the second neighborhood radius as the radius, obtain the second neighborhood of the target image.
[0051] In some embodiments, the plurality of clustering factors include a first clustering factor and a second clustering factor, the first clustering factor corresponds to a first neighborhood radius, and the second clustering factor corresponds to a second neighborhood radius. As a method, the first clustering factor may include shooting location information, and the second clustering factor may include shooting time information. The shooting location information may be two-dimensional data, and the shooting time information may be one-dimensional data.
[0052] As one way, after obtaining the first neighborhood radius corresponding to the target image and the shooting location information, the first neighborhood of the target image can be obtained with the target image as the center of the data point and the first neighborhood radius as the radius, wherein the first neighborhood can be a circular range with the target image as the center and N1 meters as the radius, which is not limited here. As another way, after obtaining the second neighborhood radius corresponding to the target image and the shooting time information, the second neighborhood of the target image can be obtained with the target image as the center of the data point and the second neighborhood radius as the radius, wherein the second neighborhood can be a circular range with the target image as the center and N2 hours as the radius, which is not limited here.
[0053] Step S240: Acquire images located in the first neighborhood to obtain a first image set, and acquire images located in the second neighborhood to obtain a second image set.
[0054] In this embodiment, after obtaining the first neighborhood based on the shooting location information and the first neighborhood radius and obtaining the second neighborhood based on the shooting time information and the second neighborhood radius, images located within the first neighborhood can be acquired, and a first image set can be obtained based on the images located within the first neighborhood, and images located within the second neighborhood can be acquired, and a second image set can be obtained based on the images located within the second neighborhood.
[0055] Step S250: obtaining a target image set based on the first image set and the second image set, and clustering the images included in the target image set.
[0056] In this embodiment, after the first image set and the second image set are acquired, a target image set may be acquired based on the first image set and the second image set, and the images included in the target image set may be clustered.
[0057] In some embodiments, after acquiring the first image set and the second image set, the images included in the first image set and the second image set can be acquired respectively, and the images included in the first image set and the second image set can be compared to acquire images that exist in both the first image set and the second image set, and a target image set is obtained based on the images that exist in both the first image set and the second image set. In some embodiments, after acquiring the first image set and the second image set, the intersection of the first image set and the second image set can be acquired, and the intersection is used as the target image set.
[0058] Another embodiment of the present application provides an image clustering method, which obtains multiple images and multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, a first neighborhood of the target image is obtained with the target image as the center of the data point and a first neighborhood radius as a radius, and a second neighborhood of the target image is obtained with the target image as the center of the data point and a second neighborhood radius as a radius, images located in the first neighborhood are obtained to obtain a first image set, and images located in the second neighborhood are obtained to obtain a second image set, a target image set is obtained based on the first image set and the second image set, and the images included in the target image set are clustered. Compared to Figure 1 The image clustering method shown in this embodiment also improves the accuracy of image clustering by setting a first neighborhood radius division corresponding to the first clustering factor to obtain a first neighborhood, setting a second neighborhood radius division corresponding to the second clustering factor to obtain a second neighborhood, and clustering the images included in the target image set obtained based on the first image set corresponding to the first neighborhood and the second image set corresponding to the second neighborhood.
[0059] See also Figure 3 , Figure 3 FIG. 2 shows a flow chart of an image clustering method provided by another embodiment of the present application. Figure 3 The process shown is described in detail, and the image clustering method may specifically include the following steps:
[0060] Step S310: Acquire multiple images, and acquire multiple clustering factors for the multiple images, wherein each image in the multiple images serves as a data point.
[0061] Step S320: obtaining a target image from the multiple images, and obtaining multiple neighborhood radii corresponding to the multiple clustering factors.
[0062] Step S330: Taking the target image as the data point center and the multiple neighborhood radii as radii, a plurality of neighborhoods of the target image are acquired, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii.
[0063] Step S340: respectively acquiring images located in each of the plurality of neighborhoods to obtain a plurality of image sets.
[0064] For the detailed description of step S310 to step S340, please refer to step S110 to step S140, which will not be repeated here.
[0065] Step S350: Obtain an intersection of the multiple image sets, and use the intersection as the target image set.
[0066] In some embodiments, after obtaining multiple image sets, the intersection of the multiple image sets can be obtained, and the intersection is used as the target image set. For example, the multiple image sets include a first image set and a second image set, and the first image set includes a first image, a second image, a third image, and a fourth image, and the second image set includes a first image, a third image, a fourth image, and a fifth image, then the intersection of the first image set and the second image set is taken to obtain a target image set including the first image, the third image, and the fourth image.
[0067] Step S360: clustering the images included in the target image set.
[0068] For the detailed description of step S360, please refer to step S150, which will not be repeated here.
[0069] Another embodiment of the present application provides an image clustering method, which obtains multiple images and multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, and multiple neighborhoods of the target image are obtained with the target image as the center of the data point and the multiple neighborhood radii as radii, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii, and images in each neighborhood of the multiple neighborhoods are obtained respectively to obtain multiple image sets, and the intersection of the multiple image sets is obtained, and the intersection is taken as the target image set to cluster the images included in the target image set. Compared to Figure 1 The image clustering method shown in this embodiment also obtains the intersection of multiple image sets as a set of target images, so as to improve the accuracy of image clustering by improving the accuracy of the determined target image set.
[0070] See also Figure 4 , Figure 4 A schematic diagram of the process flow of an image clustering method provided by another embodiment of the present application is shown below. Figure 4 The process shown is described in detail, and the image clustering method may specifically include the following steps:
[0071] Step S410: Acquire multiple images, and acquire multiple clustering factors for the multiple images, wherein each image in the multiple images serves as a data point.
[0072] Step S420: Acquire a target image from the multiple images, and acquire multiple neighborhood radii corresponding to the multiple clustering factors.
[0073] Step S430: Taking the target image as the data point center and the multiple neighborhood radii as radii, a plurality of neighborhoods of the target image are acquired, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii.
[0074] Step S440: respectively acquiring images located in each of the plurality of neighborhoods to obtain a plurality of image sets.
[0075] Step S450: Obtain a target image set based on the multiple image sets.
[0076] For the detailed description of step S410 to step S450 , please refer to step S110 to step S150 , which will not be repeated here.
[0077] Step S460: Obtain the number of images included in the target image set.
[0078] In some embodiments, after obtaining the target image set, the number of images included in the target image set may be obtained. Since each of the multiple images can be used as a data point, after obtaining the target image set, the number of data points included in the target image set may be obtained as the number of images included in the target image set.
[0079] Step S470: When the number of images included in the target image set is greater than a number threshold, the target image is determined as a core object, and the images included in the target image set are clustered based on the target image.
[0080] In some embodiments, a quantity threshold MinPts may be pre-set and stored, and the quantity threshold is used as a basis for judging the number of images included in the target image set. Therefore, in this embodiment, after obtaining the number of images included in the target image set, the number of images included in the target image set and the quantity threshold may be compared to determine whether the number of images included in the target image set is greater than the quantity threshold, wherein when the judgment result indicates that the number of images included in the target image set is greater than the quantity threshold, it may be determined that the target image is in a certain cluster, the data point corresponding to the target image may be marked as a core point, the target image may be determined as a core object, and the images included in the target image set may be clustered based on the target image. Similarly, the above method may be used for other images in the plurality of images until all images in the plurality of images have been clustered.
[0081] See also Figure 5 , Figure 5 This application shows Figure 4 The process diagram of step S470 of the image clustering method shown in FIG. Figure 5 The process shown is described in detail, and the method may specifically include the following steps:
[0082] Step S471: when the number of images included in the target image set is greater than a number threshold, the target image is determined as a core object, and a target cluster is established based on the target image.
[0083] In some embodiments, a quantity threshold MinPts may be pre-set and stored, and the quantity threshold is used as a basis for judging the number of images included in the target image set. Therefore, in this embodiment, after obtaining the number of images included in the target image set, the number of images included in the target image set and the quantity threshold may be compared to determine whether the number of images included in the target image set is greater than the quantity threshold, wherein when the judgment result indicates that the number of images included in the target image set is greater than the quantity threshold, it may be determined that the target image is in a certain cluster, the data point corresponding to the target image may be marked as a core point, the target image may be determined as a core object, and a target cluster may be established based on the target image. Based on this, the target cluster established based on the target image integrates multiple clustering factors, so that the image classification accuracy is higher.
[0084] Step S472: acquiring images having a specified relationship with the target image from the target image set, and adding the images having the specified relationship with the target image to the target cluster.
[0085] In some embodiments, after establishing a target cluster based on a target image, an image having a specified relationship with the target image can be obtained from a target image set and added to the target cluster to classify images belonging to the target cluster from multiple images.
[0086] See also Figure 6 , Figure 6 This application shows Figure 5 The process diagram of step S472 of the image clustering method shown in FIG. Figure 6 The process shown is described in detail, and the method may specifically include the following steps:
[0087] Step S4721: Acquire core objects and edge objects connected to the target image from the target image set.
[0088] In some embodiments, after establishing a target cluster based on a target image, core objects and edge objects connected to the target image can be obtained from the target image set. The core object connected to the target image indicates that the image is connected to the target image, and the number of images contained in the neighborhood of the image is greater than a quantity threshold, and the edge object connected to the target image indicates that the image is connected to the target image, and the number of images contained in the neighborhood of the image is not greater than a quantity threshold. As a way, being connected to the target image can include having a direct or indirect relationship with the target image, for example, the shooting location information of the image is close to the shooting location information of the target image, the shooting time information of the image is close to the shooting time information of the target image, etc., which is not limited here.
[0089] Step S4722: adding the core objects and edge objects connected to the target image to the target cluster.
[0090] In some implementations, after obtaining the core objects and edge objects connected to the target image, the core objects and edge objects connected to the target image may be added to the target cluster to improve the accuracy of image classification.
[0091] Another embodiment of the present application provides an image clustering method, which obtains multiple images and multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, with the target image as the center of the data point and the multiple neighborhood radii as radii, multiple neighborhoods of the target image are obtained, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii, images within each neighborhood of the multiple neighborhoods are obtained respectively, multiple image sets are obtained, a target image set is obtained based on the multiple image sets, the number of images included in the target image set is obtained, and when the number of images included in the target image set is greater than a number threshold, the target image is determined as a core object, and the images included in the target image set are clustered based on the target image. Compared to Figure 1 The image clustering method shown in this embodiment also determines the target image as a core object and clusters the images contained in the target image set based on the target image when the number of images contained in the target image set is greater than a quantity threshold, so as to improve the accuracy of image clustering.
[0092] Please refer to the figure, Figure 7 The module block diagram of the image clustering device provided in the embodiment of the present application is shown in FIG. Figure 7 The block diagram shown in FIG. 1 is used to illustrate that the image clustering device 200 includes: an image acquisition module 210, a neighborhood radius acquisition module 220, a neighborhood acquisition module 230, an image set acquisition module 240, and an image clustering module 250, wherein:
[0093] The image acquisition module 210 is used to acquire multiple images and acquire multiple clustering factors for the multiple images, wherein each image in the multiple images serves as a data point.
[0094] The neighborhood radius acquisition module 220 is used to acquire a target image from the multiple images, and acquire multiple neighborhood radii corresponding to the multiple clustering factors.
[0095] The neighborhood acquisition module 230 is used to acquire multiple neighborhoods of the target image with the target image as the data point center and the multiple neighborhood radii as radii, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii.
[0096] Further, the multiple clustering factors include a first clustering factor and a second clustering factor, the first clustering factor corresponds to a first neighborhood radius, the second clustering factor corresponds to a second neighborhood radius, and the neighborhood acquisition module 230 includes: a neighborhood acquisition submodule, wherein:
[0097] The neighborhood acquisition submodule is used to acquire the first neighborhood of the target image with the target image as the data point center and the first neighborhood radius as the radius, and to acquire the second neighborhood of the target image with the target image as the data point center and the second neighborhood radius as the radius.
[0098] The image set acquisition module 240 is used to respectively acquire images located in each of the multiple neighborhoods to obtain multiple image sets.
[0099] Further, the multiple clustering factors include a first clustering factor and a second clustering factor, the first clustering factor corresponds to a first neighborhood radius, and the second clustering factor corresponds to a second neighborhood radius. The image set acquisition module 240 includes: an image set acquisition submodule, wherein:
[0100] The image set acquisition submodule is used to acquire images located in the first neighborhood to obtain a first image set, and to acquire images located in the second neighborhood to obtain a second image set.
[0101] The image clustering module 250 is configured to obtain a target image set based on the multiple image sets, and cluster the images contained in the target image set.
[0102] Furthermore, the image clustering module 250 includes: a first target image set acquisition submodule and a first image clustering submodule, wherein:
[0103] The first target image set acquisition submodule is used to acquire the intersection of the multiple image sets and use the intersection as the target image set.
[0104] The first image clustering submodule is used to cluster the images included in the target image set.
[0105] Furthermore, the image clustering module 250 includes: a second target image set acquisition submodule, an image quantity acquisition submodule and a second image clustering submodule, wherein:
[0106] The second target image set acquisition submodule is configured to acquire a target image set based on the multiple image sets.
[0107] The image quantity acquisition submodule is used to obtain the number of images included in the target image set.
[0108] The second image clustering submodule is used to determine the target image as a core object when the number of images included in the target image set is greater than a number threshold, and cluster the images included in the target image set based on the target image.
[0109] Furthermore, the second image clustering submodule includes: a target cluster establishment unit and an image adding unit, wherein:
[0110] The target cluster establishing unit is used to determine the target image as a core object and establish a target cluster based on the target image when the number of images included in the target image set is greater than a number threshold.
[0111] The image adding unit is used to obtain an image having a specified relationship with the target image from the target image set, and add the image having the specified relationship with the target image to the target cluster.
[0112] Further, the image adding unit includes: an object acquiring subunit and an image adding subunit, wherein:
[0113] The object acquisition subunit is used to acquire the core object and edge object connected to the target image from the target image set.
[0114] The image adding subunit is used to add the core objects and edge objects connected with the target image to the target cluster.
[0115] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0116] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0117] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0118] See also Figure 8, which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0119] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0120] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.
[0121] See also Fig. 9 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0122] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.
[0123] In summary, the image clustering method, device, electronic device and storage medium provided in the embodiments of the present application obtain multiple images and obtain multiple clustering factors for the multiple images, wherein each image in the multiple images is taken as a data point, a target image is obtained from the multiple images, and multiple neighborhood radii corresponding to the multiple clustering factors are obtained, with the target image as the center of the data point and the multiple neighborhood radii as radii, multiple neighborhoods of the target image are obtained, wherein the multiple neighborhoods correspond one-to-one to the multiple neighborhood radii, images located in each neighborhood of the multiple neighborhoods are respectively obtained, multiple image sets are obtained, a target image set is obtained based on the multiple image sets, and the images included in the target image set are clustered, so that the accuracy of image clustering is improved by setting multiple neighborhood radii to divide and obtain multiple neighborhoods when there are multiple clustering factors, and clustering the images included in the target image set obtained based on the multiple image sets corresponding to the multiple neighborhoods.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image clustering method, characterized in that: The method comprises: Acquire a plurality of images, and acquire a plurality of clustering factors for the plurality of images, wherein each image in the plurality of images is regarded as a data point; Acquire a target image from the multiple images, and acquire multiple neighborhood radii corresponding to the multiple clustering factors; Taking the target image as the data point center and the multiple neighborhood radii as radii, obtaining multiple neighborhoods of the target image, wherein the multiple neighborhoods correspond to the multiple neighborhood radii one by one; Respectively acquiring images located in each neighborhood of the plurality of neighborhoods to obtain a plurality of image sets; Obtaining a target image set based on the multiple image sets, and clustering the images included in the target image set; The step of obtaining a target image set based on the multiple image sets and clustering the images contained in the target image set includes: Obtaining an intersection of the multiple image sets, and using the intersection as a target image set; The images contained in the target image set are clustered.
2. The method according to claim 1, characterized in that The multiple clustering factors include a first clustering factor and a second clustering factor, the first clustering factor corresponds to a first neighborhood radius, the second clustering factor corresponds to a second neighborhood radius, the target image is taken as a data point center, the multiple neighborhood radii are radii, and multiple neighborhoods of the target image are obtained, including: Taking the target image as the data point center and the first neighborhood radius as the radius, a first neighborhood of the target image is obtained, and taking the target image as the data point center and the second neighborhood radius as the radius, a second neighborhood of the target image is obtained; The step of respectively acquiring images located in each of the plurality of neighborhoods to obtain a plurality of image sets comprises: Images located in the first neighborhood are acquired to obtain a first image set, and images located in the second neighborhood are acquired to obtain a second image set.
3. The method according to claim 2, characterized in that The first clustering factor includes shooting location information, and the second clustering factor includes shooting time information.
4. The method according to claim 1, characterized in that The step of obtaining a target image set based on the multiple image sets and clustering the images contained in the target image set includes: Obtaining a target image set based on the multiple image sets; Obtaining the number of images contained in the target image set; When the number of images included in the target image set is greater than a number threshold, the target image is determined as a core object, and the images included in the target image set are clustered based on the target image.
5. The method according to claim 4, characterized in that When the number of images included in the target image set is greater than a number threshold, determining the target image as a core object, and clustering the images included in the target image set based on the target image, comprising: When the number of images included in the target image set is greater than a number threshold, determining the target image as a core object, and establishing a target cluster based on the target image; An image having a specified relationship with the target image is acquired from the target image set, and the image having the specified relationship with the target image is added to the target cluster.
6. The method according to claim 5, characterized in that The acquiring, from the target image set, an image having a specified relationship with the target image, and adding the image having the specified relationship with the target image to the target cluster comprises: Acquire core objects and edge objects connected to the target image from the target image set; The core objects and edge objects connected with the target image are added to the target cluster.
7. An image clustering device, characterized in that: The device comprises: An image acquisition module, used to acquire a plurality of images and acquire a plurality of clustering factors for the plurality of images, wherein each of the plurality of images is regarded as a data point; A neighborhood radius acquisition module, used to acquire a target image from the multiple images, and acquire multiple neighborhood radii corresponding to the multiple clustering factors; A neighborhood acquisition module, configured to acquire a plurality of neighborhoods of the target image with the target image as the center of the data point and the plurality of neighborhood radii as radii, wherein the plurality of neighborhoods correspond one to one with the plurality of neighborhood radii; An image set acquisition module, used to respectively acquire images located in each of the plurality of neighborhoods to obtain a plurality of image sets; An image clustering module, used for obtaining a target image set based on the multiple image sets, and clustering the images contained in the target image set; The step of obtaining a target image set based on the multiple image sets and clustering the images contained in the target image set includes: obtaining an intersection of the multiple image sets and taking the intersection as the target image set; and clustering the images contained in the target image set.
8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 6.
