[Insight-users] Write data in PNG Format

Samuel Rodríguez Bescos srodrigu at gbt . tfo . upm . es
Thu, 4 Jul 2002 12:04:05 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C22352.E4B14B30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello every body,

I'm developing and watershed segmentation example that can read PNG =
Images and write the results in PNG format. I have a problems with =
writing the smoothed image, the gradinet magnitude Image and the final =
Segmented image. I want to write them to disk in PNG format.

I'm using the next code for witing:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
          (...)
          typedef   float                             PixelType;
          (...)
  typedef   itk::Image< PixelType, 2 >      ImageType;
  typedef   itk::PNGImageIO         IoType;

  (...)

  typedef itk::ImageFileWriter<ImageType>      ImageWriterType;
  IoType::Pointer             m_Io;
  CurvatureAnisotropicDiffusionImageFilterType::Pointer    m_Smoothed;
  ImageWriterType::Pointer           m_SmoothedWriter;

  (........Executing the algorithm....)

     m_SmoothedWriter->SetInput(m_Smoothed->GetOutput());
     m_SmoothedWriter->SetFileName( filename );
     m_SmoothedWriter->SetImageIO(m_Io);
     m_SmoothedWriter->Write();
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Can anyboby tell me how can I do it or what is the problem.

Thanks,

Samuel

------=_NextPart_000_001B_01C22352.E4B14B30
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2715.400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello every body,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm developing and watershed =
segmentation example=20
that can read PNG Images and write the results in PNG format. I have a =
problems=20
with writing the smoothed image, the gradinet magnitude Image and the =
final=20
Segmented image. I want to write them to disk in PNG =
format.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm using the next code for =
witing:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;(...)</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=
def&nbsp;&nbsp;=20
float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
PixelType;</FONT></FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
(...)</DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV>
  <DIV><FONT face=3DArial size=3D2>typedef&nbsp;&nbsp; itk::Image&lt; =
PixelType, 2=20
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ImageType;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>typedef&nbsp;&nbsp;=20
  =
itk::PNGImageIO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IoTy=
pe;</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>(...)</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial=20
  =
size=3D2>typedef&nbsp;itk::ImageFileWriter&lt;ImageType&gt;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;ImageWriterType;</FONT></DIV>
  <DIV><FONT face=3DArial=20
  =
size=3D2>IoType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Io;</FONT></DIV>
  <DIV><FONT face=3DArial=20
  =
size=3D2>CurvatureAnisotropicDiffusionImageFilterType::Pointer&nbsp;&nbsp=
;&nbsp;&nbsp;m_Smoothed;</FONT></DIV>
  <DIV><FONT face=3DArial=20
  =
size=3D2>ImageWriterType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;m_SmoothedWriter;</FONT></DIV></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>(........Executing the=20
algorithm....)</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;=20
  =
m_SmoothedWriter-&gt;SetInput(m_Smoothed-&gt;GetOutput());<BR>&nbsp;&nbsp=
;=20
  m_SmoothedWriter-&gt;SetFileName( filename );<BR>&nbsp;&nbsp;=20
  m_SmoothedWriter-&gt;SetImageIO(m_Io);<BR>&nbsp;&nbsp;=20
  m_SmoothedWriter-&gt;Write();</FONT></DIV></BLOCKQUOTE>
<DIV><FONT face=3DArial=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Can anyboby tell me how can I do it or =
what is the=20
problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Samuel</FONT></DIV></BODY></HTML>

------=_NextPart_000_001B_01C22352.E4B14B30--