Função de exibição de colchão de múltiplos canais

Eu quero escrever uma função curta para exibir o tipo de matriz Mat OpenCV. Estou fechado para terminar. Este é o meu código:

template <class eleType>
int MATmtxdisp(const Mat mtx, eleType fk)   
// create function template to avoid type dependent programming i.e. Mat element can be float, Vec2f, Vec3f, Vec4f
// cannot get rid of fk ('fake') variable to identify Mat element type
{   
    uchar chan = mtx.channels();

    for(int i = 0; i < mtx.rows; i++)
        for(int k = 0; k < chan; k++)
        {
            for(int l = 0; l < mtx.cols; l++)
            {
                eleType ele = mtx.at<eleType>(i,l);  
// I even split 2 cases for 1 channel and multi-channel element
// but this is unacceptable by the compiler when element is float type (1 channel)
// i.e. C2109: subscript requires array or pointer type
                if (chan > 1)
                    printf("%8.2f",ele[k]);   
                else 
                    printf("%8.2f",ele);
            }
            printf("\n");
        }

        return 0;
}

Existe alguma maneira que eu possa contornar isso para ter uma função de exibição compacta e canal num livre?

questionAnswers(1)

yourAnswerToTheQuestion