Data structure to store huge amount of data?

Ashika Umanga Umagiliya picture Ashika Umanga Umagiliya · Nov 9, 2010 · Viewed 10.2k times · Source

In my application,I have to load volumedata from set of images (MRC images) and keep the pixel data in memory.(images are grayscaled ,so one byte per pixel).

My development environment is QT framework ,MinGW for Windows and GCC for Linux.

At the moment,I use a simple data structure to store volumedata as :

unsigned char *volumeData;

and do one huge allocation as follows.

volumeData=new unsigned char[imageXsize * imageYsize * numofImages];

Following are the important methods to access image-data in a given plane,such as

unsigned char* getXYPlaneSlice(int z_value);
unsigned char* getYZPlaneSlice(int x_value);
unsigned char* getZXPlaneSlice(int y_value);

With my simple data-structure it was easy to implement above methods.

But we might need to adopt to volume size as 2000x2000x1000 (~3.7Gb) in the future.And current datastructure will not be able to handle that huge data.

  1. How to avoid fragmentation ? Now,even with 1000x1000x200 data, application crash giving bad_alloc. Whats the best way to change the datastructure for this ? shall I use something like linked-list which each chunk is of size 100mb.

  2. Also,user should be able to perfome some image-processing filters on volume-data and also should be able to reset to original pixel value. That means, I should keep two copies of volume-data. With current implemetation its like.

    unsigned char *volumeDataOriginal;

    unsigned char *volumeDataCurrent;

So with 2000x2000x1000 data-range its going to utilize about 8Gb (4Gb for each volume). But in Win32 , the address space is 4GB.How to tackle this ? I should go with 64bit application ?

EDIT : Here is a snapshot of my application enter image description here

Basically,I load the volume-data (from set of images,from MRC format..etc) and display them in different plane-viewers (XY,YX,YZ.Image shows XY-plane-viewer).I need to keep above 3 data-access methods to show an image in a particular plane.using slider-bar user can change which image to show in the selected plane)

Thanks in advance.

Answer

jimmyb picture jimmyb · Nov 9, 2010

I think you should take a look at hdf5. This is a binary format for storing huge amounts of data collected from things like telescopes, physics experiments, and gene-sequencing machines. The benefits of using something like this are many, but three immediate thoughts are: (1) tested, (2) supports hyperslab selection, and (3) you get compression for free.

There are C/C++, java, python, matlab libraries available.