12 int nRows = mimOrigPatch.size().y;
13 int nCols = mimOrigPatch.size().x;
15 byte *templatepointer;
18 for(
int nRow = 0; nRow < nRows; nRow++)
20 imagepointer = &im[irImgBase + ImageRef(0,nRow)];
21 templatepointer = &mimOrigPatch[ImageRef(0,nRow)];
22 for(
int nCol = 0; nCol < nCols; nCol++)
24 nDiff = imagepointer[nCol] - templatepointer[nCol];
25 nSumSqDiff += nDiff * nDiff;
37 vector<ImageRef> &vCorners,
38 std::vector<int> *pvRowLUT)
42 int nBestSSD = mnMaxSSD + 1;
44 ImageRef irBBoxBR = irPos + ImageRef(nRange, nRange);
45 vector<ImageRef>::iterator i;
48 for(i = vCorners.begin(); i!=vCorners.end(); i++)
49 if(i->y >= irBBoxTL.
y)
break;
53 int nTopRow = irBBoxTL.
y;
56 if(nTopRow >= (
int) pvRowLUT->size())
57 nTopRow = (
int) pvRowLUT->size() - 1;
58 i = vCorners.begin() + (*pvRowLUT)[nTopRow];
61 for(; i!=vCorners.end(); i++)
63 if(i->x < irBBoxTL.
x || i->x > irBBoxBR.
x)
67 int nSSD = SSDAtPoint(im, *i);
75 if(nBestSSD < mnMaxSSD)
88 CVD::ImageRef irPatchSize( 2 * mnHalfPatchSize + 1 , 2 * mnHalfPatchSize + 1);
89 mimOrigPatch.resize(irPatchSize);
90 copy(im, mimOrigPatch, mimOrigPatch.
size(), irPos - mimOrigPatch.size() / 2);
void SampleFromImage(CVD::ImageRef irPos, CVD::BasicImage< CVD::byte > &im)
bool FindPatch(CVD::ImageRef &irPos, CVD::BasicImage< CVD::byte > &im, int nRange, std::vector< CVD::ImageRef > &vCorners, std::vector< int > *pvRowLUT=NULL)
void copy(const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1,-1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())
ImageRef size() const
What is the size of this image?
bool in_image_with_border(const ImageRef &ir, int border) const
ImageRef ir(const TooN::Vector< 2 > &v)
int SSDAtPoint(CVD::BasicImage< CVD::byte > &im, const CVD::ImageRef &ir)
static int mnHalfPatchSize