Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It depends on how much you want to sacrifice for time performance. The code will be faster but dirtier. If time is really really important you can do:

  1. Avoid using 'for' loops. Just write 'suma' as sum of 9 values.

  2. Don't use .at<>. Instead use pointers to access memory directly.

    uchar* p = grayImage.ptr(ay2) + ax2;

    uchar* q = grayImage.ptr(by2) + bx2;

    // difference at top left pixel of 3x3 patch

    difa = p[-step-1] - q[-step-1];

    // and so on...