[Insight-users] (no subject)
yasser salman
yass71 at yahoo.com
Tue, 9 Mar 2004 12:37:05 -0800 (PST)
Hi All
for this code how can i get the voxel (or pixel)
value in the specified location ,also when i'm using
itk::ImageMomentsCalculator
the following error occured ..,
"error C2039: 'ComputeMoments' : is not a member of
'ImageMomentsCalculator<class itk::Image<unsigned
short,3> >'"
can any one help me in that..,
yasser
typedef unsigned short InputPixelType;
typedef float InternalPixelType;
typedef unsigned short SegmentedPixelType;
typedef itk::Image< InputPixelType, 3 >
InputImageType;
typedef itk::Image< InternalPixelType, 3>
InternalImageType;
typedef itk::Image< SegmentedPixelType, 3 >
SegmentedImageType;
typedef
itk::ImageMomentsCalculator<SegmentedImageType>
ImageMomentsType;
typedef itk::CastImageFilter<
InputImageType,
InternalImageType >
CastImageFilterType;
typedef itk::CurvatureFlowImageFilter<
InternalImageType,
InternalImageType >
CurvatureFlowImageFilterType;
typedef itk::ConnectedThresholdImageFilter<
InternalImageType, SegmentedImageType >
ConnectedFilterType;
typedef itk::ImageToVTKImageFilter<
SegmentedImageType >
ITK2VTKConnectorFilterType;
typedef itk::VTKImageToImageFilter< InputImageType
>
VTK2ITKConnectorFilterType;
typedef itk::ImageSeriesReader< InputImageType >
ReaderType;
itk::DICOMImageIO2::Pointer dicomIO =
itk::DICOMImageIO2::New();
// Get the DICOM filenames from the directory
itk::DICOMSeriesFileNames::Pointer nameGenerator =
itk::DICOMSeriesFileNames::New();
nameGenerator->SetDirectory( argv[1] );
std::cerr << "Usage: viewer1 imagefilename
xseed yseed zseed neighborhoodsize" << std::endl;
typedef std::vector<std::string> seriesIdContainer;
const seriesIdContainer & seriesUID =
nameGenerator->GetSeriesUIDs();
seriesIdContainer::const_iterator seriesItr =
seriesUID.begin();
seriesIdContainer::const_iterator seriesEnd =
seriesUID.end();
std::cout << std::endl << "The directory: " <<
std::endl;
//std::cout << std::endl << argv[1] << std::endl <<
std::endl;
std::cout << "Contains the following DICOM Series:
";
std::cout << std::endl << std::endl;
while( seriesItr != seriesEnd )
{
std::cout << seriesItr->c_str() << std::endl;
seriesItr++;
}
std::cout << std::endl << std::endl;
std::cout << "Now reading series: " << std::endl <<
std::endl;
typedef std::vector<std::string> fileNamesContainer;
fileNamesContainer fileNames;
argc=3; ///Part One
if( argc < 4 ) // If no optional third argument
{
std::cout << seriesUID.begin()->c_str() <<
std::endl;
fileNames = nameGenerator->GetFileNames();
}
else //part Two..
{
std::cout << argv[3] << std::endl;
fileNames = nameGenerator->GetFileNames( argv[3]
);
}
std::cout << std::endl << std::endl;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileNames( fileNames );
reader->SetImageIO( dicomIO );
try
{
reader->Update();
}
catch (itk::ExceptionObject &ex)
{
std::cout << ex << std::endl;
return EXIT_FAILURE;
}
CastImageFilterType::Pointer cast =
CastImageFilterType::New();
CurvatureFlowImageFilterType::Pointer smoothing =
CurvatureFlowImageFilterType::New();
ConnectedFilterType::Pointer connectedThreshold =
ConnectedFilterType::New();
VTK2ITKConnectorFilterType::Pointer VTK2ITKconnector
=
VTK2ITKConnectorFilterType::New();
ImageMomentsType::Pointer
calculator=ImageMomentsType::New();
cast->SetInput( reader->GetOutput() );
smoothing->SetInput( cast->GetOutput() );
confidence->SetInput( smoothing->GetOutput() );
smoothing->SetTimeStep( 0.125 );
smoothing->SetNumberOfIterations( 2 );
connectedThreshold->SetInput(
smoothing->GetOutput() );
const InternalPixelType lowerThreshold = 190;
const InternalPixelType upperThreshold = 205;
connectedThreshold->SetLower( lowerThreshold );
connectedThreshold->SetUpper( upperThreshold );
connectedThreshold->SetReplaceValue( 255 );
typedef ConnectedFilterType::IndexType IndexType;
IndexType seed;
seed[0] = 126;
seed[1] = 126;
seed[2] = 9;
std::cout << "Using seed = " << seed << std::endl;
connectedThreshold->SetSeed( seed );
//confidence->SetInitialNeighborhoodRadius( 2);
ITK2VTKConnectorFilterType::Pointer ITK2VTKconnector
=
ITK2VTKConnectorFilterType::New();
calculator->ComputeMoments(
connectedThreshold->GetOutput() );
double area = calculator->GetTotalMass();
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com