Mat srcImg = imread("D:\\1.jpg");if(srcImg.empty()){QMessageBox::information(this,"警告","图片读取失败,请检查图片路径!");return;}Mat imgShow ;cvtColor(srcImg, imgShow, COLOR_BGR2RGB); QImage qImg = QImage((unsigned char*)(imgShow.data), imgShow.cols,imgShow.rows, imgShow.cols*imgShow.channels(), QImage::Format_RGB888);ui->label->setPixmap(QPixmap::fromImage(qImg.scaled(ui->label->size(), Qt::KeepAspectRatio)));qDebug()<<"通道"<<imgShow.channels()<<endl;for(int i=0;i<imgShow.rows;++i){uchar*ptr = imgShow.ptr<uchar>(i);for(int j =0;j<imgShow.cols;++j){qDebug()<<static_cast<int>(ptr[j*3+0])<< static_cast<int>(ptr[j*3+1])<<static_cast<int>(ptr[j*3+2])<<endl;}}for(int i = 0; i < imgShow.rows; ++i) {for(int j = 0; j < imgShow.cols; ++j) {cv::Vec3b color = imgShow.at<cv::Vec3b>(i, j);std::cout << "Pixel at (" << i << ", " << j << "): "<< "B = " << static_cast<int>(color[0]) << ", "<< "G = " << static_cast<int>(color[1]) << ", "<< "R = " << static_cast<int>(color[2]) << std::endl;}}