Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Save a 8 bit uncompressed greyscale AVI

I'm able to capture picture from IMAQ device, but I only care about the brightness of each pixel, so I set camera to monochrome mode, which returns a U8 grey scale data.

 

I need to save a lot of frame for later process, but I noticed even if I give a U8 data image reference to Write to AVI sub-vi, the avi file will always 3 times larger then it should be, which suggesting LabVIEW has saved a 24bit uncompressed AVI.

 

But all I need is a uncompressed 8 bit AVI file. Any idea?

0 Kudos
Message 1 of 8
(4,585 Views)
Can you post your code?
-Check what image type you are using for IMAQ Create.
Thanks
uday
0 Kudos
Message 2 of 8
(4,558 Views)


avi issue.png

 
 

Let's do some calculation:

1024*1024*100*u8=100MByte
and the result would be 314,579,456 bytes, that's 300MByte.
 
What's more, any AVI file size cannot exceed 2GB,(maybe a limitation from 32bit LabVIEW), if I can save U8 grayscale AVI, I can save about 1000 frames of 1024*1024 image, now I can only save about 300 frames!
0 Kudos
Message 3 of 8
(4,548 Views)
Aha, Somewhere i read about this 2GB limit with AVI.
-Can you change the Y800 Uncompressed Gray scale Codec type and see if it is still same?
-What are the codecs installed in your PC? Try it with different Codecs and see if you are still not able to achieve it.
Thanks
uday
0 Kudos
Message 4 of 8
(4,525 Views)

Thanks, It works!

 

One more question:  are there any way to install NI Vision codec on a 3rd computer? My coworker need to open it with Matlab, and they don't seems be able to open it. Also, windows media player is not able to play the avi file, says the format is not correct.

0 Kudos
Message 5 of 8
(4,491 Views)

Here it is, a few years later, and this stills seems to be a problem with no solution. Any updates? 🙂

 

Note: You can play the format in VideoLan (VLC) and transcode, but I would prefer for, say, Matlab to be able to read it directly and import frames.

 

Thank you!

0 Kudos
Message 6 of 8
(1,579 Views)

Solutions I would suggest:

 

Write your own AVI Write routine.  I found some C code (search for "avi file write Wischik") that would work pretty well.  It looks fairly simple if you eliminate the audio and compression routines.  Creating a LabVIEW dll that calls these could be done and debugged in a day or so.  I'm not sure how you would convert a LabVIEW U8 image to the format required, since the example only demonstrates loading images from the drive.

 

Another option would be to use a different file format.  I have a system where I use Image to JPEG String to compress each of the images, then concatenate the strings into a single file.  Fairly easy to read and convert back into an image.  If you don't want compression, you could easily convert the U8 image array into a string - two U32 for the dimensions plus the data.  I did find that storing everything in a single file significantly decreases load and save times.  The only disadvantage is the inability to read the file using any standard video players.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 8
(1,569 Views)

I was interested in the subject a few years ago. My understanding is that JPEG compression and Video compression are different. 

JPEG is a lossy compression. If you want lossless compresion it is part of the PNG standard. 

AVI is doing compression that is based on recording the changes of the next image from the previous image. Usually, the changes are minimal. So, the compresion is part of the standard.

I think it is lossless, but I am not sure. You need to read the standard. 

Level of compression depending on the changes between the adjacent images. So, some videos will compress more than others. 

Amit Shachaf
0 Kudos
Message 8 of 8
(1,563 Views)