| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_align.cpp
Go to the documentation of this file.
1
9 #include "Bimage.h"
10 #include "img_align.h"
11 #include "marker.h"
12 #include "ps_marker.h"
13 #include "linked_list.h"
14 #include "utilities.h"
15
16 // Declaration of global variables
17 extern int verbose; // Level of output to the screen
18
19 /*
20 @brief Real space cross-correlation of two power spectrum annuli in two directions.
21 @param n number of values in the annulus.
22 @param *x first annulus.
23 @param *y second annulus.
24 @return double* array of correlation coefficients.
25
26 The first halves of the annuli is cross-correlated forward and the second
27 halves backward, representing the correlations of the original annulus and
28 its inverse.
29 **/
30 double* cross_correlate_two_way(int n, double* x, double* y)
31 {
32 int i, j, k, n2 = n/2;
33 double sx(0), sx2(0), sy(0), sy2(0), sxy, d;
34
35 double* cc = new double[n];
36 for ( i=0; i<n; i++ ) cc[i] = 0;
37
38 for ( i=0; i<n2; i++ ) {
39 sx += x[i];
40 sx2 += x[i]*x[i];
41 sy += y[i];
42 sy2 += y[i]*y[i];
43 }
44
45 d = (n2*sx2 - sx*sx)*(n2*sy2 - sy*sy);
46 if ( d > 0 ) d = sqrt(d);
47 else {
48 cerr << "Error in cross_correlate_two_way: denominator is negative!" << endl;
49 return cc;
50 }
51
52 for ( i=0; i<n2; i++ ) {
53 sxy = 0;
54 for ( j=0, k=i; j<n2; j++, k++ ) {
55 if ( k >= n ) k = 0;
56 sxy += x[j]*y[k];
57 }
58 cc[i] = (n2*sxy - sx*sy)/d;
59 }
60
61 for ( i=n2; i<n; i++ ) {
62 sxy = 0;
63 for ( j=n2, k=i; j<n; j++, k-- ) {
64 if ( k < 0 ) k = n - 1;
65 sxy += x[j]*y[k];
66 }
67 cc[i] = (n2*sxy - sx*sy)/d;
68 }
69
70 return cc;
71 }
72
73 /*
74 @brief Calculates the sums of the cross-correlation arrays for annuli of the power spectra.
75 @param *p 2D image.
76 @param *pref reference 2D image.
77 @param res_hi high resolution limit.
78 @param res_lo low resolution limit.
79 @param planf FFT forward plan.
80 @return double* array of summed correlation coefficients.
81
82 The images are packed into a complex form, Fourier transformed and unpacked.
83 The two polar power spectra are calculated and the annuli cross-correlated.
84 The input images must be equal-sized square 2D images.
85 **/
86 double* img_pps_angular_correlation(Bimage* p, Bimage* pref,
87 double res_hi, double res_lo, fft_plan planf)
88 {
89 Bimage* pc = p->pack_two_in_complex(pref);
90 if ( !pc ) return NULL;
91
92 pc->fft(planf, 1);
93
94 pc->origin(0,0,0);
95
96 Bimage* pc2 = pc->unpack_combined_transform();
97
98 pc->complex_to_amplitudes();
99 pc2->complex_to_amplitudes();
100
101 Bimage* ppsref = pc2->polar_power_spectrum(res_hi, NANG);
102 Bimage* pps = pc->polar_power_spectrum(res_hi, NANG);
103
104 delete pc;
105 delete pc2;
106
107 size_t min_rad(1);
108 if ( res_lo ) min_rad = (size_t) (p->real_size().x()/res_lo);
109 if ( min_rad < 1 ) min_rad = 1;
110
111 size_t i, j, na, r, m, offset;
112 double f;
113 double* cc;
114 double* ccs = new double[pps->sizeX()];
115 for ( i=0; i<pps->sizeX(); i++ ) ccs[i] = 0;
116
117 for ( r=min_rad, m=0, offset=r*pps->sizeX(); r<pps->sizeY(); r++, m++, offset+=pps->sizeX() ) {
118 na = NANG*r;
119 cc = cross_correlate_two_way(na, (double*) (ppsref->data_pointer(offset)), (double*) (pps->data_pointer(offset)));
120 f = na*1.0L/pps->sizeX();
121 for ( i=0; i<pps->sizeX(); i++ ) {
122 j = (size_t) (i*f + 0.5);
123 if ( j >= na ) j -= na;
124 ccs[i] += cc[j];
125 }
126 delete[] cc;
127 }
128
129 for ( i=0; i<pps->sizeX(); i++ ) ccs[i] /= m;
130
131 delete pps;
132 delete ppsref;
133
134 return ccs;
135 }
136
152 Transform img_align(Bimage* p1, Bimage* p2, Vector3<int> tile_size,
153 double res_lo, double res_hi, double max_shift, int filter_flag, int refine_flag)
154 {
155 unsigned long i;
156 int iter, maxiter(5);
157 Vector3<float> shift;
158 Transform t, best_t;
159 best_t.fom = 1e37;
160
161 Vector3<int> start1, common_size;
162
163 // Find the largest area covering both images
164 common_size = p1->size().min(p2->size());
165 common_size = common_size.max(1);
166
167 // Ensure the tile fits into the images
168 tile_size = tile_size.max(1);
169 tile_size = tile_size.min(common_size);
170 if ( tile_size.x() >= common_size.x() && common_size.x() > 1 ) {
171 tile_size[0] = (int) (0.4*common_size.x());
172 // start1[0] = (common_size.x() - tile_size.x())/2;
173 }
174 if ( tile_size.y() >= common_size.y() && common_size.y() > 1 ) {
175 tile_size[1] = (int) (0.4*common_size.y());
176 // start1[1] = (common_size.y() - tile_size.y())/2;
177 }
178 if ( tile_size.z() >= common_size.z() && common_size.z() > 1 ) {
179 tile_size[2] = (int) (0.4*common_size.z());
180 // start1[2] = (common_size.z() - tile_size.z())/2;
181 }
182
183 if ( max_shift < 1 ) max_shift = tile_size.x()/4;
184
185 Vector3<float> half_tile;
186 half_tile[0] = (tile_size.x() - 1)/2;
187 half_tile[1] = (tile_size.y() - 1)/2;
188 half_tile[2] = (tile_size.z() - 1)/2;
189
190 Bimage* pex1 = NULL;
191 Bimage* pex2 = NULL;
192 Bmarker* set1 = NULL;
193 Bmarker* set2 = NULL;
194 Bmarker* m1 = NULL;
195 Bmarker* m2 = NULL;
196 Bstring filename = p1->file_name().pre_rev('.') + "_" + p2->file_name().pre_rev('.') + ".ps";
197
198 if ( verbose & VERB_LABEL ) {
199 cout << "Aligning images ";
200 if ( refine_flag ) cout << "with ";
201 else cout << "without ";
202 cout << "shift refinement." << endl << endl;
203 }
204
205 if ( common_size.x() > 2*tile_size.x() )
206 start1[0] = (common_size.x()
207 - (int) (tile_size.x()*(common_size.x()/tile_size.x())))/2;
208 if ( common_size.y() > 2*tile_size.y() )
209 start1[1] = (common_size.y()
210 - (int) (tile_size.y()*(common_size.y()/tile_size.y())))/2;
211 if ( common_size.z() > 2*tile_size.z() )
212 start1[2] = (common_size.z()
213 - (int) (tile_size.z()*(common_size.z()/tile_size.z())))/2;
214
215 if ( verbose & VERB_PROCESS ) {
216 cout << "Common size: " << common_size << endl;
217 cout << "Tile size: " << tile_size << endl;
218 cout << "Maximum shift: " << max_shift << endl;
219 cout << "Reference start: " << start1 << endl << endl;
220 }
221
222 if ( res_hi < 0.1 || res_hi > tile_size.x()*p1->sampling().x() ) res_hi = 4.0*p1->sampling().x();
223
224 if ( filter_flag ) {
225 p1->filter_extremes();
226 p2->filter_extremes();
227 }
228
229 pex1 = p1->extract_tiles(0, start1, common_size, tile_size, 0);
230
231 Vector3<size_t>* tile_start = new Vector3<size_t>[pex1->images()];
232
233 for ( i=0; i<pex1->images(); i++ ) {
234 m1 = (Bmarker *) add_item((char **) &m1, sizeof(Bmarker));
235 m2 = (Bmarker *) add_item((char **) &m2, sizeof(Bmarker));
236 if ( !set1 ) set1 = m1;
237 if ( !set2 ) set2 = m2;
238 m1->sel = m2->sel = 1;
239 m1->fom = m2->fom = 1;
240 m1->loc = pex1->image[i].origin() + half_tile;
241 tile_start[i] = pex1->image[i].origin();
242 }
243
244 for ( iter=0; iter<maxiter && best_t.fom>0.1; iter++ ) {
245 pex2 = p2->extract_tiles(0, pex1->images(), tile_start, tile_size);
246 // Determines the shift of the second image onto the first
247 pex1->find_shift(pex2, NULL, res_hi, res_lo, max_shift, 0, refine_flag);
248 for ( i=0, m2=set2; i<pex1->images(); i++, m2=m2->next ) {
249 shift = pex1->image[i].origin() - pex2->image[i].origin();
250 if ( shift.x() > half_tile.x() ) shift[0] -= tile_size.x();
251 if ( shift.y() > half_tile.y() ) shift[1] -= tile_size.y();
252 if ( shift.z() > half_tile.z() ) shift[2] -= tile_size.z();
253 // To get the location in the second image, the shift must be subtracted
254 m2->loc = tile_start[i] + half_tile - shift;
255 }
256 t = markers_find_rottrans(set1, set2, 0.01);
257 // if ( verbose & VERB_PROCESS )
258 cout << "Fit " << iter+1 << ":\t" << p1->file_name() << tab << p2->file_name() << tab
259 << t.trans << tab
260 << t.scale << tab
261 << t.angle*180.0/M_PI << tab << t.fom << endl;
262 if ( best_t.fom > t.fom ) best_t = t;
263 else iter = maxiter;
264 for ( i=0, m1=set1, m2=set2; i<pex1->images(); i++, m1=m1->next, m2=m2->next ) {
265 m2->loc[0] = best_t.scale.x()*(m1->loc.x()*cos(best_t.angle) -
266 m1->loc.y()*sin(best_t.angle)) + t.trans.x() + 0.5;
267 m2->loc[1] = best_t.scale.y()*(m1->loc.x()*sin(best_t.angle) +
268 m1->loc.y()*cos(best_t.angle)) + t.trans.y() + 0.5;
269 m2->loc[2] = best_t.scale.z()*m1->loc.z() + t.trans.z();
270 tile_start[i] = m2->loc - half_tile;
271 }
272 delete pex2;
273 }
274
275 if ( verbose & VERB_RESULT )
276 cout << "Best fit:\t" <<
277 p1->file_name() << tab << p2->file_name() << tab <<
278 best_t.trans << tab <<
279 best_t.scale << tab <<
280 best_t.angle*180.0/M_PI << tab << best_t.fom << endl;
281
282 delete[] tile_start;
283 delete pex1;
284
285 ps_marker_errors(filename, set1, set2, t, p1->size(), 20);
286
287 kill_list((char *) set1, sizeof(Bmarker));
288 kill_list((char *) set2, sizeof(Bmarker));
289
290 return best_t;
291 }
292
319 double img_align2D_pps(Bimage* p, Bimage* pref, int fullasu,
320 double res_hi, double res_lo, double shift_limit, fft_plan planf, fft_plan planb)
321 {
322 if ( verbose & VERB_DEBUG )
323 cout << "DEBUG img_align2D_pps: res_hi=" << res_hi << " res_lo=" << res_lo << endl;
324
325 unsigned long max_rad = (unsigned long) (p->real_size().x()/res_hi);
326 if ( max_rad > p->sizeX()/2 ) max_rad = p->sizeX()/2;
327 unsigned long max_ang = NANG*max_rad;
328 unsigned long hang = max_ang/2;
329
330 int select_on_pps_cc(1);
331 int i, j, shift;
332 double cc1, cc2, cc3, cc, ccp, f, ang1, ang2;
333 double ox, oy, ang;
334 double* ccs;
335
336 // Forward cross-correlation
337 ccs = img_pps_angular_correlation(p, pref, res_hi, res_lo, planf);
338 for ( i=0, cc2 = 0; i<hang; i++ ) if ( cc2 < ccs[i] ) {
339 shift = i;
340 cc2 = ccs[i];
341 }
342 j = shift - 1;
343 if ( j < 0 ) j += hang;
344 cc1 = ccs[j];
345 j = shift + 1;
346 if ( j >= hang ) j -= hang;
347 cc3 = ccs[j];
348 f = (cc1 - cc3)/(2*(cc1 - 2*cc2 + cc3));
349 ang1 = (shift + f)*M_PI*2.0L/max_ang;
350 ccp = cc2;
351
352 // Reverse cross-correlation
353 if ( !fullasu ) {
354 for ( i=hang, cc2 = 0; i<max_ang; i++ ) if ( cc2 < ccs[i] ) {
355 shift = i;
356 cc2 = ccs[i];
357 }
358 j = shift - 1;
359 if ( j < hang ) j += hang;
360 cc1 = ccs[j];
361 j = shift + 1;
362 if ( j >= max_ang ) j -= hang;
363 cc3 = ccs[j];
364 f = (cc1 - cc3)/(2*(cc1 - 2*cc2 + cc3));
365 ang2 = -(shift + f)*M_PI*2.0L/max_ang + M_PI;
366 if ( select_on_pps_cc ) if ( ccp < cc2 ) ang1 = ang2;
367 if ( ccp < cc2 ) ccp = cc2;
368 }
369
370 delete[] ccs;
371
372 // Determine origins and CC's for both angles and select the best
373 cc = cc1 = p->rotate_cross_correlate_two_way(pref, ang1, res_hi, res_lo, shift_limit, planf, planb);
374 ox = p->image->origin().x();
375 oy = p->image->origin().y();
376 ang = p->image->view_angle();
377 if ( !fullasu && !select_on_pps_cc ) {
378 cc = cc2 = p->rotate_cross_correlate_two_way(pref, ang2, res_hi, res_lo, shift_limit, planf, planb);
379 if ( cc2 < cc1 ) {
380 cc = cc1;
381 p->image->origin(ox, oy, 0);
382 p->image->view_angle(ang);
383 }
384 }
385
386 return cc;
387 }
388
389
417 double img_align2D(Bimage* p, Bimage* pref, int fullasu, double res_polar,
418 int ann_min, int ann_max, Bimage* prs_mask, double shift_limit,
419 fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
420 {
421 if ( verbose & VERB_DEBUG )
422 cout << "DEBUG img_align2D: ann_min=" << ann_min << " ann_max=" << ann_max << endl;
423
424 int nannuli(pref->sizeX()/2); // Sampling same as image
425 int nangles(NPOLANG); // 0.5 degree step size
426 double pimgcc(0); // Polar image correlation coefficient
427
428 Bimage* ppart = p->copy();
429 Bimage* pproj = pref->copy();
430
431 if ( res_polar ) {
432 ppart->fspace_bandpass(0, res_polar, 0, planf_2D, planb_2D);
433 pproj->fspace_bandpass(0, res_polar, 0, planf_2D, planb_2D);
434 }
435
436 // cout << ppart->image->origin() << tab << pproj->image->origin() << endl;
437
438 Bimage* pol = NULL;
439 Bimage* polref = pproj->cartesian_to_cylindrical(nannuli, nangles, 1);
440 delete pproj;
441
442 int i, done(0);
443 double angle, best_angle(0);
444 double da, dx, dy, ap(1e37);
445 double cc, best_cc(-1e37);
446 Vector3<double> translate, prev_translate(1e37, 1e37, 0), best_shift;
447 Bimage* prot;
448
449 for ( i=0; i<5 && !done; i++ ) {
450 pol = ppart->cartesian_to_cylindrical(nannuli, nangles, 1);
451 angle = img_correlate_annuli(pol, polref, fullasu, ann_min, ann_max, planf_1D, planb_1D, pimgcc);
452 delete pol;
453 prot = pref->rotate(pref->size(), fabs(angle));
454 translate = p->find_shift(prot, prs_mask, 0, 0, shift_limit, 0, 1, planf_2D, planb_2D, cc);
455 delete prot;
456 if ( best_cc < cc ) {
457 best_cc = cc;
458 best_shift = translate;
459 best_angle = angle;
460 }
461 da = fabs(angle - ap);
462 dx = fabs(translate.x() - prev_translate.x());
463 dy = fabs(translate.y() - prev_translate.y());
464 prev_translate = translate;
465 ap = angle;
466 if ( i > 0 && da < 0.005 && dx < 0.1 && dy < 0.1 ) done = 1;
467 }
468
469 delete polref;
470 delete ppart;
471
472 p->image->origin(pref->image->origin() + best_shift);
473 p->image->view_angle(best_angle);
474 // p->image->view_angle(pref->image->view_angle() + best_angle);
475
476 return best_cc;
477 }
478
494 int img_align2D(Bimage* p, Bimage* pref, int ann_min, int ann_max,
495 double res_lo, double res_hi, double shift_limit)
496 {
497 // Generate the masks for cross-correlation and cross-validation
498 Bimage* prs_mask = new Bimage(Float, TSimple, p->size(), 1);
499 prs_mask->sampling(p->sampling());
500
501 float band[6];
502 band[0] = p->sizeX()*p->sampling().x();
503 band[1] = -1;
504 band[2] = res_lo;
505 band[3] = 1;
506 band[4] = res_hi;
507 band[5] = 0;
508 prs_mask->mask_fspace_banded(band);
509
510 // Specify FFTW arrays
511 fft_plan planf_1D = fft_setup_plan(NPOLANG, 1, 1, FFTW_FORWARD, 1);
512 fft_plan planb_1D = fft_setup_plan(NPOLANG, 1, 1, FFTW_BACKWARD, 1);
513 fft_plan planf_2D = fft_setup_plan(p->size(), FFTW_FORWARD, 1);
514 fft_plan planb_2D = fft_setup_plan(p->size(), FFTW_BACKWARD, 1);
515
516
517 double cc = img_align2D(p, pref, 1, 0, ann_min, ann_max, prs_mask, shift_limit,
518 planf_1D, planb_1D, planf_2D, planb_2D);
519
520 if ( verbose )
521 cout << "Alignment correlation: " << cc << endl << endl;
522
523 fft_destroy_plan(planf_1D);
524 fft_destroy_plan(planb_1D);
525 fft_destroy_plan(planf_2D);
526 fft_destroy_plan(planb_2D);
527
528 delete prs_mask;
529
530 p->rotate();
531
532 return 0;
533 }
534
535
558 double img_correlate_annuli(Bimage* pol, Bimage* polref, int fullasu,
559 int ann_min, int ann_max, fft_plan planf, fft_plan planb, double& cc_max)
560 {
561 if ( ann_min > ann_max ) swap(ann_min, ann_max);
562 if ( ann_min < 0 ) ann_min = 0;
563 if ( ann_max >= pol->sizeY() ) ann_max = pol->sizeY() - 1;
564
565 Bimage* pcc = polref->pack_two_in_complex(pol);
566
567 if ( verbose & VERB_PROCESS )
568 cout << "Doing row cross-correlations from annulus " << ann_min << " to annulus " << ann_max << endl;
569
570 // Do FFT's in place
571 long i, j, ij, icc, n;
572 // int nannuli = ann_max - ann_min + 1;
573 size_t offset, linesize(pcc->channels()*pcc->sizeX());
574 double scale, sum1, sum2;
575 Complex<float> d1, d2;
576
577 float* cc = new float[2*pcc->sizeX()];
578 for ( i=0; i<2*pcc->sizeX(); i++ ) cc[i] = 0;
579
580 // Specify FFTW arrays
581 Complex<float>* data;
582 Complex<float>* temp1 = new Complex<float>[pcc->sizeX()];
583 Complex<float>* temp2 = new Complex<float>[pcc->sizeX()];
584
585 // Correlate polar images line by line
586 for ( i=ann_min, offset=i*linesize; i<=ann_max; i++, offset+=linesize ) {
587 data = (Complex<float> *) (pcc->data_pointer(offset));
588 fftw(planf, data);
589 sum1 = sum2 = 0;
590 for ( j=0; j<pcc->sizeX(); j++ ) temp1[j] = 0;
591 if ( !fullasu ) for ( j=0; j<pcc->sizeX(); j++ ) temp2[j] = 0;
592 for ( j=0; j<pcc->sizeX()/2; j++ ) {
593 ij = -j;
594 if ( ij < 0 ) ij += pcc->sizeX();
595 d1 = data[j].unpack_first(data[ij]);
596 d2 = data[j].unpack_second(data[ij]);
597 temp1[ij] = d1 * d2.conj();
598 temp1[i] = temp1[ij].conj();
599 if ( !fullasu ) {
600 temp2[ij] = d1 * d2;
601 temp2[i] = temp2[ij].conj();
602 }
603 sum1 += d1.power();
604 sum2 += d2.power();
605 }
606 if ( sum1 && sum2 ) {
607 scale = 0.5/sqrt(sum1*sum2);
608 for ( j=0; j<pcc->sizeX(); j++ ) temp1[j] *= scale;
609 if ( !fullasu ) for ( j=0; j<pcc->sizeX(); j++ ) temp2[j] *= scale;
610 }
611 fftw(planb, temp1);
612 for ( j=0; j<pcc->sizeX(); j++ ) cc[j] += temp1[j].real();
613 if ( !fullasu ) {
614 fftw(planb, temp2);
615 for ( j=0, ij=pcc->sizeX(); j<pcc->sizeX(); j++, ij++ ) cc[ij] += temp2[j].real();
616 }
617 }
618
619 delete[] temp1;
620 delete[] temp2;
621
622 n = ( fullasu )? pcc->sizeX(): 2*pcc->sizeX();
623 icc = 0;
624 cc_max = cc[0];
625 for ( j=0; j<n; j++ ) {
626 if ( cc_max < cc[j] ) {
627 cc_max = cc[j];
628 icc = j;
629 }
630 }
631 double angle = icc*M_PI*(2.0/pcc->sizeX());
632 // if ( icc >= pcc->sizeX() ) angle = ((long)pcc->sizeX() - icc)*M_PI*(2.0/pcc->sizeX());
633 if ( icc >= pcc->sizeX() ) angle = (icc - 2.0*pcc->sizeX())*M_PI*(2.0/pcc->sizeX());
634
635 if ( fabs(angle) < 1e-10 ) angle = 0;
636
637 if ( verbose & VERB_DEBUG )
638 cout << "DEBUG img_correlate_annuli: " << icc << tab << angle << tab << angle*180.0/M_PI << tab << cc[icc] << endl;
639
640 delete[] cc;
641
642 delete pcc;
643
644 if ( verbose & VERB_PROCESS )
645 cout << "Best in-plane rotation angle: " << angle*180.0/M_PI << endl;
646
647 return angle;
648 }
649
Vector3::z
Type z()
Definition: Vector3.h:139
fft_setup_plan
fft_plan fft_setup_plan(size_t x, size_t y, size_t z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
Definition: fft.cpp:31
Bimage::mask_fspace_banded
int mask_fspace_banded(float *band)
Generate reciprocal space mask based on a specification of bands.
Definition: Bimage_mask.cpp:665
Complex::unpack_second
Complex unpack_second(Complex c)
Definition: Complex.h:116
Bimage::unpack_combined_transform
Bimage * unpack_combined_transform()
Unpacks a complex transform obtained from two real images.
Definition: Bimage_complex.cpp:671
img_align.h
Header file for functions to align images.
Bimage.h
Header file for image class.
img_align
Transform img_align(Bimage *p1, Bimage *p2, Vector3< int > tile_size, double res_lo, double res_hi, double max_shift, int filter_flag, int refine_flag)
Aligns the second image to the first.
Definition: img_align.cpp:152
fftw
void fftw(fftw_plan plan, int howmany, fftw_complex *in, int istride, int idist, fftw_complex *out, int ostride, int odist)
Definition: executor.c:402
Bimage::extract_tiles
Bimage * extract_tiles(size_t nn, size_t ntiles, Vector3< size_t > *coords, Vector3< size_t > tile_size)
Extracts a set of tiles at specified positions from an image into a new image.
Definition: Bimage_extract.cpp:325
Bimage::fft
int fft()
Definition: Bimage.h:692
utilities.h
Header file for general utilities.
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:106
NANG
#define NANG
Definition: img_align.h:13
cross_correlate_two_way
double * cross_correlate_two_way(int n, double *x, double *y)
Definition: img_align.cpp:30
img_pps_angular_correlation
double * img_pps_angular_correlation(Bimage *p, Bimage *pref, double res_hi, double res_lo, fft_plan planf)
Definition: img_align.cpp:86
Transform::angle
double angle
Definition: Transform.h:29
Bimage::polar_power_spectrum
Bimage * polar_power_spectrum(double resolution, size_t num_angle)
Calculates the polar power spectrum of a 2D transform amplitude or intensity image.
Definition: Bimage_polar.cpp:695
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
Transform::fom
double fom
Definition: Transform.h:32
Bmarker
Definition: marker.h:21
add_item
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Definition: linked_list.cpp:26
Complex::conj
Complex conj()
Definition: Complex.h:106
Vector3< int >
img_align2D_pps
double img_align2D_pps(Bimage *p, Bimage *pref, int fullasu, double res_hi, double res_lo, double shift_limit, fft_plan planf, fft_plan planb)
Finds the best in-plane alignment for two 2D images using polar power spectra.
Definition: img_align.cpp:319
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:101
Vector3::max
Type max()
Definition: Vector3.h:149
Bimage::size
Vector3< size_t > size() const
Definition: Bimage.h:327
verbose
int verbose
TSimple
Definition: Bimage.h:51
Bimage::complex_to_amplitudes
void complex_to_amplitudes()
The amplitudes from a complex image is written to a simple image.
Definition: Bimage_complex.cpp:114
Float
Definition: utilities.h:151
Bimage
General image parameter class.
Definition: Bimage.h:152
Bimage::real_size
Vector3< double > real_size()
Definition: Bimage.h:437
Transform
Definition: Transform.h:24
M_PI
#define M_PI
Definition: utilities.h:53
linked_list.h
Header file for generalized linked list functions.
Bimage::fspace_bandpass
int fspace_bandpass(double res_hi, double res_lo, double width)
Applies a bandpass filter to an image.
Definition: Bimage_fspace.cpp:311
Bimage::channels
size_t channels()
Definition: Bimage.h:325
Bimage::sampling
void sampling(double s)
Definition: Bimage.h:440
ps_marker_errors
int ps_marker_errors(Bstring &filename, Bmarker *set1, Bmarker *set2, Transform t, Vector3< int > size, float err_scale)
Output a postscript file that graphs the deviations of points in a Bmarker from their predicted locat...
Definition: ps_marker.cpp:34
ps_marker.h
Header file for postscript tools dealing with Bmarkers.
Vector3::min
Type min()
Definition: Vector3.h:143
img_correlate_annuli
double img_correlate_annuli(Bimage *pol, Bimage *polref, int fullasu, int ann_min, int ann_max, fft_plan planf, fft_plan planb, double &cc_max)
Correlate annuli of a polar image.
Definition: img_align.cpp:558
Transform::scale
Vector3< double > scale
Definition: Transform.h:31
Vector3::x
Type x()
Definition: Vector3.h:137
Bmarker::fom
float fom
Definition: marker.h:28
Bimage::file_name
void file_name(Bstring s)
Definition: Bimage.h:213
Bimage::rotate_cross_correlate_two_way
double rotate_cross_correlate_two_way(Bimage *pref, double angle, double res_hi, double res_lo, double shift_limit, fft_plan planf, fft_plan planb)
Definition: Bimage_correlate.cpp:603
Transform::trans
Vector3< double > trans
Definition: Transform.h:30
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:132
Bmarker::next
Bmarker * next
Definition: marker.h:22
fftwnd_data
Definition: fftw.h:355
VERB_RESULT
#define VERB_RESULT
Definition: utilities.h:99
Bimage::images
size_t images()
Definition: Bimage.h:438
Complex
Definition: Complex.h:23
Bimage::filter_extremes
int filter_extremes()
Filters the extremes out of a micrograph image.
Definition: Bimage_segment.cpp:594
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:231
Bstring
Definition: Bstring.h:28
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2414
Bimage::sizeX
void sizeX(size_t nx)
Definition: Bimage.h:330
img_align2D
double img_align2D(Bimage *p, Bimage *pref, int fullasu, double res_polar, int ann_min, int ann_max, Bimage *prs_mask, double shift_limit, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
Finds the best in-plane alignment for two 2D images using polar power spectra.
Definition: img_align.cpp:417
FFTW_BACKWARD
Definition: fftw.h:64
markers_find_rottrans
Transform markers_find_rottrans(Bmarker *set1, Bmarker *set2, float tolerance)
Finds the rotation and shift between two sets of vectors.
Definition: marker.cpp:394
fft_destroy_plan
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Definition: fft.cpp:97
Bimage::sizeY
void sizeY(size_t ny)
Definition: Bimage.h:331
Bimage::rotate
int rotate()
Rotates an image using parameters defined in the image in place.
Definition: Bimage_transform.cpp:220
Bmarker::loc
Vector3< float > loc
Definition: marker.h:25
Bimage::find_shift
int find_shift(Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
Calculates a cross-correlation map to find the shift for the pair of images.
Definition: Bimage_correlate.cpp:671
Bimage::cartesian_to_cylindrical
Bimage * cartesian_to_cylindrical(size_t nannuli, size_t nphi, int flag=0)
Calculates an image with cylindrical coordinates.
Definition: Bimage_polar.cpp:529
data
JSAMPIMAGE data
Definition: jpeglib.h:945
Complex::unpack_first
Complex unpack_first(Complex c)
Definition: Complex.h:113
Complex::power
double power()
Definition: Complex.h:103
Bimage::pack_two_in_complex
Bimage * pack_two_in_complex(Bimage *p)
Packs two real images into one complex image.
Definition: Bimage_complex.cpp:600
FFTW_FORWARD
Definition: fftw.h:64
NPOLANG
#define NPOLANG
Definition: img_align.h:14
VERB_LABEL
#define VERB_LABEL
Definition: utilities.h:100
Vector3::y
Type y()
Definition: Vector3.h:138
Bsub_image::view_angle
void view_angle(double d)
Definition: Bimage.h:138
marker.h
Header file for image parameter functions.
Bmarker::sel
int sel
Definition: marker.h:29
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bimage::image
Bsub_image * image
Definition: Bimage.h:183
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:483