[Insight-developers] Re: [Insight-users] CannyEdgeDetectionImageFilter GraftOutput() bug?

Karthik Krishnan Karthik.Krishnan at kitware.com
Tue Nov 15 18:15:02 EST 2005


Hi,

Ok. Thanks for pointing this out.

There are  bugs in the canny filter. The Canny filter allocates its own 
output internally and grafts its output from that allocated output 
(m_UpdateBuffer) as you've pointed out. m_UpdateBuffer should graft the 
filter's output prior to execution.

The region propagation is also messed up, at times it takes it from the 
input/ switches back and forth to use the output regions. And the cvs 
logs seem to have made a few changes multiple times to fix it, but I am 
not sure if they did the right thing in the end.

I've logged an entry in the bug tracker and I'll try to fix it soon.

Regards
karthik


Quan Chen wrote:

>Well, I just follow the itkFilterlib example to build a library.
>Could you attach the updated files to me?  I don't have immediate access to
>CVS.  
>BTW, I use the method of "g_OutputImage=cannyFilter->GetOutput();
>g_OutputImage->DisconnectPipeline();
>return(g_OutputImage->GetBufferPointer());" to return data yesterday.  It
>works fine, but somehow it didn't work today.  It still calculates but what
>I got is all 0. 
>
>BTW, I have another experience of strang behavior in CannyEdgeDection.  When
>I re-use the filter with a different size image as input, the output edge
>seems have some residue from the last calculation overlap with the new edge
>(only a small region in the last several slice).  I try to call
>updatelargestpossibleregion() but it doesn't help.  I also try to set
>Modified() flag and still no improvement.  It seems that I have to call it
>twice to get it straight out.  I am wondering if it is because the extra
>buffers were not re-allocated correctly? Or it involve multithread (since
>the affected area seems small).
>
>
>
>
>-----Original Message-----
>From: Karthik Krishnan [mailto:Karthik.Krishnan at kitware.com] 
>Sent: Wednesday, November 09, 2005 5:27 PM
>To: Quan Chen
>Cc: insight-users at itk.org; Luis Ibanez
>Subject: Re: [Insight-users] CannyEdgeDetectionImageFilter GraftOutput()
>bug?
>
>
>Thanks. That was  a bug. There was no need for the output to be 
>allocated. Its fixed in CVS.
>
>How were you trying to graft the output ?
>
>thanks
>karthik
>
>Quan Chen wrote:
>
>  
>
>>I was trying to use GraftOutput() to set the output of
>>CannyEdgeDetectionImageFilter.  However, I find that the image does 
>>not change.  I did same thing for other filters like Sigmoid and 
>>AnisotropicDiffusion, and they worked well.  If I 
>>use  g_OutputImage=cannyFilter->GetOutput();
>>    
>>
>g_OutputImage->DisconnectPipeline(); 
>  
>
>>it worked well. 
>> 
>>I read the CannyEdgeDetection code for a while.  Because I am still
>>not familiar with the ITK architecture, I am not sure about my 
>>findings.  But it seems to me that the beginning of the GenerateData() 
>>function just re-allocate the output buffer:
>>template< class TInputImage, class TOutputImage >
>>void
>>CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >
>>::GenerateData()
>>{
>>  // Need to allocate output buffer
>>  typename OutputImageType::Pointer output = this->GetOutput();
>>  output->SetBufferedRegion(output->GetRequestedRegion());
>>  output->Allocate();
>> 
>> 
>>And at last line
>> 
>>  this->GraftOutput(m_UpdateBuffer);
>> 
>>Sets the output buffer to be m_UpdateBuffer.
>>Both m_UpdateBuffer and m_UpdateBuffer1 was allocated in
>>AllocateUpdateBuffer():
>> 
>>
>>template <class TInputImage, class TOutputImage>
>>void
>>CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>
>>::AllocateUpdateBuffer()
>>{
>>  // The update buffer looks just like the input.
>>
>>  typename TInputImage::ConstPointer input = this->GetInput();
>>
>>  m_UpdateBuffer->CopyInformation( input );
>>  m_UpdateBuffer->SetRequestedRegion(input->GetRequestedRegion());
>>  m_UpdateBuffer->SetBufferedRegion(input->GetBufferedRegion());
>>  m_UpdateBuffer->Allocate();
>> 
>>  m_UpdateBuffer1->CopyInformation( input );
>>  m_UpdateBuffer1->SetRequestedRegion(input->GetRequestedRegion());
>>  m_UpdateBuffer1->SetBufferedRegion(input->GetBufferedRegion());
>>  m_UpdateBuffer1->Allocate();
>>}
>>
>>Can anyone from development team confirm it is sth wrong with the
>>code?  Or it just I use it incorrectly.
>>
>> 
>>
>> 
>> 
>>
>>-----------------------------------------------------------------------
>>-
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org http://www.itk.org/mailman/listinfo/insight-users
>> 
>>
>>    
>>
>
>
>  
>


More information about the Insight-developers mailing list