Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write binary image on ImageViewer to TIFF file

I am using NI Vision Dev module 2012 SP1 with Visual Basic 2010 Express with good results so far. I can display  8 bit images using the ImageViewer and have no problem saving these displayed greyscale images as individual tiff files using following code :

 

'- Save raw image to tiff file

ImageFilename = "C:\temp\RawImage " & Format$(FramesAcquired, "0000") & ".Tif"

myTiffOptions.CompressionType = 0

myTiffOptions.PhotometricMode = PhotometricMode.BlackIsZero

myTiffOptions.RowsPerStrip = 1

.Image.WriteTiffFile(ImageFilename, myTiffOptions)

 

However, when I threshold and further process the image, the resultant saved TIFF file using the above code is the correct size but displays only black pixels,  whereas the image displayed on the ImageViewer is correct and displays the processed binary image as expected.

 

I'm guessing that I need to use instead the expanded command that includes the palette specification. I therefore tried the following code:

 

'- Save processed image to tiff file

ImageFilename = "C:\temp\ProcessedImage " & Format$(FramesAcquired, "0000") & ".Tif"

myTiffOptions.CompressionType = 0

myTiffOptions.PhotometricMode = PhotometricMode.BlackIsZero

myTiffOptions.RowsPerStrip = 1

Dim myPalette AsNew NationalInstruments.Vision.WindowsForms.Palette

myPalette.Type = WindowsForms.PaletteType.Binary

.Image.WriteTiffFile(ImageFilename, myTiffOptions, myPalette)

 

However, this produces the same all black Tiff file

 

Hoping someone can help me save this binary image to Tiff file?

 

 

 

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

Hi philgo,

 

Are you using a third party program to open up the TIFF file after it has been saved? If so, what program?

0 Kudos
Message 2 of 8
(6,364 Views)

I am using IrfanView, version 4.35  ( see website www.irfanview.com) .

 

The properties of the two Tiff files are shown in the attached file. This viewer has worked we other situations. Would you suggest using a different means to view file?

0 Kudos
Message 3 of 8
(6,359 Views)

It might be useful to try another program and see if this is happening just in IrfanView or across the board. It could be good to open the file in something like Photoshop and see if the image is truly all black or if the contrast is just extremely low.

 

 

0 Kudos
Message 4 of 8
(6,344 Views)

besides IrfanView, there are a lot of software support tiff formats and being able to read and open tiff files. check the .net imaging sdk here. it is simple and powerful.

0 Kudos
Message 5 of 8
(6,212 Views)

Hi, I am learning about how to build Tiff viewers with the help of some manual tools which can be customized by users according to our own favors to help view and process tiff files these days. Do you have any ideas about it? Or any good suggestion? Thanks in advance.



Best regards,
Arron

0 Kudos
Message 6 of 8
(5,996 Views)

Hi Aaron, 

 

What is is about TIFF files you have questions about specifically? The format is fairly well specified in the wikipedia article. It also might be more beneficial for you to post specific questions in a new thread so people will see it. 

 

-N

National Instruments
Staff Certification Engineer
0 Kudos
Message 7 of 8
(5,987 Views)

tiff file has its own specification when you are display file. by the way i really want to know which tiff software are you using to view and read tiff file.

go through wike for more information.

0 Kudos
Message 8 of 8
(5,834 Views)