Hi guys. So I am making progess understanding file manipulation in c++. My ultimate plan is to make a program that can find one image within another in 24 bit color bitmaps.
I have been reading BMP file format - Wikipedia, the free encyclopedia for info on bitmaps.
My first question is about the output of my pixel array.
This is my current method of saving it and printint it out:
This outputs large numbers, positive or negative. TBH I didnt expect them to be negative, but I suppose the values are signed?Code:void change2Negative(fstream &dFile, Image &dInfo) { int pixel[dInfo.imageWidth][dInfo.imageHeight]; for(int i = 0; i < dInfo.imageWidth; i++) { for(int j = 0; j < dInfo.imageHeight; j++) { dFile.seekg(dInfo.offSet + i); dFile.read(reinterpret_cast<char *>(&pixel[i][j]), sizeof(pixel)); cout << pixel[i][j] << ","; } cout <<","<< endl; } }
Anyway. I am wanting to compare to images, so I suppose I dont need to break that into the RGB values (which for bitmaps appear to be BGR)?
So for an algorithm that find one image (image A) inside another(image B), is the best way to go along each pixel in B, until I find the value of the first pixel in A, then check what the value of pixel 2 is in A, and see if the next pixel in B is that number - keep doing that until the end of the line in A, and then jump to next line and continue checking. If a pixel doesnt match, reset back to the first pixel in A and continue checking in B?
What does anyone think?



LinkBack URL
About LinkBacks


