[Insight-users] Re: level set region approach
olivier Bernard
bernard at creatis.insa-lyon.fr
Tue Oct 19 05:11:52 EDT 2004
Hi Luis,
Yes, by update I mean that I want to modify the feature image at each
iteration.
To do so, I had the idea to subclass the itkSegmentationImageFilter class
and to add an observer on it.
I named the new class : itkMoyActiveRegionLevelSetImageFilter
I created too a class called "FeatureImageFilter". This class creates from
two inputs an outputimage that I use as new FeatureImage for the class
itkMoyActiveRegionLevelSetImageFilter for each iteration.
Here is the code of the observer. This code seems to work, but I'm not
sure if I'm doing the right think, could you please tell me what you think
on this code.
Thanks
#ifndef __EXTRACTORLEVELSETEVOLUTIONMOY__HXX__
#define __EXTRACTORLEVELSETEVOLUTIONMOY__HXX__
#include <itkCommand.h>
#include "itkMoyActiveRegionLevelSetImageFilter.h"
#include "FeatureImageFilter.h"
#include "itkImage.h"
/* Connexion itk/vtk/itk */
#include "../src/VTKImageToImageFilter.h"
namespace creatis
{
class ExtractorLevelSetEvolutionMoy : public itk::Command
{
public:
// ITK types
typedef ExtractorLevelSetEvolutionMoy Self;
typedef itk::Command Superclass;
typedef itk::SmartPointer< Self > Pointer;
// ITK-style macros
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro(ExtractorLevelSetEvolutionMoy, Command);
typedef float PixelFloatType;
typedef unsigned char PixelUCharType;
typedef itk::Image< PixelFloatType, 2 > ImageFloatType;
typedef itk::Image< PixelUCharType, 2 > ImageUCharType;
typedef itk::VTKImageToImageFilter<ImageFloatType> ConnectorVtkToItkFloat;
ConnectorVtkToItkFloat::Pointer itkImporter;
//////////////////////////////////////////////////////////////
typedef itk::MoyActiveRegionLevelSetImageFilter
<
ImageFloatType,
ImageFloatType
> MoyActiveRegionFilterType;
typedef const MoyActiveRegionFilterType* MoyActiveRegionPointer;
///////////////////////////////////////////////////////////////
// Execution procedures
void Execute( itk::Object* caller, const itk::EventObject& event)
{
Execute( ( const itk::Object* )caller, event);
}
void Execute( const itk::Object* object, const itk::EventObject& event)
{
if( typeid( event ) == typeid( itk::IterationEvent ) ) {
///////////////////////////////////////////////////////////////////////
MoyActiveRegionFilterType* moyActiveRegion =
(MoyActiveRegionFilterType* )object;
ImageFloatType::Pointer image = ImageFloatType::New();
image = ( ( MoyActiveRegionFilterType* )moyActiveRegion )->GetOutput( );
/* FeatureImageFilter method */
typedef itk::FeatureImageFilter< ImageFloatType,
ImageFloatType,ImageFloatType> FeatureImageFilter;
FeatureImageFilter::Pointer featureImage = FeatureImageFilter::New();
featureImage->SetInputEdgeMap( itkImporter->GetOutput() );
featureImage->SetInputLevelSet( image );
featureImage->Update();
std::cout << moyActiveRegion->GetElapsedIterations()<< " ";
moyActiveRegion->SetFeatureImage(featureImage->GetOutput());
moyActiveRegion->Modified();
}
}
protected:
ExtractorLevelSetEvolutionMoy( )
{
/* Lecture Image ACR sous VTK */
ReaderVtk = vtkACRReader::New();
ReaderVtk->SetFileName("../../data/NonLogIma_1.acr");
/* PIPELINE : Vtk ---->Itk */
itkImporter = ConnectorVtkToItkFloat::New();
itkImporter->SetInput(ReaderVtk->GetOutput());
itkImporter->Update();
}
~ExtractorLevelSetEvolutionMoy( )
{
ReaderVtk->Delete();
}
private:
ExtractorLevelSetEvolutionMoy( const Self& ); // Not impl.
void operator=( const Self& ); // Not impl.
};
} // fnamespace
#endif
--
olivier Bernard
Creatis Laboratory
Doctorant 2nd year
More information about the Insight-users
mailing list