help for rendering a large amount of images

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

help for rendering a large amount of images

Henry Blanco
Hello guys, I need some hints on how to render a large amount of images
(e.g., thousands of images) using just few RAM resources (e.g., 128 MB)
using the vtkImageReslice class for the whole volume.

Thanks in advance

Henry

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

David Gobbi
What kind of views will you need?  Do you just have to view the original
slices?  If so, then the VTK pipeline's streaming will make the job easy.
If you need orthogonal or oblique views, things are more difficult.  Also,
how is the data stored on disk?  If the whole volume is stored on disk
as a single flat file, then you can memory map the file.

 - David

On Mon, Nov 2, 2015 at 4:10 PM, Henry Blanco <[hidden email]> wrote:
Hello guys, I need some hints on how to render a large amount of images
(e.g., thousands of images) using just few RAM resources (e.g., 128 MB)
using the vtkImageReslice class for the whole volume.

Thanks in advance

Henry

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

David Gobbi
Hi Henry,

Please reply to the vtk list, not just to me.

You're requirement of rendering "thousands of medical images" is
way too vague.  Do you need to render them all simultaneously,
i.e. will they all be on screen at the same time?  I really do not
understand what you are trying to do.

The vtkImageDataStreamer will be no help to you, because it always
loads the entire volume.  It's job is to pull the data through the pipeline
in small chunks, but the end result is still that the whole volume ends
up in memory.

Yes, vtkImageReslice can show a sagittal or coronal view by only
streaming a small part of the volume into memory, but this will only
work with certain reader classes.  For example, the vtkTIFFReader
always reads entire slices, so it cannot read just one row of a
slice that vtkImageReslice can then incorporate into a sagittal view.
In fact, I think that only vtkImageReader2 can stream individual
rows or columns of an image from disk.  The other readers can
only stream the data slice-by-slice.

You should seriously consider my recommendation of using memory
mapping.  If you simply map a flat file to a memory address and then
use that memory address as a pixel data inside a vtkImageData, then
the operating system can make all the decisions about how and when
to load the data from disk.

 - David


On Tue, Nov 3, 2015 at 10:33 AM, Henry Blanco <[hidden email]> wrote:
Thanks David for your soon reply. Ok, my problem is to load and render thousands of medical images,
organized into series, by using VTK, but considering strong limitations
in terms of RAM (e.g., only 128 or 256 MB of RAM available).

To achieve this task, we have tried to use the "vtkImageDataStreamer"
class, but we have failed. This class seems to load the whole volume into
memory, therefore loading 2000 CT images (1GB) into memory may fail if
we consider just 128 MB of RAM.

We are thinking to partition the whole volume into K blocks and to load
a block of images into memory just when it's needed. The illusion of
having the whole volume loaded in memory could be achieved by
uploading/downloading one or more blocks of images to/from memory when
needed. I'm wondering whether exist some vtk classes which can be used
to picture a different view than the original (e.g., sagittal, coronal,
or even oblique) without loading the whole volume of images.

Henry

On lun, 2015-11-02 at 17:29 -0700, David Gobbi wrote:
> What kind of views will you need?  Do you just have to view the
> original
> slices?  If so, then the VTK pipeline's streaming will make the job
> easy.
> If you need orthogonal or oblique views, things are more difficult.
> Also,
> how is the data stored on disk?  If the whole volume is stored on disk
> as a single flat file, then you can memory map the file.
>
>
>  - David
>
> On Mon, Nov 2, 2015 at 4:10 PM, Henry Blanco <[hidden email]>
> wrote:
>         Hello guys, I need some hints on how to render a large amount
>         of images
>         (e.g., thousands of images) using just few RAM resources
>         (e.g., 128 MB)
>         using the vtkImageReslice class for the whole volume.
>
>         Thanks in advance
>
>         Henry





_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

Henry Blanco
In reply to this post by David Gobbi
Thanks David for your soon reply. My problem is to load and render
thousands of medical images, organized into series, by using VTK, but
considering strong limitations in terms of RAM (e.g., only 128 or 256 MB
of RAM available).

To achieve this task, we have tried to use the "vtkImageDataStreamer"
class, but we have failed. This class seems to load the whole volume
into memory, therefore loading 2000 CT images (1GB) into memory may fail
if we just consider 128 MB of RAM.

