I have the following code snippet that I created to change the pixel intensity in an OpenCV image (Cv :: Mat class).
As you can see, I do the loop in both cases, but with a different type of pattern.
The transfer function may be overloaded.
So my question is how can I create a dynamic type of template to make it look better.
Mat mat = _mat.clone() ;
int channels = mat.channels();
switch(channels)
{
case 1:
for (int i=0; i<mat.rows; i++)
{
for (int j=0; j<mat.cols; j++)
{
uchar src = mat.at<uchar>(i,j);
uchar dst = mat.at<uchar>(i,j);
t.transfer(src, dst);
}
}
break;
case 3:
for (int i=0; i<mat.rows; i++)
{
for (int j=0; j<mat.cols; j++)
{
Vec3b src = mat.at<Vec3b>(i,j);
Vec3b dst = mat.at<Vec3b>(i,j);
t.transfer(src, dst);
}
}
break;
}
return mat ;
source
share