next up previous
Next: mask_volume() Up: Brain Volume I/O Handling Previous: convert_volume()

resize_volume()  

Resize a volume



Synopsis


int
resize_volume(header *hdr, void **data, int *new_size, int *start, 
              double background);


Description
Resizes an image volume by adding space around/cutting the volume. The memory is reallocated.

If space is added around the volume, it is possible to fill in a special value for the background.

Usage

hdr Volume header
data Pointer to volume data. Reallocated, so pointer may be changed.
new\_size Int array to specify new size.
start Starting coordinates in output volume, i.e. where does 0,0,0 in input image go in output image.
background Fill value if output image is bigger than input image.

All volio data types are supported, as well as any rank of the volume (the data may be 1,2, .. MAX_DIM dimensional).

This program will read in a volume, and resize it to 100x100x100 voxels.

If the volume "myvol.img" is 50x50x50, the volume will have the value 13 (converted to the volume data type) for
x < 20, x >= 70, y < 30, y >= 80, and z >= 40. Outside this range, (inside this cube) the volume will be copied.

   int newsize[3] = {100,100,100};
   int start[3] = {20,30,-10};
   
   void *data;
   header *hdr;
   hdr = new_header();
   
   read_volume("myvol.hdr", hdr, &data);
   resize_volume(hdr, &data, newsize, start, 13);

   write_volume("myvol.hdr", hdr, data);
   
   free_header(hdr);
   free(data);

Revision


1.0  15/11-96   Ulrik Kjems  Initial code


Program listing






Ulrik Kjems
6/3/1998