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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/lib/diderot.c
ViewVC logotype

Diff of /branches/pure-cfg/src/lib/diderot.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 566, Thu Feb 24 19:29:51 2011 UTC revision 568, Fri Feb 25 00:21:39 2011 UTC
# Line 200  Line 200 
200  #undef I  #undef I
201  }  }
202    
203    static void LoadTransformMatrix (Nrrd *nin, Diderot_Mat4x4_t m)
204    {
205    #define M(i)    m[(i)>>2].r[(i)&3]
206        int size =  nin->spaceDim;
207    
208      // Image axis Scaling and Rotation
209        for (int i = 0; i < size; i++) {
210            NrrdAxisInfo axisInfo = nin->axis[i];
211            for (int j = 0; j < size; j++) {
212                int k = (size + 1) * j + i;
213                M(k) = axisInfo.spaceDirection[j];
214            }
215    
216          //Image Location
217            M((i * (size + 1)) + size) = nin->spaceOrigin[i];
218    
219          //Bottom row of the Transform Matrix
220            M(((size + 1) * (size)) + i) = 0;
221        }
222        M(((size + 1) * (size)) + size) = 1;
223    
224    #undef M
225    }
226    
227    static Nrrd *LoadNrrdFile (const char *filename)
228    {
229      /* create a nrrd; at this point this is just an empty container */
230        Nrrd *nin = nrrdNew();
231    
232      /* read in the nrrd from file */
233        if (nrrdLoad(nin, filename, NULL)) {
234            char *err = biffGetDone(NRRD);
235            fprintf (stderr, "Diderot: trouble reading \"%s\":\n%s", filename, err);
236            free (err);
237            return NULL;
238        }
239    
240        return nin;
241    
242    }
243    
244  /* load image data from Nrrd files */  /* load image data from Nrrd files */
245  //Status_t Diderot_LoadImage1D (Diderot_string_t name, Diderot_image1D_t *img);  //Status_t Diderot_LoadImage1D (Diderot_string_t name, Diderot_image1D_t *img);
246  //Status_t Diderot_LoadImage2D (Diderot_string_t name, Diderot_image2D_t *img);  //Status_t Diderot_LoadImage2D (Diderot_string_t name, Diderot_image2D_t *img);
247    
248  Status_t Diderot_LoadImage3D (Diderot_string_t name, Diderot_image3D_t **imgOut)  Status_t Diderot_LoadImage3D (Diderot_string_t name, Diderot_image3D_t **imgOut)
249  {  {
250      Nrrd *nin = loadNrrdFile (name);      Nrrd *nin = LoadNrrdFile (name);
251      Diderot_image3D_t *img = (Diderot_image3D_t *)malloc(sizeof(Diderot_image3D_t));      Diderot_image3D_t *img = (Diderot_image3D_t *)malloc(sizeof(Diderot_image3D_t));
252    
253      img->dim = 3;      img->dim = 3;
# Line 215  Line 256 
256      img->size[2] = nin->axis[2].size;      img->size[2] = nin->axis[2].size;
257      img->data = nin->data;      img->data = nin->data;
258    
259      loadTransformMatrix (nin, img->m);      LoadTransformMatrix (nin, img->m);
260      InvertM4x4 (img->m, img->mInv);      InvertM4x4 (img->m, img->mInv);
261      InvertTransposeM4x4 (img->m, img->mInvT);      InvertTransposeM4x4 (img->m, img->mInvT);
262    

Legend:
Removed from v.566  
changed lines
  Added in v.568

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