Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a grayscale avi?

I am trying to threshold images from an avi file that I recorded with my Basler A622f camera.  Because the camera is grayscale (and set to U8), I assumed that the avi file was recorded in U8 image format and would therefore work with the threshold sub-vi.  However, in troubleshooting my VI, I figured out that the image type in the avi file is RGB (U32), and I can't figure out either how to record videos in U8 image type or to convert my U32 image videos to U8. The videos look like grayscale, not color. I'm using DV Video Encoder compression and I changed my record VI to input U8 as the image type when I create IMAQ, but the avi still comes out as U32.  There are a lot of inputs when you create an avi file, but I don't think you can input the image type. Or am I missing something? I'm also concerned that if my videos are saving as color, they're taking up a lot more space than they should. Any ideas?
Thanks!
0 Kudos
Message 1 of 12
(5,629 Views)
Hi Kelly,
 
You are correct, when the avi file is saved to disk, it is saved as an RGB image.  As of right now, I'm not sure if this is due to the format or the way that our software creates the avi file, but I can confirm the behavior.
 
How large are the avi files you are working with?  Hopefully they are small enough that this is not a great inconvenience.
 
Hope this helps,
 
Robert
0 Kudos
Message 2 of 12
(5,610 Views)

Thanks Robert. I figured out that I can get the thresholding to work by reading each frame and using the IMAQ cast image sub-VI to convert the individual images to grayscale.  However, I'm using the camera to measure changes in intensity over time.  I had a problem with my previous set-up (using a sony camcorder) because I imported the images into photoshop and converted color images to grayscale, but the conversion was treating each picture differently and constructing an evenly distributed histogram for all of them, so when I thresholded the images, I had the same number of pixels in each image even though the relative intensity among them was clearly different. Is the cast image sub-VI doing that or is it giving me a real measure of intensity? Do I need to convert the image from RGB to HSI first? It doesn't show any hue or saturation, just intensity, so does that mean the cast image sub-VI is giving me unaltered intensity???

Is there any way to change the create avi sub-VI to create a U8 video?  That would simplify this problem a lot.

Thanks,

Kelly

0 Kudos
Message 3 of 12
(5,606 Views)
What version of Vision are you using?  I believe the newest version does have support for writing U8 AVIs (although I'm not sure if it will work with compression).

Greg Stoll
IMAQ R&D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 4 of 12
(5,594 Views)

I'm using LabView and Vision 7.1 student edition, which I got about 6 months ago. 

Thanks,

Kelly

0 Kudos
Message 5 of 12
(5,588 Views)
The ability to write U8 AVIs is available in Vision 7.1.1, which is a free upgrade from Vision 7.1.  Contact your sales representative to have a Vision 7.1.1 CD shipped to you for free.

Let me know how it turns out!

Greg Stoll
IMAQ R&D
National Instruments
Greg Stoll
LabVIEW R&D
Message 6 of 12
(5,579 Views)

Greg,

Apparently I can't get the free update for the student edition... any other ideas?

Thanks,

Kelly

0 Kudos
Message 7 of 12
(5,575 Views)

Greg,

I tried saving the Create AVI sub-VI under a different name and adding an "Image type" input.  I think I did it right because I copied it from the IMAQ Create sub-VI which has an Image Type input.  It doesn't give me any errors and lets me record video, but my avis are still color and I'm not sure why.  It seems like it's just ignoring my input and sticking with the default.  So then I was playing with different inputs in the Create AVI sub-VI (not the one I messed with, the original one) and it doesn't seem to take an input for Frames per second.  No matter what I input, when I check the avi with Get AVI Info in another program, it tells me the avi has 29 frames per second. The camera is set through Measurement and Automation Explorer to record 7.5 fps.  Any idea what's wrong here?  So I think when I go to play my video, it's reading the fps as 29 and running it back at the wrong speed, but how do I know whether the video was actually recorded at 7.5 or 29 fps? 

Thanks,

Kelly 

0 Kudos
Message 8 of 12
(5,560 Views)
Hi Kelly,
 
The setting in MAX should not affect the way the data is stored in the avi file.  If you have the number wired into the avi create, you should see that frame rate when you open the vi later.  Assuming this number matches your acquisition speed, you should see the video play back correctly.  Is this not the case?
 
Robert
0 Kudos
Message 9 of 12
(5,507 Views)

Hi Robert,

No, when I wire 7.5 fps to the Create AVI sub-VI and then check it with Get AVI info, it says it's 29 fps.  Now that I've figured that out, I can play my video back at normal speed by using a numerical constant instead of the frames per second from get AVI info, which works fine because all of my videos are taken at 7.5 fps, but I don't know why it doesn't work properly.

Kelly

0 Kudos
Message 10 of 12
(5,504 Views)