Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

Commit

Permalink
STYLE: removing verbose debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Jul 20, 2018
1 parent bed9cae commit 57e2a8a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 205 deletions.
1 change: 0 additions & 1 deletion include/itkGPUSmoothingRecursiveYvvGaussianImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class ITK_EXPORT GPUSmoothingRecursiveYvvGaussianImageFilter:
typename GPUOutputImage::SizeType m_requestedSize;
/** Standard deviation of the gaussian used for smoothing */
SigmaArrayType m_Sigma;
int telltale; //TODO: REMOVE
};
} // end namespace itk

Expand Down
84 changes: 0 additions & 84 deletions include/itkGPUSmoothingRecursiveYvvGaussianImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@

#include "itkGPUSmoothingRecursiveYvvGaussianImageFilter.h"

//#define VERBOSE
namespace itk
{
/**
* Constructor
*/
template< typename TInputImage, typename TOutputImage >
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::GPUSmoothingRecursiveYvvGaussianImageFilter()
{
#ifdef VERBOSE
telltale = rand();
std::cout << telltale << ". GPUSmoothing::constructor \n";
#endif
m_NormalizeAcrossScale = false;
otPtr = dynamic_cast< GPUOutputImage * >( this->ProcessObject::GetOutput(0) );

Expand Down Expand Up @@ -81,33 +73,20 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
GetTypenameInString(typeid( ScalarRealType ), defines);
defines << "#define MAX_LINE_LENGTH " << maxLineSize << "\n";

#ifdef VERBOSE
std::cout << telltale << ". Defines: \n" << defines.str() << "\n";
#endif

//load, build, create kernel
this->m_GPUKernelManager->LoadProgramFromString( GPUSource, defines.str().c_str() );
m_FilterGPUKernelHandle = this->m_GPUKernelManager->CreateKernel("YvvFilter");
}

/**
* Compute filter for Gaussian kernel.
*/
template< typename TInputImage, typename TOutputImage >
void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::SetUp(ScalarRealType spacing)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::SetUp with spacing " << spacing << "\n";
#endif
const ScalarRealType sigmad = this->GetSigma() / spacing;

if ( this->GetSigma() >= 0.5 )
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::SetUp with sigma " << m_Sigma << "\n";
#endif
// Compute q according to 16 in Young et al on Gabor filering
ScalarRealType q = 0;
if ( sigmad >= 3.556 )
Expand Down Expand Up @@ -179,9 +158,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::SetInput(const TInputImage *input)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothingRecursiveYvvGaussianImageFilter::SetInput \n";
#endif
// ProcessObject is not const_correct so this const_cast is required
ProcessObject::SetNthInput( 0,
const_cast< TInputImage * >( input ) );
Expand All @@ -204,29 +180,20 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
}
}

// Set value of Sigma (isotropic)
template< typename TInputImage, typename TOutputImage >
void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::SetSigma(ScalarRealType sigma)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::SetSigma: " << sigma << " \n";
#endif
SigmaArrayType sigmas(sigma);
this->SetSigmaArray(sigmas);
}

// Set value of Sigma (an-isotropic)

template< typename TInputImage, typename TOutputImage >
void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::SetSigmaArray(const SigmaArrayType & sigma)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::SetSigmaArray" << m_Sigma << " vs new: " << sigma[0] << " \n";
#endif
if ( this->m_Sigma != sigma )
{
this->m_Sigma = sigma;
Expand All @@ -235,25 +202,17 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
this->GetOutput()->GetSpacing();
if ( pixelSize[0] != 0 )
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::SetSigmaArray. pixelSize: [" << pixelSize[0] << "," << pixelSize[1]
<< "," << pixelSize[2] << "] \n";
#endif
this->SetUp(pixelSize[0]);
}
this->Modified();
}
}

// Get the sigma array.
template< typename TInputImage, typename TOutputImage >
typename GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >::SigmaArrayType
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::GetSigmaArray() const
{
/*#ifdef VERBOSE
std::cout<< telltale << ". GPUSmoothing::GetSigmaArray \n";
#endif*/
return m_Sigma;
}

Expand All @@ -264,23 +223,14 @@ typename GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::GetSigma() const
{
/*#ifdef VERBOSE
std::cout<< telltale << ". GPUSmoothing::GetSigma \n";
#endif*/
return m_Sigma[0];
}

