Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read the Image buffer array?

I just started using the PC1411 card & loaded NI-IMAQ.
I'm now playing around with the examples given in C.
 
From the "Grab" example in MSVC, is the image stored in ImaqBuffer?
What does this buffer look like?
As in how do I get, for example coordinate (x=12, y=23)   HSL=? R=? G=? B=? the values for the pixel.
 
Hope you can help. Thank you
0 Kudos
Message 1 of 6
(4,531 Views)
Hello,
 
An option you have is get the image into a bitmap format then use the following syntax:
 
int GetBitmapData (int bitmapID, int *bytesPerRow, int *pixelDepth, int *width, int *height, int colorTable[], unsigned char bits[], unsigned char mask[]);
 
If the pixelDepth is greater than 8, then the colorTable returns NULL and the bits array contains the actual color value for each pixel in the image.  If the pixelDepth is less than 8, then the colorTable will return an array of RGB color values.  Before calling this function, you will need to either call GetBitmapInfo to get the size of the buffers to pass and then allocate the buffers or you can call AllocBitmapData.  The syntax for these two functions are as follows (I simply pulled them from the IMAQ C Function Reference Help):
 
int GetBitmapInfo (int bitmapID, int *colorSize, int *bitsSize, int *maskSize);
 
int AllocBitmapData (int bitmapID, int **colorTable, unsigned char **bits, unsigned char **mask);
 
I hope this will help you out!
Carlton
CLA
0 Kudos
Message 2 of 6
(4,505 Views)

Thank you & my apologies for posting my question twice.

You mentioned these 3 functions

GetBitmapInfo(), AllocBitmapData(), GetBitmapData()

1. You mentioned that you pulled this from the IMAQ C Function Reference Help. Please may I know where I can get this "Reference Help". In my  2 folders, C:\Program Files\National Instruments\Vision\IMAQ Vision for CVI Function Reference.chm & C:\Program Files\National Instruments\NI-IMAQ\Docs\NI-IMAQ Function Reference.chm, I can't find these functions.

2. Do you have actual examples using these functions?

3. Could I have the example C code used for "Measurement & Automation Explorer" example supplied with the PC1411? 

Thank you & Best Regards

0 Kudos
Message 3 of 6
(4,469 Views)

Just to clarify my earlier request....

Item No 3 is the program supplied whereby while in GRAB mode, moving the mouse will display, at the bottom of the image, the actual R,G,B values of that point.

- NI-IMAQ Devices - img0 : IMAQ PCI-1411 - Channel 0:PAL

Thanks.

 

0 Kudos
Message 4 of 6
(4,468 Views)

Hi,

The functions I mentioned above are located in the CVI functions help, not the help file located in the IMAQ folder.  Are you wanting to get the RGB values from a single pixel for each frame while doing a grab?  If so then those functions are not ideal since they are looking for a bitmap.  The functions that do what you are looking for are the GetColorPixelValue and IntegerToColorValue VIs, but not every VI in LabVIEW has a function that can be used when programming in C.  I have contacted R&D to see if they know of some available functions and I will let you know their reply.  There is no example specifically written for this but if there is a function to do what you are wanting, it should be a quick addition to the Grab example.

Carlton
CLA
0 Kudos
Message 5 of 6
(4,446 Views)

Hello Vic,

I found a function for you:

int imaqGetPixel(const Image* image, Point pixel, PixelValue* value);

PixelValue is a type that contains a member called RGBValue and RGBValue is a structure that contains elements R, G, B and alpha. So if you call the above function as such:

imaqGetPixel(image, pixel, value);

Then I believe you can extract the components like this:

char Red = value.rgb.R;
char Blue = value.rgb.B;
char Green = value.rgb.G;

 

Carlton
CLA
0 Kudos
Message 6 of 6
(4,427 Views)