[Insight-users] fast assign ITK image to an array?

Neil Panjwani paniwani at gmail.com
Sun Apr 17 14:11:11 EDT 2011


I have some code that treats images as arrays. Using GetBufferPointer()
works perfectly. You can in fact set the value using the normal notation:

PixelType * imgArray = img->GetBufferPointer();

imgArray[100] = 1;

I don't think there is any padding. I'm unfamiliar with the
ImportImageFilter.

- Neil

On Sun, Apr 17, 2011 at 5:06 AM, Francis Girard
<francis.girard07 at gmail.com>wrote:

> Hi,
>
> Can we iterate safely using this raw buffer pointer?
>
> Maybe there is some padding to ensure some byte alignment property?
>
> Also if there is a GetBufferPointer notice that there is no
> SetBufferPointer. So I don't think you can just set some buffer pointer as
> is the case with some C++ STL containers. With that API, you will at least
> need to make a copy of the contents, and even then we must make sure that
> there is enough allocated memory.
>
> After all, what would be the usefulness of the "ImportImageFilter" if we
> could simply and safely set a raw buffer pointer?
>
> And finally what precisely the  "ImportImageFilter" does under the hood?
> Apprently it does _NOT_ make a copy of your buffer pointer. So maybe that is
> fast. But I am not sure of what I am saying.
>
> Thanks
>
> Francis
>
>
>
>
> 2011/4/17 Neil Panjwani <paniwani at gmail.com>
>
>> You can access the image in 1D C++ array form using the GetBuferPointer()
>> function.
>>
>> - Neil
>>
>>
>> On Sat, Apr 16, 2011 at 8:53 PM, Dongfeng Han <handongfeng at gmail.com>wrote:
>>
>>> Hello everyone,
>>> Anyone know how to fast assign ITK image data to an c++ array?
>>> The common approach is to use the iterator of  the ITK image and assign
>>> the c++ array.
>>> Any other fast way?
>>> Best
>>> df
>>>
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.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
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110417/57645f7c/attachment.htm>


More information about the Insight-users mailing list