/**
* Set Normalize Across Scale Space
*/
template< typename TInputImage, typename TOutputImage >
void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::SetNormalizeAcrossScale(bool normalize)
{
/*#ifdef VERBOSE
std::cout<< telltale << ". GPUSmoothing::SetNormalizeAcrossScale \n";
#endif*/
m_NormalizeAcrossScale = normalize;
this->Modified();
}
Expand All @@ -290,9 +240,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::GenerateInputRequestedRegion() throw( InvalidRequestedRegionError )
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::GenerateInputRequestedRegion \n";
#endif
// call the superclass' implementation of this method. this should
// copy the output requested region to the input requested region
Superclass::GenerateInputRequestedRegion();
Expand All @@ -312,9 +259,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::EnlargeOutputRequestedRegion(DataObject *output)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::EnlargeOutputRequestedRegion \n";
#endif
TOutputImage *out = dynamic_cast< TOutputImage * >( output );

if ( out )
Expand All @@ -328,10 +272,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::AllocateGPUCoefficients()
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothingRecursiveYvvGaussianImageFilter::AllocateGPUInputBuffer \n";
#endif

m_GPUBCoefficientsDataManager = GPUDataManager::New();
m_GPUBCoefficientsDataManager->SetBufferSize( 4 * sizeof( ScalarRealType ) );
m_GPUBCoefficientsDataManager->SetCPUBufferPointer(m_Bvalues);
Expand Down Expand Up @@ -361,9 +301,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::GPUGenerateData(void)
{
#ifdef VERBOSE
std::cout << telltale << ". GPUSmoothing::GPUGenerateData \n";
#endif
if ( m_FilterGPUKernelHandle == -1 )
{
this->BuildKernel();
Expand All @@ -384,9 +321,6 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
for ( int i = 0; i < ndim; ++i )
{
this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, argidx++, sizeof( int ), &( m_requestedSize[i] ) );
#ifdef VERBOSE
std::cout << telltale << ".Arg " << argidx << ": " << m_requestedSize[i] << "\n";
#endif
}

const unsigned int dimArg = argidx;
Expand All @@ -396,17 +330,11 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
int globalSize1D = ( m_requestedSize[1] > m_requestedSize[0] ? m_requestedSize[1] : m_requestedSize[0] );

this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, dimArg, sizeof( unsigned int ), &( X ) );
#ifdef VERBOSE
std::cout << telltale << ". Calling 1D kernel on X.\n";
#endif
this->m_GPUKernelManager->LaunchKernel1D(m_FilterGPUKernelHandle, globalSize1D, 16);

//change ONLY input and direction of filter
this->m_GPUKernelManager->SetKernelArgWithImage( m_FilterGPUKernelHandle, 0, otPtr->GetGPUDataManager() );
this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, dimArg, sizeof( unsigned int ), &( Y ) );
#ifdef VERBOSE
std::cout << telltale << ". Calling 1D kernel on Y.\n";
#endif
this->m_GPUKernelManager->LaunchKernel1D(m_FilterGPUKernelHandle, globalSize1D, 16);
}
else
Expand All @@ -415,25 +343,16 @@ GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
// dimension.

this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, argidx++, sizeof( unsigned int ), &( X ) );
#ifdef VERBOSE
std::cout << telltale << ". Calling 2D kernel on X.\n";
#endif
this->m_GPUKernelManager->LaunchKernel2D(m_FilterGPUKernelHandle, m_requestedSize[2], m_requestedSize[1], 16, 16);

//change ONLY input and direction of filter
this->m_GPUKernelManager->SetKernelArgWithImage( m_FilterGPUKernelHandle, 0, otPtr->GetGPUDataManager() );
this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, dimArg, sizeof( unsigned int ), &( Y ) );
#ifdef VERBOSE
std::cout << telltale << ". Calling 2D kernel on Y.\n";
#endif
this->m_GPUKernelManager->LaunchKernel2D(m_FilterGPUKernelHandle, m_requestedSize[0], m_requestedSize[2], 16, 16);

//input is already pointing to previous output; change ONLY direction of
// filter
this->m_GPUKernelManager->SetKernelArg( m_FilterGPUKernelHandle, dimArg, sizeof( unsigned int ), &( Z ) );
#ifdef VERBOSE
std::cout << telltale << ". Calling 2D kernel on Z.\n";
#endif
this->m_GPUKernelManager->LaunchKernel2D(m_FilterGPUKernelHandle, m_requestedSize[0], m_requestedSize[1], 16, 16);
}
}
Expand All @@ -443,9 +362,6 @@ void
GPUSmoothingRecursiveYvvGaussianImageFilter< TInputImage, TOutputImage >
::PrintSelf(std::ostream & os, Indent indent) const
{
/*#ifdef VERBOSE
std::cout<< telltale << ". GPUSmoothing::PrintSelf \n";
#endif*/
Superclass::PrintSelf(os, indent);

os << "NormalizeAcrossScale: " << m_NormalizeAcrossScale << std::endl;
Expand Down
Loading

0 comments on commit 57e2a8a

Please sign in to comment.