[ITK Community] Image buffer pointer
Gib Bogle
g.bogle at auckland.ac.nz
Mon Mar 17 00:39:09 EDT 2014
Indeed, Luis, that looks like just what I want!
Thanks
Gib
________________________________
From: Luis Ibanez [luis.ibanez at kitware.com]
Sent: Monday, 17 March 2014 5:29 p.m.
To: Gib Bogle
Cc: community at itk.org
Subject: Re: [ITK Community] Image buffer pointer
Gib
The itkImportImageFilter
http://www.itk.org/Wiki/ITK/Examples/IO/ImportImageFilter
Might be what you are looking for.
Hope this helps
Luis
On Mar 17, 2014 12:24 AM, "Gib Bogle" <g.bogle at auckland.ac.nz<mailto:g.bogle at auckland.ac.nz>> wrote:
Hi,
I am doing manipulations on images by directly accessing the image buffer. When I want to create a new image I currently employ a rather crude method. I allocate a buffer of the right size, create the image in the buffer, then because I do not know how to make itk::Image use this buffer address I allocate the image buffer and copy from my buffer to the new image buffer:
unsigned char *p_u8;
typedef itk::Image<unsigned char,3> ImageType_u8;
ImageType_u8::Pointer im_u8 = ImageType_u8::New();
ImageType_u8::SizeType imsize;
ImageType_u8::IndexType imstart;
ImageType_u8::RegionType imregion;
imsize[0] = width;
imsize[1] = height;
imsize[2] = depth;
imstart[0] = 0;
imstart[1] = 0;
imstart[2] = 0;
imregion.SetSize(imsize);
imregion.SetIndex(imstart);
im_u8->SetRegions(imregion);
im_u8->Allocate();
p_u8 = (unsigned char *)(im_u8->GetBufferPointer());
// copy buffer to p_u8
memcpy(p_u8,buffer,(size_t)(width*height*depth));
This works but is obviously inefficient. Previously the inefficiency didn't bother me,
but now that I'm working with big tiff images I am running out of memory. Is there a way to create an Image
and make it use a buffer that has already been allocated?
Thanks
Gib
_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/cgi-bin/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140317/78c07bdd/attachment-0002.html>
More information about the Community
mailing list