LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Grayscale Image from IMAQdx Grab

Hello everyone, I am just starting to use lab view to control a camera to performing data analysis. I have a Monochrome USB3.0 Camera to obtain Image with type Grayscale (U8).But it seems IMAQdx Grab VI always get image data in type of RGB(U32) which could be used by Image analysis vi like IMAQ Centroid VI only after converting it to image type U8 or U16.

      Is there any chance that IMAQdx Grab VI could obtain image in type of Grayscale (U8)? That will same me lots of time with type converting.

0 Kudos
Message 1 of 10
(5,955 Views)

What's your settings in NI-MAX ?

What's your buffer image type ?

 

 

George Zou
0 Kudos
Message 2 of 10
(5,869 Views)
  1. Make your Subject Line relevant (to help other Forum Users).  I'd suggest "How to get Grayscale Image from IMAQdx Grab".
  2. Attach your existing Code (simplest/best way is to attach the VI) so we can both see what you are doing and try it out for ourselves.  Do not send a verbal description or a partial picture that would make us do a lot of work to recreate what you've already done.

Have you looked at the Vision functions?  Surely there is one that can convert an RGB image to an I16 or U8 GrayScale image ... 

 

Bob Schor

0 Kudos
Message 3 of 10
(5,866 Views)

1.png

This is the code I used, it will work after using Cast Image VI. As the image I want analyzed with the size of 3856 x 2764 that will slow down the sampling rate.

0 Kudos
Message 4 of 10
(5,795 Views)

I'm glad you are satisfied with your code, and no longer need our help.  [I'm deducing this from the fact that (a) you refused to attach your code, but only showed us a picture (non-executable) of part of your code) and (b) you didn't ask any question.

 

Bob Schor

0 Kudos
Message 5 of 10
(5,781 Views)

I am not satisfied with my code, If there is a way that Grab VI could generate a Grayscale U8 image I like to know?

 

0 Kudos
Message 6 of 10
(5,775 Views)

Thank you.  Now I can see what you are doing.  I notice that you use the Enumerate Video Modes function, but don't look at its outputs, which is probably just as well, as setting Camera Attributes in IMAQdx is not particularly User-Friendly.  Can you look at the array output by Enumerate Video Modes and find one that is more suitable than the default you are now using?  

 

You can also examine, and set, the Video Attributes of your Camera in MAX.  One of my Cameras has a Color or Mono Attribute, along with variable Image Size -- might yours?  

 

Bob Schor

0 Kudos
Message 7 of 10
(5,747 Views)

Thank you for your help again. I am using a camera Basler acA3800-14um  which will only generate grayscale image of Mono 8 or Mono 12 and the default image type Mono 8 is what I need. The Grab VI will convert it into RGB(U32) and I have to convert it back to U8 for my application. Lots of time have been wasted.

0 Kudos
Message 8 of 10
(5,721 Views)

Well, my assumption that you could "turn down" the image coming from the camera.  I'd used MAX to look at one of my AXIS cameras, saw that it had a "JPEG Mono" mode, so I figured I could choose this mode when I configured IMAQdx and decrease the image size from a U32 RGB to a U8 Grey.

 

Wrong!  First, there seemed to be no Property Node (nor Camera Configuration) that would set the mode to give me an 8-bit Image.  I could manually set the camera to send no color information, getting a B&W image on my camera, but still getting a U32 image.  However, the IMAQ Cast Image function should be very quick in getting the image size converted to a U8 Grayscale.

 

So let's go back to your VI.  In your While loop, you (a) acquire an Image, (b) display it, and (c) "process the pixels" (do some computations on the pixel values).  All three of these events occur in sequence, so the loop time is the sum of the times for all three steps.  However, because the Camera runs on a "frame-rate" clock, this time, ideally, should be less than 1/Frame Rate so as not to miss any frames.

 

One way to speed up the loop process is to adopt a Producer/Consumer Design -- as the Images come in, put them on a Queue and pass them to a Consumer loop for display and image processing.  This will allow Image Acquisition (which takes camera time) and Image Processing (which takes PC time) to largely occur in parallel, clocked not by the sum of their respective speeds, but by the slower of their individual speeds.  Indeed, if you don't need to view every frame, you can drop the occasional Display to speed up the Consumer loop.

 

Give that a try, and see if this gets the speed of your Image Acquisition and Processing up to acceptable levels.  I'm guessing that it will.

 

Bob Schor

0 Kudos
Message 9 of 10
(5,687 Views)

Thank you, I will try it to optimize my code.

0 Kudos
Message 10 of 10
(5,660 Views)