Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image centering before classification?

I did a project at school where I had to classify objects into cats and dogs. I used SVM and logistic regression to achieve this.

The images were given to us in the form of features. So we did not have to handle things like image centering and so on...

My questions is, how do you center all the images so my classifier can learn better? I know CNN are good for this, but I would like to know just how to center the images before classification?

Thanks!

like image 228
LoveMeow Avatar asked Jul 16 '26 06:07

LoveMeow


1 Answers

I don't know this is the best solution or not, but You can try by find the center of the object, then shift the image so the center of the object become the center of the image.

Step by step:

  1. Find the the object in the image: for the simple one you can use function like findContours from OpenCV. But this is the hardest part, it really depends on your image and may need more advance technique.
  2. Find the center of the object: you can find it using moments from OpenCV or just manually compute using Centroid method
  3. Shift the object: again, there are options to do this, by using OpenCV library warpAffine or compute it manually using Affine Transform

I found nice tutorial for step 1 and 2 in OpenCV documentation:

http://docs.opencv.org/2.4/doc/tutorials/imgproc/shapedescriptors/moments/moments.html

like image 143
malioboro Avatar answered Jul 18 '26 21:07

malioboro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!