Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Saving the image

Hi there, A very easy question. I´m trying to load an image and save it to a new variable/file. int main() { Mat host, dest; register unsigned long int i1, j1; vector<int> JPEG_param; host = imread("E://PO//2//Amir_3_0_0__0_16x16-des22_L1xL2_300x300_NxM_1000x1000_centrox10_centroy46.jpg", CV_LOAD_IMAGE_ANYCOLOR); dest = Mat::zeros(host.rows, host.cols, CV_8UC3); if (!(host.size() == dest.size())) cout << "Unequal Size" << endl; for (i1 = 0; i1 < host.rows* host.cols; i1++) host.data[i1] = dest.data[i1];

namedWindow("The Host Image", WINDOW_AUTOSIZE);
imshow("The Host Image", host);
waitKey(0);
destroyWindow("The Host Image");
namedWindow("The dest Image", WINDOW_AUTOSIZE);
imshow("The dest Image", dest);
waitKey(0);
destroyWindow("The dest Image");
JPEG_param.push_back(CV_IMWRITE_JPEG_QUALITY);
JPEG_param.push_back(100);
imwrite("E://PO//123.jpg", dest, JPEG_param);
getchar();
return 0;

} But when I display the image, it´s entirely black. What´s wrong???!!!

Saving the image

Hi there, A very easy question. I´m trying to load an image and save it to a new variable/file.

int main()
{
    Mat host, dest;
    register unsigned long int i1, j1;
    vector<int> JPEG_param;
    host = imread("E://PO//2//Amir_3_0_0__0_16x16-des22_L1xL2_300x300_NxM_1000x1000_centrox10_centroy46.jpg", CV_LOAD_IMAGE_ANYCOLOR);
    dest = Mat::zeros(host.rows, host.cols, CV_8UC3);
    if (!(host.size() == dest.size()))
        cout << "Unequal Size" << endl;
    for (i1 = 0; i1 < host.rows* host.cols; i1++)
        host.data[i1] = dest.data[i1];

dest.data[i1];

    namedWindow("The Host Image", WINDOW_AUTOSIZE);
 imshow("The Host Image", host);
 waitKey(0);
 destroyWindow("The Host Image");
 namedWindow("The dest Image", WINDOW_AUTOSIZE);
 imshow("The dest Image", dest);
 waitKey(0);
 destroyWindow("The dest Image");
 JPEG_param.push_back(CV_IMWRITE_JPEG_QUALITY);
 JPEG_param.push_back(100);
 imwrite("E://PO//123.jpg", dest, JPEG_param);
 getchar();
 return 0;
}

} But when I display the image, it´s entirely black. What´s wrong???!!!