LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not read tif image correctly with IMAQ Vision

Hi everybody,

 

I have a problem in reading and displaying a tif file with IMAQ Vision.

1. The displayed image on Labview is just a part of the original image.

2. In addition, the aspect of the image is different from the original one.

 

I attached several files to show the problem and the tif image.

The software successfully displayed the tif image is Fit2D, which is free an image processing software.

The tif image has size of 981x1043 pixels, 149x149 dpi, 32 bit depth.

If you want to try to read my tif image, please remove the extension .png.

0 Kudos
Message 1 of 4
(3,810 Views)

The TIFF file format is notorious for its many variants of formats. TIFF is only a container format, how the image data is stored inside the file is for a large part left to the implementor. (TIFF stands for Tagged Image File Format), meaning it describes a generic format to store so called tags. A Tag consists of an identifier, a size, and the actual data following in a binary stream. A typical TIFF file consists of several such tags, such as the witdh, height, bits per sample, compression type etc. There are some globally accepted tag identifiers but there isn't an official standard in what tag identifiers an implementor should use for what and how. The format is so flexible that anyone can basically create his own variant of image format if he wants and quite a few make use of that. The image you have attached has several non-standard features that make it hard to read in the file, despite that it is a fully uncompressed format.

 

GIMP isn't even able to show the image at all, as it stumbles over several non standard elements. The Windows image viewer only shows a black image as it seems only to be able to determine the image size but nothing more. With that background it is already quite an accomplishment that IMAQ Vsion is actually able to show something that resembles the actual image.

 

What can you do?

 

Use some conversion software that knows this particular format to convert the image into a more standard image format. As explained above, TIFF has some more frequently used internal image formats. Yours definitely isn't one of them.

 

Or since the image is actually uncompressed it should be not that difficult to read it in yourself. There are several LabVIEW libraries out there that allow you to read in the TIFF tags. From there you can determine the various parameters such as image width and height, line length, byte order, and pixel size as well as the offselt into the file to use to read the actual image data. The only difficult part is to determine the actual pixel format. This doesn't seem to be described with any publically known tag, but with some private tags and so you will have to experiment. TheBitsPerSample tag claims the image to use 32 Bit samples. Now you have to find out if the image is either RGB, BGR, GBR, etc. and if the filler (or alpha channel) is the first or last byte in the 32 bit value.

Rolf Kalbermatter
My Blog
Message 2 of 4
(3,789 Views)

Thank you for the reply. I really appreciate your help.


 

Or since the image is actually uncompressed it should be not that difficult to read it in yourself. There are several LabVIEW libraries out there that allow you to read in the TIFF tags. From there you can determine the various parameters such as image width and height, line length, byte order, and pixel size as well as the offselt into the file to use to read the actual image data. The only difficult part is to determine the actual pixel format. This doesn't seem to be described with any publically known tag, but with some private tags and so you will have to experiment. TheBitsPerSample tag claims the image to use 32 Bit samples. Now you have to find out if the image is either RGB, BGR, GBR, etc. and if the filler (or alpha channel) is the first or last byte in the 32 bit value.


I know my tiff image is stored in grayscale and 32bits. I used LUTs to make grayscale images become colorful.

 

Following your advice, I tried to read the tag of the tiff file by using "IMAQ ReadFile".
The result is
Image Type U8
File Type TIFF
File Data Type 1bit
Hight 1043
Width 981

 

I also used a free image analysis software (ImageJ) to read the tiff tag.

BitsPerSample 32

Hight 1043

Width 981

offset to first image: 4096

and a lot of other information
Please find the detail of the tags in the attached text file.

 

Is that possible to get all tags that you mentioned with LabVIEW? I could not find any other LabVIEW libraries to read tags.

0 Kudos
Message 3 of 4
(3,757 Views)

32 bit grayscale images?? Talk about not standard format! Smiley LOL

 

Well I'm not sure what you have done to look for TIFF libraries to use in LabVIEW, but I suppose you haven't used Google. The first link in Google gives me already this page, which in the beginning looks like having lost all attachments but if you look further down you will find a post where someone attached a new version. It is a LabVIEW native implementation and doesn't support compression but that shouldn't be a problem for your image.

 

Another post on this site shows an implementation using the external libtiff DLL to import images into LabVIEW.

 

For uncompressed files that are unlikely to change in format in the future, I think the first library is probably easier to use since it is all in LabVIEW. The second is a lot more complex and while supporting many more TIFF formats, it's giving you less insight in what way your image is constructed, as it delegates most of the real work to the external DLL. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(3,700 Views)