[Insight-users] Help with writing a filter - textural feature
extraction
JD
johndq at gmail.com
Tue Oct 2 17:41:57 EDT 2007
Skipped content of type multipart/alternative-------------- next part --------------
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkVector.h"
#include "itkListSample.h"
#include "itkKdTree.h"
#include "itkWeightedCentroidKdTreeGenerator.h"
#include "itkKdTreeBasedKmeansEstimator.h"
#include "itkMinimumDecisionRule.h"
#include "itkEuclideanDistance.h"
#include "itkSampleClassifier.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "ScalarImageNeighborhoodTextureCalculator.h"
#include "itkRescaleIntensityImageFilter.h"
int main(int argc, char * argv [] )
{
// check input arguments
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " inputScalarImage outputLabeledScalarImage numberOfClasses(K)" << std::endl;
return EXIT_FAILURE;
}
// parameters
const char * inputImageFileName = argv[1];
const char * outputImageFileName = argv[2];
const unsigned int dimension = 2;
const unsigned int measurementVectorLength = 6;
const unsigned int numberOfClasses = atoi( argv[3] );
// typedefs
typedef char InputPixelType;
typedef unsigned char OutputPixelType;
typedef itk::Image<InputPixelType, dimension > InputImageType;
typedef itk::Image<OutputPixelType, dimension > OutputImageType;
typedef itk::Vector< double,
measurementVectorLength > MeasurementVectorType;
typedef itk::Statistics::ListSample<
MeasurementVectorType > SampleType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
typedef itk::Statistics::ScalarImageNeighborhoodTextureCalculator<
InputImageType > TexCalcType;
typedef itk::RescaleIntensityImageFilter<
OutputImageType, OutputImageType > RescaleIntensityFilterType;
// Get input image
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputImageFileName );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
// Create texture calculator
TexCalcType::Pointer texCalc = TexCalcType::New();
texCalc->SetInput( reader->GetOutput() );
try
{
texCalc->Compute();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
// sample, for storing many measurement vectors
SampleType::Pointer sample = texCalc->GetOutput();
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScalarImageNeighborhoodTextureCalculator.h
Type: text/x-chdr
Size: 9603 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20071002/998ef583/ScalarImageNeighborhoodTextureCalculator-0001.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScalarImageNeighborhoodTextureCalculator.txx
Type: application/octet-stream
Size: 6617 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20071002/998ef583/ScalarImageNeighborhoodTextureCalculator-0001.obj
More information about the Insight-users
mailing list