Good after-noon itk users!!<br><br>I am trying to use CompositeFilterExample (the compilation has been satisfactory) but the output image is not well built. Have anybody had the same problem?<br><br>By the way, I have constructed another filter using as base CompositeFilterExample. I want that my filter get an image, reescale its intensity and, after that, make an automatic adaptation of the histogram. In the same way, I have obtained an executable, but it doesn't work. What is the problem with that?<br>
<br>This is my code.<br><br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif<br><br>#include "itkImageToImageFilter.h"<br><br>
<br>#include "itkRescaleIntensityImageFilter.h"<br>#include "itkAdaptiveHistogramEqualizationImageFilter.h"<br><br>#include "itkNumericTraits.h"<br><br>namespace itk {<br><br>template <class TImageType><br>
class ITK_EXPORT CompositeExampleImageFilter :<br> public ImageToImageFilter<TImageType, TImageType><br>{<br>public:<br><br> typedef CompositeExampleImageFilter Self;<br> typedef ImageToImageFilter<TImageType,TImageType> Superclass;<br>
typedef SmartPointer<Self> Pointer;<br> typedef SmartPointer<const Self> ConstPointer;<br><br> itkNewMacro(Self);<br> <br> itkTypeMacro(CompositeExampleImageFilter, ImageToImageFilter);<br>
<br><br><br> typedef typename TImageType::PixelType PixelType;<br><br> <br><br>protected:<br><br> CompositeExampleImageFilter();<br><br><br>protected:<br><br> typedef RescaleIntensityImageFilter< TImageType, TImageType > RescalerType;<br>
typedef AdaptiveHistogramEqualizationImageFilter< TImageType > EqualizerType;<br><br><br> void GenerateData();<br><br>private:<br><br> CompositeExampleImageFilter(Self&); // intentionally not implemented<br>
void operator=(const Self&); // intentionally not implemented<br><br> <br> typename RescalerType::Pointer m_RescaleFilter;<br> typename EqualizerType::Pointer m_EqualizeFilter;<br><br> <br>};<br>
<br>} <br><br>namespace itk <br>{<br><br>// Software Guide : BeginCodeSnippet<br>template <class TImageType><br>CompositeExampleImageFilter<TImageType><br>::CompositeExampleImageFilter()<br>{<br> <br> m_RescaleFilter = RescalerType::New();<br>
m_EqualizeFilter = EqualizerType::New();<br><br> m_RescaleFilter->SetOutputMinimum(NumericTraits<PixelType>::NonpositiveMin());<br> m_RescaleFilter->SetOutputMaximum(NumericTraits<PixelType>::max());<br>
<br> m_EqualizeFilter->SetInput( m_RescaleFilter->GetOutput() );<br><br> <br>}<br><br>template <class TImageType><br>void<br>CompositeExampleImageFilter<TImageType>::<br>GenerateData()<br>{<br> <br> m_RescaleFilter->SetInput( this->GetInput() );<br>
m_RescaleFilter->Update();<br> m_EqualizeFilter->SetInput( this->GetOutput() );<br> m_EqualizeFilter->Update();<br> <br>}<br><br>}<br><br><br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>
<br>int main( int argc, char* argv[] )<br>{<br> if( argc < 3 ) <br> { <br> std::cerr << "Usage: " << std::endl;<br> std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;<br>
return EXIT_FAILURE;<br> }<br><br> typedef itk::Image<short, 2> ImageType;<br> typedef itk::ImageFileReader<ImageType> ReaderType;<br> typedef itk::ImageFileWriter<ImageType> WriterType;<br>
<br> typedef itk::CompositeExampleImageFilter<ImageType> FilterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br> FilterType::Pointer filter = FilterType::New();<br>
<br> reader->SetFileName( argv[1] );<br> filter->SetInput( reader->GetOutput() );<br> writer->SetInput( filter->GetOutput() );<br> writer->SetFileName( argv[2] );<br><br> try<br> {<br> writer->Update();<br>
}<br> catch ( itk::ExceptionObject e )<br> {<br> std::cerr << "Error: " << e << std::endl;<br> }<br><br> return 0;<br>}<br><br><br>Thank you very much!!!<br clear="all"><br>-- <br>
Ignacio García Fenoll<br>Grupo de Imágenes Médicas<br>Departamento de Teoría de la Señal y Comunicaciones<br>Universidad de Sevilla<br>e-mail: <a href="mailto:igfenoll@gmail.com">igfenoll@gmail.com</a><br><br>