/** * 读取路径中的图像并显示 * @param inputPath */ void readImage(char *inputPath) { //读取图像,ps:opencv默认读取的是彩色图,其色彩格式BGR Mat color = imread(inputPath); //加载灰度图 Mat gray = imread(inputPath, IMREAD_GRAYSCALE); // if (!color.data) { cout << "Could not open or find the image" << endl; return; } //展示彩色图像 imshow("Image(BGR)", color); //展示灰度图像 imshow("Image(Gray)", gray); //wait for any key press waitKey(0); }