LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Imaq: how to decode PNG

Hello,

 

I'm using the Imaq write to string VI to convert 16bit images to PNG binary data at fast frame rates (up to 200).

I found out that even LabVIEW 2009 still doesn't provide a function to convert that data back to an imaq image and I'm really unhappy about this.

 

Does someone know a way to convert PNG binary data to an IMAQ image?

 

Please don't suggest to use flatten to string instead, because the image-data gets sent via tcp to also non-Labview-applications and they can't decode the flattened LabVIEW-string.

 

Thanks in advance for any idea.

 

And please LabVIEW-Engineers, if you read this, do something that this function will be provided in future LabVIEW-Versions. If it is possible to read a png-file and decode it (using the read from file vi), it can not be that hard to decode from an binary array (string).     

 

By the way, I also would like to receive PNG data via tcp and convert it to 16bit imaq images for further processing, but without a StringToImage VI I can't. 

 

Regards,

Thomas

0 Kudos
Message 1 of 24
(6,744 Views)

 

 

Hi,

 

please see the discussion below.

 

http://forums.ni.com/ni/board/message?board.id=200&message.id=18139&requireLogin=False

 

Regards

Rüdiger 

Message 2 of 24
(6,712 Views)

Without looking at your code I can only speculate at a solution. If I understand correctly here is what I came up with: 

You can read the .PNG file and paste it over the IMAQ memory location.

Message 3 of 24
(6,709 Views)

Hi Kris,

 

thank you for your answer.

 

That's not really what I'm looking for.

I'm looking for the opposite of the IMAQ Write String.vi

 

It's quite simple:

 

Temp.png

That string get's transferred via TCP to a c++ client-application I developed (using Qt). That's why I have to use IMAQ Write String and not IMAQ Flaten Image To String. I also developed a LabVIEW-Client, but this one is currently not able to decode it back to an image. And I think this should be possible somehow.

 

So, I'm looking for a fast (no temporary file please) method that decodes the PNG-FileStrings. 

 

Thanks in advance for your help.

 

Regards,

Thomas

0 Kudos
Message 4 of 24
(6,693 Views)

This thread may be of interest: Transfer Images over the Network - though it discusses IMAQ Flatten Image To String which will work for your LabVIEW client but not the C++ client.

 

In this thread, there is a library for doing what you want with JPEG files (also here), so that would depend whether your application can cope with lossy images.  There are also comments which seem to indicate a reluctance from NI to provide a corresponding IMAQ Read String (also here).  Perhaps it's an idea you want to add to the LabVIEW Idea Exchange.

 

Is another alternative to extract the image to an array, and transfer that?  That should be readable from both clients.

Message 5 of 24
(6,673 Views)

found this on LAVA.  Apparently, you are not alone.

 

http://lavag.org/topic/10472-custom-data-in-png-files/

 

May be other references as well.  Apparently there is a dll floating around out there that might do some of the trick.

 

Hummer1

Message 6 of 24
(6,664 Views)
I have a DLL here to read and write PNG pictures but it does not yet work with IMAQ images. If I only had the time to program that Smiley Wink
Rolf Kalbermatter
My Blog
Message 7 of 24
(6,647 Views)

Hi,

 

thanks for all your replies.

 

The requirement says lossless compression using png, so the only choice is IMAQ Write PNG String. My LabVIEW server application that sends those png-Strings to clients is also supposed to be able to receive PNG's via tcp and process them. This is also a customer requirement, that I currently can not fulfill without an IMAQ Read PNG String VI.

 

This looks very poor and it's hard to explain to the customer. :smileyindifferent:

 

All your suggestions and links are interesting and I feel happy not to be alone, but they don't provide a solution for my problem. 

 

Any further idea?

 

Thanks,

Thomas

0 Kudos
Message 8 of 24
(6,626 Views)

I had a look at the .NET routines for decoding PNG files and put this VI together (LabVIEW 8.6).  It seems to work for the PNG files I've tried it on.  Requires Windows and .NET (3.5 I think, but you could try with earlier).  I'm just learning .NET so there could be a much simpler way. Smiley Happy

 

It seems to work OK for U8, I16, U16 and RGB (U32) images - I haven't bothered coding the others, and SGL is not supported by IMAQ Write PNG String.  Errors are generated for other than U8 images, but it all still seems to work ok, so I've ignored the error.

 

Cheers ~ Greg

 

Message Edited by GregS on 11-04-2009 12:10 PM
Message Edited by GregS on 11-04-2009 12:14 PM
Message 9 of 24
(6,614 Views)

Hello Greg,

 

thanks a lot for the posted VI's. A very interesting and promising approach.

 

Unfortunately the .NET Method copy pixels doesn't work with 16bit images (at least I didn't get it working). Only if I use an 8bit image it works as expected but very slow (on my PC conversion takes 400ms). Please check out the attached test VI's. The also attached image 4ksnake.png is a 16bit image and the test VI's load it as 16 or 8 bit image (I found it somewhere on the internet and I hope it's creator doesn't get mad at me for posting it here). 

 

Please let me know if the 16bit conversion works on your System as expected, than I have to find out what I mixed up.

 

Thanks for your support. You have great ideas!!! Please keep on posting them.

 

Greetings,

Thomas


 

 

 

0 Kudos
Message 10 of 24
(6,582 Views)