Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Bayer LUT and Bayer Color Decode

Please, could someone explain what these two vi's do?  When I perform a RGB gain calculation and initialize the LUT, it doesn't do much of anything.  Please look at my code and let me know if I am doing something wrong. 

 

Thank you in advance.  

 

Matt
Download All
0 Kudos
Message 1 of 9
(5,493 Views)

Hey Matt,

 

I'll have to look around for a firewire cam so I can test your VIs, but first I wanted to see if you've tried some of our Bayer examples? I assume you have, but its worth looking into if you haven't.

 

Looking at your code, I don't see anything that really sticks out, minus you using a case strucutre for false to become true and vice versa. You merely need to use a Boolean not for that.

Chris Van Horn
Applications Engineer
0 Kudos
Message 2 of 9
(5,480 Views)
Chris,

I have figured out kinda what is wrong with it.  I have looked at your examples, just to answer your question.  I got it to work, but not that great. The color correction doesn't work very well.  If I use a property node to set the gains it works much better, but I can only do that one time because when I tried to do it on a loop the unconfigure and configure took way to long to be practical.  Does the property node actually set the gain inside the camera?  I believe this is correct, but I would like confirmation.  Also, I tried to do a first stage where I set the bayer inside the camera (assumption) and then start running the auto wb with the code I have here.  But it seems that when I get the raw image data, the rgb pixels dont have the gains applied to them.  I assumed the bayer in the camera would apply the gains to the pixels in the 8 bit raw output that corresponded to the colors they represent.  But that doesn't seem to be the case. 

One other question.  Could you tell me exactly what the Bayer LUT does?  If I know what it does maybe I can set up a LUT that configures the bits first and then give them to the bayer decode. 

Please advise.

There was a problem with the code I gave you.  I connected the raw 8 bit line to the image in of the rgb gain calculation sub vi.  I will attach the correceted one. 

Thank you

 

Matt
0 Kudos
Message 3 of 9
(5,466 Views)

Please disregard the LUT question, I just saw that I could see the code, and I will try to decipher that. 

 

Matt

0 Kudos
Message 4 of 9
(5,459 Views)

Matt,

 

As far as being able to set the attributes only once with the property nodes, I have a suggestion. I would assume it is the same with IMAQdx as it is with our framegrabbers, I will have to look into it to verify. Anytime you change attributes of the camera, you need to end the camera session and open it again. Even in MAX when you change an attribute, it doesn't look like it is ending the session, but on very low-level, it actually is. So, normally the best way around this is to create an event structure, where if the gain settigns change, end session and restart it.

 

As far as changing gain, with firewire cameras, it is stored on the camera, so your assumptions are correct.

Chris Van Horn
Applications Engineer
0 Kudos
Message 5 of 9
(5,451 Views)

Chris,

 

If this is the case, why is the raw 8 bit bayer image data that is transmitted from the camera not reflecting the gains that were set in the camera?  When I set the gain in the camera and then put a gain value of 1 into the Bayer LUT vi, and then create a RGB image witht the Bayer decoded image vi the image still has the color as if the gains were not set in the property node first?  I also made indicators that showed the gain from the camera with a property node (a read node) and they reflected the values I set at the beginning.  

 

Matt 

0 Kudos
Message 6 of 9
(5,444 Views)

Hi Matt,

 

I have a couple of suggestions...

 

Presumably the color gains you were setting via the IMAQdx property nodes were the Bayer gains that IMAQdx uses for its internal image decoding (these are not on the camera). However, you were grabbing raw image data as an array and decoding it yourself and doing a manual de-bayering of it via the Vision bayer decode VIs. Since IMAQdx is not doing the decoding to a color image, its bayer gains are not used.

 

What you probably want to do is instead tell IMAQdx to decode your image with a Bayer pattern. You can change this option in MAX on the last tab that selects the Bayer pattern to use. Depending on your camera this may be set automatically if you go into a color video mode. However, you can tell the driver manually to decode it as a bayer image. You can also change all of these things programatically in LabVIEW as well but it might be easier to start by saving the settings in MAX first. You can then switch to using a normal Grab VI instead of getting the raw data as an array. Even if you didn't want IMAQdx to do the Bayer decode, you would probably be better off still just telling IMAQdx to not apply a pattern ("None") and grabbing it as a Mono image and then running it through those Vision VIs to de-bayer.

 

Now what Chris mentioned about the session needing to be closed is not quite true. In the IMAQ framegrabber driver, "camera" attributes (ie ones that exist on the camera and controlled via serial commands as described by the camera file) do in fact need to reconfigure the framegrabber when you modify them to keep the camera's settings coherent with the driver. In the IMAQdx driver, this is not true and each attribute (whether in the driver or the camera) may have a different policy regarding when it can be written to. However, the one you are talking about that controls the Bayer gains is not writable while the acquisition is "configured". This is because the image decoder must recalculate the lookup table. However, there may be another option. Many color cameras offer on-board color correction as well where they adjust the gains individually on the pixels representing each color of the bayer pattern. You may want to see if your camera offers a White Balance or Hue attribute (it would show up in MAX) that may achieve the desired effect. In fact, they may have a mode to make it do a continuous automatic white balance too.

 

Hope this helps,
Eric 

0 Kudos
Message 7 of 9
(5,436 Views)

Eric

 

Thanks for the reply but your post brings up some questions.  

 

Is there any way to set the gains first with the property node, and then take that image and correct it with the Bayer LUT and Decode vis?  The reason is when I set the gain with the property node it works pretty well, but I want to be able to make small small color adjustments to that image, but the best way seems to be using the Bayer LUT and Decode.  

 

Also, I think I may be missing something.   What is the differnece between IMAQ and IMAQdx?  I can't seem to find anything.  Please let me know, or at least fill me in where to look.

 

Thanks again,

 

Matt

0 Kudos
Message 8 of 9
(5,413 Views)

Hey Matt,

 

To answer the second half of your post, IMAQ and IMAQdx are different drivers that both come in Vision Acquisition Software. IMAQdx requires a license and can communicate with firewire and GigE cameras. IMAQ is used for our framegrabbers.

Chris Van Horn
Applications Engineer
0 Kudos
Message 9 of 9
(5,403 Views)