如何手动将8位(CV_8U)图像转换为4位图像?这是加载图像的简单示例。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
if (argc != 2)
{
cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
for (int r = 0; r < image.rows; ++r)
{
for (int c = 0; c < image.cols; ++c)
{
// What to do here??
}
}
return 0;
}
或许还有另一种转换方式。