We are thinking to split the whole volume into K blocks and to load
a block of images into memory just when it's needed. The illusion of
having the whole volume loaded in memory could be achieved by
uploading/downloading one or more blocks of images to/from memory when
needed. We're wondering whether exists some vtk classes which can be
used to picture a view different than the original one (e.g., sagittal,
coronal, or even oblique view) without loading the whole volume of
images into memory.

Henry

On mar, 2015-11-03 at 12:33 -0500, Henry Blanco wrote:

> Thanks David for your soon reply. Ok, my problem is to load and render thousands of medical images,
> organized into series, by using VTK, but considering strong limitations
> in terms of RAM (e.g., only 128 or 256 MB of RAM available).
>
> To achieve this task, we have tried to use the "vtkImageDataStreamer"
> class, but we have failed. This class seems to load the whole volume into
> memory, therefore loading 2000 CT images (1GB) into memory may fail if
> we consider just 128 MB of RAM.
>
> We are thinking to partition the whole volume into K blocks and to load
> a block of images into memory just when it's needed. The illusion of
> having the whole volume loaded in memory could be achieved by
> uploading/downloading one or more blocks of images to/from memory when
> needed. I'm wondering whether exist some vtk classes which can be used
> to picture a different view than the original (e.g., sagittal, coronal,
> or even oblique) without loading the whole volume of images.
>
> Henry
>
> On lun, 2015-11-02 at 17:29 -0700, David Gobbi wrote:
> > What kind of views will you need?  Do you just have to view the
> > original
> > slices?  If so, then the VTK pipeline's streaming will make the job
> > easy.
> > If you need orthogonal or oblique views, things are more difficult.
> > Also,
> > how is the data stored on disk?  If the whole volume is stored on disk
> > as a single flat file, then you can memory map the file.
> >
> >
> >  - David
> >
> > On Mon, Nov 2, 2015 at 4:10 PM, Henry Blanco <[hidden email]>
> > wrote:
> >         Hello guys, I need some hints on how to render a large amount
> >         of images
> >         (e.g., thousands of images) using just few RAM resources
> >         (e.g., 128 MB)
> >         using the vtkImageReslice class for the whole volume.
> >        
> >         Thanks in advance
> >        
> >         Henry
>
>


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

Henry Blanco
In reply to this post by David Gobbi
Hello David, thanks for your help and sorry for the late reply, I've
been absent for a couple of days.
Well we're newbies on vtk, ... therefore it would nice if you give us
more details on:
1- How to create a flat file from several images. I guess we have to use
some vtk classes, but we don't know which one.
2- How to achieve the mapping from the flat file memory address to the
vtkImageData.

Thanks in advance,

Henry

On mar, 2015-11-03 at 11:03 -0700, David Gobbi wrote:

> Hi Henry,
>
>
> Please reply to the vtk list, not just to me.
>
>
> You're requirement of rendering "thousands of medical images" is
> way too vague.  Do you need to render them all simultaneously,
> i.e. will they all be on screen at the same time?  I really do not
> understand what you are trying to do.
>
>
> The vtkImageDataStreamer will be no help to you, because it always
> loads the entire volume.  It's job is to pull the data through the
> pipeline
> in small chunks, but the end result is still that the whole volume
> ends
> up in memory.
>
>
> Yes, vtkImageReslice can show a sagittal or coronal view by only
> streaming a small part of the volume into memory, but this will only
> work with certain reader classes.  For example, the vtkTIFFReader
> always reads entire slices, so it cannot read just one row of a
> slice that vtkImageReslice can then incorporate into a sagittal view.
> In fact, I think that only vtkImageReader2 can stream individual
> rows or columns of an image from disk.  The other readers can
> only stream the data slice-by-slice.
>
>
> You should seriously consider my recommendation of using memory
> mapping.  If you simply map a flat file to a memory address and then
> use that memory address as a pixel data inside a vtkImageData, then
> the operating system can make all the decisions about how and when
> to load the data from disk.
>
>
>  - David
>
>
>
> On Tue, Nov 3, 2015 at 10:33 AM, Henry Blanco
> <[hidden email]> wrote:
>         Thanks David for your soon reply. Ok, my problem is to load
>         and render thousands of medical images,
>         organized into series, by using VTK, but considering strong
>         limitations
>         in terms of RAM (e.g., only 128 or 256 MB of RAM available).
>        
>         To achieve this task, we have tried to use the
>         "vtkImageDataStreamer"
>         class, but we have failed. This class seems to load the whole
>         volume into
>         memory, therefore loading 2000 CT images (1GB) into memory may
>         fail if
>         we consider just 128 MB of RAM.
>        
>         We are thinking to partition the whole volume into K blocks
>         and to load
>         a block of images into memory just when it's needed. The
>         illusion of
>         having the whole volume loaded in memory could be achieved by
>         uploading/downloading one or more blocks of images to/from
>         memory when
>         needed. I'm wondering whether exist some vtk classes which can
>         be used
>         to picture a different view than the original (e.g., sagittal,
>         coronal,
>         or even oblique) without loading the whole volume of images.
>        
>         Henry
>        
>         On lun, 2015-11-02 at 17:29 -0700, David Gobbi wrote:
>         > What kind of views will you need?  Do you just have to view
>         the
>         > original
>         > slices?  If so, then the VTK pipeline's streaming will make
>         the job
>         > easy.
>         > If you need orthogonal or oblique views, things are more
>         difficult.
>         > Also,
>         > how is the data stored on disk?  If the whole volume is
>         stored on disk
>         > as a single flat file, then you can memory map the file.
>         >
>         >
>         >  - David
>         >
>         > On Mon, Nov 2, 2015 at 4:10 PM, Henry Blanco
>         <[hidden email]>
>         > wrote:
>         >         Hello guys, I need some hints on how to render a
>         large amount
>         >         of images
>         >         (e.g., thousands of images) using just few RAM
>         resources
>         >         (e.g., 128 MB)
>         >         using the vtkImageReslice class for the whole
>         volume.
>         >
>         >         Thanks in advance
>         >
>         >         Henry
>        
>        
>        
>        
>
>


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

