Creating new image in a loop using OpenCV

Posted by user565415 on Stack Overflow See other posts from Stack Overflow or by user565415
Published on 2011-01-07T10:54:08Z Indexed on 2011/01/07 15:54 UTC
Read the original article Hit count: 201

Filed under:
|
|
|

I am programing some image conversion code with OpenCV and I don't know how can I create image memory buffer to load image on every iteration. I have number of iteration (maxImNumber) and I have an input image. In every loop program must create image that is resized and modified input image. Here is some basic code (concept).

    for (int imageIndex = 0; imageIndex < maxImNumber; imageIndex++){
    cvCopy(inputImage, images[imageIndex], 0);
    cvReleaseImage(&inputImage);

    images[imageIndex+1] = cvCreateImage(cvSize((image[imageIndex]->width)/2, image[imageIndex]->height), IPL_DEPTH_8U, 1);

    for (i=1; i < image[imageIndex]->height; i++) {   
        index = 0;      //   
        for(j=0; j < image[imageIndex]->width ; j=j+2){
            // doing some basic matematical operation on image content and store it to new image
            images[imageIndex+1][i][index] = (image[imageIndex][i][j] + image[imageIndex][i][j+2])/2;
            index++
        }
    }

    inputImage = cvCreateImage(cvSize((image[imageIndex+1]->width), image[imageIndex]->height), IPL_DEPTH_8U, 1);
    cvCopy(images[imageIndex+1], inputImage, 0);
}

Can somebody, please, explain how can I create this image buffer (images[]) and allocate memory for it. Also how can I access any image in this buffer?

Thank you very much in advance!

© Stack Overflow or respective owner

Related posts about image-processing

Related posts about opencv