[Insight-users] ItkConnectedThresholdImageFilter

cspl affable at hd2 . dot . net . in
Tue, 6 Aug 2002 18:39:21 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_0021_01C23D78.945E8EF0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Mr.Luis & Dear Mr.B.Jorn and Friends,

I am working on ItkConnectedThresholdImageFilter. I am passing one seed =
point and threshold values to the class but I am not getting boundary =
which is located nearest.I got only one point that is seed point.Is =
there any parameters to set to get nearest boudary region.I have written =
code as follows.please Give me suggestion.

#include "afxwin.h"

#include <fstream>
#include "itkConnectedThresholdImageFilter.h"
#include "itkImageFileReader.h"

#include <itkRawImageIO.h>
#include <itkImageFileWriter.h>
#include <itkRawImageWriter.h>


int main()=20
{
 =20
  typedef unsigned short PixelType;
  typedef itk::Image<PixelType, 2> myImage;
  itk::ImageFileReader<myImage>::Pointer input=20
    =3D itk::ImageFileReader<myImage>::New();

    typedef itk::RawImageIO<PixelType,2>   RawReaderType;
  input->SetFileName("mriimg");//Input file name
   RawReaderType::Pointer  rawReader  =3D RawReaderType::New();
=20
  rawReader->SetDimensions( 0, 512);
  rawReader->SetDimensions( 1, 512);

  input->SetImageIO( rawReader );
  input->Update();

 =20
  // Create a filter
  typedef itk::ConnectedThresholdImageFilter<myImage,myImage> =
FilterType;

  FilterType::Pointer filter =3D FilterType::New();
    filter->SetInput(input->GetOutput());

    FilterType::IndexType seed; seed[0] =3D 165; seed[1] =3D 90;
    filter->SetSeed(seed);

    filter->SetLower(0);
    filter->SetUpper(150);
    filter->SetReplaceValue(255);
  try
    {
    input->Update();
    filter->Update();
    }
  catch (itk::ExceptionObject& e)
    {
    std::cerr << "Exception detected: "  << e.GetDescription();
    return -1;
    }

   typedef  itk::ImageFileWriter< myImage >      FileSinkType;
   typedef  itk::RawImageIO<PixelType,2>   RawWriterType;
=20
  FileSinkType::Pointer   fileSink   =3D FileSinkType::New();
  RawWriterType::Pointer  rawWriter  =3D RawWriterType::New();

 rawWriter->SetDimensions( 0, 512 );
 rawWriter->SetDimensions( 1, 512 );
    fileSink->SetImageIO( rawWriter );
    fileSink->SetFileName( "connectedmriImg1.raw" );//Output file name.
    fileSink->SetInput(filter->GetOutput());
    fileSink->Write();
 AfxMessageBox("successfully written");


  return 0;
}


Thanking you,
Regards,
satyanarayana R.

------=_NextPart_000_0021_01C23D78.945E8EF0
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>Dear Mr.Luis &amp; Dear Mr.B.Jorn and=20
Friends,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am working on =
ItkConnectedThresholdImageFilter. I=20
am passing one seed point and threshold values to the class but I am not =
getting=20
boundary which is located nearest.I got only one point that is seed =
point.Is=20
there any parameters to set to get nearest boudary region.I have written =
code as=20
follows.please Give me suggestion.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#include "afxwin.h"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#include &lt;fstream&gt;<BR>#include=20
"itkConnectedThresholdImageFilter.h"<BR>#include=20
"itkImageFileReader.h"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#include =
&lt;itkRawImageIO.h&gt;<BR>#include=20
&lt;itkImageFileWriter.h&gt;<BR>#include=20
&lt;itkRawImageWriter.h&gt;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>int main() <BR>{<BR>&nbsp; <BR>&nbsp; typedef unsigned short=20
PixelType;<BR>&nbsp; typedef itk::Image&lt;PixelType, 2&gt; =
myImage;<BR>&nbsp;=20
itk::ImageFileReader&lt;myImage&gt;::Pointer input =
<BR>&nbsp;&nbsp;&nbsp; =3D=20
itk::ImageFileReader&lt;myImage&gt;::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; typedef =
itk::RawImageIO&lt;PixelType,2&gt;&nbsp;&nbsp;=20
RawReaderType;<BR>&nbsp; input-&gt;SetFileName("mriimg");//Input file=20
name<BR>&nbsp;&nbsp; RawReaderType::Pointer&nbsp; rawReader&nbsp; =3D=20
RawReaderType::New();<BR>&nbsp;<BR>&nbsp; rawReader-&gt;SetDimensions( =
0,=20
512);<BR>&nbsp; rawReader-&gt;SetDimensions( 1, 512);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; input-&gt;SetImageIO( rawReader );<BR>&nbsp;=20
input-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; <BR>&nbsp; // Create a filter<BR>&nbsp; typedef=20
itk::ConnectedThresholdImageFilter&lt;myImage,myImage&gt; =
FilterType;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; FilterType::Pointer filter =3D=20
FilterType::New();<BR>&nbsp;&nbsp;&nbsp;=20
filter-&gt;SetInput(input-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; FilterType::IndexType seed; seed[0] =3D 165; =
seed[1] =3D=20
90;<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetSeed(seed);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; filter-&gt;SetLower(0);<BR>&nbsp;&nbsp;&nbsp;=20
filter-&gt;SetUpper(150);<BR>&nbsp;&nbsp;&nbsp;=20
filter-&gt;SetReplaceValue(255);<BR>&nbsp; try<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; input-&gt;Update();<BR>&nbsp;&nbsp;&nbsp;=20
filter-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; catch=20
(itk::ExceptionObject&amp; e)<BR>&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
std::cerr &lt;&lt; "Exception detected: "&nbsp; &lt;&lt;=20
e.GetDescription();<BR>&nbsp;&nbsp;&nbsp; return =
-1;<BR>&nbsp;&nbsp;&nbsp;=20
}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; typedef&nbsp; itk::ImageFileWriter&lt; myImage=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSinkType;<BR>&nbsp;&nbsp; =
typedef&nbsp;=20
itk::RawImageIO&lt;PixelType,2&gt;&nbsp;&nbsp;=20
RawWriterType;<BR>&nbsp;<BR>&nbsp; FileSinkType::Pointer&nbsp;&nbsp;=20
fileSink&nbsp;&nbsp; =3D FileSinkType::New();<BR>&nbsp;=20
RawWriterType::Pointer&nbsp; rawWriter&nbsp; =3D =
RawWriterType::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;rawWriter-&gt;SetDimensions( 0, 512=20
);<BR>&nbsp;rawWriter-&gt;SetDimensions( 1, 512 );<BR>&nbsp;&nbsp;&nbsp; =

fileSink-&gt;SetImageIO( rawWriter );<BR>&nbsp;&nbsp;&nbsp;=20
fileSink-&gt;SetFileName( "connectedmriImg1.raw" );//Output file=20
name.<BR>&nbsp;&nbsp;&nbsp;=20
fileSink-&gt;SetInput(filter-&gt;GetOutput());<BR>&nbsp;&nbsp;&nbsp;=20
fileSink-&gt;Write();<BR>&nbsp;AfxMessageBox("successfully =
written");</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp; return 0;<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Thanking you,<BR>Regards,<BR>satyanarayana=20
R.</FONT></DIV></BODY></HTML>

------=_NextPart_000_0021_01C23D78.945E8EF0--