next up previous contents
Next: Example: Writing values Up: Image conversion variables Previous: Writing with pixel conversion   Contents

Example: Reading values

Read an image without normalization:

   /* 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);

   /* 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);

Read an integer image with normalization:

   /* 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_NORM, TRUE);
   (void) miicv_setint(icv, MI_ICV_USER_NORM, TRUE);
   (void) miicv_setdbl(icv, MI_ICV_IMAGE_MAX, 1.83);
   (void) miicv_setdbl(icv, MI_ICV_IMAGE_MIN, -0.57);
   ...

Read a floating point image :

   /* Create the icv. We don't have to set MI_ICV_USER_NORM to TRUE,
      but doing so ensures that the conversion is done properly
      without looking at file values (the defaults for
      MI_ICV_IMAGE_MAX and MI_ICV_IMAGE_MIN are 1 and 0) */
   icv=miicv_create();
   (void) miicv_setint(icv, MI_ICV_TYPE, NC_FLOAT);
   (void) miicv_setint(icv, MI_ICV_DO_NORM, TRUE);
   (void) miicv_setint(icv, MI_ICV_USER_NORM, TRUE);
   ...



Robert VINCENT 2004-05-28