'This method extracts a bag of features histogram for the input image using
the provided codebook. The result are the bin counts for each codebook code.'

def extract(self, img):

    data = self._getPatches(img)
    p = spsd.cdist(data, self.mCodebook)
    codes = np.argmin(p, axis=1)
    [retVal, foo] = np.histogram(codes, self.mNumCodes, normed=True, range=(0, (self.mNumCodes - 1)))
    return retVal
