Bsoft  2.1.0
Bernard's software package
Bimage_nad.cpp
Go to the documentation of this file.
1 
10 #include "Bimage.h"
11 #include "Matrix.h"
12 #include "utilities.h"
13 
14 // Declaration of global variables
15 extern int verbose; // Level of output to the screen
16 
17 /*
18  Calculates a structure tensor for a 2D image.
19 */
20 Bimage* Bimage::structure_tensor_2D(long nn)
21 {
22  if ( z > 1 ) {
23  cerr << "Error in Bimage::structure_tensor_2D: The image must be 2D!" << endl;
24  return NULL;
25  }
26 
27  long i, k, xx, yy;
28  double dx, dy;
29 
30  Bimage* pd = new Bimage(Float, 3, x, y, 1, 1);
31  pd->image->origin(image->origin());
32  pd->sampling(sampling(0));
33 
34  for ( i=nn*image_size(), k=yy=0; yy<y; yy++ ) {
35  for ( xx=0; xx<x; xx++, i++ ) {
36  dx = dy = -avg;
37  if ( xx > 0 ) dx = -(*this)[i-1];
38  if ( xx < x-1 ) dx += (*this)[i+1];
39  else dx += avg;
40  if ( yy > 0 ) dy = -(*this)[i-x];
41  if ( yy < y-1 ) dy += (*this)[i+x];
42  else dy += avg;
43  dx /= 2;
44  dy /= 2;
45  pd->set(k++, dx*dx);
46  pd->set(k++, dx*dy);
47  pd->set(k++, dy*dy);
48 // cout << xx << tab << yy << tab << dx << tab << dy << endl;
49  }
50  }
51 
52  return pd;
53 }
54 
55 /*
56  Calculates a structure tensor for a 3D volume.
57 */
58 Bimage* Bimage::structure_tensor(long zs, long zw)
59 {
60  long i, k, xx, yy, zz, zf;
61  long nxy(x*y);
62  double dx, dy, dz;
63 
64  // Padding for the top and bottom slices
65  if ( zs > 0 ) zw++;
66  if ( zs+zw < z ) zw++;
67 
68  Bimage* pd = new Bimage(Float, 6, x, y, zw, 1);
69  pd->image->origin(image->origin());
70  pd->sampling(sampling(0));
71 
72  // Start point for the first slice
73  if ( zs > 0 ) {
74  pd->image->origin(0,0,1);
75  zs--;
76  }
77 
78  for ( zz=zs, zf=zs+zw, k=0, i=nxy*zs; zz<zf; zz++ ) {
79  for ( yy=0; yy<y; yy++ ) {
80  for ( xx=0; xx<x; xx++, i++ ) {
81  dx = dy = dz = -avg;
82  if ( xx > 0 ) dx = -(*this)[i-1];
83  if ( xx < x-1 ) dx += (*this)[i+1];
84  else dx += avg;
85  if ( yy > 0 ) dy = -(*this)[i-x];
86  if ( yy < y-1 ) dy += (*this)[i+x];
87  else dy += avg;
88  if ( zz > 0 ) dz = -(*this)[i-nxy];
89  if ( zz < z-1 ) dz += (*this)[i+nxy];
90  else dz += avg;
91  dx /= 2;
92  dy /= 2;
93  dz /= 2;
94  pd->set(k++, dx*dx);
95  pd->set(k++, dx*dy);
96  pd->set(k++, dx*dz);
97  pd->set(k++, dy*dy);
98  pd->set(k++, dy*dz);
99  pd->set(k++, dz*dz);
100 // cout << xx << tab << yy << tab << zz << tab << dx << tab << dy << tab << dz << endl;
101  }
102  }
103  }
104 
105  return pd;
106 }
107 
108 /*
109 Calculates the diffusion tensor of EED or CED using the structure tensor.
110 */
111 int Bimage::diffusion_tensor_2D(double lambda, double C, double alpha)
112 {
113  if ( z > 1 ) {
114  cerr << "Error in Bimage::diffusion_tensor_2D: The image must be 2D!" << endl;
115  return -1;
116  }
117 
118  long i, j, imgsize(x*y);
119  double lam[2] = {1,1}; /* eigenvalues of diffusion tensor */
120 // double* d; /* vector with unordered eigenvalues */
121  Matrix a(2,2); /* real tensor matrix */
122  double beta(1 - alpha); /* time saver */
123  double thexp(16), grd, gol;
124 
125  for ( i=0; i<imgsize; i++ ) {
126  j = i*c;
127  a[0][0] = (*this)[j++];
128  a[0][1] = a[1][0] = (*this)[j++];
129  a[1][1] = (*this)[j++];
130 // cout << i << tab << a[0] << tab << a[1] << tab << a[2] << endl;
131 
132  grd = a[0][0] + a[1][1];
133  vector<double> d = a.jacobi_rotation();
134  a.eigen_sort(d);
135 
136  if ( C ) {
137  // for plane-like structures, calculate the second eigenvalue
138  lam[0] = lam[1] = alpha;
139  if ( d[1] )
140  lam[1] += beta * exp (- C / (d[1]*d[1]));
141  } else {
142  if ( grd > 0.0) {
143  gol = sqrt(grd)/lambda;
144  lam[0] = 1.0 - exp (-3.31488 / pow(gol, thexp));
145  } else {
146  lam[0] = lam[1] = 1;
147  }
148  }
149 
150 // delete[] d;
151 
152  /* principal axis backtransformation */
153  j = i*c;
154  set(j++, lam[0]*a[0][0]*a[0][0] + lam[1]*a[0][1]*a[0][1]);
155  set(j++, lam[0]*a[0][0]*a[1][0] + lam[1]*a[0][1]*a[1][1]);
156  set(j++, lam[0]*a[1][0]*a[1][0] + lam[1]*a[1][1]*a[1][1]);
157  // cout << i;
158  // for ( int k=0; k<3; k++ ) cout << tab << (*this)[j++];
159  // cout << endl;
160  }
161 
162  return 0;
163 }
164 
165 /*
166 Calculates the diffusion tensor of EED or CED using the structure tensor.
167 Principal axis backtransformation of a symmetric 3x3 matrix.
168 A = U * diag(lam[0], lam[1], lam[2]) * U_transpose with U = (v1 | v2 | v3)
169 */
170 int Bimage::diffusion_tensor(double lambda, double C, double alpha)
171 {
172  long i, j, imgsize(x*y*z);
173  double lam[3] = {1,1,1}; /* eigenvalues of diffusion tensor */
174 // double* d; /* vector with unordered eigenvalues */
175  Matrix a(3,3); /* real tensor matrix */
176  double beta(1 - alpha); /* time saver */
177  double thexp(16), grd, gol, denom;
178 
179  for ( i=0; i<imgsize; i++ ) {
180  j = i*c;
181  a[0][0] = (*this)[j++];
182  a[0][1] = a[1][0] = (*this)[j++];
183  a[0][2] = a[2][0] = (*this)[j++];
184  a[1][1] = (*this)[j++];
185  a[1][2] = a[2][1] = (*this)[j++];
186  a[2][2] = (*this)[j++];
187  // cout << i << tab << a[0] << tab << a[1] << tab << a[2] << tab << a[4] << tab << a[5] << tab << a[8] << endl;
188 
189  grd = a[0][0] + a[1][1] + a[2][2];
190 // d = a.jacobi_rotation();
191  vector<double> d = dsyevq3(a);
192  a.eigen_sort(d);
193 
194  if ( C ) {
195  // for plane-like structures, calculate the second eigenvalue
196  lam[0] = lam[1] = lam[2] = alpha;
197  denom = d[0] - d[1];
198  if ( denom && denom > d[2] && ( denom > d[1] - d[2] ) )
199  lam[1] += beta * exp (- C / (denom*denom));
200  /* calculate third eigenvalue */
201  denom = d[0] - d[2];
202  if ( denom ) lam[2] += beta * exp (- C / (denom*denom));
203  } else {
204  if ( grd > 0.0) {
205  gol = sqrt(grd)/lambda;
206  lam[0] = lam[1] = 1.0 - exp (-3.31488 / pow(gol, thexp));
207  } else {
208  lam[0] = lam[1] = 1;
209  }
210  }
211 
212 // delete[] d;
213 
214  /* principal axis backtransformation */
215  j = i*c;
216  set(j++, lam[0]*a[0][0]*a[0][0] + lam[1]*a[0][1]*a[0][1] + lam[2]*a[0][2]*a[0][2]);
217  set(j++, lam[0]*a[0][0]*a[1][0] + lam[1]*a[0][1]*a[1][1] + lam[2]*a[0][2]*a[1][2]);
218  set(j++, lam[0]*a[0][0]*a[2][0] + lam[1]*a[0][1]*a[2][1] + lam[2]*a[0][2]*a[2][2]);
219  set(j++, lam[0]*a[1][0]*a[1][0] + lam[1]*a[1][1]*a[1][1] + lam[2]*a[1][2]*a[1][2]);
220  set(j++, lam[0]*a[1][0]*a[2][0] + lam[1]*a[1][1]*a[2][1] + lam[2]*a[1][2]*a[2][2]);
221  set(j++, lam[0]*a[2][0]*a[2][0] + lam[1]*a[2][1]*a[2][1] + lam[2]*a[2][2]*a[2][2]);
222 
223  // cout << i;
224  // for ( int k=0; k<6; k++ ) cout << tab << (*this)[j++];
225  // cout << endl;
226  }
227 
228  return 0;
229 }
230 
231 int Bimage::diffuse_2D(Bimage* pdn, Bimage* pd, double ht, long nn)
232 {
233  if ( z > 1 ) {
234  cerr << "Error in Bimage::diffuse_2D: The image must be 2D!" << endl;
235  return -1;
236  }
237 
238  long i, j, k, xx, yy, ii;
239  long iw, xw, yw, ix, iy, xf1, yf1;
240  double w[9], v;
241  double r(ht/4);
242 
243  if ( verbose & VERB_FULL )
244  cout << "Calculating the new image chunk" << endl;
245 
246  xf1 = pd->x - 1;
247  yf1 = pd->y - 1;
248 
249  for ( i=yy=0, j=nn*image_size(); yy<y; yy++ ) {
250  for ( xx=0; xx<x; xx++, i++, j++ ) {
251  for ( iw=0; iw<9; iw++ ) w[iw] = 0;
252 
253  k = pd->c*i;
254 
255 // w[12] = w[14] = 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
256  w[3] = w[5] = 2*(*pd)[k] - fabs((*pd)[k+1]);
257 // w[10] = w[16] = 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
258  w[1] = w[7] = 2*(*pd)[k+2] - fabs((*pd)[k+1]);
259 // w[4] = w[22] = 2*(*pd)[k+5] - fabs((*pd)[k+4]) - fabs((*pd)[k+2]);
260 
261 // w[9] = w[17] = (*pd)[k+1] + fabs((*pd)[k+1]);
262  w[0] = w[8] = (*pd)[k+1] + fabs((*pd)[k+1]);
263 // w[15] = w[11] = -(*pd)[k+1] + fabs((*pd)[k+1]);
264  w[6] = w[2] = -(*pd)[k+1] + fabs((*pd)[k+1]);
265 
266  if ( xx > 0 ) {
267  k = pd->c*(i - 1);
268 // w[12] += 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
269  w[3] += 2*(*pd)[k] - fabs((*pd)[k+1]);
270  }
271  if ( xx < xf1 ) {
272  k = pd->c*(i + 1);
273 // w[14] += 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
274  w[5] += 2*(*pd)[k] - fabs((*pd)[k+1]);
275  }
276 
277  if ( yy > 0 ) {
278  k = pd->c*(i - pd->x);
279 // w[10] += 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
280  w[1] += 2*(*pd)[k+2] - fabs((*pd)[k+1]);
281  }
282  if ( yy < yf1 ) {
283  k = pd->c*(i + pd->x);
284 // w[16] += 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
285  w[7] += 2*(*pd)[k+2] - fabs((*pd)[k+1]);
286  }
287 
288  if ( xx > 0 && yy > 0 ) {
289  k = pd->c*(i - pd->x - 1) + 1;
290 // w[9] += (*pd)[k] + fabs((*pd)[k]);
291  w[0] += (*pd)[k] + fabs((*pd)[k]);
292  }
293  if ( xx < xf1 && yy > 0 ) {
294  k = pd->c*(i - pd->x + 1) + 1;
295 // w[11] += -(*pd)[k] + fabs((*pd)[k]);
296  w[2] += -(*pd)[k] + fabs((*pd)[k]);
297  }
298  if ( xx > 0 && yy < yf1 ) {
299  k = pd->c*(i + pd->x - 1) + 1;
300 // w[15] += -(*pd)[k] + fabs((*pd)[k]);
301  w[6] += -(*pd)[k] + fabs((*pd)[k]);
302  }
303  if ( xx < xf1 && yy < yf1 ) {
304  k = pd->c*(i + pd->x + 1) + 1;
305 // w[17] += (*pd)[k] + fabs((*pd)[k]);
306  w[8] += (*pd)[k] + fabs((*pd)[k]);
307  }
308 
309  /* modify weights to prevent flux across boundaries */
310  if ( xx==0 ) w[6] = w[3] = w[0] = 0.0;
311  if ( xx==x-1 ) w[2] = w[5] = w[8] = 0.0;
312  if ( yy==0 ) w[0] = w[1] = w[2] = 0.0;
313  if ( yy==y-1 ) w[8] = w[7] = w[6] = 0.0;
314 
315  // cout << xx << tab << yy <<;
316  // for ( iw=0; iw<9; iw++ ) cout << tab << w[iw]*r;
317  // cout << endl;
318 
319  /* evolution */
320  v = (*this)[i];
321  for ( yw=0; yw<2; yw++ ) {
322  iy = yy + yw - 1;
323  if ( iy >= 0 && iy < y ) for ( xw=0; xw<2; xw++ ) {
324  ix = xx + xw - 1;
325  if ( ix >= 0 && ix < x ) {
326  iw = 2*yw + xw;
327  if ( w[iw] ) {
328  ii = iy*x + ix;
329  v += w[iw]*r*((*this)[ii] - (*this)[i]);
330  }
331  }
332  }
333  }
334  pdn->set(j, v);
335  }
336  }
337 
338  return 0;
339 }
340 
341 int Bimage::diffuse(Bimage* pdn, Bimage* pd, double ht, long zs)
342 {
343  long i, k, xx, yy, zz, zf, ii, ik;
344  long iw, xw, yw, zw, ix, iy, iz, zs1, xf1, yf1, zf1;
345  long nxy(x*y);
346  double w[27], v;
347  double r(ht/4);
348 
349  if ( verbose & VERB_FULL )
350  cout << "Calculating the new image chunk" << endl;
351 
352  xf1 = pd->x - 1;
353  yf1 = pd->y - 1;
354  zs1 = zs;
355  ik = 0;
356  if ( zs > 0 ) { // The diffusion tensor reference starts one slice in
357  ik = nxy;
358  zs1 = zs - 1;
359  }
360  zf = zs1 + pd->z;
361  zf1 = zf - 1;
362  if ( zf < z ) zf -= 1;
363  if ( zf > z ) zf = z;
364 
365  if ( verbose & VERB_DEBUG )
366  cout << "pd->sizeZ()=" << pd->z << " zs=" << zs << " zs1=" << zs1 << " zf=" << zf << " zf1=" << zf1 << endl;
367 
368  for ( zz=zs, i=nxy*zs; zz<zf; zz++ ) {
369  for ( yy=0; yy<y; yy++ ) {
370  for ( xx=0; xx<x; xx++, i++, ik++ ) {
371  for ( iw=0; iw<27; iw++ ) w[iw] = 0;
372 
373  k = pd->c*ik;
374 
375  w[12] = w[14] = 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
376  w[10] = w[16] = 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
377  w[4] = w[22] = 2*(*pd)[k+5] - fabs((*pd)[k+4]) - fabs((*pd)[k+2]);
378 
379  w[9] = w[17] = (*pd)[k+1] + fabs((*pd)[k+1]);
380  w[15] = w[11] = -(*pd)[k+1] + fabs((*pd)[k+1]);
381 
382  w[3] = w[23] = (*pd)[k+2] + fabs((*pd)[k+2]);
383  w[5] = w[21] = -(*pd)[k+2] + fabs((*pd)[k+2]);
384 
385  w[1] = w[25] = (*pd)[k+4] + fabs((*pd)[k+4]);
386  w[7] = w[19] = -(*pd)[k+4] + fabs((*pd)[k+4]);
387 
388  if ( xx > 0 ) {
389  k = pd->c*(ik - 1);
390  w[12] += 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
391  }
392  if ( xx < xf1 ) {
393  k = pd->c*(ik + 1);
394  w[14] += 2*(*pd)[k] - fabs((*pd)[k+1]) - fabs((*pd)[k+2]);
395  }
396 
397  if ( yy > 0 ) {
398  k = pd->c*(ik - pd->x);
399  w[10] += 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
400  }
401  if ( yy < yf1 ) {
402  k = pd->c*(ik + pd->x);
403  w[16] += 2*(*pd)[k+3] - fabs((*pd)[k+1]) - fabs((*pd)[k+4]);
404  }
405 
406  if ( zz > zs1 ) {
407  k = pd->c*(ik - nxy);
408  w[4] += 2*(*pd)[k+5] - fabs((*pd)[k+4]) - fabs((*pd)[k+2]);
409  }
410  if ( zz < zf1 ) {
411  k = pd->c*(ik + nxy);
412  w[22] += 2*(*pd)[k+5] - fabs((*pd)[k+4]) - fabs((*pd)[k+2]);
413  }
414 
415  if ( xx > 0 && yy > 0 ) {
416  k = pd->c*(ik - pd->x - 1) + 1;
417  w[9] += (*pd)[k] + fabs((*pd)[k]);
418  }
419  if ( xx < xf1 && yy > 0 ) {
420  k = pd->c*(ik - pd->x + 1) + 1;
421  w[11] += -(*pd)[k] + fabs((*pd)[k]);
422  }
423  if ( xx > 0 && yy < yf1 ) {
424  k = pd->c*(ik + pd->x - 1) + 1;
425  w[15] += -(*pd)[k] + fabs((*pd)[k]);
426  }
427  if ( xx < xf1 && yy < yf1 ) {
428  k = pd->c*(ik + pd->x + 1) + 1;
429  w[17] += (*pd)[k] + fabs((*pd)[k]);
430  }
431 
432  if ( xx > 0 && zz > zs1 ) {
433  k = pd->c*(ik - nxy - 1) + 2;
434  w[3] += (*pd)[k] + fabs((*pd)[k]);
435  }
436  if ( xx < xf1 && zz > zs1 ) {
437  k = pd->c*(ik - nxy + 1) + 2;
438  w[5] += -(*pd)[k] + fabs((*pd)[k]);
439  }
440  if ( xx > 0 && zz < zf1 ) {
441  k = pd->c*(ik + nxy - 1) + 2;
442  w[21] += -(*pd)[k] + fabs((*pd)[k]);
443  }
444  if ( xx < xf1 && zz < zf1 ) {
445  k = pd->c*(ik + nxy + 1) + 2;
446  w[23] += (*pd)[k] + fabs((*pd)[k]);
447  }
448 
449  if ( yy > 0 && zz > zs1 ) {
450  k = pd->c*(ik - pd->x - nxy) + 4;
451  w[1] += (*pd)[k] + fabs((*pd)[k]);
452  }
453  if ( yy < yf1 && zz > zs1 ) {
454  k = pd->c*(ik + pd->x - nxy) + 4;
455  w[7] += -(*pd)[k] + fabs((*pd)[k]);
456  }
457  if ( yy > 0 && zz < zf1 ) {
458  k = pd->c*(ik - pd->x + nxy) + 4;
459  w[19] += -(*pd)[k] + fabs((*pd)[k]);
460  }
461  if ( yy < yf1 && zz < zf1 ) {
462  k = pd->c*(ik + pd->x + nxy) + 4;
463  w[25] += (*pd)[k] + fabs((*pd)[k]);
464  }
465 
466  /* modify weights to prevent flux across boundaries */
467  if ( xx==0 ) w[15] = w[12] = w[9] = w[3] = w[21] = 0.0;
468  if ( xx==x-1 ) w[11] = w[14] = w[17] = w[5] =w[23] = 0.0;
469  if ( yy==0 ) w[9] = w[10] = w[11] = w[1] = w[19] = 0.0;
470  if ( yy==y-1 ) w[17] = w[16] = w[15] = w[7] = w[25] = 0.0;
471  if ( zz==0 ) w[7] = w[4] = w[1] = w[5] = w[3] = 0.0;
472  if ( zz==z-1 ) w[23] = w[22] = w[21] = w[1] =w[25] = 0.0;
473 
474  // cout << xx << tab << yy << tab << zz;
475  // for ( iw=0; iw<27; iw++ ) cout << tab << w[iw]*r;
476  // cout << endl;
477 
478  /* evolution */
479  v = (*this)[i];
480  for ( zw=0; zw<3; zw++ ) {
481  iz = zz + zw - 1;
482  if ( iz >= 0 && iz < z ) for ( yw=0; yw<3; yw++ ) {
483  iy = yy + yw - 1;
484  if ( iy >= 0 && iy < y ) for ( xw=0; xw<3; xw++ ) {
485  ix = xx + xw - 1;
486  if ( ix >= 0 && ix < x ) {
487  iw = 9*zw + 3*yw + xw;
488  if ( w[iw] ) {
489  ii = (iz*y + iy)*x + ix;
490  v += w[iw]*r*((*this)[ii] - (*this)[i]);
491  }
492  }
493  }
494  }
495  }
496  pdn->set(i, v);
497  }
498  }
499  }
500 
501  return 0;
502 }
503 
504 int Bimage::nad_chunk_2D(Bimage* pdn, double lambda, double C,
505  double alpha, double ht, long nn)
506 {
507  if ( verbose & VERB_DEBUG )
508  cout << "DEBUG Bimage::nad_chunk_2D: nn = " << nn << endl;
509 
510  Bimage* pd = structure_tensor_2D(nn);
511 
512  pd->diffusion_tensor_2D(lambda, C, alpha);
513 
514  diffuse_2D(pdn, pd, ht, nn);
515 
516  delete pd;
517 
518  return 0;
519 }
520 
521 int Bimage::nad_chunk(Bimage* pdn, double lambda, double C,
522  double alpha, double ht, long zs, long zw)
523 {
524  if ( zs+zw > z ) zw = z - zs;
525 
526  if ( verbose & VERB_DEBUG )
527  cout << "DEBUG Bimage::nad_chunk: Chunk start = " << zs << " and size = " << zw << endl;
528 
529  Bimage* pd = structure_tensor(zs, zw);
530 
531  pd->diffusion_tensor(lambda, C, alpha);
532 
533  diffuse(pdn, pd, ht, zs);
534 
535  delete pd;
536 
537  return 0;
538 }
539 
552 Bimage* Bimage::nad_2D(double ht, double lambda, double C, double alpha)
553 {
555 
556  Bimage* pdn = copy();
557 
558  for ( long nn=0; nn<n; ++nn )
559  nad_chunk_2D(pdn, lambda, C, alpha, ht, nn);
560 
561  return pdn;
562 }
563 
564 
578 Bimage* Bimage::nad(double ht, long zw, double lambda, double C, double alpha)
579 {
581 
582  Bimage* pdn = copy();
583 
584 #ifdef HAVE_GCD
585  dispatch_apply((z - 1)/zw + 1, dispatch_get_global_queue(0, 0), ^(size_t zz){
586  nad_chunk(pdn, lambda, C, alpha, ht, zz*zw, zw);
587  });
588 #else
589 #pragma omp parallel for
590  for ( long zz=0; zz<z; zz+=zw )
591  nad_chunk(pdn, lambda, C, alpha, ht, zz, zw);
592 #endif
593 
594  return pdn;
595 }
596 
597 
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
dsyevq3
vector< double > dsyevq3(Matrix &A)
Calculates the eigenvalues and normalized eigenvectors of a symmetric 3x3 matrix.
Definition: matrix.cpp:850
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1118
Bimage::Bimage
Bimage()
Initializes an image.
Definition: Bimage.cpp:43
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2702
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:136
Bimage::nad_2D
Bimage * nad_2D(double ht, double lambda, double C, double alpha)
Denoises a 2D image by non-linear anisotropic diffusion.
Definition: Bimage_nad.cpp:552
Bimage::image_size
long image_size()
Definition: Bimage.h:290
Bimage
General image parameter class.
Definition: Bimage.h:177
Bimage.h
Header file for image class.
utilities.h
Header file for general utilities.
Bimage::nad
Bimage * nad(double ht, long zw, double lambda, double C, double alpha)
Denoises a 3D density map by non-linear anisotropic diffusion.
Definition: Bimage_nad.cpp:578
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1765
Matrix.h
Generalized matrix class.
beta
double beta(double volt)
Calculates the relative electron velocity.
Definition: ctf.cpp:500
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Bimage::sampling
vector< Vector3< double > > sampling()
Definition: Bimage.h:529
Bimage::sampling
void sampling(long nn, Vector3< double > u)
Definition: Bimage.h:514
verbose
int verbose
Matrix
Definition: Matrix.h:22
Float
@ Float
Definition: utilities.h:161