plneo Posted July 3, 2006 Report Share Posted July 3, 2006 Hi everyone, I am totally new to Labview and need some help here. I have generated an array using LabView and want to convert the array into a .bmp file. In my array, the element can only hold a value of '0' or '1'. I want to convert this array full of '0' or '1' into a .bmp file with black and white pixels. I wonder if this is possible? Thanks. Quote Link to comment
crelf Posted July 3, 2006 Report Share Posted July 3, 2006 I want to convert this array full of '0' or '1' into a .bmp file with black and white pixels. Do you have the NI-Vision Toolkit installed? Quote Link to comment
plneo Posted July 3, 2006 Author Report Share Posted July 3, 2006 Do you have the NI-Vision Toolkit installed? I am not sure if I have what you have mentioned. However, when I looked under my NI tree, I see this... National Instruments > Vision. Is this what you are talking about? Pardon my ignorance. Quote Link to comment
crelf Posted July 3, 2006 Report Share Posted July 3, 2006 I see this... National Instruments > Vision. LabVIEW ships with a handful of basic vision functions under the "Vision and Motion" functions palette, but you can also get an add-on toolkit called the NI Vision Development Module. You can convert integer arrays to bitmaps, so all you need to do is create a low bit width (8 bit) image space (IMAQ_Create) and then convert your Booleans into integers (0/255), populate them into the image (IMAQ_ArrayToImage) and then save it our to a bitmap (IMAQ Write Bitmap File): Download File:post-181-1151940289.vi Download File:post-181-1151940390.zip Quote Link to comment
Yair Posted July 3, 2006 Report Share Posted July 3, 2006 This can also be done with the standard picture VIs (which ship with most versions of LV) and can be found (at least before LV 8.0) in the Graphics & Sound palette. You basically need to use Flatten Pixmap and wire the result into Write BMP file. You will also need to convert your array into a boolean array, which you can do by wiring it into a Not Equal to Zero? node. Quote Link to comment
crelf Posted July 3, 2006 Report Share Posted July 3, 2006 This can also be done with the standard picture VIs (which ship with most versions of LV) and can be found (at least before LV 8.0) in the Graphics & Sound palette. Yep - that'll work too Quote Link to comment
plneo Posted July 4, 2006 Author Report Share Posted July 4, 2006 Yep - that'll work too Thanks - yen and crelf. It works. Quote Link to comment
plneo Posted July 4, 2006 Author Report Share Posted July 4, 2006 Thanks - yen and crelf. It works. I just want to confirm, when I used Yen's method, my output file is not black-and-white, instead, it is made up of 2 colors. The .bmp file can be red with blue or yellow with green or green with white or etc.... And everytime I run the program, it will get different combinations. I wonder if anyone is seeing this too? Is there anyway I can do so that I will always get black and white ONLY in my .bmp file? Appreciate your help/assistance/comments. Quote Link to comment
Yair Posted July 4, 2006 Report Share Posted July 4, 2006 I just want to confirm, when I used Yen's method, my output file is not black-and-white, instead, it is made up of 2 colors. The .bmp file can be red with blue or yellow with green or green with white or etc.... And everytime I run the program, it will get different combinations. I wonder if anyone is seeing this too? Is there anyway I can do so that I will always get black and white ONLY in my .bmp file? If you read the help for the function, you will see that the colors of the boolean array are determined by the first 2 elements of the Colors[] array. All you need to do is drop a couple of color box constants (from the Numeric>>Constants palette) in a constant array and set them to be white and black and wire that constant in as the colors. Quote Link to comment
Cool-LV Posted July 4, 2006 Report Share Posted July 4, 2006 I just want to confirm, when I used Yen's method, my output file is not black-and-white, instead, it is made up of 2 colors. The .bmp file can be red with blue or yellow with green or green with white or etc.... And everytime I run the program, it will get different combinations. I wonder if anyone is seeing this too? Is there anyway I can do so that I will always get black and white ONLY in my .bmp file? Appreciate your help/assistance/comments. I think my sample can help you, and you can define its"size" to get bmp's pixel. Download File:post-4703-1152021249.vi Quote Link to comment
plneo Posted July 5, 2006 Author Report Share Posted July 5, 2006 If you read the help for the function, you will see that the colors of the boolean array are determined by the first 2 elements of the Colors[] array. All you need to do is drop a couple of color box constants (from the Numeric>>Constants palette) in a constant array and set them to be white and black and wire that constant in as the colors. Thanks Yen. It took me the whole day to get familiar with simple array functions and trying to control the colors[] array. Afterall I am a 3-day old Labview user. Your method works. Many thanks. Thanks to Cool-LV for helping too! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.