Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/lamont/test/sum-reduction/readNrrd.c
ViewVC logotype

View of /branches/lamont/test/sum-reduction/readNrrd.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (download) (as text) (annotate)
Wed Feb 26 14:22:24 2014 UTC (5 years, 7 months ago) by lamonts
File size: 1095 byte(s)
Fixed global reduction block
/*
 * readNrrd.c 
 *
 * Reads in a vec4 Nrrd! 
 *
 */

#include <stdlib.h> 
#include <stdio.h> 
#include <teem/nrrd.h> 
#include <assert.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
void demoIO(char *filename); 

int main(void)
{
  demoIO("sum.nrrd");
  return 0; 
}

void demoIO(char *filename) {
  char me[]="demoIO", *err;
  Nrrd *nin;

  /* create a nrrd; at this point this is just an empty container */
  nin = nrrdNew();

  /* read in the nrrd from file */
  if (nrrdLoad(nin, filename, NULL)) {
    err = biffGetDone(NRRD);
    fprintf(stderr, "%s: trouble reading \"%s\":\n%s", me, filename, err);
    free(err);
    return;
  }

  /* say something about the array */
  printf("%s: \"%s\" is a %d-dimensional nrrd of type %d (%s)\n", 
         me, filename, nin->dim, nin->type,
         airEnumStr(nrrdType, nin->type));
  printf("%s: the array contains %d elements, each %d bytes in size\n",
         me, (int)nrrdElementNumber(nin), (int)nrrdElementSize(nin));
    
    
  float * data = (float *)nin->data;
    for(int i = 0; i < 1; i++){
        printf("%f\n",data[i]);
    }
}

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0