简体   繁体   English

以libsvm格式转换像素数据(在txt文件中)

[英]Convert pixel data (in txt file) in libsvm format

I am trying to perform a prediction with libsvm for the recognition of a specific object in an image. 我正在尝试使用libsvm进行预测,以识别图像中的特定对象。 I was able to convert my images using the sobel operator and I stored the pixel value of one of the image into a txt file. 我能够使用sobel运算符转换图像,并将其中一张图像的像素值存储到txt文件中。 So, I have a txt file that looks like that: 所以,我有一个txt文件,看起来像这样:

14 18 0

173 176 145

175 177 155

20 21 7

19 18 13

9 7 8

3 1 4

3 1 2

5 4 2

1 0 0

[...]

My problem is that I am not really familiar with the libsvm data format so I was wondering: how do I modify this file using python in order to make it usable with the libsvm? 我的问题是我对libsvm数据格式不是很熟悉,所以我想知道:如何使用python修改此文件以使其可用于libsvm?

Thanks a lot!! 非常感谢!!

A converter shouldn't be so difficult but even better is not saving to txt! 转换器不应该那么困难,但是更好的是不要保存到txt! You probably don't need this intermediate step. 您可能不需要此中间步骤。 You can input your image data to libsvm directly using libsvm python bindings or (my recomendation) scikits , see for example: 您可以使用libsvm python绑定或(我的建议) scikits直接将图像数据输入到libsvm中,例如:

http://scikit-learn.org/0.13/auto_examples/plot_digits_classification.html http://scikit-learn.org/0.13/auto_examples/plot_digits_classification.html

Note: Scikits uses libsvm. 注意:Scikits使用libsvm。

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

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