[vtkusers] Problems with TIFF Writer while writing a volume

Enkelejda Tafaj lejda at gmx.de
Thu Aug 2 08:06:38 EDT 2007


Hi Cory,

thank you for your suggestions.

What I'm trying to do is to write a sequence of 50 images in a single file containing all of them (3D File). When I use the TIFF Writer it concatenates all images along the y axis. 

But when I try to read this file using the TIFFReader and setting FileDimensionality=3,  the file will not be interpreted as a volume but as a "very long" 2D image file. 

On this file I was applying the marching cubes algorithm (see below) and got the error message: 
"vtkMarchingCubes (0x80598c0): Cannot contour data of dimension != 3"

Do I need to add some more parameters to the Tiff Reader? 

  //writes the image sequence to a single "3d" file
  vtkTIFFWriter *writer = vtkTIFFWriter::New();
  writer->SetInputConnection(filter->GetOutputPort());
  resultWriter->SetFileDimensionality(3);
  resultWriter->SetFileName("test/test.tif");
  resultWriter->Write();

  .........

  //read the 3D file from another application 
  vtkTIFFReader *read = vtkTIFFReader::New();
  read->SetFileDimensionality(3);
  read->SetFileName("test/test.tif");
  read->SetDataSpacing(1,1,1);
  read->SetDataByteOrderToLittleEndian();

  //Marching Cubes 
  vtkMarchingCubes *marchingCubes = vtkMarchingCubes::New();
  marchingCubes->SetInputConnection(read->GetOutputPort());
  marchingCubes->SetValue(0,111);
  marchingCubes->ComputeGradientsOn();
  marchingCubes->ComputeScalarsOff();
  marchingCubes->Update();

Thank you.
Enkelejda

-----------------------------------------

> 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
> 

-- 



Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger



More information about the vtkusers mailing list