Casting Float32 (Short) IMAQ Image to U8 or I16Primary Software: Driver Software>>NI-IMAQPrimary Software Version: 3.5.1 Primary Software Fixed Version: N/A Secondary Software: Driver Software>>NI-IMAQ for IEEE-1394, Driver Software>>NI-IMAQ for USB Cameras
Problem: I am trying to cast my Float32 (Short) IMAQ Image to an U8 or an I16 IMAQ Image using IMAQ Cast Image VI and my resulting image is black. What am I doing wrong? Solution: IMAQ Cast Image VI does not actually cast the image data when converting from a float32 (short) to a U8 or an I16 image type. Rather, IMAQ Cast Image VI coerces the image data, in the same way that LabVIEW will coerce a float to an integer. For example, 2.57 (float) would be coerced to 2. Imagine you are using IMAQ Cast Image VI on a float32 (short) image with a pixel value of 255.000 (b01000011011111110000000000000000). If you pass this image through the IMAQ Cast Image VI, the new pixel value will be a U8 with a value of 255 (b11111111), not (b01000011). Your image will show up black if the float32 (short) pixel is over 255, because any pixel over 255 will be coerced to 255. Likewise, if you are converting to an I16 image, the image might look like a binary image, because all pixels less than 0 will be coerced to 0 and all pixels greater than 255 will be coerced to 255. If you would like to actually cast the float32 (short) image to a U8 or I16, you will need to convert the image to a 2D array and use the LabVIEW Type Cast function to cast the 2D array. The screenshot below shows how to accomplish this in LabVIEW.
Related Links: KnowledgeBase 3W6EEVD3: 16-bit Images in NI Vision KnowledgeBase 3QJD6R4Y: Why Does the Image I Snapped Look Lighter/Darker After Type Casting it from 16-bit to 8-bit? Attachments:
Report Date: 05/03/2006 Last Updated: 05/14/2009 Document ID: 3X2E15AJ |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

