Ask Your Question

Revision history [back]

This should be the fastest way of retrieving Mat elements

Size contSize = mat.size();
if (mat.isContinous())
{
    contSize.width *= contSize.height;
    contSize.height = 1;
}
for (int i = 0; i < contSize.height; ++i)
{
    T* ptr = mat.ptr<T>(y);
    for (int j = 0; j < contSize.width; ++j)
    {
        ptr[j] = ...;
    }
}

according to one of the core developers of OpenCV posted in this topic. Then inside the loop, do apply a sine or cosine on the value based on standard C++ functionality.