简体   繁体   English

使用Python对信号图像进行分类

[英]Classify Signal Images using Python

I have following Signal Images which I want to classify depending upon the shape. 我有以下要根据形状分类的信号图像。 Which algorithm is suited to do this ? 哪种算法适合这样做? I have attached 2-2 images of each class. 我已附上每班2-2张图片。 在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明

You'll probably want to use sklearn . 您可能需要使用sklearn Assuming you want to classify these patterns based on images rather than the data from which the images were generated, you can use a simple k-nearest-neighbor (KNN) classifier. 假设要基于图像而不是根据生成图像的数据对这些模式进行分类,则可以使用简单的k最近邻(KNN)分类器。

KNN classification is a way you can classify many different types of data. KNN分类是一种可以对许多不同类型的数据进行分类的方法。 First, the algorithm is trained using tagged data (images, in your case, that appear to be in classes of differing frequencies). 首先,使用标记数据(在您的情况下,图像似乎属于不同频率的类)训练算法。 Then, the algorithm analyzes untagged data, data you want to classify. 然后,该算法分析未标记的数据,即您要分类的数据。 The "nearest neighbor" part means that each new piece of data seen by the algorithm is classified based on the k nearest pieces of data that you trained the algorithm with. “最近邻居”部分意味着算法看到的每个新数据都是根据您用来训练算法的k最近数据进行分类的。 The idea is that new data of a certain category will be numerically similar to another category. 这个想法是某个类别的新数据在数值上将类似于另一个类别。 Here's a high-level workflow of how the algorithm works: 这是算法工作原理的高级工作流程:

train_set = [(img1, 'low freq'), (img2, 'hi freq'), (img3, 'low freq'), (img4, 'med freq'), (img5, 'med freq')]

img_classifier = algorithm(train_set)

Then, you call your trained algorithm on new data to identify untagged images. 然后,您可以对新数据调用经过训练的算法,以识别未标记的图像。

test = [img6, img7]

for i in test:
    img_classifier(test)

You'll want to use a LOT more than five training images, though. 不过,您可能要使用超过五个训练图像。 The value of k that you choose is important, too. 您选择的k的值也很重要。 Assuming you train with the same amount of images for each class (let's say n ), for a total of 3n images trained with, a good k to use is be k=n/2 . 假设您为每个课程训练了相同数量的图像(比如说n ),对于总共训练了3n张图像,要使用的一个好kk=n/2 Too high and you risk misclassification because you take into account too much of the training data, too low and you may take into account too little. 太高了,您可能会误分类,因为您考虑了太多的训练数据,太低了而您可能考虑的太少了。

There is an excellent tutorial here that you should definitely check out if you decide to use sklearn. 这里有一个很棒的教程 ,如果您决定使用sklearn,则一定要检查一下。

Your images appear to be in very discrete classes. 您的图像似乎是非常离散的类。 If you don't want to use sklearn, you might be able to classify your images based on the area of the image that your curve covers. 如果您不想使用sklearn,则可以根据曲线覆盖的图像区域对图像进行分类。 If these are the only these three classes, you can try some of these to see if they give you a good threshold for image classification: 如果只有这三个类别,则可以尝试其中的一些类别,看看它们是否为您提供了良好的图像分类阈值:

  • Calculate the area of the blue (light+dark) in the image--different frequencies may be covered by different areas. 计算图像中蓝色(亮+暗)的面积-不同的频率可能会覆盖不同的区域。
  • Check out the ratio of light blue to dark blue, it may be different. 检查浅蓝色与深蓝色的比率,可能有所不同。
  • Calculate the maximum y-displacement of the dark blue from the center of the image (x-axis). 从图像中心(x轴)计算深蓝色的最大y位移。 This will easily separate the high-frequency from the mid and low frequency images, and then you can use the area calculation in the first method to differentiate the low and mid frequencies as they clearly cover different areas. 这样可以轻松地将高频图像与中低频图像分开,然后您可以使用第一种方法中的面积计算来区分低频和中频,因为它们清楚地覆盖了不同区域。

If you decide to go with the second method, definitely check out the Python Imaging Library . 如果您决定使用第二种方法,请一定要查看Python Imaging Library It's used in sklearn, actually, if I'm not mistaken. 如果我没记错的话,它实际上是在sklearn中使用的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM