简体   繁体   中英

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. 在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明在此处输入图片说明

You'll probably want to use 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.

KNN classification is a way you can classify many different types of data. 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. 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. 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 . 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.

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. 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). 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 . It's used in sklearn, actually, if I'm not mistaken.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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