[ITK-users] Run Time Errors with NeighborhoodOperatorImageFilter

Matthew Roscoe mat.roscoe at unb.ca
Sat Jul 12 00:58:02 EDT 2014


Hello,

I am currently trying to get a derivative filter working. I have
implemented the following function:

void
DepthDerivative::ForwardDifferenceDerivative( const ScalarImage::Pointer
input_depth_map, GradientImage* const gradient_image )
{
DLOG(INFO) << "Setting up Forward Difference Derivative";
// Setup the Derivative Operator, and set its radius to 1. This will give
us a kernel that is
// 3px x 3px.
typedef itk::ForwardDifferenceOperator<unsigned char, 2> DerivativeOperator;
itk::Size<2> derivative_kernel_radius;
derivative_kernel_radius.Fill( 1 );

DLOG(INFO) << "Creating X Derivative Operator";
// Compute the derivative in the X direction.
DerivativeOperator DerivativeX;
DerivativeX.SetDirection( 0 );
DerivativeX.CreateToRadius( derivative_kernel_radius );

DLOG(INFO) << "Computing X Derivative";
typedef itk::NeighborhoodOperatorImageFilter<ScalarImage, ScalarImage>
NeighborhoodImageFilter;
NeighborhoodImageFilter::Pointer DerivativeXFilter =
NeighborhoodImageFilter::New();
DerivativeXFilter->SetOperator( DerivativeX );
DerivativeXFilter->SetInput( input_depth_map );
DLOG(INFO) << "Primary is set: " << (bool)DerivativeXFilter->HasInput(
"Primary" );
DerivativeXFilter->Update();

#ifndef NDEBUG
DLOG(INFO) << "Saving X Derivative to File";
SaveImage( DerivativeXFilter->GetOutput(), "xDerivative.png" );
#endif


I have done this using the examples on the ITK website. I have also
downloaded the example for NeighborhoodOperatorImageFilter and it functions
properly. Running this code I get the following output:

badrobit at Ubuntu:build {master} $ ./InpaintingDemo
I0712 01:52:24.366832 19445 DepthDerivative.cpp:21] Debugging Enabled, Logs
will also output to Terminal
I0712 01:52:24.366889 19445 DepthDerivative.cpp:27] DephDerivative
Initialized
I0712 01:52:24.366901 19445 Helpers.hpp:62] Starting Image File Read of:
data/test.png
I0712 01:52:24.367377 19445 Helpers.hpp:76] Reading in of Image:
data/test.png is completed
I0712 01:52:24.367399 19445 DepthDerivative.cpp:59] Setting up Forward
Difference Derivative
I0712 01:52:24.367408 19445 DepthDerivative.cpp:66] Creating X Derivative
Operator
I0712 01:52:24.367425 19445 DepthDerivative.cpp:72] Computing X Derivative
I0712 01:52:24.367441 19445 DepthDerivative.cpp:77] Primary is set: 1
terminate called after throwing an instance of 'itk::ExceptionObject'
  what():
 /home/badrobit/InsightToolkit-4.4.2/Modules/Core/Common/src/itkProcessObject.cxx:1380:
itk::ERROR: NeighborhoodOperatorImageFilter(0x26fe4f0): Input Primary is
required but not set.
Aborted (core dumped)

As you can see I am pretty confused because I check before running Update()
if Primary has been set and the function is telling me that it is but as
soon as I run Update() it disappears... This behaviour is exactly the same
in ITK4.5.2 in case you saw the older build number. I am really at a loss
for what to do and I am hoping that the community might be able to help me
out.

Thanks in advance!
Mat Roscoe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20140712/4517ad8f/attachment.html>


More information about the Insight-users mailing list