[MINC-users] Synthetic data with different world and voxel coordinates

Tanweer Rashid trash001 at odu.edu
Sun Aug 4 17:04:31 EDT 2013


Hi,

I am trying to create some synthetic data (a box within a box) having
different voxel and world coordinates. I have tried using
miset_world_origin(), but had no effect. Can you tell me what else I need
to use? The following is my code:


void createCuboidVolume(char f[], int xSize, int ySize, int zSize) {
    int result;
    mihandle_t volume;
    midimhandle_t dim[3];
    mivolumeprops_t props;

    result = minew_volume_props(&props);

    result = micreate_dimension("xspace", MI_DIMCLASS_SPATIAL,
MI_DIMATTR_REGULARLY_SAMPLED, xSize, &dim[0]);
    if (result == MI_ERROR) cout << "Error creating dimension xspace" <<
endl;

    result = micreate_dimension("yspace", MI_DIMCLASS_SPATIAL,
MI_DIMATTR_REGULARLY_SAMPLED, ySize, &dim[1]);
    if (result == MI_ERROR) cout << "Error creating dimension yspace" <<
endl;

    result = micreate_dimension("zspace", MI_DIMCLASS_SPATIAL,
MI_DIMATTR_REGULARLY_SAMPLED, zSize, &dim[2]);
    if (result == MI_ERROR) cout << "Error creating dimension zspace" <<
endl;

    result = micreate_volume(f, 3, dim, MI_TYPE_DOUBLE, MI_CLASS_REAL,
props, &volume);
    if (result == MI_ERROR) cout << "Error encountered in creating MINC
file" << endl;

    result = micreate_volume_image(volume);
    if (result == MI_ERROR) cout << "Error encountered in creating volume
image" << endl;

    double worldOrigin[] = {-10, -20, -30};
    result = miset_world_origin(volume, worldOrigin);
    if (result == MI_ERROR) cout << "Error encountered in setting world
origin" << endl;

    unsigned long location[3];
    for (int x = 0; x < xSize; x++) {
        for (int y = 0; y < ySize; y++) {
            for (int z = 0; z < zSize; z++) {
                location[0] = x;
                location[1] = y;
                location[2] = z;

                miset_voxel_value(volume, location, 3, 0);

                if (z >= 1 && z <= zSize - 2 && x >= 1 && x <= xSize - 2 &&
y >= 1 && y <= ySize - 2) {
                    miset_voxel_value(volume, location, 3, 0.3);
                }

                if ((z >= 10 && z < 20) && (x >= 2 && x < 8) && (y >= 7 &&
y < 17)) {
                    miset_voxel_value(volume, location, 3, 0.7);
                }
            }
        }
    }

    return;
}


-- 
Tanweer Rashid
MSVE Dept.
Old Dominion University


More information about the MINC-users mailing list