使用最近邻算法进行图像模式识别

发布于 2024-08-31 17:05:15 字数 412 浏览 11 评论 0原文

所以我希望能够识别图像中的模式(例如数字 4),我一直在阅读不同的算法,我真的很想使用最近邻算法,它看起来很简单,而且我确实根据本教程理解了它: http://people.revoledu.com/kardi/tutorial/KNN/ KNN_Numerical-example.html 问题是,虽然我了解如何使用它来填充缺失的数据集,但我不明白如何使用它作为模式识别工具来瞄准图像形状识别。有人可以解释一下这个算法如何用于模式识别吗?我看过使用 OpenCV 的教程,但是我真的不想使用这个库,因为我有能力自己进行预处理,而且我仅仅为了简单的最近邻而实现这个库似乎很愚蠢算法。

So I want to be able to recognise patterns in images (such as a number 4), I have been reading about different algorithms and I would really like to use the Nearest Neighbour algorithm, it looks simple and I do understand it based on this tutorial:
http://people.revoledu.com/kardi/tutorial/KNN/KNN_Numerical-example.html
Problem is, although I understand how to use it to fill in missing data sets, I don't understand how I could use it as a pattern recognition tool to aim in Image Shape Recognition. Could someone please shed some light as to how this algorithm could work for pattern recognition? I have seen tutorials using OpenCV, however I don't really want to use this library as I have the ability to do the pre-processing myself, and it seems silly that I would implement this library just for what should be a simple nearest neighbour algorithm.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌伤ぢ 2024-09-07 17:05:16

我在摄像机实时姿势识别中使用 K 最近邻算法进行姿势识别。我建议您使用 Matlab 来训练和测试数据集,因为它有用于此目的的 PRToolbox,并且有很多帮助和示例。
最重要的是,您正确选择了能够稳健地表示每个类的特征。
一旦有了特征(这将是一组值,如颜色、面积、位置...)和类别,您就需要样本来训练分类器(例如 KNN)。与分类器一样重要的是如何选择训练样本。然后你必须测试分类器。

尝试不同的训练集、不同的特征、不同的分类器,因为 KNN 可能不是最适合您的数据类型的方法。

我希望你觉得这很有用。

I used the K-Nearest-Neighbor algorithm for pose recognition in a real-time Pose-Recognition with videocamera. I would recomend you to use Matlab for training and testing datasets, as it has PRToolbox for this purpose and there is a lot of help and samples.
Teh most importan thing is that you properly choose the features that will make possible to represent each class robustly.
Once you have the features (this will be a set of values like, color, area, positions...) and the classes, you need samples to train the classifier (KNN for example). As important as the classifier is how you choose the samples for training. Then you will have to test the classifier.

Try different training sets, different features, different classifiers, because maybe the KNN is not the most suitable method for your type of data.

I hope you find this useful.

神爱温柔 2024-09-07 17:05:15

您只需(简单地?)必须为您的数据定义“距离”的度量。

假设您已经将大图像分割为小图像,每个小图像对应于您想要分类的文本字符。假设我们正在处理数字单色图像,因此每个图像都表示为 0-255 整数范围(亮度)内的值(像素)的矩形矩阵。还假设(NN 是一种“监督分类算法”)您有很多已经很好分类的图像(您的训练集)。

给定一个新的小图像,您必须定义两个图像之间的距离,以便选择训练集中最接近的图像,并将其“标签”选择为识别的文本字符。

一种简单的方法是采用像素差(例如平方和)。但这种距离测量对平移(以及旋转和缩放)很敏感,我们通常不希望这样。另一种方法是计算傅立叶变换的模,它是平移不变的(但这还不够)。从这里您可以开始 - 并认识到这个问题很困难,并且这种分类需要大量工作才能令人满意地执行。

You simply (simply?) have to define a measure of "distance" for your data.

Lets asume you have already segmented you big image in small images, each one corresponding to a text character you want to classified. Lets assume that we are dealing with digital monocrome images, so each image is represented as a rectangular matrix of values (pixels) in (say) the 0-255 integer range (brightness). It is also assumed (NN is a "supervised clasification algorithm") that you have a lot of already well classified images (your training set).

Given a new small image, you must define a distance between two images so that the most close in the training set is chosen, and its "label" chosen as the recognized text character.

One naive approach would be to take the difference of pixels (sum of squares, for example). But this distance measure would be sensitive to translations (and rotations and scaling) and we usually don't want that. An alternative would be to compute the modulus of the Fourier transform, which is translation invariant (but this is not enough). From here you can start - and appreciate that the problem is difficult, and these kind of classification needs a lot of work to perform acceptably.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文