Skip to content
Micah Chambers edited this page Jul 12, 2014 · 1 revision

Introduction

The purpose of these libraries is primarily for myself; I got tired of using FSL (the terrible, static, C coding) and ITK (the awful templates and inability to read values from the disk without casting). The image library I have written uses templates for the same reason ITK does: so that the compiler can optimize. However, I have added a layer of abstraction similar to that that VTK uses, so that you can pass around MRImage* variables without knowing the underlying template. You can check the type using img->type(), and the dimensionality with img->ndim(). You can then cast to another type by using:

MRImage* img2 = img->cast(2, FLOAT32);

which will produce an identical image except casted to the new type. If the dimensionality decreases, then the original image will be sliced down using index 0, or the index provided:

MRImage* img3 = img->cast(1, FLOAT32, {-1,0,7});

if img has 3 dimensions, img3 will have 1 dimension which will be a slice of x (because of the -1 in the x index) at Y=0 and Z=7. If you cast up dimensions, the input meaning differs, it is then size of the extra dimensions:

MRImage* img4 = img->cast(5, FLOAT32, {-1,-1,-1,10,11});

All dimensions that match should be set to -1, other dimensions should indicate the new output dimensions. This will result in zeros in the upper indices and the original image in {,,*,0,0}. If you want to make a copy of the original image throughout the new dimensions, add a true to the back:

MRImage* img5 = img->cast(5, FLOAT32, {-1,-1,-1,10,11});

Now:

img5->get_dbl({23,13,42,0,0}) == img5->get_dbl({23,13,42,3,5}) img->get_dbl({23,13,42}) == img5->get_dbl({23,13,42,3,5})

Clone this wiki locally