05-19-2015 01:44 PM
Hi,
I know there are quite a lot of topic relating to the "Array to Bitmap Conversion" . However, I cant find one that solved my problem, so I though it would be a good idea to start a new one.
I tried a few ways to save my 2d array in Labview and convert it to a bitmap. The problem is that when I try to open the file on Windows Photo Viewer or Paint, I get :
Windows Photo Viewer cant open this picture because either WPV doesnt support this file format, or you dont have the latest updates to WPV.
I get : Paint cannot read this file. This is not a valid bitmap file, or its format is not currently supported.
On LabView, I use : 2d array > flatten pixmap.vi > draw flattened pixmap.vi > write bmp file.vi
I can display the picture obtained after the draw flattened pixmap VI on the front panel.
My picture is actually very small : it is 8x8 pixels ( each pixel corresponds to the value of a sensor ).
I hope I gave you enough information about my problem. If I can make anything clearer please let me know. Thanks a lot for your help !
05-19-2015 01:53 PM - edited 05-19-2015 01:54 PM
Attach your VI. Save your controls and indicators as default, save the VI, then attach it. (That way we can work with the same picture data you are using.)
You wouldn't send an e-mail your mechanic and ask him to troubleshoot your car without ever taking it in and showing it to him.
05-19-2015 01:57 PM
What's the format of the image data (B&W, colormapped, 24bit, etc.). The bitmap format has a bewidering number of internal representations.
Have you tried saving to PNG instead? Probably more efficient.
05-19-2015 03:18 PM
Thanks for your fast replies.
I tried to save it as PNG but the <write to PNG> VI was stopping the execution of the program. The error code was :
Error 1 occurred at Check Color Table Size.vi
Possible reason(s):
LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
=========================
NI-488: Command requires GPIB Controller to be Controller-In-Charge.
The format of the picture data is probably the default one. In fact, I am really new to both Labview and picture formats so it might be the cause of my problem.
In my main program, the numeric block of the subVi is wired to the <i> in my while loop. It changes the name of the bmp file every cycle ( each cycle is around 2 seconds ). The values in the 2d array are between 0 and 5 for now so I am using only 4 bits ( I might want to go from -10 to 10 eventually, with 8 bits resolution ).
I hope I saved the default values the right way and you can see them.
05-19-2015 03:24 PM
Your error message tells me that something is wrong with your file name. Perhaps the path doesn't exist.
I didn't see that problem.
But I did get a corrupted .bmp file.
I'm suspicious of the use of a 2-D double array into an input that is expecting a 2-D U-8 integer array.
05-19-2015 03:33 PM
Why are you converting it to a 4 bit image?
You did not wire the colormap.
(You should set the zoom factor of your picture to e.g. 10 to see things better)
05-19-2015 03:34 PM - edited 05-19-2015 03:39 PM
I just tried to wire my 2d array to the 24 bits input of the Flatten Pixmap VI. I scaled my values before so the 0-10 interval is now between 0 -2 to the 24.
I kind of works but the colors look almost random. It think the problem might comes from the colors mapping input of the Flatten Pixmap VI but I dont know how to fix it. Do you think this might be the source of the problem ?
05-19-2015 03:45 PM - edited 05-19-2015 03:49 PM
No, scaling a DBL to a 24bit color seems not the right thing to do. What kind of colors do you expect?
I would scale the DBL to 0...255, create a suitable color ramp of 256 colors, and covert to an paletted 8bit image. Works just fne here. See attached for an example (creating greyscale).
.
05-19-2015 04:50 PM
This is exactly what I needed. Seems like the color input cant be left blank on the Flatten Pixmap VI. Thanks a lot ! One last thing, is there an easy way to apply the zoom factor to the saved image ? My file is indeed very small.
05-19-2015 05:00 PM
You could just use the zoom function in the new application. To create a larger image in LabVIEW, you would resample the existing image into a larger (by an integer multiple) array.