a function or class that is CUDA enabled


Classes

class  EMAN::TranslationalAligner
 Translational 2D Alignment using cross correlation. More...
class  EMAN::RotationalAligner
 rotational alignment using angular correlation More...
class  EMAN::RotateTranslateAligner
 rotational, translational alignment More...
class  EMAN::RotateFlipAligner
 rotational and flip alignment More...
class  EMAN::RotateTranslateFlipAligner
 rotational, translational and flip alignment More...
class  EMAN::Rotate180Processor
 Rotate by 180 using pixel swapping, works for 2D only. More...
class  EMAN::TransformProcessor
 Transform the image using a Transform object. More...
class  EMAN::IntTranslateProcessor
 Translate the image an integer amount Uses EMData::clip_inplace (inplace) and EMData::get_clip (out of place) to do the translation. More...
class  EMAN::BinarizeFourierProcessor
 A thresholding processor for Fourier images based on the amplitude component. More...

Functions

EMDataEMAN::EMData::do_fft () const
 For fft, wavelet, insert data.
EMDataEMAN::EMData::do_ift ()
 return the inverse fourier transform (IFT) image of the current image.
void EMAN::EMData::ri2ap ()
 convert the complex image from real/imaginary to amplitude/phase
void EMAN::EMData::ap2ri ()
 convert the complex image from amplitude/phase to real/imaginary
void EMAN::EMData::ri2inten ()
 convert the complex image from real/imaginary to Intensity/0.
void EMAN::EMData::insert_clip (const EMData *const block, const IntPoint &origin)
 Insert a clip into this image.
 EMAN::EMData::EMData (const EMData &that)
 Construct from an EMData (copy constructor).
EMDataEMAN::EMData::operator= (const EMData &that)
 EMData assignment operator Performs a deep copy.
EMDataEMAN::EMData::get_clip (const Region &area, const float fill=0) const
 Get an inclusive clip.
EMDataEMAN::EMData::calc_ccf (EMData *with, fp_flag fpflag=CIRCULANT, bool center=false)
 Calculate Cross-Correlation Function (CCF).
EMDataEMAN::EMData::calc_ccfx (EMData *const with, int y0=0, int y1=-1, bool nosum=false)
 Calculate Cross-Correlation Function (CCF) in the x-direction and adds them up, result in 1D.
EMDataEMAN::EMData::make_rotational_footprint (bool unwrap=true)
 Makes a 'rotational footprint', which is an 'unwound' autocorrelation function.
EMDataEMAN::EMData::unwrap (int r1=-1, int r2=-1, int xs=-1, int dx=0, int dy=0, bool do360=false, bool weight_radial=true) const
 Maps to polar coordinates from Cartesian coordinates.
EMData * do_fft () const
 $Id$
EMData * do_ift ()
 return the inverse fourier transform (IFT) image of the current image.
void ri2ap ()
 convert the complex image from real/imaginary to amplitude/phase
void ap2ri ()
 convert the complex image from amplitude/phase to real/imaginary
void ri2inten ()
 convert the complex image from real/imaginary to Intensity/0.
void insert_clip (const EMData *const block, const IntPoint &origin)
 Insert a clip into this image.

Function Documentation

void ap2ri (  ) 

convert the complex image from amplitude/phase to real/imaginary

Referenced by EMAN::EMData::ap2ri().

void EMData::ap2ri (  )  [inherited]

EMData * EMData::calc_ccf ( EMData with,
fp_flag  fpflag = CIRCULANT,
bool  center = false 
) [inherited]

Calculate Cross-Correlation Function (CCF).

Calculate the correlation of two 1-, 2-, or 3-dimensional images. Note: this method internally just calls the correlation function from fundamentals.h.

Parameters:
[in] with The image used to calculate the CCF. If 'with' is NULL, the autocorrelation function is computed instead.
[in] fpflag Specify how periodicity (or normalization) should be handled. See fundamentals.h The default is "CIRCULANT". for specific flags.
center whether or not to center the image (bring bottom left corner to center)
Returns:
Real-space image.
Exceptions:
ImageDimensionException if nx > 1 and nx < 2*radius + 1

Definition at line 1408 of file emdata.cpp.

References EMAN::EMData::clip_inplace(), EMAN::convolution(), EMAN::correlation(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

Referenced by EMAN::TranslationalAligner::align(), EMAN::EMData::calc_flcf(), EMAN::TomoDotCmp::cmp(), EMAN::EMData::make_rotational_footprint(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

01409 {
01410         ENTERFUNC;
01411         if( with == 0 ) {
01412                 EXITFUNC;
01413                 return convolution(this,this,fpflag, center);
01414         }
01415         else if ( with == this ){ // this if statement is not necessary, the correlation function tests to see if with == this
01416                 EXITFUNC;
01417                 return correlation(this, this, fpflag,center);
01418         }
01419         else {
01420                 
01421 #ifdef EMAN2_USING_CUDA
01422                 if (gpu_operation_preferred()) {
01423                         EXITFUNC;
01424                         return calc_ccf_cuda(with,false,center);
01425                 }
01426 #endif
01427                 
01428                 // If the argument EMData pointer is not the same size we automatically resize it
01429                 bool undoresize = false;
01430                 int wnx = with->get_xsize(); int wny = with->get_ysize(); int wnz = with->get_zsize();
01431                 if ( wnx != nx || wny != ny || wnz != nz ) {
01432                         Region r((wnx-nx)/2, (wny-ny)/2, (wnz-nz)/2,nx,ny,nz);
01433                         with->clip_inplace(r);
01434                         undoresize = true;
01435                 }
01436 
01437                 EMData* cor = correlation(this, with, fpflag, center);
01438 
01439                 // If the argument EMData pointer was resized, it is returned to its original dimensions
01440                 if ( undoresize ) {
01441                         Region r((nx-wnx)/2, (ny-wny)/2,(nz-wnz)/2,wnx,wny,wnz);
01442                         with->clip_inplace(r);
01443                 }
01444 
01445                 EXITFUNC;
01446                 return cor;
01447         }
01448 }

EMData * EMData::calc_ccfx ( EMData *const   with,
int  y0 = 0,
int  y1 = -1,
bool  nosum = false 
) [inherited]

Calculate Cross-Correlation Function (CCF) in the x-direction and adds them up, result in 1D.

WARNING: this routine will modify the 'this' and 'with' to contain 1D fft's without setting some flags. This is an optimization for rotational alignment.

Parameters:
with The image used to calculate CCF.
y0 Starting position in x-direction.
y1 Ending position in x-direction. '-1' means the end of the row.
nosum If true, returns an image y1-y0+1 pixels high.
See also:
calc_ccf()
Exceptions:
NullPointerException If input image 'with' is NULL.
ImageFormatException If 'with' and 'this' are not same size.
ImageDimensionException If 'this' image is 3D.
Returns:
The result image containing the CCF.

Definition at line 1450 of file emdata.cpp.

References EMAN::EMData::EMData(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, ImageFormatException, EMAN::EMData::is_complex_x(), EMAN::EMUtil::is_same_size(), LOGERR, NullPointerException, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::set_size(), EMAN::EMData::to_zero(), and EMAN::EMData::update().

Referenced by EMAN::RTFExhaustiveAligner::align(), EMAN::RotatePrecenterAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), and EMAN::EMData::make_footprint().

01451 {
01452         ENTERFUNC;
01453 
01454 #ifdef EMAN2_USING_CUDA
01455         if (gpu_operation_preferred() ) {
01456                 EXITFUNC;
01457                 return calc_ccfx_cuda(with,y0,y1,no_sum);
01458         }
01459 #endif
01460 
01461         if (!with) {
01462                 LOGERR("NULL 'with' image. ");
01463                 throw NullPointerException("NULL input image");
01464         }
01465 
01466         if (!EMUtil::is_same_size(this, with)) {
01467                 LOGERR("images not same size: (%d,%d,%d) != (%d,%d,%d)",
01468                            nx, ny, nz,
01469                            with->get_xsize(), with->get_ysize(), with->get_zsize());
01470                 throw ImageFormatException("images not same size");
01471         }
01472         if (get_ndim() > 2) {
01473                 LOGERR("2D images only");
01474                 throw ImageDimensionException("2D images only");
01475         }
01476 
01477         if (y1 <= y0) {
01478                 y1 = ny;
01479         }
01480 
01481         if (y0 >= y1) {
01482                 y0 = 0;
01483         }
01484 
01485         if (y0 < 0) {
01486                 y0 = 0;
01487         }
01488 
01489         if (y1 > ny) {
01490                 y1 = ny;
01491         }
01492         if (is_complex_x() || with->is_complex_x() ) throw; // Woops don't support this anymore!
01493 
01494         static int nx_fft = 0;
01495         static int ny_fft = 0;
01496         static EMData f1;
01497         static EMData f2;
01498         static EMData rslt;
01499 
01500         int height = y1-y0;
01501         int width = (nx+2-(nx%2));
01502         if (width != nx_fft || height != ny_fft ) {
01503                 f1.set_size(width,height);
01504                 f2.set_size(width,height);
01505                 rslt.set_size(nx,height);
01506                 nx_fft = width;
01507                 ny_fft = height;
01508         }
01509 
01510         float *d1 = get_data();
01511         float *d2 = with->get_data();
01512         float *f1d = f1.get_data();
01513         float *f2d = f2.get_data();
01514         for (int j = 0; j < height; j++) {
01515                 EMfft::real_to_complex_1d(d1 + j * nx, f1d+j*width, nx);
01516                 EMfft::real_to_complex_1d(d2 + j * nx, f2d+j*width, nx);
01517         }
01518 
01519         for (int j = 0; j < height; j++) {
01520                 float *f1a = f1d + j * width;
01521                 float *f2a = f2d + j * width;
01522 
01523                 for (int i = 0; i < width / 2; i++) {
01524                         float re1 = f1a[2*i];
01525                         float re2 = f2a[2*i];
01526                         float im1 = f1a[2*i+1];
01527                         float im2 = f2a[2*i+1];
01528 
01529                         f1d[j*width+i*2] = re1 * re2 + im1 * im2;
01530                         f1d[j*width+i*2+1] = im1 * re2 - re1 * im2;
01531                 }
01532         }
01533 
01534         float* rd = rslt.get_data();
01535         for (int j = y0; j < y1; j++) {
01536                 EMfft::complex_to_real_1d(f1d+j*width, rd+j*nx, nx);
01537         }
01538 
01539         if (no_sum) {
01540                 rslt.update(); // This is important in terms of the copy - the returned object won't have the correct flags unless we do this
01541                 EXITFUNC;
01542                 return new EMData(rslt);
01543         } else {
01544                 EMData *cf = new EMData(nx,1,1);
01545                 cf->to_zero();
01546                 float *c = cf->get_data();
01547                 for (int j = 0; j < height; j++) {
01548                         for(int i = 0; i < nx; ++i) {
01549                                 c[i] += rd[i+j*nx];
01550                         }
01551                 }
01552                 cf->update();
01553                 EXITFUNC;
01554                 return cf;
01555         }
01556 }

EMData* do_fft (  )  const

$Id$

This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. return the fast fourier transform (FFT) image of the current image. the current image is not changed. The result is in real/imaginary format.

Returns:
The FFT of the current image in real/imaginary format.

EMData * EMData::do_fft (  )  const [inherited]

For fft, wavelet, insert data.

$Id$ This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. return the fast fourier transform (FFT) image of the current image. the current image is not changed. The result is in real/imaginary format.

Returns:
The FFT of the current image in real/imaginary format.

Definition at line 153 of file emdata_transform.cpp.

References EMAN::EMData::copy_head(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageFormatException, EMAN::EMData::is_complex(), LOGERR, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::set_complex(), EMAN::EMData::set_complex_x(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::update().

Referenced by EMAN::CtfAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::EMData::bispecRotTransInvDirect(), EMAN::EMData::bispecRotTransInvN(), EMAN::EMData::calc_mutual_correlation(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::TomoDotCmp::cmp(), EMAN::EMData::common_lines(), EMAN::EMData::convolute(), EMAN::MatchSFProcessor::create_radial_func(), EMAN::EMData::FourInterpol(), EMAN::EMData::FourTruncate(), main(), EMAN::EMData::make_footprint(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::FFTResampleProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), EMAN::Wiener2DAutoAreaProcessor::process(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), and EMAN::GaussFFTProjector::project3d().

00154 {
00155         ENTERFUNC;
00156 
00157 #ifdef EMAN2_USING_CUDA
00158         if (gpu_operation_preferred()) {
00159                 EXITFUNC;
00160                 return do_fft_cuda();
00161         }
00162 #endif
00163 
00164         if ( is_complex() ) {
00165                 LOGERR("real image expected. Input image is complex image.");
00166                 throw ImageFormatException("real image expected. Input image is complex image.");
00167         }
00168 
00169         int nxreal = nx;
00170         int offset = 2 - nx%2;
00171         int nx2 = nx + offset;
00172         EMData* dat = copy_head();
00173         dat->set_size(nx2, ny, nz);
00174         //dat->to_zero();  // do not need it, real_to_complex will do it right anyway
00175         if (offset == 1) dat->set_fftodd(true);
00176         else             dat->set_fftodd(false);
00177 
00178         float *d = dat->get_data();
00179         //std::cout<<" do_fft "<<rdata[5]<<"  "<<d[5]<<std::endl;
00180         EMfft::real_to_complex_nd(get_data(), d, nxreal, ny, nz);
00181 
00182         dat->update();
00183         dat->set_fftpad(true);
00184         dat->set_complex(true);
00185         if(dat->get_ysize()==1 && dat->get_zsize()==1) dat->set_complex_x(true);
00186         dat->set_ri(true);
00187 
00188         EXITFUNC;
00189         return dat;
00190 }

EMData* do_ift (  ) 

return the inverse fourier transform (IFT) image of the current image.

the current image may be changed if it is in amplitude/phase format as opposed to real/imaginary format - if this change is performed it is not undone.

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current image's inverse fourier transform image.

EMData * EMData::do_ift (  )  [inherited]

return the inverse fourier transform (IFT) image of the current image.

the current image may be changed if it is in amplitude/phase format as opposed to real/imaginary format - if this change is performed it is not undone.

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current image's inverse fourier transform image.

Definition at line 240 of file emdata_transform.cpp.

References EMAN::EMData::ap2ri(), EMAN::EMData::copy_head(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageFormatException, EMAN::EMData::is_complex(), EMAN::EMData::is_fftodd(), EMAN::EMData::is_ri(), LOGERR, LOGWARN, EMAN::EMData::mult(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::rdata, EMAN::EMData::set_complex(), EMAN::EMData::set_complex_x(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::update().

Referenced by EMAN::EMData::calc_mutual_correlation(), EMAN::OptVarianceCmp::cmp(), EMAN::EMData::convolute(), EMAN::EMData::FH2Real(), EMAN::CtfAverager::finish(), EMAN::CtfCWautoAverager::finish(), main(), EMAN::EMData::make_footprint(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::Wiener2DFourierProcessor::process(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), and EMAN::GaussFFTProjector::project3d().

00241 {
00242         ENTERFUNC;
00243 
00244 #ifdef EMAN2_USING_CUDA
00245         if (gpu_operation_preferred()) {
00246                 EXITFUNC;
00247                 return do_ift_cuda();
00248         }
00249 #endif
00250 
00251         if (!is_complex()) {
00252                 LOGERR("complex image expected. Input image is real image.");
00253                 throw ImageFormatException("complex image expected. Input image is real image.");
00254         }
00255 
00256         if (!is_ri()) {
00257                 LOGWARN("run IFT on AP data, only RI should be used. Converting.");
00258         }
00259 
00260         get_data(); // Required call if GPU caching is being used. Otherwise harmless
00261         EMData* dat = copy_head();
00262         dat->set_size(nx, ny, nz);
00263         ap2ri();
00264 
00265         float *d = dat->get_data();
00266         int ndim = get_ndim();
00267 
00268         /* Do inplace IFT on a image copy, because the complex to real transform of
00269          * nd will destroy its input array even for out-of-place transforms.
00270          */
00271         memcpy((char *) d, (char *) rdata, nx * ny * nz * sizeof(float));
00272 
00273         int offset = is_fftodd() ? 1 : 2;
00274         //cout << "Sending offset " << offset << " " << nx-offset << endl;
00275         if (ndim == 1) {
00276                 EMfft::complex_to_real_nd(d, d, nx - offset, ny, nz);
00277         } else {
00278                 EMfft::complex_to_real_nd(d, d, nx - offset, ny, nz);
00279 
00280 #ifndef CUDA_FFT
00281                 size_t row_size = (nx - offset) * sizeof(float);
00282                 for (int i = 1; i < ny * nz; i++) {
00283                         memmove((char *) &d[i * (nx - offset)], (char *) &d[i * nx], row_size);
00284                 }
00285 #endif
00286         }
00287 
00288         dat->set_size(nx - offset, ny, nz);     //remove the padding
00289 #if defined     FFTW2 || defined FFTW3  || defined CUDA_FFT //native fft and ACML already done normalization
00290         // SCALE the inverse FFT
00291         float scale = 1.0f / ((nx - offset) * ny * nz);
00292         dat->mult(scale);
00293 #endif  //FFTW2 || FFTW3
00294         dat->set_fftodd(false);
00295         dat->set_fftpad(false);
00296         dat->set_complex(false);
00297         if(dat->get_ysize()==1 && dat->get_zsize()==1)  dat->set_complex_x(false);
00298         dat->set_ri(false);
00299         dat->update();
00300 
00301 
00302         EXITFUNC;
00303         return dat;
00304 }

EMData::EMData ( const EMData that  )  [inherited]

Construct from an EMData (copy constructor).

Performs a deep copy

Parameters:
that the EMData to copy

Definition at line 123 of file emdata.cpp.

References data, EMAN::EMUtil::em_malloc(), EMAN::EMUtil::em_memcpy(), EMAN::EMData::EMData(), EMAN::EMData::EMDATA_GPU_RO_NEEDS_UPDATE, ENTERFUNC, EMAN::EMData::flags, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::rdata, EMAN::EMData::rot_fp, EMAN::EMData::totalalloc, and UnexpectedBehaviorException.

00123                                  :
00124 #ifdef EMAN2_USING_CUDA
00125                 cuda_cache_handle(-1),
00126 #endif //EMAN2_USING_CUDA
00127                 attr_dict(that.attr_dict), rdata(0), supp(0), flags(that.flags), changecount(that.changecount), nx(that.nx), ny(that.ny), nz(that.nz),
00128                 nxy(that.nx*that.ny), xoff(that.xoff), yoff(that.yoff), zoff(that.zoff),all_translation(that.all_translation),  path(that.path),
00129                 pathnum(that.pathnum), rot_fp(0)
00130 {
00131         ENTERFUNC;
00132 
00133         float* data = that.rdata;
00134         size_t num_bytes = nx*ny*nz*sizeof(float);
00135         if (data && num_bytes != 0)
00136         {
00137                 rdata = (float*)EMUtil::em_malloc(num_bytes);
00138                 EMUtil::em_memcpy(rdata, data, num_bytes);
00139         }
00140 #ifdef EMAN2_USING_CUDA
00141         if (num_bytes != 0 && that.cuda_cache_handle != -1 && that.gpu_rw_is_current()) {
00142                 float * cuda_data = that.get_cuda_data();
00143                 CudaDataLock lock2(&that);
00144                 set_size_cuda(nx,ny,nz);
00145                 float *cd = get_cuda_data();
00146                 CudaDataLock lock1(this);
00147                 cudaError_t error = cudaMemcpy(cd,cuda_data,num_bytes,cudaMemcpyDeviceToDevice);
00148                 if ( error != cudaSuccess ) throw UnexpectedBehaviorException("cudaMemcpy failed in EMData copy construction with error: " + string(cudaGetErrorString(error)));
00149         }
00150         // This is a bit of hack
00151         flags |= EMDATA_GPU_RO_NEEDS_UPDATE;
00152 #endif //EMAN2_USING_CUDA
00153         if (that.rot_fp != 0) rot_fp = new EMData(*(that.rot_fp));
00154 
00155         EMData::totalalloc++;
00156 
00157         ENTERFUNC;
00158 }

EMData * EMData::get_clip ( const Region area,
const float  fill = 0 
) const [inherited]

Get an inclusive clip.

Pads to fill if larger than this image.

Parameters:
area The clip area, can be 2D/3D
fill the value to assign new pixels outside the area of the original image
Exceptions:
ImageDimensionException if any of the dimensions of the argument region are negative
Returns:
The clip image.

Definition at line 543 of file emdata.cpp.

References EMAN::EMData::attr_dict, EMAN::EMData::EMData(), ENTERFUNC, EXITFUNC, EMAN::Region::get_ndim(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), ImageDimensionException, EMAN::EMData::insert_clip(), LOGERR, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::Region::origin, EMAN::EMData::path, EMAN::EMData::pathnum, EMAN::EMData::set_path(), EMAN::EMData::set_pathnum(), EMAN::EMData::set_size(), EMAN::EMData::set_xyz_origin(), EMAN::Region::size, EMAN::EMData::to_value(), and EMAN::EMData::update().

Referenced by EMAN::EMData::calc_fast_sigma_image(), main(), EMAN::EMData::make_footprint(), EMAN::ScaleTransformProcessor::process(), EMAN::IntTranslateProcessor::process(), EMAN::SNRProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), and EMAN::EMData::window_center().

00544 {
00545         ENTERFUNC;
00546         if (get_ndim() != area.get_ndim()) {
00547                 LOGERR("cannot get %dD clip out of %dD image", area.get_ndim(),get_ndim());
00548                 return 0;
00549         }
00550 
00551         EMData *result = new EMData();
00552 
00553         // Ensure that all of the metadata of this is stored in the new object
00554         // Originally added to ensure that euler angles were retained when preprocessing (zero padding) images
00555         // prior to insertion into the 3D for volume in the reconstruction phase (see reconstructor.cpp/h).
00556         result->attr_dict = this->attr_dict;
00557         int zsize = (int)area.size[2];
00558         if (zsize == 0 && nz <= 1) {
00559                 zsize = 1;
00560         }
00561         int ysize = (ny<=1 && (int)area.size[1]==0 ? 1 : (int)area.size[1]);
00562 
00563         if ( (int)area.size[0] < 0 || ysize < 0 || zsize < 0 )
00564         {
00565                 // Negative image dimensions not supported - added retrospectively by d.woolford (who didn't write get_clip but wrote clip_inplace)
00566                 throw ImageDimensionException("New image dimensions are negative - this is not supported in the the get_clip operation");
00567         }
00568 
00569 #ifdef EMAN2_USING_CUDA
00570         // Strategy is always to prefer using the GPU if possible
00571         bool use_gpu = false;
00572         if ( gpu_operation_preferred() ) {
00573                 result->set_size_cuda((int)area.size[0], ysize, zsize);
00574                 //CudaDataLock lock(this); // Just so we never have to recopy this data to and from the GPU
00575                 result->get_cuda_data(); // Force the allocation - set_size_cuda is lazy
00576                 // Setting the value is necessary seeing as cuda data is not automatically zeroed
00577                 result->to_value(fill); // This will automatically use the GPU.
00578                 use_gpu = true;
00579         } else { // cpu == True
00580                 result->set_size((int)area.size[0], ysize, zsize);
00581                 if (fill != 0.0) { result->to_value(fill); };
00582         }
00583 #else
00584         result->set_size((int)area.size[0], ysize, zsize);
00585         if (fill != 0.0) { result->to_value(fill); };
00586 #endif //EMAN2_USING_CUDA
00587 
00588         int x0 = (int) area.origin[0];
00589         x0 = x0 < 0 ? 0 : x0;
00590 
00591         int y0 = (int) area.origin[1];
00592         y0 = y0 < 0 ? 0 : y0;
00593 
00594         int z0 = (int) area.origin[2];
00595         z0 = z0 < 0 ? 0 : z0;
00596 
00597         int x1 = (int) (area.origin[0] + area.size[0]);
00598         x1 = x1 > nx ? nx : x1;
00599 
00600         int y1 = (int) (area.origin[1] + area.size[1]);
00601         y1 = y1 > ny ? ny : y1;
00602 
00603         int z1 = (int) (area.origin[2] + area.size[2]);
00604         z1 = z1 > nz ? nz : z1;
00605         if (z1 <= 0) {
00606                 z1 = 1;
00607         }
00608 
00609         result->insert_clip(this,-((IntPoint)area.origin));
00610 
00611         if( attr_dict.has_key("apix_x") && attr_dict.has_key("apix_y") &&
00612                 attr_dict.has_key("apix_z") )
00613         {
00614                 if( attr_dict.has_key("origin_x") && attr_dict.has_key("origin_y") &&
00615                     attr_dict.has_key("origin_z") )
00616                 {
00617                         float xorigin = attr_dict["origin_x"];
00618                         float yorigin = attr_dict["origin_y"];
00619                         float zorigin = attr_dict["origin_z"];
00620 
00621                         float apix_x = attr_dict["apix_x"];
00622                         float apix_y = attr_dict["apix_y"];
00623                         float apix_z = attr_dict["apix_z"];
00624 
00625                         result->set_xyz_origin(xorigin + apix_x * area.origin[0],
00626                                                                    yorigin + apix_y * area.origin[1],
00627                                                                zorigin + apix_z * area.origin[2]);
00628                 }
00629         }
00630 
00631 #ifdef EMAN2_USING_CUDA
00632         if (use_gpu) result->gpu_update();
00633         else result->update();
00634 #else
00635         result->update();
00636 #endif // EMAN2_USING_CUDA
00637 
00638 
00639         result->set_path(path);
00640         result->set_pathnum(pathnum);
00641 
00642         EXITFUNC;
00643         return result;
00644 }

void insert_clip ( const EMData *const   block,
const IntPoint &  origin 
)

Insert a clip into this image.

Very robust clip insertion code works in all way you might think possible

Parameters:
block An image block.
origin The origin location to insert the clip. ( )

void EMData::insert_clip ( const EMData *const   block,
const IntPoint origin 
) [inherited]

Insert a clip into this image.

Very robust clip insertion code works in all way you might think possible

Parameters:
block An image block.
origin The origin location to insert the clip. ( )

Definition at line 1706 of file emdata_transform.cpp.

References EMAN::EMUtil::em_memcpy(), EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::Region::origin, EMAN::Region::size, UnexpectedBehaviorException, and EMAN::EMData::update().

Referenced by EMAN::EMData::get_clip(), and EMAN::EMData::make_rotational_footprint_e1().

01706                                                                            {
01707         int nx1 = block->get_xsize();
01708         int ny1 = block->get_ysize();
01709         int nz1 = block->get_zsize();
01710 
01711         Region area(origin[0], origin[1], origin[2],nx1, ny1, nz1);
01712 
01713         int x0 = (int) area.origin[0];
01714         x0 = x0 < 0 ? 0 : x0;
01715 
01716         int y0 = (int) area.origin[1];
01717         y0 = y0 < 0 ? 0 : y0;
01718 
01719         int z0 = (int) area.origin[2];
01720         z0 = z0 < 0 ? 0 : z0;
01721 
01722         int x1 = (int) (area.origin[0] + area.size[0]);
01723         x1 = x1 > nx ? nx : x1;
01724 
01725         int y1 = (int) (area.origin[1] + area.size[1]);
01726         y1 = y1 > ny ? ny : y1;
01727 
01728         int z1 = (int) (area.origin[2] + area.size[2]);
01729         z1 = z1 > nz ? nz : z1;
01730         if (z1 <= 0) {
01731                 z1 = 1;
01732         }
01733 
01734         int xd0 = (int) (area.origin[0] < 0 ? -area.origin[0] : 0);
01735         int yd0 = (int) (area.origin[1] < 0 ? -area.origin[1] : 0);
01736         int zd0 = (int) (area.origin[2] < 0 ? -area.origin[2] : 0);
01737 
01738         if (x1 < x0 || y1 < y0 || z1 < z0) return; // out of bounds, this is fine, nothing happens
01739 
01740         size_t clipped_row_size = (x1-x0) * sizeof(float);
01741         int src_secsize =  nx1 * ny1;
01742         int dst_secsize = nx * ny;
01743 
01744 #ifdef EMAN2_USING_CUDA
01745         if (gpu_operation_preferred()) {
01746 //              cudaMemcpy3DParms copyParams = {0};
01747 //              copyParams.srcPtr   = make_cudaPitchedPtr((void*)get_cuda_data(), nx*sizeof(float), nx, ny);
01748 //              cout << "Src pos is " << x0 << " " << y0 << " " << z0 << endl;
01749 //              copyParams.srcPos  = make_cudaPos(x0,y0,z0);
01750 //              cout << "Extent is " << x1-x0 << " " << y1-y0 << " " << z1-z0 << endl;
01751 //              cudaExtent extent = make_cudaExtent(x1-x0,y1-y0,z1-z0);
01752 //              int rnx = result->get_xsize();
01753 //              int rny = result->get_ysize();
01754 //              copyParams.dstPtr = make_cudaPitchedPtr((void*)result->get_cuda_data(),rnx*sizeof(float),rnx,rny );
01755 //              cout << "Dest pos is " << xd0 << " " << yd0 << " " << zd0 << endl;
01756 //              copyParams.dstPos  = make_cudaPos(xd0,yd0,zd0);
01757 //              copyParams.extent   = extent;
01758 //              copyParams.kind     = cudaMemcpyDeviceToDevice;
01759 //              cudaError_t error =  cudaMemcpy3D(&copyParams);
01760 //              if ( error != cudaSuccess) {
01761 //                      string e = cudaGetErrorString(error);
01762 //                      throw UnexpectedBehaviorException("CudaMemcpy3D failed with error: " + e);
01763 //              }
01764                 get_cuda_data();
01765                 CudaDataLock lock(this);
01766                 block->get_cuda_data();
01767                 CudaDataLock lock2(block);
01768                 for (int i = 0; i < (z1-z0); i++) {
01769                         float* ldst = get_cuda_data() + (z0+i) * dst_secsize + y0 * nx + x0;
01770                         float* lsrc = block->get_cuda_data() + (zd0+i) * src_secsize + yd0 * nx1 + xd0;
01771 
01772 
01773 //                      float* ldst = result->get_cuda_data() + (zd0+i) * dst_secsize + yd0 * (int)area.size[0] + xd0;
01774 //                      float* lsrc = get_cuda_data() + (z0+i) * src_secsize + y0 * nx + x0;
01775                         cudaError_t error =  cudaMemcpy2D( ldst, (nx)*sizeof(float), lsrc,nx1*sizeof(float), clipped_row_size, (y1-y0), cudaMemcpyDeviceToDevice );
01776                         if ( error != cudaSuccess) {
01777                                 string e = cudaGetErrorString(error);
01778                                 throw UnexpectedBehaviorException("cudaMemcpy2D failed in get_clip with error: " + e);
01779                         }
01780                 }
01781                 gpu_update();
01782                 EXITFUNC;
01783                 return;
01784         }
01785 #endif
01786         float *src = block->get_data() + zd0 * src_secsize + yd0 * nx1 + xd0;
01787         float *dst = get_data() + z0 * dst_secsize + y0 * nx + x0;
01788 
01789 //              float *src = get_data() + z0 * src_secsize + y0 * nx + x0;
01790 //              float *dst = result->get_data();
01791 //              dst += zd0 * dst_secsize + yd0 * (int)area.size[0] + xd0;
01792 
01793         int src_gap = src_secsize - (y1-y0) * nx1;
01794         int dst_gap = dst_secsize - (y1-y0) * nx;
01795         for (int i = z0; i < z1; i++) {
01796                 for (int j = y0; j < y1; j++) {
01797                         EMUtil::em_memcpy(dst, src, clipped_row_size);
01798                         src += nx1;
01799                         dst += nx;
01800                 }
01801                 src += src_gap;
01802                 dst += dst_gap;
01803         }
01804 
01805         update();
01806         EXITFUNC;
01807 }

EMData * EMData::make_rotational_footprint ( bool  unwrap = true  )  [inherited]

Makes a 'rotational footprint', which is an 'unwound' autocorrelation function.

generally the image should be edge-normalized and masked before using this.

Parameters:
unwrap RFP undergoes polar->cartesian x-form
Exceptions:
ImageFormatException If image size is not even.
Returns:
The rotaional footprint image.

Definition at line 1610 of file emdata.cpp.

References EMAN::EMData::calc_ccf(), EMAN::CIRCULANT, EMAN::EMData::EMData(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_edge_mean(), EMAN::EMData::rot_fp, EMAN::EMData::sub(), EMAN::EMData::unwrap(), and EMAN::EMData::update_stat().

Referenced by EMAN::RotationalAligner::align_180_ambiguous(), and main().

01610                                                       {
01611         ENTERFUNC;
01612         update_stat();
01613         // Note that rotational_footprint caching saves a large amount of time
01614         // but this is at the expense of memory. Note that a policy is hardcoded here,
01615         // that is that caching is only employed when premasked is false and unwrap
01616         // is true - this is probably going to be what is used in most scenarios
01617         // as advised by Steve Ludtke - In terms of performance this caching doubles the metric
01618         // generated by e2speedtest.
01619         if ( rot_fp != 0 && unwrap == true) {
01620                 return new EMData(*rot_fp);
01621         }
01622 
01623         EMData* ccf = this->calc_ccf(this,CIRCULANT,true);
01624         ccf->sub(ccf->get_edge_mean());
01625         //ccf->process_inplace("xform.phaseorigin.tocenter"); ccf did the centering
01626         EMData *result = ccf->unwrap();
01627         delete ccf; ccf = 0;
01628 
01629         EXITFUNC;
01630         if ( unwrap == true)
01631         { // this if statement reflects a strict policy of caching in only one scenario see comments at beginning of function block
01632 
01633 // Note that the if statement at the beginning of this function ensures that rot_fp is not zero, so there is no need
01634 // to throw any exception
01635 // if ( rot_fp != 0 ) throw UnexpectedBehaviorException("The rotational foot print is only expected to be cached if it is not NULL");
01636 
01637 // Here is where the caching occurs - the rot_fp takes ownsherhip of the pointer, and a deep copied EMData object is returned.
01638 // The deep copy invokes a cost in terms of CPU cycles and memory, but prevents the need for complicated memory management (reference counting)
01639                 rot_fp = result;
01640                 return new EMData(*rot_fp);
01641         }
01642         else return result;
01643 }

EMData & EMData::operator= ( const EMData that  )  [inherited]

EMData assignment operator Performs a deep copy.

Parameters:
that the EMData to copy

Definition at line 160 of file emdata.cpp.

References EMAN::EMData::all_translation, EMAN::EMData::attr_dict, EMAN::EMData::changecount, data, EMAN::EMUtil::em_memcpy(), EMAN::EMData::EMData(), EMAN::EMData::EMDATA_GPU_RO_NEEDS_UPDATE, ENTERFUNC, EXITFUNC, EMAN::EMData::flags, EMAN::EMData::free_memory(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::path, EMAN::EMData::pathnum, EMAN::EMData::rdata, EMAN::EMData::rot_fp, EMAN::EMData::set_size(), UnexpectedBehaviorException, EMAN::EMData::xoff, EMAN::EMData::yoff, and EMAN::EMData::zoff.

00161 {
00162         ENTERFUNC;
00163 
00164         if ( this != &that )
00165         {
00166                 free_memory(); // Free memory sets nx,ny and nz to 0
00167 
00168                 // Only copy the rdata if it exists, we could be in a scenario where only the header has been read
00169                 float* data = that.rdata;
00170                 size_t num_bytes = that.nx*that.ny*that.nz*sizeof(float);
00171                 if (data && num_bytes != 0)
00172                 {
00173                         nx = 1; // This prevents a memset in set_size
00174                         set_size(that.nx,that.ny,that.nz);
00175                         EMUtil::em_memcpy(rdata, data, num_bytes);
00176                 }
00177 
00178                 flags = that.flags;
00179 
00180                 all_translation = that.all_translation;
00181 
00182                 path = that.path;
00183                 pathnum = that.pathnum;
00184                 attr_dict = that.attr_dict;
00185 
00186                 xoff = that.xoff;
00187                 yoff = that.yoff;
00188                 zoff = that.zoff;
00189 
00190 #ifdef EMAN2_USING_CUDA
00191                 free_cuda_memory();
00192                 // There should also be the case where we deal with ro data...
00193                 if (num_bytes != 0 && that.cuda_cache_handle != -1 && that.gpu_rw_is_current()) {
00194                         float * cuda_data = that.get_cuda_data();
00195                         CudaDataLock lock1(&that);
00196                         set_size_cuda(that.nx, that.ny, that.nz);
00197                         float *cd = get_cuda_data();
00198                         CudaDataLock lock2(this);
00199                         cudaError_t error = cudaMemcpy(cd,cuda_data,num_bytes,cudaMemcpyDeviceToDevice);
00200                         if ( error != cudaSuccess ) throw UnexpectedBehaviorException("cudaMemcpy failed in operator= with error: " + string(cudaGetErrorString(error)));
00201                 }
00202                 // This is a bit of hack
00203                 flags &= EMDATA_GPU_RO_NEEDS_UPDATE;
00204 #endif //EMAN2_USING_CUDA
00205 
00206                 changecount = that.changecount;
00207 
00208                 if (that.rot_fp != 0) rot_fp = new EMData(*(that.rot_fp));
00209                 else rot_fp = 0;
00210         }
00211         EXITFUNC;
00212         return *this;
00213 }

void ri2ap (  ) 

convert the complex image from real/imaginary to amplitude/phase

void EMData::ri2ap (  )  [inherited]

convert the complex image from real/imaginary to amplitude/phase

Definition at line 940 of file emdata_transform.cpp.

References data, emdata_ri2ap(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::is_complex(), EMAN::EMData::is_ri(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::set_ri(), and EMAN::EMData::update().

Referenced by EMAN::EMData::add_incoherent(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::EMData::get_fft_amplitude(), EMAN::EMData::get_fft_phase(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::EMData::render_amp24(), and EMAN::EMData::render_ap24().

00941 {
00942         ENTERFUNC;
00943 
00944         if (!is_complex() || !is_ri()) {
00945                 return;
00946         }
00947 #ifdef EMAN2_USING_CUDA
00948         if (gpu_operation_preferred()) {
00949                 EMDataForCuda tmp = get_data_struct_for_cuda();
00950                 emdata_ri2ap(&tmp);
00951                 set_ri(false);
00952                 gpu_update();
00953                 EXITFUNC;
00954                 return;
00955         }
00956 #endif
00957 
00958         float * data = get_data();
00959 
00960         size_t size = nx * ny * nz;
00961         for (size_t i = 0; i < size; i += 2) {
00962 #ifdef  _WIN32
00963                 float f = (float)_hypot(data[i], data[i + 1]);
00964 #else
00965                 float f = (float)hypot(data[i], data[i + 1]);
00966 #endif
00967                 if (data[i] == 0 && data[i + 1] == 0) {
00968                         data[i + 1] = 0;
00969                 }
00970                 else {
00971                         data[i + 1] = atan2(data[i + 1], data[i]);
00972                 }
00973                 data[i] = f;
00974         }
00975 
00976         set_ri(false);
00977         update();
00978         EXITFUNC;
00979 }

void ri2inten (  ) 

convert the complex image from real/imaginary to Intensity/0.

This conversion cannot be reversed, and the image remains marked as R/I

void EMData::ri2inten (  )  [inherited]

convert the complex image from real/imaginary to Intensity/0.

This conversion cannot be reversed, and the image remains marked as R/I

Definition at line 909 of file emdata_transform.cpp.

References EMAN::EMData::ap2ri(), data, emdata_ri2inten(), ENTERFUNC, EXITFUNC, EMAN::EMData::get_data(), EMAN::EMData::is_complex(), EMAN::EMData::is_ri(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::set_attr(), and EMAN::EMData::update().

Referenced by EMAN::CTFSNRWeightProcessor::process_inplace().

00910 {
00911         ENTERFUNC;
00912 
00913         if (!is_complex()) return;
00914         if (!is_ri()) ap2ri();
00915 
00916 #ifdef EMAN2_USING_CUDA
00917         if (gpu_operation_preferred()) {
00918                 EMDataForCuda tmp = get_data_struct_for_cuda();
00919                 emdata_ri2inten(&tmp);
00920                 set_attr("is_intensity", int(1));
00921                 gpu_update();
00922                 EXITFUNC;
00923                 return;
00924         }
00925 #endif
00926 
00927         float * data = get_data();
00928         size_t size = nx * ny * nz;
00929         for (size_t i = 0; i < size; i += 2) {
00930                 data[i]=data[i]*data[i]+data[i+1]*data[i+1];
00931                 data[i+1]=0;
00932         }
00933 
00934         set_attr("is_intensity", int(1));
00935         update();
00936         EXITFUNC;
00937 }

EMData * EMData::unwrap ( int  r1 = -1,
int  r2 = -1,
int  xs = -1,
int  dx = 0,
int  dy = 0,
bool  do360 = false,
bool  weight_radial = true 
) const [inherited]

Maps to polar coordinates from Cartesian coordinates.

Optionaly radially weighted. When used with RFP, this provides 1 pixel accuracy at 75% radius. 2D only.

Parameters:
r1 
r2 
xs 
dx 
dy 
do360 If true, do 0-360 degree mapping. Otherwise, do 0-180 degree mapping.
weight_radial if true (default) reights the pixel value by its radius
Exceptions:
ImageDimensionException If 'this' image is not 2D.
UnexpectedBehaviorException if the dimension of this image and the function arguments are incompatibale - i.e. the return image is less than 0 in some dimension.
Returns:
The image in Cartesian coordinates.

Definition at line 2269 of file emdata.cpp.

References EMAN::Util::bilinear_interpolate(), EMAN::EMData::EMData(), emdata_unwrap(), ENTERFUNC, EXITFUNC, EMAN::Util::fast_floor(), EMAN::EMData::get_const_data(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), ImageDimensionException, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::set_size(), t, unbind_cuda_texture(), UnexpectedBehaviorException, EMAN::EMData::update(), x, and y.

Referenced by EMAN::RTFExhaustiveAligner::align(), EMAN::RotatePrecenterAligner::align(), EMAN::EMData::make_rotational_footprint(), EMAN::EMData::make_rotational_footprint_cmc(), and EMAN::EMData::make_rotational_footprint_e1().

02270 {
02271         ENTERFUNC;
02272 
02273         if (get_ndim() != 2) {
02274                 throw ImageDimensionException("2D image only");
02275         }
02276 
02277         int p = 1;
02278         if (do360) {
02279                 p = 2;
02280         }
02281 
02282         if (xs < 1) {
02283                 xs = (int) Util::fast_floor(p * M_PI * ny / 4);
02284                 xs -= xs % 8;
02285                 if (xs<=8) xs=16;
02286         }
02287 
02288         if (r1 < 0) {
02289                 r1 = 4;
02290         }
02291 
02292 #ifdef  _WIN32
02293         int rr = ny / 2 - 2 - (int) Util::fast_floor(static_cast<float>(_hypot(dx, dy)));
02294 #else
02295         int rr = ny / 2 - 2 - (int) Util::fast_floor(static_cast<float>(hypot(dx, dy)));
02296 #endif  //_WIN32
02297         rr-=rr%2;
02298         if (r2 <= r1 || r2 > rr) {
02299                 r2 = rr;
02300         }
02301 
02302         if ( (r2-r1) < 0 ) throw UnexpectedBehaviorException("The combination of function the arguments and the image dimensions causes unexpected behavior internally. Use a larger image, or a smaller value of r1, or a combination of both");
02303 
02304 #ifdef EMAN2_USING_CUDA
02305         if ( gpu_operation_preferred() ) {
02306 //              cout << "Binding " << cuda_cache_handle << endl;
02307                 bind_cuda_texture();
02308                 EMData* rslt = new EMData();
02309                 rslt->set_size_cuda(xs,r2-r1,1);
02310                 EMDataForCuda r = rslt->get_data_struct_for_cuda();
02311 //              CudaDataLock lock1(rslt);
02312                 /*EMDataForCuda* tmp = */emdata_unwrap(&r,r1,r2,xs,p,dx,dy,weight_radial,nx,ny);
02313                 unbind_cuda_texture();
02314 //              EMData* e = new EMData();
02315 //              e->set_gpu_rw_data(tmp->data,tmp->nx,tmp->ny,tmp->nz);
02316 //              free(tmp);
02317                 return  rslt;
02318         }
02319 #endif
02320 
02321         EMData *ret = new EMData();
02322         ret->set_size(xs, r2 - r1, 1);
02323         const float *const d = get_const_data();
02324         float *dd = ret->get_data();
02325         float pfac = (float)p/(float)xs;
02326 
02327         int nxon2 = nx/2;
02328         int nyon2 = ny/2;
02329         for (int x = 0; x < xs; x++) {
02330                 float ang = x * M_PI * pfac;
02331                 float si = sin(ang);
02332                 float co = cos(ang);
02333 
02334                 for (int y = 0; y < r2 - r1; y++) {
02335                         float ypr1 = (float)y + r1;
02336                         float xx = ypr1 * co + nxon2 + dx;
02337                         float yy = ypr1 * si + nyon2 + dy;
02338 //                      float t = xx - Util::fast_floor(xx);
02339 //                      float u = yy - Util::fast_floor(yy);
02340                         float t = xx - (int)xx;
02341                         float u = yy - (int)yy;
02342 //                      int k = (int) Util::fast_floor(xx) + (int) (Util::fast_floor(yy)) * nx;
02343                         int k = (int) xx + ((int) yy) * nx;
02344                         float val = Util::bilinear_interpolate(d[k], d[k + 1], d[k + nx], d[k + nx+1], t,u);
02345                         if (weight_radial) val *=  ypr1;
02346                         dd[x + y * xs] = val;
02347                 }
02348 
02349         }
02350         ret->update();
02351 
02352         EXITFUNC;
02353         return ret;
02354 }


Generated on Sat Nov 21 02:20:06 2009 for EMAN2 by  doxygen 1.5.6