12-02-2008 09:09 PM
From my camera I collected 512x512 data (type: long). They are saved in a one dimentional array. Now I want to call imaqDisplayImage (const Image *Image, int Window_Number, int Resize) to display my image. But the first step is to convert the array to image. So I use imaqArrayToImage (Image *Image, const void *Array, int Num_Cols, int Num_Rows) to convert the array to Image. But now the problem is that here "void *Array" is a 2 dimentional array, while my collected data is 1 dimentional array. Are there any function I can call to reshape my 1 D array to 2D array? I know that in Labview there is some array reshape functions.
Thank you.
12-03-2008 06:08 PM
Hi Moon
You can find array function references in the NI LabWindows/CVI Help under Library Reference>> Analysis Library >> Alphabetical list of functions. I looked and did not see a manipulate array command under this list, but it should be something fairly straight forward to implement with two for loops.
11-02-2017 05:52 AM
Old post, but probably still actual...
consider an image of size width*height
int i, width, height, row, col;
unsigned short* array_1D;
unsigned short** array_2D;
// allocate memory for 2D array
array_2D = malloc(sizeof(unsigned short*) * height);
for(i=0; i<height; i++)
{
array_2D[i] = malloc(sizeof(unsigned short) * width);
}
// allocate memory for 1D array
array_1D = malloc(sizeof(unsigned short) * width*height);
// copy values row-per-row from 2D array in 1D array
for(row = 0; row < height; row++)
{
for(col = 0; col < width; col++)
{
array_1D[(row*width)+col] = array_2D[row][col];
}
}
Best regards.
Philipp