[Insight-users] itkImageSource for block of memory
Daniel Blezek
Blezek.Daniel at mayo.edu
Fri Jun 19 09:38:07 EDT 2009
Hi Koen,
On 6/19/09 6:38 AM, "Koen Vermeer" <koen at vermeer.tv> wrote:
> On Fri, 2009-06-19 at 07:14 -0400, Bill Lorensen wrote:
>> Take a look at BasicFilters/itkImportImageFilter
>
> Cool! What about the other way around, like itkExportImageFilter? It
> seems that I cannot find it, but maybe something similar exists with a
> different name?
We do exactly the same thing as you, i.e. use ITK from a different
application. For the output, to avoid duplicating memory, we do something
like this:
// Allocate output ImageBuffer
ImageBuffer = new T[NumberOfPixels];
itkImage = filter->GetOutput()
itkImage->GetPixelContainer()->SetImportPointer ( (T*)ImageBuffer,
NumberOfPixels, false );
itkImage->Allocate();
This creates the buffer, and asks ITK to use it.
NB: ITK will re-allocate the output if the size changes, so you have to
check in the itkImage is still using your memory.
if ( itkImage->GetBufferPointer() != ImageBuffer ) {
// Copy from ITK to your output
} else {
// All is happy
}
Cheers,
-dan
--
Daniel Blezek, PhD
Medical Imaging Informatics Innovation Center
P 127 or (77) 8 8886
T 507 538 8886
E blezek.daniel at mayo.edu
Mayo Clinic
200 First St. S.W.
Harwick SL-44
Rochester, MN 55905
mayoclinic.org
More information about the Insight-users
mailing list