[vtkusers] Problems with TIFF Writer while writing a volume
Cory Quammen
cquammen at cs.unc.edu
Tue Jul 31 23:23:01 EDT 2007
It's unclear what you mean by "write out the filter result as a
volume". If you mean write it out as a sequence of 50 8-bit tiff
images, then you need to use:
volumeWriter->SetFilePrefix("test_volume");
volumeWriter->SetFilePattern("%s%d.tif");
volumeWriter->SetFileDimensionality(2);
volumeWriter->Write();
Unfortunately, this is broken last I checked, and you're program will
likely crash. However, I submitted a bug with a fix back in October
2006 (http://www.vtk.org/Bug/bug.php?op=show&bugid=3917&pos=1) which
contains a working version of vtkTIFFWriter.cxx that makes the above
code work. You could grab that if you'd like and recompile. My fix
merely duplicates what vtkPNGWriter and vtkJPGWriter do when saving a
volume as a sequence of images.
If, on the other hand, you mean that you want a single file containing
all of the images, then it seems to me that vtkTIFFWriter is doing the
correct thing by concatenating the images in the y-direction. It is
just writing pixels from each image into the file row-by-row: when it
finishes the first image, it starts back at row 0 in the second image
and continues writing, thus the concatenation along the y-axis.
Perhaps it's that your TIFF viewing program doesn't understand TIFF
volumes?
One other note: aren't the zimn and zmax arguments to
vtkTIFFReader::SetDataExtent() zero-based? That is, shouldn't your
code be
imageReader->SetDataExtent(0,299,0,299,0,49)
I wouldn't be surprised if setting the last to arguments to 1 and 50,
as you have in your example, causes problems.
-Cory
--
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
> Message: 10
> Date: Tue, 31 Jul 2007 14:22:01 +0200
> From: "Enkelejda Tafaj" <lejda at gmx.de>
> Subject: [vtkusers] Problems with TIFF Writer while writing a volume
> To: vtkusers at vtk.org
> Message-ID: <20070731122201.118240 at gmx.net>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I'm using the vtkTIFFWriter to convert a 8-bit tiff image sequence into a volume. In my application I go through following steps:
>
> 1. Using the vtkTiffReader I first read a sequence of 50 8-bit tiff images. Thereby I'm setting the file dimensionality to 3.
>
> 2. In a second step I'm using a Gaussian filter to smooth the image stack.
>
> 3. At the end i would like to write out the filter result as a volume. If i use the TIFFWriter like below, it writes out a concatenation of the image sequence along the y axis. I don't get a volume but one very long image.
>
> What am I doing wrong?
>
> Thanks for your help!
>
> Enkelejda
>
>
>
> // 1. reading image sequence
> vtkTIFFReader *imageReader = vtkTIFFReader::New();
> imageReader->SetFilePrefix("image_");
> imageReader->SetFilePattern("%s%.d.tif");
> imageReader->SetFileDimensionality(3);
> imageReader->SetDataExtent(0,299,0,299,1,50);
> imageReader->SetDataSpacing(1,1,1);
> imageReader->SetDataByteOrderToLittleEndian();
> imageReader->UpdateWholeExtent();
>
> // 2. Some Filtering-...
> vtkImageMedian3D *filter = vtkImageMedian3D::New();
> filter->SetKernelSize(3,3,3);
> filter->SetInputConnection(imageReader->GetOutputPort());
> filter->UpdateWholeExtent();
>
> // 3. write out the result as a volume
> vtkTIFFWriter *volumeWriter = vtkTIFFWriter::New();
> volumeWriter->SetInputConnection(filter->GetOutputPort());
> volumeWriter->SetFileDimensionality(3);
> volumeWriter->SetFileName("test_volume.tif");
> volumeWriter->Write();
>
> --
> GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
> Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
More information about the vtkusers
mailing list