<div dir="ltr">Hello, <div><br></div><div>I am currently trying to get a derivative filter working. I have implemented the following function: </div><div><br></div><div><div>void</div><div>DepthDerivative::ForwardDifferenceDerivative( const ScalarImage::Pointer input_depth_map, GradientImage* const gradient_image )</div>
<div>{</div><div><span class="" style="white-space:pre">    </span>DLOG(INFO) << "Setting up Forward Difference Derivative";</div><div><span class="" style="white-space:pre">  </span>// Setup the Derivative Operator, and set its radius to 1. This will give us a kernel that is</div>
<div><span class="" style="white-space:pre">    </span>// 3px x 3px.</div><div><span class="" style="white-space:pre">      </span>typedef itk::ForwardDifferenceOperator<unsigned char, 2> DerivativeOperator;</div><div><span class="" style="white-space:pre"> </span>itk::Size<2> derivative_kernel_radius;</div>
<div><span class="" style="white-space:pre">    </span>derivative_kernel_radius.Fill( 1 );</div><div><br></div><div><span class="" style="white-space:pre">       </span>DLOG(INFO) << "Creating X Derivative Operator";</div>
<div><span class="" style="white-space:pre">    </span>// Compute the derivative in the X direction.</div><div><span class="" style="white-space:pre">      </span>DerivativeOperator DerivativeX;</div><div><span class="" style="white-space:pre">    </span>DerivativeX.SetDirection( 0 );</div>
<div><span class="" style="white-space:pre">    </span>DerivativeX.CreateToRadius( derivative_kernel_radius );</div><div><br></div><div><span class="" style="white-space:pre">   </span>DLOG(INFO) << "Computing X Derivative";</div>
<div><span class="" style="white-space:pre">    </span>typedef itk::NeighborhoodOperatorImageFilter<ScalarImage, ScalarImage> NeighborhoodImageFilter;</div><div><span class="" style="white-space:pre">      </span>NeighborhoodImageFilter::Pointer DerivativeXFilter = NeighborhoodImageFilter::New();</div>
<div><span class="" style="white-space:pre">    </span>DerivativeXFilter->SetOperator( DerivativeX );</div><div><span class="" style="white-space:pre">  </span>DerivativeXFilter->SetInput( input_depth_map );</div><div><span class="" style="white-space:pre"> </span>DLOG(INFO) << "Primary is set: " << (bool)DerivativeXFilter->HasInput( "Primary" );</div>
<div><span class="" style="white-space:pre">    </span>DerivativeXFilter->Update();</div><div><br></div><div>#ifndef NDEBUG</div><div><span class="" style="white-space:pre">      </span>DLOG(INFO) << "Saving X Derivative to File";</div>
<div><span class="" style="white-space:pre">    </span>SaveImage( DerivativeXFilter->GetOutput(), "xDerivative.png" );</div><div>#endif</div></div><div><br></div><div><br></div><div>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: </div>
<div><br></div><div><div>badrobit@Ubuntu:build {master} $ ./InpaintingDemo </div><div>I0712 01:52:24.366832 19445 DepthDerivative.cpp:21] Debugging Enabled, Logs will also output to Terminal</div><div>I0712 01:52:24.366889 19445 DepthDerivative.cpp:27] DephDerivative Initialized</div>
<div>I0712 01:52:24.366901 19445 Helpers.hpp:62] Starting Image File Read of: data/test.png</div><div>I0712 01:52:24.367377 19445 Helpers.hpp:76] Reading in of Image: data/test.png is completed</div><div>I0712 01:52:24.367399 19445 DepthDerivative.cpp:59] Setting up Forward Difference Derivative</div>
<div>I0712 01:52:24.367408 19445 DepthDerivative.cpp:66] Creating X Derivative Operator</div><div>I0712 01:52:24.367425 19445 DepthDerivative.cpp:72] Computing X Derivative</div><div>I0712 01:52:24.367441 19445 DepthDerivative.cpp:77] Primary is set: 1</div>
<div>terminate called after throwing an instance of 'itk::ExceptionObject'</div><div>  what():  /home/badrobit/InsightToolkit-4.4.2/Modules/Core/Common/src/itkProcessObject.cxx:1380:</div><div>itk::ERROR: NeighborhoodOperatorImageFilter(0x26fe4f0): Input Primary is required but not set.</div>
<div>Aborted (core dumped)</div></div><div><br></div><div>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. </div>
<div><br></div><div>Thanks in advance!</div><div>Mat Roscoe</div></div>