Jump to content

converting array data to .bmp file


Recommended Posts

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.

Link to comment
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):

post-181-1151940299.png?width=400

Download File:post-181-1151940289.vi

Download File:post-181-1151940390.zip

Link to comment

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.

post-1431-1151940891.png?width=400

Link to comment
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.

Link to comment
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.
Link to comment
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

Link to comment
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!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.