Thanks everyone.
I have implemented something like this:
https://gist.github.com/1113999
<https://gist.github.com/1113999>(thanks Sascha).
With the main function being:
template<typename TPixel, unsigned int VImageDimension>
void
MIDASMorphologicalSegmentorView
::InvokeITKPipeline(itk::Image<TPixel, VImageDimension>* itkImage,
mitk::Image::Pointer& output)
{
std::stringstream key;
key << typeid(TPixel).name() << VImageDimension;
MorphologicalSegmentorPipeline<TPixel, VImageDimension>* pipeline = NULL;
MorphologicalSegmentorPipelineInterface* myPipeline = NULL;
std::map<std::string, MorphologicalSegmentorPipelineInterface*>::iterator
iter;
iter = m_TypeToPipelineMap.find(key.str());
if (iter == m_TypeToPipelineMap.end())
{
pipeline = new MorphologicalSegmentorPipeline<TPixel, VImageDimension>();
myPipeline = pipeline;
m_TypeToPipelineMap.insert(StringAndPipelineInterfacePair(key.str(),
myPipeline));
pipeline->m_ThresholdingFilter->SetInput(itkImage);
}
else
{
myPipeline = iter->second;
pipeline = static_cast<MorphologicalSegmentorPipeline<TPixel,
VImageDimension>*>(myPipeline);
}
MorphologicalSegmentorPipelineParams params;
params.m_Stage = this->m_MorphologicalControls->GetTabNumber();
params.m_LowerIntensityThreshold =
this->m_MorphologicalControls->m_ThresholdingLowerThresholdSlider->value();
params.m_UpperIntensityThreshold =
this->m_MorphologicalControls->m_ThresholdingUpperThresholdSlider->value();
// Lots of extra parameters here
myPipeline->SetParam(params);
myPipeline->Update();
//output = mitk::ImportItkImage( pipeline->GetOutput() );
mitk::CastToMitkImage(pipeline->GetOutput(), output);
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
This works fine, except that I would like to avoid the CastToMitkImage, as the
pointer provided to this function is already allocated to the correct size
image.
I don't want to repeatedly delete/re-allocate memory each time my pipeline runs.
Is this possible?
Thanks as always.
Matt
------------------------------------------------------
Matt Clarkson Ph.D.
CMIC Software Manager
Senior Research Associate
[email protected]<mailto:[email protected]>
Centre For Medical Image Computing
http://cmic.cs.ucl.ac.uk/staff/matt_clarkson/<http://cmic.cs.ucl.ac.uk/>
Tel: 020 7679 0221
Fax: 020 7679 0255
Dementia Research Centre
http://dementia.ion.ucl.ac.uk/
Tel: 08451 555 000 ext. 723653
Fax: 020 7676 2066
------------------------------------------------------
On 1 Aug 2011, at 10:30, Sascha Zelzer wrote:
Hi,
for in-place filters there is no problem. However, if you are creating a
more complicated pipeline, with no in-place intermediate filters, it
gets more complicated.
Currently, if you access MITK images via an AccessByITK macro call, you
usually call a function/method which locally instantiates the ITK filter
pipeline (as Matt figured out correctly). Therefore, the output images
are repeatedly newly allocated and putting the output ITK image in a
MITK image will not reuse the memory from the "old" MITK image which
might have been put in a MITK data node already.
Sascha
On 08/01/2011 11:16 AM, Daniel Maleike wrote:
On 08/01/2011 11:00 AM, Peter Neher wrote:
Hi Matt,
I think you could work directly on the input segmentation image without
creating any output. This way you avoid the allocation of an unnecessary
second image.
Some ITK filters have an in-place options, which would do exactly what
you are looking for, i.e. modifying their input instead of allocating a
new output.
Daniel
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users