[Insight-users] Memory-mapped images?

Luis Ibanez luis.ibanez at kitware.com
Fri Jun 4 15:37:44 EDT 2004


Hi Demian,

The ImportImageFilter does not make a copy of the buffer,
So, it seems that it will work for what you are trying to
do with mmap().


You probably can run a rapid test modifying the file

    Insight/
       Examples/
             DataRepresentation/
                            Image/Image5.cxx


Just get rid of the memory allocation done in line 178
and replace it with the appropriate call to mmap().

Note that the ownership of the buffer should probably
remain with mmap(), so you may want to change line 237
and put it to "false".  This will prevent the
ImportImageFilter from attempting to release the buffer.

--

If that works, it will actually be pretty easy to create
a modified version of the ImportImageFilter for taking
a filename as argument and do the equivalent mapping.

We will be happy to assist you in writing such a class,
and of course will encourage you to contribute it back
to the Toolkit.


Please let us know what you find,


Regards,



    Luis



-------------------------
Demian M. Nave wrote:

>>If that is the case, what you want to use
>>is the ImportImageFilter
> 
> 
> Hi Luis,
> 
> I want to 'mmap()' a file into memory and use it as an image source without
> having to copy the whole image into memory at once.
> 
> If ImportImageFilter doesn't cause an implicit copying of data into a new
> Image (rather, it uses the pixels from the 'mmap()'ed buffer), then I can
> try that.
> 
> Thanks,
> Demian
> 





More information about the Insight-users mailing list