Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert cv::Math src to QImage qim:

int w=src.cols;
int h=src.rows;
QImage qim(w,h,QImage::Format_RGB32);
QRgb pixel;
normalize(src.clone(),im,0.0,255.0,CV_MINMAX,CV_8UC1);
for(int i=0;i<w;i++)
{
    for(int j=0;j<h;j++)
    {
        pixel = qRgb((int)im.at<unsigned char>(j, i),(int)im.at<unsigned char>(j, i),(int)im.at<unsigned char>(j, i));
        qim.setPixel(i,j,pixel);
    }
}

Convert cv::Math src to QImage qim:

int w=src.cols;
int h=src.rows;
QImage qim(w,h,QImage::Format_RGB32);
QRgb pixel;
normalize(src.clone(),im,0.0,255.0,CV_MINMAX,CV_8UC1);
for(int i=0;i<w;i++)
{
    for(int j=0;j<h;j++)
    {
        int gray = (int)im.at<unsigned char>(j, i);
        pixel = qRgb((int)im.at<unsigned char>(j, i),(int)im.at<unsigned char>(j, i),(int)im.at<unsigned char>(j, i));
qRgb(gray,gray,gray);
        qim.setPixel(i,j,pixel);
    }
}

Convert Normalize and then convert cv::Math src to QImage qim:

int w=src.cols;
int h=src.rows;
QImage qim(w,h,QImage::Format_RGB32);
QRgb pixel;
Mat im;
normalize(src.clone(),im,0.0,255.0,CV_MINMAX,CV_8UC1);
for(int i=0;i<w;i++)
{
    for(int j=0;j<h;j++)
    {
        int gray = (int)im.at<unsigned char>(j, i);
        pixel = qRgb(gray,gray,gray);
        qim.setPixel(i,j,pixel);
    }
}