Ask Your Question
0

OpenCV3: KNN classifier Feature matrix data type

asked 2019-05-05 19:42:24 -0600

eldesgraciado gravatar image

Hello! Hope someone can help me out clarifying this. According to the documentation I've read, the KNN classifier takes a feature matrix of type CV_32FC1. So, what range should the data be in?

So far I've been experimenting with just plain pixel data in the ol' range [0, 255] but further, I plan to train on some normalized (feature) vectors containing float data in the range [0.0, 1.0]. Shouldn't be any problem, right?

Thanks for the info!!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2019-05-06 02:52:17 -0600

berak gravatar image

updated 2019-05-06 02:53:32 -0600

the range of your floatinput data does not matter for the KNN classifier.

however, it DOES matter for other classifiers, like SVM, ANN_MLP, where you should normalize it. so, if there's any chance you would change it -- normalize !

sidenote: the size/length of your features are far more important than the range of the data. throwing whole images (you mentioned: "pixels") at KNearest might be a bad idea, unless you have tons of those (the ratio of image count / size is somewhat "even")

edit flag offensive delete link more

Comments

Thanks a lot, berak! I appreciate your comments! I used pixels as features because I was experimenting with “color segmentation” - something that would group similar pixel values into defined classes.

However, my main goal is to use normalized feature vectors. Thanks again for your input!

eldesgraciado gravatar imageeldesgraciado ( 2019-05-07 17:31:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-05-05 19:42:24 -0600

Seen: 248 times

Last updated: May 06 '19