Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use return value of the function imaqImageToArray ?

in the help file, i says that the function creates a two-dimensional array from an image. The following is my code:
 
array = imaqImageToArray(sourceImage,IMAQ_NO_RECT, &columns ,&rows);
      g = malloc ( columns * rows * sizeof (unsigned char));
      for(i=0;i<columns;i++)
         for(j=0;j<rows;j++)
        
          g[rows+i*columns]= array[rows+i*columns];
 
but the error report said the 201 byte( 201 elements) pass end of array, I do not what is the wrong?
Who can tell me?
THANKS!

Message Edited by toidi on 07-16-2005 08:22 PM

Dongsheng Zhao
North China Electronic Power Univ.
zds_hd@yahoo.com.cn
0 Kudos
Message 1 of 2
(2,978 Views)

Hi Dongsheng,

 

The attached code is indexing columns and then rows.  Try the code below, which indexes the rows and then columns.  I think this will fix the problem.

 

array = imaqImageToArray(sourceImage,IMAQ_NO_RECT, &columns ,&rows);
      g = malloc ( columns * rows * sizeof (unsigned char));
      for(i=0;i<rows;i++)
         for(j=0;j<columns;j++)

 

Ryan

Applications Engineer

National Instruments

Message 2 of 2
(2,958 Views)