Displaying images from 1D double array
I have a 1D double array that represents a grayscale image. How can I create a Mat using this array to display the image using imshow?
Mat img = imread("input.jpg",0);
double outImg[224932];
imgProcessing(src.data,outImg);
The following are the processing fuctions:
static double* imgProcessing(unsigned char* data)
{
double *img = filter(data);
return img ;
}
double* filter(const unsigned char imageName[680028])
{
int i0;
static double img[680028];
static double img_x[680028];
static double img_y[680028];
static double img_sqr[680028];
static double test[680028];
for (i0 = 0; i0 < 680028; i0++) {
img[i0] = (double)imageName[i0] / 255.0;
}
imfilter(img, img_x);
b_imfilter(img, img_y);
power(img_x, img_sqr);
power(img_y, img);
for (i0 = 0; i0 < 680028; i0++) {
imgl_sqr[i0] += img[i0];
}
b_sqrt(img_sqr);
return img_sqr;
}
Thanks in advance.
Yes, the height and width of the image are known. This is an array that was returned from a function that processes a given image to detect edges.
"This is an array that was returned from a function that processes a given image" -- so, some kind of callback function ?
could you add the code, acquiring the image ?
(again, the question is: do we need to copy the data, or not, will it go out of scope (between imshow() / waitKey() calls) ? then we need to.)
I have added what I have come up with till now. The code was written in the main function. Then, from there I called the imgProccessing function. Yes, I do need to copy the data.
you probably should not write code like this, but use opencv functions instead.
I am required to use this could, I can not use opencv fucntions.