David Gobbi
Hi Henry,

A "flat file" is a file whose layout on disk is identical to the needed
layout of the data in memory.  A flat file can be "memory mapped"
so that data in the file can be accessed via a C/C++ pointer, even
without loading the whole file into memory.

Memory mapping and flat files are not part of VTK, so you have
to create the flat file and memory-map it _before_ you pass the
memory pointer to VTK.  For more information on memory mapping,

As an example, here is how I use a flat file with VTK in Python,
in order to display a very large RGB image:

    import mmap
    import vtk
    
    f = open("earth.21601x10801.bin","rb")
    memory = mmap.mmap(f.fileno(),0,mmap.MAP_PRIVATE,mmap.PROT_READ)
    
    importer = vtk.vtkImageImport()
    importer.SetImportVoidPointer(memory)
    importer.SetDataScalarTypeToUnsignedChar()
    importer.SetNumberOfScalarComponents(3)
    importer.SetDataExtent(0,21600,0,10800,0,0)
    importer.SetWholeExtent(0,21600,0,10800,0,0)
    importer.SetDataOrigin(0,0,0)
    importer.SetDataSpacing(1,1,1)
    
    reslice = vtkImageReslice()
    reslice.SetInputConnection(importer.GetOutputPort())
    # etcetera

The same concept can be used in C++, you just need to store your
entire data set as a huge flat file, use "mmap" (or an equivalent
function) to map the file to memory, and then use vtkImageImport
to allow the VTK pipeline to use the file as virtual memory.

My advice is to read as much as you can about memory mapping
and about how computers use virtual memory.  This will be very
useful knowledge if you are using a computer with limited memory.

 - David



On Fri, Nov 6, 2015 at 8:52 AM, Henry Blanco <[hidden email]> wrote:
Hello David, thanks for your help and sorry for the late reply, I've
been absent for a couple of days.
Well we're newbies on vtk, ... therefore it would nice if you give us
more details on:
1- How to create a flat file from several images. I guess we have to use
some vtk classes, but we don't know which one.
2- How to achieve the mapping from the flat file memory address to the
vtkImageData.

Thanks in advance,

Henry

