next up previous contents
Next: About this document ... Up: Image conversion variables Previous: Dimension conversion   Contents

Example: Reading with dimension conversion

Reading a $256\times 256$ image with the first pixel at the patient's inferior, posterior, left side as short values between 0 and 32000:

   /* Create the icv */
   icv=miicv_create();
   (void) miicv_setint(icv, MI_ICV_TYPE, NC_SHORT);
   (void) miicv_setstr(icv, MI_ICV_SIGN, MI_UNSIGNED);
   (void) miicv_setint(icv, MI_ICV_VALID_MAX, 32000);
   (void) miicv_setint(icv, MI_ICV_VALID_MIN, 0);
   (void) miicv_setint(icv, MI_ICV_DO_DIM_CONV, TRUE);
   (void) miicv_setint(icv, MI_ICV_ADIM_SIZE, 256);
   (void) miicv_setint(icv, MI_ICV_BDIM_SIZE, 256);
   (void) miicv_setint(icv, MI_ICV_KEEP_ASPECT, TRUE);
   (void) miicv_setint(icv, MI_ICV_XDIM_DIR, MI_POSITIVE);
   (void) miicv_setint(icv, MI_ICV_YDIM_DIR, MI_POSITIVE);
   (void) miicv_setint(icv, MI_ICV_ZDIM_DIR, MI_POSITIVE);

   /* Open the file, attach the image variable */
   cdfid=ncopen(filename, NC_NOWRITE);

   /* Attach image variable */
   img=ncvarid(cdfid, MIimage);
   (void) miicv_attach(icv, cdfid, img);

   /* Get the data - we assume that coord and count are set properly */
   (void) miicv_get(icv, coord, count, image);

   /* Close the file and free the icv */
   (void) ncclose(cdfid);
   (void) miicv_free(icv);



Robert VINCENT 2004-05-28