12-06-2007 12:29 PM
12-07-2007 07:02 AM
12-07-2007 07:18 AM
void* imaqImageToArray(const Image* image, Rect rect, int* columns, int* rows);
Creates a two-dimensional array from an image.
12-07-2007 08:52 AM
12-07-2007 10:22 AM
rval imgGetBufferElement(BUFLIST_ID bid, uInt32 element, uInt32 itemType, void* itemValue);
Gets the value for a specified itemType for a buffer in a buffer list.
Name | Type | Direction |
bid | BUFLIST_ID | input |
element | uInt32 | input |
itemType | uInt32 | input |
itemValue | void* | output |
rval | Int32 | output |
07-27-2010 12:12 AM
How would the imgGetBufferElement(...) function be implemented?
For example, I have a image buffer populated by the imgSnap(...) function. The buffer is declared as:
Int8* imaqbuffer=NULL;
how does this imaqbuffer go into the imgGetBufferElement(...) function to create a 2D integer array ( i[256][320] )?
I am using a 12-bit ALPHA NIR camera from FLIR technologies. Currently, I can save the images using the imgSaveBufferEx(...) function, but I also have to use the values of each individual pixel to do a few image processing manipulations.
07-27-2010 09:43 AM
Hi Vs3,
In the example code you are using, ImaqBuffer is the 2D array of your pixels. It is simply a block of memory that matches your width*height*bytes per pixel.
Eric
07-27-2010 03:54 PM
So how do I put that into a form i can use?
I've tried reading values in the visual studio debugger by accessing imaqbuffer[100][100] but I get an out of range error.
I can get a value by accessing imaqbuffer[100], but this value comes out to be meaningless to me... I am looking for a 2D array of 12-bit integers (0-4095)
Is the buffer simply a long string of bytes that I have to split up? is each 12-bit value from my camera stored as a word, or do every 3 bytes contain 2 pixels?
I have to do some image ratios, and I would like to have a simple var[][] identifier to use in my for loops.
07-27-2010 04:06 PM
vs3,
Your debugger won't let you access the data using the 2D array syntax because it is defined in the code as a pointer to a byte array but you want to access it as a 2D array of 16-bit integers (your 12-bit image data cannot be efficiently accessed in 12-bit form, so the IMAQ board always transfers it into 16-bit integers). You would simply cast the pointer to the format you need before dereferencing it. Note that in C, using 2D array syntax is tricky unless you hardcode the dimensions of such an array in your code. You are much likely better off treating it as a 1D array and accessing it as follows: imageData[y*width+x].
Eric
07-27-2010 05:16 PM
ah, okay...
so if I cast the buffer as a 16-bit integer, I will see the numbers that I am looking for in a 1D array?
what if I changed the declaration from Int8* to Int16*? I tried this earlier except I get a compilation error that Int16 is ambiguous so I haven't looked into it any farther yet.
all of my images are 318x256 pixels, which is why I am leaning toward a int[][] over a vector< vector<int> >.