[Insight-users] Medianfilter:Requested region is outside..

Andreas Schuh andreas.schuh.84 at googlemail.com
Wed Mar 18 16:56:15 EDT 2009


If you have a look at the MITK docu of the Adaptor Classes and the  
macro definition of AccessByItk, you see that you need a

InstantiateAccessFunction(AutomaticSegmentation);

in your source file. Moreover, your access function misses the second  
parameter.

template< class TPixel, unsigned int VDimension >
void AutomaticSegmentation( itk::Image<TPixel, VDimension>* itkImage,  
TPixel* dummy = NULL )
{
   // ...
}

The dummy variable may ensure that the right template instantiation is  
used.

However, you should post your problem to an MITK mailinglist if one  
exists, as the problem doesn't come from ITK.

--
regards
Andreas

Am 18.03.2009 um 15:37 schrieb doege at mi.fu-berlin.de:

> Hi,
>
> 1) I put a try-catch-block around the update
> 2) I tried to call itkImage->Print() and itkImage- 
> >DisconnectPipeline() but I couldn´t call the function. It only work 
> ed
> before I called the function AutomaticSegmentation, which is a  
> template and I some how need it for the itk-stuff. So I guess it has  
> something to do  with calling the template.
>
>
> void QmitkAutomaticSegmentation::ImageSelected(const  
> mitk::DataTreeFilter::Item* item)
> {
>    //mitk::Image* image; ( header file)
>    image = dynamic_cast<mitk::Image*>( item->GetNode()->GetData( ));
> }
> void QmitkAutomaticSegmentation::StartButtonClicked()
> {
>
> ..
>  image->DisconnectPipeline();
>  image->Print();
>  AccessByItk( image, AutomaticSegmentation );
> }
>
> Greetings,
> Juliane
>
>
> Quoting Andreas Schuh <andreas.schuh.84 at googlemail.com>:
>
>> Hi!
>>
>> Ok, actually it would be no good behavior of itk::MedianImageFilter  
>> (or
>> the used itk::NeighborhoodIterator) if it couldn't handle this  
>> degraded
>> case properly.
>>
>> Did you try to embrace the call of the Update() method of the median
>> filter with a try-catch-block to ensure that the problem is this  
>> update?
>> You could print the state of the image regions just before calling
>> update or even in the catch block. To do so use itkImage->Print().
>> As you tried UpdateLargestPossibleRegion() already, the requested
>> region should actually be set to the largest possible region before  
>> the
>> filter is updated.
>> However, if your itkImage that is passed to your
>> AutomaticSegmentation() method is connected to an output of a  
>> previous
>> filter, this filter
>> may be updated as well and modify the requested region. Where does  
>> your
>> itkImage come from?
>> You could try to disconnect it manually, calling
>> itkImage->DisconnectPipeline(), just to track back the error.
>> For instance, call DisconnectPipeline() directly before passing the
>> image to your method.
>>
>> Concluding, my hints to debug the error are:
>>
>> 1. Enclose the update call of the median filter in a try-catch block
>> (catch any itk::ExceptionObject and print the message)
>> 2. Print the state of the image right before the update call and  
>> within
>> the catch block using Print()
>> 3. Disconnect the input image manually from any previous ITK pipeline
>> using DisconnectPipeline()
>>
>>
>> BTW: Your comment "aufrufen des Filters" seems to be accidentally
>> placed on the wrong line ...
>>
>> --
>> regards
>> Andreas
>>
>> doege at mi.fu-berlin.de schrieb:
>>> Sorry, of course I doesn´t want to set it 0,0,0 it was just a tr 
>>> y  after 1,1,1 didn´t work out, and I forgot to set it back, but 
>>>  I got  the same error.
>>>
>>> Quoting Andreas Schuh <andreas.schuh.84 at googlemail.com>:
>>>
>>>> Hi Juliane,
>>>>
>>>> does it make sense that you want to apply the median filter without
>>>> considering any neighborhood?
>>>> What do you think is the median of just a single value?
>>>> That the radius is set to [0, 0, 0] may be your problem.
>>>> Try at least [1, 1, 1] instead, which is the default radius used by
>>>> itk::MedianImageFilter.
>>>>
>>>> -- 
>>>> regards
>>>> Andreas
>>>>
>>>> doege at mi.fu-berlin.de schrieb:
>>>>> Hi Luis,
>>>>>
>>>>> 1. perhaps I was misleading words, I trying to use the   
>>>>> itk::median  filter with mitk and I think that I am getting an   
>>>>> itk error, which  probably means that I am using either itk or   
>>>>> mitk wrong.
>>>>>
>>>>> 2. I am getting the error after using it the first time.
>>>>>
>>>>> 3.:
>>>>> template < typename TPixel, unsigned int VImageDimension >
>>>>> void  
>>>>> QmitkAutomaticSegmentation::AutomaticSegmentation(  itk::Image<   
>>>>> TPixel, VImageDimension >* itkImage )
>>>>> {
>>>>> typedef itk::Image< TPixel, VImageDimension >  
>>>>> InputImageType;  //   Image type
>>>>> typedef itk::Image< TPixel, VImageDimension > OutputImageType;
>>>>> typedef typename InputImageType::IndexType    IndexType;
>>>>>
>>>>> //Median Filter
>>>>> typedef itk::MedianImageFilter<InputImageType, OutputImageType  
>>>>> >   FilterType; //creating Filtertype
>>>>> FilterType::Pointer filter = FilterType::New(); //filter  
>>>>> object   erzeugt filter
>>>>>
>>>>> InputImageType::SizeType indexRadius; //Radius for calculating   
>>>>> the  median filter
>>>>>
>>>>> indexRadius[0] = 0; // radius along x
>>>>> indexRadius[1] = 0; // radius along y
>>>>> indexRadius[2] = 0; // radius along z
>>>>> filter->SetRadius( indexRadius );
>>>>>
>>>>>
>>>>> filter->SetInput( itkImage); //aufrufen des Filters
>>>>>
>>>>> std::cout << "Execute the filter";
>>>>> filter->UpdateLargestPossibleRegion();
>>>>>
>>>>> //filter->Update();
>>>>>
>>>>>
>>>>> mitk::Image::Pointer resultImage =  
>>>>> mitk::ImportItkImage(   filter->GetOutput() );
>>>>> mitk::DataTreeNode::Pointer newNode = mitk::DataTreeNode::New();
>>>>> newNode->SetData( resultImage );
>>>>>
>>>>>
>>>>> mitk::DataTreeNodeFactory::SetDefaultImageProperties( newNode );
>>>>>
>>>>>
>>>>> // add result to data tree
>>>>> mitk::DataStorage::GetInstance()->Add( newNode );
>>>>>
>>>>> mitk::RenderingManager::GetInstance()->RequestUpdateAll();
>>>>> }
>>>>>
>>>>> Best regards
>>>>> Juliane
>>>>>
>>>>> Quoting Luis Ibanez <luis.ibanez at kitware.com>:
>>>>>
>>>>>>
>>>>>> Hi Juliane,
>>>>>>
>>>>>>
>>>>>> 1) Why are you implementing a median filter ?
>>>>>>
>>>>>> Is there are reason why the current MedianFilter in ITK
>>>>>> is not suitable for what you are doing ?
>>>>>>
>>>>>>
>>>>>> 2) Do you get that error message after running the
>>>>>> filter multiple times ?
>>>>>>
>>>>>> or do you get that error in the first run of the filter  ?
>>>>>>
>>>>>>
>>>>>> 3) Can you please post to the list the code of your filter ?
>>>>>>
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>>     Luis
>>>>>>
>>>>>>
>>>>>>
>>>>>> -----------------------------
>>>>>> doege at mi.fu-berlin.de wrote:
>>>>>>> Hello,
>>>>>>>
>>>>>>> I am trying to implement a median filter with mitk and  
>>>>>>> getting   the   following itk error:
>>>>>>> ..\..\..\source\Code\Common\itkDataObject.cxx:
>>>>>>> 397:Requested region is (at least partially) outside the   
>>>>>>> largest   possible region.
>>>>>>>
>>>>>>> I tried to update only the largest possible region but i 
>>>>>>> t  didn´t   work  either. Does anyone got another idea?  
>>>>>>> I also  couldn´t find   out how to  print out the size o 
>>>>>>> f the region.
>>>>>>> I am using dicom images with more than 4 slices.
>>>>>>>
>>>>>>> Best regards
>>>>>>> Juliane
>>>>>>>
>>>>>>> ----------------------------------------------------------------
>>>>>>> This message was sent using IMP, the Internet Messaging Program.
>>>>>>>
>>>>>>> _____________________________________
>>>>>>> Powered by www.kitware.com
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at
>>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>>
>>>>>>> Please keep messages on-topic and check the ITK FAQ at:    http://www.itk.org/Wiki/ITK_FAQ
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ----------------------------------------------------------------
>>>>> This message was sent using IMP, the Internet Messaging Program.
>>>>>
>>>>> _____________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the ITK FAQ at:   http://www.itk.org/Wiki/ITK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>>
>>> ----------------------------------------------------------------
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:  http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>


More information about the Insight-users mailing list