On mar, 2015-11-03 at 11:03 -0700, David Gobbi wrote:
> Hi Henry,
>
>
> Please reply to the vtk list, not just to me.
>
>
> You're requirement of rendering "thousands of medical images" is
> way too vague.  Do you need to render them all simultaneously,
> i.e. will they all be on screen at the same time?  I really do not
> understand what you are trying to do.
>
>
> The vtkImageDataStreamer will be no help to you, because it always
> loads the entire volume.  It's job is to pull the data through the
> pipeline
> in small chunks, but the end result is still that the whole volume
> ends
> up in memory.
>
>
> Yes, vtkImageReslice can show a sagittal or coronal view by only
> streaming a small part of the volume into memory, but this will only
> work with certain reader classes.  For example, the vtkTIFFReader
> always reads entire slices, so it cannot read just one row of a
> slice that vtkImageReslice can then incorporate into a sagittal view.
> In fact, I think that only vtkImageReader2 can stream individual
> rows or columns of an image from disk.  The other readers can
> only stream the data slice-by-slice.
>
>
> You should seriously consider my recommendation of using memory
> mapping.  If you simply map a flat file to a memory address and then
> use that memory address as a pixel data inside a vtkImageData, then
> the operating system can make all the decisions about how and when
> to load the data from disk.
>
>
>  - David
>
>
>
> On Tue, Nov 3, 2015 at 10:33 AM, Henry Blanco
> <[hidden email]> wrote:
>         Thanks David for your soon reply. Ok, my problem is to load
>         and render thousands of medical images,
>         organized into series, by using VTK, but considering strong
>         limitations
>         in terms of RAM (e.g., only 128 or 256 MB of RAM available).
>
>         To achieve this task, we have tried to use the
>         "vtkImageDataStreamer"
>         class, but we have failed. This class seems to load the whole
>         volume into
>         memory, therefore loading 2000 CT images (1GB) into memory may
>         fail if
>         we consider just 128 MB of RAM.
>
>         We are thinking to partition the whole volume into K blocks
>         and to load
>         a block of images into memory just when it's needed. The
>         illusion of
>         having the whole volume loaded in memory could be achieved by
>         uploading/downloading one or more blocks of images to/from
>         memory when
>         needed. I'm wondering whether exist some vtk classes which can
>         be used
>         to picture a different view than the original (e.g., sagittal,
>         coronal,
>         or even oblique) without loading the whole volume of images.
>
>         Henry
>
>         On lun, 2015-11-02 at 17:29 -0700, David Gobbi wrote:
>         > What kind of views will you need?  Do you just have to view
>         the
>         > original
>         > slices?  If so, then the VTK pipeline's streaming will make
>         the job
>         > easy.
>         > If you need orthogonal or oblique views, things are more
>         difficult.
>         > Also,
>         > how is the data stored on disk?  If the whole volume is
>         stored on disk
>         > as a single flat file, then you can memory map the file.
>         >
>         >
>         >  - David
>         >
>         > On Mon, Nov 2, 2015 at 4:10 PM, Henry Blanco
>         <[hidden email]>
>         > wrote:
>         >         Hello guys, I need some hints on how to render a
>         large amount
>         >         of images
>         >         (e.g., thousands of images) using just few RAM
>         resources
>         >         (e.g., 128 MB)
>         >         using the vtkImageReslice class for the whole
>         volume.
>         >
>         >         Thanks in advance
>         >
>         >         Henry
>
>
>
>
>
>


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Ang
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

Ang
Hi David,

Could you give me advanced tips for memory mapping file ?

in my understanding, the process is

vtkDICOMReader(retrieve pixel data)  =>  CreateFileMapping => MapViewOfFile => put the pixel data into  File => OpenFileMapping => MapViewOfFile => vtkImageImport => vtkImageReslice

Is it correct?


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

David Gobbi
Hi Ang,

If I was going to use memory mapping to read a DICOM file, then I wouldn't use vtkDICOMReader.  The whole point of memory mapping is to _avoid_ using a traditional file reader.

Instead, I would use vtkDICOMParser to find out where in the file the PixelData starts, and then I would directly memory-map the PixelData from disk.  This requires the use of uncompressed DICOM images, of course.

Or, if you need to map multiple files as one contiguous block of memory (e.g. for vtkImageReslice), then you can do what I suggested earlier in this thread: combine the PixelData from all those files into one large flat file, and then memory-map the new file.

 - David


On Tue, Apr 11, 2017 at 9:05 PM, Ang <[hidden email]> wrote:
Hi David,

Could you give me advanced tips for memory mapping file ?

in my understanding, the process is

vtkDICOMReader(retrieve pixel data)  =>  CreateFileMapping => MapViewOfFile
=> put the pixel data into  File => OpenFileMapping => MapViewOfFile =>
vtkImageImport => vtkImageReslice

Is it correct?

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Ang
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help for rendering a large amount of images

Ang
Hi David,

Sorry for the late reply.

I have tried your solution ,but I don't know how to use vtkDICOMParser to get memory address pointer correctly.

So I follow your suggestion no matter what my data is compressed or not.

It works well for me. I appreciate your kind assistance.

Then I have another question...please have a look at the thread .


Loading...