I am working on a small project in which I will have to extract all small blocks of data that resemble a given input (a simple image comparison problem).

Do I need to scan the whole image to and compare bit by bit to get what I would like to have ? Please drop me some hints or explanation for me to move on to the next level, I am really stuck, I have had my head all night around this and couldnt figure out a way to go ? Go where ? I don't want to wait endlessly.