SET(CLITK_USE_SYSTEM_GDCM TRUE)
ENDIF()
ENDIF(ITK_VERSION_MAJOR LESS "4")
-
+SET(CLITK_USE_SYSTEM_GDCM FALSE)
#DD(CLITK_USE_SYSTEM_GDCM)
typedef typename OutputImageType::PixelType OutputImagePixelType;
typedef typename OutputImageType::SpacingType OutputImageSpacingType;
typedef typename OutputImageType::SizeType OutputImageSizeType;
+ typedef typename OutputImageType::PointType OutputImageOriginType;
+ typedef typename OutputImageType::DirectionType OutputImageDirectionType;
typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
typedef typename InputImageType::SpacingType GaussianSigmaType;
itkGetMacro(OutputSpacing, OutputImageSpacingType);
itkSetMacro(OutputSize, OutputImageSizeType);
itkGetMacro(OutputSize, OutputImageSizeType);
+ itkSetMacro(OutputOrigin, OutputImageOriginType);
+ itkGetMacro(OutputOrigin, OutputImageOriginType);
+ itkSetMacro(OutputDirection, OutputImageDirectionType);
+ itkGetMacro(OutputDirection, OutputImageDirectionType);
itkGetMacro(InterpolationType, InterpolationTypeEnumeration);
itkSetMacro(InterpolationType, InterpolationTypeEnumeration);
itkGetMacro(GaussianFilteringEnabled, bool);
int m_BSplineOrder;
int m_BLUTSamplingFactor;
OutputImageSizeType m_OutputSize;
- OutputImageSpacingType m_OutputSpacing;
+ OutputImageSpacingType m_OutputSpacing;
+ OutputImageOriginType m_OutputOrigin;
+ OutputImageDirectionType m_OutputDirection;
typename TransformType::Pointer m_Transform;
GaussianSigmaType m_GaussianSigma;
OutputImagePixelType m_DefaultPixelValue;
m_OutputSpacing[i] = -1;
m_GaussianSigma[i] = -1;
}
+ m_OutputOrigin.Fill(0);
+ m_OutputDirection.SetIdentity();
m_VerboseOptions = false;
SetDefaultPixelValue(0);
}
filter->SetTransform(m_Transform);
filter->SetSize(m_OutputSize);
filter->SetOutputSpacing(m_OutputSpacing);
- filter->SetOutputOrigin(origin);
+ filter->SetOutputOrigin(m_OutputOrigin);
filter->SetDefaultPixelValue(m_DefaultPixelValue);
filter->SetNumberOfThreads(this->GetNumberOfThreads());
- filter->SetOutputDirection(input->GetDirection()); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example)
+ filter->SetOutputDirection(m_OutputDirection); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example)
// Select interpolator
switch (m_InterpolationType) {
TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon )
SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkFooImage)
- #WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
- #ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
- #TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkMedianImageFilterLib clitkCommon)
- #SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianImageFilter)
+ WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
+ ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
+ TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkMedianImageFilterLib clitkCommon)
+ SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianImageFilter)
ADD_EXECUTABLE(clitkResampleImage clitkResampleImage.cxx)
TARGET_LINK_LIBRARIES(clitkResampleImage clitkResampleImageLib clitkCommon)
public:
//--------------------------------------------------------------------
- MedianImageGenericFilter();
+ MedianImageGenericFilter();
//--------------------------------------------------------------------
- typedef MedianImageGenericFilter Self;
+ typedef MedianImageGenericFilter Self;
+ typedef ImageToImageGenericFilter<MedianImageGenericFilter<args_info_type> > Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
// Main function called each time the filter is updated
template<class InputImageType>
void UpdateWithInputImageType();
-
-
-
protected:
template<unsigned int Dim> void InitializeImageType();
-
args_info_type mArgsInfo;
-
+
+ private:
+ MedianImageGenericFilter(const Self&); //purposely not implemented
+ void operator=(const Self&); //purposely not implemented
+
}; // end class
//--------------------------------------------------------------------
// typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
- // Main filter
- typedef itk::Image<PixelType, InputImageType::ImageDimension> OutputImageType;
- typename InputImageType::SizeType indexRadius;
-
// Filter
- typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
- typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
- thresholdFilter->SetInput(input);
-
- for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
- indexRadius[i]=mArgsInfo.radius_arg[i];
-
- // indexRadius[0] = 1;
- // indexRadius[1] = 1;
-
- thresholdFilter->SetRadius( indexRadius );
-
- typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
- thresholdFilter->Update();
+ typedef itk::MedianImageFilter<InputImageType, InputImageType> MedianImageFilterType;
+ typename MedianImageFilterType::Pointer medianFilter=MedianImageFilterType::New();
+ typename MedianImageFilterType::InputSizeType radius;
+ radius.Fill(1);
+ medianFilter->SetInput(input);
+
+ if(mArgsInfo.radius_given) {
+ for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
+ radius[i]=mArgsInfo.radius_arg[i];
+ }
+ //
+ std::cout<<"radius median filter= "<<radius<<std::endl;
+ //
+ medianFilter->SetRadius( radius );
+ medianFilter->Update();
// Write/Save results
- this->template SetNextOutput<OutputImageType>(outputImage);
+ typename InputImageType::Pointer outputImage = medianFilter->GetOutput();
+ this->template SetNextOutput<InputImageType>(outputImage);
}
//--------------------------------------------------------------------
static const unsigned int dim = OutputImageType::ImageDimension;
typename OutputImageType::SpacingType spacing;
typename OutputImageType::SizeType size;
+ typename OutputImageType::PointType origin;
+ typename OutputImageType::DirectionType direction;
if (mArgsInfo.like_given) {
itk::ImageIOBase::Pointer header = clitk::readImageHeader(mArgsInfo.like_arg);
for(unsigned int i=0; i<dim; i++){
spacing[i] = header->GetSpacing(i);
size[i] = header->GetDimensions(i);
+ origin[i] = header->GetOrigin(i);
+ }
+ for(unsigned int i=0; i<dim; i++) {
+ for(unsigned int j=0;j<dim;j++) {
+ direction(i,j) = header->GetDirection(i)[j];
+ }
}
filter->SetOutputSpacing(spacing);
filter->SetOutputSize(size);
+ filter->SetOutputOrigin(origin);
+ filter->SetOutputDirection(direction);
}
else {
std::cerr << "*** Warning : I could not read '" << mArgsInfo.like_arg << "' ***" << std::endl;
size[i] = mArgsInfo.size_arg[i];
filter->SetOutputSize(size);
}
+ itk::ImageIOBase::Pointer header = clitk::readImageHeader(mArgsInfo.input_arg);
+ for(unsigned int i=0; i<dim; i++){
+ origin[i] = header->GetOrigin(i);
+ }
+ for(unsigned int i=0; i<dim; i++) {
+ for(unsigned int j=0;j<dim;j++) {
+ direction(i,j) = header->GetDirection(i)[j];
+ }
+ }
+ filter->SetOutputOrigin(origin);
+ filter->SetOutputDirection(direction);
}
// Set temporal dimension