简体   繁体   English

如何根据其内容将一组图像文件群集到不同的文件夹

[英]How to cluster a set of image files to different folders based on their content

I have a set of images in a folder, where each image either has a square shape or a triangle shape on a white background (like this and this ). 我在文件夹中有一组图像,其中每个图像在白色背景上都具有正方形或三角形(例如thisthis )。 I would like to separate those images into different folders (note that I don't care about detecting whether image is a square/triangle etc. I just want to separate those two). 我想将这些图像分离到不同的文件夹中(请注意,我不在乎检测图像是否是正方形/三角形等。我只想将这两个图像分离)。

I am planning to use more complex shapes in the future (eg pentagons, or other non-geometric shapes) so I am looking for an unsupervised approach. 我计划将来使用更复杂的形状(例如五边形或其他非几何形状),因此我正在寻找一种无监督的方法。 But the main task will always be clustering a set of images into different folders. 但是主要任务将始终是将一组图像群集到不同的文件夹中。

What is the easiest/best way to do it? 最简单/最好的方法是什么? I looked at image clustering algorithms, but they do clustering of colors/shapes inside the image. 我研究了图像聚类算法,但是它们在图像内部对颜色/形状进行聚类。 In my case I simply want to separate those image files based on the shapes that have. 就我而言,我只是想根据具有的形状来分离那些图像文件。

Any pointers/help is appreciated. 任何指针/帮助表示赞赏。

You can follow this method: 您可以按照以下方法:

1. Create a look-up tables with shape you are using in the images
2. Do template matching on the images stored in a single folder
3. According to the result of template matching just store them in different folders
4. You can create folders beforehand and just replace the strings in program according to the usage.

I hope this helps 我希望这有帮助

It's really going to depend on what your data set looks like (eg, what your shape images look like), and how robust you want your solution to be. 这实际上取决于数据集的外观(例如,形状图像的外观)以及解决方案的稳定性。 The tricky part is going to be extracting features from each shape image the produce a clustering result that you're satisfied with. 棘手的部分是从每个形状图像中提取特征,以产生您满意的聚类结果。 A few ideas: 一些想法:

You could compute SIFT features for each images and then cluster the images based on those features: http://en.wikipedia.org/wiki/Scale-invariant_feature_transform 您可以为每个图像计算SIFT功能 ,然后基于这些功能对图像进行聚类: http : //en.wikipedia.org/wiki/Scale-invariant_feature_transform

If you don't want to go the SIFT route, you could try something like HOG : http://en.wikipedia.org/wiki/Histogram_of_oriented_gradients 如果您不想走SIFT路线,则可以尝试类似HOG的方法http : //en.wikipedia.org/wiki/Histogram_of_ 取向_gradients

A somewhat more naive approach - If the shapes are always the same scale, and the background color is fixed you could get rid of the background cluster the images based on shape area (eg, number of pixels taken up by the shape). 一种比较幼稚的方法-如果形状总是相同的比例,并且背景颜色是固定的,则可以基于形状区域 (例如,形状所占据的像素数)来消除背景群集图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过Python合并来自同名但位于不同文件夹中的文件的内容? - How to merge content from files with same name but in different folders by Python? 如何遍历具有多个文件夹的目录中的文件,对文件进行操作,保存到不同的文件夹集 - how to iterate through files in directory with multiple folders, operate on files, save to different set of folders 如何聚类来自不同文件的不同文本? - How to cluster different texts from different files? 如何使用 Python 基于一个文件对一组文件的内容进行排序 - How to order the content of a set of files based on one file with Python 如何根据Python中列表中的文件名将图像文件分类到两个文件夹中? - How to sort image files into two folders based on filename from a list in Python? python如何访问不同文件夹中的所有文件 - python how to access all the files that are in different folders 如何将每 500 个文件移动到不同的文件夹中 - How to move every 500 files into different folders 如何将 excel 文件与不同文件夹合并 - How to combine excel files with different folders 根据文本列表将文件移动到不同的文件夹 Python - Move files into different folders based on a text list Python 如何从不同文件夹读取图像数据? - How to read the image data from different folders?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM