To proccess an image out-of-place.
For those processors which can only be processed out-of-place, override this function to give the right behavior.
13328 if (image->is_complex()) cimage = image->copy();
13329 else cimage = image->do_fft();
13330 cimage->process_inplace(
"xform.phaseorigin.tocorner");
13336 if (nky<4 || nky>=cimage->get_ysize()/2) nky=cimage->get_ysize()/8;
13337 if (nkx<5 || nky>=cimage->get_xsize()/2) nkx=cimage->get_xsize()/8+1;
13341 ret->set_complex(1);
13342 ret->set_fftpad(1);
13349 float dsbg=1.0/(float(image->get_attr(
"apix_x"))*image->get_xsize()*4.0);
13353 ret2->set_complex(1);
13355 ret2->set_fftpad(1);
13359 size_t laysize=nkx*2*nky*2;
13360 cimage=
new EMData((nkx+fp+2)*2,(nky+fp+2)*2,1);
13361 cimage->set_complex(1);
13363 cimage->set_fftpad(1);
13365 for (
int k=-cimage->get_ysize()/2; k<cimage->
get_ysize()/2; k++) {
13366 for (
int j=0; j<cimage->get_xsize()/2; j++) {
13367 cimage->set_complex_at(j,k,tmp->get_complex_at(j,k));
13373 for (
int k=2; k<2+fp; k++) {
13380 for (
float ang=0; ang<360.0; ang+=360.0/(nky*M_PI) ) {
13381 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang));
13383 for (
int jy=-nky; jy<nky; jy++) {
13384 for (
int jx=0; jx<nkx; jx++) {
13385 if (jx==0 && jy<0)
continue;
13392 complex<double> v1 = (complex<double>)cimage2->get_complex_at(jx,jy);
13393 complex<double> v2 = (complex<double>)cimage2->get_complex_at(kx,ky);
13394 complex<double> v3 = (complex<double>)cimage2->get_complex_at(jkx,jky);
13395 ret->add_complex_at(jx,jy,0,(complex<float>)(v1*v2*std::conj(v3)));
13407 for (
int jy=-2; jy<=2; jy++) {
13408 for (
int jx=0; jx<=2; jx++) {
13409 ret->set_complex_at(jx,jy,0.0f);
13412 memcpy(ret2->get_data()+laysize*(k-2),ret->get_data(),laysize*
sizeof(
float));
13416 ret2->set_attr(
"dsbg",dsbg);
13430 cimage=
new EMData((nkx*2+fp)*2-2,(nky*2+fp)*2,1);
13431 cimage->set_complex(1);
13433 cimage->set_fftpad(1);
13434 int step=int(floor(tmp->get_ysize()/(2.0f*cimage->get_ysize())));
13436 if (step==0) step=1;
13439 for (
int k=-cimage->get_ysize()/2; k<cimage->
get_ysize()/2; k++) {
13440 for (
int j=0; j<cimage->get_xsize()/2; j++) {
13441 cimage->set_complex_at(j,k,tmp->get_complex_at(j*step,k*step));
13448 for (
int dk=0; dk<fp; dk++) {
13455 for (
float ang=0; ang<360.0; ang+=360.0/(nky*M_PI) ) {
13456 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang,
"zerocorners",1));
13458 for (
int jy=-nky; jy<nky; jy++) {
13459 for (
int jx=0; jx<nkx; jx++) {
13460 if ((jx==0 && jy<0) || (jx+dk<4))
continue;
13472 complex<double> v1 = (complex<double>)cimage2->get_complex_at(jx,jy);
13473 complex<double> v2 = (complex<double>)cimage2->get_complex_at(kx,ky);
13474 complex<double> v3 = (complex<double>)cimage2->get_complex_at(jkx,jky);
13476 ret->add_complex_at(jx,jy,0,(complex<float>)(v1*v2*std::conj(v3)));
13505 for (
int x=0;
x<nkx-1;
x++) {
13506 for (
int y=-nky;
y<nky;
y++) {
13507 complex<float> val=ret->get_complex_at(
x,
y);
13509 ret2->set_value_at(
x,
y+nky+nky*dk*2,cbrt(
std::real(val)));
13517 ret2->set_attr(
"is_bispec_fp",(
int)fp);
13526 int rsize=cimage->get_ysize()/4-minr-2;
13527 if (rsize>nky) rsize=nky;
13533 line->set_complex(1);
13535 line->set_fftpad(1);
13537 for (
int angi=0; angi<nang; angi++) {
13538 float ofs=M_PI/float(nang);
13539 float dx=cos(2.0*M_PI*angi/
float(nang)+ofs);
13540 float dy=sin(2.0*M_PI*angi/
float(nang)+ofs);
13560 for (
int dr=0; dr<rfp; dr++) {
13562 for (
int r=minr; r<rsize+minr; r++) {
13565 float kx=dx*(r+dr);
13566 float ky=dy*(r+dr);
13569 complex<double> v1 = (complex<double>)cimage->get_complex_at_interp(jx,jy);
13570 complex<double> v2 = (complex<double>)cimage->get_complex_at_interp(kx,ky);
13571 complex<double> v3 = (complex<double>)cimage->get_complex_at_interp(jx+kx,jy+ky);
13572 complex<double> bv = v1*v2*std::conj(v3);
13573 line->set_complex_at(r,0,0,complex<float>(bv));
13574 lsq+=std::norm(bv);
13576 float rsig = 1.0/
sqrt(lsq/
double(rsize));
13595 for (
int i=0; i<rsize*2; i++) ret2->set_value_at(angi,i+dr*rsize*2,line->get_value_at(i+minr*2,0)*rsig);
13620 ret2->set_attr(
"is_bispec_rfp",(
int)rfp);
13631 for (
float ang=0; ang<360.0; ang+=360.0/(nky*M_PI) ) {
13633 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang));
13635 for (
int jy=-nky; jy<nky; jy++) {
13636 for (
int jx=0; jx<nkx; jx++) {
13643 complex<double> v1 = (complex<double>)cimage2->get_complex_at(jx,jy);
13644 complex<double> v2 = (complex<double>)cimage2->get_complex_at(kx,ky);
13645 complex<double> v3 = (complex<double>)cimage2->get_complex_at(jkx,jky);
13646 ret->add_complex_at(jx,jy,0,(complex<float>)(v1*v2*std::conj(v3)));
13654 if (image->is_complex()) cimage = image->copy();
13655 else cimage = image->do_fft();
13656 cimage->process_inplace(
"xform.phaseorigin.tocorner");
13662 printf(
"nky = %d , size= %d \n",nky,image->get_xsize());
13678 ret->set_complex(0);
13689 for (
float ang=0; ang<360.0; ang+=2 ) {
13690 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang));
13692 for (
int qy=-nky; qy<nky; qy++) {
13693 for (
int qx=-nkx; qx<nkx; qx++) {
13698 if (abs(kqx)>nkx || abs(kqy)>nky)
continue;
13701 complex<double> v1 = (complex<double>)cimage2->get_complex_at(kx,ky);
13702 complex<double> v2 = (complex<double>)cimage2->get_complex_at(qx,qy);
13703 complex<double> v3 = (complex<double>)cimage2->get_complex_at(kqx,kqy);
13704 complex<double> vTotal = (complex<double>)(v1*v2*std::conj(v3));
13705 double RealV = (
real)(vTotal);
13706 int jxInd = (qx+2*nkx)%(2*nkx);
13707 int jyInd = (qy+2*nky)%(2*nky);
13709 double OldVal = ret->get_value_at(jxInd,jyInd,0);
13710 ret->set_value_at(jxInd,jyInd,0,OldVal+RealV);
13720 if (image->is_complex()) cimage = image->copy();
13721 else cimage = image->do_fft();
13722 cimage->process_inplace(
"xform.phaseorigin.tocorner");
13731 printf(
"nkx = %d, nky = %d , size= %d \n",nkx,nky,image->get_xsize());
13735 ret->set_complex(0);
13741 for (
float ang=0; ang<360.0; ang+=2 ) {
13742 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang));
13744 for (
int qy=-k; qy<k+1; qy++) {
13745 if (qy*qy> (0.75)*k*k)
continue;
13746 for (
int qx=-k; qx<1; qx++) {
13747 if ((qx+k)*(qx+k) > (k*k - qy*qy))
continue;
13750 complex<double> v1 = (complex<double>)cimage2->get_complex_at(kx,ky);
13751 complex<double> v2 = (complex<double>)cimage2->get_complex_at(qx,qy);
13752 complex<double> v3 = (complex<double>)cimage2->get_complex_at(kqx,kqy);
13753 complex<double> vTotal = (complex<double>)(v1*v2*std::conj(v3));
13754 double RealV = (
real)(vTotal);
13755 int qxInd = (qx+nkx)%(nkx);
13756 int qyInd = (qy+nky)%(nky);
13757 int NegQx = k/2 +qx ;
13758 int QyInd = qy+Nyquist;
13762 double OldVal = ret->get_value_at(NegQx,QyInd,0);
13764 ret->set_value_at(NegQx,QyInd,0,OldVal+RealV);
13778 if (image->is_complex()) cimage = image->copy();
13779 else cimage = image->do_fft();
13781 cimage->process_inplace(
"xform.phaseorigin.tocorner");
13788 int csizex = cimage->get_xsize();
13789 int csizey = cimage->get_ysize();
13791 printf(
"csizex = %d, csizey = %d \n", csizex , csizey );
13793 Nyquist = (csizey+1)/2;
13795 printf(
"csizex = %d, csizey = %d, Nyquist= %d \n", csizex , csizey, Nyquist);
13797 int nkx= Nyquist/2+1;
13798 int nky= 2*Nyquist+2;
13799 int nkz= Nyquist+1;
13802 printf(
"nkx = %d, nky = %d , size= %d \n",nkx,nky,image->get_xsize());
13807 ret->set_complex(0);
13812 for (
float ang=0; ang<360.0; ang+=2 ) {
13813 EMData *cimage2=cimage->process(
"xform",
Dict(
"alpha",ang));
13815 for (
int k=0; k < Nyquist+1;k++){
13818 int qyMax =
sqrt(3*k2/4);
13820 for (
int qy=-qyMax; qy<qyMax+1; qy++) {
13822 int qxMin =k/2; qxMin *= -1;
13823 int qxMax = k -
sqrt(k2-qy*qy)+0.999999; qxMax *= -1;
13824 for (
int qx=qxMin; qx<qxMax+1; qx++) {
13829 complex<double> v1 = (complex<double>)cimage2->get_complex_at(k,0);
13830 complex<double> v2 = (complex<double>)cimage2->get_complex_at(qx,qy);
13831 complex<double> v3 = (complex<double>)cimage2->get_complex_at(kqx,kqy);
13832 complex<double> vTotal = (complex<double>)(v1*v2*std::conj(v3));
13833 double RealV = (
real)(vTotal);
13834 int qxInd = (qx+nkx)%(nkx);
13835 int qyInd = (qy+nky)%(nky);
13836 int NegQx = k/2 +qx ;
13837 int QyInd = qy+Nyquist;
13840 double OldVal = ret->get_value_at(NegQx,QyInd,k);
13842 ret->set_value_at(NegQx,QyInd,k,OldVal+RealV);
13855 for (
int jy=-nky; jy<nky; jy++) {
13856 for (
int jx=0; jx<nkx; jx++) {
13861 complex<double> v1 = (complex<double>)cimage->get_complex_at(jx,jy);
13862 complex<double> v2 = (complex<double>)cimage->get_complex_at(kx,ky);
13863 complex<double> v3 = (complex<double>)cimage->get_complex_at(jkx,jky);
13864 ret->set_complex_at(jx,jy,(complex<float>)(v1*v2*std::conj(v3)));
13876 for (
int jy=-nky; jy<nky; jy++) {
13877 for (
int jx=0; jx<nkx; jx++) {
13879 complex<double> v1 = (complex<double>)cimage->get_complex_at(jx,jy);
13880 complex<double> v2 = (complex<double>)cimage->get_complex_at(kx,ky);
13881 complex<double> v3 = (complex<double>)cimage->get_complex_at(jx+kx,jy+ky);
13882 ret->set_complex_at(jx,jy,(complex<float>)(v1*v2*std::conj(v3)));
13888 for (
int jy=-nky; jy<nky; jy++) {
13889 ret->set_complex_at(0,jy,ret->get_complex_at(0,jy)/
sqrt(2.0f));
13890 ret->set_complex_at(nkx-1,jy,ret->get_complex_at(nkx-1,jy)/
sqrt(2.0f));
Dict is a dictionary to store <string, EMObject> pair.
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
EMData stores an image's data and defines core image processing routines.
static int calc_best_fft_size(int low)
Search the best FFT size with good primes.
static float hypot_fast(int x, int y)
Euclidean distance in 2D for integers computed fast using a cached lookup table.
EMData * sqrt() const
return square root of current image
EMData * real() const
return real part of a complex image as a real image format, if this image is a real image,...
#define ImageDimensionException(desc)