Hi,<br><br>Here is the code I use (just for testing purposes on how to write an image with float values) :<br><br>void main( int argc , char** argv )<br>{<br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; float, 2 &gt; FloatImageType;<br>&nbsp;&nbsp;&nbsp; FloatImageType::Pointer flimzge = FloatImageType::New();
<br><br>&nbsp;&nbsp;&nbsp; FloatImageType::IndexType start;<br>&nbsp;&nbsp;&nbsp; start[0] = 0; // first index on X<br>&nbsp;&nbsp;&nbsp; start[1] = 0; // first index on Y<br>&nbsp;&nbsp;&nbsp; FloatImageType::SizeType size;<br>&nbsp;&nbsp;&nbsp; size[0] = 200; // size along X<br>&nbsp;&nbsp;&nbsp; size[1] = 200; // size along Y
<br><br>&nbsp;&nbsp;&nbsp; FloatImageType::RegionType region;<br>&nbsp;&nbsp;&nbsp; region.SetSize( size );<br>&nbsp;&nbsp;&nbsp; region.SetIndex( start );<br><br>&nbsp;&nbsp;&nbsp; flimzge-&gt;SetRegions( region );<br>&nbsp;&nbsp;&nbsp; flimzge-&gt;Allocate();<br><br>&nbsp;&nbsp;&nbsp; FloatImageType::IndexType pixelIndex;
<br><br>&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //filtre-&gt;Update();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i=0;i&lt;200;i++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pixelIndex[0] = i; // x position<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int j=0;j&lt;200;j++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pixelIndex[1] = j; // y position<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; flimzge-&gt;SetPixel( pixelIndex, (i-j)*4.7 );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt; FloatImageType &gt; WriterType;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WriterType::Pointer writer = WriterType::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writer-&gt;SetInput(flimzge);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writer-&gt;SetFileName( &quot;C:\\test.tif&quot; );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject e)
<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cout &lt;&lt; e &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>The exception is :<br><br>itk::ExceptionObject (00F7FEF8)<br>Location: &quot;void __thiscall itk::TIFFImageIO::InternalWrite(const void *)&quot;
<br>File: .\itkTIFFImageIO.cxx<br>Line: 1659<br>Description: itk::ERROR: TIFFImageIO(01443978): TIFF supports unsigned/signed char and unsigned/signed short<br><br>So, the ITK TIFF writer does not support float pixels. Is there a way to write images with float pixels in TIFF format ?
<br><br>Regards,<br><br>Olivier<br><br><div><span class="gmail_quote">2008/1/15, gabri &lt;<a href="mailto:tartuz@gmail.com">tartuz@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>give more information for asking an help like cut &#39;n paste here the<br>exception you read and the code lines you are using.<br><br>Best reguards<br><br>gabriele<br><br>Olivier Tournaire ha scritto:<br>&gt; Hi all,
<br>&gt;<br>&gt; I am new to ITK and I tried to write a simple image of float, but it<br>&gt; throws an exception. Is there a way to write such images ? If not,<br>&gt; could you give me a way on how to add this functionnality ?
<br>&gt;<br>&gt; Regards<br>&gt;<br>&gt; Olivier<br>&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>&gt; 
<a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt;<br><br><br><br></blockquote></div><br>