LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Reshap array to display as image

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. 

0 Kudos
Message 1 of 3
(3,370 Views)

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.


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 2 of 3
(3,343 Views)

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

0 Kudos
Message 3 of 3
(2,540 Views)