[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 & Dear Mr.B.Jorn and=20
Friends,</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>#include "afxwin.h"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>#include <fstream><BR>#include=20
"itkConnectedThresholdImageFilter.h"<BR>#include=20
"itkImageFileReader.h"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>#include =
<itkRawImageIO.h><BR>#include=20
<itkImageFileWriter.h><BR>#include=20
<itkRawImageWriter.h></FONT></DIV>
<DIV> </DIV><FONT face=3DArial size=3D2>
<DIV><BR>int main() <BR>{<BR> <BR> typedef unsigned short=20
PixelType;<BR> typedef itk::Image<PixelType, 2> =
myImage;<BR> =20
itk::ImageFileReader<myImage>::Pointer input =
<BR> =3D=20
itk::ImageFileReader<myImage>::New();</DIV>
<DIV> </DIV>
<DIV> typedef =
itk::RawImageIO<PixelType,2> =20
RawReaderType;<BR> input->SetFileName("mriimg");//Input file=20
name<BR> RawReaderType::Pointer rawReader =3D=20
RawReaderType::New();<BR> <BR> rawReader->SetDimensions( =
0,=20
512);<BR> rawReader->SetDimensions( 1, 512);</DIV>
<DIV> </DIV>
<DIV> input->SetImageIO( rawReader );<BR> =20
input->Update();</DIV>
<DIV> </DIV>
<DIV> <BR> // Create a filter<BR> typedef=20
itk::ConnectedThresholdImageFilter<myImage,myImage> =
FilterType;</DIV>
<DIV> </DIV>
<DIV> FilterType::Pointer filter =3D=20
FilterType::New();<BR> =20
filter->SetInput(input->GetOutput());</DIV>
<DIV> </DIV>
<DIV> FilterType::IndexType seed; seed[0] =3D 165; =
seed[1] =3D=20
90;<BR> filter->SetSeed(seed);</DIV>
<DIV> </DIV>
<DIV> filter->SetLower(0);<BR> =20
filter->SetUpper(150);<BR> =20
filter->SetReplaceValue(255);<BR> try<BR> =20
{<BR> input->Update();<BR> =20
filter->Update();<BR> }<BR> catch=20
(itk::ExceptionObject& e)<BR> =
{<BR> =20
std::cerr << "Exception detected: " <<=20
e.GetDescription();<BR> return =
-1;<BR> =20
}</DIV>
<DIV> </DIV>
<DIV> typedef itk::ImageFileWriter< myImage=20
> FileSinkType;<BR> =
typedef =20
itk::RawImageIO<PixelType,2> =20
RawWriterType;<BR> <BR> FileSinkType::Pointer =20
fileSink =3D FileSinkType::New();<BR> =20
RawWriterType::Pointer rawWriter =3D =
RawWriterType::New();</DIV>
<DIV> </DIV>
<DIV> rawWriter->SetDimensions( 0, 512=20
);<BR> rawWriter->SetDimensions( 1, 512 );<BR> =
fileSink->SetImageIO( rawWriter );<BR> =20
fileSink->SetFileName( "connectedmriImg1.raw" );//Output file=20
name.<BR> =20
fileSink->SetInput(filter->GetOutput());<BR> =20
fileSink->Write();<BR> AfxMessageBox("successfully =
written");</DIV>
<DIV> </DIV>
<DIV><BR> return 0;<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>Thanking you,<BR>Regards,<BR>satyanarayana=20
R.</FONT></DIV></BODY></HTML>
------=_NextPart_000_0021_01C23D78.945E8EF0--