1 | initial version |
Unfortunately, you have to use a switch statement. ex:
switch(img.depth())
{
case CV_8U:
std::for_each(img.begin<uchar>(), img.end<uchar>(), cleanPixel);
break;
case CV_16U:
....
default:
//Print error or whatever
}
You can also use the built-in forEach HERE, but it still requires a template argument, and therefore a switch statement.
2 | No.2 Revision |
Unfortunately, you have to use a if or a switch statement. ex:
switch(img.depth())
{
case CV_8U:
std::for_each(img.begin<uchar>(), img.end<uchar>(), cleanPixel);
break;
case CV_16U:
....
default:
//Print error or whatever
}
You can also use the built-in forEach HERE, but it still requires a template argument, and therefore an if/switch statement. However, it will parallellize your function, which is nice.
You can make a switch templated function for the whole processing chain and simply call that after the imread, giving you just one if/switch statement.