[Insight-users] Write float / double images
Olivier Tournaire
olitour at gmail.com
Tue Jan 15 10:00:36 EST 2008
Hi,
Here is the code I use (just for testing purposes on how to write an image
with float values) :
void main( int argc , char** argv )
{
typedef itk::Image< float, 2 > FloatImageType;
FloatImageType::Pointer flimzge = FloatImageType::New();
FloatImageType::IndexType start;
start[0] = 0; // first index on X
start[1] = 0; // first index on Y
FloatImageType::SizeType size;
size[0] = 200; // size along X
size[1] = 200; // size along Y
FloatImageType::RegionType region;
region.SetSize( size );
region.SetIndex( start );
flimzge->SetRegions( region );
flimzge->Allocate();
FloatImageType::IndexType pixelIndex;
try
{
//filtre->Update();
for (int i=0;i<200;i++)
{
pixelIndex[0] = i; // x position
for (int j=0;j<200;j++)
{
pixelIndex[1] = j; // y position
flimzge->SetPixel( pixelIndex, (i-j)*4.7 );
}
}
typedef itk::ImageFileWriter< FloatImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(flimzge);
writer->SetFileName( "C:\\test.tif" );
writer->Update();
}
catch( itk::ExceptionObject e)
{
std::cout << e << std::endl;
}
}
The exception is :
itk::ExceptionObject (00F7FEF8)
Location: "void __thiscall itk::TIFFImageIO::InternalWrite(const void *)"
File: .\itkTIFFImageIO.cxx
Line: 1659
Description: itk::ERROR: TIFFImageIO(01443978): TIFF supports
unsigned/signed char and unsigned/signed short
So, the ITK TIFF writer does not support float pixels. Is there a way to
write images with float pixels in TIFF format ?
Regards,
Olivier
2008/1/15, gabri <tartuz at gmail.com>:
>
> Hi,
> give more information for asking an help like cut 'n paste here the
> exception you read and the code lines you are using.
>
> Best reguards
>
> gabriele
>
> Olivier Tournaire ha scritto:
> > Hi all,
> >
> > I am new to ITK and I tried to write a simple image of float, but it
> > throws an exception. Is there a way to write such images ? If not,
> > could you give me a way on how to add this functionnality ?
> >
> > Regards
> >
> > Olivier
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080115/f5de4c59/attachment.html
More information about the Insight-users
mailing list