2007.10.30 02:27 "[Tiff] Simple code to write Tiff images from Raw data", by Richard Nolde
If you have your data in memory as an series of 2 dimensional arrays, one array for each 2D image, you can map them to a series of individual pages in a multipage TIFF file. The size, type, and range of each element and the ordering of the data in your array will determine your TIFF parameters, eg grayscale, palette, RGB, additional channels, etc. First, you should download and read the TIFF spec to get an idea which tags you will need to setup to properly describe your data and what the options are for each tag. After that, you might look at the source code for the tiffcrop utility, which has code to write out buffers of data from memory to TIFF files. There are also a few very simplistic sample programs available on the IBM developerworks site that illustrate the basic concepts. I don't have the URL handy but you can probably find it with Google. These samples are for bilevel or grayscale data, but you should be able to use them to move on to color images.
For simulation data, you may have to scale your values to a range that
is conducive to viewing and/or remove outliers if your intent is to
analyze the data visually rather than statistically. If you data are
produced as floating point data, you may want to convert them to
integers so that a wider variety of available TIFF readers can handle
them. You will also have to decide whether to write you image data as
RGB,RGB,RGB...... (PLANAR_CONFIG_CONTIGUOUS) or RRR....,GGG.....,BBB....
I am new to libTiff. I am looking for a way to create TIF image files (or any other graphics format) from "raw" simulation data. (basically it is 3-d data projected on a 2-D plane. What it comes down to is that I have a bunch of "pixels", a discrete coordinate (that translates to a pixel in an image) and RGB values. (I basically just want to create an image by doing something like "this pixel has these RGB values" and "stick them in an image file.
It probably can be done with libTiff, right? are there any examples that I can take a look at?