Given is a trained classifer in scikit learn, e.g. a RandomForestClassifier
. The classifier has been trained on samples of size e.g. 25x25.
How can I easily apply this to all tiles/windows in a large image (e.g. 640x480)?
What I could do is (slow code ahead!)
x_train = np.arange(25*25*1000).reshape(25,25,1000) # just some pseudo training data
y_train = np.arange(1000) # just some pseudo training labels
clf = RandomForestClassifier()
clf.train( ... ) #train the classifier
img = np.arange(640*480).reshape(640,480) #just some pseudo image data
clf.magicallyApplyToAllSubwindoes( img )
How can I apply clf
to all 25x25 windows in img
?