08-12-2015 10:03 AM
Hi,
i am generating a series of simulated dot-by-dot prints and displaying them in an array of 2D pictures (see print1.png). I have tried to merge all the elements of the array into a single image and to save it as a BMP file in order to be able to compare the differences between consecutive prints. Howeve, I am having some trouble converting between the different image formats.
- The "Unflatten Pixmap VI" only provides an output as 24-bit pixmap (even though a 4-bit or 1-bit output would suit my needs).
- The "Flatten Pixmap VI" where I feed the full array of pixmaps produces an image with distorted colours (see print2.png)
- The "Write BMP File VI" creates a huge BMP file of about 86MB with the distorted image
- The "Draw Unflattened Pixmap VI" which I use for test purposes to display the merged picture in Labview also generates a distorted image; however, instead it inverts the colours (white dots over black background) and adds some blue traces on the scale.
Any suggestions about how I could make this work properly?
Cheers
08-13-2015 02:05 AM
Maybe - I'm not sure - but you try to play with inputs "Colors" and "Mask" for functions Flatten Pixmap VI, Unflatten Pixmap VI, in order to remove distortion of colors...
Regarding Unflatten Pixmap VI: in the help file it is written, that "... If you wire 32-bit image data to this VI, the VI returns a 24-bit pixmap. " - that's why you have a 4-bit or 1-bit output empty...
08-13-2015 02:19 AM
Hi hun,
The "Write BMP File VI" creates a huge BMP file of about 86MB with the distorted image
What's the (pixel) size of your image? What's the color depth?
And last but not least: Why do you use BMP at all? Why not PNG?
08-13-2015 02:31 AM
I would agree with the recommendation to use PNG, but even if you do stick with BMP (which will be large anyway, because it has no compression), you just need to save it as a 1 bit image. Either do this at the source where you create the images, or you can do this in your print3 code, by having the array be a boolean array and converting the data to booleans (you will have to look at the values to determine the logic) and wiring that into the 1 bit input of the flatten VI.
08-13-2015 04:45 AM
kosist90,
How can I set a picture to 4-bit or 1-bit? All I do is create a blank 2D picture and draw black dots onto it (see print4.png). I haven't found any way of setting a pixel bitrate.
In Flatten Pixmap help, it says "If you wire data to 24-bit pixmap, LabVIEW ignores this input."
GerdW, tst
as I said I didn't set any color depth. How can I do that? I will write PNG instead of BMP though if you say it takes up less space.
08-13-2015 04:57 AM
@thehun wrote:
How can I set a picture to 4-bit or 1-bit?
The picture to pixmap VI which you call in print3 has a depth input, which determines which output of the VI will have the data. If it's 1, it will be the boolean array output. And yes, PNG should be smaller (definitely don't use JPEG, because that's lossy and not suitable for something like this).
08-13-2015 06:24 AM
@tst wrote:
@thehun wrote:
How can I set a picture to 4-bit or 1-bit?
The picture to pixmap VI which you call in print3 has a depth input, which determines which output of the VI will have the data. If it's 1, it will be the boolean array output. And yes, PNG should be smaller (definitely don't use JPEG, because that's lossy and not suitable for something like this).
Thanks, for some reason I never realized about this input and it did the trick... partially. The image looks pretty good (at the output of Draw Unflattened Pixmap VI) now but I'm getting an error when trying to save it as PNG:
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
Complete call chain:
Check Color Table Size.vi
Write PNG File.vi
WBTB Main_12082015.vi
When I save it as BMP it doesn't throw any error and it "only" takes up 6.8 MB but the image is completely black.
08-13-2015 06:33 AM
Answering myself... instead of doing thing as I was I unflattened again the picture at the output of the Draw Unflattened Pixmap VI and fed this into the Write PNG File VI. It's working perfectly and only takes up 320kB ![]()