问题
I have several images like this and trying to recognise objects using Neural Networks
and GIST
as features. My data set has 50 classes and 4 images per class. Using 75% of the images as training data, I get an test accuracy of 83%

To improve the accuracy I want to preprocess the images I.e. I want to make the background transparent or white, while keeping the original object. I have been trying cv2.BackgroundSubtractorMOG2()
but it's making the entire image gray.
What will be the best way to preprocess this image?
回答1:
You could try using the GrabCut algorithm for this problem. Since you know that the object is roughly in the center you can try building the color distribution of the object and gather background samples from the borders of the image.
OpenCV documentation can be found here: http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#grabcut
with an example here: https://github.com/Itseez/opencv/blob/master/samples/cpp/grabcut.cpp
回答2:
You might want to try extracting contours to find the object within the image. You can then extract only that part of the image within the largest contour and assume that that is your object.
回答3:
For image pre-processing there is no one best answer. There are number of things that can be done to augment your training set / improve classification accuracy. If you are using neural networks (and especially training them yourself), then you need to augment your data as much as possible to be the most effective. A few possible techniques you can do for image preprocessing / training set data augmentation:
- Rotate your training images by arbitrary amounts (in addition to 90 / 180 / 270 degrees, something like 30 / 60 / 120 / etc.)
- Randomly add Gaussian noise.
- Blur your images a little bit.
- Brighten the images.
Since you only have 4 images per class, that is not nearly enough images for training unless the images you want to be able to classify are very similar to those in your training set, so you want to turn those 4 images (3 if you are using 75% for training) into something like 12 to use for training.
But for testing, one important thing to note is that the SHAPE of the image is important. So if your network requires 50x50 pixel images and your original images are 100x50, you have a number of choices about how to re-shape the image to 50x50, including straight warping, cropping a 50x50 region from the middle, filling in the image with black pixels to 100x100 and then re-scaling, etc.
来源:https://stackoverflow.com/questions/30273249/making-background-of-the-image-white