<p>Because you have variable-sized patches, there are a couple of ways you can handle the classification of these patches using a SVM.  These have their advantages and disadvantages so you will have to decide what you think is best.  Given that you have decided to choose a patch of size <code>M x N</code> for your images to be submitted into your SVM for classification, you can try one of the two following approaches:</p>

<h1>Resize the input image patches</h1>

<p>For each of your images at test time, resize them so that they all match the size of <code>M x N</code>, then run through the SVM classification pipeline to determine which class that image belongs to.  The advantages of this are that the only information you are losing is due to the information lost when subsampling the images.  However, the disadvantage is that if the image is smaller than the target patch size of <code>M x N</code> you will introduce bogus information when upsampling to match the target patch size.  This kind of thing has been seen before especially in Deep Learning.  Specifically, <a href="https://arxiv.org/pdf/1506.01497v3.pdf" rel="nofollow"><strong>Region Proposal Networks by Ren et al.</strong></a> first take a look at what patches in a larger image are candidates to have an object or something worth taking a look at in the image, they then <strong>resize</strong> the patches to match the input layer into their neural network (convolutional btw) then proceed with the classification.</p>

<h1>Search for patches over multiple scales</h1>

<p>Another way is to keep the image size intact but using patch sizes of <code>M x N</code>, do a sliding window scheme where you extract overlapping patches of size <code>M x N</code>, submit these to your SVM then for each centre of each overlapping patch, determine what the class of that patch would be.  You would do this over multiple scales then have a voting procedure where the most occurring class over the entire image is the class of interest.  Something similar to this was seen in <a href="https://arxiv.org/pdf/1312.6229v4.pdf" rel="nofollow"><strong>Semenet et al. for their Overfeat classification engine</strong></a> - also using convolutional neural networks.  The advantage of this is that you don't lose any information in that you are using all (if not most) of the image information when classifying an object.  The disadvantage is the amount of computation time required - specifically, the number of scales, the amount of overlap between windows and the patch size itself are all hyperparameters that you need to determine for the most optimal performance.  This approach also assumes that the patch size is smaller than the image in question when scanning.  You will have to be cognizant and choose patch sizes that are smaller than the largest image you have in your training dataset.</p>

<h1>If I can recommend....</h1>

<p>Because you are doing image classification, the algorithms that have the best performance in classification and for the sheer speed at test time would be convolutional neural networks.  I would consider looking at those rather than using SVMs for performance.  As a start, take a look at the <a href="https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf" rel="nofollow"><strong>AlexNet pipeline by Krizhevsky et al.</strong></a> as a start. This was <em>the</em> seminal work and how convolutional neural networks was placed on the map for computer vision tasks, such as classification, detection and so on.</p>
How to train SVM using variable size raw image patch?
<p>I want to train a classifier to classify between "person with weapon" and "person without weapon". weapon can contain any weapon like revolver or assault riffle. <br>
I have images with bounding boxes of weapons in the images. Images are of different sizes. <br>
<strong>What I want to do?</strong><br>
I want to train SVM classifier using the raw image patches obtained using bounding box coordinates of weapons. For "person without weapon" i want to pass whole raw image as feature vector to SVM. <br>
<strong>Limitations:</strong><br>
Each bounding box is of different size, that means a weapon of different size. I cant use PCA for these bounding boxes because i think it may result into loss of information because there are 3 different types of weapons with different sizes in images.Some bounding boxes cover almost whole image. So first i have to downscale image and bounding box because otherwise my memory runs out if i take whole image for PCA. <br>
<strong>Question:</strong><br>
How can i train SVM using variable sized feature vector? To put in another way, How can I make all feature vectors of same size without losing information?</p>