[vtkusers] ImageReader2 Issue

Bill Lorensen bill.lorensen at gmail.com
Fri May 14 11:34:25 EDT 2010


ImageReader2 has no notion of file formats. It assumes the data is raw
pixels with a possibly fixed header. It is also used as a base class
for most of the image readers.

You should use the vtkTIFFReader to read the file correctly (as you discovered).

On Fri, May 14, 2010 at 9:21 AM, Doug Hoppes <dhoppes at mbfbioscience.com> wrote:
> Hi All,
>
>
>
>                 I’ve just started playing with the VTK libraries and seem to
> have run into a small issue about reading my tif file.
>
>
>
>                 If I use the code to read my tif file:
>
> ----------------------------------
>
>       vtkSmartPointer<vtkImageReader2> pReader =
> vtkSmartPointer<vtkImageReader2>::New();
>
>       pReader->SetFilePrefix("TestImages\\input");
>
>       pReader->SetFilePattern("%s%03d.tif");
>
>       pReader->SetDataScalarTypeToUnsignedChar();
>
>       pReader->SetNumberOfScalarComponents(1);
>
>       pReader->SetDataOrigin(0,0,0);
>
>       pReader->SetDataSpacing(1,1,1);
>
>       pReader->SetFileLowerLeft(0);
>
>       pReader->SetDataExtent(0, 274, 0, 246, 0, 10);
>
> ---------------------
>
>       The image file is not correct.  It’s kind of weird.  It looks like the
> image is shifted to the right and a wrap-around is done (where the right
> one-quarter side of the image is on the left.
>
>
>
>       If I use the code to read my tif file:
>
> ----------------------------------
>
>       vtkSmartPointer<vtkImageAppend> pImageList =
> vtkSmartPointer<vtkImageAppend>::New();
>
>       pImageList->SetAppendAxis(2);
>
>       for (int i=0; i<10; i++)
>
>       {
>
>             vtkSmartPointer<vtkTIFFReader> pReader =
> vtkSmartPointer<vtkTIFFReader>::New();
>
>             QString file = "TestImages\\GreenCells\\Images_2_0001_00" +
> QString::number(i) + ".tif";
>
>             pReader->SetFileName(file.toStdString().c_str());
>
>             pImageList->AddInput(pReader->GetOutput());
>
>       }
>
> ---------------------
>
>       The image looks beautiful and is correct.
>
>
>
>       Is there something that I’m missing on using the ImageReader2?  I have
> a sample image file if anyone wants to look at it.
>
>
>
> Dougie
>
>
>
>
>
>
>
> ---------------------------------------------------
>
> Doug Hoppes doug at mbfbioscience.com
>
> Senior Software Engineer
>
> MBF Bioscience (Microbrightfield, Inc.)
>
> +1.802.288.9290 ext:119
>
> www.mbfbioscience.com
>
> ---------------------------------------------------
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list