Showing results for 
Search instead for 
Did you mean: 

Convert 32 bit image to 16 or 8 bit image...


Me again... (the other problem is still not solved)


but now I got a new problem... My webcam generates 32 bit images... now some IMAQ vi's only accept a 16bit or 8bit image... How do I convert my 32bit image from my webcam to a 16/8 bit image in labview? 

0 Kudos
Message 1 of 12

I think your web cam produces a RGB image. That consist of 3 channel (red green and blue). Each channel is encoded with 8 bits. Its extended to 4 Bytes. If you try to display as  8 bit you loose the color information and you have a grayscale image. 16 bits is also a grayscale image. You can apply a color table to grayscale image but I haven't an algorithm for calculating an optimal colortable from the color distribution in the RGB image.


In some cases you might have a 32bit grayscale image, which mean that each pixel is represented by a 32bit floating point number.

Then you need some more information about the image. You can do a transformation from min to may value from the 32bit numbers to 0-255 (values of 8bit image) or just convert the number to 8 bit and clip values exceeding the range from 0 to 255.


There are several VIs in the IMAQ-Vision package performing the described functions. But before giving more advice please check the camera whether it is RGB or 32bit floating point number grayscale and give some more information on your task.

0 Kudos
Message 2 of 12

Well I figured the following stuff out...


Image type is indeed RGB and 4 bytes per pixel. (atleast that is what labview says about the image)


Btw I've the following cam:,NL 


It has a colordepth of 24 bit. It doesn't have any technical detail furthermore.. 

0 Kudos
Message 3 of 12

Use the IMAQ IntegerToColorValue.VI to convert your camera data into a form that is accepted by the IMAQ ArrayToColorImage.VI The image for that VI should be created as a RGB (U32) image.


What do you want to do with the images? Do need a conversion to grayscale?

0 Kudos
Message 4 of 12
Well not really grayscale, color would (maybe) be better. It is just that the images must be 8 or 16 bit to detect edges with the IMAQ Find edge vi
0 Kudos
Message 5 of 12

I found the following formula on for RGB to grayscale conversion:


intensity = 0.2989*red + 0.5870*green + 0.1140*blue


The Vision Concepts Manual gives the same formula or suggest simple averaging of the three color planes.

There might be different formulas. Just google for "rgb grayscale conversion".


With IMAQ Vision split up the RGB image with 'Color Utilities > IMAQ ExtractColorPlanes'multiply with a constant and sum up with the 'Image processing > Operator'  VIs.


Regards, Jörn

0 Kudos
Message 6 of 12

Can't you just connect the image type "Grayscale (U8)" or "Grayscale (I16)" to the "Image type" connector of the "IMAQ Create" vi? The conversion will be done automatically by LabView.

I'll do it that way and the result is fine for me Smiley Happy

Maybe it will satisfy you also Smiley Wink

0 Kudos
Message 7 of 12

to Alain:


How do you do this? Could post some code?



0 Kudos
Message 8 of 12

Attached 3 screen shots

Snag-001 : IMAQ to create memory locations

Snag-002 : Load an image, even if it's a 32bit colour image it loads and show as an 8 bit grayscale image in the image control

Snag-003 : Process the image and show the result in the image control


This code is part of a complete project that load's 32 bit colour images from microscopes and analyse them in a certain way.

0 Kudos
Message 9 of 12

Right, if you load the image from disk it is automatically converted. I was thinking of an array of U32 representing colored pixels. U32-arrays can only converted to images with color planes using IMAQ ArrayToColorImage. I think Wouser might be interested in processing a stream of images. Then he wouldn't store them before processing and he would need the described algorithms.


0 Kudos
Message 10 of 12