我有一个问题,我得到了一套图片,需要分类。在
问题是,我真的对这些图像一无所知。所以我计划使用尽可能多的描述符,然后对这些描述符进行PCA,只识别对我有用的描述符。在
如果有帮助的话,我可以对很多数据点进行监督学习。然而,有一个机会,图片是相互连接的。这意味着可能会有一个从图像X到图像X+1的发展,尽管我有点希望通过每个图像中的信息来进行分类。在
我的问题是:在使用Python时,如何做到最好?(我想先做一个概念证明,在速度不成问题的情况下)。我应该使用什么库?在
已经有这样一种图像分类的例子了吗?使用一堆描述符并通过PCA将它们烹饪下来的例子?老实说,这部分对我来说有点可怕。虽然我认为python应该已经为我做了这样的事情。在
编辑:
我找到了一个很好的工具包,我目前正在为此进行尝试:http://scikit-image.org/里面似乎有一些描述符。有没有一种方法可以自动提取特征,并根据特征对目标分类的描述能力对特征进行排序?PCA应该能够自动排名。在
编辑2:
我的数据存储框架现在有了一些改进。我将使用Fat系统作为数据库。我将有一个文件夹为每个实例的组合类。因此,如果图像属于1类和2类,则会有一个包含这些图像的文件夹img12。这样我可以更好地控制每个类的数据量。在
编辑3:
我发现了一个python库(sklearn)的例子,它可以做一些我想做的事情。它是关于识别手写数字。我正在尝试将我的数据集转换为可用于此的数据集。在
下面是我使用sklearn找到的示例:import pylab as pl
# Import datasets, classifiers and performance metrics
from sklearn import datasets, svm, metrics
# The digits dataset
digits = datasets.load_digits()
# The data that we are interested in is made of 8x8 images of digits,
# let's have a look at the first 3 images, stored in the `images`
# attribute of the dataset. If we were working from image files, we
# could load them using pylab.imread. For these images know which
# digit they represent: it is given in the 'target' of the dataset.
for index, (image, label) in enumerate(zip(digits.images, digits.target)[:4]):
pl.subplot(2, 4, index + 1)
pl.axis('off')
pl.imshow(image, cmap=pl.cm.gray_r, interpolation='nearest')
pl.title('Training: %i' % label)
# To apply an classifier on this data, we need to flatten the image, to
# turn the data in a (samples, feature) matrix:
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
# Create a classifier: a support vector classifier
classifier = svm.SVC(gamma=0.001)
# We learn the digits on the first half of the digits
classifier.fit(data[:n_samples / 2], digits.target[:n_samples / 2])
# Now predict the value of the digit on the second half:
expected = digits.target[n_samples / 2:]
predicted = classifier.predict(data[n_samples / 2:])
print("Classification report for classifier %s:\n%s\n"
% (classifier, metrics.classification_report(expected, predicted)))
print("Confusion matrix:\n%s" % metrics.confusion_matrix(expected, predicted))
for index, (image, prediction) in enumerate(
zip(digits.images[n_samples / 2:], predicted)[:4]):
pl.subplot(2, 4, index + 5)
pl.axis('off')
pl.imshow(image, cmap=pl.cm.gray_r, interpolation='nearest')
pl.title('Prediction: %i' % prediction)
pl.show()