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 in a step by step manner. I am new to both C and OpenCV.
please do not use opencv's arcane c-api (which was abandoned in 2010 already)
... and have a look at the basic tutorials
Unknowingly I started with C. Now that I am almost in the verge of completing my project, I need this little conversion. With this last process, my work will be over. That is why I am not able to skip using C. Kindly help me out if possible.