#include "RangeCUDAMedianImageFilter.h"


template<class TRImage>
RangeCUDAMedianImageFilter<TRImage>
::RangeCUDAMedianImageFilter()
{
	m_KernelRadius = 1;

	m_RangeFilter = RangeFilterType::New();
}


template<class TRImage>
RangeCUDAMedianImageFilter<TRImage>
::~RangeCUDAMedianImageFilter()
{
}


//----------------------------------------------------------------------------
template<class TRImage>
void
RangeCUDAMedianImageFilter<TRImage>
::SetKernelRadius(unsigned int Radius)
{
	if ( Radius == m_KernelRadius )
		return;

	m_KernelRadius = Radius;
	m_RangeFilter->SetKernelRadius(m_KernelRadius);

	this->Modified();
}


//----------------------------------------------------------------------------
template<class TRImage>
unsigned int
RangeCUDAMedianImageFilter<TRImage>
::GetKernelRadius()
{
	return m_KernelRadius;
}


//----------------------------------------------------------------------------
template<class TRImage>
void
RangeCUDAMedianImageFilter<TRImage>
::DoFiltering()
{
	// Filter range image if requested
	if ( (Superclass::GetFilterMode()&Superclass::RANGE) == Superclass::RANGE )
	{
		m_RangeFilter->SetInput(this->GetInput()->GetRangeImage());
		m_RangeFilter->UpdateLargestPossibleRegion();
		this->GetOutput()->GetRangeImage()->Graft(m_RangeFilter->GetOutput());
	}

	// Filtering for RGBs NOT supported
	if ( (Superclass::GetFilterMode()&Superclass::RGB) == Superclass::RGB )
	{
		itkExceptionMacro(<<"Filtering of gray scale values not supported!");
	}

	// Filtering for world coord images NOT supported
	if ( (Superclass::GetFilterMode()&Superclass::WORLDCOORD) == Superclass::WORLDCOORD ) 
	{
		itkExceptionMacro(<<"Filtering of world coords not supported!");
	}
}


