To optimize, one idea I have is to store the larger area as a matrix as well. Use an "iterator matrix" located within your container matrix to skip column wise looking for the image, and then row-wise down a row. The iterator matrix search is done using the existing search algorithm to compare the desired sub image to the current iterator very quickly.
To optimize, one idea I have is to store the larger area as a matrix as well. Use an "iterator matrix" located within your container matrix to skip column wise looking for the image, and then row-wise down a row. The iterator matrix search is done using the existing search algorithm to compare the desired sub image to the current iterator very quickly.