I have a set of "goob" and "bad" images, presented as gray-scale array. I would like to extract "good" and "bad" features from these images and populate a dictionary. Here my high-level algorithm to approach this task:
- Load images and present them NP matrix
img_mtx [ img_mtx.shape = (10, 255, 255)] - Use
image.PatchExtractoroverimg_mtxto get the 1000 patches for each image, in total 10000 7x7 pixelpatches[patches.shape = (10000, 49)] - Next step, I assume my
patchesmatrix is something like a bag of words and I want to create a sparse matrix of patches for each image and set "good" or "bad" class for each image. - Now I should have pretty classic task for classification, like spam detection, just adding more images in training set I should have a good result.
But I have some problems here:
- How to implement step 3? I've seen the example for text classification, but not for image classification
- When I need to classify a new image, again I'm splitting it into patches, but now I need to map these patches from the new image into my "patch dictionary". How to do it the best way, keeping in mind I may never receive 100% match with dictionary? I looks like I need to calculate the closest distance to my dictionary's feature, but this sounds expensive.
... or I took a completely wrong approach to this task?