LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I write an 8bit Grayscale AVI?

Hi,

I tried to write 8bit grayscale images to an uncompressed avi by using the IMAQ Vision avi routines.
But I found that the routines are writing an 32bit uncompressed video instead an 8bit uncompressed video.
Therefore the resulting avi is four times larger than necessary.

Does anybody know how to write uncompressed 8bit grayscale avis with LabView and/or  IMAQ Vision?

Bye
Ronnn

Message 1 of 9
(4,887 Views)

Hey Ronnn,

Have you made sure that you are writing 8-bit images to the AVI? You can use the IMAQ Cast VI to make sure that your images are really of type U8.

What VI's are you using to do this? Maybe attach your code to this thread.

There are AVI Example programs that come with both the IMAQ driver software and the Vision Software. You can find these in the NI Example Finder.

Let me know if this doesn't help. Thanks.

Regards,
DJ L.

0 Kudos
Message 2 of 9
(4,859 Views)
Hi D J L,

thanks for your answer.

I have attached a small sample program.

By varying the loop count you can produce videos with different frame numbers.
It uses a standard 600x800 pixel backgrund picture from windows and converts in to an U8 image before writing it to an avi.

The framesize should be 800x600=480.000 bytes.
But with each frame the avisize increases by 1.920.812 which is 4.001 times the framesize.
The file information from VirtualDub gives me as a Decompressor: "Uncompressed RGB32".

Bye
Christian

0 Kudos
Message 3 of 9
(4,855 Views)
Hey Ronnn,
 
So I ran your program, and I too got an AVI of size of about 1,941 k. I saw that each frame is 800x600 which is equal to 480,000. But then I saw in your program you are writing 4 frames to the AVI, so therefore you are writing 4x480,000 which is equal to 1,920,000. So therefore, you are seeing the correct behavior. Since you are not compressing the AVI, you should see the AVI increase with the more images you write to it. Try changing your For Loop n value to 8 and you will see the AVI size increase to 8x480,000. Then try setting the For Loop n value to 1 (which is 1x480,000), and you will see around 480,000 bytes in size for your AVI. So when your AVI is 4 times the size of one of your frames, you are actually writing 4 frames, not one frame. Let me know if you have any questions about this. But in general, the more frames you add to your AVI, the larger your AVI will be in size, especially as Uncompressed. If N is the number of loops that you are writing one frame, then the approximate size of your AVI is going to be N times the size of your image. 
 
I hope this answers your questions. Please let me know if you need further clarification. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 4 of 9
(4,838 Views)
Hi DJ L.,

thanks for your answer.

I think my last email was not clear enough.

The program I wrote has intentionally wired a for to the N of the loop, as it should write four frames.
On my computer I get a filesize of 7747584 bytes.
By changing the 4 against other  values ranging from 1 to 5 you can write avis with a number of frames between 1 and 5.
On my computer I get  for

For Loop N Value: N=1  =>   1 frame      =>  filesize = 1986048 bytes
For Loop N Value: N=2  =>   2 frames    =>  filesize = 3906560 bytes
For Loop N Value: N=3  =>   3 frames    =>  filesize = 5827072 bytes
For Loop N Value: N=4  =>   4 frames    =>  filesize = 7747584 bytes
For Loop N Value: N=5  =>   5 frames    =>  filesize = 9668096 bytes

The difference between N=i and N=i+1 is always f =1920512 bytes.
The difference between the filesize for N=1 and f is h=65536 bytes.
Therefore I guess h = 65536 is the size of the header and f = 1920512 is the framesize of the avis on my disk.
f is about 4 times higher than my expected framesize of  800x600=480000 bytes.
Additionally VirtualDub says that the avis are "Uncompressed RGB32" avis.
I assume on my computer the avi files are consisting of  32bit images instead of 8 bit images.

As my program gives on your computer for a For Loop value of n=4 a filesize of
1,941 k instead of 7,7 k,
I think that you might have a newer version of IMAQ vision which has already fixed that problem.
MAX tells my that I have Labview 7.1 with IMAQ Vision 7.0.0 (Image Prcocessing and Machine Vision 7.0.1.187).

Can you tell me what version is running on your machine?

Thanks again

Bye
Ronnn
 

0 Kudos
Message 5 of 9
(4,818 Views)
Ronnn,
 
Sorry for taking so long to get back to you.  DJ has been out sick for a couple of days, so I thought I would reply to your posting for him.
 
You are seeing the expected behavior when writing your AVI file.  Vision 7.0 was setup to work that way.
 
In Vision 7.1 the feature you are looking for was added and works fine (as DJ found out when running your program).
 
Now (in Vision 7.1) if you write U8 Grayscale images to an AVI file, the AVI file will be composed of U8 grayscale images instead of 32 bit RGB images.
 
Lorne Hengst
Application Engineer
National Instruments
 
 
0 Kudos
Message 6 of 9
(4,798 Views)
Hi Lorne,

thanks for your help! I think I need to upgrade.
I hope
DJ L. is doing better meanwhile.

Bye
Ronnn
0 Kudos
Message 7 of 9
(4,784 Views)

Even with vision 13.0.0 I am getting the same problem. Do anyone know what might be the issue? Is there any codec that should be used when saving u8 images?

0 Kudos
Message 8 of 9
(3,999 Views)

Did you ever find a way to do 8 bit grayscale AVI's?

0 Kudos
Message 9 of 9
(3,449 Views)