Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to save raw pixel values as image and display it?

I am using C and OPENCV in Ubuntu 14.04 platform. I have accessed the pixels of the input image (gray scale), compressed them and then reconstructed them back. Now I have a single vector of reconstructed pixel values of size 65536 X 1 (i.e. vi[65536]). I tried in various methods to convert these raw pixels into image so that i can display it. but I failed. Here is the process that I used.

uchar *output = (uchar*)image->imageData;

Then I reconstructed the input image and have saved the pixel values as vector in vi[]

`for (i=0; i < 65536; i=i+1) 
{
output->imageData[i]=vi[i];
}
cvSaveImage("foo.png", output, 0);
cvNamedWindow("foo", CV_WINDOW_AUTOSIZE);
cvShowImage( "foo", output );
cvReleaseImage(&output);
cvWaitKey(0);
return 0;

But I am not able to save the pixel values as image and display it. Where have I gone wrong? I am using C. Kindly help me with this.

How to save raw pixel values as image and display it?

I am using C and OPENCV in Ubuntu 14.04 platform. I have accessed the pixels of the input image (gray scale), compressed them and then reconstructed them back. Now I have a single vector of reconstructed pixel values of size 65536 X 1 (i.e. vi[65536]). I tried in various methods to convert these raw pixels into image so that i can display it. but I failed. Here is the process that I used.

uchar *output = (uchar*)image->imageData;

Then I reconstructed the input image and have saved the pixel values as vector in vi[]

`for (i=0; i < 65536; i=i+1) 
{
output->imageData[i]=vi[i];
}
cvSaveImage("foo.png", output, 0);
cvNamedWindow("foo", CV_WINDOW_AUTOSIZE);
cvShowImage( "foo", output );
cvReleaseImage(&output);
cvWaitKey(0);
return 0;

But I am not able to save the pixel values as image and display it. Where have I gone wrong? I am using C. Kindly help me with this.in a step by step manner. I am new to both C and OpenCV.

How to save raw pixel values as image and display it?

I am using C and OPENCV in Ubuntu 14.04 platform. I have accessed the pixels of the input image (gray scale), compressed them and then reconstructed them back. Now I have a single vector of reconstructed pixel values of size 65536 X 1 (i.e. vi[65536]). I tried in various methods to convert these raw pixels into image so that i can display it. but I failed. Here is the process that I used.

uchar *output = (uchar*)image->imageData;

Then I reconstructed the input image and have saved the pixel values as vector in vi[]

`for for (i=0; i < 65536; i=i+1) 
{
output->imageData[i]=vi[i];
}
cvSaveImage("foo.png", output, 0);
cvNamedWindow("foo", CV_WINDOW_AUTOSIZE);
cvShowImage( "foo", output );
cvReleaseImage(&output);
cvWaitKey(0);
return 0;

But I am not able to save the pixel values as image and display it. Where have I gone wrong? I am using C. Kindly help me in a step by step manner. I am new to both C and OpenCV.