[Insight-users] problems while working with itk::laplacianfilter

cspl affable at hd2 . dot . net . in
Tue, 4 Jun 2002 17:29:06 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C20BED.53F49DD0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

June,4,2002

Dear Luis,
I am SrinivaJ, I am trying to load a raw file
and apply laplacian effect on it, and get the result
in a different raw file.
And, I was getting some exceptions during the
runtime( while calling Update() method of ImageFileReader,
and Write() method of ImageFileWriter ).

I am listing my source code here,

/////////////SOURCE CODE/////////////////////
int main(int argc, char* argv[])
{
=20
  itk::ImageFileReader<ImageType>::Pointer  reader;
  reader =3D  itk::ImageFileReader<ImageType>::New();
  reader->SetFileName("1.raw");

  itk::RawImageIO<unsigned short,2>::Pointer io;
  io =3D itk::RawImageIO<unsigned short,2>::New();
  io->SetFileName ("1.raw");
  io->SetFilePrefix ("*.raw");
  io->ReadImageInformation();=20
  reader->SetImageIO(io);
  //reader->Update();

  ImageType::Pointer input =3D reader->GetOutput();
 =20
  cout<<"Laplacian filter test"<<endl;
  itk12::DiscreteGaussianImageFilter<ImageType, ImageType>::Pointer
    gaussianFilter =3D itk12::DiscreteGaussianImageFilter<ImageType, =
ImageType>::New();
  gaussianFilter->SetInput(input);
  //gaussianFilter->Update();



  itk::LaplacianImageFilter<ImageType, ImageType>::Pointer
    lapFilter =3D itk::LaplacianImageFilter<ImageType, =
ImageType>::New();
  lapFilter->SetInput(gaussianFilter->GetOutput());
//  lapFilter->Update();
  cout<<lapFilter->GetOutput();

//writing the output
itk::ImageFileWriter<ImageType>::Pointer writer;
  writer =3D itk::ImageFileWriter<ImageType>::New();

writer->SetInput(lapFilter->GetOutput());
  writer->SetFileName("junk2.raw");
  writer->SetInput(lapFilter->GetOutput());
  writer->SetImageIO(io);
  writer->Write();
 cout<<"Writing is completed"<<endl;
  return 0;
}

/////////////END OF THE SOURCE CODE/////////////////


Appreciating your help.

Regards
Srinivas jalataru
(CSPL, Hyderabad, India)


------=_NextPart_000_001C_01C20BED.53F49DD0
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 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>June,4,2002</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dear Luis,<BR>I am SrinivaJ, I am =
trying to load a=20
raw file<BR>and apply laplacian effect on it, and get the result<BR>in a =

different raw file.<BR>And, I was getting some exceptions during =
the<BR>runtime(=20
while calling Update() method of ImageFileReader,<BR>and Write() method =
of=20
ImageFileWriter ).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am listing my source code =
here,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>/////////////SOURCE=20
CODE/////////////////////<BR>int main(int argc, char*=20
argv[])<BR>{<BR>&nbsp;<BR>&nbsp;=20
itk::ImageFileReader&lt;ImageType&gt;::Pointer&nbsp; reader;<BR>&nbsp; =
reader=20
=3D&nbsp; itk::ImageFileReader&lt;ImageType&gt;::New();<BR>&nbsp;=20
reader-&gt;SetFileName("1.raw");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; itk::RawImageIO&lt;unsigned=20
short,2&gt;::Pointer io;<BR>&nbsp; io =3D itk::RawImageIO&lt;unsigned=20
short,2&gt;::New();<BR>&nbsp; io-&gt;SetFileName ("1.raw");<BR>&nbsp;=20
io-&gt;SetFilePrefix ("*.raw");<BR>&nbsp; io-&gt;ReadImageInformation(); =

<BR>&nbsp; reader-&gt;SetImageIO(io);<BR>&nbsp;=20
//reader-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; ImageType::Pointer input =3D=20
reader-&gt;GetOutput();<BR>&nbsp; <BR>&nbsp; cout&lt;&lt;"Laplacian =
filter=20
test"&lt;&lt;endl;<BR>&nbsp; =
itk12::DiscreteGaussianImageFilter&lt;ImageType,=20
ImageType&gt;::Pointer<BR>&nbsp;&nbsp;&nbsp; gaussianFilter =3D=20
itk12::DiscreteGaussianImageFilter&lt;ImageType, =
ImageType&gt;::New();<BR>&nbsp;=20
gaussianFilter-&gt;SetInput(input);<BR>&nbsp;=20
//gaussianFilter-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; =
itk::LaplacianImageFilter&lt;ImageType,=20
ImageType&gt;::Pointer<BR>&nbsp;&nbsp;&nbsp; lapFilter =3D=20
itk::LaplacianImageFilter&lt;ImageType, ImageType&gt;::New();<BR>&nbsp;=20
lapFilter-&gt;SetInput(gaussianFilter-&gt;GetOutput());<BR>//&nbsp;=20
lapFilter-&gt;Update();<BR>&nbsp;=20
cout&lt;&lt;lapFilter-&gt;GetOutput();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>//writing the=20
output<BR>itk::ImageFileWriter&lt;ImageType&gt;::Pointer =
writer;<BR>&nbsp;=20
writer =3D itk::ImageFileWriter&lt;ImageType&gt;::New();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>writer-&gt;SetInput(lapFilter-&gt;GetOutput());<BR>&nbsp;=20
writer-&gt;SetFileName("junk2.raw");<BR>&nbsp;=20
writer-&gt;SetInput(lapFilter-&gt;GetOutput());<BR>&nbsp;=20
writer-&gt;SetImageIO(io);<BR>&nbsp;=20
writer-&gt;Write();<BR>&nbsp;cout&lt;&lt;"Writing is=20
completed"&lt;&lt;endl;<BR>&nbsp; return 0;<BR>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>/////////////END OF THE SOURCE=20
CODE/////////////////</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><FONT face=3DArial =
size=3D2>
<DIV><BR>Appreciating your help.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards<BR>Srinivas jalataru<BR>(CSPL, Hyderabad,=20
India)<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_001C_01C20BED.53F49DD0--