Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-IMAQ: Image Processing in Buffer

Greetings,

I am an undergraduate research assistant working on a small utility written in Visual C++ to acquire 10 images and save the average of them. I have read the documentation included with the framegrabber. I can only use the NI-IMAQ DLLs. While I understand how to setup the interface, session, and buffers and then acquire the image, I do not understand how to process the image in the buffer. I would like to be able to reference it like a 2D array, which would make taking the average of the 10 images easier. Then, if possible, take the resulting average and put it in a new buffer so I can use the built in saving functions of NI-IMAQ. Any help would be appreciated. Thanks in advance.
0 Kudos
Message 1 of 7
(4,116 Views)
Hi, the buffer you create with the IMAQ.DLL in C is actually a 1D array with all the data, starting with pixel (0,0) in Line 0, then line 1, then line 2, etc., so with the attributes you can figure out how many pixels per line and how many lines you have in your image as to build your 2D array if you wish. If not, just do the average with the 1D buffer that you already have. The buffer functions in IMAQ.DLL will give you the pointer to the buffer address, from there use your logic to create the 2D array if you decide to.

Good luck!

Nestor.
Nestor
Message 2 of 7
(4,116 Views)
Thanks for your help. That helped me in my problem.
0 Kudos
Message 3 of 7
(4,116 Views)
I created a buffer list of 10 elements using imgCreateBufList(10, &Bid), but now, how do I access say element 2 of that buffer array? Bid[1] doesn't do the trick. Thanks.
0 Kudos
Message 4 of 7
(4,116 Views)
Check the function reference details for "imgGetBufferElement" using attribute IMG_BUFF_ADDRESS, it will give you the address where the buffer starts.

Good luck!

Nestor.
Nestor
0 Kudos
Message 5 of 7
(4,116 Views)
Is there anymore sample code I could look at, other than what came with the framegrabber software in the Samples directory?
0 Kudos
Message 6 of 7
(4,116 Views)
You may want to browse through our Development Library section here in the Developers Zone. Go to www.ni.com > NI Developer Zone > Development Library > Vision and then browse thru the categories, I believe right now you might be interested in Image Acquisition. Your User Manuals (Start > Programs > National Instruments > Vision > Documentation) is also a valuable source of information.

Nestor.
Nestor
0 Kudos
Message 7 of 7
(4,116 Views)