LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ readfile

I want to use IMAQ readfile to read TIF files.  TIF files can be of various formats / bit depths.  How can I properly specify the image type in IMAQ create if I do not know beforehand what the TIF file format / bit depth is?

Thanks,

Don
0 Kudos
Message 1 of 9
(4,370 Views)
Hi Don,
 
    The IMAQ Create.vi does not require that you input an image type.  I believe it is able to take in an image without that specification.  Is it giving you any errors?  Have you tried acquiring an image without the image type specified?  Let me know what troubles you are having, and I'll see what I can do.  Thank you!
 
-Allison S.
Applications Engineering
-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 2 of 9
(4,368 Views)
No, if you do not specify the correct image type using IMAQ Create, the image will not appear properly. IMAQ ReadFile will read the image in as an 8-bit image if you do not specify an image type (i.e. the default is the U8 image type).  If the tif image is in fact a 16-bit tif, you will then see an improper image in the Vision container.  Here, see for yourself with the attached 16-bit TIF.  The problem is, I need to read in U8, I16, and RGB (U32) TIFs, and I do not necessarily know before I open them which type they are.

The IMAQGetImageInfo fx will not help - because the image space must be set up before you can call this.  Therefore, if you do not specify image type, and the image is read in as 8-bit by default, the IMAQGetImageInfo fx will return a value of 8-bit for image type, even if the actual image you are trying to open is other than 8-bit.

There needs to be a way to find the image type prior to creating the image space - and it seems like a catch 22 in IMAQ Vision to be able to do this.  Unless I am missing something obvious.

Don

ps. your attachment engine will not accept .tif file extension, so I renamed it to .gif.  You can rename it to .tif.
0 Kudos
Message 3 of 9
(4,360 Views)

Don,

    I apologize for the mistake.  I still may be misunderstanding you.  From what I can tell, you want to be able to set your image type programmatically?  You can't change it after the IMAQ create because the IMAQ create actually creates a block of memory that the image will fit in.  But, if you look at the example program (Help >> Find Examples...) called HL Grab.vi I think this may help.  Notice that there is a property node that reads the image type from the incoming camera initialization, and sets the IMAQ Create.vi's image type to that.  If you change the camera in this program, or if your camera image type changes, it will change with it.  Is that at all what you were looking for?  If I misunderstood please let me know, thank you!

-Allison S.

Applications Engineering

-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 4 of 9
(4,346 Views)

Yes, I need to be able to do it programmatically. However, I am using IMAQ readfile to read in an already-stored TIF image from disk. I'm not acquiring from a camera. Let's say for now it could be 8- or 16-bit, but I do not know beforehand.  So within a programmatic context, I need some utility to look at the file and see what the bit depth is, then I can programmatically set the image type on the IMAQ Create based on the discovered bit depth.

 

If you look at the graphic file functions, say for example 'read BMP file'.  If you look, there is an output cluster of image information including the bit depth and colors.  This allows you to choose the correct way to 'unflatten the pixmap' (unflatten pixmap.vi) which has outputs for 1, 4, 8, and 24-bit pixmap).  This is the equivalent of what I need in IMAQ Vision.  Unfortunately, straight LabVIEW does not have the facilities to read in .TIF files (unless you know something I don't).  If it did, then I would not need this particular IMAQ capability.

 

Sincerely,

 

Don

0 Kudos
Message 5 of 9
(4,341 Views)
Don,
 
    I think I may have found something that will help you, I feel silly for forgetting it up to now.  There is a function in Vision & Motion >> Vision Utilities >> Image Management called IMAQ GetImageInfo.vi  I believe this will return all of the information you need to set up your image acquisition.  Let me know if that helps!
 
-Allison S.
Applications Engineering
-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 6 of 9
(4,328 Views)

Hi Allison:

 

See message#3 in this thread.  The IMAQGetImageInfo fx will not help - because the image space must be set up before you can call this.  Therefore, if you do not specify image type, and the image is read in as 8-bit by default, the IMAQGetImageInfo fx will return a value of 8-bit for image type, even if the actual image you are trying to open is other than 8-bit.

There needs to be a way to find the image type prior to creating the image space.  In other words, there needs to be either a utility within IMAQ Vision or a 3rd party tool that can be used within LabVIEW to get the image information so as to be able to programmatically determine image information.

Sincerely,

 

Don

0 Kudos
Message 7 of 9
(4,303 Views)

Hi Don,

I tried running this VI and it was able to recognize the two different images.  See if this works for you.  I was able to recognize your image from your third post as a 16 bit image. 

If this doesn’t work let me know what version of Vision you are using.

Have a great day,

Gavin   

0 Kudos
Message 8 of 9
(4,283 Views)

Right in front of us the whole time!  I should have seen this. Instead, I was fixated on GetImageInfo instead of GetFileInfo.  Thanks a lot for pointing this out!

Sincerely,

Don

0 Kudos
Message 9 of 9
(4,273 Views)