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

SCM Repository

[diderot] Diff of /branches/vis12/src/lib/common/image.c
ViewVC logotype

Diff of /branches/vis12/src/lib/common/image.c

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

revision 1300, Thu Jun 9 21:11:47 2011 UTC revision 1301, Thu Jun 9 23:58:40 2011 UTC
# Line 351  Line 351 
351      img->size[0] = nin->axis[base+0].size;      img->size[0] = nin->axis[base+0].size;
352      img->data = nin->data;      img->data = nin->data;
353    
354  printf("LoadImage \"%s\": space dim = 1, axes = <%d>\n",  //printf("LoadImage \"%s\": space dim = 1, axes = <%d>\n",
355  name, img->size[base+0]);  //name, img->size[base+0]);
356    
357    // from the Nrrd file, we load the scaling and translation    // from the Nrrd file, we load the scaling and translation
358      double s, t;      double s, t;
# Line 393  Line 393 
393      img->size[1] = nin->axis[base+1].size;      img->size[1] = nin->axis[base+1].size;
394      img->data = nin->data;      img->data = nin->data;
395    
396  printf("LoadImage \"%s\": space dim = 2, axes = <%d, %d>\n",  //printf("LoadImage \"%s\": space dim = 2, axes = <%d, %d>\n",
397  name, img->size[0], img->size[1]);  //name, img->size[0], img->size[1]);
398    
399    // from the Nrrd file, we load the affine image-to-world transform matrix    // from the Nrrd file, we load the affine image-to-world transform matrix
400      Matrix2x2_t m;              // rotation and scaling      Matrix2x2_t m;              // rotation and scaling
401      Vec2_t t;                   // translation part of the transform      Vec2_t t;                   // translation part of the transform
402      LoadTransform2D (nin, m, t);      LoadTransform2D (nin, m, t);
403    
404  PrintMat2x2("m", m);  //PrintMat2x2("m", m);
405  printf("t = <%f, %f>\n", t[0], t[1]);  //printf("t = <%f, %f>\n", t[0], t[1]);
406    
407    // compute inverse of m, which is the transform from the world basis to the image basis    // compute inverse of m, which is the transform from the world basis to the image basis
408      Matrix2x2_t mInv;      Matrix2x2_t mInv;
409      InvertM2x2 (mInv, m);      InvertM2x2 (mInv, m);
410  PrintMat2x2("w2i", mInv);  //PrintMat2x2("w2i", mInv);
411    
412    // copy results into the image data structure    // copy results into the image data structure
413      for (int i = 0;  i < 2;  i++) {      for (int i = 0;  i < 2;  i++) {
# Line 418  Line 418 
418      transpose2x2f (img->w2iT, img->w2i);      transpose2x2f (img->w2iT, img->w2i);
419      Diderot_vec2_t tVec = vec2(t[0], t[1]);      Diderot_vec2_t tVec = vec2(t[0], t[1]);
420      img->tVec = -mulMat2x2Vec2(img->w2i, tVec);  // inv([M t]) = [inv(M) -inv(M)t]      img->tVec = -mulMat2x2Vec2(img->w2i, tVec);  // inv([M t]) = [inv(M) -inv(M)t]
421  printf("tVec = <%f, %f>\n", ((union2f_t)img->tVec).r[0], ((union2f_t)img->tVec).r[1]);  //printf("tVec = <%f, %f>\n", ((union2f_t)img->tVec).r[0], ((union2f_t)img->tVec).r[1]);
422    
423      *imgOut = img;      *imgOut = img;
424      return DIDEROT_OK;      return DIDEROT_OK;
# Line 455  Line 455 
455      img->size[2] = nin->axis[base+2].size;      img->size[2] = nin->axis[base+2].size;
456      img->data = nin->data;      img->data = nin->data;
457    
458  printf("LoadImage \"%s\": space dim = 3, axes = <%d, %d, %d>\n",  //printf("LoadImage \"%s\": space dim = 3, axes = <%d, %d, %d>\n",
459  name, img->size[0], img->size[1], img->size[2]);  //name, img->size[0], img->size[1], img->size[2]);
460    
461    // from the Nrrd file, we load the affine image-to-world transform matrix    // from the Nrrd file, we load the affine image-to-world transform matrix
462      Matrix3x3_t m;              // rotation and scaling      Matrix3x3_t m;              // rotation and scaling
463      Vec3_t t;                   // translation part of the transform      Vec3_t t;                   // translation part of the transform
464      LoadTransform3D (nin, m, t);      LoadTransform3D (nin, m, t);
465    
466  PrintMat3x3("m", m);  //PrintMat3x3("m", m);
467  printf("t = <%f, %f, %f>\n", t[0], t[1], t[2]);  //printf("t = <%f, %f, %f>\n", t[0], t[1], t[2]);
468    
469    // compute inverse of m, which is the transform from the world basis to the image basis    // compute inverse of m, which is the transform from the world basis to the image basis
470      Matrix3x3_t mInv;      Matrix3x3_t mInv;
471      InvertM3x3 (mInv, m);      InvertM3x3 (mInv, m);
472  PrintMat3x3("w2i", mInv);  //PrintMat3x3("w2i", mInv);
473    
474    // copy results into the image data structure    // copy results into the image data structure
475      for (int i = 0;  i < 3;  i++) {      for (int i = 0;  i < 3;  i++) {
# Line 480  Line 480 
480      transpose3x3f (img->w2iT, img->w2i);      transpose3x3f (img->w2iT, img->w2i);
481      Diderot_vec3_t tVec = vec3(t[0], t[1], t[2]);      Diderot_vec3_t tVec = vec3(t[0], t[1], t[2]);
482      img->tVec = -mulMat3x3Vec3(img->w2i, tVec);  // inv([M t]) = [inv(M) -inv(M)t]      img->tVec = -mulMat3x3Vec3(img->w2i, tVec);  // inv([M t]) = [inv(M) -inv(M)t]
483  printf("tVec = <%f, %f, %f>\n", ((Diderot_union3_t)img->tVec).r[0], ((Diderot_union3_t)img->tVec).r[1], ((Diderot_union3_t)img->tVec).r[2]);  //printf("tVec = <%f, %f, %f>\n", ((Diderot_union3_t)img->tVec).r[0], ((Diderot_union3_t)img->tVec).r[1], ((Diderot_union3_t)img->tVec).r[2]);
484    
485      *imgOut = img;      *imgOut = img;
486      return DIDEROT_OK;      return DIDEROT_OK;

Legend:
Removed from v.1300  
changed lines
  Added in v.1301

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