Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::EMData Class Reference
[unit test in Python]

EMData stores an image's data and defines core image processing routines. More...

#include <emdata.h>

Collaboration diagram for EMAN::EMData:

Collaboration graph
[legend]
List of all members.

Public Types

enum  FFTPLACE { FFT_OUT_OF_PLACE, FFT_IN_PLACE }
enum  WINDOWPLACE { WINDOW_OUT_OF_PLACE, WINDOW_IN_PLACE }

Public Member Functions

void read_image (const string &filename, int img_index=0, bool header_only=false, const Region *region=0, bool is_3d=false)
 read an image file and stores its information to this EMData object.
void read_binedimage (const string &filename, int img_index=0, int binfactor=0, bool fast=false, bool is_3d=false)
 read in a binned image, bin while reading.
void write_image (const string &filename, int img_index=0, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false, const Region *region=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)
 write the header and data out to an image.
void append_image (const string &filename, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false)
 append to an image file; If the file doesn't exist, create one.
void write_lst (const string &filename, const string &reffile="", int refn=-1, const string &comment="")
 Append data to a LST image file.
void print_image (const string str=string(""), ostream &out=std::cout)
 Print the image data to a file stream (standard out by default).
EMDataget_fft_amplitude ()
 return the amplitudes of the FFT including the left half
EMDataget_fft_amplitude2D ()
 return the amplitudes of the 2D FFT including the left half PRB
EMDataget_fft_phase ()
 return the phases of the FFT including the left half
float * get_data () const
 Get the image pixel density data in a 1D float array.
const float * get_const_data () const
 Get the image pixel density data in a 1D float array - const version of get_data.
void set_data (float *data, const int x, const int y, const int z)
 Set the data explicitly data pointer must be allocated using malloc!
void set_data (float *data)
void write_data (string fsp, size_t loc, const Region *const area=0, const int file_nx=0, const int file_ny=0, const int file_nz=0)
 Dump the image pixel data in native byte order to a disk file.
void read_data (string fsp, size_t loc, const Region *area=0, const int file_nx=0, const int file_ny=0, const int file_nz=0)
 Read the image pixel data in native byte order from a disk file.
void update ()
 Mark EMData as changed, statistics, etc will be updated at need.
void clearupdate ()
 turn off updates.
bool has_ctff () const
 check whether the image physical file has the CTF info or not.
float calc_center_density ()
 Calculates the density value at the peak of the image histogram, sort of like the mode of the density.
float calc_sigma_diff ()
 Calculates sigma above and below the mean and returns the difference between them.
IntPoint calc_min_location () const
 Calculates the coordinates of the minimum-value pixel.
IntPoint calc_max_location () const
 Calculates the coordinates of the maximum-value pixel.
IntPoint calc_max_location_wrap (const int maxshiftx=-1, const int maxshifty=-1, const int maxshiftz=-1)
 Calculates the wrapped coordinates of the maximum value This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.
vector< float > calc_max_location_wrap_intp (const int maxshiftx=-1, const int maxshifty=-1, const int maxshiftz=-1)
 Calculates the wrapped coordinates of the maximum value, and uses quadration intp to subpixel prec This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.
FloatPoint calc_center_of_mass (const float threshold=0)
 Calculate the center of mass with a threshold (Default 0, so only positive values are considered).
size_t calc_min_index () const
 Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array.
size_t calc_max_index () const
 Calculates the index of maximum-value pixel when assuming all pixels are in a 1D array.
vector< Pixelcalc_highest_locations (float threshold) const
 Calculate and return a sorted list of pixels whose values are above a specified threshold.
vector< Pixelcalc_n_highest_locations (int n)
 Calculate and return a sorted list of N highest pixels in the map.
vector< Pixelfind_pixels_with_value (float val)
 Find pixels in the image with exactly the specified values.
float get_edge_mean () const
 Calculates the mean pixel values around the (1 pixel) edge of the image.
float get_circle_mean ()
 Calculates the circular edge mean by applying a circular mask on 'this' image.
Ctfget_ctf () const
 Get ctf parameter of this image.
void set_ctf (Ctf *ctf)
 Set the CTF parameter of this image.
Vec3f get_translation () const
 Get 'this' image's translation vector from the original location.
void set_translation (const Vec3f &t)
 Set 'this' images' translation vector from the original location.
void set_translation (float dx, float dy, float dz)
 Set 'this' images' translation vector from the original location.
Transform get_transform () const
 Get the 3D orientation of 'this' image.
void set_rotation (float az, float alt, float phi)
 Define the 3D orientation of this particle, also used to indicate relative rotations for reconstructions.
void set_rotation (const Transform &t3d)
 Define the 3D orientation of this particle Orientation information is extracted from a Transform object and stored internally in EMAN (az,alt,phi) format.
void set_size (int nx, int ny=1, int nz=1, bool noalloc=false)
 Resize this EMData's main board memory pointer.
void set_complex_size (int nx, int ny=1, int nz=1)
 Resize 'this' complex image.
void set_path (const string &new_path)
 Set the path.
void set_pathnum (int n)
 Set the number of paths.
MArray2D get_2dview () const
 Get image raw pixel data in a 2D multi-array format.
MArray3D get_3dview () const
 Get image raw pixel data in a 3D multi-array format.
MCArray2D get_2dcview () const
 Get complex image raw pixel data in a 2D multi-array format.
MCArray3D get_3dcview () const
 Get complex image raw pixel data in a 3D multi-array format.
MCArray3Dget_3dcviewptr () const
 Get pointer to a complex image raw pixel data in a 3D multi-array format.
MArray2D get_2dview (int x0, int y0) const
 Get image raw pixel data in a 2D multi-array format.
MArray3D get_3dview (int x0, int y0, int z0) const
 Get image raw pixel data in a 3D multi-array format.
MCArray2D get_2dcview (int x0, int y0) const
 Get complex image raw pixel data in a 2D multi-array format.
MCArray3D get_3dcview (int x0, int y0, int z0) const
 Get complex image raw pixel data in a 3D multi-array format.
EMObject get_attr (const string &attr_name) const
 The generic way to get any image header information given a header attribute name.
EMObject get_attr_default (const string &attr_name, const EMObject &em_obj=EMObject()) const
 The generic way to get any image header information given a header attribute name.
void set_attr (const string &key, EMObject val)
 Set a header attribute's value.
void set_attr_python (const string &key, EMObject val)
 Set a header attribute's value from Python.
bool has_attr (const string &key) const
 Ask if the header has a particular attribute.
Dict get_attr_dict () const
 Get the image attribute dictionary containing all the image attribute names and attribute values.
void set_attr_dict (const Dict &new_dict)
 Merge the new values with the existing dictionary.
void del_attr (const string &attr_name)
 Delete the attribute from dictionary.
void del_attr_dict (const vector< string > &del_keys)
 Delete the attributes from the dictionary.
int get_xsize () const
 Get the image x-dimensional size.
int get_ysize () const
 Get the image y-dimensional size.
int get_zsize () const
 Get the image z-dimensional size.
size_t get_size () const
 Get the number of allocated floats in the image (nx*ny*nz).
vector< float > get_data_as_vector () const
 Get the pixel data as a vector.
int get_ndim () const
 Get image dimension.
bool is_shuffled () const
 Has this image been shuffled?
bool is_FH () const
 Is this a FH image?
bool is_complex () const
 Is this a complex image?
bool is_real () const
 Is this a real image?
void set_shuffled (bool is_shuffled)
 Mark this image as a shuffled image.
void set_FH (bool is_FH)
 Mark this complex image as a FH image.
void set_complex (bool is_complex)
 Mark this image as a complex image.
bool is_complex_x () const
 Is this image a 1D FFT image in X direction?
void set_complex_x (bool is_complex_x)
bool is_flipped () const
 Is this image flipped?
void set_flipped (bool is_flipped)
 Mark this image as flipped.
bool is_ri () const
 Is this image a real/imaginary format complex image?
void set_ri (bool is_ri)
 Mark this image as a real/imaginary format complex image.
bool is_fftpadded () const
 Is this image already extended along x for ffts?
void set_fftpad (bool is_fftpadded)
 Mark this image as already extended along x for ffts.
bool is_fftodd () const
 Does this image correspond to a (real-space) odd nx?
void set_fftodd (bool is_fftodd)
 Mark this image as having (real-space) odd nx.
void set_nxc (int nxc)
 Set the number of complex elements along x.
int get_flags () const
void set_flags (int f)
int get_changecount () const
void set_changecount (int c)
int get_xoff () const
int get_yoff () const
int get_zoff () const
void set_xyzoff (int x, int y, int z)
void scale_pixel (float scale_factor) const
 Scale the angstrom per pixel of this image by a uniform amount Alters the EMData metadata I had to make this function public for access from the Processors (David Woolford).
string get_path () const
int get_pathnum () const
std::string get_data_pickle () const
void set_data_pickle (std::string vf)
int get_supp_pickle () const
void set_supp_pickle (int i)
vector< Vec3imask_contig_region (const float &val, const Vec3i &seed)
float get_amplitude_thres (float thres)
 return the FFT amplitude which is greater than thres
void process_inplace (const string &processorname, const Dict &params=Dict())
 Apply a processor with its parameters on this image.
void process_inplace (Processor *p)
 Call the process_inplace with an instance od Processor, usually this instancecan be get by (in Python) Processors.get("name", {'k':v, 'k':v}).
EMDataprocess (const string &processorname, const Dict &params=Dict()) const
 Apply a processor with its parameters on a copy of this image, return result as a a new image.
EMDataprocess (Processor *p) const
 Call the process with an instance od Processor, usually this instance can be get by (in Python) Processors.get("name", {'k':v, 'k':v}).
float cmp (const string &cmpname, EMData *with, const Dict &params=Dict())
 Compare this image with another image.
EMDataalign (const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const string &cmp_name="", const Dict &cmp_params=Dict())
 Align this image with another image and return the result image.
vector< Dictxform_align_nbest (const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const unsigned int nsoln=1, const string &cmp_name="dot", const Dict &cmp_params=Dict())
 Align this image with another image, return the parameters of the "n best" solutions See Aligner::xform_align_nbest for more comments.
EMDataproject (const string &projector_name, const Dict &params=Dict())
 Calculate the projection of this image and return the result.
EMDataproject (const string &projector_name, const Transform &t3d)
 Calculate the projection of this image and return the result.
EMDatabackproject (const string &projector_name, const Dict &params=Dict())
 Calculate the backprojection of this image (stack) and return the result.
EMDatado_fft () const
 return the fast fourier transform (FFT) image of the current image.
EMDatado_fft_inplace ()
 Do FFT inplace.
EMDatado_ift ()
 return the inverse fourier transform (IFT) image of the current image.
EMDatado_ift_inplace ()
std::string render_amp8 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, float gamma, int flags)
 Render the image into an 8-bit image.
std::string render_ap24 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, float gamma, int flags)
 Render the image into an 8-bit image.
void render_amp24 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, void *ref, void cmap(void *, int coord, unsigned char *tri))
 Render the image into a 24-bit 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.
EMDatabispecRotTransInvN (int N, int NK)
 This computes the rotational and translational bispectral invariants of an image.
EMDatabispecRotTransInvDirect (int type=0)
 This computes the rotational and translational bispectral invariants of an image.
void insert_clip (const EMData *const block, const IntPoint &origin)
 Insert a clip into this image.
void insert_scaled_sum (EMData *block, const FloatPoint &center, float scale=1.0, float mult_factor=1.0)
 Add a scaled image into another image at a specified location.
EMDatacopy () const
 Make a copy of this image including both data and header.
EMDatacopy_head () const
 Make an image with a copy of the current image's header.
void add (float f, int keepzero=0)
 add a number to each pixel value of the image.
void add (const EMData &image)
 add a same-size image to this image pixel by pixel.
void addsquare (const EMData &image)
 add the squared value of each pixel from a same-size image to this image.
void sub (float f)
 subtract a float number to each pixel value of the image.
void sub (const EMData &image)
 subtract a same-size image from this image pixel by pixel.
void subsquare (const EMData &image)
 subtract the squared value of each pixel from a same-size image to this image.
void mult (int n)
 multiply an integer number to each pixel value of the image.
void mult (float f)
 multiply a float number to each pixel value of the image.
void mult (const EMData &image, bool prevent_complex_multiplication=false)
 multiply each pixel of this image with each pixel of some other same-size image.
void mult_complex_efficient (const EMData &em, const int radius)
void div (float f)
 make each pixel value divided by a float number.
void div (const EMData &image)
 make each pixel value divided by pixel value of another same-size image.
void to_zero ()
 Set all the pixel value = 0.
void to_one ()
 set all the pixel values = 1.
void to_value (const float &value)
 set all the pixel values to a value.
float dot (EMData *with)
 Dot product 2 images.
EMDataget_row (int row_index) const
 Get one row of a 1D/2D image.
void set_row (const EMData *data, int row_index)
 Set one row of a 1D/2D image.
EMDataget_col (int col_index) const
 Get one column of a 2D images.
void set_col (const EMData *data, int col_index)
 Set one column of a 2D image.
float get_value_at (int x, int y, int z) const
 Get the pixel density value at coordinates (x,y,z).
float get_value_at_index (int i)
 Get the pixel density value at index i.
float get_value_at (int x, int y) const
 Get the pixel density value at coordinates (x,y).
float get_value_at (size_t i) const
 Get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.
std::complex< float > get_complex_at (const int &x, const int &y) const
 Get complex<float> value at x,y.
std::complex< float > get_complex_at (const int &x, const int &y, const int &z) const
 Get complex<float> value at x,y,z.
size_t get_complex_index (const int &x, const int &y, const int &z) const
 Get complex<float> index for coords x,y,z.
size_t get_complex_index (int x, int y, int z, const int &subx0, const int &suby0, const int &subz0, const int &fullnx, const int &fullny, const int &fullnz) const
size_t get_complex_index_fast (const int &x, const int &y, const int &z) const
void set_complex_at (const int &x, const int &y, const std::complex< float > &val)
 Set complex<float> value at x,y.
void set_complex_at (const int &x, const int &y, const int &z, const std::complex< float > &val)
 Set complex<float> value at x,y,z.
size_t add_complex_at (const int &x, const int &y, const int &z, const std::complex< float > &val)
 Add complex<float> value at x,y,z.
size_t add_complex_at_fast (const int &x, const int &y, const int &z, const std::complex< float > &val)
size_t add_complex_at (int x, int y, int z, const int &subx0, const int &suby0, const int &subz0, const int &fullnx, const int &fullny, const int &fullnz, const std::complex< float > &val)
 Add complex<float> value at x,y,z assuming that 'this' is a subvolume from a larger virtual volume.
float get_value_at_wrap (int x, int y, int z) const
 Get the pixel density value at coordinates (x,y,z).
float & get_value_at_wrap (int x, int y, int z)
float get_value_at_wrap (int x, int y) const
 Get the pixel density value at coordinates (x,y).
float & get_value_at_wrap (int x, int y)
float get_value_at_wrap (int x) const
 Get the pixel density value at coordinates (x).
float & get_value_at_wrap (int x)
float sget_value_at (int x, int y, int z) const
 A safer, slower way to get the pixel density value at coordinates (x,y,z).
float sget_value_at (int x, int y) const
 A safer, slower way to get the pixel density value at coordinates (x,y).
float sget_value_at (size_t i) const
 A safer, slower way to get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.
float sget_value_at_interp (float x, float y) const
 Get pixel density value at interpolation of (x,y).
float sget_value_at_interp (float x, float y, float z) const
 Get the pixel density value at interpolation of (x,y,z).
void set_value_at (int x, int y, int z, float v)
 Set the pixel density value at coordinates (x,y,z).
void set_value_at_fast (int x, int y, int z, float v)
 Set the pixel density value at coordinates (x,y,z).
void set_value_at_index (int i, float v)
 Set the pixel density value at index.
void set_value_at (int x, int y, float v)
 Set the pixel density value at coordinates (x,y).
void set_value_at_fast (int x, int y, float v)
 Set the pixel density value at coordinates (x,y).
void set_value_at (int x, float v)
 Set the pixel density value at coordinate (x).
void set_value_at_fast (int x, float v)
 Set the pixel density value at coordinate (x).
void free_memory ()
 Free memory associated with this EMData Called in destructor and in assignment operator.
void free_rdata ()
 Free rdata memory associated with this EMData Called in CUDA.
EMDataoperator+= (float n)
EMDataoperator-= (float n)
EMDataoperator *= (float n)
EMDataoperator/= (float n)
EMDataoperator+= (const EMData &em)
EMDataoperator-= (const EMData &em)
EMDataoperator *= (const EMData &em)
EMDataoperator/= (const EMData &em)
bool operator== (const EMData &that) const
 Change the equality check for memory address check, i.e.
bool equal (const EMData &that) const
 compare the equality of two EMData object based on their pixel values
float & operator() (const int ix, const int iy, const int iz) const
 Overload operator() for array indexing.
float & operator() (const int ix, const int iy) const
float & operator() (const size_t ix) const
void set_array_offsets (const int xoff_=0, const int yoff_=0, const int zoff_=0)
 Set the array offsets.
void set_array_offsets (vector< int > offsets)
vector< int > get_array_offsets ()
std::complex< float > & cmplx (const int ix, const int iy, const int iz)
 Return reference to complex elements.
std::complex< float > & cmplx (const int ix, const int iy)
std::complex< float > & cmplx (const int ix)
EMDatapower (int n) const
 return a image to the power of n
EMDatasqrt () const
 return square root of current image
EMDatalog () const
 return natural logarithm image for a image
EMDatalog10 () const
 return base 10 logarithm image for a image
EMDatareal () const
 return real part of a complex image as a real image format, if this image is a real image, return a copy of this image.
EMDataimag () const
 return imaginary part of a complex image as a real image format.
EMDataabsi () const
 For a real image, it returns a same size image with abs() of each pixel.
EMDataamplitude () const
 return amplitude part of a complex image as a real image format
EMDataphase () const
 return phase part of a complex image as a real image format
EMDatareal2complex (float img=0.0f) const
 create a complex image from a real image, this complex image is in real/imaginary format
EMDatareal2FH (float OverSamplekB)
 returns the fourier harmonic transform (FH) image of the current image (in real space).
EMDatacopy_empty_head () const
 copy header but not set size for the image
EMDataFH2F (int Size, float OverSamplekB, int IntensityFlag=0)
 returns the fourier version of the image from the FH version.
EMDataFH2Real (int Size, float OverSamplekB, int IntensityFlag=0)
 returns the real version of the image from the FH version.
EMDatarotavg ()
 Create a (1-D) rotationally averaged image.
EMDatarotavg_i ()
 Create a 2-D or 3-D rotationally averaged image.
EMDatamult_radial (EMData *radial)
 Multiply radially a 2-D or 3-D image by a 1-D image.
vector< float > cog ()
 Calculates the Center of Gravity and the Radius of Gyration of the image.
vector< float > calc_fourier_shell_correlation (EMData *with, float w=1.0f)
 Calculate CCF in Fourier space as a function of spatial frequency between a pair of 2-3D images (corners not included).
EMDataaverage_circ_sub () const
 Subtract average outside of a circle.
void onelinenn (int j, int n, int n2, EMData *wptr, EMData *bi, const Transform &tf)
 Helper function for method nn.
void onelinenn_mult (int j, int n, int n2, EMData *wptr, EMData *bi, const Transform &tf, int mult)
void nn (EMData *wptr, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation.
void insert_rect_slice (EMData *w, EMData *myfft, const Transform &trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad, int mult)
void nn_SSNR (EMData *wptr, EMData *wptr2, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.
void nn_SSNR_ctf (EMData *wptr, EMData *wptr2, EMData *wptr3, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.
void symplane0 (EMData *norm)
 Calculate Wiener summation from the inserted 2D slice put the summation into 3D grids using nearest neighbour approximation a.
void symplane1 (EMData *norm, EMData *norm2)
 Symmetrize plane 0 Modifies the current object.
void symplane2 (EMData *norm, EMData *norm2, EMData *norm3)
 Symmetrize plane 0 Modifies the current object.
void onelinenn_ctf (int j, int n, int n2, EMData *w, EMData *bi, const Transform &tf, int mult)
 Helper function for method nn4_ctf.
void nn_ctf (EMData *w, EMData *myfft, const Transform &tf, int mult)
 Nearest Neighbor interpolation.
void insert_rect_slice_ctf (EMData *w, EMData *myfft, const Transform &trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad, int mult)
 helper function to insert rectangualr slice for ctf rect case
void insert_rect_slice_ctf_applied (EMData *w, EMData *myfft, const Transform &trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad, int mult)
void onelinenn_ctf_applied (int j, int n, int n2, EMData *w, EMData *bi, const Transform &tf, int mult)
 Helper function for method nn4_ctf.
void nn_ctf_applied (EMData *w, EMData *myfft, const Transform &tf, int mult)
 Nearest Neighbor interpolation.
void symplane0_ctf (EMData *w)
 Symmetrize plane 0 Modifies the current object.
void symplane0_rect (EMData *w)
EMDatasymvol (string symmetry)
 Symmetrize volume in real space.
EMDatarot_scale_trans2D (float ang, float delx=0.0f, float dely=0.0f, float scale=1.0f)
 Rotate-Shift-Scale-Circulantly image.
EMDatarot_scale_trans2D_background (float ang, float delx=0.0f, float dely=0.0f, float scale=1.0f)
 Rotate-Shift-Scale image.
EMDatarot_scale_trans (const Transform &RA)
 Rotate-Shift-Scale-Circulantly image.
EMDatarot_scale_trans_background (const Transform &RA)
 Rotate-Shift-Scale image.
float cm_euc (EMData *sinoj, int n1, int n2)
 euclidean distance between two line
EMDatarot_scale_conv (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
 Rotate-Shift-Scale-Circulantly image using convolution.
EMDatadownsample (Util::sincBlackman &kb, float scale=1.0)
EMDatarot_scale_conv7 (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale_input)
EMDatarot_scale_conv_new (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
EMDatarot_scale_conv_new_background (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
EMDatarot_scale_conv_new_3D (float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel &kb, float scale=1.0, bool wrap=false)
EMDatarot_scale_conv_new_background_3D (float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel &kb, float scale=1.0, bool wrap=false)
float get_pixel_conv (float delx, float dely, float delz, Util::KaiserBessel &kb)
 Get pixel value image using convolution.
float get_pixel_filtered (float delx, float dely, float delz, Util::sincBlackman &kb)
float get_pixel_conv7 (float delx, float dely, float delz, Util::KaiserBessel &kb)
float getconvpt2d_kbi0 (float x, float y, Util::KaiserBessel::kbi0_win win, int size=7)
 Value of 2-D analytic masking (or 2-D convolution) at off-grid point.
void fft_shuffle ()
 fft_shuffle -- Shuffle a Fourier image to put the origin at (0,ny/2)
void pad_corner (float *pad_image)
void shuffle_pad_corner (float *pad_image)
std::complex< float > extractpoint (float xin, float yin, Util::KaiserBessel &kb)
 extractpoint -- Gridding convolution
EMDataextract_plane (const Transform &tf, Util::KaiserBessel &kb)
 extractplane -- Gridding convolution in 3D along a plane
EMDataextract_plane_rect (const Transform &tf, Util::KaiserBessel &kbx, Util::KaiserBessel &kby, Util::KaiserBessel &kbz)
EMDataextract_plane_rect_fast (const Transform &tf, Util::KaiserBessel &kbx, Util::KaiserBessel &kby, Util::KaiserBessel &kbz)
EMDatafouriergridrot2d (float ang, float scale, Util::KaiserBessel &kb)
EMDatafouriergridrot_shift2d (float ang, float sx, float sy, Util::KaiserBessel &kb)
void divkbsinh (const Util::KaiserBessel &kb)
 divkbsinh -- Divide image by a Kaiser-Bessel sinh window.
void divkbsinh_rect (const Util::KaiserBessel &kbx, const Util::KaiserBessel &kby, const Util::KaiserBessel &kbz)
vector< float > peak_search (int ml, float invert)
 Search specified number peaks in 1D, 2D, or 3D real images.
vector< float > phase_cog ()
 Calculate the Phase approximation to center of gravity This operations works for 1-2-3-d images.
float find_3d_threshold (float mass, float pixel_size)
vector< float > peak_ccf (float hf_p)
 Peak (with a radius of hf_p) search for particle picking:.
EMDataget_pow (float n_pow)
EMDataconjg ()
EMDataextractline (Util::KaiserBessel &kb, float nuxnew, float nuynew)
EMDatadelete_disconnected_regions (int ix=0, int iy=0, int iz=0)
 Delete disconnected regions in a binary image.
EMDatahelicise (float pixel_size, float dp, float dphi, float section_use=1.0f, float radius=-1.0f, float minrad=-1.0f)
 Apply helical symmetry.
EMDatahelicise_grid (float pixel_size, float dp, float dphi, Util::KaiserBessel &kb, float section_use=1.0f, float radius=-1.0f, float minrad=-1.0f)
void depad ()
 De-pad, and and remove Fourier extension convenience function.
void depad_corner ()
 De-pad, and and remove Fourier extension convenience function.
EMDatanorm_pad (bool do_norm, int npad=1, int valtype=0)
 Normalize, pad, and Fourier extend convenience function.
void center_origin ()
void center_origin_yz ()
void center_origin_fft ()
 Multiply a Fourier image by (-1)**(ix+iy+iz) to center it.
EMDataFourInterpol (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDataFourTruncate (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
 Truncate Fourier transform of an image, it will reduce its size.
EMDataFour_ds (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDataFour_shuf_ds_cen_us (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDatafilter_by_image (EMData *image, bool RetReal=true)
EMDatareplace_amplitudes (EMData *image, bool RetReal=true)
 EMData ()
 Construct an empty EMData instance.
 ~EMData ()
 EMData (const string &filename, int image_index=0)
 Construct from an image file.
 EMData (int nx, int ny, int nz=1, bool is_real=true)
 # makes an image of the specified size, either real or complex.
 EMData (float *data, const int nx, const int ny, const int nz, const Dict &attr_dict=Dict())
 Construction from a data pointer, dimensions must be supplied.
 EMData (float *data, float *cudadata, const int nx, const int ny, const int nz, const Dict &attr_dict=Dict())
 Construction from a data pointer for usage in cuda, dimensions must be supplied.
 EMData (const EMData &that)
 Construct from an EMData (copy constructor).
EMDataoperator= (const EMData &that)
 EMData assignment operator Performs a deep copy.
EMDataget_clip (const Region &area, const float fill=0) const
 Get an inclusive clip.
void clip_inplace (const Region &area, const float &fill_value=0)
 Clip the image inplace - clipping region must be smaller than the current region internally memory is reallocated.
EMDataget_top_half () const
 Get the top half of this 3D image.
EMDataget_rotated_clip (const Transform &xform, const IntSize &size, float scale=1.0)
 This will extract an arbitrarily oriented and sized region from the image.
EMDatawindow_center (int l)
 Window the center of an image.
float * setup4slice (bool redo=true)
 Set up for fftslice operations.
void scale (float scale_factor)
 scale the image by a factor.
void translate (float dx, float dy, float dz)
 Translate this image.
void translate (const Vec3f &translation)
 Translate this image.
void translate (int dx, int dy, int dz)
 Translate this image.
void translate (const Vec3i &translation)
 Translate this image.
void rotate (const Transform &t)
 Rotate this image.
float max_3D_pixel_error (const Transform &t1, const Transform &t2, float r)
void rotate (float az, float alt, float phi)
 Rotate this image.
void transform (const Transform &t)
 Transform the image.
void rotate_translate (const Transform &t)
 Apply a transformation to the image.
void rotate_translate (float az, float alt, float phi, float dx, float dy, float dz)
 Rotate then translate the image.
void rotate_translate (float az, float alt, float phi, float dx, float dy, float dz, float pdx, float pdy, float pdz)
 Rotate then translate the image.
void rotate_x (int dx)
 This performs a translation of each line along x with wraparound.
void rotate_180 ()
 Fast rotation by 180 degrees.
double dot_rotate_translate (EMData *with, float dx, float dy, float da, const bool mirror=false)
 dot product of 2 images.
EMDatalittle_big_dot (EMData *little_img, bool do_sigma=false)
 This does a normalized dot product of a little image with a big image using real-space methods.
EMDatado_radon ()
 Radon Transform: an algorithm that transforms an original image into a series of equiangular projections.
EMDatacalc_ccf (EMData *with=0, fp_flag fpflag=CIRCULANT, bool center=false)
 Calculate Cross-Correlation Function (CCF).
void zero_corner_circulant (const int radius=0)
 Zero the pixels in the bottom left corner of the image If radius is greater than 1, than circulant zeroing occurs assuming that the center of operation starts in the bottom left corner and proceed outwards to the NE and backwards in a circulant fashion towards the SW.
EMDatacalc_ccfx (EMData *const with, int y0=0, int y1=-1, bool nosum=false, bool flip=false, bool usez=false)
 Calculate Cross-Correlation Function (CCF) in the x-direction and adds them up, result in 1D.
EMDatamake_rotational_footprint (bool unwrap=true)
 Makes a 'rotational footprint', which is an 'unwound' autocorrelation function.
EMDatamake_rotational_footprint_e1 (bool unwrap=true)
EMDatamake_rotational_footprint_cmc (bool unwrap=true)
EMDatamake_footprint (int type=0)
 Makes a 'footprint' for the current image.
EMDatacalc_mutual_correlation (EMData *with, bool tocorner=false, EMData *filter=0)
 Calculates mutual correlation function (MCF) between 2 images.
EMDataunwrap (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.
EMDataunwrap_largerR (int r1, int r2, int xs, float rmax_f)
EMDataoneDfftPolar (int size, float rmax, float MAXR)
void apply_radial_func (float x0, float dx, vector< float >array, bool interp=true)
 multiplies by a radial function in fourier space.
vector< float > calc_radial_dist (int n, float x0, float dx, bool inten)
 calculates radial distribution.
vector< float > calc_radial_dist (int n, float x0, float dx, int nwedge, float offset, bool inten)
 calculates radial distribution subdivided by angle.
void cconj ()
 Replace the image its complex conjugate.
void add_incoherent (EMData *obj)
 Adds 'obj' to 'this' incoherently.
vector< float > calc_hist (int hist_size=128, float hist_min=0, float hist_max=0, const float &brt=0.0f, const float &cont=1.0f)
 Calculates the histogram of 'this' image.
vector< float > calc_az_dist (int n, float a0, float da, float rmin, float rmax)
 Caculates the azimuthal distributions.
float calc_dist (EMData *second_img, int y_index=0) const
 Calculates the distance between 2 vectors.
EMDatacalc_flcf (EMData *with)
 Calculates the cross correlation with local normalization between 2 images.
EMDatacalc_fast_sigma_image (EMData *mask)
 Calculates the local standard deviation (sigma) image using the given mask image.
EMDataconvolute (EMData *with)
 Convolutes 2 data sets.
void common_lines (EMData *image1, EMData *image2, int mode=0, int steps=180, bool horizontal=false)
 Finds common lines between 2 complex images.
void common_lines_real (EMData *image1, EMData *image2, int steps=180, bool horizontal=false)
 Finds common lines between 2 real images.
void cut_slice (const EMData *const map, const Transform &tr, bool interpolate=true)
 cut a 2D slice out of a real 3D map.
void uncut_slice (EMData *const map, const Transform &tr) const
 Opposite of the cut_slice().
EMDataextract_box (const Transform &cs, const Region &r)
 Extract a box from EMData in an abritrary orrientation.
int getResolution () const
 function for MarchingCubes, for 3D image display
void debug_print_parms ()
 Printing EMData params for debugging purpose.
void set_xyz_origin (float origin_x, float origin_y, float origin_z)
 Set the x,y,z origin of the image.
EMDatacompute_missingwedge (float wedgeangle, float start=0.05, float stop=0.5)
 Find the mean and variance of voxels in the missing wedge.

Static Public Member Functions

vector< boost::shared_ptr<
EMData > > 
read_images (const string &filename, vector< int >img_indices=vector< int >(), bool header_only=false)
 Read a set of images from file specified by 'filename'.
vector< boost::shared_ptr<
EMData > > 
read_images_ext (const string &filename, int img_index_start, int img_index_end, bool header_only=false, const string &ext="")
 Read a set of images from file specified by 'filename'.
float restrict1 (float x, int nx)
float restrict2 (float x, int nx)

Static Public Attributes

int totalalloc = 0

Private Types

enum  EMDataFlags {
  EMDATA_BUSY = 1 << 3, EMDATA_HASCTFF = 1 << 4, EMDATA_NEEDUPD = 1 << 5, EMDATA_FLIP = 1 << 7,
  EMDATA_PAD = 1 << 8, EMDATA_FFTODD = 1 << 9, EMDATA_SHUFFLE = 1 << 10, EMDATA_FH = 1 << 11,
  EMDATA_CPU_NEEDS_UPDATE = 1 << 12, EMDATA_GPU_NEEDS_UPDATE = 1 << 13, EMDATA_GPU_RO_NEEDS_UPDATE = 1 << 14
}
 This EMDataFlags is deprecated. More...

Private Member Functions

void set_attr_dict_explicit (const Dict &new_dict)
 Make the attributes of this EMData exactly equal to the argument dictionary Originally introduced because set_attr_dict does automatic resizing, which is undersirable in some circumstances.
void update_stat () const
void save_byteorder_to_dict (ImageIO *imageio)

Static Private Member Functions

bool peakcmp (const Pixel &p1, const Pixel &p2)

Private Attributes

Dict attr_dict
 to store all image header info
float * rdata
 image real data
float * supp
 supplementary data array
int flags
 flags
int changecount
int nx
 image size
int ny
 image size
int nz
 image size
int nxy
 image size
size_t nxyz
int xoff
 array index offsets
int yoff
 array index offsets
int zoff
 array index offsets
Vec3f all_translation
 translation from the original location
string path
int pathnum
EMDatarot_fp
 This is a cached rotational footprint, can save much time.

Friends

class GLUtil

Detailed Description

EMData stores an image's data and defines core image processing routines.

The image is 1D, 2D or 3D, in real space or fourier space (complex image).

Data are ordered with x increasing fastest, then y, then z.

Definition at line 87 of file emdata.h.


Member Enumeration Documentation

enum EMAN::EMData::EMDataFlags [private]
 

This EMDataFlags is deprecated.

For anything which is currently handled by setting a bit in 'flags', instead, set or read an appropriately named attribute in the attributes dictionary. While there is a small overhead in the string lookup, none of these things should be called in the innermost loop anywhere, so it should be fine. --Grant

Enumeration values:
EMDATA_BUSY 
EMDATA_HASCTFF 
EMDATA_NEEDUPD 
EMDATA_FLIP 
EMDATA_PAD 
EMDATA_FFTODD 
EMDATA_SHUFFLE 
EMDATA_FH 
EMDATA_CPU_NEEDS_UPDATE 
EMDATA_GPU_NEEDS_UPDATE 
EMDATA_GPU_RO_NEEDS_UPDATE 

Definition at line 3891 of file emdata.h.

enum EMAN::EMData::FFTPLACE
 

Enumeration values:
FFT_OUT_OF_PLACE 
FFT_IN_PLACE 

Definition at line 3200 of file emdata.h.

enum EMAN::EMData::WINDOWPLACE
 

Enumeration values:
WINDOW_OUT_OF_PLACE 
WINDOW_IN_PLACE 

Definition at line 3201 of file emdata.h.


Constructor & Destructor Documentation

EMData::EMData  ) 
 

Construct an empty EMData instance.

It has no image data.

Definition at line 74 of file emdata.cpp.

References attr_dict, nx, ny, and rdata.

Referenced by absi(), amplitude(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_ccfx(), calc_fast_sigma_image(), calc_flcf(), compute_missingwedge(), copy(), copy_empty_head(), copy_head(), do_radon(), EMData(), extract_box(), get_circle_mean(), get_clip(), get_col(), get_rotated_clip(), get_row(), get_top_half(), imag(), make_footprint(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), operator=(), phase(), read_binedimage(), read_images(), read_images_ext(), real(), real2complex(), rotavg(), rotavg_i(), and unwrap().

00074                :
00075 #ifdef EMAN2_USING_CUDA
00076                 cudarwdata(0), cudarodata(0), num_bytes(0), nextlistitem(0), prevlistitem(0), roneedsupdate(0), cudadirtybit(0),
00077 #endif //EMAN2_USING_CUDA
00078                 attr_dict(), rdata(0), supp(0), flags(0), changecount(0), nx(0), ny(0), nz(0), nxy(0), nxyz(0), xoff(0), yoff(0),
00079                 zoff(0), all_translation(),     path(""), pathnum(0), rot_fp(0)
00080 
00081 {
00082         ENTERFUNC;
00083 
00084         attr_dict["apix_x"] = 1.0f;
00085         attr_dict["apix_y"] = 1.0f;
00086         attr_dict["apix_z"] = 1.0f;
00087 
00088         attr_dict["is_complex"] = int(0);
00089         attr_dict["is_complex_x"] = int(0);
00090         attr_dict["is_complex_ri"] = int(1);
00091 
00092         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;
00093 
00094         EMData::totalalloc++;
00095 #ifdef MEMDEBUG2
00096         printf("EMDATA+  %4d    %p\n",EMData::totalalloc,this);
00097 #endif
00098 
00099         EXITFUNC;
00100 }

EMData::~EMData  ) 
 

Definition at line 318 of file emdata.cpp.

References free_memory().

00319 {
00320         ENTERFUNC;
00321         free_memory();
00322 
00323 #ifdef EMAN2_USING_CUDA
00324         if(cudarwdata){rw_free();}
00325         if(cudarodata){ro_free();}
00326 #endif // EMAN2_USING_CUDA
00327         EMData::totalalloc--;
00328 #ifdef MEMDEBUG2
00329         printf("EMDATA-  %4d    %p\n",EMData::totalalloc,this);
00330 #endif
00331         EXITFUNC;
00332 }

EMData::EMData const string &  filename,
int  image_index = 0
[explicit]
 

Construct from an image file.

Parameters:
filename the image file name
image_index the image index for stack image file, default 0

Definition at line 102 of file emdata.cpp.

References attr_dict, nx, ny, rdata, read_image(), and update().

00102                                                       :
00103 #ifdef EMAN2_USING_CUDA
00104                 cudarwdata(0), cudarodata(0), num_bytes(0), nextlistitem(0), prevlistitem(0), roneedsupdate(0), cudadirtybit(0),
00105 #endif //EMAN2_USING_CUDA
00106                 attr_dict(), rdata(0), supp(0), flags(0), changecount(0), nx(0), ny(0), nz(0), nxy(0), nxyz(0), xoff(0), yoff(0), zoff(0),
00107                 all_translation(),      path(filename), pathnum(image_index), rot_fp(0)
00108 {
00109         ENTERFUNC;
00110 
00111         attr_dict["apix_x"] = 1.0f;
00112         attr_dict["apix_y"] = 1.0f;
00113         attr_dict["apix_z"] = 1.0f;
00114 
00115         attr_dict["is_complex"] = int(0);
00116         attr_dict["is_complex_x"] = int(0);
00117         attr_dict["is_complex_ri"] = int(1);
00118 
00119         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;
00120 
00121         this->read_image(filename, image_index);
00122 
00123         update();
00124         EMData::totalalloc++;
00125 #ifdef MEMDEBUG2
00126         printf("EMDATA+  %4d    %p\n",EMData::totalalloc,this);
00127 #endif
00128 
00129         EXITFUNC;
00130 }

EMData::EMData float *  data,
const int  nx,
const int  ny,
const int  nz,
const Dict attr_dict = Dict()
 

Construction from a data pointer, dimensions must be supplied.

Takes possession of the pointer. data pointer must be allocated using malloc!

Parameters:
data a pointer to the pixel data which is stored in memory. Takes possession
nx the number of pixels in the x direction
ny the number of pixels in the y direction
nz the number of pixels in the z direction
attr_dict attribute dictionary for this image

Definition at line 268 of file emdata.cpp.

References data, nx, ny, rdata, update(), x, and y.

00268                                                                                         :
00269 #ifdef EMAN2_USING_CUDA
00270                 cudarwdata(0), cudarodata(0), num_bytes(0), nextlistitem(0), prevlistitem(0), roneedsupdate(0), cudadirtybit(0),
00271 #endif //EMAN2_USING_CUDA
00272                 attr_dict(attr_dict), rdata(data), supp(0), flags(0), changecount(0), nx(x), ny(y), nz(z), nxy(x*y), nxyz((size_t)x*y*z), xoff(0),
00273                 yoff(0), zoff(0), all_translation(), path(""), pathnum(0), rot_fp(0)
00274 {
00275         ENTERFUNC;
00276         // used to replace cube 'pixel'
00277         attr_dict["apix_x"] = 1.0f;
00278         attr_dict["apix_y"] = 1.0f;
00279         attr_dict["apix_z"] = 1.0f;
00280 
00281         EMData::totalalloc++;
00282 #ifdef MEMDEBUG2
00283         printf("EMDATA+  %4d    %p\n",EMData::totalalloc,this);
00284 #endif
00285 
00286         update();
00287         EXITFUNC;
00288 }


Member Function Documentation

EMData * EMData::absi  )  const
 

For a real image, it returns a same size image with abs() of each pixel.

For a complex image, it returns a image in size (nx/2,ny,nz), the pixel value output[i]=sqrt(input[i]*input[i]+input[i+1]*input[i+1])

Exceptions:
InvalidCallException this function call require a complex image in real/imaginary format.

Definition at line 1143 of file emdata_core.cpp.

References abs, copy(), data, EMData(), get_data(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_real(), is_ri(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_size(), sqrt(), and update().

01144 {
01145         ENTERFUNC;
01146 
01147         EMData * e = new EMData();
01148 
01149         if( is_real() ) // a real image
01150         {
01151                 e = this->copy();
01152                 int nx = get_xsize();
01153                 int ny = get_ysize();
01154                 int nz = get_zsize();
01155                 float *edata = e->get_data();
01156                 float * data = get_data();
01157                 size_t idx;
01158                 for( int i=0; i<nx; ++i ) {
01159                         for( int j=0; j<ny; ++j ) {
01160                                 for( int k=0; k<nz; ++k ) {
01161                                         idx = i+j*nx+k*nx*ny;
01162                                         edata[idx] = std::abs(data[idx]);
01163                                 }
01164                         }
01165                 }
01166         }
01167         else //for a complex image
01168         {
01169                 if( !is_ri() )
01170                 {
01171                         throw InvalidCallException("This image is in amplitude/phase format, this function call require a complex image in real/imaginary format.");
01172                 }
01173                 int nx = get_xsize();
01174                 int ny = get_ysize();
01175                 int nz = get_zsize();
01176                 e->set_size(nx/2, ny, nz);
01177                 float * edata = e->get_data();
01178                 float * data = get_data();
01179                 size_t idx1, idx2;
01180                 for( int i=0; i<nx; ++i )
01181                 {
01182                         for( int j=0; j<ny; ++j )
01183                         {
01184                                 for( int k=0; k<nz; ++k )
01185                                 {
01186                                         if( i%2 == 0 )
01187                                         {
01188                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01189                                                 idx2 = i+j*nx+k*nx*ny;
01190                                                 //complex data in format [real, complex, real, complex...]
01191                                                 edata[idx1] =
01192                                                 std::sqrt(data[idx2]*data[idx2]+data[idx2+1]*data[idx2+1]);
01193                                         }
01194                                 }
01195                         }
01196                 }
01197         }
01198 
01199         e->set_complex(false);
01200         if(e->get_ysize()==1 && e->get_zsize()==1) {
01201                 e->set_complex_x(false);
01202         }
01203         e->update();
01204         return e;
01205 
01206         EXITFUNC;
01207 }

void EMData::add const EMData image  ) 
 

add a same-size image to this image pixel by pixel.

Parameters:
image The image added to 'this' image.
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 326 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_real(), nx, ny, nz, and update().

00327 {
00328         ENTERFUNC;
00329         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00330                 throw ImageFormatException( "images not same sizes");
00331         }
00332         else if( (is_real()^image.is_real()) == true )
00333         {
00334                 throw ImageFormatException( "not support add between real image and complex image");
00335         }
00336         else {
00337 
00338                 const float *src_data = image.get_data();
00339                 size_t size = nxyz;
00340                 float* data = get_data();
00341 
00342                 for (size_t i = 0; i < size; i++) {
00343                         data[i] += src_data[i];
00344                 }
00345                 update();
00346         }
00347         EXITFUNC;
00348 }

void EMData::add float  f,
int  keepzero = 0
 

add a number to each pixel value of the image.

Image may be real or complex.

Parameters:
f The number added to 'this' image.
keepzero If set will not modify pixels that are exactly zero

Definition at line 271 of file emdata_core.cpp.

References data, get_data(), ImageFormatException, is_complex(), is_real(), nx, ny, and update().

Referenced by EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::BackProjectionReconstructor::finish(), EMAN::operator+(), operator+=(), EMAN::operator-(), EMAN::CtfSimProcessor::process(), EMAN::NormalizeRampNormVar::process_inplace(), and EMAN::SNREvalProcessor::process_inplace().

00272 {
00273         ENTERFUNC;
00274 
00275         float * data = get_data();
00276         if( is_real() )
00277         {
00278                 if (f != 0) {
00279 
00280                         size_t size = nxyz;
00281                         if (keepzero) {
00282                                 for (size_t i = 0; i < size; i++) {
00283                                         if (data[i]) data[i] += f;
00284                                 }
00285                         }
00286                         else {
00287                                 for (size_t i = 0; i < size; i++) {
00288                                         data[i] += f;
00289                                 }
00290                         }
00291                         update();
00292                 }
00293         }
00294         else if( is_complex() )
00295         {
00296                 if( f!=0 )
00297                 {
00298                         update();
00299                         size_t size = (size_t)nx*ny*nz; //size of data
00300                         if( keepzero )
00301                         {
00302                                 for(size_t i=0; i<size; i+=2)
00303                                 {
00304                                         if (data[i]) data[i] += f;
00305                                 }
00306                         }
00307                         else
00308                         {
00309                                 for(size_t i=0; i<size; i+=2)
00310                                 {
00311                                         data[i] += f;
00312                                 }
00313                         }
00314                 }
00315         }
00316         else
00317         {
00318                 throw ImageFormatException("This image is neither a real nor a complex image.");
00319         }
00320         update();
00321         EXITFUNC;
00322 }

size_t EMData::add_complex_at int  x,
int  y,
int  z,
const int &  subx0,
const int &  suby0,
const int &  subz0,
const int &  fullnx,
const int &  fullny,
const int &  fullnz,
const std::complex< float > &  val
 

Add complex<float> value at x,y,z assuming that 'this' is a subvolume from a larger virtual volume.

Requires that parameters often stored in the header as: subvolume_x0,y0,z0 and subvolume_full_nx,ny,nz be passed in as parameters. Otherwise similar to add_complex_at. It will return the index into the subvolume float array at which the complex began, or nx*ny*nz if out of range

Parameters:
x x coordinate
y y coordinate
z z coordinate
val complex<float> value to set
Returns:
The complex pixel at x,y

Definition at line 238 of file emdata_core.cpp.

References abs, imag(), nx, ny, rdata, real(), x, and y.

00238                                                                                                                                                                                      {
00239 if (abs(x)>=fullnx/2 || abs(y)>fullny/2 || abs(z)>fullnz/2) return nxyz;
00240 //if (x==0 && (y!=0 || z!=0)) add_complex_at(0,-y,-z,subx0,suby0,subz0,fullnx,fullny,fullnz,conj(val));
00241 // complex conjugate insertion. Removed due to ambiguity with returned index
00242 /*if (x==0&& (y!=0 || z!=0)) {
00243         int yy=y<=0?-y:fullny-y;
00244         int zz=z<=0?-z:fullnz-z;
00245 
00246         if (yy<suby0||zz<subz0||yy>=suby0+ny||zz>=subz0+nz) return nx*ny*nz;
00247 
00248         size_t idx=(yy-suby0)*nx+(zz-subz0)*nx*ny;
00249         rdata[idx]+=(float)val.real();
00250         rdata[idx+1]+=(float)-val.imag();
00251 }*/
00252 float cc=1.0;
00253 if (x<0) {
00254         x*=-1;
00255         y*=-1;
00256         z*=-1;
00257         cc=-1.0;
00258 }
00259 if (y<0) y=fullny+y;
00260 if (z<0) z=fullnz+z;
00261 
00262 if (x<subx0||y<suby0||z<subz0||x>=subx0+nx||y>=suby0+ny||z>=subz0+nz) return nxyz;
00263 
00264 size_t idx=(x-subx0)*2+(y-suby0)*(size_t)nx+(z-subz0)*(size_t)nx*ny;
00265 rdata[idx]+=(float)val.real();
00266 rdata[idx+1]+=cc*(float)val.imag();
00267 return idx;
00268 }

size_t EMData::add_complex_at const int &  x,
const int &  y,
const int &  z,
const std::complex< float > &  val
 

Add complex<float> value at x,y,z.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny x nz image, a nx+2 x ny x nz image will be produced, and values using this function can go from -nx/2 to nx/2 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. It will return the index into the float array at which the complex began, or nx*ny*nz if out of range

Parameters:
x x coordinate
y y coordinate
z z coordinate
val complex<float> value to set
Returns:
The complex pixel at x,y

Definition at line 211 of file emdata_core.cpp.

References imag(), nx, ny, nz, rdata, real(), x, and y.

Referenced by EMAN::FourierInserter3DMode7::insert_pixel(), EMAN::FourierInserter3DMode6::insert_pixel(), EMAN::FourierInserter3DMode2::insert_pixel(), and EMAN::FourierInserter3DMode1::insert_pixel().

00211                                                                                                  {
00212 //if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return nxyz;
00213 if (x>=nx/2 || y>ny/2 || z>nz/2 || x<=-nx/2 || y<-ny/2 || z<-nz/2) return nxyz;
00214 
00215 // for x=0, we need to insert the value in 2 places
00216 // complex conjugate insertion. Removed due to ambiguity with returned index
00217 /*if (x==0 && (y!=0 || z!=0)) {
00218         size_t idx=(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nx*ny;
00219         rdata[idx]+=(float)val.real();
00220         rdata[idx+1]-=(float)val.imag();
00221 }*/
00222 
00223 size_t idx;
00224 if (x<0) {
00225         idx=-x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00226         rdata[idx]+=(float)val.real();
00227         rdata[idx+1]-=(float)val.imag();
00228         return idx;
00229 }
00230 
00231 idx=x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00232 rdata[idx]+=(float)val.real();
00233 rdata[idx+1]+=(float)val.imag();
00234 
00235 return idx;
00236 }

size_t EMAN::EMData::add_complex_at_fast const int &  x,
const int &  y,
const int &  z,
const std::complex< float > &  val
[inline]
 

Definition at line 2050 of file emdata.h.

Referenced by EMAN::FourierInserter3DMode5::insert_pixel(), EMAN::FourierInserter3DMode3::insert_pixel(), and EMAN::FourierInserter3DMode2::insert_pixel().

void EMData::add_incoherent EMData obj  ) 
 

Adds 'obj' to 'this' incoherently.

'obj' and 'this' should be same size. Both images should be complex images.

Parameters:
obj The image added to 'this' image.
Exceptions:
ImageFormatException If the 2 images are not same size; or if the 2 images are not complex images.

Definition at line 3191 of file emdata.cpp.

References get_data(), ImageFormatException, is_complex(), LOGERR, NullPointerException, nx, ny, ri2ap(), and update().

03192 {
03193         ENTERFUNC;
03194 
03195         if (!obj) {
03196                 LOGERR("NULL image");
03197                 throw NullPointerException("NULL image");
03198         }
03199 
03200         if (!obj->is_complex() || !is_complex()) {
03201                 throw ImageFormatException("complex images only");
03202         }
03203 
03204         if (!EMUtil::is_same_size(this, obj)) {
03205                 throw ImageFormatException("images not same size");
03206         }
03207 
03208         ri2ap();
03209         obj->ri2ap();
03210 
03211         float *dest = get_data();
03212         float *src = obj->get_data();
03213         size_t size = (size_t)nx * ny * nz;
03214         for (size_t j = 0; j < size; j += 2) {
03215 #ifdef  _WIN32
03216                 dest[j] = (float) _hypot(src[j], dest[j]);
03217 #else
03218                 dest[j] = (float) hypot(src[j], dest[j]);
03219 #endif  //_WIN32
03220                 dest[j + 1] = 0;
03221         }
03222 
03223         obj->update();
03224         update();
03225         EXITFUNC;
03226 }

void EMData::addsquare const EMData image  ) 
 

add the squared value of each pixel from a same-size image to this image.

Parameters:
image The image whose square is added to 'this' image.
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 351 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), nx, ny, nz, and update().

00352 {
00353         ENTERFUNC;
00354         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00355                 throw ImageFormatException( "images not same sizes");
00356         }
00357         else if( this->is_complex() || image.is_complex() )
00358         {
00359                 throw ImageFormatException( "Cannot addsquare() with complex images");
00360         }
00361         else {
00362 
00363                 const float *src_data = image.get_data();
00364                 size_t size = nxyz;
00365                 float* data = get_data();
00366 
00367                 for (size_t i = 0; i < size; i++) {
00368                         data[i] += src_data[i]*src_data[i];
00369                 }
00370                 update();
00371         }
00372         EXITFUNC;
00373 }

EMData * EMData::align const string &  aligner_name,
EMData to_img,
const Dict params = Dict(),
const string &  cmp_name = "",
const Dict cmp_params = Dict()
 

Align this image with another image and return the result image.

Parameters:
aligner_name Alignment algorithm name.
to_img The image 'this' image aligns to.
params Alignment algorithm parameters in a keyed dictionary.
cmp_name Comparison algorithm used in alignment.
cmp_params Parameter dictionary for comparison algorithm.
Exceptions:
NotExistingObjectError If the alignment algorithm doesn't exist.
Returns:
The result image.

Definition at line 116 of file emdata_modular.cpp.

References EMAN::Aligner::align().

Referenced by EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::ScaleAlignerABS::align_using_base(), main(), and EMAN::ACFCenterProcessor::process_inplace().

00118 {
00119         ENTERFUNC;
00120         EMData *result = 0;
00121         Aligner *a = Factory < Aligner >::get(aligner_name, params);
00122         if (a) {
00123                 if (cmp_name == "") {
00124                         result = a->align(this, to_img);
00125                 }
00126                 else {
00127                         result = a->align(this, to_img, cmp_name, cmp_params);
00128                 }
00129                 if( a )
00130                 {
00131                         delete a;
00132                         a = 0;
00133                 }
00134         }
00135 
00136         EXITFUNC;
00137         return result;
00138 }

EMData * EMData::amplitude  )  const
 

return amplitude part of a complex image as a real image format

Returns:
EMData * a real image which is the amplitude part of this image
Exceptions:
InvalidCallException if this image is a real image or is in real/imaginary format

Definition at line 1210 of file emdata_core.cpp.

References data, EMData(), get_data(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_real(), is_ri(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_size(), and update().

01211 {
01212         ENTERFUNC;
01213 
01214         EMData * e = new EMData();
01215 
01216         if( is_real() ) {
01217                 throw InvalidCallException("No imaginary part for a real image, this function call require a complex image.");
01218         }
01219         else {
01220                 if(is_ri()) {
01221                         throw InvalidCallException("This image is in real/imaginary format, this function call require a complex image in amplitude/phase format.");
01222                 }
01223 
01224                 int nx = get_xsize();
01225                 int ny = get_ysize();
01226                 int nz = get_zsize();
01227                 e->set_size(nx/2, ny, nz);
01228                 float * edata = e->get_data();
01229                 float * data = get_data();
01230                 size_t idx1, idx2;
01231                 for( int i=0; i<nx; ++i )
01232                 {
01233                         for( int j=0; j<ny; ++j )
01234                         {
01235                                 for( int k=0; k<nz; ++k )
01236                                 {
01237                                         if( i%2 == 0 )
01238                                         {
01239                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01240                                                 idx2 = i+j*nx+k*nx*ny;
01241                                                 //complex data in format [amp, phase, amp, phase...]
01242                                                 edata[idx1] = data[idx2];
01243                                         }
01244                                 }
01245                         }
01246                 }
01247         }
01248 
01249         e->set_complex(false);
01250         if(e->get_ysize()==1 && e->get_zsize()==1) {
01251                 e->set_complex_x(false);
01252         }
01253         e->update();
01254         return e;
01255 
01256         EXITFUNC;
01257 }

void EMData::ap2ri  ) 
 

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

Definition at line 956 of file emdata_transform.cpp.

References ap2ri(), get_data(), is_complex(), is_ri(), nx, ny, nz, set_ri(), and update().

Referenced by apply_radial_func(), calc_mutual_correlation(), EMAN::OptVarianceCmp::cmp(), common_lines(), convolute(), do_ift(), do_ift_inplace(), mult(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), and ri2inten().

00957 {
00958         ENTERFUNC;
00959 
00960         if (!is_complex() || is_ri()) {
00961                 return;
00962         }
00963         
00964         Util::ap2ri(get_data(), (size_t)nx * ny * nz);
00965         set_ri(true);
00966         update();
00967         EXITFUNC;
00968 }

void EMData::append_image const string &  filename,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false
 

append to an image file; If the file doesn't exist, create one.

Parameters:
filename The image file name.
imgtype Write to the given image format type. if not specified, use the 'filename' extension to decide.
header_only To write only the header or both header and data.

Definition at line 407 of file emdata_io.cpp.

References write_image().

Referenced by EMAN::IterationAverager::finish(), and main().

00409 {
00410         ENTERFUNC;
00411         write_image(filename, -1, imgtype, header_only, 0);
00412         EXITFUNC;
00413 }

void EMData::apply_radial_func float  x0,
float  dx,
vector< float >  array,
bool  interp = true
 

multiplies by a radial function in fourier space.

Parameters:
x0 starting point x coordinate.
dx step of x.
array radial function data array.
interp Do the interpolation or not.

Definition at line 2596 of file emdata.cpp.

References ap2ri(), data, get_data(), get_ndim(), ImageFormatException, is_complex(), nx, ny, sqrt(), and update().

Referenced by EMAN::OptVarianceCmp::cmp(), main(), EMAN::CtfSimProcessor::process(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), and EMAN::FourierProcessor::process_inplace().

02597 {
02598         ENTERFUNC;
02599 
02600         if (!is_complex()) throw ImageFormatException("apply_radial_func requires a complex image");
02601 
02602         int n = static_cast < int >(array.size());
02603 
02604         if (n*step>2.0) printf("Warning, apply_radial_func takes x0 and step with respect to Nyquist (0.5)\n");
02605 
02606 //      printf("%f %f %f\n",array[0],array[25],array[50]);
02607 
02608         ap2ri();
02609 
02610         size_t ndims = get_ndim();
02611         float * data = get_data();
02612         if (ndims == 2) {
02613                 int k = 0;
02614                 for (int j = 0; j < ny; j++) {
02615                         for (int i = 0; i < nx; i += 2, k += 2) {
02616                                 float r;
02617 #ifdef  _WIN32
02618                                 if (j<ny/2) r = (float)_hypot(i/(float)(nx*2), j/(float)ny);
02619                                 else r = (float)_hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02620 #else
02621                                 if (j<ny/2) r = (float)hypot(i/(float)(nx*2), j/(float)ny);
02622                                 else r = (float)hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02623 #endif  //_WIN32
02624                                 r = (r - x0) / step;
02625 
02626                                 int l = 0;
02627                                 if (interp) {
02628                                         l = (int) floor(r);
02629                                 }
02630                                 else {
02631                                         l = (int) floor(r + 1);
02632                                 }
02633 
02634 
02635                                 float f = 0;
02636                                 if (l >= n - 2) {
02637                                         f = array[n - 1];
02638                                 }
02639                                 else {
02640                                         if (interp) {
02641                                                 r -= l;
02642                                                 f = (array[l] * (1.0f - r) + array[l + 1] * r);
02643                                         }
02644                                         else {
02645                                                 f = array[l];
02646                                         }
02647                                 }
02648 
02649                                 data[k] *= f;
02650                                 data[k + 1] *= f;
02651                         }
02652                 }
02653         }
02654         else if (ndims == 3) {
02655                 int k = 0;
02656                 for (int m = 0; m < nz; m++) {
02657                         float mnz;
02658                         if (m<nz/2) mnz=m*m/(float)(nz*nz);
02659                         else { mnz=(nz-m)/(float)nz; mnz*=mnz; }
02660 
02661                         for (int j = 0; j < ny; j++) {
02662                                 float jny;
02663                                 if (j<ny/2) jny= j*j/(float)(ny*ny);
02664                                 else { jny=(ny-j)/(float)ny; jny*=jny; }
02665 
02666                                 for (int i = 0; i < nx; i += 2, k += 2) {
02667                                         float r = std::sqrt((i * i / (nx*nx*4.0f)) + jny + mnz);
02668                                         r = (r - x0) / step;
02669 
02670                                         int l = 0;
02671                                         if (interp) {
02672                                                 l = (int) floor(r);
02673                                         }
02674                                         else {
02675                                                 l = (int) floor(r + 1);
02676                                         }
02677 
02678 
02679                                         float f = 0;
02680                                         if (l >= n - 2) {
02681                                                 f = array[n - 1];
02682                                         }
02683                                         else {
02684                                                 if (interp) {
02685                                                         r -= l;
02686                                                         f = (array[l] * (1.0f - r) + array[l + 1] * r);
02687                                                 }
02688                                                 else {
02689                                                         f = array[l];
02690                                                 }
02691                                         }
02692 
02693                                         data[k] *= f;
02694                                         data[k + 1] *= f;
02695                                 }
02696                         }
02697                 }
02698 
02699         }
02700 
02701         update();
02702         EXITFUNC;
02703 }

EMData * EMData::average_circ_sub  )  const
 

Subtract average outside of a circle.

Returns:
image with sbtracted average outside of a circle.

Definition at line 1006 of file emdata_sparx.cpp.

References copy_head(), get_data(), nx, ny, nz, pnewimg, proj, and update().

Referenced by EMAN::padfft_slice().

01007 {
01008 //  this is written as though dimensions could be different, but in fact they should be all equal nx=ny=nz,
01009 //                                                           no check of this
01010         ENTERFUNC;
01011         const EMData* const image = this;
01012         EMData* newimg = copy_head();
01013         float *proj = image->get_data();
01014         float *pnewimg = newimg->get_data();
01015         //  Calculate average outside of a circle
01016         float r2 = static_cast<float>( (nx/2)*(nx/2) );
01017         float qs=0.0f;
01018         int m=0;
01019         int ncz = nz/2 + 1;
01020         int ncy = ny/2 + 1;
01021         int ncx = nx/2 + 1;
01022         for (int iz = 1; iz <= nz; iz++) {
01023                 float yy = static_cast<float>( (iz-ncz)*(iz-ncz) );
01024                 for (int iy = 1; iy <=ny; iy++) { float xx = yy + (iy-ncy)*(iy-ncy);
01025                         for (int ix = 1; ix <= nx; ix++) {
01026                                 if ( xx+float((ix-ncx)*(ix-ncx)) > r2 ) {
01027                                         qs += proj(ix,iy,iz);
01028                                         m++;
01029                                 }
01030                         }
01031                 }
01032         }
01033 
01034 
01035         if( m > 0 ) qs /= m;
01036 
01037         for (int iz = 1; iz <= nz; iz++)
01038                 for (int iy = 1; iy <= ny; iy++)
01039                         for (int ix = 1; ix <= nx; ix++)
01040                                         pnewimg(ix,iy,iz) = proj(ix,iy,iz) - qs;
01041         newimg->update();
01042         return newimg;
01043         EXITFUNC;
01044 }

EMData * EMData::backproject const string &  projector_name,
const Dict params = Dict()
 

Calculate the backprojection of this image (stack) and return the result.

Parameters:
projector_name Projection algorithm name. (Only "pawel" and "chao" have been implemented now).
params Projection Algorithm parameters.
Exceptions:
NotExistingObjectError If the projection algorithm doesn't exist.
Returns:
The result image.

Definition at line 193 of file emdata_modular.cpp.

References EMAN::Projector::backproject3d().

00194 {
00195         ENTERFUNC;
00196         EMData *result = 0;
00197         Projector *p = Factory < Projector >::get(projector_name, params);
00198         if (p) {
00199                 result = p->backproject3d(this);
00200                 if( p )
00201                 {
00202                         delete p;
00203                         p = 0;
00204                 }
00205         }
00206 
00207         EXITFUNC;
00208         return result;
00209 }

EMData * EMData::bispecRotTransInvDirect int  type = 0  ) 
 

This computes the rotational and translational bispectral invariants of an image.

the output is a single 3d Volume whose x,y labels are lengths, corresponding to the two lengths of sides of a triangle the z label is for the angle

Definition at line 1326 of file emdata_transform.cpp.

References do_fft(), EMData(), get_value_at(), get_xsize(), process_inplace(), set_value_at(), and write_image().

01327 {
01328 
01329         int EndP = this -> get_xsize(); // length(fTrueVec);
01330         int Mid  = (int) ((1+EndP)/2);
01331         int End = 2*Mid-1;
01332 
01333         int CountxyMax = End*End;
01334 
01335 //      int   *SortfkInds       = new    int[CountxyMax];
01336         int   *kVecX            = new    int[CountxyMax];
01337         int   *kVecY            = new    int[CountxyMax];
01338         float *fkVecR           = new  float[CountxyMax];
01339         float *fkVecI           = new  float[CountxyMax];
01340         float *absD1fkVec       = new  float[CountxyMax];
01341 //      float *absD1fkVecSorted = new  float[CountxyMax];
01342 
01343 
01344         float *jxjyatan2         = new  float[End*End];
01345 
01346 
01347         EMData * ThisCopy = new EMData(End,End);
01348 
01349         for (int jx=0; jx <End ; jx++) {  // create jxjyatan2
01350                 for (int jy=0; jy <End ; jy++) {
01351                         float ValNow = this -> get_value_at(jx,jy);
01352                         ThisCopy -> set_value_at(jx,jy,ValNow);
01353                         jxjyatan2[jy*End + jx]  = atan2((float)(jy+1-Mid) , (float)(jx +1 -Mid));
01354 //              cout<< " jxM= " << jx+1<<" jyM= " << jy+1<< "ValNow" << ValNow << endl; //    Works
01355         }}
01356 
01357 
01358         EMData* fk = ThisCopy -> do_fft();
01359         fk          ->process_inplace("xform.fourierorigin.tocenter");
01360 
01361 //      Create kVecX , kVecy etc
01362 
01363         for (int kEx= 0; kEx<2*Mid; kEx=kEx+2) { // kEx twice the value of the Fourier
01364                                                 // x variable: EMAN index for real, imag
01365                 int kx    = kEx/2;              // kx  is  the value of the Fourier variable
01366                 int kIx   = kx+Mid-1; // This is the value of the index for a matlab image (-1)
01367                 int kCx   = -kx ;
01368                 int kCIx  = kCx+ Mid-1 ;
01369                 for (int kEy= 0 ; kEy<End; kEy++) { // This is the value of the EMAN index
01370                         int kIy              =  kEy       ; //  This is the value of the index for a matlab image (-1)
01371                         int ky               =  kEy+1-Mid; // (kEy+ Mid-1)%End - Mid+1 ;  // This is the actual value of the Fourier variable
01372                         float realVal        =  fk -> get_value_at(kEx  ,kEy) ;
01373                         float imagVal        =  fk -> get_value_at(kEx+1,kEy) ;
01374                         float absVal         =  ::sqrt(realVal*realVal+imagVal*imagVal);
01375                         float fkAng          =  atan2(imagVal,realVal);
01376 
01377                         float NewRealVal   ;
01378                         float NewImagVal   ;
01379                         float AngMatlab    ;
01380 
01381                         if (kIx==Mid-1) {
01382 //                              AngMatlab = -fkAng - 2.*M_PI*(kIy+ 1-Mid)*(Mid)/End;
01383                         }
01384 
01385                         if (kIx>Mid-1){
01386 //                      cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << AngMatlab << endl;
01387                         }
01388 
01389                         AngMatlab = fkAng - 2.0f*M_PI*(kx +ky)*(Mid)/End;
01390                         NewRealVal  =   absVal*cos(AngMatlab);
01391                         NewImagVal  =   absVal*sin(AngMatlab);
01392 
01393 
01394                         fkVecR[ kIy +kIx *End] =  NewRealVal ;
01395                         fkVecR[(End-1-kIy)+kCIx*End] =  NewRealVal ;
01396                         fkVecI[ kIy +kIx *End] =  NewImagVal ;
01397                         fkVecI[(End-1-kIy)+kCIx*End] = -NewImagVal ;
01398                         absD1fkVec[(End-1-kIy) + kIx  *End] = absVal;
01399                         absD1fkVec[(End-1-kIy) + kCIx *End] = absVal;
01400                         kVecX[kIy+kIx  *End] =  kx      ;
01401                         kVecX[kIy+kCIx *End] =  kCx    ;
01402                         kVecY[kIy+kIx  *End] =  ky     ;
01403                         kVecY[kIy+kCIx *End] =  ky     ;
01404 
01405  //                     cout << " kIxM= " << kIx+1 << " kIy=" << kIy+1 << " fkVecR[i] =" << NewRealVal << " fkVecI[i]="  << NewImagVal <<"  angle[i]= "  << AngMatlab << " Total Index" << kIy+kIx *End << endl;
01406 
01407 //                      printf("kx=%d,ky=%d,tempVal =%f+ i %4.2f \n",kx,ky,realVal,imagVal );
01408 //                      cout << "kx = " << kx << "; ky = "<< ky << "; val is" << realVal<<"+ i "<<imagVal<< endl;
01409 
01410 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; fkAng*9/ 2pi is " << fkAng*9/2/M_PI<<  endl;
01411 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; absval is " << absVal<<  "; realval is " << NewRealVal<< "; imagval is " << NewImagVal<< endl;
01412                 }
01413         }
01414 
01415 
01416 //      for (int TotalInd = 0 ;  TotalInd < CountxyMax ; TotalInd++){
01417 //              int kx     = kVecX[TotalInd]; // This is the value of the index for a matlab image (-1)
01418 //              int kIx    = kx+Mid-1; // This is the value of the index for a matlab image (-1)
01419 //              int ky     = kVecY[TotalInd];
01420 //              int kIy    = ky+Mid-1; // This is the value of the index for a matlab image (-1)
01421                 //float fkR  = fkVecR[kIy+kIx *End]  ;
01422                 //float fkI  = fkVecI[kIy+kIx *End]  ;
01423 //      }
01424 
01425         float frR= 3.0/4.0;
01426         frR= 1;
01427         int LradRange= (int) (1+floor(Mid/frR -.1)) ;
01428 
01429         float *radRange = new float[LradRange]; //= 0:.75:(Mid-1);
01430         for (int irad=0; irad < LradRange; irad++){
01431                         radRange[irad] =  frR*irad;
01432 //                      cout << " irad = " << irad << " radRange[irad]= " <<  radRange[irad] <<  " LradRange= " << LradRange << endl;
01433         }
01434 
01435         cout << "Starting the calculation of invariants" << endl;
01436 
01437 
01438         if (type==0) {
01439                 int LthetaRange  = 59;
01440                 float ftR        = (2.0f*M_PI/LthetaRange );
01441                 float *thetaRange = new float[LthetaRange]; //= 0:.75:(Mid-1);
01442 
01443                 for (int ith=0; ith < LthetaRange; ith++){
01444                                 thetaRange[ith] =  ftR*ith; }
01445 
01446                 int TotalVol = LradRange*LradRange*LthetaRange;
01447 
01448                 float *RotTransInv   = new  float[TotalVol];
01449                 float *WeightInv     = new  float[TotalVol];
01450 
01451                 for (int jW=0; jW<TotalVol; jW++) {
01452                         RotTransInv[jW] = 0;
01453                         WeightInv[jW]   = 0;
01454                 }
01455 
01456                 for (int jW=0; jW<TotalVol; jW++) {
01457                         RotTransInv[jW] = 0;
01458                         WeightInv[jW]   = 0;
01459                 }
01460         //      float  *RotTransInv       = new float[LradRange*LradRange ] ;
01461         //      float  *RotTransInvN      = new float[LradRange*LradRange*(NMax+1) ] ;
01462 
01463                 for (int Countkxy =0; Countkxy<CountxyMax; Countkxy++){  // Main Section for type 0
01464                         int kx = kVecX[Countkxy] ;
01465                         int ky = kVecY[Countkxy] ;
01466                         float k2 = ::sqrt((float)(kx*kx+ky*ky));
01467                         float phiK =0;
01468                         if (k2>0)    phiK = jxjyatan2[ (ky+Mid-1)*End + kx+Mid-1]; //  phiK=atan2(ky,kx);
01469                         float fkR     = fkVecR[(ky+Mid-1) + (kx+Mid-1) *End] ;
01470                         float fkI     = fkVecI[(ky+Mid-1) + (kx+Mid-1) *End]  ;
01471         //              printf("Countkxy=%d,\t kx=%d, ky=%d, fkR=%3.2f,fkI=%3.2f \n", Countkxy, kx, ky, fkR, fkI);
01472 
01473                         if ((k2==0)|| (k2>Mid) ) { continue;}
01474 
01475                         for (int Countqxy =0; Countqxy<CountxyMax; Countqxy++){   // This is the innermost loop
01476                                 int qx   = kVecX[Countqxy] ;
01477                                 int qy   = kVecY[Countqxy] ;
01478                                 float q2   = ::sqrt((float)(qx*qx+qy*qy));
01479                                 if ((q2==0)|| (q2>Mid) ) {continue;}
01480                                 float phiQ =0;
01481                                 if (q2>0)   phiQ = jxjyatan2[ (qy+Mid-1)*End + qx+Mid-1]; // phiQ=atan2(qy,qx);
01482                                 float fqR     = fkVecR[(qy+Mid-1) + (qx+Mid-1) *End] ;
01483                                 float fqI     = fkVecI[(qy+Mid-1) + (qx+Mid-1) *End]  ;
01484                                 int kCx  = (-kx-qx);
01485                                 int kCy  = (-ky-qy);
01486                                 int kCIx = ((kCx+Mid+2*End)%End);// labels of the image in C
01487                                 int kCIy = ((kCy+Mid+2*End)%End);
01488                                 kCx  = ((kCIx+End-1)%End)+1-Mid; // correct
01489                                 kCy  = ((kCIy+End-1)%End)+1-Mid ; // correct
01490 
01491 //                              float C2   = ::sqrt((float)(kCx*kCx+ kCy*kCy));
01492                                 int CountCxy  = (kCx+Mid-1)*End+(kCy+Mid-1);
01493                                 float fCR     = fkVecR[CountCxy];
01494                                 float fCI     = fkVecI[CountCxy];
01495         /*                      if (Countkxy==1) {
01496                                         printf(" Countqxy=%d, absD1fkVec(Countqxy)=%f,qx=%d, qy=%d \n", Countqxy, absD1fkVec[Countqxy],qx, qy);
01497                                         printf(" CountCxy=%d, absD1fkVec[CountCxy]=%f,kCx=%d,kCy=%d \n",CountCxy, absD1fkVec[CountCxy], kCx, kCy );
01498                                 }*/
01499 //                              float   phiC = jxjyatan2[ (kCy+Mid-1)*End + kCx+Mid-1];
01500                                 float   phiQK = (4*M_PI+phiQ-phiK);
01501                                 while (phiQK> (2*M_PI)) phiQK -= (2*M_PI);
01502 
01503 
01504 
01505                                 float bispectemp  = (fkR*(fqR*fCR -fqI*fCI) -fkI*(fqI*fCR  +fqR*fCI));
01506 
01507                                 if  ((q2<k2) )  continue;
01508 //                              if  ((q2<k2) || (C2<k2) || (C2<q2))  continue;
01509 
01510         //                              printf(" CountCxy=%d, absD1fkVec[CountCxy]=%f,kCx=%d,kCy=%d \n",CountCxy, absD1fkVec[CountCxy], kCx, kCy );
01511 
01512         //                      up to here, matched perfectly with Matlab
01513 
01514                                 int k2IndLo  = 0; while ((k2>=radRange[k2IndLo+1]) && (k2IndLo+1 < LradRange ) ) k2IndLo +=1;
01515                                 int k2IndHi = k2IndLo;
01516                                 float k2Lo= radRange[k2IndLo];
01517                                 if (k2IndLo+1< LradRange) {
01518                                         k2IndHi   = k2IndLo+1;
01519                                 }
01520 //                              float k2Hi= radRange[k2IndHi];
01521 
01522                                 float kCof =k2-k2Lo;
01523 
01524                                 int q2IndLo  = 0; while ((q2>=radRange[q2IndLo+1]) && (q2IndLo+1 < LradRange ) ) q2IndLo +=1;
01525                                 int q2IndHi=q2IndLo;
01526                                 float q2Lo= radRange[q2IndLo];
01527                                 if (q2IndLo+1 < LradRange)  {
01528                                         q2IndHi   = q2IndLo+1 ;
01529                                 }
01530                                 float qCof = q2-q2Lo;
01531 
01532                                 if ((qCof<0) || (qCof >1) ) {
01533                                         cout<< "Weird! qCof="<< qCof <<  " q2="<< q2 << " q2IndLo="<< q2IndLo << endl ;
01534                                         int x    ;
01535                                         cin >> x ;
01536                                 }
01537 
01538                                 int thetaIndLo = 0; while ((phiQK>=thetaRange[thetaIndLo+1])&& (thetaIndLo+1<LthetaRange)) thetaIndLo +=1;
01539                                 int thetaIndHi = thetaIndLo;
01540 
01541                                 float thetaLo  = thetaRange[thetaIndLo];
01542                                 float thetaHi = thetaLo;
01543                                 float thetaCof = 0;
01544 
01545                                 if (thetaIndLo+1< LthetaRange) {
01546                                         thetaIndHi = thetaIndLo +1;
01547                                 }else{
01548                                         thetaIndHi=0;
01549                                 }
01550 
01551                                 thetaHi    = thetaRange[thetaIndHi];
01552 
01553                                 if (thetaHi==thetaLo) {
01554                                         thetaCof =0 ;
01555                                 } else {
01556                                         thetaCof   = (phiQK-thetaLo)/(thetaHi-thetaLo);
01557                                 }
01558 
01559                                 if ((thetaCof>2*M_PI)  ) {
01560                                         cout<< "Weird! thetaCof="<< thetaCof <<endl ;
01561                                         thetaCof=0;
01562                                 }
01563 
01564 
01565         //                      if ((thetaIndLo>=58) || (k2IndLo >= LradRange-1) || (q2IndLo >= LradRange-1) ) {
01566 
01567 
01568                                 for (int jk =1; jk<=2; jk++){
01569                                 for (int jq =1; jq<=2; jq++){
01570                                 for (int jtheta =1; jtheta<=2; jtheta++){
01571 
01572                                         float Weight = (kCof+(1-2*kCof)*(jk==1))*(qCof+(1-2*qCof)*(jq==1))
01573                                                         * (thetaCof+(1-2*thetaCof)*(jtheta==1));
01574 
01575 
01576                                         int k2Ind      =  k2IndLo*(jk==1)      +   k2IndHi*(jk==2);
01577                                         int q2Ind      =  q2IndLo*(jq==1)      +   q2IndHi*(jq==2);
01578                                         int thetaInd   =  thetaIndLo*(jtheta==1)  + thetaIndHi*(jtheta ==2);
01579                                         int TotalInd   = thetaInd*LradRange*LradRange+q2Ind*LradRange+k2Ind;
01580         /*                              if (TotalInd+1 >=  LthetaRange*LradRange*LradRange) {
01581                                                 cout << "Weird!!! TotalInd="<< TotalInd << " IndMax" << LthetaRange*LradRange*LradRange << " LradRange=" << LradRange << endl;
01582                                                 cout << "k2Ind= "<< k2Ind  << " q2Ind="<< q2Ind  << " thetaInd="<< thetaInd  << " q2IndLo="<< q2IndLo  << " q2IndHi="<< q2IndHi  <<  endl;
01583                                                 cout << "k2=" << k2 << "q2=" << q2 << " phiQK=" << phiQK*180.0/M_PI<< endl;
01584                                         }*/
01585 
01586                                         RotTransInv[TotalInd] += Weight*bispectemp;
01587                                         WeightInv[TotalInd]   +=  Weight;
01588         //                              cout << "k2Ind= "<< k2Ind  << " q2Ind="<< q2Ind  << "Weight=" << Weight << endl;
01589                                 }}}
01590                         } // Countqxy
01591                 } // Countkxy
01592 
01593                 cout << "Finished Main Section " << endl;
01594 
01595         /*              RotTransInvN[jr1 + LradRange*jr2+LradRange*LradRange*N] = RotTransInvTemp  ;*/
01596 
01597                 cout << " LradRange " <<LradRange <<" LthetaRange " << LthetaRange << endl;
01598                 EMData *RotTransInvF  = new  EMData(LradRange,LradRange,LthetaRange);
01599                 EMData *WeightImage   = new  EMData(LradRange,LradRange,LthetaRange);
01600 
01601         //      cout << "FFFFFFF" << endl;
01602         //
01603         //      RotTransInvF -> set_size(LradRange,LradRange,LthetaRange);
01604         //
01605         //      cout << "GGGG" << endl;
01606 
01607                 for (int jtheta =0; jtheta < LthetaRange; jtheta++){    // write out to RotTransInvF
01608                 for (int jq =0; jq<LradRange; jq++){ // LradRange
01609                 for (int jk =0; jk<LradRange ; jk++){// LradRange
01610         //              cout << "Hi There" << endl;
01611                         int TotalInd   = jtheta*LradRange*LradRange+jq*LradRange+jk;
01612                         float Weight = WeightInv[TotalInd];
01613                         WeightImage    -> set_value_at(jk,jq,jtheta,Weight);
01614                         RotTransInvF   -> set_value_at(jk,jq,jtheta,0);
01615                         if (Weight <= 0) continue;
01616                         RotTransInvF -> set_value_at(jk,jq,jtheta,RotTransInv[TotalInd] / Weight);//  include /Weight
01617                         int newjtheta = (LthetaRange- jtheta)%LthetaRange;
01618                         RotTransInvF -> set_value_at(jq,jk,newjtheta,RotTransInv[TotalInd]/Weight );//  include /Weight
01619                                 }
01620                         }
01621                 }
01622 
01623                 cout << " Almost Done " << endl;
01624 #ifdef  _WIN32
01625                 _unlink("WeightImage.???");
01626 #else
01627                 system("rm -f WeightImage.???");
01628 #endif  //_WIN32
01629                 WeightImage  -> write_image("WeightImage.img");
01630 
01631                 return  RotTransInvF ;
01632         } // Finish type 0
01633 
01634         if (type==1) {
01635                 int TotalVol = LradRange*LradRange;
01636 
01637                 float *RotTransInv   = new  float[TotalVol];
01638                 float *WeightInv     = new  float[TotalVol];
01639 
01640                 for (int jW=0; jW<TotalVol; jW++) {
01641                         RotTransInv[jW] = 0;
01642                         WeightInv[jW]   = 0;
01643                 }
01644 
01645 
01646                 for (int Countkxy =0; Countkxy<CountxyMax; Countkxy++){
01647                         int kx = kVecX[Countkxy] ;
01648                         int ky = kVecY[Countkxy] ;
01649                         float k2 = ::sqrt((float)(kx*kx+ky*ky));
01650                         float fkR     = fkVecR[(ky+Mid-1) + (kx+Mid-1) *End] ;
01651                         float fkI     = fkVecI[(ky+Mid-1) + (kx+Mid-1) *End]  ;
01652         //              printf("Countkxy=%d,\t kx=%d, ky=%d, fkR=%3.2f,fkI=%3.2f \n", Countkxy, kx, ky, fkR, fkI);
01653 
01654                         if ((k2==0)|| (k2>Mid) ) { continue;}
01655 
01656                         for (int Countqxy =0; Countqxy<CountxyMax; Countqxy++){   // This is the innermost loop
01657 
01658 //                      up to here, matched perfectly with Matlab
01659                                 int qx   = kVecX[Countqxy] ;
01660                                 int qy   = kVecY[Countqxy] ;
01661                                 float q2   = ::sqrt((float)(qx*qx+qy*qy));
01662                                 if ((q2==0)|| (q2>Mid) ) {continue;}
01663                                 if  ((q2<k2) )   continue;
01664 
01665                                 float fqR     = fkVecR[(qy+Mid-1) + (qx+Mid-1) *End] ;
01666                                 float fqI     = fkVecI[(qy+Mid-1) + (qx+Mid-1) *End]  ;
01667 
01668                                 int kCx  = (-kx-qx);
01669                                 int kCy  = (-ky-qy);
01670                                 int kCIx = ((kCx+Mid+2*End)%End);// labels of the image in C
01671                                 int kCIy = ((kCy+Mid+2*End)%End);
01672                                 kCx  = ((kCIx+End-1)%End)+1-Mid; // correct
01673                                 kCy  = ((kCIy+End-1)%End)+1-Mid ; // correct
01674 
01675 //                              float C2   = ::sqrt((float)(kCx*kCx+ kCy*kCy));
01676                                 int CountCxy  = (kCx+Mid-1)*End+(kCy+Mid-1);
01677                                 float fCR     = fkVecR[CountCxy];
01678                                 float fCI     = fkVecI[CountCxy];
01679 
01680 
01681                                 float bispectemp  = (fkR*(fqR*fCR -fqI*fCI) -fkI*(fqI*fCR  +fqR*fCI));
01682 
01683 
01684                                 int k2IndLo  = 0; while ((k2>=radRange[k2IndLo+1]) && (k2IndLo+1 < LradRange ) ) k2IndLo +=1;
01685                                 int k2IndHi = k2IndLo;
01686                                 float k2Lo= radRange[k2IndLo];
01687                                 if (k2IndLo+1< LradRange) {
01688                                         k2IndHi   = k2IndLo+1;
01689                                 }
01690 //                              float k2Hi= radRange[k2IndHi];
01691 
01692                                 float kCof =k2-k2Lo;
01693 
01694                                 int q2IndLo  = 0; while ((q2>=radRange[q2IndLo+1]) && (q2IndLo+1 < LradRange ) ) q2IndLo +=1;
01695                                 int q2IndHi=q2IndLo;
01696                                 float q2Lo= radRange[q2IndLo];
01697                                 if (q2IndLo+1 < LradRange)  {
01698                                         q2IndHi   = q2IndLo+1 ;
01699                                 }
01700                                 float qCof = q2-q2Lo;
01701 
01702 
01703                                 for (int jk =1; jk<=2; jk++){
01704                                 for (int jq =1; jq<=2; jq++){
01705 
01706                                         float Weight = (kCof+(1-2*kCof)*(jk==1))*(qCof+(1-2*qCof)*(jq==1));
01707 
01708                                         int k2Ind      =  k2IndLo*(jk==1)      +   k2IndHi*(jk==2);
01709                                         int q2Ind      =  q2IndLo*(jq==1)      +   q2IndHi*(jq==2);
01710                                         int TotalInd   = q2Ind*LradRange+k2Ind;
01711                                         RotTransInv[TotalInd] += Weight*bispectemp;
01712                                         WeightInv[TotalInd]   +=  Weight;
01713         //                              cout << "k2Ind= "<< k2Ind  << " q2Ind="<< q2Ind  << "Weight=" << Weight << endl;
01714                                 }}
01715                         } // Countqxy
01716                 } // Countkxy
01717 
01718 //              cout << "Finished Main Section " << endl;
01719 //              cout << " LradRange " <<LradRange <<  endl;
01720 
01721 
01722                 EMData *RotTransInvF  = new  EMData(LradRange,LradRange);
01723                 EMData *WeightImage   = new  EMData(LradRange,LradRange);
01724 
01725                 for (int jk =0; jk<LradRange ; jk++){// LradRange
01726                 for (int jq =jk; jq<LradRange; jq++){ // LradRange
01727                         int TotalInd      = jq*LradRange+jk;
01728                         int TotalIndBar   = jq*LradRange+jk;
01729                         float Weight = WeightInv[TotalInd] + WeightInv[TotalIndBar];
01730                         if (Weight <=0) continue;
01731                         WeightImage    -> set_value_at(jk,jq,Weight);
01732                         WeightImage    -> set_value_at(jq,jk,Weight);
01733 #ifdef _WIN32
01734                         float ValNow  = pow( (RotTransInv[TotalInd] + RotTransInv[TotalIndBar]) / Weight, 1.0f/3.0f )  ;
01735 #else
01736                         float ValNow  = cbrt( (RotTransInv[TotalInd] + RotTransInv[TotalIndBar]) / Weight )  ;
01737 #endif  //_WIN32
01738                         RotTransInvF -> set_value_at(jk,jq,ValNow);//  include /Weight
01739                         RotTransInvF -> set_value_at(jq,jk,ValNow );//  include /Weight
01740                 }}
01741 
01742 #ifdef  _WIN32
01743                 _unlink("WeightImage.???");
01744 #else
01745                 system("rm -f WeightImage.???");
01746 #endif  //_WIN32
01747                 WeightImage  -> write_image("WeightImage.img");
01748 
01749                 return  RotTransInvF ;
01750         }
01751         return 0;
01752 }

EMData * EMData::bispecRotTransInvN int  N,
int  NK
 

This computes the rotational and translational bispectral invariants of an image.

The invariants are labelled by the Fourier Harmonic label given by N. fVec is the real input image NK is the number of Fourier components one wishes to use in calculating this bispectrum the output is a single 2D image whose x,y labels are lengths, corresponding to the two lengths of sides of a triangle

Definition at line 1029 of file emdata_transform.cpp.

References calc_bessel(), do_fft(), EMData(), get_value_at(), get_xsize(), process_inplace(), set_size(), set_value_at(), and write_image().

01030 {
01031 
01032         int EndP = this -> get_xsize(); // length(fTrueVec);
01033         int Mid  = (int) ((1+EndP)/2);
01034         int End = 2*Mid-1;
01035 
01036         int CountxyMax = End*End;
01037 
01038         int   *SortfkInds       = new    int[CountxyMax];
01039         int   *kVecX            = new    int[CountxyMax];
01040         int   *kVecY            = new    int[CountxyMax];
01041         float *fkVecR           = new  float[CountxyMax];
01042         float *fkVecI           = new  float[CountxyMax];
01043         float *absD1fkVec       = new  float[CountxyMax];
01044         float *absD1fkVecSorted = new  float[CountxyMax];
01045 
01046         float *jxjyatan2         = new  float[End*End]; //  jxjyatan2[jy*End + jx]  = atan2(jy+1-Mid , jx +1 -Mid);
01047 
01048         EMData * ThisCopy = new EMData(End,End);
01049 
01050         for (int jx=0; jx <End ; jx++) {
01051                 for (int jy=0; jy <End ; jy++) {
01052                         float ValNow = this -> get_value_at(jx,jy);
01053                         ThisCopy -> set_value_at(jx,jy,ValNow);
01054 //              cout<< " jxM= " << jx+1<<" jyM= " << jy+1<< "ValNow" << ValNow << endl; //    Works
01055         }}
01056 
01057 
01058         EMData* fk = ThisCopy -> do_fft();
01059         fk          ->process_inplace("xform.fourierorigin.tocenter");
01060 
01061 //      EMData* fk
01062         EMData* fkRCopy = new EMData(End,End);
01063         EMData* fkICopy = new EMData(End,End);
01064         EMData* fkCopy  = new EMData(End,End);
01065 
01066 
01067         for  (int jCount= 0; jCount<End*End; jCount++) {
01068 //              jCount = jy*End + jx;
01069                 int jx             = jCount%End ;
01070                 int jy             = (jCount-jx)/End ;
01071                 jxjyatan2[jCount]  = atan2((float)(jy+1-Mid) , (float)(jx +1-Mid));
01072         }
01073 
01074 
01075         for (int kEx= 0; kEx<2*Mid; kEx=kEx+2) { // kEx twice the value of the Fourier
01076                                                 // x variable: EMAN index for real, imag
01077                 int kx    = kEx/2;              // kx  is  the value of the Fourier variable
01078                 int kIx   = kx+Mid-1; // This is the value of the index for a matlab image (-1)
01079                 int kCx   =  -kx ;
01080                 int kCIx  = kCx+ Mid-1 ;
01081                 for (int kEy= 0 ; kEy<End; kEy++) { // This is the value of the EMAN index
01082                         int kIy              =  kEy       ; //  This is the value of the index for a matlab image (-1)
01083                         int ky               =  kEy+1-Mid; // (kEy+ Mid-1)%End - Mid+1 ;  // This is the actual value of the Fourier variable
01084                         float realVal        =  fk -> get_value_at(kEx  ,kEy) ;
01085                         float imagVal        =  fk -> get_value_at(kEx+1,kEy) ;
01086                         float absVal         =  ::sqrt(realVal*realVal+imagVal*imagVal);
01087                         float fkAng          =  atan2(imagVal,realVal);
01088 
01089                         float NewRealVal   ;
01090                         float NewImagVal   ;
01091                         float AngMatlab    ;
01092 
01093                         if (kIx==Mid-1) {
01094 //                              AngMatlab = -fkAng - 2.*M_PI*(kIy+ 1-Mid)*(Mid)/End;
01095 //                      cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << AngMatlab << endl;
01096                         }
01097 
01098                         if (kIx>Mid-1){
01099 //                      cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << AngMatlab << endl;
01100                         }
01101 
01102                         AngMatlab = fkAng - 2.0f*M_PI*(kx +ky)*(Mid)/End;
01103                         NewRealVal  =   absVal*cos(AngMatlab);
01104                         NewImagVal  =   absVal*sin(AngMatlab);
01105 
01106 
01107                         fkVecR[kIy+kIx *End] =  NewRealVal ;
01108                         fkVecR[kIy+kCIx*End] =  NewRealVal ;
01109                         fkVecI[kIy+kIx *End] =  NewImagVal ;
01110                         fkVecI[kIy+kCIx*End] = -NewImagVal ;
01111                         absD1fkVec[kIy + kIx  *End] = absVal;
01112                         absD1fkVec[kIy + kCIx *End] = absVal;
01113                         kVecX[kIy+kIx  *End] =  kx      ;
01114                         kVecX[kIy+kCIx *End] =  kCx    ;
01115                         kVecY[kIy+kIx  *End] =  ky     ;
01116                         kVecY[kIy+kCIx *End] =  ky     ;
01117 //                      printf("kx=%d,ky=%d,tempVal =%f+ i %4.2f \n",kx,ky,realVal,imagVal );
01118 //                      cout << "kx = " << kx << "; ky = "<< ky << "; val is" << realVal<<"+ i "<<imagVal<< endl;
01119 
01120 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; fkAng*9/ 2pi is " << fkAng*9/2/M_PI<<  endl;
01121 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; absval is " << absVal<<  "; realval is " << NewRealVal<< "; imagval is " << NewImagVal<< endl;
01122                         fkCopy  -> set_value_at(kIx ,kIy, absVal);
01123                         fkCopy  -> set_value_at(kCIx,kIy, absVal);
01124                         fkRCopy -> set_value_at(kIx, kIy, NewRealVal);
01125                         fkRCopy -> set_value_at(kCIx,kIy, NewRealVal);
01126                         fkICopy -> set_value_at(kIx, kIy, NewImagVal);
01127                         fkICopy -> set_value_at(kCIx,kIy,-NewImagVal);
01128 
01129                 }
01130         }
01131 #ifdef _WIN32
01132         _unlink("fkCopy.???");
01133         _unlink("fk?Copy.???");
01134 #else
01135         system("rm -f fkCopy.???");
01136         system("rm -f fk?Copy.???");
01137 #endif  //_WIN32
01138         fkCopy  -> write_image("fkCopy.img");
01139         fkRCopy -> write_image("fkRCopy.img");
01140         fkICopy -> write_image("fkICopy.img");
01141 
01142         cout << "Starting the sort "<< endl;
01143 
01144         vector< pair<float, int> > absInds;
01145         for(int i  = 0; i < CountxyMax; ++i ) {
01146                 pair<float,int> p;
01147                 p = make_pair(absD1fkVec[i],i); // p = make_pair(rand(),i);
01148                 absInds.push_back( p);
01149         }
01150 
01151         std::sort(absInds.begin(),absInds.end());
01152 
01153         for(int i  = 0; i < CountxyMax; ++i ) {
01154                 pair<float,int> p   ;
01155                 p = absInds[i]         ;
01156                 absD1fkVecSorted[CountxyMax-1-i] =  p.first ;
01157                 SortfkInds[CountxyMax-1-i]       =  p.second ;
01158         }
01159 
01160         cout << "Ending the sort "<< endl;
01161 
01162 // float AngsMat[] ={2.8448, -0.3677,-0.2801,-1.0494,-1.7836,-2.5179, 2.9959, 3.0835,-0.1290,-0.8876,2.1829, 2.2705,1.5011,0.7669,0.0327,-0.7366,-0.6489,2.4215,-1.6029,1.4676,1.5552,0.7859,0.0517,-0.6825,-1.4518,-1.3642,1.7063,-1.7845,1.2859,1.3736,0.6043,-0.1299,-0.8642,-1.6335,-1.5459,1.5247,-1.6546,1.4159,1.5036,0.7342,0,-0.7342,-1.5036,-1.4159,1.6546,-1.5247,1.5459,1.6335,0.8642,0.1299,-0.6043,-1.3736,-1.286,1.7846,-1.7063,1.3642,1.4519,0.6825,-0.0517,-0.7859,-1.5553,-1.4676,1.6029,-2.4216,0.649,0.7366,-0.0327,-0.767,-1.5012,-2.2705,-2.1829,0.8877,0.1291,-3.0836,-2.9959,2.5179,1.7837,1.0495,0.2801,0.3677,-2.8449};
01163 
01164 
01165         for(int i  = 0; i < CountxyMax; ++i ) {  // creates a new fkVec
01166                 int Si  = SortfkInds[i];
01167                 int kIx = (int)  Si/End;  kIx = (int)  i/End; // i = kIx*End+kIy
01168 //              int kIy = Si  - kIx*End;  kIy = i  - kIx*End;
01169 //              int iC = (End-1-kIx)*End + (End-1-kIy);
01170 //              if (i<30) { cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " valAft=" << absD1fkVecSorted[i]<< " valBef="  <<     absD1fkVec[Si] << "  SortfkInds = " << Si <<endl; }// This worked
01171 //              cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << fkAng << endl;
01172         }
01173         cout<< "Ratio of Last Amplitude to First Amplitude= " << absD1fkVecSorted[NK] /absD1fkVecSorted[0]  << endl;
01174 
01175 //      pause;
01176 
01177 //      for(int i  = 0; i < NK; ++i ) { // Prints out the new fkVec ,  CountxyMax
01178 //              int Si= SortfkInds[i];
01179 //              int kIx = (int)  Si/End; // i = kIx*End+kIy
01180 //              int kIy = Si  - kIx*End;
01181 //              cout << " kIxM= " << kIx+1 << " kIyM=" << kIy+1 << " fkVecAbs=" << ::sqrt(fkVecR[Si]*fkVecR[Si] +  fkVecI[Si]* fkVecI[Si]) << " fkVecAbs=" << absD1fkVecSorted[i] << " kx= " << kVecX[Si] <<  " ky=" << kVecY[Si] <<  endl;
01182 //      }
01183 
01184 //       angEMAN+angMat+angDiff    =0  mod 2 pi
01185 
01186 //      angDiff=  2*pi*((-4):4)*(Mid)/End; angEMAN+angMat+angDiff= integer*2 *pi
01187 //              [  absD1fkVecSorted, SortfkInds] =sort( absD1fkVec,'descend') ;
01188 //      Util::sort_mat(&absD1fkVec[0],&absD1fkVec[Countxy],&SortfkInds[0],&SortfkInds[Countxy]);
01189 
01190 
01191 //      Let radial sampling be 0:0.5:(Mid-1)
01192 
01193  //     int NK=  min(12,CountxyMax) ;
01194 
01195 
01196 
01197         cout << "NK = " << NK << endl;
01198         float frR= 3.0/4.0;
01199         int LradRange= (int) (floor(Mid/frR)) ;
01200 
01201         float *radRange = new float[LradRange]; //= 0:.75:(Mid-1);
01202         radRange[0]=0;
01203         for (int irad=1; irad < LradRange; irad++){
01204                         radRange[irad] = radRange[irad-1] + frR; }
01205 
01206 
01207 
01208          // should equal to (2*Mid-1)
01209         cout << "Starting the calculation of invariants for N= " << N << endl;
01210 
01211 /*      int NMax=5;            */
01212 
01213         EMData* RotTransInv = new EMData();
01214         RotTransInv -> set_size(LradRange,LradRange);
01215 
01216 
01217 //      float  *RotTransInv       = new float[LradRange*LradRange ] ;
01218 //      float  *RotTransInvN      = new float[LradRange*LradRange*(NMax+1) ] ;
01219 
01220 //      for (int N=0 ; N<NMax; N++) {
01221 
01222         for (int jr1=0; jr1 < LradRange ; jr1++ ) { // LradRange
01223                 float r1= radRange[jr1];
01224 //              cout << "Pre jr2 "<< endl;
01225                 for (int jr2=0;  jr2<LradRange;  jr2++ ) { //LradRange
01226                         float r2= radRange[jr2];
01227                         float RotTransInvTemp=0;
01228                         for (int jCountkxy =0; jCountkxy<NK; jCountkxy++){
01229                                 int Countkxy =SortfkInds[jCountkxy] ;   // 1: CountxyMax
01230                                 int kx = kVecX[Countkxy] ;
01231                                 int ky = kVecY[Countkxy] ;
01232                                 float k2 = (float)(kx*kx+ky*ky);
01233                                 if (k2==0) { continue;}
01234                                 float phiK =0;
01235                                 if (k2>0) phiK= jxjyatan2[ (ky+Mid-1)*End + kx+Mid-1];  phiK= atan2((float)ky,(float)kx);
01236 
01237                                 float fkR     = fkVecR[Countkxy] ;
01238                                 float fkI     = fkVecI[Countkxy]  ;
01239 /*                              printf("jCountkxy=%d, Countkxy=%d,absD1fkVec(Countkxy)=%f,\t\t kx=%d, ky=%d \n", jCountkxy, Countkxy, absD1fkVec[Countkxy], kx, ky);*/
01240 
01241                                 for (int jCountqxy =0; jCountqxy<NK; jCountqxy++){
01242                                         int Countqxy =SortfkInds[jCountqxy] ;   // Countqxy is the index for absD1fkVec
01243                                         int qx   = kVecX[Countqxy] ;
01244                                         int qy   = kVecY[Countqxy] ;
01245                                         int q2   = qx*qx+qy*qy;
01246                                         if (q2==0) {continue;}
01247                                         float phiQ =0;
01248                                         if (q2>0) phiQ = jxjyatan2[ (qy+Mid-1)*End + qx+Mid-1];   phiQ=atan2((float)qy,(float)qx);
01249                                         float fqR     = fkVecR[Countqxy]  ;
01250                                         float fqI     = fkVecI[Countqxy]  ;
01251                                         int kCx  = (-kx-qx);
01252                                         int kCy  = (-ky-qy);
01253                                         int kCIx = ((kCx+Mid+2*End)%End);// labels of the image in C
01254                                         int kCIy = ((kCy+Mid+2*End)%End);
01255                                         kCx  = kCIx-Mid; // correct
01256                                         kCy  = kCIy-Mid; // correct
01257                                         int CountCxy = kCIx*End+kCIy;
01258                                         float fCR     = fkVecR[CountCxy];
01259                                         float fCI     = fkVecI[CountCxy];
01260                                         if (jr1+jr2==-1) {
01261                                         printf("jCountqxy=%d , Countqxy=%d, absD1fkVec(Countqxy)=%f,qx=%d, qy=%d \n", jCountqxy, Countqxy, absD1fkVec[Countqxy],qx, qy);
01262                                         printf(" CountCxy=%d,absD1fkVec[CountCxy]=%f,  kCx=%d,     kCy=%d \n",CountCxy, absD1fkVec[CountCxy], kCx, kCy );
01263                                         }
01264                                         for (int p=0; p<NK; p++){
01265 //                                              printf("p=%d, SortfkInds[p]=%d, CountCxy =%d \n", p,SortfkInds[p], CountCxy);
01266                                                 if (SortfkInds[p]==CountCxy){
01267                                                         float Arg1 = 2.0f*M_PI*r1*::sqrt((float) q2)/End;
01268                                                         float Arg2 = 2.0f*M_PI*r2*::sqrt((float) k2)/End;
01269 //                                                      printf("Arg1=%4.2f, Arg2=%4.2f,  \n",Arg1, Arg2 );
01270 //                                                      if (Arg1+ Arg2<15) {
01271                                                                 float bispectemp  = (fkR*(fqR*fCR -fqI*fCI) -fkI*(fqI*fCR  +fqR*fCI))
01272                                                                 * cos(N*(phiK-phiQ+M_PI));
01273                                                                 bispectemp  -= (fkR*(fqR*fCI + fqI*fCR) +fkI*(fqR*fCR - fqI*fCI))
01274                                                                 * sin(N*(phiK-phiQ+M_PI));
01275                                                                 float bess1 = calc_bessel(N, Arg1 );
01276                                                                 float bess2 = calc_bessel(N, Arg2 );
01277 //                      printf("fkr=%4.2f, fqr=%4.2f, bess1=%4.2f,bess2=%4.2f \n",fkR, fqR, bess1, bess2);
01278 /*                      printf("p =%d, SortfkInds[p]=%d, CountCxy=%d, Arg1 =%4.2f, bess1=%4.2f,  \n",
01279                                 p, SortfkInds[p],CountCxy, Arg1, bess1);*/
01280                                                                 RotTransInvTemp   = RotTransInvTemp  + bispectemp  * bess1*bess2 ;
01281 //                                                      }
01282                                                 }
01283                                         }
01284                                 } // jCountqxy
01285                         } // jCountkxy
01286                         RotTransInv -> set_value_at(jr1,jr2, RotTransInvTemp)   ;
01287 /*              RotTransInvN[jr1 + LradRange*jr2+LradRange*LradRange*N] = RotTransInvTemp  ;*/
01288                 } //jr2
01289         } //jr1
01290 // }//N
01291 
01292         return  RotTransInv ;
01293 
01294 
01295 }

vector< float > EMData::calc_az_dist int  n,
float  a0,
float  da,
float  rmin,
float  rmax
 

Caculates the azimuthal distributions.

works for real or complex images, 2D only.

Parameters:
n Number of elements.
a0 Starting angle.
da Angle step.
rmin Minimum radius.
rmax Maximum radius.
Exceptions:
ImageDimensionException If image is 3D.
Returns:
Float array to store the data.

Definition at line 2379 of file emdata.cpp.

References data, EMAN::EMObject::f, get_data(), get_ndim(), ImageDimensionException, is_complex(), is_ri(), nx, ny, ny, x, and y.

02380 {
02381         ENTERFUNC;
02382 
02383         a0=a0*M_PI/180.0f;
02384         da=da*M_PI/180.0f;
02385 
02386         if (get_ndim() > 2) {
02387                 throw ImageDimensionException("no 3D image");
02388         }
02389 
02390         float *yc = new float[n];
02391 
02392         vector<float>   vd(n);
02393         for (int i = 0; i < n; i++) {
02394                 yc[i] = 0.00001f;
02395         }
02396 
02397         float * data = get_data();
02398         if (is_complex()) {
02399                 int c = 0;
02400                 for (int y = 0; y < ny; y++) {
02401                         for (int x = 0; x < nx; x += 2, c += 2) {
02402                                 int x1 = x / 2;
02403                                 int y1 = y<ny/2?y:y-ny;
02404                                 float r = (float)Util::hypot_fast(x1,y1);
02405 
02406                                 if (r >= rmin && r <= rmax) {
02407                                         float a = 0;
02408 
02409                                         if (y != ny / 2 || x != 0) {
02410                                                 a = (atan2((float)y1, (float)x1) - a0) / da;
02411                                         }
02412 
02413                                         int i = (int)(floor(a));
02414                                         a -= i;
02415 
02416                                         if (i == 0) {
02417                                                 vd[0] += data[c] * (1.0f - a);
02418                                                 yc[0] += (1.0f - a);
02419                                         }
02420                                         else if (i == n - 1) {
02421                                                 vd[n - 1] += data[c] * a;
02422                                                 yc[n - 1] += a;
02423                                         }
02424                                         else if (i > 0 && i < (n - 1)) {
02425                                                 float h = 0;
02426                                                 if (is_ri()) {
02427 #ifdef  _WIN32
02428                                                         h = (float)_hypot(data[c], data[c + 1]);
02429 #else
02430                                                         h = (float)hypot(data[c], data[c + 1]);
02431 #endif  //_WIN32
02432                                                 }
02433                                                 else {
02434                                                         h = data[c];
02435                                                 }
02436 
02437                                                 vd[i] += h * (1.0f - a);
02438                                                 yc[i] += (1.0f - a);
02439                                                 vd[i + 1] += h * a;
02440                                                 yc[i + 1] += a;
02441                                         }
02442                                 }
02443                         }
02444                 }
02445         }
02446         else {
02447                 int c = 0;
02448                 float half_nx = (nx - 1) / 2.0f;
02449                 float half_ny = (ny - 1) / 2.0f;
02450 
02451                 for (int y = 0; y < ny; y++) {
02452                         for (int x = 0; x < nx; x++, c++) {
02453                                 float y1 = y - half_ny;
02454                                 float x1 = x - half_nx;
02455 #ifdef  _WIN32
02456                                 float r = (float)_hypot(x1, y1);
02457 #else
02458                                 float r = (float)hypot(x1, y1);
02459 #endif
02460 
02461                                 if (r >= rmin && r <= rmax) {
02462                                         float a = 0;
02463                                         if (x1 != 0 || y1 != 0) {
02464                                                 a = atan2(y1, x1);
02465                                                 if (a < 0) {
02466                                                         a += M_PI * 2;
02467                                                 }
02468                                         }
02469 
02470                                         a = (a - a0) / da;
02471                                         int i = static_cast < int >(floor(a));
02472                                         a -= i;
02473 
02474                                         if (i == 0) {
02475                                                 vd[0] += data[c] * (1.0f - a);
02476                                                 yc[0] += (1.0f - a);
02477                                         }
02478                                         else if (i == n - 1) {
02479                                                 vd[n - 1] += data[c] * a;
02480                                                 yc[n - 1] += (a);
02481                                         }
02482                                         else if (i > 0 && i < (n - 1)) {
02483                                                 vd[i] += data[c] * (1.0f - a);
02484                                                 yc[i] += (1.0f - a);
02485                                                 vd[i + 1] += data[c] * a;
02486                                                 yc[i + 1] += a;
02487                                         }
02488                                 }
02489                         }
02490                 }
02491         }
02492 
02493 
02494         for (int i = 0; i < n; i++) {
02495                 vd[i] /= yc[i];
02496         }
02497 
02498         if( yc )
02499         {
02500                 delete[]yc;
02501                 yc = 0;
02502         }
02503 
02504         return vd;
02505 
02506         EXITFUNC;
02507 }

float EMData::calc_center_density  ) 
 

Calculates the density value at the peak of the image histogram, sort of like the mode of the density.

Returns:
The density value at the peak of the image histogram.

Definition at line 254 of file emdata_metadata.cpp.

References EMAN::EMObject::f, get_attr(), get_data(), norm(), nx, and ny.

00255 {
00256         ENTERFUNC;
00257 
00258         float center = get_attr("mean");
00259         float sigma = get_attr("sigma");
00260         float ds = sigma / 2;
00261         size_t size = (size_t)nx * ny * nz;
00262         float *d = get_data();
00263         float sigma1 = sigma / 20;
00264         float sigma2 = sigma / 1000;
00265 
00266         while (ds > sigma1) {
00267                 double sum = 0;
00268                 int norm = 0;
00269 
00270                 for (size_t i = 0; i < size; ++i) {
00271                         if (fabs(d[i] - center) < ds) {
00272                                 sum += d[i];
00273                                 norm++;
00274                         }
00275                 }
00276                 if (!norm) {
00277                         break;
00278                 }
00279                 float mean = (float)(sum / norm);
00280                 if (fabs(mean - center) < sigma2) {
00281                         ds *= 0.5f;
00282                 }
00283                 center = mean;
00284         }
00285         EXITFUNC;
00286 
00287         return center;
00288 }

FloatPoint EMData::calc_center_of_mass const float  threshold = 0  ) 
 

Calculate the center of mass with a threshold (Default 0, so only positive values are considered).

Author:
Steve Ludtke
Date:
Fri Jun 6th 2008

Definition at line 567 of file emdata_metadata.cpp.

References data, get_data(), and nx.

Referenced by EMAN::FRM2DAligner::align(), and EMAN::ToMassCenterProcessor::process_inplace().

00568 {
00569         float *data = get_data();
00570 
00571         //float sigma = get_attr("sigma");
00572         //float mean = get_attr("mean");
00573         float m = 0.0;
00574 
00575         FloatPoint com(0,0,0);
00576         for (int i = 0; i < nx; ++i) {
00577                 for (int j = 0; j < ny; ++j) {
00578                         int j2 = nx * j;
00579                         for (int k = 0; k < nz; ++k) {
00580                                 size_t l = i + j2 + (size_t)k * nxy;
00581                                 if (data[l] >= threshold) {             // threshold out noise (and negative density)
00582                                         com[0] += i * data[l];
00583                                         com[1] += j * data[l];
00584                                         com[2] += k * data[l];
00585                                         m += data[l];
00586                                 }
00587                         }
00588                 }
00589         }
00590 
00591         com[0] /= m;
00592         com[1] /= m;
00593         com[2] /= m;
00594 
00595         return com;
00596 }

float EMData::calc_dist EMData second_img,
int  y_index = 0
const
 

Calculates the distance between 2 vectors.

'this' image is 1D, which contains a vector; 'second_img' may be nD. One of its row is used as the second vector. 'second_img' and 'this' must have the same x size.

Parameters:
second_img The image used to caculate the distance.
y_index Specifies which row in 'second_img' is used to do the caculation.
Exceptions:
ImageDimensionException If 'this' image is not 1D.
ImageFormatException If the 2 images don't have same xsize.
Returns:
The distance between 2 vectors.

Definition at line 3229 of file emdata.cpp.

References get_data(), get_ndim(), get_xsize(), get_ysize(), ImageDimensionException, ImageFormatException, nx, ny, sqrt(), and square.

03230 {
03231         ENTERFUNC;
03232 
03233         if (get_ndim() != 1) {
03234                 throw ImageDimensionException("'this' image is 1D only");
03235         }
03236 
03237         if (second_img->get_xsize() != nx || ny != 1) {
03238                 throw ImageFormatException("image xsize not same");
03239         }
03240 
03241         if (y_index > second_img->get_ysize() || y_index < 0) {
03242                 return -1;
03243         }
03244 
03245         float ret = 0;
03246         float *d1 = get_data();
03247         float *d2 = second_img->get_data() + second_img->get_xsize() * y_index;
03248 
03249         for (int i = 0; i < nx; i++) {
03250                 ret += Util::square(d1[i] - d2[i]);
03251         }
03252         EXITFUNC;
03253         return std::sqrt(ret);
03254 }

EMData * EMData::calc_fast_sigma_image EMData mask  ) 
 

Calculates the local standard deviation (sigma) image using the given mask image.

The mask image is typically much smaller than this image, and consists of ones, or is a small circle consisting of ones. The extent of the non zero neighborhood explicitly defines the range over which the local standard deviation is determined. Fourier convolution is used to do the math, ala Roseman (2003, Ultramicroscopy) However, Roseman was just working on methods Van Heel had presented earlier. The normalize flag causes the mask image to be processed so that it has a unit sum. Works in 1,2 and 3D

Parameters:
mask the image that will be used to define the neighborhood for determine the local standard deviation
Returns:
the sigma image, the phase origin is at the corner (not the center)
Exceptions:
ImageDimensionException if the dimensions of with do not match those of this
ImageDimensionException if any of the dimensions sizes of with exceed of this image's.
Author:
David Woolford
Date:
April 2008

Definition at line 3257 of file emdata.cpp.

References clip_inplace(), convolute(), copy(), EMData(), get_clip(), get_edge_mean(), get_ndim(), get_size(), get_value_at(), get_xsize(), get_ysize(), get_zsize(), ImageDimensionException, mult(), nx, nx, ny, ny, nz, process_inplace(), and sub().

Referenced by calc_flcf().

03258 {
03259         ENTERFUNC;
03260 
03261         bool maskflag = false;
03262         if (mask == 0) {
03263                 mask = new EMData(nx,ny,nz);
03264                 mask->process_inplace("testimage.circlesphere");
03265                 maskflag = true;
03266         }
03267 
03268         if (get_ndim() != mask->get_ndim() ) throw ImageDimensionException("The dimensions do not match");
03269 
03270         int mnx = mask->get_xsize(); int mny = mask->get_ysize(); int mnz = mask->get_zsize();
03271 
03272         if ( mnx > nx || mny > ny || mnz > nz)
03273                 throw ImageDimensionException("Can not calculate variance map using an image that is larger than this image");
03274 
03275         size_t P = 0;
03276         for(size_t i = 0; i < mask->get_size(); ++i){
03277                 if (mask->get_value_at(i) != 0){
03278                         ++P;
03279                 }
03280         }
03281         float normfac = 1.0f/(float)P;
03282 
03283 //      bool undoclip = false;
03284 
03285         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03286 //      if ( mnx < nx || mny < ny || mnz < nz) {
03287         Region r;
03288         if (ny == 1) r = Region((mnx-nxc)/2,nxc);
03289         else if (nz == 1) r = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03290         else r = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03291         mask->clip_inplace(r,0.0);
03292         //Region r((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03293         //mask->clip_inplace(r);
03294         //undoclip = true;
03295         //}
03296 
03297         // Here we generate the local average of the squares
03298         Region r2;
03299         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03300         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03301         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03302         EMData* squared = get_clip(r2,get_edge_mean());
03303 
03304         EMData* tmp = squared->copy();
03305         Dict pow;
03306         pow["pow"] = 2.0f;
03307         squared->process_inplace("math.pow",pow);
03308         EMData* s = mask->convolute(squared);//ming, mask squared exchange
03309         squared->mult(normfac);
03310 
03311         EMData* m = mask->convolute(tmp);//ming, tmp mask exchange
03312         m->mult(normfac);
03313         m->process_inplace("math.pow",pow);
03314         delete tmp; tmp = 0;
03315         s->sub(*m);
03316         // Here we finally generate the standard deviation image
03317         s->process_inplace("math.sqrt");
03318 
03319 //      if ( undoclip ) {
03320 //              Region r((nx-mnx)/2, (ny-mny)/2, (nz-mnz)/2,mnx,mny,mnz);
03321 //              mask->clip_inplace(r);
03322 //      }
03323 
03324         if (maskflag) {
03325                 delete mask;
03326                 mask = 0;
03327         } else {
03328                 Region r;
03329                 if (ny == 1) r = Region((nxc-mnx)/2,mnx);
03330                 else if (nz == 1) r = Region((nxc-mnx)/2, (nyc-mny)/2,mnx,mny);
03331                 else r = Region((nxc-mnx)/2, (nyc-mny)/2,(nzc-mnz)/2,mnx,mny,mnz);
03332                 mask->clip_inplace(r);
03333         }
03334 
03335         delete squared;
03336         delete m;
03337 
03338         s->process_inplace("xform.phaseorigin.tocenter");
03339         Region r3;
03340         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03341         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03342         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03343         s->clip_inplace(r3);
03344         EXITFUNC;
03345         return s;
03346 }

EMData * EMData::calc_flcf EMData with  ) 
 

Calculates the cross correlation with local normalization between 2 images.

This is a faster version of local correlation that make use of Fourier convolution and correlation. With is the template - the thing that you wish to find in the this image. It should not be unecessarily padded. The function uses the size of with to determine the extent of the local neighborhood used in the local normalization (for technical details, see calc_fast_sigma_image). Note that this function circularly masks the template at its radius so the calling function need not do this beforehand. Works in 1,2 and 3D.

Parameters:
with The image used to calculate cross correlation (the template)
Returns:
the local normalized cross correlation image - the phase origin is at the corner of the image
Author:
David Woolford
Date:
April 2008

Definition at line 3350 of file emdata.cpp.

References calc_ccf(), calc_fast_sigma_image(), clip_inplace(), copy(), div(), EMData(), get_xsize(), get_ysize(), get_zsize(), mult(), nx, nx, ny, ny, nz, and process_inplace().

Referenced by EMAN::TranslationalAligner::align().

03351 {
03352         ENTERFUNC;
03353         EMData *this_copy=this;
03354         this_copy=copy();
03355 
03356         int mnx = with->get_xsize(); int mny = with->get_ysize(); int mnz = with->get_zsize();
03357         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03358 
03359         // Ones is a circular/spherical mask, consisting of 1s.
03360         EMData* ones = new EMData(mnx,mny,mnz);
03361         ones->process_inplace("testimage.circlesphere");
03362 
03363         // Get a copy of with, we will eventually resize it
03364         EMData* with_resized = with->copy();
03365         with_resized->process_inplace("normalize");
03366         with_resized->mult(*ones);
03367 
03368         EMData* s = calc_fast_sigma_image(ones);// Get the local sigma image
03369 
03370         Region r1;
03371         if (ny == 1) r1 = Region((mnx-nxc)/2,nxc);
03372         else if (nz == 1) r1 = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03373         else r1 = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03374         with_resized->clip_inplace(r1,0.0);
03375 
03376         Region r2;
03377         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03378         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03379         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03380         this_copy->clip_inplace(r2,0.0);
03381 
03382         EMData* corr = this_copy->calc_ccf(with_resized); // the ccf results should have same size as sigma
03383 
03384         corr->process_inplace("xform.phaseorigin.tocenter");
03385         Region r3;
03386         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03387         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03388         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03389         corr->clip_inplace(r3);
03390 
03391         corr->div(*s);
03392 
03393         delete with_resized; delete ones; delete this_copy; delete s;
03394         EXITFUNC;
03395         return corr;
03396 }

vector< float > EMData::calc_fourier_shell_correlation EMData with,
float  w = 1.0f
 

Calculate CCF in Fourier space as a function of spatial frequency between a pair of 2-3D images (corners not included).

The input image 'with' must have the same size to 'this' image. Input images can be either real or Fourier in arbitrary combination.

Parameters:
[in] with The image used to caculate the fourier shell
[in] w Ring/shell width in Fourier space.
Exceptions:
ImageFormatException If the 2 images are not same size.
NullPointerException if the input image is null
Cannot calculate FSC for 1D images
Returns:
Vector of 3*k FSC results (frequencies, FSC values, error) k - length of FSC curve, depends on dimensions of the image and ring width 1 column - normalized frequency [0,0.5] 2 column - FSC, 3 column - error of the FSC = 1/sqrt(n), where n is the number of Fourier coefficients within given shell.

Definition at line 832 of file emdata_sparx.cpp.

References do_fft_inplace(), get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), is_fftodd(), max, norm_pad(), NullPointerException, nx, nx, ny, ny, nz, and sqrt().

Referenced by ali3d_d(), and EMAN::FRCCmp::cmp().

00833 {
00834         ENTERFUNC;
00835 
00836 /*
00837  ******************************************************
00838  *DISCLAIMER
00839  * 08/16/05 P.A.Penczek
00840  * The University of Texas
00841  * Pawel.A.Penczek@uth.tmc.edu
00842  * Please do not modify the content of calc_fourier_shell_correlation
00843  ******************************************************/
00844 /*
00845 Fourier Ring/Shell Correlation
00846 Purpose: Calculate CCF in Fourier space as a function of spatial frequency
00847          between a pair of 2-3D images.
00848 Method: Calculate FFT (if needed), calculate FSC.
00849 Input:  f - real or complex 2-3D image
00850         g - real or complex 2-3D image
00851         w - float ring width
00852 Output: 2D 3xk real image.
00853         k - length of FSC curve, depends on dimensions of the image and ring width
00854         1 column - FSC,
00855         2 column - normalized frequency [0,0.5]
00856         3 column - currently n /error of the FSC = 1/sqrt(n),
00857                      where n is the number of Fourier coefficients within given shell
00858 */
00859         int needfree=0, kz, ky, ii;
00860         float  argx, argy, argz;
00861 
00862         if (!with) {
00863                 throw NullPointerException("NULL input image");
00864         }
00865 
00866 
00867         EMData *f = this;
00868         EMData *g = with;
00869 
00870         int nx  = f->get_xsize();
00871         int ny  = f->get_ysize();
00872         int nz  = f->get_zsize();
00873 
00874         if (ny==0 && nz==0) {
00875                 throw ImageFormatException( "Cannot calculate FSC for 1D images");
00876         }
00877 
00878         if (f->is_complex()) nx = (nx - 2 + f->is_fftodd()); // nx is the real-space size of the input image
00879         int lsd2 = (nx + 2 - nx%2) ; // Extended x-dimension of the complex image
00880 
00881 //  Process f if real
00882         EMData* fpimage = NULL;
00883         if (f->is_complex()) fpimage = f;
00884         else {
00885                 fpimage= f->norm_pad(false, 1); 
00886                 fpimage->do_fft_inplace();
00887                 needfree|=1; // Extend and do the FFT if f is real
00888         } 
00889 
00890 //  Process g if real
00891         EMData* gpimage = NULL;
00892         if (g->is_complex()) gpimage = g;
00893         else {
00894                 gpimage= g->norm_pad(false, 1);
00895                 gpimage->do_fft_inplace();
00896                 needfree|=2;  // Extend and do the FFT if g is real
00897         }
00898 
00899         float *d1 = fpimage->get_data();
00900         float *d2 = gpimage->get_data();
00901 
00902         int nx2 = nx/2;
00903         int ny2 = ny/2;
00904         int nz2 = nz/2;
00905 
00906         float dx2 = 1.0f/float(nx2)/float(nx2);
00907         float dy2 = 1.0f/float(ny2)/float(ny2);
00908 
00909 #ifdef _WIN32
00910         float dz2 = 1.0f / _cpp_max(float(nz2),1.0f)/_cpp_max(float(nz2),1.0f);
00911         int inc = Util::round(float( _cpp_max( _cpp_max(nx2,ny2),nz2) )/w );
00912 #else
00913         float dz2 = 1.0f/std::max(float(nz2),1.0f)/std::max(float(nz2),1.0f);
00914         int inc = Util::round(float(std::max(std::max(nx2,ny2),nz2))/w);
00915 #endif  //_WIN32
00916 
00917         double* ret = new double[inc+1];
00918         double* n1 = new double[inc+1];
00919         double* n2 = new double[inc+1];
00920         float*  lr = new float[inc+1];
00921         for (int i = 0; i <= inc; i++) {
00922                 ret[i] = 0; n1[i] = 0; n2[i] = 0; lr[i]=0;
00923         }
00924 
00925         for (int iz = 0; iz <= nz-1; iz++) {
00926                 if(iz>nz2) kz=iz-nz; else kz=iz; argz = float(kz*kz)*dz2;
00927                 for (int iy = 0; iy <= ny-1; iy++) {
00928                         if(iy>ny2) ky=iy-ny; else ky=iy; argy = argz + float(ky*ky)*dy2;
00929                         for (int ix = 0; ix <= lsd2-1; ix+=2) {
00930                         // Skip Friedel related values
00931                                 if (ix>0 || (kz>=0 && (ky>=0 || kz!=0))) {
00932                                         argx = 0.5f*std::sqrt(argy + float(ix*ix)*0.25f*dx2);
00933                                         int r = Util::round(inc*2*argx);
00934                                         if(r <= inc) {
00935                                                 ii = ix + (iy  + iz * ny)* lsd2;
00936                                                 ret[r] += d1[ii] * double(d2[ii]) + d1[ii + 1] * double(d2[ii + 1]);
00937                                                 n1[r]  += d1[ii] * double(d1[ii]) + d1[ii + 1] * double(d1[ii + 1]);
00938                                                 n2[r]  += d2[ii] * double(d2[ii]) + d2[ii + 1] * double(d2[ii + 1]);
00939                                                 lr[r]  += 2;
00940                                         }
00941                                 }
00942                         }
00943                 }
00944         }
00945 
00946         int  linc = 0;
00947         for (int i = 0; i <= inc; i++) if(lr[i]>0) linc++;
00948 
00949         vector<float> result(linc*3);
00950 
00951         ii = -1;
00952         for (int i = 0; i <= inc; i++) {
00953                 if(lr[i]>0) {
00954                         ii++;
00955                         result[ii]        = float(i)/float(2*inc);
00956                         result[ii+linc]   = float(ret[i] / (std::sqrt(n1[i] * n2[i])));
00957                         result[ii+2*linc] = lr[i]  /*1.0f/sqrt(float(lr[i]))*/;
00958                 }
00959                 /*else {
00960                         result[i]           = 0.0f;
00961                         result[i+inc+1]     = 0.0f;
00962                         result[i+2*(inc+1)] = 0.0f;}*/
00963         }
00964 
00965         if (needfree&1) {
00966                 if (fpimage) {
00967                         delete fpimage;
00968                         fpimage = 0;
00969                 }
00970         }
00971         if (needfree&2) {
00972                 if (gpimage) {
00973                         delete gpimage;
00974                         gpimage = 0;
00975                 }
00976         }
00977         delete[] ret; delete[]  n1; delete[]  n2; delete[]  lr;
00978 
00979         EXITFUNC;
00980         return result;
00981 }

vector< Pixel > EMData::calc_highest_locations float  threshold  )  const
 

Calculate and return a sorted list of pixels whose values are above a specified threshold.

The pixels are sorted from high to low.

Parameters:
threshold The specified pixel value. Returned pixels should have higher values than it.
Returns:
A sorted list of pixels with their values, and locations. Their values are higher than threshold.

Definition at line 615 of file emdata_metadata.cpp.

References data, get_data(), is_complex(), is_ri(), nx, nxy, and v.

Referenced by EMAN::DistanceSegmentProcessor::process().

00616 {
00617         ENTERFUNC;
00618 
00619         vector<Pixel> result;
00620 
00621         int di = 1;
00622         if (is_complex() && !is_ri()) {
00623                 di = 2;
00624         }
00625 
00626         int nxy = nx * ny;
00627         float * data = get_data();
00628 
00629         for (int j = 0; j < nz; ++j) {
00630                 size_t cur_z = (size_t)j * nxy;
00631 
00632                 for (int k = 0; k < ny; ++k) {
00633                         size_t cur_y = k * nx + cur_z;
00634 
00635                         for (int l = 0; l < nx; l += di) {
00636                                 float v =data[l + cur_y];
00637                                 if (v > threshold) {
00638                                         result.push_back(Pixel(l, k, j, v));
00639                                 }
00640                         }
00641                 }
00642         }
00643 
00644         std::sort(result.begin(), result.end());
00645 
00646         EXITFUNC;
00647         return result;
00648 }

vector< float > EMData::calc_hist int  hist_size = 128,
float  hist_min = 0,
float  hist_max = 0,
const float &  brt = 0.0f,
const float &  cont = 1.0f
 

Calculates the histogram of 'this' image.

The result is stored in float array 'hist'. If hist_min = hist_max, use image data min as hist_min; use image data max as hist_max.

Parameters:
hist_size Histogram array's size.
hist_min Minimum histogram value.
hist_max Maximum histogram value.
brt 
cont 
Returns:
histogram array of this image.

Definition at line 2299 of file emdata.cpp.

References data, get_attr(), get_data(), is_complex(), nx, and ny.

02300 {
02301         ENTERFUNC;
02302 
02303         static size_t prime[] = { 1, 3, 7, 11, 17, 23, 37, 59, 127, 253, 511 };
02304 
02305         if (histmin == histmax) {
02306                 histmin = get_attr("minimum");
02307                 histmax = get_attr("maximum");
02308         }
02309 
02310         vector <float> hist(hist_size, 0.0);
02311 
02312         int p0 = 0;
02313         int p1 = 0;
02314         size_t size = (size_t)nx * ny * nz;
02315         if (size < 300000) {
02316                 p0 = 0;
02317                 p1 = 0;
02318         }
02319         else if (size < 2000000) {
02320                 p0 = 2;
02321                 p1 = 3;
02322         }
02323         else if (size < 8000000) {
02324                 p0 = 4;
02325                 p1 = 6;
02326         }
02327         else {
02328                 p0 = 7;
02329                 p1 = 9;
02330         }
02331 
02332         if (is_complex() && p0 > 0) {
02333                 p0++;
02334                 p1++;
02335         }
02336 
02337         size_t di = 0;
02338 //      float norm = 0;
02339         size_t n = hist.size();
02340 
02341         float * data = get_data();
02342         for (int k = p0; k <= p1; ++k) {
02343                 if (is_complex()) {
02344                         di = prime[k] * 2;
02345                 }
02346                 else {
02347                         di = prime[k];
02348                 }
02349 
02350 //              norm += (float)size / (float) di;
02351                 float w = (float)n / (histmax - histmin);
02352 
02353                 for(size_t i=0; i<=size-di; i += di) {
02354                         float val;
02355                         if (cont != 1.0f || brt != 0)val = cont*(data[i]+brt);
02356                         else val = data[i];
02357                         int j = Util::round((val - histmin) * w);
02358                         if (j >= 0 && j < (int) n) {
02359                                 hist[j] += 1;
02360                         }
02361                 }
02362         }
02363 /*
02364         for (size_t i = 0; i < hist.size(); ++i) {
02365                 if (norm != 0) {
02366                         hist[i] = hist[i] / norm;
02367                 }
02368         }
02369 */
02370         return hist;
02371 
02372         EXITFUNC;
02373 }

size_t EMData::calc_max_index  )  const
 

Calculates the index of maximum-value pixel when assuming all pixels are in a 1D array.

Returns:
Index of the maximum-value pixel.

Definition at line 607 of file emdata_metadata.cpp.

References calc_max_location(), and nx.

Referenced by EMAN::RTFExhaustiveAligner::align().

00608 {
00609         IntPoint max_location = calc_max_location();
00610         size_t i = max_location[0] + max_location[1] * nx + (size_t)max_location[2] * nx * ny;
00611         return i;
00612 }

IntPoint EMData::calc_max_location  )  const
 

Calculates the coordinates of the maximum-value pixel.

Returns:
The coordinates of the maximum-value pixel.

Definition at line 366 of file emdata_metadata.cpp.

References data, get_data(), is_complex(), is_ri(), max, nx, nxy, and t.

Referenced by calc_max_index().

00367 {
00368         ENTERFUNC;
00369 
00370         int di = 1;
00371         if (is_complex() && !is_ri()) {
00372                 di = 2;
00373         }
00374 
00375         float max = -FLT_MAX;
00376         int max_x = 0;
00377         int max_y = 0;
00378         int max_z = 0;
00379         int nxy = nx * ny;
00380         float * data = get_data();
00381 
00382         for (int j = 0; j < nz; ++j) {
00383                 size_t cur_z = (size_t)j * nxy;
00384 
00385                 for (int k = 0; k < ny; ++k) {
00386                         size_t cur_y = k * nx + cur_z;
00387 
00388                         for (int l = 0; l < nx; l += di) {
00389                                 float t = data[l + cur_y];
00390                                 if (t > max) {
00391                                         max_x = l;
00392                                         max_y = k;
00393                                         max_z = j;
00394                                         max = t;
00395                                 }
00396                         }
00397                 }
00398         }
00399 
00400         EXITFUNC;
00401         return IntPoint(max_x, max_y, max_z);
00402 }

IntPoint EMData::calc_max_location_wrap const int  maxshiftx = -1,
const int  maxshifty = -1,
const int  maxshiftz = -1
 

Calculates the wrapped coordinates of the maximum value This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.

Returns:
the wrapped coordinates of the maximum
Author:
David Woolford
Date:
Fri Jun 6th 2008

Definition at line 405 of file emdata_metadata.cpp.

References calc_max_location_wrap_cuda(), get_value_at_wrap(), get_xsize(), get_ysize(), get_zsize(), nx, ny, nz, CudaPeakInfo::px, CudaPeakInfo::py, and CudaPeakInfo::pz.

Referenced by EMAN::Refine3DAlignerGrid::align(), EMAN::TranslationalAligner::align(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00406 {
00407         int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
00408         if (maxdx == -1) maxshiftx = get_xsize()/4;
00409         if (maxdy == -1) maxshifty = get_ysize()/4;
00410         if (maxdz == -1) maxshiftz = get_zsize()/4;
00411 
00412         float max_value = -FLT_MAX;
00413 
00414         IntPoint peak(0,0,0);
00415         
00416 #ifdef EMAN2_USING_CUDA //CUDA
00417         if(EMData::usecuda == 1 && cudarwdata){
00418         
00419                 CudaPeakInfo* soln = calc_max_location_wrap_cuda(cudarwdata, nx, ny, nz, maxdx, maxdy, maxdz);
00420                 
00421                 peak[0] = soln->px;
00422                 peak[1] = soln->py;
00423                 peak[2] = soln->pz;
00424                 free(soln);
00425                 
00426 //              cout << "x " << peak[0] << " y " << peak[1] << " z " << peak[2] << endl;
00427                 return peak;
00428         }
00429 #endif
00430         for (int k = -maxshiftz; k <= maxshiftz; k++) {
00431                 for (int j = -maxshifty; j <= maxshifty; j++) {
00432                         for (int i = -maxshiftx; i <= maxshiftx; i++) {
00433 
00434                                 float value = get_value_at_wrap(i,j,k);
00435 
00436                                 if (value > max_value) {
00437                                         max_value = value;
00438                                         peak[0] = i;
00439                                         peak[1] = j;
00440                                         peak[2] = k;
00441                                 }
00442                         }
00443                 }
00444         }
00445 
00446         return peak;
00447 }

vector< float > EMData::calc_max_location_wrap_intp const int  maxshiftx = -1,
const int  maxshifty = -1,
const int  maxshiftz = -1
 

Calculates the wrapped coordinates of the maximum value, and uses quadration intp to subpixel prec This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.

Returns:
the wrapped coordinates of the maximum
Author:
John Flanagan
Date:
Mon Mar 7th 2011

Definition at line 449 of file emdata_metadata.cpp.

References get_value_at_wrap(), get_xsize(), get_ysize(), get_zsize(), x, and y.

00450 {
00451         int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
00452         if (maxdx == -1) maxshiftx = get_xsize()/4;
00453         if (maxdy == -1) maxshifty = get_ysize()/4;
00454         if (maxdz == -1) maxshiftz = get_zsize()/4;
00455 
00456         float max_value = -FLT_MAX;
00457 
00458         IntPoint peak(0,0,0);
00459 
00460 // NOT yet working......
00477         for (int k = -maxshiftz; k <= maxshiftz; k++) {
00478                 for (int j = -maxshifty; j <= maxshifty; j++) {
00479                         for (int i = -maxshiftx; i <= maxshiftx; i++) {
00480 
00481                                 float value = get_value_at_wrap(i,j,k);
00482 
00483                                 if (value > max_value) {
00484                                         max_value = value;
00485                                         peak[0] = i;
00486                                         peak[1] = j;
00487                                         peak[2] = k;
00488                                 }
00489                         }
00490                 }
00491         }
00492         
00493         // compute the center of mass
00494         float cmx = 0.0; float cmy = 0.0f; float cmz = 0.0f;
00495         float sval = 0.0f;
00496         for (float x = float(peak[0])-2.0f; x <= float(peak[0])+2.0f; x++) {
00497                 for (float y = float(peak[1])-2.0f; y <= float(peak[1])+2.0f; y++) {
00498                         for (float z = float(peak[2])-2.0f; z <= float(peak[2])+2.0f; z++) {
00499                                 //Compute center of mass
00500                                 float val = get_value_at_wrap(x,y,z);
00501                                 cmx += x*val;
00502                                 cmy += y*val;
00503                                 cmz += z*val;
00504                                 sval += val;
00505                         }
00506                 }
00507         }
00508         cmx /= sval;
00509         cmy /= sval;
00510         cmz /= sval;
00511 
00512         vector<float> mydata;
00513         mydata.push_back(cmx);
00514         mydata.push_back(cmy);
00515         mydata.push_back(cmz);
00516         mydata.push_back(max_value);
00517 
00564         return mydata;
00565 }

size_t EMData::calc_min_index  )  const
 

Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array.

Returns:
Index of the minimum-value pixel.

Definition at line 599 of file emdata_metadata.cpp.

References calc_min_location(), and nx.

00600 {
00601         IntPoint min_location = calc_min_location();
00602         size_t i = min_location[0] + min_location[1] * nx + (size_t)min_location[2] * nx * ny;
00603         return i;
00604 }

IntPoint EMData::calc_min_location  )  const
 

Calculates the coordinates of the minimum-value pixel.

Returns:
The coordinates of the minimum-value pixel.

Definition at line 328 of file emdata_metadata.cpp.

References data, get_data(), is_complex(), is_ri(), min, nx, nxy, and t.

Referenced by calc_min_index().

00329 {
00330         ENTERFUNC;
00331 
00332         int di = 1;
00333         if (is_complex() && !is_ri()) {
00334                 di = 2;
00335         }
00336 
00337         float min = FLT_MAX;
00338         int min_x = 0;
00339         int min_y = 0;
00340         int min_z = 0;
00341         int nxy = nx * ny;
00342         float * data = get_data();
00343 
00344         for (int j = 0; j < nz; ++j) {
00345                 size_t cur_z = (size_t)j * nxy;
00346 
00347                 for (int k = 0; k < ny; ++k) {
00348                         size_t cur_y = k * nx + cur_z;
00349 
00350                         for (int l = 0; l < nx; l += di) {
00351                                 float t = data[l + cur_y];
00352                                 if (t < min) {
00353                                         min_x = l;
00354                                         min_y = k;
00355                                         min_z = j;
00356                                         min = t;
00357                                 }
00358                         }
00359                 }
00360         }
00361 
00362         return IntPoint(min_x, min_y, min_z);
00363 }

EMData * EMData::calc_mutual_correlation EMData with,
bool  tocorner = false,
EMData filter = 0
 

Calculates mutual correlation function (MCF) between 2 images.

If 'with' is NULL, this does mirror ACF.

Parameters:
with The image used to calculate MCF.
tocorner Set whether to translate the result image to the corner.
filter The filter image used in calculating MCF.
Exceptions:
ImageFormatException If 'with' is not NULL and it doesn't have the same size to 'this' image.
NullPointerException If FFT returns NULL image.
Returns:
Mutual correlation function image.

Definition at line 2143 of file emdata.cpp.

References ap2ri(), copy(), do_fft(), do_ift(), get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, LOGERR, mcf_cuda(), mult(), mult_complex_efficient(), mult_complex_efficient_cuda(), NullPointerException, process_inplace(), set_attr(), set_path(), sqrt(), square, t, and update().

Referenced by make_rotational_footprint_cmc(), and make_rotational_footprint_e1().

02144 {
02145         ENTERFUNC;
02146 
02147         if (with && !EMUtil::is_same_size(this, with)) {
02148                 LOGERR("images not same size");
02149                 throw ImageFormatException( "images not same size");
02150         }
02151 
02152 #ifdef EMAN2_USING_CUDA
02153         if(EMData::usecuda == 1 && cudarwdata && with->cudarwdata)
02154         {       
02155 
02156                 EMData* this_fft = do_fft_cuda();
02157 
02158                 EMData *cf = 0;
02159                 if (with && with != this) {
02160                         cf = with->do_fft_cuda();
02161                 }else{
02162                         cf = this_fft->copy();
02163                 }
02164                 
02165                 if (filter) {
02166                         if (!EMUtil::is_same_size(filter, cf)) {
02167                                 LOGERR("improperly sized filter");
02168                                 throw ImageFormatException("improperly sized filter");
02169                         }
02170                         mult_complex_efficient_cuda(cf->cudarwdata, filter->cudarwdata, cf->get_xsize(), cf->get_ysize(), cf->get_zsize(), 1);
02171                         mult_complex_efficient_cuda(this_fft->cudarwdata, filter->cudarwdata, this_fft->get_xsize(), this_fft->get_ysize(), this_fft->get_zsize(), 1);
02172                 }
02173                 
02174                 mcf_cuda(this_fft->cudarwdata, cf->cudarwdata, this_fft->get_xsize(), this_fft->get_ysize(), this_fft->get_zsize());
02175                 
02176                 EMData *f2 = cf->do_ift_cuda();
02177 
02178                 if (tocenter) {
02179                         f2->process_inplace("xform.phaseorigin.tocenter");
02180                 }
02181 
02182                 if( cf )
02183                 {
02184                         delete cf;
02185                         cf = 0;
02186                 }
02187 
02188                 if( this_fft )
02189                 {
02190                         delete this_fft;
02191                         this_fft = 0;
02192                 }
02193 
02194                 f2->set_attr("label", "MCF");
02195                 f2->set_path("/tmp/eman.mcf");
02196                 f2->update();
02197 
02198                 EXITFUNC;
02199                 return f2;
02200         }
02201 #endif
02202 
02203         EMData *this_fft = 0;
02204         this_fft = do_fft();
02205 
02206         if (!this_fft) {
02207 
02208                 LOGERR("FFT returns NULL image");
02209                 throw NullPointerException("FFT returns NULL image");
02210         }
02211 
02212         this_fft->ap2ri(); //this is not needed!
02213         EMData *cf = 0;
02214 
02215         if (with && with != this) {
02216                 cf = with->do_fft();
02217                 if (!cf) {
02218                         LOGERR("FFT returns NULL image");
02219                         throw NullPointerException("FFT returns NULL image");
02220                 }
02221                 cf->ap2ri(); //nor is this!
02222         }
02223         else {
02224                 cf = this_fft->copy();
02225         }
02226         
02227         if (filter) {
02228                 if (!EMUtil::is_same_size(filter, cf)) {
02229                         LOGERR("improperly sized filter");
02230                         throw ImageFormatException("improperly sized filter");
02231                 }
02232                 
02233                 cf->mult_complex_efficient(*filter,true); //insanely this is required....
02234                 this_fft->mult(*filter,true);
02235                 //cf->mult_complex_efficient(*filter,7); // takes advantage of the fact that the filter is 1 everywhere but near the origin
02236                 //this_fft->mult_complex_efficient(*filter,7);
02237                 /*cf->mult_complex_efficient(*filter,5);
02238                 this_fft->mult_complex_efficient(*filter,5);*/
02239         }
02240 
02241         float *rdata1 = this_fft->get_data();
02242         float *rdata2 = cf->get_data();
02243         size_t this_fft_size = (size_t)this_fft->get_xsize() * this_fft->get_ysize() * this_fft->get_zsize();
02244 
02245         if (with == this) {
02246                 for (size_t i = 0; i < this_fft_size; i += 2) {
02247                         rdata2[i] = std::sqrt(rdata1[i] * rdata2[i] + rdata1[i + 1] * rdata2[i + 1]);
02248                         rdata2[i + 1] = 0;
02249                 }
02250 
02251                 this_fft->update();
02252                 cf->update();
02253         }
02254         else {
02255                 for (size_t i = 0; i < this_fft_size; i += 2) {
02256                         rdata2[i] = (rdata1[i] * rdata2[i] + rdata1[i + 1] * rdata2[i + 1]);
02257                         rdata2[i + 1] = (rdata1[i + 1] * rdata2[i] - rdata1[i] * rdata2[i + 1]);
02258                 }
02259                 
02260                 //This seems like a bug, but it probably is never used....
02261                 for (size_t i = 0; i < this_fft_size; i += 2) {
02262                         float t = Util::square(rdata2[i]) + Util::square(rdata2[i + 1]);
02263                         if (t != 0) {
02264                                 t = pow(t, 0.25f);
02265                                 rdata2[i] /= t;
02266                                 rdata2[i + 1] /= t;
02267                         }
02268                 }
02269                 this_fft->update();
02270                 cf->update();
02271         }
02272 
02273         EMData *f2 = cf->do_ift();
02274 
02275         if (tocenter) {
02276                 f2->process_inplace("xform.phaseorigin.tocenter");
02277         }
02278 
02279         if( cf )
02280         {
02281                 delete cf;
02282                 cf = 0;
02283         }
02284 
02285         if( this_fft )
02286         {
02287                 delete this_fft;
02288                 this_fft = 0;
02289         }
02290 
02291         f2->set_attr("label", "MCF");
02292         f2->set_path("/tmp/eman.mcf");
02293 
02294         EXITFUNC;
02295         return f2;
02296 }

vector< Pixel > EMData::calc_n_highest_locations int  n  ) 
 

Calculate and return a sorted list of N highest pixels in the map.

Parameters:
n The number of highest value pixels should be returned.
Returns:
A sorted list of N pixels with their values, and locations.

Definition at line 650 of file emdata_metadata.cpp.

References data, get_data(), is_complex(), is_ri(), nx, nxy, and v.

Referenced by EMAN::AutoMask3D2Processor::process_inplace(), and EMAN::AutoMask2DProcessor::process_inplace().

00651 {
00652         ENTERFUNC;
00653 
00654         vector<Pixel> result;
00655 
00656         int di = 1;
00657         if (is_complex() && !is_ri()) {
00658                 di = 2;
00659         }
00660 
00661         // initialize with n elements
00662         float * data = get_data();
00663         for ( int i=0; i<n; i++) result.push_back(Pixel(0,0,0,data[0]));
00664 
00665         int nxy = nx * ny;
00666 
00667         for (int j = 0; j < nz; ++j) {
00668                 size_t cur_z = (size_t)j * nxy;
00669 
00670                 for (int k = 0; k < ny; ++k) {
00671                         size_t cur_y = k * nx + cur_z;
00672 
00673                         for (int l = 0; l < nx; l += di) {
00674                                 float v =data[l + cur_y];
00675                                 if (v<result[n-1].value) continue;
00676                                 for (vector<Pixel>::iterator i=result.begin(); i<result.end(); i++) {
00677                                         if (v>(*i).value) { result.insert(i,Pixel(l, k, j, v)); result.pop_back(); break; }
00678                                 }
00679                         }
00680                 }
00681         }
00682 
00683         EXITFUNC;
00684         return result;
00685 }

vector< float > EMData::calc_radial_dist int  n,
float  x0,
float  dx,
int  nwedge,
float  offset,
bool  inten
 

calculates radial distribution subdivided by angle.

works for real and imaginary images. 2-D only. The first returns a single vector of n*nwedge points, with radius varying first. That is, the first n points represent the radial profile in the first wedge.

Parameters:
n number of points.
x0 starting x coordinate.
dx step of x.
nwedge int number of wedges to divide the circle into
nwedge float angular offset in radians for start of first bin
inten returns intensity (amp^2) rather than amplitude if set
Exceptions:
ImageDimensionException If 'this' image is not 2D.
Returns:
nwedge radial distributions packed into a single vector<float>

Definition at line 2813 of file emdata.cpp.

References data, EMAN::EMObject::f, get_attr_default(), get_data(), ImageDimensionException, InvalidParameterException, is_complex(), is_ri(), LOGERR, norm(), nx, ny, nz, v, x, and y.

02814 {
02815         ENTERFUNC;
02816 
02817         if (nz > 1) {
02818                 LOGERR("2D images only.");
02819                 throw ImageDimensionException("2D images only");
02820         }
02821         int isinten=get_attr_default("is_intensity",0);
02822 
02823         if (isinten&&!inten) { throw InvalidParameterException("Must set inten for calc_radial_dist with intensity image"); }
02824 
02825 
02826         vector<float>ret(n*nwedge);
02827         vector<float>norm(n*nwedge);
02828 
02829         int x,y,i;
02830         int step=is_complex()?2:1;
02831         float astep=static_cast<float>(M_PI*2.0/nwedge);
02832         if (is_complex()) astep/=2;                                                     // Since we only have the right 1/2 of Fourier space
02833         float* data = get_data();
02834         for (i=0; i<n*nwedge; i++) ret[i]=norm[i]=0.0;
02835 
02836         // We do 2D separately to avoid the hypot3 call
02837         for (y=i=0; y<ny; y++) {
02838                 for (x=0; x<nx; x+=step,i+=step) {
02839                         float r,v,a;
02840                         int bin;
02841                         if (is_complex()) {
02842 #ifdef  _WIN32
02843                                 r=static_cast<float>(_hypot(x/2.0,y<ny/2?y:ny-y));              // origin at 0,0; periodic
02844 #else
02845                                 r=static_cast<float>(hypot(x/2.0,y<ny/2?y:ny-y));               // origin at 0,0; periodic
02846 #endif
02847                                 a=atan2(float(y<ny/2?y:y-ny),x/2.0f);
02848                                 if (!inten) {
02849 #ifdef  _WIN32
02850                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02851 #else
02852                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02853 #endif  //_WIN32
02854                                         else v=data[i];                                                 // amp/phase, just get amp
02855                                 } else {
02856                                         if (isinten) v=data[i];
02857                                         else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02858                                         else v=data[i]*data[i];
02859                                 }
02860                                 bin=n*int(floor((a+M_PI/2.0f+offset)/astep));
02861                         }
02862                         else {
02863 #ifdef  _WIN32
02864                                 r=static_cast<float>(_hypot(x-nx/2,y-ny/2));
02865 #else
02866                                 r=static_cast<float>(hypot(x-nx/2,y-ny/2));
02867 #endif  //_WIN32
02868                                 a=atan2(float(y-ny/2),float(x-nx/2));
02869                                 if (inten) v=data[i]*data[i];
02870                                 else v=data[i];
02871                                 bin=n*int(floor((a+M_PI+offset)/astep));
02872                         }
02873                         if (bin>=nwedge*n) bin-=nwedge*n;
02874                         if (bin<0) bin+=nwedge*n;
02875                         r=(r-x0)/dx;
02876                         int f=int(r);   // safe truncation, so floor isn't needed
02877                         r-=float(f);    // r is now the fractional spacing between bins
02878 //                      printf("%d %d %d %d %1.3f %1.3f\n",x,y,bin,f,r,a);
02879                         if (f>=0 && f<n) {
02880                                 ret[f+bin]+=v*(1.0f-r);
02881                                 norm[f+bin]+=(1.0f-r);
02882                                 if (f<n-1) {
02883                                         ret[f+1+bin]+=v*r;
02884                                         norm[f+1+bin]+=r;
02885                                 }
02886                         }
02887                 }
02888         }
02889 
02890         for (i=0; i<n*nwedge; i++) ret[i]/=norm[i]?norm[i]:1.0f;        // Normalize
02891         EXITFUNC;
02892 
02893         return ret;
02894 }

vector< float > EMData::calc_radial_dist int  n,
float  x0,
float  dx,
bool  inten
 

calculates radial distribution.

works for real and imaginary images. Returns mean radial amplitude, or intensity if inten is set. Note that the complex origin is at (0,0), with periodic boundaries. Note that the inten option is NOT equivalent to returning amplitude and squaring the result.

Parameters:
n number of points.
x0 starting point x coordinate.
dx step of x.
inten returns intensity (amp^2) rather than amplitude if set
Returns:
The radial distribution in an array.

Definition at line 2705 of file emdata.cpp.

References data, EMAN::EMObject::f, get_attr_default(), get_data(), InvalidParameterException, is_complex(), is_ri(), norm(), nx, ny, nz, v, x, and y.

Referenced by EMAN::FRCCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::MatchSFProcessor::create_radial_func(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), main(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), and EMAN::FourierAnlProcessor::process_inplace().

02706 {
02707         ENTERFUNC;
02708 
02709         vector<float>ret(n);
02710         vector<float>norm(n);
02711 
02712         int x,y,z,i;
02713         int step=is_complex()?2:1;
02714         int isinten=get_attr_default("is_intensity",0);
02715 
02716         if (isinten&&!inten) { throw InvalidParameterException("Must set inten for calc_radial_dist with intensity image"); }
02717 
02718         for (i=0; i<n; i++) ret[i]=norm[i]=0.0;
02719         float * data = get_data();
02720 
02721         // We do 2D separately to avoid the hypot3 call
02722         if (nz==1) {
02723                 for (y=i=0; y<ny; y++) {
02724                         for (x=0; x<nx; x+=step,i+=step) {
02725                                 float r,v;
02726                                 if (step==2) {          //complex
02727                                         if (x==0 && y>ny/2) continue;
02728                                         r=(float)(Util::hypot_fast(x/2,y<ny/2?y:ny-y));         // origin at 0,0; periodic
02729                                         if (!inten) {
02730 #ifdef  _WIN32
02731                                                 if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02732 #else
02733                                                 if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02734 #endif
02735                                                 else v=data[i];                                                 // amp/phase, just get amp
02736                                         } else {
02737                                                 if (isinten) v=data[i];
02738                                                 else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02739                                                 else v=data[i]*data[i];
02740                                         }
02741                                 }
02742                                 else {
02743                                         r=(float)(Util::hypot_fast(x-nx/2,y-ny/2));
02744                                         if (inten) v=data[i]*data[i];
02745                                         else v=data[i];
02746                                 }
02747                                 r=(r-x0)/dx;
02748                                 int f=int(r);   // safe truncation, so floor isn't needed
02749                                 r-=float(f);    // r is now the fractional spacing between bins
02750 //                              printf("%d\t%d\t%d\t%1.3f\t%d\t%1.3f\t%1.4g\n",x,y,f,r,step,Util::hypot_fast(x/2,y<ny/2?y:ny-y),v);
02751                                 if (f>=0 && f<n) {
02752                                         ret[f]+=v*(1.0f-r);
02753                                         norm[f]+=(1.0f-r);
02754                                         if (f<n-1) {
02755                                                 ret[f+1]+=v*r;
02756                                                 norm[f+1]+=r;
02757                                         }
02758                                 }
02759                         }
02760                 }
02761         }
02762         else {
02763                 size_t i;       //3D file may have >2G size
02764                 for (z=i=0; z<nz; ++z) {
02765                         for (y=0; y<ny; ++y) {
02766                                 for (x=0; x<nx; x+=step,i+=step) {
02767                                         float r,v;
02768                                         if (step==2) {  //complex
02769                                                 if (x==0 && z<nz/2) continue;
02770                                                 if (x==0 && z==nz/2 && y<ny/2) continue;
02771                                                 r=Util::hypot3(x/2,y<ny/2?y:ny-y,z<nz/2?z:nz-z);        // origin at 0,0; periodic
02772                                                 if (!inten) {
02773 #ifdef  _WIN32
02774                                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02775 #else
02776                                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02777 #endif  //_WIN32
02778                                                         else v=data[i];                                                 // amp/phase, just get amp
02779                                                 } else {
02780                                                         if (isinten) v=data[i];
02781                                                         else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02782                                                         else v=data[i]*data[i];
02783                                                 }
02784                                         }
02785                                         else {
02786                                                 r=Util::hypot3(x-nx/2,y-ny/2,z-nz/2);
02787                                                 if (inten) v=data[i]*data[i];
02788                                                 else v=data[i];
02789                                         }
02790                                         r=(r-x0)/dx;
02791                                         int f=int(r);   // safe truncation, so floor isn't needed
02792                                         r-=float(f);    // r is now the fractional spacing between bins
02793                                         if (f>=0 && f<n) {
02794                                                 ret[f]+=v*(1.0f-r);
02795                                                 norm[f]+=(1.0f-r);
02796                                                 if (f<n-1) {
02797                                                         ret[f+1]+=v*r;
02798                                                         norm[f+1]+=r;
02799                                                 }
02800                                         }
02801                                 }
02802                         }
02803                 }
02804         }
02805 
02806         for (i=0; i<n; i++) ret[i]/=norm[i]?norm[i]:1.0f;       // Normalize
02807 
02808         EXITFUNC;
02809 
02810         return ret;
02811 }

float EMData::calc_sigma_diff  ) 
 

Calculates sigma above and below the mean and returns the difference between them.

Returns:
The difference between sigma above and below the mean.

Definition at line 291 of file emdata_metadata.cpp.

References get_attr(), get_data(), nx, ny, sqrt(), and square.

00292 {
00293         ENTERFUNC;
00294 
00295         float *d = get_data();
00296         float mean = get_attr("mean");
00297         float sigma = get_attr("sigma");
00298 
00299         double sum_up = 0;
00300         double sum_down = 0;
00301         int nup = 0;
00302         int ndown = 0;
00303 
00304         size_t size = (size_t)nx * ny * nz;
00305 
00306         for (size_t i = 0; i < size; ++i) {
00307                 if (d[i] > mean) {
00308                         sum_up += Util::square(d[i] - mean);
00309                         nup++;
00310                 }
00311                 else {
00312                         sum_down += Util::square(mean - d[i]);
00313                         ndown++;
00314                 }
00315         }
00316 
00317         float sigup = std::sqrt((float)sum_up / nup);
00318         float sigdown = std::sqrt((float)sum_down / ndown);
00319         float sig_diff = fabs(sigup - sigdown) / sigma;
00320 
00321 
00322         EXITFUNC;
00323         return sig_diff;
00324 
00325 }

void EMData::cconj  ) 
 

Replace the image its complex conjugate.

Exceptions:
ImageFormatException Image must be complex (and RI)

Definition at line 2896 of file emdata.cpp.

References cmplx(), ImageFormatException, is_complex(), is_fftodd(), is_ri(), and nx.

02896                    {
02897         ENTERFUNC;
02898         if (!is_complex() || !is_ri())
02899                 throw ImageFormatException("EMData::conj requires a complex, ri image");
02900         int nxreal = nx -2 + int(is_fftodd());
02901         int nxhalf = nxreal/2;
02902         for (int iz = 0; iz < nz; iz++)
02903                 for (int iy = 0; iy < ny; iy++)
02904                         for (int ix = 0; ix <= nxhalf; ix++)
02905                                 cmplx(ix,iy,iz) = conj(cmplx(ix,iy,iz));
02906         EXITFUNC;
02907 }

void EMData::center_origin  ) 
 

Definition at line 6718 of file emdata_sparx.cpp.

References ImageFormatException, and LOGERR.

06719                           {
06720                 LOGERR("Real image expected. Input image is complex.");
06721                 throw ImageFormatException("Real image expected. Input image is complex.");
06722         }
06723         for (int iz = 0; iz < nz; iz++) {
06724                 for (int iy = 0; iy < ny; iy++) {
06725                         for (int ix = 0; ix < nx; ix++) {
06726                                 // next line multiplies by +/- 1
06727                                 (*this)(ix,iy,iz) *= -2*((ix+iy+iz)%2) + 1;
06728                         }
06729                 }
06730         }
06731         update();
06732         EXITFUNC;
06733 }
06734 
06735 void EMData::center_origin_yz()

void EMData::center_origin_fft  ) 
 

Multiply a Fourier image by (-1)**(ix+iy+iz) to center it.

Definition at line 6755 of file emdata_sparx.cpp.

References ImageFormatException, and LOGERR.

Referenced by EMAN::padfft_slice(), EMAN::FourierGriddingProjector::project3d(), and EMAN::Util::twoD_to_3D_ali().

06756                            {
06757                 LOGERR("complex image expected. Input image is real image.");
06758                 throw ImageFormatException("complex image expected. Input image is real image.");
06759         }
06760 
06761         if (!is_ri()) {
06762                 LOGWARN("Only RI should be used. ");
06763         }
06764         vector<int> saved_offsets = get_array_offsets();
06765         // iz in [1,nz], iy in [1,ny], ix in [0,nx/2], but nx comes in as extended and is the same for odd
06766         //                                                 and even, so we can ignore the difference...
06767         //                         in short, as nx is extended, it should be  ix in [0,(nx-2)/2],  corrected PAP 05/20
06768         set_array_offsets(0,1,1);
06769         int nxc = nx/2;
06770 
06771         if (is_fftodd()) {
06772                 for (int iz = 1; iz <= nz; iz++) {
06773                         for (int iy = 1; iy <= ny; iy++) {
06774                                 for (int ix = 0; ix < nxc; ix++) {
06775                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06776                                         float temp = float(iz-1+iy-1+ix)/float(ny)*M_PI;
06777                                         complex<float> temp2 = complex<float>(cos(temp), -sin(temp));
06778                                         cmplx(ix,iy,iz) *= temp2;
06779                                 }
06780                         }
06781                 }
06782         } else {
06783                 for (int iz = 1; iz <= nz; iz++) {
06784                         for (int iy = 1; iy <= ny; iy++) {
06785                                 for (int ix = 0; ix < nxc; ix++) {
06786                                         // next line multiplies by +/- 1
06787                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06788                                 }
06789                         }
06790                 }
06791         }
06792         set_array_offsets(saved_offsets);
06793         update();
06794         EXITFUNC;
06795 }
06796 
06797 

void EMData::center_origin_yz  ) 
 

Definition at line 6737 of file emdata_sparx.cpp.

References ImageFormatException, and LOGERR.

06738                           {
06739                 LOGERR("Real image expected. Input image is complex.");
06740                 throw ImageFormatException("Real image expected. Input image is complex.");
06741         }
06742         for (int iz = 0; iz < nz; iz++) {
06743                 for (int iy = (iz+1)%2; iy < ny; iy+=2) {
06744                         for (int ix = 0; ix < nx; ix++) {
06745                                 (*this)(ix,iy,iz) *= -1;
06746                         }
06747                 }
06748         }
06749         update();
06750         EXITFUNC;
06751 }
06752 
06753 void EMData::center_origin_fft()

void EMAN::EMData::clearupdate  )  [inline]
 

turn off updates.

Useful to avoid wasteful recacling stats

Definition at line 422 of file emdata.h.

00439                           : this routine will modify the 'this' and 'with' to contain

void EMData::clip_inplace const Region area,
const float &  fill_value = 0
 

Clip the image inplace - clipping region must be smaller than the current region internally memory is reallocated.

Exceptions:
ImageDimensionException if any of the dimensions of the argument region are negative
Parameters:
area The clip area, can be 2D/3D.
fill_value the value that new region

Definition at line 334 of file emdata.cpp.

References Assert, attr_dict, get_data(), EMAN::Dict::has_key(), ImageDimensionException, EMAN::EMData::ClipInplaceVariables::new_x_left, EMAN::EMData::ClipInplaceVariables::new_x_right, EMAN::EMData::ClipInplaceVariables::new_y_back, EMAN::EMData::ClipInplaceVariables::new_y_front, EMAN::EMData::ClipInplaceVariables::new_z_bottom, EMAN::EMData::ClipInplaceVariables::new_z_top, nx, ny, EMAN::Region::origin, EMAN::EMData::ClipInplaceVariables::prv_x_left, EMAN::EMData::ClipInplaceVariables::prv_y_back, EMAN::EMData::ClipInplaceVariables::prv_y_front, EMAN::EMData::ClipInplaceVariables::prv_z_bottom, EMAN::EMData::ClipInplaceVariables::prv_z_top, rdata, set_size(), set_xyz_origin(), EMAN::Region::size, update(), EMAN::EMData::ClipInplaceVariables::x_iter, EMAN::EMData::ClipInplaceVariables::y_iter, and EMAN::EMData::ClipInplaceVariables::z_iter.

Referenced by calc_ccf(), calc_fast_sigma_image(), calc_flcf(), EMAN::FFTResampleProcessor::fft_resample(), EMAN::ScaleTransformProcessor::process(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::IntTranslateProcessor::process_inplace(), and EMAN::FlattenBackgroundProcessor::process_inplace().

00335 {
00336         // Added by d.woolford
00337         ENTERFUNC;
00338 
00339 //      printf("cip %d %d %d %d %d %d %f %d %d %d\n",area.origin[0],area.origin[1],area.origin[2],area.size[0],area.size[1],area.size[2],fill_value,nx,ny,nz);
00340         // Store the current dimension values
00341         int prev_nx = nx, prev_ny = ny, prev_nz = nz;
00342         size_t prev_size = (size_t)nx*ny*nz;
00343 
00344         // Get the zsize, ysize and xsize of the final area, these are the new dimension sizes of the pixel data
00345         int new_nz = ( area.size[2]==0 ? 1 : (int)area.size[2]);
00346         int new_ny = ( area.size[1]==0 ? 1 : (int)area.size[1]);
00347         int new_nx = (int)area.size[0];
00348 
00349         if ( new_nz < 0 || new_ny < 0 || new_nx < 0 )
00350         {
00351                 // Negative image dimensions were never tested nor considered when creating this implementation
00352                 throw ImageDimensionException("New image dimensions are negative - this is not supported in the clip_inplace operation");
00353         }
00354 
00355         size_t new_size = (size_t)new_nz*new_ny*new_nx;
00356 
00357         // Get the translation values, they are used to construct the ClipInplaceVariables object
00358         int x0 = (int) area.origin[0];
00359         int y0 = (int) area.origin[1];
00360         int z0 = (int) area.origin[2];
00361 
00362         // Get a object that calculates all the interesting variables associated with the clip inplace operation
00363         ClipInplaceVariables civ(prev_nx, prev_ny, prev_nz, new_nx, new_ny, new_nz, x0, y0, z0);
00364 
00365         get_data(); // Do this here to make sure rdata is up to date, applicable if GPU stuff is occuring
00366         // Double check to see if any memory shifting even has to occur
00367         if ( x0 > prev_nx || y0 > prev_ny || z0 > prev_nz || civ.x_iter == 0 || civ.y_iter == 0 || civ.z_iter == 0)
00368         {
00369                 // In this case the volume has been shifted beyond the location of the pixel rdata and
00370                 // the client should expect to see a volume with nothing in it.
00371 
00372                 // Set size calls realloc,
00373                 set_size(new_nx, new_ny, new_nz);
00374 
00375                 // Set pixel memory to zero - the client should expect to see nothing
00376                 EMUtil::em_memset(rdata, 0, (size_t)new_nx*new_ny*new_nz);
00377 
00378                 return;
00379         }
00380 
00381         // Resize the volume before memory shifting occurs if the new volume is larger than the previous volume
00382         // All of the pixel rdata is guaranteed to be at the start of the new volume because realloc (called in set size)
00383         // guarantees this.
00384         if ( new_size > prev_size )
00385                 set_size(new_nx, new_ny, new_nz);
00386 
00387         // Store the clipped row size.
00388         size_t clipped_row_size = (civ.x_iter) * sizeof(float);
00389 
00390         // Get the new sector sizes to save multiplication later.
00391         size_t new_sec_size = new_nx * new_ny;
00392         size_t prev_sec_size = prev_nx * prev_ny;
00393 
00394         // Determine the memory locations of the source and destination pixels - at the point nearest
00395         // to the beginning of the volume (rdata)
00396         size_t src_it_begin = civ.prv_z_bottom*prev_sec_size + civ.prv_y_front*prev_nx + civ.prv_x_left;
00397         size_t dst_it_begin = civ.new_z_bottom*new_sec_size + civ.new_y_front*new_nx + civ.new_x_left;
00398 
00399         // This loop is in the forward direction (starting at points nearest to the beginning of the volume)
00400         // it copies memory only when the destination pointer is less the source pointer - therefore
00401         // ensuring that no memory "copied to" is yet to be "copied from"
00402         for (int i = 0; i < civ.z_iter; ++i) {
00403                 for (int j = 0; j < civ.y_iter; ++j) {
00404 
00405                         // Determine the memory increments as dependent on i and j
00406                         // This could be optimized so that not so many multiplications are occurring...
00407                         size_t dst_inc = dst_it_begin + j*new_nx + i*new_sec_size;
00408                         size_t src_inc = src_it_begin + j*prev_nx + i*prev_sec_size;
00409                         float* local_dst = rdata + dst_inc;
00410                         float* local_src = rdata + src_inc;
00411 
00412                         if ( dst_inc >= src_inc )
00413                         {
00414                                 // this is fine, it will happen now and then and it will be necessary to continue.
00415                                 // the tempatation is to break, but you can't do that (because the point where memory intersects
00416                                 // could be in this slice - and yes, this aspect could be optimized).
00417                                 continue;
00418                         }
00419 
00420                         // Asserts are compiled only in debug mode
00421                         // This situation not encountered in testing thus far
00422                         Assert( dst_inc < new_size && src_inc < prev_size && dst_inc >= 0 && src_inc >= 0 );
00423 
00424                         // Finally copy the memory
00425                         EMUtil::em_memcpy(local_dst, local_src, clipped_row_size);
00426                 }
00427         }
00428 
00429         // Determine the memory locations of the source and destination pixels - at the point nearest
00430         // to the end of the volume (rdata+new_size)
00431         size_t src_it_end = prev_size - civ.prv_z_top*prev_sec_size - civ.prv_y_back*prev_nx - prev_nx + civ.prv_x_left;
00432         size_t dst_it_end = new_size - civ.new_z_top*new_sec_size - civ.new_y_back*new_nx - new_nx + civ.new_x_left;
00433 
00434         // This loop is in the reverse direction (starting at points nearest to the end of the volume).
00435         // It copies memory only when the destination pointer is greater than  the source pointer therefore
00436         // ensuring that no memory "copied to" is yet to be "copied from"
00437         for (int i = 0; i < civ.z_iter; ++i) {
00438                 for (int j = 0; j < civ.y_iter; ++j) {
00439 
00440                         // Determine the memory increments as dependent on i and j
00441                         size_t dst_inc = dst_it_end - j*new_nx - i*new_sec_size;
00442                         size_t src_inc = src_it_end - j*prev_nx - i*prev_sec_size;
00443                         float* local_dst = rdata + dst_inc;
00444                         float* local_src = rdata + src_inc;
00445 
00446                         if (dst_inc <= (src_inc + civ.x_iter ))
00447                         {
00448                                 // Overlap
00449                                 if ( dst_inc > src_inc )
00450                                 {
00451                                         // Because the memcpy operation is the forward direction, and this "reverse
00452                                         // direction" loop is proceeding in a backwards direction, it is possible
00453                                         // that memory copied to is yet to be copied from (because memcpy goes forward).
00454                                         // In this scenario pixel memory "copied to" is yet to be "copied from"
00455                                         // i.e. there is overlap
00456 
00457                                         // memmove handles overlapping cases.
00458                                         // memmove could use a temporary buffer, or could go just go backwards
00459                                         // the specification doesn't say how the function behaves...
00460                                         // If memmove creates a temporary buffer is clip_inplace no longer inplace?
00461                                         memmove(local_dst, local_src, clipped_row_size);
00462                                 }
00463                                 continue;
00464                         }
00465 
00466                         // This situation not encountered in testing thus far
00467                         Assert( dst_inc < new_size && src_inc < prev_size && dst_inc >= 0 && src_inc >= 0 );
00468 
00469                         // Perform the memory copy
00470                         EMUtil::em_memcpy(local_dst, local_src, clipped_row_size);
00471                 }
00472         }
00473 
00474         // Resize the volume after memory shifting occurs if the new volume is smaller than the previous volume
00475         // set_size calls realloc, guaranteeing that the pixel rdata is in the right location.
00476         if ( new_size < prev_size )
00477                 set_size(new_nx, new_ny, new_nz);
00478 
00479         // Now set all the edges to zero
00480 
00481         // Set the extra bottom z slices to the fill_value
00482         if (  z0 < 0 )
00483         {
00484                 //EMUtil::em_memset(rdata, 0, (-z0)*new_sec_size*sizeof(float));
00485                 size_t inc = (-z0)*new_sec_size;
00486                 std::fill(rdata,rdata+inc,fill_value);
00487         }
00488 
00489         // Set the extra top z slices to the fill_value
00490         if (  civ.new_z_top > 0 )
00491         {
00492                 float* begin_pointer = rdata + (new_nz-civ.new_z_top)*new_sec_size;
00493                 //EMUtil::em_memset(begin_pointer, 0, (civ.new_z_top)*new_sec_size*sizeof(float));
00494                 float* end_pointer = begin_pointer+(civ.new_z_top)*new_sec_size;
00495                 std::fill(begin_pointer,end_pointer,fill_value);
00496         }
00497 
00498         // Next deal with x and y edges by iterating through each slice
00499         for ( int i = civ.new_z_bottom; i < civ.new_z_bottom + civ.z_iter; ++i )
00500         {
00501                 // Set the extra front y components to the fill_value
00502                 if ( y0 < 0 )
00503                 {
00504                         float* begin_pointer = rdata + i*new_sec_size;
00505                         //EMUtil::em_memset(begin_pointer, 0, (-y0)*new_nx*sizeof(float));
00506                         float* end_pointer = begin_pointer+(-y0)*new_nx;
00507                         std::fill(begin_pointer,end_pointer,fill_value);
00508                 }
00509 
00510                 // Set the extra back y components to the fill_value
00511                 if ( civ.new_y_back > 0 )
00512                 {
00513                         float* begin_pointer = rdata + i*new_sec_size + (new_ny-civ.new_y_back)*new_nx;
00514                         //EMUtil::em_memset(begin_pointer, 0, (civ.new_y_back)*new_nx*sizeof(float));
00515                         float* end_pointer = begin_pointer+(civ.new_y_back)*new_nx;
00516                         std::fill(begin_pointer,end_pointer,fill_value);
00517                 }
00518 
00519                 // Iterate through the y to set each correct x component to the fill_value
00520                 for (int j = civ.new_y_front; j <civ.new_y_front + civ.y_iter; ++j)
00521                 {
00522                         // Set the extra left x components to the fill_value
00523                         if ( x0 < 0 )
00524                         {
00525                                 float* begin_pointer = rdata + i*new_sec_size + j*new_nx;
00526                                 //EMUtil::em_memset(begin_pointer, 0, (-x0)*sizeof(float));
00527                                 float* end_pointer = begin_pointer+(-x0);
00528                                 std::fill(begin_pointer,end_pointer,fill_value);
00529                         }
00530 
00531                         // Set the extra right x components to the fill_value
00532                         if ( civ.new_x_right > 0 )
00533                         {
00534                                 float* begin_pointer = rdata + i*new_sec_size + j*new_nx + (new_nx - civ.new_x_right);
00535                                 //EMUtil::em_memset(begin_pointer, 0, (civ.new_x_right)*sizeof(float));
00536                                 float* end_pointer = begin_pointer+(civ.new_x_right);
00537                                 std::fill(begin_pointer,end_pointer,fill_value);
00538                         }
00539 
00540                 }
00541         }
00542 
00543 // These couts may be useful
00544 //      cout << "start starts " << civ.prv_x_left << " " << civ.prv_y_front << " " << civ.prv_z_bottom << endl;
00545 //      cout << "start ends " << civ.prv_x_right << " " << civ.prv_y_back << " " << civ.prv_z_top << endl;
00546 //      cout << "dst starts " << civ.new_x_left << " " << civ.new_y_front << " " << civ.new_z_bottom << endl;
00547 //      cout << "dst ends " << civ.new_x_right << " " << civ.new_y_back << " " << civ.new_z_top << endl;
00548 //      cout << "total iter z - " << civ.z_iter << " y - " << civ.y_iter << " x - " << civ.x_iter << endl;
00549 //      cout << "=====" << endl;
00550 //      cout << "dst_end is " << dst_it_end << " src end is " << src_it_end << endl;
00551 //      cout << "dst_begin is " << dst_it_begin << " src begin is " << src_it_begin << endl;
00552 
00553         // Update appropriate attributes (Copied and pasted from get_clip)
00554         if( attr_dict.has_key("origin_x") && attr_dict.has_key("origin_y") &&
00555         attr_dict.has_key("origin_z") )
00556         {
00557                 float xorigin = attr_dict["origin_x"];
00558                 float yorigin = attr_dict["origin_y"];
00559                 float zorigin = attr_dict["origin_z"];
00560 
00561                 float apix_x = attr_dict["apix_x"];
00562                 float apix_y = attr_dict["apix_y"];
00563                 float apix_z = attr_dict["apix_z"];
00564 
00565                 set_xyz_origin(xorigin + apix_x * area.origin[0],
00566                         yorigin + apix_y * area.origin[1],
00567                         zorigin + apix_z * area.origin[2]);
00568         }
00569 
00570         // Set the update flag because the size of the image has changed and stats should probably be recalculated if requested.
00571         update();
00572 
00573         EXITFUNC;
00574 }

float EMData::cm_euc EMData sinoj,
int  n1,
int  n2
 

euclidean distance between two line

Parameters:
sinoj 
n1 
n2 

Definition at line 525 of file emdata_sparx.cpp.

References dist(), get_data(), and get_xsize().

00526 {
00527     int lnlen = get_xsize();
00528     float* line_1 = get_data() + n1 * lnlen;
00529     float* line_2 = sinoj->get_data() + n2 * lnlen;
00530     return dist(lnlen, line_1, line_2);
00531 }

float EMData::cmp const string &  cmpname,
EMData with,
const Dict params = Dict()
 

Compare this image with another image.

Parameters:
cmpname Comparison algorithm name.
with The image you want to compare to.
params Comparison parameters in a keyed dictionary.
Exceptions:
NotExistingObjectError If the comparison algorithm doesn't exist.
Returns:
comparison score. The bigger, the better.

Definition at line 97 of file emdata_modular.cpp.

References EMAN::Cmp::cmp().

Referenced by EMAN::Refine3DAlignerQuaternion::align(), EMAN::SymAlignProcessorQuat::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::ScaleAlignerABS::align_using_base(), EMAN::Util::ccc_images(), EMAN::Util::ccc_images_G(), frm_2d_Align(), main(), EMAN::Util::twoD_fine_ali(), EMAN::Util::twoD_fine_ali_G(), and EMAN::Util::twoD_to_3D_ali().

00098 {
00099         ENTERFUNC;
00100         float result = 0;
00101         Cmp *c = Factory < Cmp >::get(cmpname, params);
00102         if (c) {
00103                 result = c->cmp(this, with);
00104                 if( c )
00105                 {
00106                         delete c;
00107                         c = 0;
00108                 }
00109         }
00110 
00111         EXITFUNC;
00112         return result;
00113 }

std::complex<float>& EMAN::EMData::cmplx const int  ix  )  [inline]
 

Definition at line 2406 of file emdata.h.

std::complex<float>& EMAN::EMData::cmplx const int  ix,
const int  iy
[inline]
 

Definition at line 2395 of file emdata.h.

std::complex<float>& EMAN::EMData::cmplx const int  ix,
const int  iy,
const int  iz
[inline]
 

Return reference to complex elements.

Definition at line 2384 of file emdata.h.

Referenced by EMAN::newfile_store::add_image(), cconj(), EMAN::Processor::EMFourierFilterFunc(), EMAN::Util::extractpoint2(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::fourierproduct(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), onelinenn(), onelinenn_ctf(), onelinenn_ctf_applied(), onelinenn_mult(), EMAN::periodogram(), symplane0(), symplane1(), and symplane2().

vector< float > EMData::cog  ) 
 

Calculates the Center of Gravity and the Radius of Gyration of the image.

Returns:
the mass and the radius as vectors.

Definition at line 722 of file emdata_sparx.cpp.

References get_ndim(), nx, ny, nz, rdata, sqrt(), and square.

00722                           {
00723 
00724         vector<float> cntog;
00725         int ndim = get_ndim();
00726         int i=1,j=1,k=1;
00727         float val,sum1=0.f,MX=0.f,RG=0.f,MY=0.f,MZ=0.f,r=0.f;
00728 
00729         if (ndim == 1) {
00730                 for ( i = 1;i <= nx; i++) {
00731                         val   = rdata(i,j,k);
00732                         sum1 += val;
00733                         MX   += ((i-1)*val);
00734                 }
00735                 MX=(MX/sum1);
00736                 for ( i = 1;i <= nx; i++) {
00737                         val   = rdata(i,j,k);
00738                         sum1 += val;
00739                         RG   += val*(square(MX - (i-1)));
00740                 }
00741                 RG=std::sqrt(RG/sum1);
00742                 MX=MX-(nx/2);
00743                 cntog.push_back(MX);
00744                 cntog.push_back(RG);
00745 #ifdef _WIN32
00746                 cntog.push_back((float)Util::round(MX));
00747 #else
00748                 cntog.push_back(round(MX));
00749 #endif  //_WIN32
00750         } else if (ndim == 2) {
00751                 for (j=1;j<=ny;j++) {
00752                         for (i=1;i<=nx;i++) {
00753                                 val = rdata(i,j,k);
00754                                 sum1 += val;
00755                                 MX   += ((i-1)*val);
00756                                 MY   += ((j-1)*val);
00757                         }
00758                 }
00759                 MX=(MX/sum1);
00760                 MY=(MY/sum1);
00761                 sum1=0.f;
00762                 RG=0.f;
00763                 for (j=1;j<=ny;j++) {
00764                         r = (square(MY-(j-1)));
00765                         for (i=1;i<=nx;i++) {
00766                                 val = rdata(i,j,k);
00767                                 sum1 += val;
00768                                 RG   += val*(square(MX - (i-1)) + r);
00769                         }
00770                 }
00771                 RG = std::sqrt(RG/sum1);
00772                 MX = MX - nx/2;
00773                 MY = MY - ny/2;
00774                 cntog.push_back(MX);
00775                 cntog.push_back(MY);
00776                 cntog.push_back(RG);
00777 #ifdef _WIN32
00778                 cntog.push_back((float)Util::round(MX));cntog.push_back((float)Util::round(MY));
00779 #else
00780                 cntog.push_back(round(MX));cntog.push_back(round(MY));
00781 #endif  //_WIN32
00782         } else {
00783                 for (k = 1;k <= nz;k++) {
00784                         for (j=1;j<=ny;j++) {
00785                                 for (i=1;i<=nx;i++) {
00786                                         val = rdata(i,j,k);
00787                                         sum1 += val;
00788                                         MX += ((i-1)*val);
00789                                         MY += ((j-1)*val);
00790                                         MZ += ((k-1)*val);
00791                                 }
00792                         }
00793                 }
00794                 MX = MX/sum1;
00795                 MY = MY/sum1;
00796                 MZ = MZ/sum1;
00797                 sum1=0.f;
00798                 RG=0.f;
00799                 for (k = 1;k <= nz;k++) {
00800                         for (j=1;j<=ny;j++) {
00801                                 float r = (square(MY-(j-1)) + square(MZ - (k-1)));
00802                                 for (i=1;i<=nx;i++) {
00803                                         val = rdata(i,j,k);
00804                                         sum1 += val;
00805                                         RG   += val*(square(MX - (i-1)) + r);
00806                                 }
00807                         }
00808                 }
00809                 RG = std::sqrt(RG/sum1);
00810                 MX = MX - nx/2;
00811                 MY = MY - ny/2;
00812                 MZ = MZ - nz/2;
00813                 cntog.push_back(MX);
00814                 cntog.push_back(MY);
00815                 cntog.push_back(MZ);
00816                 cntog.push_back(RG);
00817 #ifdef _WIN32
00818                 cntog.push_back((float)Util::round(MX));cntog.push_back((float)Util::round(MY));cntog.push_back((float)Util::round(MZ));
00819 #else
00820                 cntog.push_back(round(MX));cntog.push_back(round(MY));cntog.push_back(round(MZ));
00821 #endif  //_WIN32
00822         }
00823         return cntog;
00824 }

EMData * EMData::compute_missingwedge float  wedgeangle,
float  start = 0.05,
float  stop = 0.5
 

Find the mean and variance of voxels in the missing wedge.

Parameters:
wedgeangle the angle of the missing wedge
influnce the region of influnce in fourier space. This is a fudge factor between 0 and 0.5
wedgedirection the direction of the wedge, so far only a wedge along Z is supported (set wedgedirection to 0)

Definition at line 4205 of file emdata.cpp.

References EMData(), get_value_at_wrap(), nx, ny, nz, set_attr(), set_size(), set_value_at(), sqrt(), and v.

04206 {               
04207         EMData* test = new EMData();
04208         test->set_size(nx,ny,nz);
04209         
04210         float ratio = tan((90.0f-wedgeangle)*M_PI/180.0f);
04211         
04212         int offset_i = 2*int(start*nz/2);
04213         int offset_f = int(stop*nz/2);
04214         
04215         int step = 0;
04216         float sum = 0.0;
04217         double square_sum = 0.0;
04218         for (int j = 0; j < offset_f; j++){
04219                 for (int k = offset_i; k < offset_f; k++) {
04220                         for (int i = 0; i < nx; i+=2) {
04221                                 if (i < int(k*ratio)) {
04222                                         test->set_value_at(i, j, k, 1.0);
04223                                         float v = std::sqrt(pow(get_value_at_wrap(i, j, k),2) + pow(get_value_at_wrap(i+1, j, k),2));
04224                                         sum += v;
04225                                         square_sum += v * (double)(v);
04226                                         step++;
04227                                 }
04228                         }
04229                 }
04230         }
04231         
04232         float mean = sum / step;
04233         
04234         #ifdef _WIN32
04235         float sigma = (float)std::sqrt( _cpp_max(0.0,(square_sum - sum*mean)/(step-1)));
04236         #else
04237         float sigma = (float)std::sqrt(std::max<double>(0.0,(square_sum - sum*mean)/(step-1)));
04238         #endif  //_WIN32
04239         
04240         cout << "Mean sqr wedge amp " << mean << " Sigma Squ wedge Amp " << sigma << endl;
04241         set_attr("spt_wedge_mean", mean);
04242         set_attr("spt_wedge_sigma", sigma);
04243         
04244         return test;
04245 }

EMData * EMData::conjg  ) 
 

Definition at line 6172 of file emdata_sparx.cpp.

References copy_head(), get_data(), in, nx, and ny.

06172                                {
06173                 EMData* buf_new = this->copy_head();
06174                 float *in  = this->get_data();
06175                 float *out = buf_new->get_data();
06176                 for(size_t i=0; i<(size_t)nx*ny*nz; i+=2) {out[i] = in[i]; out[i+1] = -in[i+1];}
06177                 return buf_new;
06178         } else throw ImageFormatException("image has to be complex");
06179 }
06180 
06181 EMData* EMData::delete_disconnected_regions(int ix, int iy, int iz) {

EMData * EMData::convolute EMData with  ) 
 

Convolutes 2 data sets.

The 2 images must be of the same size.

Parameters:
with One data set. 'this' image is the other data set.
Exceptions:
NullPointerException If FFT resturns NULL image.
Returns:
The result image.

Definition at line 3398 of file emdata.cpp.

References ap2ri(), copy(), do_fft(), do_ift(), get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, LOGERR, NullPointerException, and update().

Referenced by calc_fast_sigma_image(), and EMAN::FlattenBackgroundProcessor::process_inplace().

03399 {
03400         ENTERFUNC;
03401 
03402         EMData *f1 = do_fft();
03403         if (!f1) {
03404                 LOGERR("FFT returns NULL image");
03405                 throw NullPointerException("FFT returns NULL image");
03406         }
03407 
03408         f1->ap2ri();
03409 
03410         EMData *cf = 0;
03411         if (with) {
03412                 cf = with->do_fft();
03413                 if (!cf) {
03414                         LOGERR("FFT returns NULL image");
03415                         throw NullPointerException("FFT returns NULL image");
03416                 }
03417                 cf->ap2ri();
03418         }
03419         else {
03420                 cf = f1->copy();
03421         }
03422         //printf("cf_x=%d, f1y=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f1->get_ysize(),this->get_xsize(),with->get_xsize());
03423         if (with && !EMUtil::is_same_size(f1, cf)) {
03424                 LOGERR("images not same size");
03425                 throw ImageFormatException("images not same size");
03426         }
03427 
03428         float *rdata1 = f1->get_data();
03429         float *rdata2 = cf->get_data();
03430         size_t cf_size = (size_t)cf->get_xsize() * cf->get_ysize() * cf->get_zsize();
03431 
03432         float re,im;
03433 
03434         for (size_t i = 0; i < cf_size; i += 2) {
03435                 re = rdata1[i] * rdata2[i] - rdata1[i + 1] * rdata2[i + 1];
03436                 im = rdata1[i + 1] * rdata2[i] + rdata1[i] * rdata2[i + 1];
03437                 rdata2[i]=re;
03438                 rdata2[i+1]=im;
03439         }
03440         cf->update();
03441         EMData *f2 = cf->do_ift();//ming change cf to cf_temp
03442         //printf("cf_x=%d, f2x=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f2->get_xsize(),this->get_xsize(),with->get_xsize());
03443         if( cf )
03444         {
03445                 delete cf;
03446                 cf = 0;
03447         }
03448 
03449         if( f1 )
03450         {
03451                 delete f1;
03452                 f1=0;
03453         }
03454 
03455         EXITFUNC;
03456         return f2;
03457 }

EMData * EMData::copy  )  const
 

Make a copy of this image including both data and header.

Returns:
A copy of this image including both data and header.

Definition at line 93 of file emdata_core.cpp.

References EMData().

Referenced by absi(), EMAN::AbsMaxMinAverager::add_image(), EMAN::MinMaxAverager::add_image(), EMAN::FRM2DAligner::align(), EMAN::RTFExhaustiveAligner::align(), calc_fast_sigma_image(), calc_flcf(), calc_mutual_correlation(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), common_lines_real(), convolute(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::FourierReconstructor::determine_slice_agreement(), do_fft(), do_radon(), EMAN::Processor::EMFourierFilterFunc(), FH2F(), EMAN::fourierproduct(), frm_2d_Align(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierReconstructor::insert_slice(), log(), log10(), main(), EMAN::operator *(), EMAN::operator+(), EMAN::operator-(), EMAN::operator/(), EMAN::periodogram(), power(), EMAN::Reconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::ScaleTransformProcessor::process(), EMAN::CtfSimProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::Processor::process(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::LocalNormProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), real(), real2FH(), set_attr_python(), EMAN::PointArray::set_from_density_map(), and sqrt().

00094 {
00095         ENTERFUNC;
00096 
00097         EMData *ret = new EMData(*this);
00098 
00099         EXITFUNC;
00100         return ret;
00101 }

EMData * EMData::copy_empty_head  )  const
 

copy header but not set size for the image

Definition at line 222 of file emdata_sparx.cpp.

References all_translation, attr_dict, EMData(), flags, path, pathnum, and update().

Referenced by EMAN::Util::window().

00223 {
00224         ENTERFUNC;
00225         EMData *ret = new EMData();
00226         ret->attr_dict = attr_dict;
00227         ret->flags = flags;
00228         ret->all_translation = all_translation;
00229         ret->path = path;
00230         ret->pathnum = pathnum;
00231 
00232 // should these be here? d.woolford I did not comment them out, merely place them here (commented out) to draw attention
00233 //      ret->xoff = xoff;
00234 //      ret->yoff = yoff;
00235 //      ret->zoff = zoff;
00236 //      ret->changecount = changecount;
00237 
00238         ret->update();
00239 
00240         EXITFUNC;
00241         return ret;
00242 }

EMData * EMData::copy_head  )  const
 

Make an image with a copy of the current image's header.

Returns:
An image with a copy of the current image's header.

Definition at line 104 of file emdata_core.cpp.

References all_translation, attr_dict, EMData(), flags, nx, ny, nz, path, pathnum, set_size(), and update().

Referenced by EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::addn_img(), average_circ_sub(), conjg(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_ift(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), little_big_dot(), EMAN::Util::madn_scalar(), EMAN::Util::muln_img(), mult_radial(), EMAN::Util::mult_scalar(), EMAN::Util::pad(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), and EMAN::Util::subn_img().

00105 {
00106         ENTERFUNC;
00107         EMData *ret = new EMData();
00108         ret->attr_dict = attr_dict;
00109 
00110         ret->set_size(nx, ny, nz);
00111         ret->flags = flags;
00112 
00113         ret->all_translation = all_translation;
00114 
00115         ret->path = path;
00116         ret->pathnum = pathnum;
00117 
00118 // should these be here? d.woolford I did not comment them out, merely place them here (commented out) to draw attention
00119 //      ret->xoff = xoff;
00120 //      ret->yoff = yoff;
00121 //      ret->zoff = zoff;
00122 //      ret->changecount = changecount;
00123 
00124         ret->update();
00125 
00126         EXITFUNC;
00127         return ret;
00128 }

void EMData::cut_slice const EMData *const   map,
const Transform tr,
bool  interpolate = true
 

cut a 2D slice out of a real 3D map.

Put slice into 'this' image.

Parameters:
map The real 3D map.
tr orientation of the slice as encapsulated in a Transform object.
interpolate Do interpolation or not.
Exceptions:
NullPointerException If map is NULL.
ImageDimensionException If this image is not 2D.
ImageDimensionException If map image is not 3D.
ImageFormatException If this image is complex
ImageFormatException If map is complex
Author:
David Woolford (adapted from an original version by Steve Ludtke)
Date:
Feb 2008

Definition at line 3854 of file emdata.cpp.

References get_data(), get_ndim(), get_xsize(), get_ysize(), get_zsize(), ImageDimensionException, ImageFormatException, is_complex(), NullPointerException, nx, ny, t, update(), v, EMAN::Vec3f, x, and y.

03855 {
03856         ENTERFUNC;
03857 
03858         if (!map) throw NullPointerException("NULL image");
03859         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
03860         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
03861         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
03862         // Now check for complex images - this is really just being thorough
03863         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
03864         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
03865 
03866 
03867         float *sdata = map->get_data();
03868         float *ddata = get_data();
03869 
03870         int map_nx = map->get_xsize();
03871         int map_ny = map->get_ysize();
03872         int map_nz = map->get_zsize();
03873         int map_nxy = map_nx * map_ny;
03874 
03875         int ymax = ny/2;
03876         if ( ny % 2 == 1 ) ymax += 1;
03877         int xmax = nx/2;
03878         if ( nx % 2 == 1 ) xmax += 1;
03879         for (int y = -ny/2; y < ymax; y++) {
03880                 for (int x = -nx/2; x < xmax; x++) {
03881                         Vec3f coord(x,y,0);
03882                         Vec3f soln = transform*coord;
03883 
03884 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
03885 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
03886 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
03887 
03888 
03889 //                      xx += map_nx/2;
03890 //                      yy += map_ny/2;
03891 //                      zz += map_nz/2;
03892 
03893                         float xx = soln[0]+map_nx/2;
03894                         float yy = soln[1]+map_ny/2;
03895                         float zz = soln[2]+map_nz/2;
03896 
03897                         int l = (x+nx/2) + (y+ny/2) * nx;
03898 
03899                         float t = xx - floor(xx);
03900                         float u = yy - floor(yy);
03901                         float v = zz - floor(zz);
03902 
03903                         if (xx < 0 || yy < 0 || zz < 0 ) {
03904                                 ddata[l] = 0;
03905                                 continue;
03906                         }
03907                         if (interpolate) {
03908                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03909                                         ddata[l] = 0;
03910                                         continue;
03911                                 }
03912                                 int k = (int) (Util::fast_floor(xx) + Util::fast_floor(yy) * map_nx + Util::fast_floor(zz) * map_nxy);
03913 
03914 
03915                                 if (xx < (map_nx - 1) && yy < (map_ny - 1) && zz < (map_nz - 1)) {
03916                                         ddata[l] = Util::trilinear_interpolate(sdata[k],
03917                                                                 sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03918                                                                 sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03919                                                                 sdata[k + map_nx + map_nxy + 1],t, u, v);
03920                                 }
03921                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03922                                         ddata[l] += sdata[k];
03923                                 }
03924                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) ) {
03925                                         ddata[l] +=     Util::linear_interpolate(sdata[k], sdata[k + map_nxy],v);
03926                                 }
03927                                 else if ( xx == (map_nx - 1) && zz == (map_nz - 1) ) {
03928                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + map_nx],u);
03929                                 }
03930                                 else if ( yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03931                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + 1],t);
03932                                 }
03933                                 else if ( xx == (map_nx - 1) ) {
03934                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + map_nx], sdata[k + map_nxy], sdata[k + map_nxy + map_nx],u,v);
03935                                 }
03936                                 else if ( yy == (map_ny - 1) ) {
03937                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nxy], sdata[k + map_nxy + 1],t,v);
03938                                 }
03939                                 else if ( zz == (map_nz - 1) ) {
03940                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nx], sdata[k + map_nx + 1],t,u);
03941                                 }
03942 
03943 //                              if (k >= map->get_size()) {
03944 //                                      cout << xx << " " << yy << " " <<  zz << " " << endl;
03945 //                                      cout << k << " " << get_size() << endl;
03946 //                                      cout << get_xsize() << " " << get_ysize() << " " << get_zsize() << endl;
03947 //                                      throw;
03948 //                                      }
03949 //
03950 //                              ddata[l] = Util::trilinear_interpolate(sdata[k],
03951 //                                              sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03952 //                                              sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03953 //                                              sdata[k + map_nx + map_nxy + 1],t, u, v);
03954                         }
03955                         else {
03956                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03957                                         ddata[l] = 0;
03958                                         continue;
03959                                 }
03960                                 size_t k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * (size_t)map_nxy;
03961                                 ddata[l] = sdata[k];
03962                         }
03963 
03964                 }
03965         }
03966 
03967         update();
03968 
03969         EXITFUNC;
03970 }

void EMAN::EMData::debug_print_parms  )  [inline]
 

Printing EMData params for debugging purpose.

Definition at line 3859 of file emdata.h.

void EMData::del_attr const string &  attr_name  ) 
 

Delete the attribute from dictionary.

Parameters:
attr_name the attribute name to be removed

Definition at line 1201 of file emdata_metadata.cpp.

References attr_dict, and EMAN::Dict::erase().

Referenced by del_attr_dict().

01202 {
01203         attr_dict.erase(attr_name);
01204 }

void EMData::del_attr_dict const vector< string > &  del_keys  ) 
 

Delete the attributes from the dictionary.

Parameters:
del_keys the attrutes' names to be removed

Definition at line 1206 of file emdata_metadata.cpp.

References del_attr(), and EMAN::Dict::end().

01207 {
01208         vector<string>::const_iterator it;
01209         for(it=del_keys.begin(); it!=del_keys.end(); ++it) {
01210                 this->del_attr(*it);
01211         }
01212 }

EMData * EMData::delete_disconnected_regions int  ix = 0,
int  iy = 0,
int  iz = 0
 

Delete disconnected regions in a binary image.

Works only for a volume.

Parameters:
[in] ix: x coordinate (with respect to the center) from which the search of the compact region begins.
[in] iy: y coordinate (with respect to the center) from which the search of the compact region begins.
[in] iz: z coordinate (with respect to the center) from which the search of the compact region begins.
Returns:
New binary image

Definition at line 6183 of file emdata_sparx.cpp.

References nx, and ny.

06194                    {
06195                 kpt = false;
06196                 for (int cz = 1; cz < nz-1; cz++) {
06197                         for (int cy = 1; cy < ny-1; cy++) {
06198                                 for (int cx = 1; cx < nx-1; cx++) {
06199                                         if((*result)(cx,cy,cz) == 1) {
06200                                                 for (int lz = -1; lz <= 1; lz++) {
06201                                                         for (int ly = -1; ly <= 1; ly++) {
06202                                                                 for (int lx = -1; lx <= 1; lx++) {
06203                                                                         if(((*this)(cx+lx,cy+ly,cz+lz) == 1) && ((*result)(cx+lx,cy+ly,cz+lz) == 0))  {
06204                                                                                 (*result)(cx+lx,cy+ly,cz+lz) = 1;
06205                                                                                 kpt = true;
06206                                                                         }
06207                                                                 }
06208                                                         }
06209                                                 }
06210                                         }
06211                                 }
06212                         }
06213                 }
06214         }
06215         result->update();
06216         return result;
06217 }
06218 
06219 #define    QUADPI                   3.141592653589793238462643383279502884197

void EMData::depad  ) 
 

De-pad, and and remove Fourier extension convenience function.

Purpose: De-pad, and and remove Fourier extension from a real image.
Method: Remove padding and extension along x for fft,
and return the new image.
Returns:
depadded input image.

Definition at line 6482 of file emdata_sparx.cpp.

References attr_dict, nx, and ny.

Referenced by EMAN::Util::BPCQ(), EMAN::Processor::EMFourierFilterFunc(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::FourierReconstructorSimple2D::finish(), EMAN::fourierproduct(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::Util::WTF(), and EMAN::Util::WTM().

06487                                      : 2;
06488         int nxold = (nx - offset)/npad;
06489 #ifdef _WIN32
06490         int nyold = _cpp_max(ny/npad, 1);
06491         int nzold = _cpp_max(nz/npad, 1);
06492 #else
06493         int nyold = std::max<int>(ny/npad, 1);
06494         int nzold = std::max<int>(nz/npad, 1);
06495 #endif  //_WIN32
06496         int xstart = 0, ystart = 0, zstart = 0;
06497         if( npad > 1) {
06498                 xstart = (nx - offset - nxold)/2 + nxold%2;
06499                 if(ny > 1) {
06500                         ystart = (ny - nyold)/2 + nyold%2;
06501                         if(nz > 1) {
06502                                 zstart = (nz - nzold)/2 + nzold%2;
06503                         }
06504                 }
06505         }
06506         int bytes = nxold*sizeof(float);
06507         float* dest = get_data();
06508         for (int iz=0; iz < nzold; iz++) {
06509                 for (int iy = 0; iy < nyold; iy++) {
06510                         memmove(dest, &(*this)(xstart,iy+ystart,iz+zstart), bytes);
06511                         dest += nxold;
06512                 }
06513         }
06514         set_size(nxold, nyold, nzold);
06515         set_attr("npad", 1);
06516         set_fftpad(false);
06517         set_fftodd(false);
06518         set_complex(false);
06519         if(ny==1 && nz==1) set_complex_x(false);
06520         set_array_offsets(saved_offsets);
06521         update();
06522         EXITFUNC;
06523 }
06524 
06525 /*

void EMData::depad_corner  ) 
 

De-pad, and and remove Fourier extension convenience function.

Purpose: De-pad, and and remove Fourier extension from a real image.
Method: Remove padding and extension along x for fft,
and return the new image.
Returns:
depadded input image.

Definition at line 6534 of file emdata_sparx.cpp.

References attr_dict, nx, and ny.

Referenced by EMAN::FFTResampleProcessor::fft_resample(), and EMAN::fourierproduct().

06539                                      : 2;
06540         int nxold = (nx - offset)/npad;
06541 #ifdef _WIN32
06542         int nyold = _cpp_max(ny/npad, 1);
06543         int nzold = _cpp_max(nz/npad, 1);
06544 #else
06545         int nyold = std::max<int>(ny/npad, 1);
06546         int nzold = std::max<int>(nz/npad, 1);
06547 #endif  //_WIN32
06548         size_t bytes = nxold*sizeof(float);
06549         float* dest = get_data();
06550         for (int iz=0; iz < nzold; iz++) {
06551                 for (int iy = 0; iy < nyold; iy++) {
06552                         memmove(dest, &(*this)(0,iy,iz), bytes);
06553                         dest += nxold;
06554                 }
06555         }
06556         set_size(nxold, nyold, nzold);
06557         set_attr("npad", 1);
06558         set_fftpad(false);
06559         set_fftodd(false);
06560         set_complex(false);
06561         if(ny==1 && nz==1) set_complex_x(false);
06562         set_array_offsets(saved_offsets);
06563         update();
06564         EXITFUNC;
06565 }
06566 
06567 

void EMData::div const EMData image  ) 
 

make each pixel value divided by pixel value of another same-size image.

Parameters:
image The image 'this' image divided by.
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 600 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), imag(), ImageFormatException, InvalidValueException, is_real(), nx, ny, nz, real(), and update().

00601 {
00602         ENTERFUNC;
00603 
00604         if (nx != em.get_xsize() || ny != em.get_ysize() || nz != em.get_zsize()) {
00605                 throw ImageFormatException( "images not same sizes");
00606         }
00607         else if( (is_real()^em.is_real()) == true )
00608         {
00609                 throw ImageFormatException( "not support division between real image and complex image");
00610         }
00611         else {
00612                 const float *src_data = em.get_data();
00613                 size_t size = nxyz;
00614                 float* data = get_data();
00615 
00616                 if( is_real() )
00617                 {
00618                         for (size_t i = 0; i < size; i++) {
00619                                 if(src_data[i] != 0) {
00620                                         data[i] /= src_data[i];
00621                                 }
00622                                 else {
00623                                         if (data[i]==0) continue;
00624                                         throw InvalidValueException(src_data[i], "divide by zero");
00625                                 }
00626                         }
00627                 }
00628                 else
00629                 {
00630                         typedef std::complex<float> comp;
00631                         for( size_t i = 0; i < size; i+=2 )
00632                         {
00633                                 comp c_src( src_data[i], src_data[i+1] );
00634                                 comp c_rdat( data[i], data[i+1] );
00635                                 comp c_result = c_rdat / c_src;
00636                                 data[i] = c_result.real();
00637                                 data[i+1] = c_result.imag();
00638                         }
00639                 }
00640                 update();
00641         }
00642 
00643         EXITFUNC;
00644 }

void EMData::div float  f  ) 
 

make each pixel value divided by a float number.

Parameters:
f The float number 'this' image divided by.

Definition at line 589 of file emdata_core.cpp.

References InvalidValueException, and mult().

Referenced by calc_flcf(), EMAN::fourierproduct(), EMAN::operator/(), operator/=(), and EMAN::LocalNormProcessor::process_inplace().

00590 {
00591         ENTERFUNC;
00592         if ( f == 0 ) {
00593                 throw InvalidValueException(f,"Can not divide by zero");
00594         }
00595         mult(1.0f/f);
00596         EXITFUNC;
00597 }

void EMData::divkbsinh const Util::KaiserBessel kb  ) 
 

divkbsinh -- Divide image by a Kaiser-Bessel sinh window.

Parameters:
[in] kb Kaiser-Bessel window object
Note: Ideally this method really should be a "processor" instead, but at the moment a KaiserBessel object cannot be passed as part of a Dict, making the usual EMData::project() interface rather awkward here.

Definition at line 4175 of file emdata_sparx.cpp.

Referenced by EMAN::FourierGriddingProjector::project3d().

04183                                       {
04184                 float wz = kb.sinhwin(static_cast<float>(iz-nz/2));
04185                 for (int iy=0; iy < ny; iy++) {
04186                         float wy = kb.sinhwin(static_cast<float>(iy-ny/2));
04187                         for (int ix=0; ix < nx; ix++) {
04188                                 float wx = kb.sinhwin(static_cast<float>(ix-nx/2));
04189                                 float w = wx*wy*wz;
04190                                 (*this)(ix,iy,iz) /= w;
04191                         }
04192                 }
04193         }
04194         set_array_offsets(saved_offsets);
04195 }
04196 
04197 void EMData::divkbsinh_rect(const Util::KaiserBessel& kbx, const Util::KaiserBessel& kby, const Util::KaiserBessel& kbz) {

void EMData::divkbsinh_rect const Util::KaiserBessel kbx,
const Util::KaiserBessel kby,
const Util::KaiserBessel kbz
 

Definition at line 4199 of file emdata_sparx.cpp.

04207                                       {
04208                 float wz = kbz.sinhwin(static_cast<float>(iz-nz/2));
04209                 for (int iy=0; iy < ny; iy++) {
04210                         float wy = kby.sinhwin(static_cast<float>(iy-ny/2));
04211                         for (int ix=0; ix < nx; ix++) {
04212                                 float wx = kbx.sinhwin(static_cast<float>(ix-nx/2));
04213                                 float w = wx*wy*wz;
04214                                 (*this)(ix,iy,iz) /= w;
04215                         }
04216                 }
04217         }
04218         
04219         set_array_offsets(saved_offsets);
04220 }
04221 
04222 /* OBSOLETED  PAP

EMData * EMData::do_fft  )  const
 

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 59 of file emdata_transform.cpp.

References copy(), copy_head(), get_data(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), is_fftodd(), is_fftpadded(), LOGERR, nx, ny, nz, set_complex(), set_complex_x(), set_fftodd(), set_fftpad(), set_ri(), set_size(), and update().

Referenced by EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::FRM2DAligner::align(), EMAN::Refine3DAlignerGrid::align(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_mutual_correlation(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::TomoFscCmp::cmp(), common_lines(), convolute(), EMAN::MatchSFProcessor::create_radial_func(), main(), make_footprint(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::CtfSimProcessor::process(), 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(), EMAN::GaussFFTProjector::project3d(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00060 {
00061         ENTERFUNC;
00062 
00063         if (is_complex() ) { // ming add 08/17/2010
00064 #ifdef NATIVE_FFT
00065                 LOGERR(" NATIVE_FFT does not supported complex to complex.");  // PAP
00066                 throw ImageFormatException("real image expected. Input image is complex image.");
00067 #else
00068                 EMData *temp_in=copy();
00069                 EMData *dat= copy_head();
00070                 int offset;
00071                 if(is_fftpadded()) {
00072                         offset = is_fftodd() ? 1 : 2;
00073                 }
00074                 else offset=0;
00075                 //printf("offset=%d\n",offset);
00076                 EMfft::complex_to_complex_nd(temp_in->get_data(),dat->get_data(),nx-offset,ny,nz);
00077 
00078                 if(dat->get_ysize()==1 && dat->get_zsize()==1) dat->set_complex_x(true);
00079 
00080                 dat->update();
00081                 delete temp_in;
00082                 EXITFUNC;
00083                 return dat;
00084 #endif // NATIVE_FFT
00085         } else {
00086                 int nxreal = nx;
00087                 int offset = 2 - nx%2;
00088                 int nx2 = nx + offset;
00089                 EMData* dat = copy_head();
00090                 dat->set_size(nx2, ny, nz);
00091                 //dat->to_zero();  // do not need it, real_to_complex will do it right anyway
00092                 if (offset == 1) dat->set_fftodd(true);
00093                 else             dat->set_fftodd(false);
00094 
00095                 float *d = dat->get_data();
00096                 //std::cout<<" do_fft "<<rdata[5]<<"  "<<d[5]<<std::endl;
00097                 EMfft::real_to_complex_nd(get_data(), d, nxreal, ny, nz);
00098 
00099                 dat->update();
00100                 dat->set_fftpad(true);
00101                 dat->set_complex(true);
00102                 if(dat->get_ysize()==1 && dat->get_zsize()==1) dat->set_complex_x(true);
00103                 dat->set_ri(true);
00104 
00105                 EXITFUNC;
00106                 return dat;
00107         }
00108 }

EMData * EMData::do_fft_inplace  ) 
 

Do FFT inplace.

And return the FFT image.

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

Definition at line 110 of file emdata_transform.cpp.

References get_data(), ImageFormatException, is_complex(), is_fftodd(), is_fftpadded(), LOGERR, nx, ny, nz, rdata, set_complex(), set_complex_x(), set_fftodd(), set_fftpad(), set_ri(), set_size(), and update().

Referenced by calc_fourier_shell_correlation(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), EMAN::fourierproduct(), oneDfftPolar(), EMAN::padfft_slice(), EMAN::periodogram(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::CtfSimProcessor::process(), EMAN::FFTProcessor::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00111 {
00112         ENTERFUNC;
00113 
00114         if ( is_complex() ) {
00115                 LOGERR("real image expected. Input image is complex image.");
00116                 throw ImageFormatException("real image expected. Input image is complex image.");
00117         }
00118 
00119         size_t offset;
00120         int nxreal;
00121         get_data(); // Required call if GPU caching is being used. Otherwise harmless
00122         if (!is_fftpadded()) {
00123                 // need to extend the matrix along x
00124                 // meaning nx is the un-fftpadded size
00125                 nxreal = nx;
00126                 offset = 2 - nx%2;
00127                 if (1 == offset) set_fftodd(true);
00128                 else             set_fftodd(false);
00129                 int nxnew = nx + offset;
00130                 set_size(nxnew, ny, nz);
00131                 for (int iz = nz-1; iz >= 0; iz--) {
00132                         for (int iy = ny-1; iy >= 0; iy--) {
00133                                 for (int ix = nxreal-1; ix >= 0; ix--) {
00134                                         size_t oldxpos = ix + (iy + iz*ny)*(size_t)nxreal;
00135                                         size_t newxpos = ix + (iy + iz*ny)*(size_t)nxnew;
00136                                         (*this)(newxpos) = (*this)(oldxpos);
00137                                 }
00138                         }
00139                 }
00140                 set_fftpad(true);
00141         } else {
00142                 offset = is_fftodd() ? 1 : 2;
00143                 nxreal = nx - offset;
00144         }
00145         EMfft::real_to_complex_nd(rdata, rdata, nxreal, ny, nz);
00146 
00147         set_complex(true);
00148         if(ny==1 && nz==1)  set_complex_x(true);
00149         set_ri(true);
00150 
00151         update();
00152 
00153         EXITFUNC;
00154         return this;
00155 }

EMData * 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.

Definition at line 322 of file emdata_transform.cpp.

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

Referenced by calc_mutual_correlation(), EMAN::OptVarianceCmp::cmp(), convolute(), FH2Real(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::FourierWeightAverager::finish(), EMAN::TomoAverager::finish(), frm_2d_Align(), main(), make_footprint(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::CtfSimProcessor::process(), 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().

00323 {
00324         ENTERFUNC;
00325 
00326         if (!is_complex()) {
00327                 LOGERR("complex image expected. Input image is real image.");
00328                 throw ImageFormatException("complex image expected. Input image is real image.");
00329         }
00330 
00331         if (!is_ri()) {
00332                 LOGWARN("run IFT on AP data, only RI should be used. Converting.");
00333         }
00334 
00335         get_data(); // Required call if GPU caching is being used. Otherwise harmless
00336         EMData* dat = copy_head();
00337         dat->set_size(nx, ny, nz);
00338         ap2ri();
00339 
00340         float *d = dat->get_data();
00341         int ndim = get_ndim();
00342 
00343         /* Do inplace IFT on a image copy, because the complex to real transform of
00344          * nd will destroy its input array even for out-of-place transforms.
00345          */
00346         memcpy((char *) d, (char *) rdata, (size_t)nx * ny * nz * sizeof(float));
00347 
00348         int offset = is_fftodd() ? 1 : 2;
00349         //cout << "Sending offset " << offset << " " << nx-offset << endl;
00350         if (ndim == 1) {
00351                 EMfft::complex_to_real_nd(d, d, nx - offset, ny, nz);
00352         } else {
00353                 EMfft::complex_to_real_nd(d, d, nx - offset, ny, nz);
00354 
00355                 size_t row_size = (nx - offset) * sizeof(float);
00356                 for (size_t i = 1; i < (size_t)ny * nz; i++) {
00357                         memmove((char *) &d[i * (nx - offset)], (char *) &d[i * nx], row_size);
00358                 }
00359         }
00360 
00361         dat->set_size(nx - offset, ny, nz);     //remove the padding
00362 #if defined     FFTW2 || defined FFTW3 //native fft and ACML already done normalization
00363         // SCALE the inverse FFT
00364         float scale = 1.0f / ((nx - offset) * ny * nz);
00365         dat->mult(scale);
00366 #endif  //FFTW2 || FFTW3
00367         dat->set_fftodd(false);
00368         dat->set_fftpad(false);
00369         dat->set_complex(false);
00370         if(dat->get_ysize()==1 && dat->get_zsize()==1)  dat->set_complex_x(false);
00371         dat->set_ri(false);
00372         dat->update();
00373 
00374 
00375         EXITFUNC;
00376         return dat;
00377 }

EMData * EMData::do_ift_inplace  ) 
 

Definition at line 383 of file emdata_transform.cpp.

References ap2ri(), data, get_data(), ImageFormatException, is_complex(), is_fftodd(), is_ri(), LOGERR, LOGWARN, mult(), nx, ny, nz, scale(), set_complex(), set_complex_x(), set_fftpad(), set_ri(), and update().

Referenced by EMAN::Util::BPCQ(), EMAN::PhaseCmp::cmp(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::FourierReconstructorSimple2D::finish(), EMAN::fourierproduct(), EMAN::FFTProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), EMAN::Util::twoD_to_3D_ali(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00384 {
00385         ENTERFUNC;
00386 
00387         if (!is_complex()) {
00388                 LOGERR("complex image expected. Input image is real image.");
00389                 throw ImageFormatException("complex image expected. Input image is real image.");
00390         }
00391 
00392         if (!is_ri()) {
00393                 LOGWARN("run IFT on AP data, only RI should be used. ");
00394         }
00395         ap2ri();
00396 
00397         int offset = is_fftodd() ? 1 : 2;
00398         float* data = get_data();
00399         EMfft::complex_to_real_nd(data, data, nx - offset, ny, nz);
00400 
00401 #if defined     FFTW2 || defined FFTW3  //native fft and ACML already done normalization
00402         // SCALE the inverse FFT
00403         int nxo = nx - offset;
00404         float scale = 1.0f / ((size_t)nxo * ny * nz);
00405         mult(scale);
00406 #endif //FFTW2 || FFTW3
00407 
00408         set_fftpad(true);
00409         set_complex(false);
00410         if(ny==1 && nz==1) set_complex_x(false);
00411         set_ri(false);
00412         update();
00413 
00414         EXITFUNC;
00415         return this;
00416 }

EMData * EMData::do_radon  ) 
 

Radon Transform: an algorithm that transforms an original image into a series of equiangular projections.

When applied to a 2D object, the output of the Radon transform is a series of 1D lines.

Do radon transformation on this image. This image must be 2D square.

Exceptions:
ImageFormatException If the image is not square.
ImageDimensionException If the image is not 2D.
Returns:
Radon transform image in square.

Definition at line 1383 of file emdata.cpp.

References copy(), EMData(), get_data(), get_ndim(), ImageDimensionException, ImageFormatException, nx, nx, ny, set_size(), square, t, to_zero(), transform(), update(), x, and y.

Referenced by main().

01384 {
01385         ENTERFUNC;
01386 
01387         if (get_ndim() != 2) {
01388                 throw ImageDimensionException("2D only");
01389         }
01390 
01391         if (nx != ny) {
01392                 throw ImageFormatException("square image only");
01393         }
01394 
01395         EMData *result = new EMData();
01396         result->set_size(nx, ny, 1);
01397         result->to_zero();
01398         float *result_data = result->get_data();
01399 
01400         EMData *this_copy = this;
01401         this_copy = copy();
01402 
01403         for (int i = 0; i < nx; i++) {
01404                 Transform t(Dict("type","2d","alpha",(float) M_PI * 2.0f * i / nx));
01405                 this_copy->transform(t);
01406 
01407                 float *copy_data = this_copy->get_data();
01408 
01409                 for (int y = 0; y < nx; y++) {
01410                         for (int x = 0; x < nx; x++) {
01411                                 if (Util::square(x - nx / 2) + Util::square(y - nx / 2) <= nx * nx / 4) {
01412                                         result_data[i + y * nx] += copy_data[x + y * nx];
01413                                 }
01414                         }
01415                 }
01416 
01417                 this_copy->update();
01418         }
01419 
01420         result->update();
01421 
01422         if( this_copy )
01423         {
01424                 delete this_copy;
01425                 this_copy = 0;
01426         }
01427 
01428         EXITFUNC;
01429         return result;
01430 }

float EMData::dot EMData with  ) 
 

Dot product 2 images.

The 2 images must be of same size. If 'evenonly' is true, only calculates pixels with even positions assuming all pixels are in a single array. If 'evenonly' is false, calculates all pixels. Shortcut for cmp("dot")

Parameters:
with The image to do dot product with.
Exceptions:
NullPointerException if with is a NULL image.
Returns:
The dot product result.

Definition at line 648 of file emdata_core.cpp.

References EMAN::DotCmp::cmp(), and NullPointerException.

Referenced by little_big_dot(), main(), and make_footprint().

00649 {
00650         ENTERFUNC;
00651         if (!with) {
00652                 throw NullPointerException("Null EMData Image");
00653         }
00654         DotCmp dot_cmp;
00655         float r = -dot_cmp.cmp(this, with);
00656         EXITFUNC;
00657         return r;
00658 }

double EMData::dot_rotate_translate EMData with,
float  dx,
float  dy,
float  da,
const bool  mirror = false
 

dot product of 2 images.

Then 'this' image is rotated/translated. It is much faster than Rotate/Translate then dot product. 2D images only.

Parameters:
with The image used to do the dot product.
dx Translation distance in x direction.
dy Translation distance in y direction.
da Rotation euler angle in degrees
mirror 
Exceptions:
ImageFormatException If the 2 images are not the same size.
ImageDimensionException If the image is 3D.
Returns:

Definition at line 1209 of file emdata.cpp.

References get_data(), get_ndim(), ImageDimensionException, ImageFormatException, LOGERR, nx, nx, ny, ny, t, and y.

Referenced by refalifnfast().

01210 {
01211         ENTERFUNC;
01212 
01213         if (!EMUtil::is_same_size(this, with)) {
01214                 LOGERR("images not same size");
01215                 throw ImageFormatException("images not same size");
01216         }
01217 
01218         if (get_ndim() == 3) {
01219                 LOGERR("1D/2D Images only");
01220                 throw ImageDimensionException("1D/2D only");
01221         }
01222 
01223         float *this_data = 0;
01224 
01225         this_data = get_data();
01226 
01227         float da_rad = da*(float)M_PI/180.0f;
01228 
01229         float *with_data = with->get_data();
01230         float mx0 = cos(da_rad);
01231         float mx1 = sin(da_rad);
01232         float y = -ny / 2.0f;
01233         float my0 = mx0 * (-nx / 2.0f - 1.0f) + nx / 2.0f - dx;
01234         float my1 = -mx1 * (-nx / 2.0f - 1.0f) + ny / 2.0f - dy;
01235         double result = 0;
01236 
01237         for (int j = 0; j < ny; j++) {
01238                 float x2 = my0 + mx1 * y;
01239                 float y2 = my1 + mx0 * y;
01240 
01241                 int ii = Util::fast_floor(x2);
01242                 int jj = Util::fast_floor(y2);
01243                 float t = x2 - ii;
01244                 float u = y2 - jj;
01245 
01246                 for (int i = 0; i < nx; i++) {
01247                         t += mx0;
01248                         u -= mx1;
01249 
01250                         if (t >= 1.0f) {
01251                                 ii++;
01252                                 t -= 1.0f;
01253                         }
01254 
01255                         if (u >= 1.0f) {
01256                                 jj++;
01257                                 u -= 1.0f;
01258                         }
01259 
01260                         if (t < 0) {
01261                                 ii--;
01262                                 t += 1.0f;
01263                         }
01264 
01265                         if (u < 0) {
01266                                 jj--;
01267                                 u += 1.0f;
01268                         }
01269 
01270                         if (ii >= 0 && ii <= nx - 2 && jj >= 0 && jj <= ny - 2) {
01271                                 int k0 = ii + jj * nx;
01272                                 int k1 = k0 + 1;
01273                                 int k2 = k0 + nx + 1;
01274                                 int k3 = k0 + nx;
01275 
01276                                 float tt = 1 - t;
01277                                 float uu = 1 - u;
01278                                 int idx = i + j * nx;
01279                                 if (mirror) idx = nx-1-i+j*nx; // mirroring of Transforms is always about the y axis
01280                                 result += (this_data[k0] * tt * uu + this_data[k1] * t * uu +
01281                                                    this_data[k2] * t * u + this_data[k3] * tt * u) * with_data[idx];
01282                         }
01283                 }
01284                 y += 1.0f;
01285         }
01286 
01287         EXITFUNC;
01288         return result;
01289 }

EMData * EMData::downsample Util::sincBlackman kb,
float  scale = 1.0
 

Definition at line 3187 of file emdata_sparx.cpp.

References nx, ny, nz, x, and y.

03206         {
03207                 for (int iy =0; iy < nyn; iy++) {
03208                         float y = float(iy)/scale;
03209                         for (int ix = 0; ix < nxn; ix++) {
03210                                 float x = float(ix)/scale;
03211                                 (*ret)(ix,iy) = this->get_pixel_filtered(x, y, 1.0f, kb);
03212                         }
03213                 }
03214         }
03215         else{
03216                 
03217                 for (int iz =0; iz < nzn; iz++) {
03218                         float z = float(iz)/scale;
03219                         for (int iy =0; iy < nyn; iy++) {
03220                                 float y = float(iy)/scale;
03221                                 for (int ix = 0; ix < nxn; ix++) {
03222                                         float x = float(ix)/scale;
03223                                         (*ret)(ix,iy,iz) = this->get_pixel_filtered(x, y, z, kb);
03224                                 }
03225                         }
03226                 }
03227         
03228         }
03229         set_array_offsets(saved_offsets);
03230         return ret;
03231 }
03232 
03233 

bool EMData::equal const EMData that  )  const
 

compare the equality of two EMData object based on their pixel values

Definition at line 2997 of file emdata.cpp.

References get_const_data(), get_data(), get_size(), get_xsize(), get_ysize(), get_zsize(), nx, and ny.

02997                                            {
02998         if (that.get_xsize() != nx || that.get_ysize() != ny || that.get_zsize() != nz ) return false;
02999 
03000         const float*  d1 = that.get_const_data();
03001         float* d2 = get_data();
03002 
03003         for(size_t i =0; i < get_size(); ++i,++d1,++d2) {
03004                 if ((*d1) != (*d2)) return false;
03005         }
03006 
03007 //      if(attr_dict != that.attr_dict) {
03008 //              return false;
03009 //      }
03010 
03011         return true;
03012 }

EMData * EMData::extract_box const Transform cs,
const Region r
 

Extract a box from EMData in an abritrary orrientation.

Used for extracting helix boxes from tomograms

EMData extract_box(const Transform& cs, const int ix, const int fx, const int iy, const int yf, const int zi, const int zf);

Parameters:
cs Transform describing the coordinate system of the box realative to the standard coord system
r Region describe the volume to extract, in the local coordinate system
Author:
John Flanagan
Date:
Aug 2011

Definition at line 4137 of file emdata.cpp.

References EMData(), get_data(), EMAN::Region::get_depth(), EMAN::Region::get_height(), EMAN::Transform::get_matrix(), EMAN::Region::get_width(), get_xsize(), get_ysize(), nx, nx, nxy, ny, nz, set_size(), t, v, x, EMAN::Region::x_origin(), y, EMAN::Region::y_origin(), and EMAN::Region::z_origin().

04138 {
04139         vector<float> cs_matrix = cs.get_matrix();
04140         
04141         EMData* box = new EMData();
04142         box->set_size((r.get_width()-r.x_origin()), (r.get_height()-r.y_origin()), (r.get_depth()-r.z_origin()));
04143         int box_nx = box->get_xsize();
04144         int box_ny = box->get_ysize();
04145         int box_nxy = box_nx*box_ny;
04146         float* bdata = box->get_data();
04147         float* ddata = get_data();
04148         
04149         for (int x = r.x_origin(); x < r.get_width(); x++) {
04150                 for (int y = r.y_origin(); y < r.get_height(); y++) {
04151                         for (int z = r.z_origin(); z < r.get_depth(); z++) {
04152                                 //float xb = cs_matrix[0]*x + cs_matrix[1]*y + cs_matrix[2]*z + cs_matrix[3];
04153                                 //float yb = cs_matrix[4]*x + cs_matrix[5]*y + cs_matrix[6]*z + cs_matrix[7];
04154                                 //float zb = cs_matrix[8]*x + cs_matrix[9]*y + cs_matrix[10]*z + cs_matrix[11];
04155                                 float xb = cs_matrix[0]*x + y*cs_matrix[4] + z*cs_matrix[8] + cs_matrix[3];
04156                                 float yb = cs_matrix[1]*x + y*cs_matrix[5] + z*cs_matrix[9] + cs_matrix[7];
04157                                 float zb = cs_matrix[2]*x + y*cs_matrix[6] + z*cs_matrix[10] + cs_matrix[11];
04158                                 float t = xb - Util::fast_floor(xb);
04159                                 float u = yb - Util::fast_floor(yb);
04160                                 float v = zb - Util::fast_floor(zb);
04161                                 
04162                                 //cout << x << " " << y << " " << z << " Box " << xb << " " << yb << " " << zb << endl;
04163                                 int l = (x - r.x_origin()) + (y - r.y_origin())*box_nx + (z - r.z_origin())*box_nxy;
04164                                 int k = (int) (Util::fast_floor(xb) + Util::fast_floor(yb) * nx + Util::fast_floor(zb) * nxy);
04165                                 //cout << k << " " << l << endl;
04166                                 if ( xb > nx - 1 || yb > ny - 1 || zb > nz - 1) {
04167                                         bdata[l] = 0;
04168                                         continue;
04169                                 }
04170                                 if (xb < 0 || yb < 0 || zb < 0){
04171                                         bdata[l] = 0;
04172                                         continue;
04173                                 }
04174 
04175                                 if (xb < (nx - 1) && yb < (ny - 1) && zb < (nz - 1)) {
04176                                         bdata[l] = Util::trilinear_interpolate(ddata[k], ddata[k + 1], ddata[k + nx],ddata[k + nx + 1], ddata[k + nxy], ddata[k + nxy + 1], ddata[k + nx + nxy], ddata[k + nx + nxy + 1],t, u, v);
04177                                 }
04178                         }
04179                 }
04180         }
04181         
04182         return box;
04183 }

EMData * EMData::extract_plane const Transform tf,
Util::KaiserBessel kb
 

extractplane -- Gridding convolution in 3D along a plane

Note: Expected to be used in combination with fourier gridding projections.

Parameters:
[in] tf transform matrix defining the intended plane.
[in] kb Kaiser-Bessel window
Returns:
Complex gridding plane
See also:
P.A. Penczek, R. Renka, and H. Schomberg, J. Opt. Soc. Am. A _21_, 499-509 (2004)

Definition at line 4250 of file emdata_sparx.cpp.

References nx, ny, and EMAN::Vec3f.

Referenced by EMAN::FourierGriddingProjector::project3d(), and EMAN::Util::twoD_to_3D_ali().

04264                         : (0..nhalf,-nhalf..nhalf-1,-nhalf..nhalf-1)
04265         int n = nxreal;
04266         int nhalf = n/2;
04267         vector<int> saved_offsets = get_array_offsets();
04268         set_array_offsets(0,-nhalf,-nhalf);
04269         res->set_array_offsets(0,-nhalf,0);
04270         // set up some temporary weighting arrays
04271         int kbsize =  kb.get_window_size();
04272         int kbmin  = -kbsize/2;
04273         int kbmax  = -kbmin;
04274         float* wy0 = new float[kbmax - kbmin + 1];
04275         float* wy  = wy0 - kbmin; // wy[kbmin:kbmax]
04276         float* wx0 = new float[kbmax - kbmin + 1];
04277         float* wx  = wx0 - kbmin;
04278         float* wz0 = new float[kbmax - kbmin + 1];
04279         float* wz  = wz0 - kbmin;
04280         float rim = nhalf*float(nhalf);
04281         int count = 0;
04282         float wsum = 0.f;
04283         Transform tftrans = tf; // need transpose of tf here for consistency
04284         tftrans.invert();      // with spider
04285         for (int jy = -nhalf; jy < nhalf; jy++) 
04286         {
04287                 for (int jx = 0; jx <= nhalf; jx++) 
04288                 {
04289                         Vec3f nucur((float)jx, (float)jy, 0.f);
04290                         Vec3f nunew = tftrans*nucur;
04291                         float xnew = nunew[0], ynew = nunew[1], znew = nunew[2];
04292                         if (xnew*xnew+ynew*ynew+znew*znew <= rim) 
04293                         {
04294                                 count++;
04295                                 std::complex<float> btq(0.f,0.f);
04296                                 bool flip = false;
04297                                 if (xnew < 0.f) {
04298                                         flip = true;
04299                                         xnew = -xnew;
04300                                         ynew = -ynew;
04301                                         znew = -znew;
04302                                 }
04303                                 int ixn = int(Util::round(xnew));
04304                                 int iyn = int(Util::round(ynew));
04305                                 int izn = int(Util::round(znew));
04306                                 // populate weight arrays
04307                                 for (int i=kbmin; i <= kbmax; i++) {
04308                                         int izp = izn + i;
04309                                         wz[i] = kb.i0win_tab(znew - izp);
04310                                         int iyp = iyn + i;
04311                                         wy[i] = kb.i0win_tab(ynew - iyp);
04312                                         int ixp = ixn + i;
04313                                         wx[i] = kb.i0win_tab(xnew - ixp);
04314 
04315                                 }
04316                                 // restrict weight arrays to non-zero elements
04317                                 int lnbz = 0;
04318                                 for (int iz = kbmin; iz <= -1; iz++) {
04319                                         if (wz[iz] != 0.f) {
04320                                                 lnbz = iz;
04321                                                 break;
04322                                         }
04323                                 }
04324                                 int lnez = 0;
04325                                 for (int iz = kbmax; iz >= 1; iz--) {
04326                                         if (wz[iz] != 0.f) {
04327                                                 lnez = iz;
04328                                                 break;
04329                                         }
04330                                 }
04331                                 int lnby = 0;
04332                                 for (int iy = kbmin; iy <= -1; iy++) {
04333                                         if (wy[iy] != 0.f) {
04334                                                 lnby = iy;
04335                                                 break;
04336                                         }
04337                                 }
04338                                 int lney = 0;
04339                                 for (int iy = kbmax; iy >= 1; iy--) {
04340                                         if (wy[iy] != 0.f) {
04341                                                 lney = iy;
04342                                                 break;
04343                                         }
04344                                 }
04345                                 int lnbx = 0;
04346                                 for (int ix = kbmin; ix <= -1; ix++) {
04347                                         if (wx[ix] != 0.f) {
04348                                                 lnbx = ix;
04349                                                 break;
04350                                         }
04351                                 }
04352                                 int lnex = 0;
04353                                 for (int ix = kbmax; ix >= 1; ix--) {
04354                                         if (wx[ix] != 0.f) {
04355                                                 lnex = ix;
04356                                                 break;
04357                                         }
04358                                 }
04359                                 if    (ixn >= -kbmin      && ixn <= nhalf-1-kbmax
04360                                    && iyn >= -nhalf-kbmin && iyn <= nhalf-1-kbmax
04361                                    && izn >= -nhalf-kbmin && izn <= nhalf-1-kbmax) {
04362                                         // interior points
04363                                         for (int lz = lnbz; lz <= lnez; lz++) {
04364                                                 int izp = izn + lz;
04365                                                 for (int ly=lnby; ly<=lney; ly++) {
04366                                                         int iyp = iyn + ly;
04367                                                         float ty = wz[lz]*wy[ly];
04368                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04369                                                                 int ixp = ixn + lx;
04370                                                                 float wg = wx[lx]*ty;
04371                                                                 btq += cmplx(ixp,iyp,izp)*wg;
04372                                                                 wsum += wg;
04373                                                         }
04374                                                 }
04375                                         }
04376                                 } else {
04377                                         // points "sticking out"
04378                                         for (int lz = lnbz; lz <= lnez; lz++) {
04379                                                 int izp = izn + lz;
04380                                                 for (int ly=lnby; ly<=lney; ly++) {
04381                                                         int iyp = iyn + ly;
04382                                                         float ty = wz[lz]*wy[ly];
04383                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04384                                                                 int ixp = ixn + lx;
04385                                                                 float wg = wx[lx]*ty;
04386                                                                 bool mirror = false;
04387                                                                 int ixt(ixp), iyt(iyp), izt(izp);
04388                                                                 if (ixt > nhalf || ixt < -nhalf) {
04389                                                                         ixt = Util::sgn(ixt)
04390                                                                                   *(n - abs(ixt));
04391                                                                         iyt = -iyt;
04392                                                                         izt = -izt;
04393                                                                         mirror = !mirror;
04394                                                                 }
04395                                                                 if (iyt >= nhalf || iyt < -nhalf) {
04396                                                                         if (ixt != 0) {
04397                                                                                 ixt = -ixt;
04398                                                                                 iyt = Util::sgn(iyt)
04399                                                                                           *(n - abs(iyt));
04400                                                                                 izt = -izt;
04401                                                                                 mirror = !mirror;
04402                                                                         } else {
04403                                                                                 iyt -= n*Util::sgn(iyt);
04404                                                                         }
04405                                                                 }
04406                                                                 if (izt >= nhalf || izt < -nhalf) {
04407                                                                         if (ixt != 0) {
04408                                                                                 ixt = -ixt;
04409                                                                                 iyt = -iyt;
04410                                                                                 izt = Util::sgn(izt)
04411                                                                                           *(n - abs(izt));
04412                                                                                 mirror = !mirror;
04413                                                                         } else {
04414                                                                                 izt -= Util::sgn(izt)*n;
04415                                                                         }
04416                                                                 }
04417                                                                 if (ixt < 0) {
04418                                                                         ixt = -ixt;
04419                                                                         iyt = -iyt;
04420                                                                         izt = -izt;
04421                                                                         mirror = !mirror;
04422                                                                 }
04423                                                                 if (iyt == nhalf) iyt = -nhalf;
04424                                                                 if (izt == nhalf) izt = -nhalf;
04425                                                                 if (mirror)   btq += conj(cmplx(ixt,iyt,izt))*wg;
04426                                                                 else          btq += cmplx(ixt,iyt,izt)*wg;
04427                                                                 wsum += wg;
04428                                                         }
04429                                                 }
04430                                         }
04431                                 }
04432                                 if (flip)  res->cmplx(jx,jy) = conj(btq);
04433                                 else       res->cmplx(jx,jy) = btq;
04434                         }
04435                 }
04436         }
04437         for (int jy = -nhalf; jy < nhalf; jy++)
04438                 for (int jx = 0; jx <= nhalf; jx++)
04439                         res->cmplx(jx,jy) *= count/wsum;
04440         delete[] wx0; delete[] wy0; delete[] wz0;
04441         set_array_offsets(saved_offsets);
04442         res->set_array_offsets(0,0,0);
04443         res->set_shuffled(true);
04444         return res;
04445 }
04446 
04447 

EMData * EMData::extract_plane_rect const Transform tf,
Util::KaiserBessel kbx,
Util::KaiserBessel kby,
Util::KaiserBessel kbz
 

Definition at line 4454 of file emdata_sparx.cpp.

References nx, ny, and EMAN::Vec3f.

04472                         : (0..nhalf,-nhalf..nhalf-1,-nhalf..nhalf-1)
04473         int n = nxcircal;
04474         int nhalf = n/2;
04475         int nxhalf = (nx-2)/2;
04476         int nyhalf = ny/2;
04477         int nzhalf = nz/2;
04478         
04479         vector<int> saved_offsets = get_array_offsets();
04480         set_array_offsets(0, -nyhalf, -nzhalf);
04481         res->set_array_offsets(0,-nhalf,0);
04482         // set up some temporary weighting arrays
04483         int kbxsize =  kbx.get_window_size();
04484         int kbxmin  = -kbxsize/2;
04485         int kbxmax  = -kbxmin;
04486 
04487         int kbysize =  kby.get_window_size();
04488         int kbymin  = -kbysize/2;
04489         int kbymax  = -kbymin;
04490 
04491         int kbzsize =  kbz.get_window_size();
04492         int kbzmin  = -kbzsize/2;
04493         int kbzmax  = -kbzmin;
04494 
04495         //std::cout<<"kb size x,y,z=="<<kbxsize<<" "<<kbysize<<" "<<kbzsize<<std::endl;
04496         float* wy0 = new float[kbymax - kbymin + 1];
04497         float* wy  = wy0 - kbymin; // wy[kbmin:kbmax]
04498         float* wx0 = new float[kbxmax - kbxmin + 1];
04499         float* wx  = wx0 - kbxmin;
04500         float* wz0 = new float[kbzmax - kbzmin + 1];
04501         float* wz  = wz0 - kbzmin;
04502         float rim = nhalf*float(nhalf);
04503         int count = 0;
04504         float wsum = 0.f;
04505         Transform tftrans = tf; // need transpose of tf here for consistency
04506         tftrans.invert();      // with spider
04507         float xratio=float(nx-2)/float(nxcircal);
04508         float yratio=float(ny)/float(nxcircal);
04509         float zratio=float(nz)/float(nxcircal);
04510         //std::cout<<"xratio,yratio=="<<xratio<<" "<<yratio<<std::endl;
04511         for (int jy = -nhalf; jy < nhalf; jy++) 
04512         {
04513                 for (int jx = 0; jx <= nhalf; jx++) 
04514                 {
04515                         Vec3f nucur((float)jx, (float)jy, 0.f);
04516                         Vec3f nunew = tftrans*nucur;
04517                         float xnew = nunew[0]*xratio, ynew = nunew[1]*yratio, znew = nunew[2]*zratio;
04518                         
04519                         if (nunew[0]*nunew[0]+nunew[1]*nunew[1]+nunew[2]*nunew[2] <= rim)
04520                         {
04521                                 count++;
04522                                 std::complex<float> btq(0.f,0.f);
04523                                 bool flip = false;
04524                                 if (xnew < 0.f) {
04525                                         flip = true;
04526                                         xnew = -xnew;
04527                                         ynew = -ynew;
04528                                         znew = -znew;
04529                                 }
04530                                 int ixn = int(Util::round(xnew));
04531                                 int iyn = int(Util::round(ynew));
04532                                 int izn = int(Util::round(znew));
04533                                 // populate weight arrays
04534                                 for (int i=kbzmin; i <= kbzmax; i++) {
04535                                         int izp = izn + i;
04536                                         wz[i] = kbz.i0win_tab(znew - izp);
04537                                         }
04538                                 for (int i=kbymin; i <= kbymax; i++) {
04539                                         int iyp = iyn + i;
04540                                         wy[i] = kby.i0win_tab(ynew - iyp);
04541                                         }
04542                                 for (int i=kbxmin; i <= kbxmax; i++) {
04543                                         int ixp = ixn + i;
04544                                         wx[i] = kbx.i0win_tab(xnew - ixp);
04545                                         }
04546                 
04547 
04548                                 
04549                                 // restrict weight arrays to non-zero elements
04550                                 int lnbz = 0;
04551                                 for (int iz = kbzmin; iz <= -1; iz++) {
04552                                         if (wz[iz] != 0.f) {
04553                                                 lnbz = iz;
04554                                                 break;
04555                                         }
04556                                 }
04557                                 int lnez = 0;
04558                                 for (int iz = kbzmax; iz >= 1; iz--) {
04559                                         if (wz[iz] != 0.f) {
04560                                                 lnez = iz;
04561                                                 break;
04562                                         }
04563                                 }
04564                                 int lnby = 0;
04565                                 for (int iy = kbymin; iy <= -1; iy++) {
04566                                         if (wy[iy] != 0.f) {
04567                                                 lnby = iy;
04568                                                 break;
04569                                         }
04570                                 }
04571                                 int lney = 0;
04572                                 for (int iy = kbymax; iy >= 1; iy--) {
04573                                         if (wy[iy] != 0.f) {
04574                                                 lney = iy;
04575                                                 break;
04576                                         }
04577                                 }
04578                                 int lnbx = 0;
04579                                 for (int ix = kbxmin; ix <= -1; ix++) {
04580                                         if (wx[ix] != 0.f) {
04581                                                 lnbx = ix;
04582                                                 break;
04583                                         }
04584                                 }
04585                                 int lnex = 0;
04586                                 for (int ix = kbxmax; ix >= 1; ix--) {
04587                                         if (wx[ix] != 0.f) {
04588                                                 lnex = ix;
04589                                                 break;
04590                                         }
04591                                 }
04592                                 if    (ixn >= -kbxmin      && ixn <= nxhalf-1-kbxmax
04593                                    && iyn >= -nyhalf-kbymin && iyn <= nyhalf-1-kbymax
04594                                    && izn >= -nzhalf-kbzmin && izn <= nzhalf-1-kbzmax) {
04595                                         // interior points
04596                                         for (int lz = lnbz; lz <= lnez; lz++) {
04597                                                 int izp = izn + lz;
04598                                                 for (int ly=lnby; ly<=lney; ly++) {
04599                                                         int iyp = iyn + ly;
04600                                                         float ty = wz[lz]*wy[ly];
04601                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04602                                                                 int ixp = ixn + lx;
04603                                                                 float wg = wx[lx]*ty;
04604                                                                 btq += cmplx(ixp,iyp,izp)*wg;
04605                                                                 wsum += wg;
04606                                                         }
04607                                                 }
04608                                         }
04609                                 } 
04610                                 else {
04611                                         // points "sticking out"
04612                                         for (int lz = lnbz; lz <= lnez; lz++) {
04613                                                 int izp = izn + lz;
04614                                                 for (int ly=lnby; ly<=lney; ly++) {
04615                                                         int iyp = iyn + ly;
04616                                                         float ty = wz[lz]*wy[ly];
04617                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04618                                                                 int ixp = ixn + lx;
04619                                                                 float wg = wx[lx]*ty;
04620                                                                 bool mirror = false;
04621                                                                 int ixt(ixp), iyt(iyp), izt(izp);
04622                                                                 if (ixt > nxhalf || ixt < -nxhalf) {
04623                                                                         ixt = Util::sgn(ixt)
04624                                                                                   *(nx-2-abs(ixt));
04625                                                                         iyt = -iyt;
04626                                                                         izt = -izt;
04627                                                                         mirror = !mirror;
04628                                                                 }
04629                                                                 if (iyt >= nyhalf || iyt < -nyhalf) {
04630                                                                         if (ixt != 0) {
04631                                                                                 ixt = -ixt;
04632                                                                                 iyt = Util::sgn(iyt)
04633                                                                                           *(ny - abs(iyt));
04634                                                                                 izt = -izt;
04635                                                                                 mirror = !mirror;
04636                                                                         } else {
04637                                                                                 iyt -= ny*Util::sgn(iyt);
04638                                                                         }
04639                                                                 }
04640                                                                 if (izt >= nzhalf || izt < -nzhalf) {
04641                                                                         if (ixt != 0) {
04642                                                                                 ixt = -ixt;
04643                                                                                 iyt = -iyt;
04644                                                                                 izt = Util::sgn(izt)
04645                                                                                           *(nz - abs(izt));
04646                                                                                 mirror = !mirror;
04647                                                                         } else {
04648                                                                                 izt -= Util::sgn(izt)*nz;
04649                                                                         }
04650                                                                 }
04651                                                                 if (ixt < 0) {
04652                                                                         ixt = -ixt;
04653                                                                         iyt = -iyt;
04654                                                                         izt = -izt;
04655                                                                         mirror = !mirror;
04656                                                                 }
04657                                                                 if (iyt == nyhalf) iyt = -nyhalf;
04658                                                                 if (izt == nzhalf) izt = -nzhalf;
04659                                                                 if (mirror)   btq += conj(cmplx(ixt,iyt,izt))*wg;
04660                                                                 else          btq += cmplx(ixt,iyt,izt)*wg;
04661                                                                 wsum += wg;
04662                                                         }
04663                                                 }
04664                                         }
04665                                 }
04666                                 if (flip)  res->cmplx(jx,jy) = conj(btq);
04667                                 else       res->cmplx(jx,jy) = btq;
04668                         }
04669                 }
04670         }
04671         for (int jy = -nhalf; jy < nhalf; jy++)
04672                 for (int jx = 0; jx <= nhalf; jx++)
04673                         res->cmplx(jx,jy) *= count/wsum;
04674         delete[] wx0; delete[] wy0; delete[] wz0;
04675         set_array_offsets(saved_offsets);
04676         res->set_array_offsets(0,0,0);
04677         res->set_shuffled(true);
04678         return res;
04679 }
04680 
04681 

EMData * EMData::extract_plane_rect_fast const Transform tf,
Util::KaiserBessel kbx,
Util::KaiserBessel kby,
Util::KaiserBessel kbz
 

Definition at line 4685 of file emdata_sparx.cpp.

References nx, ny, and EMAN::Vec3f.

04733                         : (0..nhalf,-nhalf..nhalf-1,-nhalf..nhalf-1)
04734         int n = nxcircal;
04735         int nhalf = n/2;
04736         int nhalfx_e = nx_e/2;
04737         int nhalfy_e = ny_e/2;
04738         int nxhalf=(nx-2)/2;
04739         int nyhalf=ny/2;
04740         int nzhalf=nz/2;
04741         //std::cout<<"nhalf,nxhalf,nyhalf,nzhalf=="<<nhalf<<" "<<nxhalf<<" "<<nyhalf<<" "<<nzhalf<<std::endl;
04742         vector<int> saved_offsets = get_array_offsets();
04743         set_array_offsets(0,-nyhalf,-nzhalf);
04744         res->set_array_offsets(0,-nhalfy_e,0);
04745         // set up some temporary weighting arrays
04746         int kbxsize =  kbx.get_window_size();
04747         int kbxmin  = -kbxsize/2;
04748         int kbxmax  = -kbxmin;
04749 
04750         int kbysize =  kby.get_window_size();
04751         int kbymin  = -kbysize/2;
04752         int kbymax  = -kbymin;
04753 
04754         int kbzsize =  kbz.get_window_size();
04755         int kbzmin  = -kbzsize/2;
04756         int kbzmax  = -kbzmin;
04757 
04758         //std::cout<<"kb size x,y,z=="<<kbxsize<<" "<<kbysize<<" "<<kbzsize<<std::endl;
04759         float* wy0 = new float[kbymax - kbymin + 1];
04760         float* wy  = wy0 - kbymin; // wy[kbmin:kbmax]
04761         float* wx0 = new float[kbxmax - kbxmin + 1];
04762         float* wx  = wx0 - kbxmin;
04763         float* wz0 = new float[kbzmax - kbzmin + 1];
04764         float* wz  = wz0 - kbzmin;
04765         float rim = nhalf*float(nhalf);
04766         int count = 0;
04767         float wsum = 0.f;
04768         Transform tftrans = tf; // need transpose of tf here for consistency
04769         tftrans.invert();      // with spider
04770 
04771         //std::cout<<"xratio,yratio=="<<xratio<<" "<<yratio<<std::endl;
04772         for (int jy = -nhalfy_e; jy < nhalfy_e; jy++) 
04773         {
04774                 for (int jx = 0; jx <= nhalfx_e; jx++) 
04775                 {
04776                         Vec3f nucur((float)jx, (float)jy, 0.f);
04777                         nucur[0]=nucur[0]*xscale;nucur[1]=nucur[1]*yscale;;
04778                         Vec3f nunew = tftrans*nucur;
04779                         float xnew = nunew[0]*xratio, ynew = nunew[1]*yratio, znew = nunew[2];
04780                         
04781                         if (nunew[0]*nunew[0]+nunew[1]*nunew[1]+nunew[2]*nunew[2] <= rim)
04782                         {
04783                                 count++;
04784                                 std::complex<float> btq(0.f,0.f);
04785                                 bool flip = false;
04786                                 if (xnew < 0.f) {
04787                                         flip = true;
04788                                         xnew = -xnew;
04789                                         ynew = -ynew;
04790                                         znew = -znew;
04791                                 }
04792                                 int ixn = int(Util::round(xnew));
04793                                 int iyn = int(Util::round(ynew));
04794                                 int izn = int(Util::round(znew));
04795                                 // populate weight arrays
04796                                 for (int i=kbzmin; i <= kbzmax; i++) {
04797                                         int izp = izn + i;
04798                                         wz[i] = kbz.i0win_tab(znew - izp);
04799                                         }
04800                                 for (int i=kbymin; i <= kbymax; i++) {
04801                                         int iyp = iyn + i;
04802                                         wy[i] = kby.i0win_tab(ynew - iyp);
04803                                         }
04804                                 for (int i=kbxmin; i <= kbxmax; i++) {
04805                                         int ixp = ixn + i;
04806                                         wx[i] = kbx.i0win_tab(xnew - ixp);
04807                                         }
04808                 
04809 
04810                                 
04811                                 // restrict weight arrays to non-zero elements
04812                                 int lnbz = 0;
04813                                 for (int iz = kbzmin; iz <= -1; iz++) {
04814                                         if (wz[iz] != 0.f) {
04815                                                 lnbz = iz;
04816                                                 break;
04817                                         }
04818                                 }
04819                                 int lnez = 0;
04820                                 for (int iz = kbzmax; iz >= 1; iz--) {
04821                                         if (wz[iz] != 0.f) {
04822                                                 lnez = iz;
04823                                                 break;
04824                                         }
04825                                 }
04826                                 int lnby = 0;
04827                                 for (int iy = kbymin; iy <= -1; iy++) {
04828                                         if (wy[iy] != 0.f) {
04829                                                 lnby = iy;
04830                                                 break;
04831                                         }
04832                                 }
04833                                 int lney = 0;
04834                                 for (int iy = kbymax; iy >= 1; iy--) {
04835                                         if (wy[iy] != 0.f) {
04836                                                 lney = iy;
04837                                                 break;
04838                                         }
04839                                 }
04840                                 int lnbx = 0;
04841                                 for (int ix = kbxmin; ix <= -1; ix++) {
04842                                         if (wx[ix] != 0.f) {
04843                                                 lnbx = ix;
04844                                                 break;
04845                                         }
04846                                 }
04847                                 int lnex = 0;
04848                                 for (int ix = kbxmax; ix >= 1; ix--) {
04849                                         if (wx[ix] != 0.f) {
04850                                                 lnex = ix;
04851                                                 break;
04852                                         }
04853                                 }
04854                                 if    (ixn >= -kbxmin      && ixn <= nxhalf-1-kbxmax
04855                                    && iyn >= -nyhalf-kbymin && iyn <= nyhalf-1-kbymax
04856                                    && izn >= -nzhalf-kbzmin && izn <= nzhalf-1-kbzmax) {
04857                                         // interior points
04858                                         for (int lz = lnbz; lz <= lnez; lz++) {
04859                                                 int izp = izn + lz;
04860                                                 for (int ly=lnby; ly<=lney; ly++) {
04861                                                         int iyp = iyn + ly;
04862                                                         float ty = wz[lz]*wy[ly];
04863                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04864                                                                 int ixp = ixn + lx;
04865                                                                 float wg = wx[lx]*ty;
04866                                                                 btq += cmplx(ixp,iyp,izp)*wg;
04867                                                                 wsum += wg;
04868                                                         }
04869                                                 }
04870                                         }
04871                                 } 
04872                                 else {
04873                                         // points "sticking out"
04874                                         for (int lz = lnbz; lz <= lnez; lz++) {
04875                                                 int izp = izn + lz;
04876                                                 for (int ly=lnby; ly<=lney; ly++) {
04877                                                         int iyp = iyn + ly;
04878                                                         float ty = wz[lz]*wy[ly];
04879                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04880                                                                 int ixp = ixn + lx;
04881                                                                 float wg = wx[lx]*ty;
04882                                                                 bool mirror = false;
04883                                                                 int ixt(ixp), iyt(iyp), izt(izp);
04884                                                                 if (ixt > nxhalf || ixt < -nxhalf) {
04885                                                                         ixt = Util::sgn(ixt)
04886                                                                                   *(nx-2-abs(ixt));
04887                                                                         iyt = -iyt;
04888                                                                         izt = -izt;
04889                                                                         mirror = !mirror;
04890                                                                 }
04891                                                                 if (iyt >= nyhalf || iyt < -nyhalf) {
04892                                                                         if (ixt != 0) {
04893                                                                                 ixt = -ixt;
04894                                                                                 iyt = Util::sgn(iyt)
04895                                                                                           *(ny - abs(iyt));
04896                                                                                 izt = -izt;
04897                                                                                 mirror = !mirror;
04898                                                                         } else {
04899                                                                                 iyt -= ny*Util::sgn(iyt);
04900                                                                         }
04901                                                                 }
04902                                                                 if (izt >= nzhalf || izt < -nzhalf) {
04903                                                                         if (ixt != 0) {
04904                                                                                 ixt = -ixt;
04905                                                                                 iyt = -iyt;
04906                                                                                 izt = Util::sgn(izt)
04907                                                                                           *(nz - abs(izt));
04908                                                                                 mirror = !mirror;
04909                                                                         } else {
04910                                                                                 izt -= Util::sgn(izt)*nz;
04911                                                                         }
04912                                                                 }
04913                                                                 if (ixt < 0) {
04914                                                                         ixt = -ixt;
04915                                                                         iyt = -iyt;
04916                                                                         izt = -izt;
04917                                                                         mirror = !mirror;
04918                                                                 }
04919                                                                 if (iyt == nyhalf) iyt = -nyhalf;
04920                                                                 if (izt == nzhalf) izt = -nzhalf;
04921                                                                 if (mirror)   btq += conj(cmplx(ixt,iyt,izt))*wg;
04922                                                                 else          btq += cmplx(ixt,iyt,izt)*wg;
04923                                                                 wsum += wg;
04924                                                         }
04925                                                 }
04926                                         }
04927                                 }
04928                                 if (flip)  res->cmplx(jx,jy) = conj(btq);
04929                                 else       res->cmplx(jx,jy) = btq;
04930                         }
04931                 }
04932         }
04933         for (int jy = -nhalfy_e; jy < nhalfy_e; jy++)
04934                 for (int jx = 0; jx <= nhalfx_e; jx++)
04935                         res->cmplx(jx,jy) *= count/wsum;
04936         delete[] wx0; delete[] wy0; delete[] wz0;
04937         set_array_offsets(saved_offsets);
04938         res->set_array_offsets(0,0,0);
04939         res->set_shuffled(true);
04940         return res;
04941 }
04942 
04943 

EMData * EMData::extractline Util::KaiserBessel kb,
float  nuxnew,
float  nuynew
 

Definition at line 3841 of file emdata_sparx.cpp.

References nx.

03856                         : (0..nhalf,-nhalf..nhalf-1)
03857         int n = nxreal;
03858         int nhalf = n/2;
03859         vector<int> saved_offsets = get_array_offsets();
03860         set_array_offsets(0,-nhalf,-nhalf);
03861 
03862         // set up some temporary weighting arrays
03863         int kbsize = kb.get_window_size();
03864         int kbmin = -kbsize/2;
03865         int kbmax = -kbmin;
03866         float* wy0 = new float[kbmax - kbmin + 1];
03867         float* wy = wy0 - kbmin; // wy[kbmin:kbmax]
03868         float* wx0 = new float[kbmax - kbmin + 1];
03869         float* wx = wx0 - kbmin;
03870 
03871         int   count = 0;
03872         float wsum = 0.f;
03873         bool  flip = (nuxnew < 0.f);
03874 
03875         for (int jx = 0; jx <= nhalf; jx++) {
03876                 float xnew = jx*nuxnew, ynew = jx*nuynew;
03877                 count++;
03878                 std::complex<float> btq(0.f,0.f);
03879                 if (flip) {
03880                         xnew = -xnew;
03881                         ynew = -ynew;
03882                 }
03883                 int ixn = int(Util::round(xnew));
03884                 int iyn = int(Util::round(ynew));
03885                 // populate weight arrays
03886                 for (int i=kbmin; i <= kbmax; i++) {
03887                         int iyp = iyn + i;
03888                         wy[i] = kb.i0win_tab(ynew - iyp);
03889                         int ixp = ixn + i;
03890                         wx[i] = kb.i0win_tab(xnew - ixp);
03891                 }
03892                 // restrict weight arrays to non-zero elements
03893 
03894                 int lnby = 0;
03895                 for (int iy = kbmin; iy <= -1; iy++) {
03896                         if (wy[iy] != 0.f) {
03897                                 lnby = iy;
03898                                 break;
03899                         }
03900                 }
03901                 int lney = 0;
03902                 for (int iy = kbmax; iy >= 1; iy--) {
03903                         if (wy[iy] != 0.f) {
03904                                 lney = iy;
03905                                 break;
03906                         }
03907                 }
03908                 int lnbx = 0;
03909                 for (int ix = kbmin; ix <= -1; ix++) {
03910                         if (wx[ix] != 0.f) {
03911                                 lnbx = ix;
03912                                 break;
03913                         }
03914                 }
03915                 int lnex = 0;
03916                 for (int ix = kbmax; ix >= 1; ix--) {
03917                         if (wx[ix] != 0.f) {
03918                                 lnex = ix;
03919                                 break;
03920                         }
03921                 }
03922                 if (ixn >= -kbmin && ixn <= nhalf-1-kbmax
03923                                 && iyn >= -nhalf-kbmin && iyn <= nhalf-1-kbmax) {
03924                         // interior points
03925                         for (int ly=lnby; ly<=lney; ly++) {
03926                                 int iyp = iyn + ly;
03927                                 for (int lx=lnbx; lx<=lnex; lx++) {
03928                                         int ixp = ixn + lx;
03929                                         float wg = wx[lx]*wy[ly];
03930                                         btq += cmplx(ixp,iyp)*wg;
03931                                         wsum += wg;
03932                                 }
03933                         }
03934                 } else {
03935                         // points "sticking out"
03936                         for (int ly=lnby; ly<=lney; ly++) {
03937                                 int iyp = iyn + ly;
03938                                 for (int lx=lnbx; lx<=lnex; lx++) {
03939                                         int ixp = ixn + lx;
03940                                         float wg = wx[lx]*wy[ly];
03941                                         bool mirror = false;
03942                                         int ixt(ixp), iyt(iyp);
03943                                         if (ixt > nhalf || ixt < -nhalf) {
03944                                                 ixt = Util::sgn(ixt)*(n - abs(ixt));
03945                                                 iyt = -iyt;
03946                                                 mirror = !mirror;
03947                                         }
03948                                         if (iyt >= nhalf || iyt < -nhalf) {
03949                                                 if (ixt != 0) {
03950                                                         ixt = -ixt;
03951                                                         iyt = Util::sgn(iyt)*(n - abs(iyt));
03952                                                         mirror = !mirror;
03953                                                 } else {
03954                                                         iyt -= n*Util::sgn(iyt);
03955                                                 }
03956                                         }
03957                                         if (ixt < 0) {
03958                                                 ixt = -ixt;
03959                                                 iyt = -iyt;
03960                                                 mirror = !mirror;
03961                                         }
03962                                         if (iyt == nhalf) iyt = -nhalf;
03963                                         if (mirror) btq += conj(cmplx(ixt,iyt))*wg;
03964                                         else        btq += cmplx(ixt,iyt)*wg;
03965                                         wsum += wg;
03966                                 }
03967                         }
03968                 }
03969                 if (flip) res->cmplx(jx) = conj(btq);
03970                 else      res->cmplx(jx) = btq;
03971         }
03972         for (int jx = 0; jx <= nhalf; jx++)  res->cmplx(jx) *= count/wsum;
03973 
03974         delete[] wx0; delete[] wy0;
03975         set_array_offsets(saved_offsets);
03976         res->set_array_offsets(0,0,0);
03977         return res;
03978 }
03979 
03980 

std::complex< float > EMData::extractpoint float  xin,
float  yin,
Util::KaiserBessel kb
 

extractpoint -- Gridding convolution

Note: Expected to be used in combination with fouriergridrot2d.

Parameters:
[in] xin x-position
[in] yin y-position
[in] kb Kaiser-Bessel window
Returns:
Complex gridding result
See also:
P.A. Penczek, R. Renka, and H. Schomberg, J. Opt. Soc. Am. A _21_, (2004)

Definition at line 3729 of file emdata_sparx.cpp.

References nx.

03740                   {
03741                 nuxnew *= -1;
03742                 nuynew *= -1;
03743         }
03744         // put (xnew,ynew) on a grid.  The indices will be wrong for
03745         // the Fourier elements in the image, but the grid sizing will
03746         // be correct.
03747         int ixn = int(Util::round(nuxnew));
03748         int iyn = int(Util::round(nuynew));
03749         // set up some temporary weighting arrays
03750         float* wy0 = new float[kbmax - kbmin + 1];
03751         float* wy = wy0 - kbmin; // wy[kbmin:kbmax]
03752         float* wx0 = new float[kbmax - kbmin + 1];
03753         float* wx = wx0 - kbmin;
03754         for (int i = kbmin; i <= kbmax; i++) {
03755                         int iyp = iyn + i;
03756                         wy[i] = kb.i0win_tab(nuynew - iyp);
03757                         int ixp = ixn + i;
03758                         wx[i] = kb.i0win_tab(nuxnew - ixp);
03759         }
03760         // restrict loops to non-zero elements
03761         int iymin = 0;
03762         for (int iy = kbmin; iy <= -1; iy++) {
03763                 if (wy[iy] != 0.f) {
03764                         iymin = iy;
03765                         break;
03766                 }
03767         }
03768         int iymax = 0;
03769         for (int iy = kbmax; iy >= 1; iy--) {
03770                 if (wy[iy] != 0.f) {
03771                         iymax = iy;
03772                         break;
03773                 }
03774         }
03775         int ixmin = 0;
03776         for (int ix = kbmin; ix <= -1; ix++) {
03777                 if (wx[ix] != 0.f) {
03778                         ixmin = ix;
03779                         break;
03780                 }
03781         }
03782         int ixmax = 0;
03783         for (int ix = kbmax; ix >= 1; ix--) {
03784                 if (wx[ix] != 0.f) {
03785                         ixmax = ix;
03786                         break;
03787                 }
03788         }
03789         float wsum = 0.0f;
03790         for (int iy = iymin; iy <= iymax; iy++)
03791                 for (int ix = ixmin; ix <= ixmax; ix++)
03792                         wsum += wx[ix]*wy[iy];
03793         std::complex<float> result(0.f,0.f);
03794         if ((ixn >= -kbmin) && (ixn <= nhalf-1-kbmax) && (iyn >= -nhalf-kbmin) && (iyn <= nhalf-1-kbmax)) {
03795                 // (xin,yin) not within window border from the edge
03796                 for (int iy = iymin; iy <= iymax; iy++) {
03797                         int iyp = iyn + iy;
03798                         for (int ix = ixmin; ix <= ixmax; ix++) {
03799                                 int ixp = ixn + ix;
03800                                 float w = wx[ix]*wy[iy];
03801                                 std::complex<float> val = cmplx(ixp,iyp);
03802                                 result += val*w;
03803                         }
03804                 }
03805         } else {
03806                 // points that "stick out"
03807                 for (int iy = iymin; iy <= iymax; iy++) {
03808                         int iyp = iyn + iy;
03809                         for (int ix = ixmin; ix <= ixmax; ix++) {
03810                                 int ixp = ixn + ix;
03811                                 bool mirror = false;
03812                                 int ixt= ixp, iyt= iyp;
03813                                 if (ixt < 0) {
03814                                         ixt = -ixt;
03815                                         iyt = -iyt;
03816                                         mirror = !mirror;
03817                                 }
03818                                 if (ixt > nhalf) {
03819                                         ixt = nxreal - ixt;
03820                                         iyt = -iyt;
03821                                         mirror = !mirror;
03822                                 }
03823                                 if (iyt > nhalf-1)  iyt -= nxreal;
03824                                 if (iyt < -nhalf)   iyt += nxreal;
03825                                 float w = wx[ix]*wy[iy];
03826                                 std::complex<float> val = this->cmplx(ixt,iyt);
03827                                 if (mirror)  result += conj(val)*w;
03828                                 else         result += val*w;
03829                         }
03830                 }
03831         }
03832         if (flip)  result = conj(result)/wsum;
03833         else       result /= wsum;
03834         delete [] wx0;
03835         delete [] wy0;
03836         return result;
03837 }
03838 
03839 EMData* EMData::extractline(Util::KaiserBessel& kb, float nuxnew, float nuynew)

void EMData::fft_shuffle  ) 
 

fft_shuffle -- Shuffle a Fourier image to put the origin at (0,ny/2)

Our usual FFT convention puts the origin at (0,0), but then grid points corresponding to iy > ny/2 correspond to (unnormalized) frequencies iy-ny. This routine rearranges the columns of the Fourier image so that iy varies from -ny/2 to ny/2 (or ny/2 - 1 for ny even). This method acts as a toggle, so to unshuffle a Fourier image just call this method a second time.

Definition at line 3990 of file emdata_sparx.cpp.

References nx, ny, and nz.

Referenced by EMAN::FourierGriddingProjector::project3d(), EMAN::Util::twoD_to_3D_ali(), and write_image().

04001                     {
04002                 for (int iy=0; iy < ny; iy++)
04003                         for (int iz=0; iz < nzhalf; iz++)
04004                                 swapx(&self(0,iy,iz),&self(0,iy,iz+nzhalf),temp,nbytes);
04005         }
04006         set_shuffled(!is_shuffled()); // toggle
04007         set_array_offsets(offsets); // reset offsets
04008         update();
04009         delete[] temp;
04010 }
04011 
04012 void EMData::pad_corner(float *pad_image) {

EMData * EMData::FH2F int  Size,
float  OverSamplekB,
int  IntensityFlag = 0
 

returns the fourier version of the image from the FH version.

The current image is not changed. The result is in real/imaginary format. The FH switch is set off.

Parameters:
Size is the size of the image to be returned
OverSamplekB is a parameter controlling the fineness of the Fourier sampling
IntensityFlag =0 is the usual; =1 means that the input was an intensity
Returns:
the shuffled version of the FFT

Definition at line 245 of file emdata_sparx.cpp.

References copy(), get_xsize(), get_ysize(), get_zsize(), imag(), ImageFormatException, LOGERR, nx, nx, ny, ny, nz, Radialize(), real(), set_complex(), set_complex_x(), set_fftodd(), set_FH(), set_ri(), set_shuffled(), set_size(), spline_mat(), sqrt(), to_zero(), and update().

Referenced by FH2Real().

00246 {
00247         int nx=get_xsize();
00248         int ny=get_ysize();
00249         int nz=get_zsize();
00250         float ScalFactor=4.1f;
00251         int Center = (int) floor((Size+1.0)/2.0 +.1);
00252         int CenterM= Center-1;
00253         int CountMax = (Center+1)*Center/2;
00254 
00255         int     *PermMatTr           = new int[CountMax];
00256         float  *RValsSorted         = new float[CountMax];
00257         float  *weightofkValsSorted = new float[CountMax];
00258         int      *SizeReturned        = new int[1];
00259         Util::Radialize(PermMatTr, RValsSorted,weightofkValsSorted,Size, SizeReturned);
00260         int RIntMax= SizeReturned[0];  // replaces CountMax; the latter should now never be used.
00261 //      kVec2Use = (0:1/OverSamplek:RValsSorted(RIntMax)+1/OverSamplek); %   in pixels  (otherwise need *2*pi/Size)
00262 
00263         int   mMax = (int) floor( ScalFactor*RValsSorted[RIntMax-1]+10.0);
00264 
00265         int    kIntMax  = 2+ (int) floor( RValsSorted[RIntMax-1]*OverSamplekB);
00266         float *kVec2Use = new float[kIntMax];
00267         for (int kk=0; kk<kIntMax; kk++){
00268                 kVec2Use[kk]= ((float) kk)/OverSamplekB;}
00269 
00270 
00271 
00272 #ifdef DEBUG
00273         printf("nx=%d, ny=%d, nz=%d Center=%d mMax=%d CountMax=%d kIntMax=%d Centerm1=%d  Size=%d\n\n",
00274             nx,ny,nz, Center, mMax, CountMax, kIntMax,  CenterM, Size);
00275 #endif
00276 
00277         EMData * rhoOfkmB = this;
00278 
00279 //     check mMax's are equal
00280 //     check kIntMax's are equal
00281 
00282         if ( (nx==2*(mMax+1)) && (ny==kIntMax) &&(nz==1) ) {
00283 
00284         EMData *rhoOfkandm = copy();
00285         rhoOfkandm ->set_size(2*(mMax+1),RIntMax);
00286         rhoOfkandm ->to_zero();
00287 //      MArray2D rhoOfkandm = tempCopy->get_2dview();  % Just changed Nov 20 2005
00288 //      printf("rhoOfkandm \n");
00289         for (int mr=0; mr <2*(mMax+1); mr++){
00290                 float *Row= new float[kIntMax];
00291                 float *RowOut= new float[RIntMax];
00292                 for (int ii=0; ii<kIntMax; ii++){ Row[ii]=(*rhoOfkmB)(mr,ii);}
00293                 Util::spline_mat(kVec2Use, Row, kIntMax,  RValsSorted, RowOut, RIntMax );
00294                 for (int ii=0; ii<RIntMax; ii++){
00295                         (*rhoOfkandm)(mr,ii) = RowOut[ii];
00296 //                      printf("%3.3f  ",RowOut[ii]);
00297                 }
00298 //              printf(" \n");
00299 //              rhoOfkandm(m+1,:) = spline(kVec2Use,rhoOfkmBReIm(m+1,1:kIntMax),kIntMax,RValsSorted);
00300         }
00301         rhoOfkandm ->update();
00302 
00303 //          So far so good PRB ....
00304 
00305         EMData* outCopy = rhoOfkandm ->copy();
00306         outCopy->set_size(2*Size,Size,1);
00307         outCopy->to_zero();
00308 //      MArray2D ImBWfftRm = outCopy->get_2dview();
00309 
00310         int Count =0, kInt, kIntm1;
00311         std::complex <float> ImfTemp;
00312         float kValue, thetak;
00313 
00314         for (int jkx=0; jkx <Center; jkx++) { // These index the outputted picture
00315                 for (int jky=0; jky<=jkx; jky++){
00316                         kInt = PermMatTr[Count];
00317                         kIntm1= kInt-1;
00318                         Count++;
00319                         float fjkx = float(jkx);
00320                         float fjky = float(jky);
00321 
00322                         kValue = std::sqrt(fjkx*fjkx +  fjky*fjky )  ;
00323 //                      mMaxR= floor(ScalFactor*kValue +10);
00324 
00325  //                   How many copies
00326 
00327                         thetak = atan2(fjky,fjkx);
00328                         ImfTemp = (*rhoOfkandm)(0, kIntm1) ;
00329                         for (int mm= 1; mm <mMax;mm++) {  // The index for m
00330                                 std::complex <float> fact(0,-mm*thetak);
00331                                 std::complex <float> expfact= exp(fact);
00332                                 std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1),(*rhoOfkandm)(2*mm+1,kIntm1));
00333                                 float mmFac = float(1-2*(mm%2));
00334                                 if (IntensityFlag==1){ mmFac=1;}
00335                                 ImfTemp +=   expfact * tempRho + mmFac  *conj(expfact*tempRho);//pow(float(-1),mm)
00336                         }
00337                         (*outCopy)(2*(CenterM+jkx),CenterM+jky)   = ImfTemp.real();
00338                         (*outCopy)(2*(CenterM+jkx)+1,CenterM+jky) = ImfTemp.imag();
00339 //                      printf("jkx=%d, jky=%d; %f + %f i \n",jkx,jky,ImfTemp.real(), ImfTemp.imag());
00340 
00341                         if (jky>0) {
00342                                 thetak = atan2(-fjky,fjkx);
00343                                 ImfTemp = (*rhoOfkandm)(0,kIntm1);
00344                                 for (int mm= 1; mm<mMax; mm++) { // The index for m
00345                                         std::complex <float> fact(0,-mm*thetak);
00346                                         std::complex <float> expfact= exp(fact);
00347                                         std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1), (*rhoOfkandm)(2*mm+1,kIntm1));
00348                                         float mmFac = float(1-2*(mm%2));
00349                                         if (IntensityFlag==1){ mmFac=1;}
00350                                         ImfTemp +=   expfact * tempRho +  mmFac  *conj(expfact*tempRho);
00351                                 }
00352                                 (*outCopy)(2*(CenterM+jkx),CenterM-jky)  = ImfTemp.real();
00353 
00354                                 (*outCopy)(2*(CenterM+jkx)+1,CenterM-jky) = ImfTemp.imag();
00355                         }
00356 
00357                         if (jkx>0) {
00358                                 thetak = atan2(fjky,-fjkx);
00359                                 ImfTemp = (*rhoOfkandm)(0,kIntm1);
00360                                 for (int mm= 1; mm<mMax; mm++) { // The index for m
00361                                         std::complex <float> fact(0,-mm*thetak);
00362                                         std::complex <float> expfact= exp(fact);
00363                                         std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1), (*rhoOfkandm)(2*mm+1,kIntm1));
00364                                         float mmFac = float(1-2*(mm%2));
00365                                         if (IntensityFlag==1){ mmFac=1;}
00366                                         ImfTemp +=   expfact * tempRho +  mmFac *conj(expfact*tempRho);
00367                                 }
00368                                 (*outCopy)(2*(CenterM-jkx)  ,CenterM+jky) = ImfTemp.real();
00369                                 (*outCopy)(2*(CenterM-jkx)+1,CenterM+jky) = ImfTemp.imag();
00370                         }
00371 
00372                         if (jkx>0 && jky>0) {
00373                                 thetak = atan2(-fjky,-fjkx);
00374                                 ImfTemp = (*rhoOfkandm)(0 , kIntm1);
00375                                 for (int mm= 1; mm<mMax; mm++) {  // The index for m
00376                                         std::complex <float> fact(0,-mm*thetak);
00377                                         std::complex <float> expfact= exp(fact);
00378                                         std::complex <float> tempRho( (*rhoOfkandm)(2*mm,kIntm1),(*rhoOfkandm)(2*mm+1,kIntm1) );
00379                                         float mmFac = float(1-2*(mm%2));
00380                                         if (IntensityFlag==1){ mmFac=1;}
00381                                         ImfTemp +=   expfact * tempRho +  mmFac *conj(expfact*tempRho);
00382                                 }
00383                                 (*outCopy)(2*(CenterM-jkx)  ,CenterM-jky) = ImfTemp.real();
00384                                 (*outCopy)(2*(CenterM-jkx)+1,CenterM-jky) = ImfTemp.imag();
00385                         }
00386 
00387                         if (jky< jkx) {
00388                                 thetak = atan2(fjkx,fjky);
00389                                 ImfTemp = (*rhoOfkandm)(0,kIntm1);
00390                                 for (int mm= 1; mm<mMax; mm++){ // The index for m
00391                                         std::complex <float> fact(0,-mm*thetak);
00392                                         std::complex <float> expfact= exp(fact);
00393                                         std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1),(*rhoOfkandm)(2*mm+1,kIntm1));
00394                                         float mmFac = float(1-2*(mm%2));
00395                                         if (IntensityFlag==1){ mmFac=1;}
00396                                         ImfTemp +=   expfact * tempRho +  mmFac *conj(expfact*tempRho);
00397                                 }
00398                                 (*outCopy)(2*(CenterM+jky)  ,CenterM+jkx) = ImfTemp.real();
00399                                 (*outCopy)(2*(CenterM+jky)+1,CenterM+jkx) = ImfTemp.imag();
00400 
00401                                 if (jky>0){
00402                                         thetak = atan2(fjkx,-fjky);
00403                                         ImfTemp = (*rhoOfkandm)(0, kIntm1);
00404                                         for (int mm= 1; mm <mMax; mm++) { // The index for m
00405                                                 std::complex <float> fact(0,-mm*thetak);
00406                                                 std::complex <float> expfact= exp(fact);
00407                                                 std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1),(*rhoOfkandm)(2*mm+1,kIntm1));
00408                                         float mmFac = float(1-2*(mm%2));
00409                                         if (IntensityFlag==1){ mmFac=1;}
00410                                                 ImfTemp +=  expfact * tempRho +  mmFac *conj(expfact*tempRho);
00411                                         }
00412                                         (*outCopy)(2*(CenterM-jky)  ,CenterM+jkx) = ImfTemp.real();
00413                                         (*outCopy)(2*(CenterM-jky)+1,CenterM+jkx) = ImfTemp.imag();
00414                                 }
00415 
00416                                  if (jkx>0) {
00417                                          thetak = atan2(-fjkx,fjky);
00418                                          ImfTemp = (*rhoOfkandm)(0,kIntm1);
00419                                         for (int mm= 1; mm <mMax; mm++) { // The index for m
00420                                                 std::complex <float> fact(0,-mm*thetak);
00421                                                 std::complex <float> expfact= exp(fact);
00422                                                 std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1),(*rhoOfkandm)(2*mm+1,kIntm1));
00423                                                 float mmFac = float(1-2*(mm%2));
00424                                                 if (IntensityFlag==1){ mmFac=1;}
00425                                                 ImfTemp +=  expfact * tempRho +  mmFac *conj(expfact*tempRho);
00426                                         }
00427                                         (*outCopy)(2*(CenterM+jky)  ,CenterM-jkx) = ImfTemp.real();
00428                                         (*outCopy)(2*(CenterM+jky)+1,CenterM-jkx) = ImfTemp.imag();
00429                                 }
00430 
00431                                 if (jkx>0 && jky>0) {
00432                                         thetak = atan2(-fjkx,-fjky);
00433                                         ImfTemp = (*rhoOfkandm)(0,kIntm1) ;
00434                                         for (int mm= 1; mm <mMax; mm++) { // The index for m
00435                                                 std::complex <float> fact(0,-mm*thetak);
00436                                                 std::complex <float> expfact= exp(fact);
00437                                                 std::complex <float> tempRho((*rhoOfkandm)(2*mm,kIntm1) ,(*rhoOfkandm)(2*mm+1,kIntm1) );
00438                                                 float mmFac = float(1-2*(mm%2));
00439                                                 if (IntensityFlag==1){ mmFac=1;}
00440                                                 ImfTemp +=  expfact * tempRho +  mmFac *conj(expfact*tempRho);
00441                                         }
00442                                         (*outCopy)(2*(CenterM-jky)  ,CenterM-jkx) = ImfTemp.real();
00443                                         (*outCopy)(2*(CenterM-jky)+1,CenterM-jkx) = ImfTemp.imag();
00444                                 }
00445                         } // ends jky <jkx
00446 
00447 
00448                 } // ends jky
00449         } // ends jkx
00450         outCopy->update();
00451         outCopy->set_complex(true);
00452         if(outCopy->get_ysize()==1 && outCopy->get_zsize()==1) outCopy->set_complex_x(true);
00453         outCopy->set_ri(true);
00454         outCopy->set_FH(false);
00455         outCopy->set_fftodd(true);
00456         outCopy->set_shuffled(true);
00457         return outCopy;
00458         } else {
00459                 LOGERR("can't be an FH image not this size");
00460                 throw ImageFormatException("something strange about this image: not a FH");
00461 
00462         }
00463 }  // ends FH2F

EMData * EMData::FH2Real int  Size,
float  OverSamplekB,
int  IntensityFlag = 0
 

returns the real version of the image from the FH version.

The current image is not changed. The result is in real format.

Parameters:
Size is the size of the image to be returned
OverSamplekB is a parameter controlling the fineness of the Fourier sampling
IntensityFlag =0 is the usual; =1 means that the input was an intensity
Returns:
the real version of the data

Definition at line 466 of file emdata_sparx.cpp.

References do_ift(), FH2F(), and process_inplace().

00467 {
00468         EMData* FFT= FH2F(Size,OverSamplekB,0);
00469         FFT->process_inplace("xform.fourierorigin.tocorner");
00470         EMData* eguess= FFT ->do_ift();
00471         return eguess;
00472 }  // ends FH2F

EMData * EMData::filter_by_image EMData image,
bool  RetReal = true
 

Definition at line 7271 of file emdata_sparx.cpp.

References nx, and ny.

07282                           {
07283                 // fimage must remain pristine
07284                 fp = this->copy();
07285         } else {
07286                 fp = this->norm_pad( false, 1);
07287                 fp->do_fft_inplace();
07288         }
07289         fp->set_array_offsets(1,1,1);
07290         int nx2 = nox/2;
07291         int ny2 = ny/2;
07292         int nz2 = nz/2;
07293         float *fint = image->get_data();
07294         for ( int iz = 1; iz <= nz; iz++) {
07295                 int jz=nz2-iz+1; if(jz<0) jz += nz;
07296                 for ( int iy = 1; iy <= ny; iy++) {
07297                         int jy=ny2-iy+1; if(jy<0) jy += ny;
07298                         for ( int ix = 1; ix <= lsd2; ix++) {
07299                                 int jx = nx2-ix+1;
07300                                 fp->cmplx(ix,iy,iz) *= fint(jx,jy,jz);
07301                         }
07302                 }
07303         }
07304 
07305         fp->set_ri(1);
07306         fp->set_fftpad(true);
07307         fp->set_attr("npad", 1);
07308         if (nx%2 == 1) fp->set_fftodd(true);
07309         else fp->set_fftodd(false);
07310         if(RetReal) {
07311                 fp->do_ift_inplace();
07312                 fp->depad();
07313         }
07314         fp->set_array_offsets(0,0,0);
07315         fp->update();
07316 
07317         return fp;
07318 }
07319 #undef   fint
07320 #define  fint(jx,jy,jz)  fint[jx + (jy + jz*ny)*(size_t)nx]
07321 #define  fout(jx,jy,jz)  fout[jx + (jy + jz*ny)*(size_t)nx]

float EMData::find_3d_threshold float  mass,
float  pixel_size
 

Definition at line 5929 of file emdata_sparx.cpp.

References C, nx, and ny.

05956                                            {
05957                 x1=thr2;
05958                 x2=thr2+C*(thr3-thr2);
05959         } else {
05960                 x2=thr2;
05961                 x1=thr2-C*(thr2-thr1);
05962         }
05963 
05964         int cnt1=0,cnt2=0;
05965         for (size_t i=0;i<size;++i) {
05966                 if(rdata[i]>=x1)  cnt1++;
05967                 if(rdata[i]>=x2)  cnt2++;
05968         }
05969         float LF1 = static_cast<float>( cnt1 - ILE );
05970         float F1 = LF1*LF1;
05971         float LF2 = static_cast<float>( cnt2 - ILE );
05972         float F2 = LF2*LF2;
05973 
05974         while ((LF1 != 0 || LF2 != 0) && (fabs(LF1-LF2) >= 1.f) && (abs(x1-x2) > (double)pow(10.0,-5) && abs(x1-x3) > (double)pow(10.0,-5) && abs(x2-x3) > (double)pow(10.0,-5)))
05975         {
05976                 if(F2 < F1) {
05977                         x0=x1;
05978                         x1=x2;
05979                         x2 = R*x1 + C*x3;
05980                         F1=F2;
05981                         int cnt=0;
05982                         for(size_t i=0;i<size;++i)
05983                                 if(rdata[i]>=x2)
05984                                         cnt++;
05985                         LF2 = static_cast<float>( cnt - ILE );
05986                         F2 = LF2*LF2;
05987                 } else {
05988                         x3=x2;
05989                         x2=x1;
05990                         x1=R*x2 + C*x0;
05991                         F2=F1;
05992                         int cnt=0;
05993                         for(size_t i=0;i<size;++i)
05994                                 if(rdata[i]>=x1)
05995                                         cnt++;
05996                         LF1 = static_cast<float>( cnt - ILE );
05997                         F1 = LF1*LF1;
05998                 }
05999         }
06000 
06001         if(F1 < F2) {
06002                 ILE = static_cast<int> (LF1 + ILE);
06003                 THR = x1;
06004         } else {
06005                 ILE = static_cast<int> (LF2 + ILE);
06006                 THR = x2;
06007         }
06008         return THR;
06009 
06010 }
06011 #undef avagadro
06012 #undef density_protein

vector< Pixel > EMData::find_pixels_with_value float  val  ) 
 

Find pixels in the image with exactly the specified values.

Parameters:
val The value to look for
Returns:
An array of pixels with the specified values

Definition at line 687 of file emdata_metadata.cpp.

References get_value_at(), ImageFormatException, and is_complex().

00688 {
00689         ENTERFUNC;
00690         
00691         if ( is_complex() ) throw ImageFormatException("Error - find_pixels_with_value real only");
00692 
00693         vector<Pixel> result;
00694 
00695         for (int k = 0; k < nz; k++) {
00696                 for (int j = 0; j < ny; j++) {
00697                         for (int i = 0; i < nx; i++) {
00698                                 if (get_value_at(i,j,k)==val) result.push_back(Pixel(i,j,k,val));
00699                         }
00700                 }
00701         }
00702 
00703         EXITFUNC;
00704         return result;
00705 }

EMData * EMData::Four_ds int  nxni,
int  nyni = 0,
int  nzni = 0,
bool  RetReal = true
 

Definition at line 7139 of file emdata_sparx.cpp.

References ny.

07142                    {
07143                 nyn = nyni;
07144                 if(nz > 1) {
07145                         nzn = nzni;
07146                 }  else {
07147                         nzn = 1;
07148                 }
07149         } else {
07150                 nyn = 1; nzn = 1;
07151         }
07152         lsd = nx-2 + 2 - nx%2;
07153         lsdn = nxn + 2 - nxn%2;
07154 //  do out of place ft
07155         EMData *temp_ft = this->copy();
07156         EMData *ret = this->copy();
07157         ret->set_size(lsdn, nyn, nzn);
07158         ret->to_zero();
07159         float *fout = ret->get_data();
07160         float *fint = temp_ft->get_data();
07161 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07162 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07163 //      float  sq2 = 1.0f/std::sqrt(2.0f);
07164         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
07165         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
07166         inx = nxn-(nx-2); iny = nyn - ny; inz = nzn - nz;
07167         for (j=1; j<=nyn; j++)
07168                 for (i=1; i<=lsdn; i++)
07169                         fout(i,j,1)=fint((i-1)/2*4+2-i%2,j*2-1,1);
07170         ret->set_complex(true);
07171         ret->set_ri(1);
07172         //ret->set_fftpad(true);
07173         //ret->set_attr("npad", 1);
07174         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07175         if(RetReal) {
07176                 ret->do_ift_inplace();
07177                 ret->depad();
07178         }
07179         ret->update();
07180 
07181         delete temp_ft;
07182         temp_ft = 0;
07183         return ret;
07184 }
07185 
07186 EMData *EMData::Four_shuf_ds_cen_us(int nxn, int nyni, int, bool RetReal) {

EMData * EMData::Four_shuf_ds_cen_us int  nxni,
int  nyni = 0,
int  nzni = 0,
bool  RetReal = true
 

Definition at line 7188 of file emdata_sparx.cpp.

References fint, fout, nx, and ny.

07210                                               {
07211                         int g = (i-1)/2+1;
07212                         if ((g+j)%2 == 0) {
07213                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1+ny/2,1);
07214                         } else {
07215                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1+ny/2,1);
07216                         }
07217                 }
07218 
07219         for (j=ny/4+1; j<=ny/4+1; j++)
07220                 for (i=1; i<=(nx-2)/2+2; i++) {
07221                         int g = (i-1)/2+1;
07222                         if ((g+j)%2 == 0) {
07223                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07224                         } else {
07225                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07226                         }
07227                 }
07228 
07229         for (j=ny/4+2; j<=ny/2; j++)
07230                 for (i=1; i<=(nx-2)/2+2; i++) {
07231                         int g = (i-1)/2+1;
07232                         if ((g+j)%2 == 0) {
07233                                 fout(i,j+ny/2,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07234                         } else {
07235                                 fout(i,j+ny/2,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07236                         }
07237                 }
07238 
07239         if (nx%2 == 0) {
07240                 for (j=1; j<=nyn; j++) {
07241                         fout((nx-2)/2+1,j,1) *= sq2;
07242                         fout((nx-2)/2+2,j,1) *= sq2;
07243                 }
07244                 for (i=1; i<=lsd/2+1; i++) {
07245                         fout(i,ny/4+1+ny/2,1) = sq2*fout(i,ny/4+1,1);
07246                         fout(i,ny/4+1,1) *= sq2;
07247                 }
07248         }
07249 
07250         ret->set_complex(true);
07251         ret->set_ri(1);
07252 
07253         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07254         if(RetReal) {
07255                 ret->do_ift_inplace();
07256                 ret->depad();
07257         }
07258         ret->update();
07259 
07260         delete temp_ft;
07261         temp_ft = 0;
07262         return ret;
07263 }
07264 
07265 #undef fint

EMData * EMData::fouriergridrot2d float  ang,
float  scale,
Util::KaiserBessel kb
 

Definition at line 4085 of file emdata_sparx.cpp.

References nx, and ny.

04109                                                   {
04110                 float ycang = iy*cang;
04111                 float ysang = iy*sang;
04112                 for (int ix = 0; ix <= nxhalf; ix++) {
04113                         float nuxold = (ix*cang - ysang)*scale;
04114                         float nuyold = (ix*sang + ycang)*scale;
04115                         if (nuxold*nuxold+nuyold*nuyold<cir) result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04116                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04117                 }
04118         }
04119         result->set_array_offsets();
04120         result->fft_shuffle(); // reset to an unshuffled result
04121         result->update();
04122         set_array_offsets();
04123         fft_shuffle(); // reset to an unshuffled complex image
04124         return result;
04125 }
04126 
04127 EMData* EMData::fouriergridrot_shift2d(float ang, float sx, float sy, Util::KaiserBessel& kb) {

EMData * EMData::fouriergridrot_shift2d float  ang,
float  sx,
float  sy,
Util::KaiserBessel kb
 

Definition at line 4129 of file emdata_sparx.cpp.

References nx, and ny.

04150                                                   {
04151                 float ycang = iy*cang;
04152                 float ysang = iy*sang;
04153                 for (int ix = 0; ix <= nxhalf; ix++) {
04154                         float nuxold = ix*cang - ysang;
04155                         float nuyold = ix*sang + ycang;
04156                         result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04157                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04158                         float phase_ang = temp*(sx*ix+sy*iy);
04159                         result->cmplx(ix,iy) *= complex<float>(cos(phase_ang), sin(phase_ang));
04160                 }
04161         }
04162         result->set_array_offsets();
04163         result->fft_shuffle(); // reset to an unshuffled result
04164         result->update();
04165         set_array_offsets();
04166         fft_shuffle(); // reset to an unshuffled complex image
04167         return result;
04168 }
04169 
04170 #undef QUADPI

EMData * EMData::FourInterpol int  nxni,
int  nyni = 0,
int  nzni = 0,
bool  RetReal = true
 

Definition at line 6802 of file emdata_sparx.cpp.

References ny.

06807                    {
06808                 nyn = nyni;
06809                 if(nz > 1) {
06810                         nzn = nzni;
06811                 }  else {
06812                         nzn = 1;
06813                 }
06814         } else {
06815                 nyn = 1; nzn = 1;
06816         }
06817         if(nxn<nx || nyn<ny || nzn<nz)  throw ImageDimensionException("Cannot reduce the image size");
06818         lsd = nx + 2 - nx%2;
06819         lsdn = nxn + 2 - nxn%2;
06820 //  do out of place ft
06821         EMData *temp_ft = do_fft();
06822         EMData *ret = this->copy();
06823         ret->set_size(lsdn, nyn, nzn);
06824         ret->to_zero();
06825         float *fout = ret->get_data();
06826         float *fint = temp_ft->get_data();
06827 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
06828 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
06829         float  sq2 = 1.0f/std::sqrt(2.0f);
06830         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
06831         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
06832         inx = nxn-nx; iny = nyn - ny; inz = nzn - nz;
06833         for (k=1; k<=nz/2+1; k++) for (j=1; j<=ny/2+1; j++) for (i=1; i<=lsd; i++) fout(i,j,k)=fint(i,j,k);
06834         if(nyn>1) {
06835         //cout << "  " <<nxn<<"  " <<nyn<<" A " <<nzn<<endl;
06836                 for (k=1; k<=nz/2+1; k++) for (j=ny/2+2+iny; j<=nyn; j++) for (i=1; i<=lsd; i++) fout(i,j,k)=fint(i,j-iny,k);
06837                 if(nzn>1) {
06838                         for (k=nz/2+2+inz; k<=nzn; k++) {
06839                                 for (j=1; j<=ny/2+1; j++) {
06840                                         for (i=1; i<=lsd; i++) {
06841                                                 fout(i,j,k)=fint(i,j,k-inz);
06842                                         }
06843                                 }
06844                                 for (j=ny/2+2+iny; j<=nyn; j++) {
06845                                         for (i=1; i<=lsd; i++) {
06846                                                 fout(i,j,k)=fint(i,j-iny,k-inz);
06847                                         }
06848                                 }
06849                         }
06850                 }
06851         }
06852 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
06853 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
06854 //       ELEMENT.
06855         if(nx%2 == 0 && inx !=0) {
06856                 for (k=1; k<=nzn; k++) {
06857                         for (j=1; j<=nyn; j++) {
06858                                 fout(nx+1,j,k) *= sq2;
06859                                 fout(nx+2,j,k) *= sq2;
06860                         }
06861                 }
06862                 if(nyn>1) {
06863                         for (k=1; k<=nzn; k++) {
06864                           for (i=1; i<=lsd; i++) {
06865                             fout(i,ny/2+1+iny,k) = sq2*fout(i,ny/2+1,k);
06866                             fout(i,ny/2+1,k) *= sq2;
06867                           }
06868                         }
06869                         if(nzn>1) {
06870                                 for (j=1; j<=nyn; j++) {
06871                                         for (i=1; i<=lsd; i++) {
06872                                                 fout(i,j,nz/2+1+inz) = sq2*fout(i,j,nz/2+1);
06873                                                 fout(i,j,nz/2+1) *= sq2;
06874                                         }
06875                                 }
06876                         }
06877                 }
06878         }
06879         ret->set_complex(true);
06880 /*
06881 //  For padding from odd to even dimension additional shift by 1 pixel is necessary.
06882         float  xshift = 0.f, yshift = 0.f, zshift = 0.f;
06883         int nyn2, nzn2;
06884         if(nxn > nx && nx%2 == 1)  xshift = 1.0f;
06885         if(ny > 1) {
06886                 if(nyn > ny && ny%2 == 1)  yshift = 1.0f;
06887                 nyn2 = nyn/2;
06888                 if(nz > 1) {
06889                         if(nzn > nz && nz%2 == 1)  zshift = 1.0f;
06890                         nzn2 = nzn/2;
06891                 }  else {
06892                         nzn2 = 0;
06893                 }
06894         } else {
06895                 nyn2 = 0; nzn2 = 0;
06896         }
06897         if(xshift == 1.0 || yshift == 1.0 || zshift == 1.0)  {
06898                 ret->set_array_offsets(1,1,1);
06899                 int  lsdn2 = lsd/2;
06900                 for (int iz = 1; iz <= nzn; iz++) {
06901                         int jz=iz-1; if(jz>nzn2) jz=jz-nzn;
06902                         for (int iy = 1; iy <= nyn; iy++) {
06903                                 int jy=iy-1; if(jy>nyn2) jy=jy-nyn;
06904                                 for (int ix = 1; ix <= lsdn2; ix++) {
06905                                         int jx=ix-1;
06906                                         ret->cmplx(ix,iy,iz) *=
06907                                         exp(-float(twopi)*iimag*(xshift*jx/nxn + yshift*jy/nyn+ zshift*jz/nzn));
06908                                 }
06909                         }
06910                 }
06911                 ret->set_array_offsets(0,0,0);
06912         }*/
06913         ret->set_ri(1);
06914         ret->set_fftpad(true);
06915         ret->set_attr("npad", 1);
06916         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
06917         if(RetReal) {
06918                 ret->do_ift_inplace();
06919                 ret->depad();
06920         }
06921         ret->update();
06922 
06923         /*Dict d1 = temp_ft->get_attr_dict();
06924         Dict d2 = ret->get_attr_dict();
06925         printf("-----------------Attribute Dict for temp_ft--------------\n");
06926         EMUtil::dump_dict(d1);
06927         printf("-----------------Attribute Dict for ret--------------\n");
06928         EMUtil::dump_dict(d2);*/
06929         delete temp_ft;
06930         temp_ft = 0;
06931         return ret;
06932 }
06933 
06934 EMData *EMData::FourTruncate(int nxn, int nyni, int nzni, bool RetReal) {

EMData * EMData::FourTruncate int  nxni,
int  nyni = 0,
int  nzni = 0,
bool  RetReal = true
 

Truncate Fourier transform of an image, it will reduce its size.

(It is a form of decimation).

Parameters:
[in] nxni new x size (has to be larger/equal than the original x size)
[in] nyni new y size (has to be larger/equal than the original y size)
[in] nzni new z size (has to be larger/equal than the original z size)
RetReal 
Returns:
New truncated up image.

Definition at line 6936 of file emdata_sparx.cpp.

References ny.

06943                    {
06944                 nyn = nyni;
06945                 if(nz > 1) {
06946                         nzn = nzni;
06947                 }  else {
06948                         nzn = 1;
06949                 }
06950         } else {
06951                 nyn = 1; nzn = 1;
06952         }
06953         if (is_complex()) {
06954                 nx = nx - 2 + nx%2;
06955                 fint = get_data();
06956         } else {
06957                 //  do out of place ft
06958                 temp_ft = do_fft();
06959                 fint = temp_ft->get_data();
06960         }
06961         if(nxn>nx || nyn>ny || nzn>nz)  throw ImageDimensionException("Cannot increase the image size");
06962         lsd = nx + 2 - nx%2;
06963         lsdn = nxn + 2 - nxn%2;
06964         EMData *ret = this->copy_head();
06965         ret->set_size(lsdn, nyn, nzn);
06966         float *fout = ret->get_data();
06967 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
06968 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
06969         //float  sq2 = std::sqrt(2.0f);
06970         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
06971         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
06972         inx = nx - nxn;  iny = ny - nyn;  inz = nz - nzn;
06973         for (k=1; k<=nzn/2+1; k++) for (j=1; j<=nyn/2+1; j++) for (i=1; i<=lsdn; i++) fout(i,j,k)=fint(i,j,k);
06974         if(nyn>1) {
06975                 for (k=1; k<=nzn/2+1; k++) for (j=nyn/2+2; j<=nyn; j++) for (i=1; i<=lsdn; i++) fout(i,j,k)=fint(i,j+iny,k);
06976                 if(nzn>1) {
06977                         for (k=nzn/2+2; k<=nzn; k++) {
06978                                 for (j=1; j<=nyn/2+1; j++) {
06979                                         for (i=1; i<=lsdn; i++) {
06980                                                 fout(i,j,k)=fint(i,j,k+inz);
06981                                         }
06982                                 }
06983                                 for (j=nyn/2+2; j<=nyn; j++) {
06984                                         for (i=1; i<=lsdn; i++) {
06985                                                 fout(i,j,k)=fint(i,j+iny,k+inz);
06986                                         }
06987                                 }
06988                         }
06989                 }
06990         }
06991 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
06992 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
06993 //       ELEMENT.
06994         /*
06995         if(nxn%2 == 0 && inx !=0) {
06996                 for (k=1; k<=nzn; k++) {
06997                         for (j=1; j<=nyn; j++) {
06998                                 fout(nxn+1,j,k) *= sq2;
06999                                 fout(nxn+2,j,k) *= sq2;
07000                         }
07001                 }
07002                 if(nyn>1) {
07003                         for (k=1; k<=nzn; k++) {
07004                           for (i=1; i<=lsdn; i++) {
07005                             fout(i,nyn/2+1+iny,k) = sq2*fout(i,nyn/2+1,k);
07006                             fout(i,nyn/2+1,k) *= sq2;
07007                           }
07008                         }
07009                         if(nzn>1) {
07010                                 for (j=1; j<=nyn; j++) {
07011                                         for (i=1; i<=lsdn; i++) {
07012                                                 fout(i,j,nzn/2+1+inz) = sq2*fout(i,j,nzn/2+1);
07013                                                 fout(i,j,nzn/2+1) *= sq2;
07014                                         }
07015                                 }
07016                         }
07017                 }
07018         }*/
07019         ret->set_complex(true);
07020         ret->set_ri(1);
07021         ret->set_fftpad(true);
07022         ret->set_attr("npad", 1);
07023         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07024         if(RetReal) {
07025                 ret->do_ift_inplace();
07026                 ret->depad();
07027         }
07028         ret->update();
07029 
07030         /*Dict d1 = temp_ft->get_attr_dict();
07031         Dict d2 = ret->get_attr_dict();
07032         printf("-----------------Attribute Dict for temp_ft--------------\n");
07033         EMUtil::dump_dict(d1);
07034         printf("-----------------Attribute Dict for ret--------------\n");
07035         EMUtil::dump_dict(d2);*/
07036         if (!is_complex()) {
07037                 delete temp_ft;
07038                 temp_ft = 0;
07039         }
07040         return ret;
07041 }
07042 /*
07043 EMData *EMData::FourInterpol_i(int nxn, int nyni, int nzni, bool RetReal) {

void EMData::free_memory  ) 
 

Free memory associated with this EMData Called in destructor and in assignment operator.

Definition at line 55 of file emdata_core.cpp.

References EMAN::EMUtil::em_free(), rdata, rot_fp, and supp.

Referenced by operator=(), and ~EMData().

00056 {
00057         ENTERFUNC;
00058         if (rdata) {
00059                 EMUtil::em_free(rdata);
00060                 rdata = 0;
00061         }
00062 
00063         if (supp) {
00064                 EMUtil::em_free(supp);
00065                 supp = 0;
00066         }
00067 
00068         if (rot_fp != 0)
00069         {
00070                 delete rot_fp;
00071                 rot_fp = 0;
00072         }
00073         /*
00074         nx = 0;
00075         ny = 0;
00076         nz = 0;
00077         nxy = 0;
00078          */
00079 
00080         EXITFUNC;
00081 }

void EMData::free_rdata  ) 
 

Free rdata memory associated with this EMData Called in CUDA.

Definition at line 83 of file emdata_core.cpp.

References EMAN::EMUtil::em_free(), and rdata.

00084 {
00085         ENTERFUNC;
00086         if (rdata) {
00087                 EMUtil::em_free(rdata);
00088                 rdata = 0;
00089         }
00090         EXITFUNC;
00091 }

MCArray2D EMData::get_2dcview int  x0,
int  y0
const
 

Get complex image raw pixel data in a 2D multi-array format.

The data coordinates is translated by (x0,y0) such that array[y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0). The array shares the memory space with the image data.

It should be used on 2D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
Returns:
2D multi-array format of the raw data.

Definition at line 1024 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, EMAN::MCArray2D, nx, and ny.

01025 {
01026         const int ndims = 2;
01027         if (get_ndim() != ndims) {
01028                 throw ImageDimensionException("2D only");
01029         }
01030         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
01031         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
01032         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
01033         boost::array<std::size_t,ndims> bases={{x0, y0}};
01034         marray.reindex(bases);
01035         return marray;
01036 }

MCArray2D EMData::get_2dcview  )  const
 

Get complex image raw pixel data in a 2D multi-array format.

The array shares the memory space with the image data.

It should be used on 2D image only.

Returns:
2D multi-array format of the raw data.

Definition at line 965 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, EMAN::MCArray2D, nx, and ny.

00966 {
00967         const int ndims = 2;
00968         if (get_ndim() != ndims) {
00969                 throw ImageDimensionException("2D only");
00970         }
00971         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00972         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00973         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00974         return marray;
00975 }

MArray2D EMData::get_2dview int  x0,
int  y0
const
 

Get image raw pixel data in a 2D multi-array format.

The data coordinates is translated by (x0,y0) such that array[y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0). The array shares the memory space with the image data.

It should be used on 2D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
Returns:
2D multi-array format of the raw data.

Definition at line 999 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, EMAN::MArray2D, and ny.

01000 {
01001         const int ndims = 2;
01002         if (get_ndim() != ndims) {
01003                 throw ImageDimensionException("2D only");
01004         }
01005         boost::array<std::size_t,ndims> dims = {{nx, ny}};
01006         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
01007         boost::array<std::size_t,ndims> bases={{x0, y0}};
01008         marray.reindex(bases);
01009         return marray;
01010 }

MArray2D EMData::get_2dview  )  const
 

Get image raw pixel data in a 2D multi-array format.

The array shares the memory space with the image data. Notice: the subscription order is d[y][x] in Python, it's d[x][y] in C++

It should be used on 2D image only.

Returns:
2D multi-array format of the raw data.

Definition at line 944 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, EMAN::MArray2D, and ny.

00945 {
00946         const int ndims = 2;
00947         if (get_ndim() != ndims) {
00948                 throw ImageDimensionException("2D only");
00949         }
00950         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00951         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00952         return marray;
00953 }

MCArray3D EMData::get_3dcview int  x0,
int  y0,
int  z0
const
 

Get complex image raw pixel data in a 3D multi-array format.

The data coordinates is translated by (x0,y0,z0) such that array[z0][y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0,z0). The array shares the memory space with the image data.

It should be used on 3D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
z0 Z-axis translation amount.
Returns:
3D multi-array format of the raw data.

Definition at line 1039 of file emdata_metadata.cpp.

References get_data(), EMAN::MCArray3D, nx, and nz.

01040 {
01041         const int ndims = 3;
01042         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
01043         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
01044         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
01045         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
01046         marray.reindex(bases);
01047         return marray;
01048 }

MCArray3D EMData::get_3dcview  )  const
 

Get complex image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data.

It should be used on 3D image only.

Returns:
3D multi-array format of the raw data.

Definition at line 978 of file emdata_metadata.cpp.

References get_data(), EMAN::MCArray3D, nx, and nz.

00979 {
00980         const int ndims = 3;
00981         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00982         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00983         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00984         return marray;
00985 }

MCArray3D * EMData::get_3dcviewptr  )  const
 

Get pointer to a complex image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data.

It should be used on 3D image only.

Returns:
Pointer to a 3D multi-array format of the raw data.

Definition at line 988 of file emdata_metadata.cpp.

References get_data(), EMAN::MCArray3D, nx, and nz.

00989 {
00990         const int ndims = 3;
00991         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00992         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00993         MCArray3D* marray = new MCArray3D(cdata, dims,
00994                                                                           boost::fortran_storage_order());
00995         return marray;
00996 }

MArray3D EMData::get_3dview int  x0,
int  y0,
int  z0
const
 

Get image raw pixel data in a 3D multi-array format.

The data coordinates is translated by (x0,y0,z0) such that array[z0][y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0,z0). The array shares the memory space with the image data.

It should be used on 3D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
z0 Z-axis translation amount.
Returns:
3D multi-array format of the raw data.

Definition at line 1013 of file emdata_metadata.cpp.

References get_data(), EMAN::MArray3D, and nz.

01014 {
01015         const int ndims = 3;
01016         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
01017         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
01018         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
01019         marray.reindex(bases);
01020         return marray;
01021 }

MArray3D EMData::get_3dview  )  const
 

Get image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data. Notice: the subscription order is d[z][y][x] in Python, it's d[x][y][z] in C++ --grant Tang

It should be used on 3D image only.

Returns:
3D multi-array format of the raw data.

Definition at line 956 of file emdata_metadata.cpp.

References get_data(), EMAN::MArray3D, and nz.

00957 {
00958         const int ndims = 3;
00959         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00960         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00961         return marray;
00962 }

float EMData::get_amplitude_thres float  thres  ) 
 

return the FFT amplitude which is greater than thres

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The FFT amplitude which is greater than thres .

Definition at line 1327 of file emdata_metadata.cpp.

References get_data_as_vector(), get_fft_amplitude(), InvalidValueException, and LOGERR.

01328 {
01329 
01330         if (thres < 0 || thres > 1){
01331                 LOGERR("threshold bust be between 0 and 1.");
01332                 throw InvalidValueException(thres, "thres: 0 <= thres <= 1");
01333         }
01334                 
01335         EMData * amps = get_fft_amplitude();
01336         vector<float> ampvector = amps->get_data_as_vector();
01337         // yes I realize this may be slow if the map is big, but then again this function is only suited for tomo alignments, which if you have a big map will be VERY slow anyways!
01338         sort (ampvector.begin(), ampvector.end()); 
01339         int thresidx = int(thres * ampvector.size());
01340         float thresamp =  ampvector[thresidx];
01341 
01342         return thresamp;
01343 }

vector<int> EMAN::EMData::get_array_offsets  )  [inline]
 

Definition at line 2374 of file emdata.h.

Referenced by EMAN::QuadMinDotCmp::cmp(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), nn(), nn_ctf(), nn_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), rotavg(), EMAN::rsconvolution(), symplane0(), symplane1(), and symplane2().

EMObject EMData::get_attr const string &  attr_name  )  const
 

The generic way to get any image header information given a header attribute name.

If the attribute does not exist, it will raise an exception.

Parameters:
attr_name The header attribute name.
Returns:
The attribute value.
Exceptions:
NotExistingObjectException when attribute not exist

Definition at line 1060 of file emdata_metadata.cpp.

References attr_dict, BadAllocException, changecount, copy(), data, flags, get_data(), greaterthan(), EMAN::Dict::has_key(), ImageFormatException, is_complex(), key, NotExistingObjectException, nx, ny, t, and update_stat().

Referenced by EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::TomoAverager::add_image(), ali3d_d(), EMAN::RefineAlignerCG::align(), EMAN::RefineAligner::align(), EMAN::SymAlignProcessor::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::RotationalAligner::align(), EMAN::Util::BPCQ(), calc_center_density(), calc_hist(), EMAN::NormalizeStdProcessor::calc_mean(), EMAN::NormalizeMaxMinProcessor::calc_mean(), EMAN::NormalizeMaxMinProcessor::calc_sigma(), EMAN::NormalizeUnitSumProcessor::calc_sigma(), EMAN::NormalizeUnitProcessor::calc_sigma(), EMAN::NormalizeProcessor::calc_sigma(), calc_sigma_diff(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::Util::constrained_helix(), EMAN::Util::constrained_helix_test(), EMAN::SetSFProcessor::create_radial_func(), EMAN::MatchSFProcessor::create_radial_func(), EMAN::LowpassAutoBProcessor::create_radial_func(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), EMAN::IterationAverager::finish(), EMAN::TomoAverager::finish(), get_attr_default(), EMAN::AddSigmaNoiseProcessor::get_sigma(), EMAN::Util::get_transform_params(), wustl_mm::SkeletonMaker::VolumeData::GetOriginX(), wustl_mm::SkeletonMaker::VolumeData::GetOriginY(), wustl_mm::SkeletonMaker::VolumeData::GetOriginZ(), wustl_mm::SkeletonMaker::VolumeData::GetSpacingX(), wustl_mm::SkeletonMaker::VolumeData::GetSpacingY(), wustl_mm::SkeletonMaker::VolumeData::GetSpacingZ(), EMAN::Util::hans(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::image_mutation(), EMAN::Util::infomask(), EMAN::FourierPixelInserter3D::init(), EMAN::nn4_ctf_rectReconstructor::insert_padfft_slice(), EMAN::nn4_ctfReconstructor::insert_padfft_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), little_big_dot(), main(), EMAN::PointArray::match_points(), EMAN::Util::multiref_polar_ali_2d_local(), EMAN::Util::multiref_polar_ali_2d_local_psi(), EMAN::Util::multiref_polar_ali_helical_90_local(), EMAN::Util::multiref_polar_ali_helical_local(), nn_ctf(), nn_ctf_applied(), nn_SSNR_ctf(), EMAN::Util::pad(), EMAN::LowpassAutoBProcessor::preprocess(), EMAN::Wiener2DFourierProcessor::process(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::TomoTiltAngleWeightProcessor::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::NSigmaClampingProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::StripeXYProcessor::process_inplace(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), ReadStackandDist(), ReadStackandDist_Cart(), recons3d_4nn(), and EMAN::PointArray::set_from_density_map().

01061 {
01062         ENTERFUNC;
01063         
01064         if ((flags & EMDATA_NEEDUPD) && (key != "is_fftpad") && (key != "xform.align2d")){update_stat();} //this gives a spped up of 7.3% according to e2speedtest
01065                 
01066         size_t size = (size_t)nx * ny * nz;
01067         if (key == "kurtosis") {
01068                 float mean = attr_dict["mean"];
01069                 float sigma = attr_dict["sigma"];
01070 
01071                 float *data = get_data();
01072                 double kurtosis_sum = 0;
01073 
01074                 for (size_t k = 0; k < size; ++k) {
01075                         float t = (data[k] - mean) / sigma;
01076                         float tt = t * t;
01077                         kurtosis_sum += tt * tt;
01078                 }
01079 
01080                 float kurtosis = (float)(kurtosis_sum / size - 3.0);
01081                 return kurtosis;
01082         }
01083         else if (key == "skewness") {
01084                 float mean = attr_dict["mean"];
01085                 float sigma = attr_dict["sigma"];
01086 
01087                 float *data = get_data();
01088                 double skewness_sum = 0;
01089                 for (size_t k = 0; k < size; ++k) {
01090                         float t = (data[k] - mean) / sigma;
01091                         skewness_sum +=  t * t * t;
01092                 }
01093                 float skewness = (float)(skewness_sum / size);
01094                 return skewness;
01095         }
01096         else if (key == "median")
01097         {
01098                 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
01099                 size_t n = size;
01100                 float* tmp = new float[n];
01101                 float* d = get_data();
01102                 if (tmp == 0 ) throw BadAllocException("Error - could not create deep copy of image data");
01103 //              for(size_t i=0; i < n; ++i) tmp[i] = d[i]; // should just be a memcpy
01104                 std::copy(d, d+n, tmp);
01105                 qsort(tmp, n, sizeof(float), &greaterthan);
01106                 float median;
01107                 if (n%2==1) median = tmp[n/2];
01108                 else median = (tmp[n/2-1]+tmp[n/2])/2.0f;
01109                 delete [] tmp;
01110                 return median;
01111         }
01112         else if (key == "nonzero_median")
01113         {
01114                 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
01115                 vector<float> tmp;
01116                 size_t n = size;
01117                 float* d = get_data();
01118                 for( size_t i = 0; i < n; ++i ) {
01119                         if ( d[i] != 0 ) tmp.push_back(d[i]);
01120                 }
01121                 sort(tmp.begin(), tmp.end());
01122                 unsigned int vsize = tmp.size();
01123                 float median;
01124                 if (vsize%2==1) median = tmp[vsize/2];
01125                 else median = (tmp[vsize/2-1]+tmp[vsize/2])/2.0f;
01126                 return median;
01127         }
01128         else if (key == "changecount") return EMObject(changecount);
01129         else if (key == "nx") {
01130                 return nx;
01131         }
01132         else if (key == "ny") {
01133                 return ny;
01134         }
01135         else if (key == "nz") {
01136                 return nz;
01137         }
01138 
01139         if(attr_dict.has_key(key)) {
01140                 return attr_dict[key];
01141         }
01142         else {
01143                 throw NotExistingObjectException(key, "The requested key does not exist");
01144         }
01145 
01146         EXITFUNC;
01147 }

EMObject EMData::get_attr_default const string &  attr_name,
const EMObject em_obj = EMObject()
const
 

The generic way to get any image header information given a header attribute name.

If the attribute does not exist, it will return a default EMObject() object, which will be converted to None in Python. Or return any object user submit.

Parameters:
attr_name The header attribute name.
em_obj the default attribute to return when this attr_name not exist in attr_dict
Returns:
The attribute value, default to None.

Definition at line 1149 of file emdata_metadata.cpp.

References attr_dict, get_attr(), EMAN::Dict::has_key(), and key.

Referenced by calc_radial_dist(), EMAN::FRCCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierReconstructor::insert_slice(), onelinenn_ctf(), onelinenn_ctf_applied(), EMAN::padfft_slice(), EMAN::CtfSimProcessor::process(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), and rotavg().

01150 {
01151         ENTERFUNC;
01152 
01153         if(attr_dict.has_key(key)) {
01154                 return get_attr(key);
01155         }
01156         else {
01157                 return em_obj;
01158         }
01159 
01160         EXITFUNC;
01161 }

Dict EMData::get_attr_dict  )  const
 

Get the image attribute dictionary containing all the image attribute names and attribute values.

Returns:
The image attribute dictionary containing all attribute names and values.

Definition at line 1163 of file emdata_metadata.cpp.

References attr_dict, and update_stat().

Referenced by EMAN::TestUtil::dump_emdata(), main(), EMAN::NewFourierProcessor::preprocess(), EMAN::LowpassAutoBProcessor::preprocess(), EMAN::FourierProcessor::preprocess(), EMAN::HighpassAutoPeakProcessor::preprocess(), EMAN::NewFourierProcessor::preprocessandconvertpars(), EMAN::TransformProcessor::process(), EMAN::NewLowpassGaussProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::NewFourierProcessor::setbutterworthdefaults(), and EMAN::TestUtil::verify_image_file_by_mode().

01164 {
01165         if(rdata) {
01166                 update_stat();
01167         }
01168 
01169         Dict tmp=Dict(attr_dict);
01170         tmp["nx"]=nx;
01171         tmp["ny"]=ny;
01172         tmp["nz"]=nz;
01173         tmp["changecount"]=changecount;
01174 
01175         return tmp;
01176 }

int EMAN::EMData::get_changecount  )  const [inline]
 

Definition at line 1253 of file emdata.h.

float EMData::get_circle_mean  ) 
 

Calculates the circular edge mean by applying a circular mask on 'this' image.

Returns:
The circular edge mean.

Definition at line 767 of file emdata_metadata.cpp.

References data, EMData(), get_data(), nx, ny, nz, process_inplace(), set_size(), and to_one().

Referenced by EMAN::NormalizeCircleMeanProcessor::calc_mean().

00768 {
00769         ENTERFUNC;
00770 
00771         static bool busy = false;
00772         static EMData *mask = 0;
00773 
00774         while (busy);
00775         busy = true;
00776 
00777         if (!mask || !EMUtil::is_same_size(this, mask)) {
00778                 if (!mask) {
00779                         mask = new EMData();
00780                 }
00781                 mask->set_size(nx, ny, nz);
00782                 mask->to_one();
00783 
00784                 float radius = (float)(ny / 2 - 2);
00785                 mask->process_inplace("mask.sharp", Dict("inner_radius", radius - 1,
00786                                                                            "outer_radius", radius + 1));
00787 
00788         }
00789         double n = 0,s=0;
00790         float *d = mask->get_data();
00791         float * data = get_data();
00792         size_t size = (size_t)nx*ny*nz;
00793         for (size_t i = 0; i < size; ++i) {
00794                 if (d[i]) { n+=1.0; s+=data[i]; }
00795         }
00796 
00797 
00798         float result = (float)(s/n);
00799         busy = false;
00800 
00801         EXITFUNC;
00802         return result;
00803 }

EMData * EMData::get_clip const Region area,
const float  fill = 0
const
 

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 576 of file emdata.cpp.

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

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

00577 {
00578         ENTERFUNC;
00579         if (get_ndim() != area.get_ndim()) {
00580                 LOGERR("cannot get %dD clip out of %dD image", area.get_ndim(),get_ndim());
00581                 return 0;
00582         }
00583 
00584         EMData *result = new EMData();
00585 
00586         // Ensure that all of the metadata of this is stored in the new object
00587         // Originally added to ensure that euler angles were retained when preprocessing (zero padding) images
00588         // prior to insertion into the 3D for volume in the reconstruction phase (see reconstructor.cpp/h).
00589         result->attr_dict = this->attr_dict;
00590         int zsize = (int)area.size[2];
00591         if (zsize == 0 && nz <= 1) {
00592                 zsize = 1;
00593         }
00594         int ysize = (ny<=1 && (int)area.size[1]==0 ? 1 : (int)area.size[1]);
00595 
00596         if ( (int)area.size[0] < 0 || ysize < 0 || zsize < 0 )
00597         {
00598                 // Negative image dimensions not supported - added retrospectively by d.woolford (who didn't write get_clip but wrote clip_inplace)
00599                 throw ImageDimensionException("New image dimensions are negative - this is not supported in the the get_clip operation");
00600         }
00601 
00602 //#ifdef EMAN2_USING_CUDA
00603         // Strategy is always to prefer using the GPU if possible
00604 //      bool use_gpu = false;
00605 //      if ( gpu_operation_preferred() ) {
00606 //              result->set_size_cuda((int)area.size[0], ysize, zsize);
00607                 //CudaDataLock lock(this); // Just so we never have to recopy this data to and from the GPU
00608 //              result->get_cuda_data(); // Force the allocation - set_size_cuda is lazy
00609                 // Setting the value is necessary seeing as cuda data is not automatically zeroed
00610 //              result->to_value(fill); // This will automatically use the GPU.
00611 //              use_gpu = true;
00612 //      } else { // cpu == True
00613 //              result->set_size((int)area.size[0], ysize, zsize);
00614 //              if (fill != 0.0) { result->to_value(fill); };
00615 //      }
00616 //#else
00617         result->set_size((int)area.size[0], ysize, zsize);
00618         if (fill != 0.0) { result->to_value(fill); };
00619 //#endif //EMAN2_USING_CUDA
00620 
00621         int x0 = (int) area.origin[0];
00622         x0 = x0 < 0 ? 0 : x0;
00623 
00624         int y0 = (int) area.origin[1];
00625         y0 = y0 < 0 ? 0 : y0;
00626 
00627         int z0 = (int) area.origin[2];
00628         z0 = z0 < 0 ? 0 : z0;
00629 
00630         int x1 = (int) (area.origin[0] + area.size[0]);
00631         x1 = x1 > nx ? nx : x1;
00632 
00633         int y1 = (int) (area.origin[1] + area.size[1]);
00634         y1 = y1 > ny ? ny : y1;
00635 
00636         int z1 = (int) (area.origin[2] + area.size[2]);
00637         z1 = z1 > nz ? nz : z1;
00638         if (z1 <= 0) {
00639                 z1 = 1;
00640         }
00641 
00642         result->insert_clip(this,-((IntPoint)area.origin));
00643 
00644         if( attr_dict.has_key("apix_x") && attr_dict.has_key("apix_y") &&
00645                 attr_dict.has_key("apix_z") )
00646         {
00647                 if( attr_dict.has_key("origin_x") && attr_dict.has_key("origin_y") &&
00648                     attr_dict.has_key("origin_z") )
00649                 {
00650                         float xorigin = attr_dict["origin_x"];
00651                         float yorigin = attr_dict["origin_y"];
00652                         float zorigin = attr_dict["origin_z"];
00653 
00654                         float apix_x = attr_dict["apix_x"];
00655                         float apix_y = attr_dict["apix_y"];
00656                         float apix_z = attr_dict["apix_z"];
00657 
00658                         result->set_xyz_origin(xorigin + apix_x * area.origin[0],
00659                                                                    yorigin + apix_y * area.origin[1],
00660                                                                zorigin + apix_z * area.origin[2]);
00661                 }
00662         }
00663 
00664 //#ifdef EMAN2_USING_CUDA
00665 //      if (use_gpu) result->gpu_update();
00666 //      else result->update();
00667 //#else
00668         result->update();
00669 //#endif // EMAN2_USING_CUDA
00670 
00671 
00672         result->set_path(path);
00673         result->set_pathnum(pathnum);
00674 
00675         EXITFUNC;
00676         return result;
00677 }

EMData * EMData::get_col int  col_index  )  const
 

Get one column of a 2D images.

Parameters:
col_index Index of the column.
Exceptions:
ImageDimensionException If this image is not 2D.
Returns:
A 1D image with the column data.

Definition at line 696 of file emdata_core.cpp.

References EMData(), get_data(), get_ndim(), ImageDimensionException, nx, ny, set_size(), and update().

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

00697 {
00698         ENTERFUNC;
00699 
00700         if (get_ndim() != 2) {
00701                 throw ImageDimensionException("2D image only");
00702         }
00703 
00704         EMData *ret = new EMData();
00705         ret->set_size(ny, 1, 1);
00706         float *dst = ret->get_data();
00707         float *src = get_data();
00708 
00709         for (int i = 0; i < ny; i++) {
00710                 dst[i] = src[i * nx + col_index];
00711         }
00712 
00713         ret->update();
00714         EXITFUNC;
00715         return ret;
00716 }

std::complex< float > EMData::get_complex_at const int &  x,
const int &  y,
const int &  z
const
 

Get complex<float> value at x,y,z.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny x nz image, a nx+2 x ny x nz image will be produced, and values using this function can go from -nx/2 to nx/2 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. This function differs from cmplx() which will interpret x,y directly as pixel coordinates

Parameters:
x x coordinate
y y coordinate
z z coordinate
Returns:
The complex pixel at x,y

Definition at line 138 of file emdata_core.cpp.

References abs, nx, ny, nz, rdata, rdata, x, and y.

00138                                                                                     {
00139         if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return std::complex<float>(0,0);
00140 
00141         if (x<0) {
00142                 int idx=-x*2+(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nxy;
00143                 return std::complex<float>(rdata[idx],rdata[idx+1]);
00144         }
00145 
00146         int idx=x*2+(y<0?ny+y:y)*nx+(z<0?nz+z:z)*nxy;
00147         return std::complex<float>(rdata[idx],rdata[idx+1]);
00148 }

std::complex< float > EMData::get_complex_at const int &  x,
const int &  y
const
 

Get complex<float> value at x,y.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny image, a nx+2 x ny image will be produced, and values using this function can go from -nx/2-1 to nx/2+1 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. This function differs from cmplx() which will interpret x,y directly as pixel coordinates

Parameters:
x x coordinate
y y coordinate
Returns:
The complex pixel at x,y

Definition at line 130 of file emdata_core.cpp.

References abs, nx, ny, rdata, rdata, x, and y.

Referenced by EMAN::FourierWeightAverager::add_image(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), EMAN::FourierWeightAverager::finish(), and make_footprint().

00130                                                                        {
00131         if (abs(x)>=nx/2 || abs(y)>ny/2) return std::complex<float>(0,0);
00132         if (x>=0 && y>=0) return std::complex<float>(rdata[ x*2+y*nx],      rdata[x*2+y*nx+1]);
00133         if (x>0 && y<0) return std::complex<float>(  rdata[ x*2+(ny+y)*nx], rdata[x*2+(ny+y)*nx+1]);
00134         if (x<0 && y>0) return std::complex<float>(  rdata[-x*2+(ny-y)*nx],-rdata[-x*2+(ny-y)*nx+1]);
00135         return std::complex<float>(rdata[-x*2-y*nx],-rdata[-x*2+-y*nx+1]);
00136 }

size_t EMData::get_complex_index int  x,
int  y,
int  z,
const int &  subx0,
const int &  suby0,
const int &  subz0,
const int &  fullnx,
const int &  fullny,
const int &  fullnz
const
 

Definition at line 158 of file emdata_core.cpp.

References abs, nx, ny, x, and y.

00158                                                                                                                                                                  {
00159 if (abs(x)>=fullnx/2 || abs(y)>fullny/2 || abs(z)>fullnz/2) return nxyz;
00160 
00161 if (x<0) {
00162         x*=-1;
00163         y*=-1;
00164         z*=-1;
00165 }
00166 if (y<0) y=fullny+y;
00167 if (z<0) z=fullnz+z;
00168 
00169 if (x<subx0||y<suby0||z<subz0||x>=subx0+nx||y>=suby0+ny||z>=subz0+nz) return nxyz;
00170 
00171 return (x-subx0)*2+(y-suby0)*(size_t)nx+(z-subz0)*(size_t)nx*(size_t)ny;
00172 }

size_t EMData::get_complex_index const int &  x,
const int &  y,
const int &  z
const
 

Get complex<float> index for coords x,y,z.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny x nz image, a nx+2 x ny x nz image will be produced, and values using this function can go from -nx/2 to nx/2 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. Note that if a pixel is accessed at this location, a complex conjugate may be required if x<0, and this fact is not returned.

Parameters:
x x coordinate
y y coordinate
z z coordinate
Returns:
The complex pixel at x,y

Definition at line 150 of file emdata_core.cpp.

References abs, nx, ny, nz, x, and y.

Referenced by EMAN::WienerFourierReconstructor::pixel_at(), and EMAN::FourierReconstructor::pixel_at().

00150                                                                              {
00151         if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return nxyz;
00152         if (x<0) {
00153                 return -x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00154         }
00155         return x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00156 }

size_t EMAN::EMData::get_complex_index_fast const int &  x,
const int &  y,
const int &  z
const [inline]
 

Definition at line 1998 of file emdata.h.

Referenced by EMAN::WienerFourierReconstructor::pixel_at(), EMAN::FourierReconstructor::pixel_at(), and EMAN::LowpassRandomPhaseProcessor::process_inplace().

const float* EMAN::EMData::get_const_data  )  const [inline]
 

Get the image pixel density data in a 1D float array - const version of get_data.

Returns:
The image pixel density data.

Definition at line 361 of file emdata.h.

Referenced by EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), equal(), EMAN::TransformProcessor::transform(), and unwrap().

00391 : an algorithm that transforms an original

Ctf * EMData::get_ctf  )  const
 

Get ctf parameter of this image.

Returns:
The ctf parameter.

Definition at line 816 of file emdata_metadata.cpp.

References attr_dict, EMAN::EMAN1Ctf::from_vector(), and EMAN::Dict::has_key().

Referenced by EMAN::EMUtil::is_same_ctf(), main(), and EMAN::SNRProcessor::process_inplace().

00817 {
00818         if(attr_dict.has_key("ctf")) {
00819                 EMAN1Ctf * ctf = new EMAN1Ctf();
00820                 ctf->from_vector(attr_dict["ctf"]);
00821 
00822                 return dynamic_cast<Ctf *>(ctf);
00823         }
00824         else {
00825                 return 0;
00826         }
00827 }

float* EMAN::EMData::get_data  )  const [inline]
 

Get the image pixel density data in a 1D float array.

Returns:
The image pixel density data.

Definition at line 355 of file emdata.h.

References process_inplace().

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::AbsMaxMinAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), add_incoherent(), EMAN::newfile_store::add_tovol(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::FRM2DAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotatePrecenterAligner::align(), EMAN::TranslationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), EMAN::ScaleAlignerABS::align_using_base(), amplitude(), EMAN::SVDAnalyzer::analyze(), EMAN::varimax::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), ap2ri(), apmd(), apmq(), apply_radial_func(), EMAN::Util::Applyws(), average_circ_sub(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), EMAN::Util::BPCQ(), calc_az_dist(), calc_ccfx(), calc_center_density(), calc_center_of_mass(), calc_dist(), calc_fourier_shell_correlation(), calc_highest_locations(), calc_hist(), EMAN::MaskEdgeMeanProcessor::calc_locals(), calc_max_location(), EMAN::NormalizeLREdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), calc_min_location(), calc_mutual_correlation(), calc_n_highest_locations(), calc_radial_dist(), EMAN::NormalizeMaskProcessor::calc_sigma(), calc_sigma_diff(), circumf(), circumf_rect(), CleanStack(), CleanStack_Cart(), clip_inplace(), cm_euc(), EMAN::Util::cml_disc(), EMAN::Util::cml_prepare_line(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::TomoFscCmp::cmp(), common_lines(), common_lines_real(), EMAN::Util::compress_image_mask(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), conjg(), convolute(), EMAN::Util::Crosrng_e(), EMAN::Util::Crosrng_ew(), EMAN::Util::Crosrng_ms(), EMAN::Util::Crosrng_ms_delta(), EMAN::Util::Crosrng_msg(), EMAN::Util::Crosrng_msg_m(), EMAN::Util::Crosrng_msg_s(), EMAN::Util::Crosrng_msg_vec(), EMAN::Util::Crosrng_ns(), EMAN::Util::Crosrng_psi(), EMAN::Util::Crosrng_sm_psi(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), EMAN::PointArray::distmx(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), EMAN::PCA::dopca_lan(), EMAN::PCA::dopca_ooc(), dot_rotate_translate(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), EMAN::Util::ener(), EMAN::Util::ener_tot(), equal(), EMAN::Util::eval(), extract_box(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), EMAN::Phase180Processor::fourier_phaseshift180(), frm_2d_Align(), EMAN::Util::Frngs(), EMAN::Util::Frngs_inv(), get_2dcview(), get_2dview(), get_3dcview(), get_3dcviewptr(), get_3dview(), get_attr(), get_circle_mean(), get_col(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_row(), EMAN::Util::get_slice(), get_top_half(), get_value_at_wrap(), EMAN::Util::hist_comp_freq(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::im_diff(), imag(), EMAN::Util::image_mutation(), EMAN::Util::infomask(), EMAN::nn4_ctf_rectReconstructor::insert_buffed_slice(), EMAN::nn4_ctfReconstructor::insert_buffed_slice(), insert_clip(), EMAN::SVDAnalyzer::insert_image(), EMAN::varimax::insert_image(), EMAN::PCAlarge::insert_image(), EMAN::PCAsmall::insert_image(), insert_scaled_sum(), EMAN::GaussFFTProjector::interp_ft_3d(), EMAN::PCA::Lanczos(), EMAN::PCA::Lanczos_ooc(), little_big_dot(), EMAN::FourierReconstructor::load_inserter(), log(), log10(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), EMAN::Util::min_dist_four(), EMAN::Util::min_dist_real(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), EMAN::Util::mult_scalar(), EMAN::Util::multiref_peaks_ali2d(), EMAN::Util::multiref_peaks_compress_ali2d(), EMAN::Util::Normalize_ring(), EMAN::ReconstructorVolumeData::normalize_threed(), oneDfftPolar(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), ParseAlignOptions(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), phase(), EMAN::WienerFourierReconstructor::pixel_at(), EMAN::FourierReconstructor::pixel_at(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::ConvolutionKernelProcessor::process(), EMAN::Wiener2DAutoAreaProcessor::process(), EMAN::XYZProcessor::process_inplace(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImageNoiseGauss::process_inplace(), EMAN::TestImageNoiseUniformRand::process_inplace(), EMAN::TestImageCirclesphere::process_inplace(), EMAN::TestImageSquarecube::process_inplace(), EMAN::TestImageSinewaveCircular::process_inplace(), EMAN::TestImageSinewave::process_inplace(), EMAN::TestImageGaussian::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::CtfSimProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AutoMaskAsymUnit::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::AddNoiseProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_binedimage(), read_data(), read_image(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), real(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), EMAN::Util::reconstitute_image_mask(), render_amp24(), render_ap24(), EMAN::PointArray::replace_by_summation(), ri2ap(), ri2inten(), rotate_x(), set_col(), set_data_pickle(), EMAN::PointArray::set_from_density_map(), EMAN::Util::set_line(), EMAN::SVDAnalyzer::set_params(), set_row(), set_size(), wustl_mm::SkeletonMaker::VolumeData::SetDataAt(), setup4slice(), sget_value_at(), sqrt(), sub(), EMAN::Util::sub_fav(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), EMAN::Phase180Processor::swap_central_slices_180(), EMAN::Phase180Processor::swap_corners_180(), to_value(), uncut_slice(), unified(), unwrap(), unwrap_largerR(), EMAN::Util::update_fav(), update_stat(), EMAN::Cmp::validate_input_args(), EMAN::TestUtil::verify_image_file_by_mode(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), write_data(), write_image(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00355 {

vector<float> EMAN::EMData::get_data_as_vector  )  const [inline]
 

Get the pixel data as a vector.

Returns:
a vector containing the pixel data.

Definition at line 923 of file emdata.h.

Referenced by get_amplitude_thres().

std::string EMData::get_data_pickle  )  const
 

Definition at line 1296 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

01297 {
01298 //      vector<float> vf;
01299 //      vf.resize(nx*ny*nz);
01300 //      std::copy(rdata, rdata+nx*ny*nz, vf.begin());
01301 
01302         std::string vf((const char *)get_data(),nx*ny*nz*sizeof(float));
01303 
01304         return vf;
01305 }

float EMData::get_edge_mean  )  const
 

Calculates the mean pixel values around the (1 pixel) edge of the image.

Returns:
The mean pixel values around the (1 pixel) edge.

Definition at line 707 of file emdata_metadata.cpp.

References data, get_data(), get_edgemean_cuda(), nx, nx, nxy, ny, ny, and nz.

Referenced by calc_fast_sigma_image(), EMAN::NormalizeEdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), little_big_dot(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), and EMAN::FlattenBackgroundProcessor::process_inplace().

00708 {
00709         ENTERFUNC;
00710 #ifdef EMAN2_USING_CUDA
00711         if(EMData::usecuda == 1 && cudarwdata){
00712                 
00713                         return get_edgemean_cuda(cudarwdata, nx, ny, nz);
00714                         
00715         }
00716 #endif
00717         int di = 0;
00718         double edge_sum = 0;
00719         float edge_mean = 0;
00720         size_t nxy = nx * ny;
00721         float * data = get_data();
00722         if (nz == 1) {
00723                 for (int i = 0, j = (ny - 1) * nx; i < nx; ++i, ++j) {
00724                         edge_sum += data[i] + data[j];
00725                 }
00726                 for (size_t i = 0, j = nx - 1; i < nxy; i += nx, j += nx) {
00727                         edge_sum += data[i] + data[j];
00728                 }
00729                 edge_mean = (float)edge_sum / (nx * 2 + ny * 2);
00730         }
00731         else {
00732                 if (nx == ny && nx == nz * 2 - 1) {
00733                         for (size_t j = (nxy * (nz - 1)); j < nxy * nz; ++j, ++di) {
00734                                 edge_sum += data[j];
00735                         }
00736                 }
00737                 else {
00738                         for (size_t i = 0, j = (nxy * (nz - 1)); i < nxy; ++i, ++j, ++di) {
00739                                 edge_sum += data[i] + data[j];
00740                         }
00741                 }
00742 
00743                 int nxy2 = nx * (ny - 1);
00744                 for (int k = 1; k < nz - 1; ++k) {
00745                         size_t k2 = k * nxy;
00746                         size_t k3 = k2 + nxy2;
00747                         for (int i = 0; i < nx; ++i, ++di) {
00748                                 edge_sum += data[i + k2] + data[i + k3];
00749                         }
00750                 }
00751                 for (int k = 1; k < nz - 1; ++k) {
00752                         size_t k2 = k * nxy;
00753                         size_t k3 = nx - 1 + k2;
00754                         for (int i = 1; i < ny - 1; ++i, ++di) {
00755                                 edge_sum += data[i * nx + k2] + data[i * nx + k3];
00756                         }
00757                 }
00758 
00759                 edge_mean = (float)edge_sum / (di * 2);
00760         }
00761         EXITFUNC;
00762 
00763         return edge_mean;
00764 }

EMData * EMData::get_fft_amplitude  ) 
 

return the amplitudes of the FFT including the left half

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current FFT image's amplitude image.

Definition at line 94 of file emdata_metadata.cpp.

References copy_head(), data, get_data(), get_ndim(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), LOGERR, nx, ny, ny, nz, ri2ap(), set_complex(), set_complex_x(), set_ri(), set_size(), to_zero(), and update().

Referenced by get_amplitude_thres().

00095 {
00096         ENTERFUNC;
00097 
00098         if (!is_complex()) {
00099                 LOGERR("complex image expected. Input image is real image.");
00100                 throw ImageFormatException("complex image expected. Input image is a real image.");
00101         }
00102 
00103         ri2ap();
00104 
00105         int nx2 = nx - 2;
00106         EMData *dat = copy_head();
00107         dat->set_size(nx2, ny, nz);
00108         dat->to_zero();
00109 
00110         float *d = dat->get_data();
00111         float *data = get_data();
00112         int ndim = get_ndim();
00113 
00114         size_t idx1, idx2, idx3;
00115         if (ndim == 3) {
00116                 for (int k = 1; k < nz; ++k) {
00117                         for (int j = 1; j < ny; ++j) {
00118                                 for (int i = 0; i < nx2/2; ++i) {
00119                                         idx1 = (size_t)k*nx2*ny+j*nx2+nx2/2+i;
00120                                         idx2 = (size_t)k*nx*ny+j*nx+2*i;
00121                                         idx3 = (size_t)(nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
00122                                         d[idx1] = data[idx2];
00123                                         d[idx3] = data[idx2];
00124                                 }
00125                         }
00126                 }
00127         }
00128         else if (ndim == 2) {
00129                 for (int j = 1; j < ny; ++j) {
00130                         for (int i = 0; i < nx2/2; ++i) {
00131                                 d[j*nx2+nx2/2+i] = data[j*nx+2*i];
00132                                 d[(ny-j)*nx2+nx2/2-i] = data[j*nx+2*i];
00133                         }
00134                 }
00135         }
00136 
00137         dat->update();
00138         dat->set_complex(false);
00139         if(dat->get_ysize()==1 && dat->get_zsize()==1) {
00140                 dat->set_complex_x(false);
00141         }
00142         dat->set_ri(false);
00143 
00144         EXITFUNC;
00145         return dat;
00146 }

EMData * EMData::get_fft_amplitude2D  ) 
 

return the amplitudes of the 2D FFT including the left half PRB

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current FFT image's amplitude image.

Definition at line 53 of file emdata_metadata.cpp.

References copy_head(), ImageFormatException, is_complex(), LOGERR, nx, ny, nz, set_complex(), set_ri(), set_size(), sqrt(), to_zero(), and update().

00054 {
00055         ENTERFUNC;
00056 
00057 //      int ndim = get_ndim();
00058         if (!is_complex()) {
00059                 LOGERR("complex image expected. Input image is real image.");
00060                 throw ImageFormatException("complex image expected. Input image is a real image.");
00061         }
00062         if (nz>1) {
00063                 LOGERR("2D image expected. Input image is 3D");
00064                 throw ImageFormatException("2D odd square complex image"
00065                         " expected Input image is 3D.");
00066         }
00067 
00068         int nx2 = nx/2;
00069 
00070         EMData *dat = copy_head();
00071 
00072         dat->set_size(nx2, ny, nz);
00073         dat->to_zero();
00074 
00075         float temp=0;
00076 
00077         for (int j = 0; j < ny; j++) {
00078                 for (int i = 0; i < nx2; i++) {
00079                         temp = (*this)(2*i,j)*(*this)(2*i,j);
00080                         temp += (*this)(2*i+1,j)*(*this)(2*i+1,j);
00081                         (*dat)(i,j) = std::sqrt(temp);
00082                 }
00083         }
00084 
00085         dat->update();
00086         dat->set_complex(false);
00087         dat->set_ri(false);
00088 
00089         EXITFUNC;
00090         return dat;
00091 }

EMData * EMData::get_fft_phase  ) 
 

return the phases of the FFT including the left half

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current FFT image's phase image.

Definition at line 149 of file emdata_metadata.cpp.

References copy_head(), data, get_data(), get_ndim(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), LOGERR, nx, ny, ny, nz, ri2ap(), set_complex(), set_complex_x(), set_ri(), set_size(), to_zero(), and update().

00150 {
00151         ENTERFUNC;
00152 
00153         if (!is_complex()) {
00154                 LOGERR("complex image expected. Input image is real image.");
00155                 throw ImageFormatException("complex image expected. Input image is a real image.");
00156         }
00157 
00158         ri2ap();
00159 
00160         int nx2 = nx - 2;
00161         EMData *dat = copy_head();
00162         dat->set_size(nx2, ny, nz);
00163         dat->to_zero();
00164 
00165         float *d = dat->get_data();
00166         float * data = get_data();
00167 
00168         int ndim = get_ndim();
00169         size_t idx1, idx2, idx3;
00170         if (ndim == 3) {
00171                 for (int k = 1; k < nz; ++k) {
00172                         for (int j = 1; j < ny; ++j) {
00173                                 for (int i = 0; i < nx2/2; ++i) {
00174                                         idx1 = (size_t)k*nx2*ny+j*nx2+nx2/2+i;
00175                                         idx2 = (size_t)k*nx*ny+j*nx+2*i+1;
00176                                         idx3 = (size_t)(nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
00177                                         d[idx1] = data[idx2];
00178                                         d[idx3] = -data[idx2];
00179                                 }
00180                         }
00181                 }
00182         }
00183         else if (ndim == 2) {
00184                 for (int j = 1; j < ny; ++j) {
00185                         for (int i = 0; i < nx2/2; ++i) {
00186                                 d[j*nx2+nx2/2+i] = data[j*nx+2*i+1];
00187                                 d[(ny-j)*nx2+nx2/2-i] = -data[j*nx+2*i+1];
00188                         }
00189                 }
00190         }
00191 
00192         dat->update();
00193         dat->set_complex(false);
00194         if(dat->get_ysize()==1 && dat->get_zsize()==1) {
00195                 dat->set_complex_x(false);
00196         }
00197         dat->set_ri(false);
00198 
00199         EXITFUNC;
00200         return dat;
00201 }

int EMAN::EMData::get_flags  )  const [inline]
 

Definition at line 1243 of file emdata.h.

int EMAN::EMData::get_ndim  )  const [inline]
 

Get image dimension.

Returns:
image dimension.

Definition at line 934 of file emdata.h.

Referenced by ali3d_d(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::align(), apply_radial_func(), EMAN::TransformProcessor::assert_valid_aspect(), calc_az_dist(), calc_ccfx(), calc_dist(), calc_fast_sigma_image(), cog(), cut_slice(), do_ift(), do_radon(), EMAN::PCA::dopca_ooc(), dot_rotate_translate(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), get_2dcview(), get_2dview(), get_clip(), EMAN::IntTranslateProcessor::get_clip_region(), get_col(), get_fft_amplitude(), get_fft_phase(), get_row(), get_top_half(), insert_scaled_sum(), EMAN::PCA::Lanczos(), EMAN::PCA::Lanczos_ooc(), little_big_dot(), main(), mult_complex_efficient(), EMAN::ScaleTransformProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::Rotate180Processor::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::TestImageSinewave::process_inplace(), EMAN::TestImageSphericalWave::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::PhaseToMassCenterProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadVandBcast(), render_amp24(), render_ap24(), rotate_x(), set_col(), set_row(), setup4slice(), uncut_slice(), unified(), unwrap(), window_center(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

string EMAN::EMData::get_path  )  const [inline]
 

Definition at line 1292 of file emdata.h.

int EMAN::EMData::get_pathnum  )  const [inline]
 

Definition at line 1297 of file emdata.h.

float EMData::get_pixel_conv float  delx,
float  dely,
float  delz,
Util::KaiserBessel kb
 

Get pixel value image using convolution.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] delx Amount to shift rotation origin along x
[in] dely Amount to shift rotation origin along y
[in] delz Amount to shift rotation origin along z
[in] kb convolution kernel
Exceptions:
ImageDimensionException can not rotate 1 D image
Returns:
New rotated/shifted/scaled image

Definition at line 3530 of file emdata_sparx.cpp.

References nx, ny, and q.

03541                  {  //1D
03542                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03543                         //  loop for ends
03544                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03545                                 float q = kb.i0win_tab(delx - inxold-m1);
03546                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03547                         }
03548                 } else {
03549                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03550                                 float q = kb.i0win_tab(delx - inxold-m1);
03551                                 pixel += (*this)(inxold+m1)*q; w+=q;
03552                         }
03553                 }
03554 
03555         } else if(nz<2) {  // 2D
03556                 dely = restrict2(dely, ny);
03557                 int inyold = int(Util::round(dely));
03558                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03559                         //  loop for strips
03560                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03561                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03562                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q; w+=q;}
03563                         }
03564                 } else {
03565                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03566                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03567                                 pixel += (*this)(inxold+m1,inyold+m2)*q; w+=q;}
03568                         }
03569                 }
03570         } else {  //  3D
03571                 dely = restrict2(dely, ny);
03572                 int inyold = int(Util::round(dely));
03573                 delz = restrict2(delz, nz);
03574                 int inzold = int(Util::round(delz));
03575                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03576                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03577                         //  loop for strips
03578                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03579                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03580                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03581                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03582                         }
03583                 } else {
03584                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03585                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03586                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03587                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03588                         }
03589                 }
03590         }
03591         return pixel/w;
03592 }
03593 
03594 

float EMData::get_pixel_conv7 float  delx,
float  dely,
float  delz,
Util::KaiserBessel kb
 

Definition at line 3676 of file emdata_sparx.cpp.

References nx, ny, and nz.

03688                                                                                        {

float EMData::get_pixel_filtered float  delx,
float  dely,
float  delz,
Util::sincBlackman kb
 

Definition at line 3597 of file emdata_sparx.cpp.

References nx, ny, nz, q, and t.

03608                    {  //1D
03609                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03610                         //  loop for ends
03611                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03612                                 float q = kb.sBwin_tab(delx - inxold-m1);
03613                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03614                         }
03615                 } else {
03616                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03617                                 float q = kb.sBwin_tab(delx - inxold-m1);
03618                                 pixel += (*this)(inxold+m1)*q; w+=q;
03619                         }
03620                 }
03621 
03622         } else */
03623         if(nz<2) {  
03624                 //dely = restrict2(dely, ny);
03625                 int inyold = int(Util::round(dely));
03626                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03627                         //  loop for strips
03628                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03629                                 float t = kb.sBwin_tab(dely - inyold-m2);
03630                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03631                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03632                                         pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q;
03633                                         w += q;
03634                                 }
03635                         }
03636                 } else {
03637                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03638                                 float t = kb.sBwin_tab(dely - inyold-m2);
03639                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03640                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03641                                         pixel += (*this)(inxold+m1,inyold+m2)*q;
03642                                         w += q;
03643                                 }
03644                         }
03645                 }
03646         } else {  //  3D
03647                 //std::cout<<"pixel_filtered 3D"<<std::endl;
03648                 dely = restrict2(dely, ny);
03649                 int inyold = int(Util::round(dely));
03650                 delz = restrict2(delz, nz);
03651                 int inzold = int(Util::round(delz));
03652                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03653                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03654                         //  loop for strips
03655                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03656                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03657                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03658                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03659                         }
03660                 } else {
03661                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03662                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03663                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03664                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03665                         }
03666                 }
03667         }
03668         return pixel/w;
03669 }
03670 
03671 // Note by Yang on 10/02/07

EMData * EMData::get_pow float  n_pow  ) 
 

Definition at line 6163 of file emdata_sparx.cpp.

References in, nx, and ny.

06171 {

EMData * EMData::get_rotated_clip const Transform xform,
const IntSize size,
float  scale = 1.0
 

This will extract an arbitrarily oriented and sized region from the image.

Parameters:
xform The transformation of the region.
size Size of the clip.
scale Scaling put on the returned image.
Returns:
The clip image.

Definition at line 706 of file emdata.cpp.

References EMData(), nx, ny, nz, set_size(), set_value_at(), sget_value_at_interp(), EMAN::Transform::transform(), update(), v, EMAN::Vec3f, x, and y.

00708 {
00709         EMData *result = new EMData();
00710         result->set_size(size[0],size[1],size[2]);
00711 
00712         if (nz==1) {
00713                 for (int y=-size[1]/2; y<(size[1]+1)/2; y++) {
00714                         for (int x=-size[0]/2; x<(size[0]+1)/2; x++) {
00715                                 Vec3f xv=xform.transform(Vec3f((float)x,(float)y,0.0f));
00716                                 float v = 0;
00717 
00718                                 if (xv[0]<0||xv[1]<0||xv[0]>nx-2||xv[1]>ny-2) v=0.;
00719                                 else v=sget_value_at_interp(xv[0],xv[1]);
00720                                 result->set_value_at(x+size[0]/2,y+size[1]/2,v);
00721                         }
00722                 }
00723         }
00724         else {
00725                 for (int z=-size[2]/2; z<(size[2]+1)/2; z++) {
00726                         for (int y=-size[1]/2; y<(size[1]+1)/2; y++) {
00727                                 for (int x=-size[0]/2; x<(size[0]+1)/2; x++) {
00728                                         Vec3f xv=xform.transform(Vec3f((float)x,(float)y,0.0f));
00729                                         float v = 0;
00730 
00731                                         if (xv[0]<0||xv[1]<0||xv[2]<0||xv[0]>nx-2||xv[1]>ny-2||xv[2]>nz-2) v=0.;
00732                                         else v=sget_value_at_interp(xv[0],xv[1],xv[2]);
00733                                         result->set_value_at(x+size[0]/2,y+size[1]/2,z+size[2]/2,v);
00734                                 }
00735                         }
00736                 }
00737         }
00738         result->update();
00739 
00740         return result;
00741 }

EMData * EMData::get_row int  row_index  )  const
 

Get one row of a 1D/2D image.

Parameters:
row_index Index of the row.
Exceptions:
ImageDimensionException If this image is 3D.
Returns:
A 1D image with the row data.

Definition at line 661 of file emdata_core.cpp.

References EMData(), get_data(), get_ndim(), ImageDimensionException, nx, set_size(), and update().

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

00662 {
00663         ENTERFUNC;
00664 
00665         if (get_ndim() > 2) {
00666                 throw ImageDimensionException("1D/2D image only");
00667         }
00668 
00669         EMData *ret = new EMData();
00670         ret->set_size(nx, 1, 1);
00671         memcpy(ret->get_data(), get_data() + nx * row_index, nx * sizeof(float));
00672         ret->update();
00673         EXITFUNC;
00674         return ret;
00675 }

size_t EMAN::EMData::get_size  )  const [inline]
 

Get the number of allocated floats in the image (nx*ny*nz).

Returns:
nx*ny*nz

Definition at line 915 of file emdata.h.

Referenced by calc_fast_sigma_image(), equal(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AddNoiseProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), and to_value().

int EMData::get_supp_pickle  )  const
 

Definition at line 1317 of file emdata_metadata.cpp.

01318 {
01319         return 0;
01320 }

EMData * EMData::get_top_half  )  const
 

Get the top half of this 3D image.

Exceptions:
ImageDimensionException If this image is not 3D.
Returns:
The top half of this image.

Definition at line 680 of file emdata.cpp.

References attr_dict, EMData(), get_data(), get_ndim(), ImageDimensionException, nx, ny, ny, nz, set_size(), and update().

00681 {
00682         ENTERFUNC;
00683 
00684         if (get_ndim() != 3) {
00685                 throw ImageDimensionException("3D only");
00686         }
00687 
00688         EMData *half = new EMData();
00689         half->attr_dict = attr_dict;
00690         half->set_size(nx, ny, nz / 2);
00691 
00692         float *half_data = half->get_data();
00693         EMUtil::em_memcpy(half_data, &(get_data()[(size_t)nz / 2 * (size_t)nx * (size_t)ny]), sizeof(float) * (size_t)nx * (size_t)ny * (size_t)nz / 2lu);
00694 
00695         float apix_z = attr_dict["apix_z"];
00696         float origin_z = attr_dict["origin_z"];
00697         origin_z += apix_z * nz / 2;
00698         half->attr_dict["origin_z"] = origin_z;
00699         half->update();
00700 
00701         EXITFUNC;
00702         return half;
00703 }

Transform EMAN::EMData::get_transform  )  const [inline]
 

Get the 3D orientation of 'this' image.

Returns:
The 3D orientation of 'this' image.

Definition at line 592 of file emdata.h.

Referenced by main().

00760                                           {

Vec3f EMAN::EMData::get_translation  )  const [inline]
 

Get 'this' image's translation vector from the original location.

Returns:
'this' image's translation vector from the original location.

Definition at line 561 of file emdata.h.

00760                                           {

float EMAN::EMData::get_value_at size_t  i  )  const [inline]
 

Get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.

The validity of i is not checked.

Parameters:
i 1D data array index.
Returns:
The pixel density value

Definition at line 1950 of file emdata.h.

float EMAN::EMData::get_value_at int  x,
int  y
const [inline]
 

Get the pixel density value at coordinates (x,y).

2D only. The validity of x, y is not checked.

Parameters:
x The x coordinate.
y The y coordinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 1937 of file emdata.h.

float EMAN::EMData::get_value_at int  x,
int  y,
int  z
const [inline]
 

Get the pixel density value at coordinates (x,y,z).

The validity of x, y, and z is not checked.

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 1917 of file emdata.h.

Referenced by EMAN::MinMaxAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::BoxingTools::auto_correlation_pick(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_fast_sigma_image(), EMAN::XYZCmp::cmp(), common_lines(), EMAN::Util::constrained_helix(), EMAN::Util::constrained_helix_test(), find_pixels_with_value(), EMAN::BoxingTools::find_radial_max(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::FourierWeightAverager::finish(), EMAN::ImageAverager::finish(), EMAN::BoxingTools::get_min_delta_profile(), wustl_mm::SkeletonMaker::VolumeData::GetDataAt(), EMAN::BoxingTools::hi_brid(), EMAN::BoxingTools::is_local_maximum(), make_footprint(), EMAN::PointArray::match_points(), printImage(), EMAN::DirectionalSumProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::StripeXYProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::BoxingTools::set_region(), and EMAN::WatershedProcessor::watershed().

float EMAN::EMData::get_value_at_index int  i  )  [inline]
 

Get the pixel density value at index i.

Parameters:
a The index.

Definition at line 1925 of file emdata.h.

float & EMData::get_value_at_wrap int  x  ) 
 

Definition at line 741 of file emdata_core.cpp.

References get_data(), nx, and x.

00742 {
00743         if (x < 0) x = nx + x;
00744         return get_data()[x];
00745 }

float EMData::get_value_at_wrap int  x  )  const
 

Get the pixel density value at coordinates (x).

Should only be called on 1D images - no errors are thrown Wraps pixel values if they are negative - i.e. is circulant For example, if x = -1, then the pixel at nx-1 is returned

Parameters:
x The x coordinate.
Returns:
The pixel density value at circulant coordinates (x).

Definition at line 775 of file emdata_core.cpp.

References get_data(), nx, and x.

00776 {
00777         if (x < 0) x = nx - x;
00778         return get_data()[x];
00779 }

float & EMData::get_value_at_wrap int  x,
int  y
 

Definition at line 747 of file emdata_core.cpp.

References get_data(), nx, ny, x, and y.

00748 {
00749         if (x < 0) x = nx + x;
00750         if (y < 0) y = ny + y;
00751 
00752         return get_data()[x + y * nx];
00753 }

float EMData::get_value_at_wrap int  x,
int  y
const
 

Get the pixel density value at coordinates (x,y).

Should only be called on 2D images - no errors are thrown Wraps pixel values if they are negative - i.e. is circulant For example, if x = -1, then the pixel at nx-1 is returned

Parameters:
x The x coordinate.
y The y coordinate.
Returns:
The pixel density value at circulant coordinates (x,y).

Definition at line 781 of file emdata_core.cpp.

References get_data(), nx, ny, x, and y.

00782 {
00783         if (x < 0) x = nx - x;
00784         if (y < 0) y = ny - y;
00785 
00786         return get_data()[x + y * nx];
00787 }

float & EMData::get_value_at_wrap int  x,
int  y,
int  z
 

Definition at line 755 of file emdata_core.cpp.

References get_data(), get_value_at_wrap_cuda(), nx, ny, nz, x, and y.

00756 {
00757         
00758 #ifdef EMAN2_USING_CUDA 
00759         if(EMData::usecuda == 1 && cudarwdata){
00760                 float result = get_value_at_wrap_cuda(cudarwdata, x, y, z, nx, ny, nz); // this should work....
00761                 return result;
00762         }
00763 #endif
00764         int lx = x;
00765         int ly = y;
00766         int lz = z;
00767 
00768         if (lx < 0) lx = nx + lx;
00769         if (ly < 0) ly = ny + ly;
00770         if (lz < 0) lz = nz + lz;
00771 
00772         return get_data()[lx + ly * (size_t)nx + lz * (size_t)nxy];
00773 }

float EMData::get_value_at_wrap int  x,
int  y,
int  z
const
 

Get the pixel density value at coordinates (x,y,z).

Should only be called on 3D images - no errors are thrown Wraps pixel values if they are negative - i.e. is circulant For example, if x = -1, then the pixel at nx-1 is returned

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
Returns:
The pixel density value at circulant coordinates (x,y,z).

Definition at line 789 of file emdata_core.cpp.

References get_data(), nx, ny, and nz.

Referenced by EMAN::Refine3DAlignerGrid::align(), calc_max_location_wrap(), calc_max_location_wrap_intp(), EMAN::TomoCccCmp::cmp(), compute_missingwedge(), EMAN::RT3DSphereAligner::xform_align_nbest(), EMAN::RT3DGridAligner::xform_align_nbest(), and zero_corner_circulant().

00790 {
00791         ptrdiff_t lx = x;
00792         ptrdiff_t ly = y;
00793         ptrdiff_t lz = z;
00794         if (lx < 0) lx = nx + lx;
00795         if (ly < 0) ly = ny + ly;
00796         if (lz < 0) lz = nz + lz;
00797 
00798         return get_data()[lx + ly * nx + lz * nxy];
00799 }

int EMAN::EMData::get_xoff  )  const [inline]
 

Definition at line 1263 of file emdata.h.

int EMAN::EMData::get_xsize  )  const [inline]
 

Get the image x-dimensional size.

Returns:
Image x-dimensional size.

Definition at line 888 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::AbsMaxMinAverager::add_image(), EMAN::MinMaxAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::FRM2DAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::align(), EMAN::SymAlignProcessorQuat::align(), EMAN::RefineAlignerCG::align(), EMAN::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotationalAlignerIterative::align(), EMAN::TranslationalAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), amplitude(), EMAN::SVDAnalyzer::analyze(), apmd(), apmq(), EMAN::BoxingTools::auto_correlation_pick(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), bispecRotTransInvDirect(), bispecRotTransInvN(), EMAN::Util::BPCQ(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccf(), calc_ccfx(), calc_dist(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_max_location_wrap(), calc_max_location_wrap_intp(), EMAN::NormalizeLREdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), calc_mutual_correlation(), EMAN::NormalizeMaskProcessor::calc_sigma(), EMAN::NormalizeUnitSumProcessor::calc_sigma(), circumf(), circumf_rect(), EMAN::FourierReconstructor::clear(), EMAN::Util::cluster_equalsize(), EMAN::Util::cluster_pairwise(), cm_euc(), EMAN::Util::cml_disc(), EMAN::Util::cml_prepare_line(), EMAN::XYZCmp::cmp(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::TomoCccCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), common_lines(), EMAN::Util::compress_image_mask(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), convolute(), EMAN::LowpassAutoBProcessor::create_radial_func(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), EMAN::PCA::dopca_ooc(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), equal(), extract_box(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), find_group(), EMAN::BoxingTools::find_radial_max(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::FourierWeightAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), EMAN::Phase180Processor::fourier_phaseshift180(), EMAN::fourierproduct(), EMAN::Util::get_biggest_cluster(), EMAN::IntTranslateProcessor::get_clip_region(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), EMAN::BoxingTools::get_min_delta_profile(), EMAN::Util::get_slice(), wustl_mm::SkeletonMaker::VolumeData::GetSizeX(), EMAN::BoxingTools::hi_brid(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::im_diff(), imag(), EMAN::Util::image_mutation(), EMAN::Util::infomask(), EMAN::FourierPixelInserter3D::init(), EMAN::nn4_ctf_rectReconstructor::insert_buffed_slice(), EMAN::nn4_ctfReconstructor::insert_buffed_slice(), insert_clip(), EMAN::SVDAnalyzer::insert_image(), EMAN::PCAlarge::insert_image(), EMAN::PCAsmall::insert_image(), insert_scaled_sum(), EMAN::GaussFFTProjector::interp_ft_3d(), EMAN::BoxingTools::is_local_maximum(), EMAN::EMUtil::is_same_size(), EMAN::PCA::Lanczos(), EMAN::PCA::Lanczos_ooc(), little_big_dot(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), make_footprint(), EMAN::EMUtil::make_image_median(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::PointArray::match_points(), median(), EMAN::Util::min_dist_four(), EMAN::Util::min_dist_real(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), mult_radial(), EMAN::Util::mult_scalar(), EMAN::Util::Normalize_ring(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::padfft_slice(), EMAN::periodogram(), phase(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::TestImageProcessor::preprocess(), EMAN::FourierReconstructor::preprocess_slice(), print_image(), printImage(), EMAN::ConvolutionKernelProcessor::process(), EMAN::ScaleTransformProcessor::process(), EMAN::TransformProcessor::process(), EMAN::DirectionalSumProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::XYZProcessor::process_inplace(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::TransformProcessor::process_inplace(), EMAN::MirrorProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImagePureGaussian::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageLineWave::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::CtfSimProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AutoMaskAsymUnit::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), real(), real2complex(), real2FH(), recons3d_4nn(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), EMAN::Util::reconstitute_image_mask(), refalifnfast(), EMAN::PointArray::replace_by_summation(), EMAN::rsconvolution(), EMAN::PointArray::set_from_density_map(), EMAN::Util::set_line(), EMAN::SVDAnalyzer::set_params(), EMAN::varimax::set_params(), EMAN::PCAlarge::set_params(), EMAN::PCAsmall::set_params(), EMAN::BoxingTools::set_radial_non_zero(), EMAN::BoxingTools::set_region(), EMAN::FourierReconstructor::setup_seed(), sub(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), EMAN::Phase180Processor::swap_central_slices_180(), EMAN::Phase180Processor::swap_corners_180(), EMAN::TestUtil::test_vector_emdata(), EMAN::TestUtil::to_emobject(), EMAN::TransformProcessor::transform(), uncut_slice(), unified(), unwrap_largerR(), EMAN::EMUtil::vertical_acf(), EMAN::WatershedProcessor::watershed(), EMAN::Util::window(), EMAN::Util::WTF(), EMAN::Util::WTM(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00892                                 {

int EMAN::EMData::get_yoff  )  const [inline]
 

Definition at line 1268 of file emdata.h.

int EMAN::EMData::get_ysize  )  const [inline]
 

Get the image y-dimensional size.

Returns:
Image y-dimensional size.

Definition at line 897 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::AbsMaxMinAverager::add_image(), EMAN::MinMaxAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::FRM2DAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotatePrecenterAligner::align(), EMAN::TranslationalAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), amplitude(), EMAN::SVDAnalyzer::analyze(), apmd(), apmq(), EMAN::BoxingTools::auto_correlation_pick(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), EMAN::Util::BPCQ(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccf(), calc_ccfx(), calc_dist(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_max_location_wrap(), calc_max_location_wrap_intp(), EMAN::NormalizeLREdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), calc_mutual_correlation(), EMAN::NormalizeMaskProcessor::calc_sigma(), EMAN::NormalizeUnitSumProcessor::calc_sigma(), circumf(), circumf_rect(), EMAN::FourierReconstructor::clear(), EMAN::XYZCmp::cmp(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::TomoCccCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), common_lines(), common_lines_real(), EMAN::Util::compress_image_mask(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), convolute(), EMAN::MatchSFProcessor::create_radial_func(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), do_fft(), do_ift(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), equal(), extract_box(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), find_group(), EMAN::BoxingTools::find_radial_max(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::FourierWeightAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), EMAN::Phase180Processor::fourier_phaseshift180(), EMAN::fourierproduct(), frm_2d_Align(), EMAN::Util::get_biggest_cluster(), EMAN::IntTranslateProcessor::get_clip_region(), get_fft_amplitude(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::BoxingTools::get_min_delta_profile(), EMAN::Util::get_slice(), wustl_mm::SkeletonMaker::VolumeData::GetSizeY(), EMAN::BoxingTools::hi_brid(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::im_diff(), imag(), EMAN::Util::infomask(), EMAN::FourierPixelInserter3D::init(), insert_clip(), EMAN::SVDAnalyzer::insert_image(), insert_scaled_sum(), EMAN::GaussFFTProjector::interp_ft_3d(), EMAN::BoxingTools::is_local_maximum(), EMAN::EMUtil::is_same_size(), little_big_dot(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), make_footprint(), EMAN::EMUtil::make_image_median(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), median(), EMAN::Util::min_dist_four(), EMAN::Util::min_dist_real(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), EMAN::Util::mult_scalar(), EMAN::Util::Normalize_ring(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::padfft_slice(), EMAN::periodogram(), phase(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::TestImageProcessor::preprocess(), EMAN::FourierReconstructor::preprocess_slice(), print_image(), printImage(), EMAN::ConvolutionKernelProcessor::process(), EMAN::ScaleTransformProcessor::process(), EMAN::TransformProcessor::process(), EMAN::DirectionalSumProcessor::process(), EMAN::CtfSimProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::XYZProcessor::process_inplace(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::TransformProcessor::process_inplace(), EMAN::MirrorProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImagePureGaussian::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageLineWave::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::LocalNormProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::CtfSimProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AutoMaskAsymUnit::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), real(), real2complex(), real2FH(), recons3d_4nn(), EMAN::Util::reconstitute_image_mask(), refalifnfast(), EMAN::rsconvolution(), EMAN::PointArray::set_from_density_map(), EMAN::SVDAnalyzer::set_params(), EMAN::varimax::set_params(), EMAN::PCAlarge::set_params(), EMAN::PCAsmall::set_params(), EMAN::BoxingTools::set_radial_non_zero(), EMAN::BoxingTools::set_region(), EMAN::FourierReconstructor::setup_seed(), sub(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), EMAN::Phase180Processor::swap_central_slices_180(), EMAN::Phase180Processor::swap_corners_180(), EMAN::TestUtil::test_vector_emdata(), EMAN::TestUtil::to_emobject(), EMAN::TransformProcessor::transform(), EMAN::Util::twoD_to_3D_ali(), uncut_slice(), unified(), unwrap_largerR(), EMAN::Util::vareas(), EMAN::EMUtil::vertical_acf(), EMAN::WatershedProcessor::watershed(), EMAN::Util::window(), EMAN::Util::WTF(), EMAN::Util::WTM(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00906                                                 {}

int EMAN::EMData::get_zoff  )  const [inline]
 

Definition at line 1273 of file emdata.h.

int EMAN::EMData::get_zsize  )  const [inline]
 

Get the image z-dimensional size.

Returns:
Image z-dimensional size.

Definition at line 906 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::IterationAverager::add_image(), EMAN::AbsMaxMinAverager::add_image(), EMAN::MinMaxAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::Refine3DAlignerGrid::align(), EMAN::TranslationalAligner::align(), amplitude(), EMAN::SVDAnalyzer::analyze(), apmd(), apmq(), EMAN::ChaoProjector::backproject3d(), EMAN::Util::BPCQ(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccf(), calc_ccfx(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_max_location_wrap(), calc_max_location_wrap_intp(), EMAN::NormalizeLREdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), calc_mutual_correlation(), EMAN::NormalizeMaskProcessor::calc_sigma(), EMAN::NormalizeUnitSumProcessor::calc_sigma(), circumf(), circumf_rect(), EMAN::FourierReconstructor::clear(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::TomoCccCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), EMAN::Util::compress_image_mask(), convolute(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), EMAN::FourierReconstructor::do_compare_slice_work(), do_fft(), do_ift(), EMAN::FourierReconstructor::do_insert_slice_work(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), equal(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), find_group(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::IterationAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), EMAN::Phase180Processor::fourier_phaseshift180(), EMAN::fourierproduct(), EMAN::Util::get_biggest_cluster(), EMAN::IntTranslateProcessor::get_clip_region(), get_fft_amplitude(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::Util::get_slice(), wustl_mm::SkeletonMaker::VolumeData::GetSizeZ(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::im_diff(), imag(), EMAN::Util::infomask(), EMAN::FourierPixelInserter3D::init(), insert_clip(), EMAN::SVDAnalyzer::insert_image(), insert_scaled_sum(), EMAN::GaussFFTProjector::interp_ft_3d(), EMAN::EMUtil::is_same_size(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), EMAN::EMUtil::make_image_median(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), median(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), EMAN::Util::mult_scalar(), EMAN::Util::Normalize_ring(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::periodogram(), phase(), EMAN::Util::Polar2Dmi(), EMAN::TestImageProcessor::preprocess(), print_image(), printImage(), EMAN::ConvolutionKernelProcessor::process(), EMAN::ScaleTransformProcessor::process(), EMAN::TransformProcessor::process(), EMAN::DirectionalSumProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::XYZProcessor::process_inplace(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::TransformProcessor::process_inplace(), EMAN::MirrorProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImagePureGaussian::process_inplace(), EMAN::TestImageLineWave::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::CtfSimProcessor::process_inplace(), EMAN::AutoMaskAsymUnit::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadVandBcast(), real(), real2complex(), real2FH(), EMAN::Util::reconstitute_image_mask(), EMAN::rsconvolution(), EMAN::PointArray::set_from_density_map(), EMAN::SVDAnalyzer::set_params(), EMAN::varimax::set_params(), EMAN::PCAlarge::set_params(), EMAN::PCAsmall::set_params(), EMAN::FourierReconstructor::setup_seed(), sub(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), EMAN::Phase180Processor::swap_central_slices_180(), EMAN::Phase180Processor::swap_corners_180(), EMAN::TestUtil::test_vector_emdata(), EMAN::TestUtil::to_emobject(), EMAN::TransformProcessor::transform(), uncut_slice(), unified(), EMAN::WatershedProcessor::watershed(), EMAN::Util::window(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00906                                                 {}
00907 
00908                         int prv_nx, prv_ny, prv_nz, new_nx, new_ny, new_nz;
00909                         int xshift, yshift, zshift;

float EMData::getconvpt2d_kbi0 float  x,
float  y,
Util::KaiserBessel::kbi0_win  win,
int  size = 7
 

Value of 2-D analytic masking (or 2-D convolution) at off-grid point.

The only requirement for the window function object is that it overload operator()(const float) and return a float.

Parameters:
[in] x x-value of the desired (potentially off-grid) point
[in] y y-value of the desired (potentially off-grid) point
[in] win Window (mask/kernel) function object.
[in] size Size of real-space kernel/mask.
Returns:
Value of masked/convolved image at (x,y)

Definition at line 3690 of file emdata_sparx.cpp.

References ny.

03699                                                          : X value out of range");
03700         if (abs(iyc) > nyhalf)
03701                 throw InvalidValueException(ixc, "getconv: Y value out of range");
03702         for (int i = -bd; i <= bd; i++) {
03703                 int iyp = iyc + i;
03704                 wy[i] = win(y - iyp);
03705                 int ixp = ixc + i;
03706                 wx[i] = win(x - ixp);
03707         }
03708         vector<int> saved_offsets = get_array_offsets();
03709         set_array_offsets(-nxhalf, -nyhalf);
03710         float conv = 0.f, wsum = 0.f;
03711         for (int iy = -bd; iy <= bd; iy++) {
03712                 int iyp = iyc + iy;
03713                 for (int ix = -bd; ix <= bd; ix++) {
03714                         int ixp = ixc + ix;
03715                         float wg = wx[ix]*wy[iy];
03716                         conv += (*this)(ixp,iyp)*wg;
03717                         wsum += wg;
03718                 }
03719         }
03720         set_array_offsets(saved_offsets);
03721         delete [] wxarr;
03722         delete [] wyarr;
03723         //return conv/wsum;
03724         return conv;
03725 }
03726 
03727 std::complex<float> EMData::extractpoint(float nuxnew, float nuynew, Util::KaiserBessel& kb) {

int EMAN::EMData::getResolution  )  const [inline]
 

function for MarchingCubes, for 3D image display

Returns:
the resolution

Definition at line 3846 of file emdata.h.

bool EMAN::EMData::has_attr const string &  key  )  const [inline]
 

Ask if the header has a particular attribute.

Parameters:
key the header attribute name
Returns:
whether or not the header has the name as a key/value entry

Definition at line 842 of file emdata.h.

References EMAN::Vec3f.

Referenced by EMAN::TomoAverager::add_image(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::FourierPixelInserter3D::init(), and EMAN::WienerFourierReconstructor::insert_slice().

bool EMAN::EMData::has_ctff  )  const [inline]
 

check whether the image physical file has the CTF info or not.

Returns:
True if it has the CTF information. Otherwise, false.

Definition at line 431 of file emdata.h.

Referenced by EMAN::EMUtil::is_same_ctf().

00439                           : this routine will modify the 'this' and 'with' to contain

EMData * EMData::helicise float  pixel_size,
float  dp,
float  dphi,
float  section_use = 1.0f,
float  radius = -1.0f,
float  minrad = -1.0f
 

Apply helical symmetry.

Works only for a volume.

Parameters:
[in] pixel_size: pixel size in Angstroms.
[in] dp: repeat in z direction in Angstroms.
[in] dphi: angular repeat in degrees.
[in] section_use: how much of z section to use for symmetrization (between zero and one).
[in] radius: radius of the structure (default nx/2-1).
Returns:
New image

Definition at line 6224 of file emdata_sparx.cpp.

References nx, ny, and phi.

06250                                    {
06251                 int nq = 0;
06252                 for (int ist = 0; ist<numst; ist++) {
06253                         float z = k*pixel_size + ist*dp;
06254                         float phi = ist*dphi;
06255                         if( z >= volen ) {
06256                                 z = k*pixel_size + (ist-numst)*dp;
06257                                 phi = (ist-numst)*dphi;
06258                         }
06259                         float ca = cos(phi*(float)DGR_TO_RAD);
06260                         float sa = sin(phi*(float)DGR_TO_RAD);
06261                         if((z >= nb) && (z <= ne )) {
06262                                 nq++;
06263                                 if( nq > numri ) break;
06264                                 float zz = z/pixel_size;
06265                                 //cout <<" zz  "<<zz<<"  k  "<<k<<"  phi  "<<phi<<endl;
06266                                 for (int j=0; j<ny; j++) {
06267                                         int jy = j - nyc;
06268                                         int jj = jy*jy;
06269                                         for (int i=0; i<nx; i++) {
06270                                                 int ix = i - nxc;
06271                                                 float d2 = float((ix*ix + jj));
06272                                                 if(d2 <= r2 && d2>=ir) {
06273                                                         float xx =  ix*ca + jy*sa + nxc;
06274                                                         float yy = -ix*sa + jy*ca + nyc;
06275 
06276 
06277         //  Do tri-linear interpolation
06278         int IOX = int(xx);
06279         int IOY = int(yy);
06280         int IOZ = int(zz);
06281 
06282         #ifdef _WIN32
06283         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
06284         #else
06285         int IOXp1 = std::min( nx-1 ,IOX+1);
06286         #endif  //_WIN32
06287 
06288         #ifdef _WIN32
06289         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
06290         #else
06291         int IOYp1 = std::min( ny-1 ,IOY+1);
06292         #endif  //_WIN32
06293 
06294         #ifdef _WIN32
06295         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
06296         #else
06297         int IOZp1 = std::min( nz-1 ,IOZ+1);
06298         #endif  //_WIN32
06299 
06300         float dx = xx-IOX;
06301         float dy = yy-IOY;
06302         float dz = zz-IOZ;
06303 
06304         float a1 = (*this)(IOX,IOY,IOZ);
06305         float a2 = (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZ);
06306         float a3 = (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZ);
06307         float a4 = (*this)(IOX,IOY,IOZp1) - (*this)(IOX,IOY,IOZ);
06308         float a5 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) + (*this)(IOXp1,IOYp1,IOZ);
06309         float a6 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOXp1,IOY,IOZp1);
06310         float a7 = (*this)(IOX,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOX,IOYp1,IOZp1);
06311         float a8 = (*this)(IOXp1,IOY,IOZ) + (*this)(IOX,IOYp1,IOZ)+ (*this)(IOX,IOY,IOZp1)
06312                         - (*this)(IOX,IOY,IOZ)- (*this)(IOXp1,IOYp1,IOZ) - (*this)(IOXp1,IOY,IOZp1)
06313                         - (*this)(IOX,IOYp1,IOZp1) + (*this)(IOXp1,IOYp1,IOZp1);
06314 
06315 
06316 
06317                                                         (*result)(i,j,k) += a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
06318                                                 }
06319                                         }
06320                                 }
06321                         }
06322                 }
06323                 if(nq < numri) throw InvalidValueException(nq, "Helicise: incorrect number of repeats encoutered.");
06324         }
06325         for (int k = 0; k<nz; k++) for (int j = 0; j<ny; j++) for (int i = 0; i<nx; i++) (*result)(i,j,k) /= numst ;
06326 
06327         result->update();
06328         return result;
06329 }
06330 
06331 

EMData * EMData::helicise_grid float  pixel_size,
float  dp,
float  dphi,
Util::KaiserBessel kb,
float  section_use = 1.0f,
float  radius = -1.0f,
float  minrad = -1.0f
 

Definition at line 6335 of file emdata_sparx.cpp.

References data, nx, and ny.

06385                                                                                       :
06386          
06387         //float a13 = -0.0f;    float a23 =  0.0f;
06388         //float a31 =  0.0f;    float a32 =  0.0f;        float a33 =  1.0f;
06389                 
06390         //end gridding
06391 
06392         
06393         int nyc = nyn/2;
06394         int nxc = nxn/2;
06395         int nb = int(nzn*(1.0f - section_use)/2.);
06396         int ne = nzn - nb -1;
06397         int numst = int(nzn*section_use*pixel_size/dp);
06398         // how many steps needed total, fewer will be used, only those that fall between nb and ne
06399         int nst = int(nzn*pixel_size/dp);
06400         float r2, ir;
06401         if(radius < 0.0f) r2 = (float)((nxc-1)*(nxc-1));
06402         else r2 = radius*radius;
06403         if(minrad < 0.0f) ir = 0.0f;
06404         else ir = minrad*minrad;
06405         
06406         for (int k = 0; k<nzn; k++) {
06407                 for (int j = 0; j<nyn; j++) {
06408                         int jy = j - nyc;
06409                         int jj = jy*jy;
06410                         for (int i = 0; i<nxn; i++) {
06411                                 int ix = i - nxc;
06412                                 float d2 = (float)(ix*ix + jj);
06413                                 if(d2 <= r2 && d2>=ir) {
06414                                         int nq = 0;
06415                                         for ( int ist = -nst; ist <= nst; ist++) {
06416                                                 float zold = (k*pixel_size + ist*dp)/pixel_size;
06417                                                 int IOZ = int(zold);
06418                                                 if(IOZ >= nb && IOZ <= ne) {
06419                                                 
06420                                                         float cphi = ist*dphi*(float)DGR_TO_RAD;
06421                                                         float ca = cos(cphi);
06422                                                         float sa = sin(cphi);
06423                                                         
06424                                                         float xold = ix*ca - jy*sa + nxc;
06425                                                         float yold = ix*sa + jy*ca + nyc;
06426                                                         
06427                                                         float xold_big = (xold-shiftxc)/scale - ixs + xc;
06428                                                         float yold_big = (yold-shiftyc)/scale - iys + yc;
06429                                                         float zold_big = (zold-shiftzc)/scale - izs + zc;
06430                                                         
06431                                                         /*float a11 =  ca; float a12 =  sa;
06432                                                         float a21 = -sa; float a22 = ca;
06433                                                         
06434                                                         float z = (zold - shiftzc)/scale;
06435                                                         float zco1 = a31*z+xc;
06436                                                         float zco2 = a32*z+yc;
06437                                                         float zco3 = a33*z+zc;
06438                                                                                                                 
06439                                                         float y = (float(j) - shiftyc)/scale;
06440                                                         float yco1 = zco1+a21*y;
06441                                                         float yco2 = zco2+a22*y;
06442                                                         float yco3 = zco3+a23*y;
06443                                                         
06444                                                         float x = (float(i) - shiftxc)/scale;
06445                                                         float xold_big = yco1+a11*x-ixs; //have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
06446                                                         float yold_big = yco2+a12*x-iys;
06447                                                         float zold_big = yco3+a13*x-izs;*/
06448                                                         
06449                                                                                                 
06450                                                         nq++;
06451                                                         
06452                                                                 
06453                                                         (*ret)(i,j,k) += Util::get_pixel_conv_new(nx, ny, nz, xold_big, yold_big, zold_big, data, kb);
06454                                                         
06455                                                         
06456                                                         if(nq == numst) break;
06457                                                 }
06458                                         }
06459                                         if(nq != numst)
06460                                                 throw InvalidValueException(nq, "Helicise: incorrect number of repeats encoutered.");
06461                                 }
06462                         }
06463                 }
06464         }
06465         
06466         for (int k = 0; k<nzn; k++) for (int j = 0; j<nyn; j++) for (int i = 0; i<nxn; i++) (*ret)(i,j,k) /= numst ;
06467         set_array_offsets(saved_offsets);
06468         ret->update();
06469         return ret;
06470 }
06471 
06472 

EMData * EMData::imag  )  const
 

return imaginary part of a complex image as a real image format.

Returns:
a real image which is the imaginary part of this image.
Exceptions:
InvalidCallException if this image is a real image
InvalidCallException if this image is a complex image in amplitude/phase format

Definition at line 1102 of file emdata_core.cpp.

References data, EMData(), get_data(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_real(), is_ri(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_size(), and update().

Referenced by add_complex_at(), EMAN::newfile_store::add_tovol(), div(), FH2F(), mult(), real2FH(), and set_complex_at().

01103 {
01104         ENTERFUNC;
01105 
01106         EMData * e = new EMData();
01107 
01108         if( is_real() ) {       //a real image has no imaginary part, throw exception
01109                 throw InvalidCallException("No imaginary part for a real image, this function call require a complex image.");
01110         }
01111         else {  //for complex image
01112                 if( !is_ri() ) {
01113                         throw InvalidCallException("This image is in amplitude/phase format, this function call require a complex image in real/imaginary format.");
01114                 }
01115                 int nx = get_xsize();
01116                 int ny = get_ysize();
01117                 int nz = get_zsize();
01118                 e->set_size(nx/2, ny, nz);
01119                 float * edata = e->get_data();
01120                 float * data = get_data();
01121                 for( int i=0; i<nx; i++ ) {
01122                         for( int j=0; j<ny; j++ ) {
01123                                 for( int k=0; k<nz; k++ ) {
01124                                         if( i%2 == 1 ) {
01125                                                 //complex data in format [real, complex, real, complex...]
01126                                                 edata[i/2+j*(nx/2)+k*(nx/2)*ny] = data[i+j*nx+k*nx*ny];
01127                                         }
01128                                 }
01129                         }
01130                 }
01131         }
01132 
01133         e->set_complex(false);
01134         if(e->get_ysize()==1 && e->get_zsize()==1) {
01135                 e->set_complex_x(false);
01136         }
01137         e->update();
01138         return e;
01139 
01140         EXITFUNC;
01141 }

void EMData::insert_rect_slice EMData w,
EMData myfft,
const Transform trans,
int  sizeofprojection,
float  xratio,
float  yratio,
float  zratio,
int  npad,
int  mult
 

Definition at line 1204 of file emdata_sparx.cpp.

References cmplx(), get_array_offsets(), mult(), nx, nxyz, ny, ny, nz, set_array_offsets(), sqrt(), EMAN::Vec2f, and EMAN::Vec3f.

Referenced by EMAN::nn4_rectReconstructor::insert_padfft_slice().

01205 {
01206         ENTERFUNC;
01207         vector<int> saved_offsets = get_array_offsets();
01208         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01209         set_array_offsets(0,1,1);
01210         myfft->set_array_offsets(0,1);
01211         
01212         // insert rectangular fft from my nn4_rect code
01213 
01214         Vec2f coordinate_2d_square;
01215         Vec3f coordinate_3dnew;
01216         Vec3f axis_newx;
01217         Vec3f axis_newy;
01218         Vec3f tempv;
01219         
01220         //begin of scaling factor calculation
01221         //unit vector x,y of 2D fft transformed to new positon after rotation and scaling
01222         axis_newx[0] = xratio*0.5f*(sizeofprojection*npad)*trans[0][0];
01223         axis_newx[1] = yratio*0.5f*(sizeofprojection*npad)*trans[0][1];
01224         axis_newx[2] = zratio*0.5f*(sizeofprojection*npad)*trans[0][2];
01225 
01226         float ellipse_length_x = std::sqrt(axis_newx[0]*axis_newx[0]+axis_newx[1]*axis_newx[1]+axis_newx[2]*axis_newx[2]);
01227         
01228         int ellipse_length_x_int = int(ellipse_length_x);
01229         float ellipse_step_x = 0.5f*(sizeofprojection*npad)/float(ellipse_length_x_int);
01230         float xscale = ellipse_step_x;//scal increased
01231 
01232         axis_newy[0] = xratio*0.5f*(sizeofprojection*npad)*trans[1][0];
01233         axis_newy[1] = yratio*0.5f*(sizeofprojection*npad)*trans[1][1];
01234         axis_newy[2] = zratio*0.5f*(sizeofprojection*npad)*trans[1][2];
01235 
01236 
01237 
01238         float ellipse_length_y = std::sqrt(axis_newy[0]*axis_newy[0]+axis_newy[1]*axis_newy[1]+axis_newy[2]*axis_newy[2]);
01239         int ellipse_length_y_int = int(ellipse_length_y);
01240         float ellipse_step_y = 0.5f*(sizeofprojection*npad)/float(ellipse_length_y_int);
01241         float yscale = ellipse_step_y;
01242         //end of scaling factor calculation
01243         std::complex<float> c1;
01244         int nxyz = sizeofprojection*npad;
01245 
01246         float r2=0.25f*sizeofprojection*npad*sizeofprojection*npad;
01247         float r2_at_point;
01248         
01249         for(int i=0;i<ellipse_length_x_int;i++) {
01250                 for(int j=-1*ellipse_length_y_int+1; j<=ellipse_length_y_int; j++) {
01251                     
01252                         r2_at_point=i*xscale*i*xscale+j*yscale*j*yscale;
01253                         if(r2_at_point<=r2 ) {
01254                                 
01255                                 
01256                                 coordinate_2d_square[0] = xscale*float(i);
01257                                 coordinate_2d_square[1] = yscale*float(j);
01258                                 float xnew = coordinate_2d_square[0]*trans[0][0] + coordinate_2d_square[1]*trans[1][0];
01259                                 float ynew = coordinate_2d_square[0]*trans[0][1] + coordinate_2d_square[1]*trans[1][1];
01260                                 float znew = coordinate_2d_square[0]*trans[0][2] + coordinate_2d_square[1]*trans[1][2];
01261                                 coordinate_3dnew[0] = xnew*xratio;
01262                                 coordinate_3dnew[1] = ynew*yratio;
01263                                 coordinate_3dnew[2] = znew*zratio;
01264                                 
01265                                 //bilinear interpolation
01266                                 float xp = coordinate_2d_square[0];
01267                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nxyz+coordinate_2d_square[1]+1;
01268                                 std::complex<float> lin_interpolated(0,0);
01269                                 int xlow=int(xp),xhigh=int(xp)+1;
01270                                 int ylow=int(yp),yhigh=int(yp)+1;
01271                                 float tx=xp-xlow,ty=yp-ylow;
01272 
01273                                 
01274                                 if(j == -1) {
01275                                         
01276                                         if(ylow<yp)
01277                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01278                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty) + myfft->cmplx(xhigh,yhigh)*tx*ty;
01279                                         else 
01280                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)
01281                                                 + myfft->cmplx(xhigh,ylow)*tx;
01282                                                                         
01283                                 } else {
01284                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01285                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
01286                                         
01287                                 }
01288                                         
01289                                 c1 = lin_interpolated;
01290                                 
01291                                 //now nearest neighborhood interpolation
01292                                 
01293                                 std::complex<float> btq;
01294                                 if ( coordinate_3dnew[0] < 0.) {
01295                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
01296                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
01297                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
01298                                         btq = conj(c1);
01299                                         } else {
01300                                         btq = c1;
01301                                         }
01302                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
01303                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
01304                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
01305 
01306                                 int iza, iya;
01307                                 if (izn >= 0)  iza = izn + 1;
01308                                 else           iza = nz + izn + 1;
01309 
01310                                 if (iyn >= 0) iya = iyn + 1;
01311                                 else          iya = ny + iyn + 1;
01312 
01313                                 cmplx(ixn,iya,iza) += btq*float(mult);
01314                                 (*w)(ixn,iya,iza) += mult;
01315                                         
01316                                 }
01317                         }
01318                             
01319                 }
01320 
01321 
01322         //end insert rectanular fft
01323                 
01324         set_array_offsets(saved_offsets);
01325         myfft->set_array_offsets(myfft_saved_offsets);
01326         EXITFUNC;
01327 
01328 }

void EMData::insert_rect_slice_ctf EMData w,
EMData myfft,
const Transform trans,
int  sizeofprojection,
float  xratio,
float  yratio,
float  zratio,
int  npad,
int  mult
 

helper function to insert rectangualr slice for ctf rect case

Definition at line 1767 of file emdata_sparx.cpp.

References cmplx(), EMAN::EMObject::f, get_array_offsets(), get_attr(), get_attr_default(), ctf_store_new::get_ctf(), ctf_store_new::init(), mult(), nx, nxyz, ny, ny, nz, set_array_offsets(), sqrt(), EMAN::Vec2f, and EMAN::Vec3f.

Referenced by EMAN::nn4_ctf_rectReconstructor::insert_padfft_slice().

01768 {
01769         ENTERFUNC;
01770         vector<int> saved_offsets = get_array_offsets();
01771         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01772         set_array_offsets(0,1,1);
01773         myfft->set_array_offsets(0,1);
01774         
01775         // insert rectangular fft from my nn4_rect code
01776 
01777         Vec2f coordinate_2d_square;
01778         Vec3f coordinate_3dnew;
01779         Vec3f axis_newx;
01780         Vec3f axis_newy;
01781         Vec3f tempv;
01782         
01783         //begin of scaling factor calculation
01784         //unit vector x,y of 2D fft transformed to new positon after rotation and scaling
01785         axis_newx[0] = xratio*0.5f*(sizeofprojection*npad)*trans[0][0];
01786         axis_newx[1] = yratio*0.5f*(sizeofprojection*npad)*trans[0][1];
01787         axis_newx[2] = zratio*0.5f*(sizeofprojection*npad)*trans[0][2];
01788 
01789         float ellipse_length_x = std::sqrt(axis_newx[0]*axis_newx[0]+axis_newx[1]*axis_newx[1]+axis_newx[2]*axis_newx[2]);
01790         
01791         int ellipse_length_x_int = int(ellipse_length_x);
01792         float ellipse_step_x = 0.5f*(sizeofprojection*npad)/float(ellipse_length_x_int);
01793         float xscale = ellipse_step_x;//scal increased
01794 
01795         axis_newy[0] = xratio*0.5f*(sizeofprojection*npad)*trans[1][0];
01796         axis_newy[1] = yratio*0.5f*(sizeofprojection*npad)*trans[1][1];
01797         axis_newy[2] = zratio*0.5f*(sizeofprojection*npad)*trans[1][2];
01798 
01799 
01800 
01801         float ellipse_length_y = std::sqrt(axis_newy[0]*axis_newy[0]+axis_newy[1]*axis_newy[1]+axis_newy[2]*axis_newy[2]);
01802         int ellipse_length_y_int = int(ellipse_length_y);
01803         float ellipse_step_y = 0.5f*(sizeofprojection*npad)/float(ellipse_length_y_int);
01804         float yscale = ellipse_step_y;
01805         //end of scaling factor calculation
01806         std::complex<float> c1;
01807         int nxyz = sizeofprojection*npad;
01808         Ctf* ctf = myfft->get_attr( "ctf" );
01809         ctf_store_new::init( nxyz, ctf );
01810         if(ctf) {delete ctf; ctf=0;}
01811         int remove = myfft->get_attr_default( "remove", 0 );
01812 
01813         float r2=0.25f*sizeofprojection*npad*sizeofprojection*npad;
01814         float r2_at_point;
01815         
01816         for(int i=0;i<ellipse_length_x_int;i++) {
01817                 for(int j=-1*ellipse_length_y_int+1; j<=ellipse_length_y_int; j++) {
01818                     
01819                         r2_at_point=i*xscale*i*xscale+j*yscale*j*yscale;
01820                         if(r2_at_point<=r2 && ! ((0==i) && (j<0))) {
01821                                 
01822                                 float ctf_value = ctf_store_new::get_ctf( r2_at_point );
01823                                 coordinate_2d_square[0] = xscale*float(i);
01824                                 coordinate_2d_square[1] = yscale*float(j);
01825                                 float xnew = coordinate_2d_square[0]*trans[0][0] + coordinate_2d_square[1]*trans[1][0];
01826                                 float ynew = coordinate_2d_square[0]*trans[0][1] + coordinate_2d_square[1]*trans[1][1];
01827                                 float znew = coordinate_2d_square[0]*trans[0][2] + coordinate_2d_square[1]*trans[1][2];
01828                                 coordinate_3dnew[0] = xnew*xratio;
01829                                 coordinate_3dnew[1] = ynew*yratio;
01830                                 coordinate_3dnew[2] = znew*zratio;
01831                                 
01832                                 //bilinear interpolation
01833                                 float xp = coordinate_2d_square[0];
01834                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nxyz+coordinate_2d_square[1]+1;
01835                                 std::complex<float> lin_interpolated(0,0);
01836                                 int xlow=int(xp),xhigh=int(xp)+1;
01837                                 int ylow=int(yp),yhigh=int(yp)+1;
01838                                 float tx=xp-xlow,ty=yp-ylow;
01839 
01840                                 
01841                                 if(j == -1) {
01842                                         
01843                                         if(ylow<yp)
01844                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01845                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty) + myfft->cmplx(xhigh,yhigh)*tx*ty;
01846                                         else 
01847                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)
01848                                                 + myfft->cmplx(xhigh,ylow)*tx;
01849                                                                         
01850                                 } else {
01851                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01852                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
01853                                         
01854                                 }
01855                                         
01856                                 c1 = lin_interpolated;
01857                                 
01858                                 //now nearest neighborhood interpolation
01859                                 
01860                                 std::complex<float> btq;
01861                                 if ( coordinate_3dnew[0] < 0.) {
01862                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
01863                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
01864                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
01865                                         btq = conj(c1);
01866                                         } else {
01867                                         btq = c1;
01868                                         }
01869                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
01870                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
01871                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
01872 
01873                                 int iza, iya;
01874                                 if (izn >= 0)  iza = izn + 1;
01875                                 else           iza = nz + izn + 1;
01876 
01877                                 if (iyn >= 0) iya = iyn + 1;
01878                                 else          iya = ny + iyn + 1;
01879 
01880                                 if(remove > 0 ) {
01881                                         cmplx(ixn,iya,iza) -= btq*ctf_value*float(mult);
01882                                         (*w)(ixn,iya,iza) -= ctf_value*ctf_value*mult;
01883                                         } else {
01884                                         cmplx(ixn,iya,iza) += btq*ctf_value*float(mult);
01885                                         (*w)(ixn,iya,iza) += ctf_value*ctf_value*mult;
01886                                         }
01887                                         
01888                                 }
01889                         }
01890                             
01891                 }
01892 
01893 
01894         //end insert rectanular fft
01895                 
01896         set_array_offsets(saved_offsets);
01897         myfft->set_array_offsets(myfft_saved_offsets);
01898         EXITFUNC;
01899 
01900 }
01901 

void EMData::insert_rect_slice_ctf_applied EMData w,
EMData myfft,
const Transform trans,
int  sizeofprojection,
float  xratio,
float  yratio,
float  zratio,
int  npad,
int  mult
 

Definition at line 1904 of file emdata_sparx.cpp.

References cmplx(), EMAN::EMObject::f, get_array_offsets(), get_attr(), get_attr_default(), ctf_store_new::get_ctf(), ctf_store_new::init(), mult(), nx, nxyz, ny, ny, nz, set_array_offsets(), sqrt(), EMAN::Vec2f, and EMAN::Vec3f.

Referenced by EMAN::nn4_ctf_rectReconstructor::insert_padfft_slice().

01904 {
01905         ENTERFUNC;
01906         vector<int> saved_offsets = get_array_offsets();
01907         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01908         set_array_offsets(0,1,1);
01909         myfft->set_array_offsets(0,1);
01910         
01911         // insert rectangular fft from my nn4_rect code
01912 
01913         Vec2f coordinate_2d_square;
01914         Vec3f coordinate_3dnew;
01915         Vec3f axis_newx;
01916         Vec3f axis_newy;
01917         Vec3f tempv;
01918         
01919         //begin of scaling factor calculation
01920         //unit vector x,y of 2D fft transformed to new positon after rotation and scaling
01921         axis_newx[0] = xratio*0.5f*(sizeofprojection*npad)*trans[0][0];
01922         axis_newx[1] = yratio*0.5f*(sizeofprojection*npad)*trans[0][1];
01923         axis_newx[2] = zratio*0.5f*(sizeofprojection*npad)*trans[0][2];
01924 
01925         float ellipse_length_x = std::sqrt(axis_newx[0]*axis_newx[0]+axis_newx[1]*axis_newx[1]+axis_newx[2]*axis_newx[2]);
01926         
01927         int ellipse_length_x_int = int(ellipse_length_x);
01928         float ellipse_step_x = 0.5f*(sizeofprojection*npad)/float(ellipse_length_x_int);
01929         float xscale = ellipse_step_x;//scal increased
01930 
01931         axis_newy[0] = xratio*0.5f*(sizeofprojection*npad)*trans[1][0];
01932         axis_newy[1] = yratio*0.5f*(sizeofprojection*npad)*trans[1][1];
01933         axis_newy[2] = zratio*0.5f*(sizeofprojection*npad)*trans[1][2];
01934 
01935 
01936 
01937         float ellipse_length_y = std::sqrt(axis_newy[0]*axis_newy[0]+axis_newy[1]*axis_newy[1]+axis_newy[2]*axis_newy[2]);
01938         int ellipse_length_y_int = int(ellipse_length_y);
01939         float ellipse_step_y = 0.5f*(sizeofprojection*npad)/float(ellipse_length_y_int);
01940         float yscale = ellipse_step_y;
01941         //end of scaling factor calculation
01942         std::complex<float> c1;
01943         int nxyz = sizeofprojection*npad;
01944         Ctf* ctf = myfft->get_attr( "ctf" );
01945         ctf_store_new::init( nxyz, ctf );
01946         if(ctf) {delete ctf; ctf=0;}
01947         int remove = myfft->get_attr_default( "remove", 0 );
01948 
01949         float r2=0.25f*sizeofprojection*npad*sizeofprojection*npad;
01950         float r2_at_point;
01951         
01952         for(int i=0;i<ellipse_length_x_int;i++) {
01953                 for(int j=-1*ellipse_length_y_int+1; j<=ellipse_length_y_int; j++) {
01954                     
01955                         r2_at_point=i*xscale*i*xscale+j*yscale*j*yscale;
01956                         if(r2_at_point<=r2 && ! ((0==i) && (j<0))) {
01957                                 
01958                                 float ctf_value = ctf_store_new::get_ctf( r2_at_point );
01959                                 coordinate_2d_square[0] = xscale*float(i);
01960                                 coordinate_2d_square[1] = yscale*float(j);
01961                                 float xnew = coordinate_2d_square[0]*trans[0][0] + coordinate_2d_square[1]*trans[1][0];
01962                                 float ynew = coordinate_2d_square[0]*trans[0][1] + coordinate_2d_square[1]*trans[1][1];
01963                                 float znew = coordinate_2d_square[0]*trans[0][2] + coordinate_2d_square[1]*trans[1][2];
01964                                 coordinate_3dnew[0] = xnew*xratio;
01965                                 coordinate_3dnew[1] = ynew*yratio;
01966                                 coordinate_3dnew[2] = znew*zratio;
01967                                 
01968                                 //bilinear interpolation
01969                                 float xp = coordinate_2d_square[0];
01970                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nxyz+coordinate_2d_square[1]+1;
01971                                 std::complex<float> lin_interpolated(0,0);
01972                                 int xlow=int(xp),xhigh=int(xp)+1;
01973                                 int ylow=int(yp),yhigh=int(yp)+1;
01974                                 float tx=xp-xlow,ty=yp-ylow;
01975 
01976                                 
01977                                 if(j == -1) {
01978                                         
01979                                         if(ylow<yp)
01980                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01981                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty) + myfft->cmplx(xhigh,yhigh)*tx*ty;
01982                                         else
01983                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)
01984                                                 + myfft->cmplx(xhigh,ylow)*tx;
01985                                                                         
01986                                 } else {
01987                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01988                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
01989                                 }
01990                                         
01991                                 c1 = lin_interpolated;
01992                                 
01993                                 //now nearest neighborhood interpolation
01994                                 
01995                                 std::complex<float> btq;
01996                                 if ( coordinate_3dnew[0] < 0.) {
01997                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
01998                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
01999                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
02000                                         btq = conj(c1);
02001                                         } else {
02002                                                 btq = c1;
02003                                         }
02004                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
02005                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
02006                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
02007 
02008                                 int iza, iya;
02009                                 if (izn >= 0)  iza = izn + 1;
02010                                 else           iza = nz + izn + 1;
02011 
02012                                 if (iyn >= 0) iya = iyn + 1;
02013                                 else          iya = ny + iyn + 1;
02014 
02015                                 if(remove > 0 ) {
02016                                         cmplx(ixn,iya,iza) -= btq*float(mult);
02017                                         (*w)(ixn,iya,iza) -= ctf_value*ctf_value*mult;
02018                                         } else {
02019                                         cmplx(ixn,iya,iza) += btq*float(mult);
02020                                         (*w)(ixn,iya,iza) += ctf_value*ctf_value*mult;
02021                                         }
02022                                         
02023                                 }
02024                         }
02025                             
02026                 }
02027 
02028 
02029         //end insert rectanular fft
02030                 
02031         set_array_offsets(saved_offsets);
02032         myfft->set_array_offsets(myfft_saved_offsets);
02033         EXITFUNC;
02034 
02035 }
02036 

void EMData::insert_scaled_sum EMData block,
const FloatPoint center,
float  scale = 1.0,
float  mult_factor = 1.0
 

Add a scaled image into another image at a specified location.

This is used, for example, to accumulate gaussians in programs like pdb2mrc.py. The center of 'block' will be positioned at 'center' with scale factor 'scale'. Densities will be interpolated in 'block' and multiplied by 'mult'.

Parameters:
block The image to inserted.
center The center of the inserted block in 'this'.
scale Scale factor.
mult_factor Number used to multiply the block's densities.
Exceptions:
ImageDimensionException If 'this' image is not 2D/3D.

Definition at line 1842 of file emdata_transform.cpp.

References data, get_data(), get_ndim(), get_xsize(), get_ysize(), get_zsize(), ImageDimensionException, LOGERR, nx, sget_value_at_interp(), update(), x, and y.

01844 {
01845         ENTERFUNC;
01846         float * data = get_data();
01847         if (get_ndim()==3) {
01848                 // Start by determining the region to operate on
01849                 int xs=(int)floor(block->get_xsize()*scale/2.0);
01850                 int ys=(int)floor(block->get_ysize()*scale/2.0);
01851                 int zs=(int)floor(block->get_zsize()*scale/2.0);
01852                 int x0=(int)center[0]-xs;
01853                 int x1=(int)center[0]+xs;
01854                 int y0=(int)center[1]-ys;
01855                 int y1=(int)center[1]+ys;
01856                 int z0=(int)center[2]-zs;
01857                 int z1=(int)center[2]+zs;
01858 
01859                 if (x1<0||y1<0||z1<0||x0>get_xsize()||y0>get_ysize()||z0>get_zsize()) return;   // object is completely outside the target volume
01860 
01861                 // make sure we stay inside the volume
01862                 if (x0<0) x0=0;
01863                 if (y0<0) y0=0;
01864                 if (z0<0) z0=0;
01865                 if (x1>=get_xsize()) x1=get_xsize()-1;
01866                 if (y1>=get_ysize()) y1=get_ysize()-1;
01867                 if (z1>=get_zsize()) z1=get_zsize()-1;
01868 
01869                 float bx=block->get_xsize()/2.0f;
01870                 float by=block->get_ysize()/2.0f;
01871                 float bz=block->get_zsize()/2.0f;
01872 
01873                 size_t idx;
01874                 for (int x=x0; x<=x1; x++) {
01875                         for (int y=y0; y<=y1; y++) {
01876                                 for (int z=z0; z<=z1; z++) {
01877                                         idx = x + y * nx + (size_t)z * nx * ny;
01878                                         data[idx] +=
01879                                                 block->sget_value_at_interp((x-center[0])/scale+bx,(y-center[1])/scale+by,(z-center[2])/scale+bz);
01880                                 }
01881                         }
01882                 }
01883                 update();
01884         }
01885         else if (get_ndim()==2) {
01886                 // Start by determining the region to operate on
01887                 int xs=(int)floor(block->get_xsize()*scale/2.0);
01888                 int ys=(int)floor(block->get_ysize()*scale/2.0);
01889                 int x0=(int)center[0]-xs;
01890                 int x1=(int)center[0]+xs;
01891                 int y0=(int)center[1]-ys;
01892                 int y1=(int)center[1]+ys;
01893 
01894                 if (x1<0||y1<0||x0>get_xsize()||y0>get_ysize()) return; // object is completely outside the target volume
01895 
01896                 // make sure we stay inside the volume
01897                 if (x0<0) x0=0;
01898                 if (y0<0) y0=0;
01899                 if (x1>=get_xsize()) x1=get_xsize()-1;
01900                 if (y1>=get_ysize()) y1=get_ysize()-1;
01901 
01902                 float bx=block->get_xsize()/2.0f;
01903                 float by=block->get_ysize()/2.0f;
01904 
01905                 for (int x=x0; x<=x1; x++) {
01906                         for (int y=y0; y<=y1; y++) {
01907                                 data[x + y * nx] +=
01908                                         block->sget_value_at_interp((x-center[0])/scale+bx,(y-center[1])/scale+by);
01909                         }
01910                 }
01911                 update();
01912         }
01913         else {
01914                 LOGERR("insert_scaled_sum supports only 2D and 3D data");
01915                 throw ImageDimensionException("2D/3D only");
01916         }
01917 
01918         EXITFUNC;
01919 }

bool EMAN::EMData::is_complex  )  const [inline]
 

Is this a complex image?

Returns:
Whether this is a complex image or not.

Definition at line 986 of file emdata.h.

Referenced by add(), EMAN::TomoAverager::add_image(), EMAN::Util::add_img2(), add_incoherent(), EMAN::Util::addn_img(), addsquare(), ap2ri(), apply_radial_func(), EMAN::Util::BPCQ(), calc_az_dist(), calc_ccf(), calc_fourier_shell_correlation(), calc_highest_locations(), calc_hist(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), calc_radial_dist(), cconj(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), common_lines(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), EMAN::MatchSFProcessor::create_radial_func(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), find_pixels_with_value(), EMAN::Phase180Processor::fourier_phaseshift180(), EMAN::fourierproduct(), get_attr(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::Util::histc(), EMAN::Util::histogram(), log(), log10(), EMAN::Util::madn_scalar(), EMAN::Util::mul_img(), EMAN::Util::muln_img(), mult(), EMAN::Util::mult_scalar(), EMAN::periodogram(), EMAN::CtfSimProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), EMAN::Wiener2DAutoAreaProcessor::process(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::FFTResampleProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::LowpassRandomPhaseProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), EMAN::GaussFFTProjector::project3d(), real2complex(), real2FH(), render_amp24(), render_ap24(), ri2ap(), ri2inten(), setup4slice(), EMAN::FourierReconstructor::setup_seed(), sqrt(), sub(), EMAN::Util::subn_img(), subsquare(), to_one(), to_zero(), uncut_slice(), update_stat(), window_center(), and write_image().

bool EMAN::EMData::is_complex_x  )  const [inline]
 

Is this image a 1D FFT image in X direction?

Returns:
Whether this image is a 1D FFT image in X direction.

Definition at line 1065 of file emdata.h.

Referenced by calc_ccfx().

bool EMAN::EMData::is_fftodd  )  const [inline]
 

Does this image correspond to a (real-space) odd nx?

Returns:
Whether this image has a (real-space) odd nx.

Definition at line 1202 of file emdata.h.

Referenced by EMAN::Util::addn_img(), calc_fourier_shell_correlation(), cconj(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::Processor::EMFourierFilterFunc(), EMAN::fourierproduct(), EMAN::Util::madn_scalar(), EMAN::Util::muln_img(), EMAN::Util::mult_scalar(), nn_SSNR(), nn_SSNR_ctf(), EMAN::Util::pack_complex_to_real(), EMAN::periodogram(), EMAN::Util::subn_img(), window_center(), EMAN::Util::WTF(), and EMAN::Util::WTM().

bool EMAN::EMData::is_fftpadded  )  const [inline]
 

Is this image already extended along x for ffts?

Returns:
Whether this image is extended along x for ffts.

Definition at line 1169 of file emdata.h.

Referenced by do_fft(), do_fft_inplace(), window_center(), EMAN::Util::WTF(), and EMAN::Util::WTM().

bool EMAN::EMData::is_FH  )  const [inline]
 

Is this a FH image?

Returns:
Whether this is a FH image or not.

Definition at line 969 of file emdata.h.

bool EMAN::EMData::is_flipped  )  const [inline]
 

Is this image flipped?

Returns:
Whether this image is flipped or not.

Definition at line 1099 of file emdata.h.

bool EMAN::EMData::is_real  )  const [inline]
 

Is this a real image?

Returns:
Whether this is image is real (not complex) or not.

Definition at line 1005 of file emdata.h.

Referenced by absi(), add(), amplitude(), div(), EMAN::fourierproduct(), imag(), mult(), mult_complex_efficient(), phase(), EMAN::RotateInFSProcessor::process_inplace(), real(), sub(), EMAN::Util::WTF(), and EMAN::Util::WTM().

01008         {

bool EMAN::EMData::is_ri  )  const [inline]
 

Is this image a real/imaginary format complex image?

Returns:
Whether this image is real/imaginary format complex image.

Definition at line 1135 of file emdata.h.

Referenced by absi(), amplitude(), ap2ri(), calc_az_dist(), calc_highest_locations(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), calc_radial_dist(), cconj(), do_ift(), do_ift_inplace(), imag(), phase(), real(), ri2ap(), ri2inten(), and update_stat().

bool EMAN::EMData::is_shuffled  )  const [inline]
 

Has this image been shuffled?

Returns:
Whether this image has been shuffled to put origin in the center.

Definition at line 952 of file emdata.h.

Referenced by EMAN::FourierGriddingProjector::project3d(), and write_image().

EMData * EMData::little_big_dot EMData little_img,
bool  do_sigma = false
 

This does a normalized dot product of a little image with a big image using real-space methods.

The result is the same size as 'this', but a border 1/2 the size of 'little_img' will be zero. This routine is only efficient when 'little_img' is fairly small.

Parameters:
little_img A small image.
do_sigma Calculate sigma or not.
Exceptions:
ImageDimensionException If the image is not 1D/2D.
Returns:
normalized dot product image.

Definition at line 1292 of file emdata.cpp.

References copy_head(), data, dot(), dot(), get_attr(), get_data(), get_edge_mean(), get_ndim(), get_xsize(), get_ysize(), ImageDimensionException, nx, ny, nz, set_size(), sqrt(), square, to_zero(), and update().

01293 {
01294         ENTERFUNC;
01295 
01296         if (get_ndim() > 2) {
01297                 throw ImageDimensionException("1D/2D only");
01298         }
01299 
01300         EMData *ret = copy_head();
01301         ret->set_size(nx,ny,nz);
01302         ret->to_zero();
01303 
01304         int nx2 = with->get_xsize();
01305         int ny2 = with->get_ysize();
01306         float em = with->get_edge_mean();
01307 
01308         float *data = get_data();
01309         float *with_data = with->get_data();
01310         float *ret_data = ret->get_data();
01311 
01312         float sum2 = (Util::square((float)with->get_attr("sigma")) +
01313                                   Util::square((float)with->get_attr("mean")));
01314         if (do_sigma) {
01315                 for (int j = ny2 / 2; j < ny - ny2 / 2; j++) {
01316                         for (int i = nx2 / 2; i < nx - nx2 / 2; i++) {
01317                                 float sum = 0;
01318                                 float sum1 = 0;
01319                                 float summ = 0;
01320                                 int k = 0;
01321 
01322                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01323                                         for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01324                                                 int l = ii + jj * nx;
01325                                                 sum1 += Util::square(data[l]);
01326                                                 summ += data[l];
01327                                                 sum += data[l] * with_data[k];
01328                                                 k++;
01329                                         }
01330                                 }
01331                                 float tmp_f1 = (sum1 / 2.0f - sum) / (nx2 * ny2);
01332                                 float tmp_f2 = Util::square((float)with->get_attr("mean") -
01333                                                                                         summ / (nx2 * ny2));
01334                                 ret_data[i + j * nx] = sum2 + tmp_f1 - tmp_f2;
01335                         }
01336                 }
01337         }
01338         else {
01339                 for (int j = ny2 / 2; j < ny - ny2 / 2; j++) {
01340                         for (int i = nx2 / 2; i < nx - nx2 / 2; i++) {
01341                                 float eml = 0;
01342                                 float dot = 0;
01343                                 float dot2 = 0;
01344 
01345                                 for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01346                                         eml += data[ii + (j - ny2 / 2) * nx] + data[ii + (j + ny2 / 2 - 1) * nx];
01347                                 }
01348 
01349                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01350                                         eml += data[i - nx2 / 2 + jj * nx] + data[i + nx2 / 2 - 1 + jj * nx];
01351                                 }
01352 
01353                                 eml /= (nx2 + ny2) * 2.0f;
01354                                 int k = 0;
01355 
01356                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01357                                         for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01358                                                 dot += (data[ii + jj * nx] - eml) * (with_data[k] - em);
01359                                                 dot2 += Util::square(data[ii + jj * nx] - eml);
01360                                                 k++;
01361                                         }
01362                                 }
01363 
01364                                 dot2 = std::sqrt(dot2);
01365 
01366                                 if (dot2 == 0) {
01367                                         ret_data[i + j * nx] = 0;
01368                                 }
01369                                 else {
01370                                         ret_data[i + j * nx] = dot / (nx2 * ny2 * dot2 * (float)with->get_attr("sigma"));
01371                                 }
01372                         }
01373                 }
01374         }
01375 
01376         ret->update();
01377 
01378         EXITFUNC;
01379         return ret;
01380 }

EMData * EMData::log  )  const
 

return natural logarithm image for a image

Returns:
a image which is the natural logarithm of this image
Exceptions:
InvalidValueException pixel value must be >= 0
ImageFormatException real image only

Definition at line 989 of file emdata_core.cpp.

References copy(), data, get_data(), ImageFormatException, InvalidValueException, is_complex(), log(), and update().

00990 {
00991         ENTERFUNC;
00992 
00993         if (is_complex()) {
00994                 throw ImageFormatException("real image only");
00995         }
00996 
00997         EMData * r = this->copy();
00998         float * new_data = r->get_data();
00999         float * data = get_data();
01000         size_t size = nxyz;
01001         for (size_t i = 0; i < size; ++i) {
01002                 if(data[i] < 0) {
01003                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
01004                 }
01005                 else {
01006                         if(data[i]) {   //do nothing with pixel has value zero
01007                                 new_data[i] = std::log(data[i]);
01008                         }
01009                 }
01010         }
01011 
01012         r->update();
01013         return r;
01014 
01015         EXITFUNC;
01016 }

EMData * EMData::log10  )  const
 

return base 10 logarithm image for a image

Returns:
a image which is the base 10 logarithm of this image
Exceptions:
InvalidValueException pixel value must be >= 0
ImageFormatException real image only

Definition at line 1019 of file emdata_core.cpp.

References copy(), data, get_data(), ImageFormatException, InvalidValueException, is_complex(), log10(), and update().

01020 {
01021         ENTERFUNC;
01022 
01023         if (is_complex()) {
01024                 throw ImageFormatException("real image only");
01025         }
01026 
01027         EMData * r = this->copy();
01028         float * new_data = r->get_data();
01029         float * data = get_data();
01030         size_t size = nxyz;
01031         for (size_t i = 0; i < size; ++i) {
01032                 if(data[i] < 0) {
01033                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
01034                 }
01035                 else {
01036                         if(data[i]) {   //do nothing with pixel has value zero
01037                                 new_data[i] = std::log10(data[i]);
01038                         }
01039                 }
01040         }
01041 
01042         r->update();
01043         return r;
01044 
01045         EXITFUNC;
01046 }

EMData * EMData::make_footprint int  type = 0  ) 
 

Makes a 'footprint' for the current image.

This is image containing a rotational & translational invariant of the parent image. The size of the resulting image depends on the selected type.

type 0- The original, default footprint derived from the rotational footprint types 1-6 - bispectrum-based types 1,3,5 - returns Fouier-like images types 2,4,6 - returns real-space-like images type 1,2 - simple r1,r2, 2-D footprints type 3,4 - r1,r2,anle 3D footprints type 5,6 - same as 1,2 but with the cube root of the final products used

Parameters:
type Select one of several possible algorithms for producing the invariants
Exceptions:
ImageFormatException If image size is not even.
Returns:
The footprint image.

Definition at line 1956 of file emdata.cpp.

References abs, calc_ccfx(), do_fft(), do_ift(), dot(), dot(), EMData(), get_clip(), get_complex_at(), get_value_at(), get_xsize(), get_ysize(), make_rotational_footprint_e1(), mult(), norm(), process_inplace(), set_complex(), set_value_at(), to_zero(), and UnexpectedBehaviorException.

01957 {
01958 //      printf("Make fp %d\n",type);
01959         if (type==0) {
01960                 EMData *un=make_rotational_footprint_e1(); // Use EMAN1's footprint strategy
01961                 if (un->get_ysize() <= 6) {
01962                         throw UnexpectedBehaviorException("In EMData::make_footprint. The rotational footprint is too small");
01963                 }
01964                 EMData *tmp=un->get_clip(Region(0,4,un->get_xsize(),un->get_ysize()-6));        // 4 and 6 are empirical
01965                 EMData *cx=tmp->calc_ccfx(tmp,0,-1,1);
01966                 EMData *fp=cx->get_clip(Region(0,0,cx->get_xsize()/2,cx->get_ysize()));
01967                 delete un;
01968                 delete tmp;
01969                 delete cx;
01970                 return fp;
01971         }
01972         else if (type==1 || type==2 ||type==5 || type==6) {
01973                 int i,j,kx,ky,lx,ly;
01974 
01975                 EMData *fft=do_fft();
01976 
01977                 // map for x,y -> radius for speed
01978                 int rmax=(get_xsize()+1)/2;
01979                 float *rmap=(float *)malloc(rmax*rmax*sizeof(float));
01980                 for (i=0; i<rmax; i++) {
01981                         for (j=0; j<rmax; j++) {
01982 #ifdef _WIN32
01983                                 rmap[i+j*rmax]=_hypotf((float)i,(float)j);
01984 #else
01985                                 rmap[i+j*rmax]=hypot((float)i,(float)j);
01986 #endif  //_WIN32
01987 //                              printf("%d\t%d\t%f\n",i,j,rmap[i+j*rmax]);
01988                         }
01989                 }
01990 
01991                 EMData *fp=new EMData(rmax*2+2,rmax*2,1);
01992                 fp->set_complex(1);
01993                 fp->to_zero();
01994 
01995                 // Two vectors in to complex space (kx,ky) and (lx,ly)
01996                 // We are computing the bispectrum, f(k).f(l).f*(k+l)
01997                 // but integrating out two dimensions, leaving |k|,|l|
01998                 for (kx=-rmax+1; kx<rmax; kx++) {
01999                         for (ky=-rmax+1; ky<rmax; ky++) {
02000                                 for (lx=-rmax+1; lx<rmax; lx++) {
02001                                         for (ly=-rmax+1; ly<rmax; ly++) {
02002                                                 int ax=kx+lx;
02003                                                 int ay=ky+ly;
02004                                                 if (abs(ax)>=rmax || abs(ay)>=rmax) continue;
02005                                                 int r1=(int)floor(.5+rmap[abs(kx)+rmax*abs(ky)]);
02006                                                 int r2=(int)floor(.5+rmap[abs(lx)+rmax*abs(ly)]);
02007 //                                              if (r1>500 ||r2>500) printf("%d\t%d\t%d\t%d\t%d\t%d\n",kx,ky,lx,ly,r1,r2);
02008 //                                              float r3=rmap[ax+rmax*ay];
02009                                                 if (r1+r2>=rmax) continue;
02010 
02011                                                 std::complex<float> p=fft->get_complex_at(kx,ky)*fft->get_complex_at(lx,ly)*conj(fft->get_complex_at(ax,ay));
02012                                                 fp->set_value_at(r1*2,r2,p.real()+fp->get_value_at(r1*2,r2));           // We keep only the real component in anticipation of zero phase sum
02013 //                                              fp->set_value_at(r1*2,rmax*2-r2-1,  fp->get_value_at(r1*2,r2));         // We keep only the real component in anticipation of zero phase sum
02014 //                                              fp->set_value_at(r1*2+1,r2,p.real()+fp->get_value_at(r1*2+1,r2));               // We keep only the real component in anticipation of zero phase sum
02015                                                 fp->set_value_at(r1*2+1,r2,fp->get_value_at(r1*2+1,r2)+1);                      // a normalization counter
02016                                         }
02017                                 }
02018                         }
02019                 }
02020 
02021                 // Normalizes the pixels based on the accumulated counts then sets the imaginary components back to zero
02022                 if (type==5 || type==6) {
02023                         for (i=0; i<rmax*2; i+=2) {
02024                                 for (j=0; j<rmax; j++) {
02025                                         float norm=fp->get_value_at(i+1,j);
02026 #ifdef _WIN32
02027                                         fp->set_value_at(i,rmax*2-j-1,pow(fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm), 1.0f/3.0f));
02028                                         fp->set_value_at(i,j,pow(fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm), 1.0f/3.0f));
02029 #else
02030                                         fp->set_value_at(i,rmax*2-j-1,cbrt(fp->get_value_at(i,j)/(norm==0?1.0:norm)));
02031                                         fp->set_value_at(i,j,cbrt(fp->get_value_at(i,j)/(norm==0?1.0:norm)));
02032 #endif  //_WIN32
02033                                         fp->set_value_at(i+1,j,0.0);
02034                                 }
02035                         }
02036                 }
02037                 else {
02038                         for (i=0; i<rmax*2; i+=2) {
02039                                 for (j=0; j<rmax; j++) {
02040                                         float norm=fp->get_value_at(i+1,j);
02041                                         fp->set_value_at(i,rmax*2-j-1,fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm));
02042                                         fp->set_value_at(i,j,fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm));
02043                                         fp->set_value_at(i+1,j,0.0);
02044                                 }
02045                         }
02046                 }
02047 
02048                 free(rmap);
02049                 if (type==2||type==6) {
02050                         EMData *f2=fp->do_ift();
02051                         if (f2->get_value_at(0,0)<0) f2->mult(-1.0f);
02052                         f2->process_inplace("xform.phaseorigin.tocorner");
02053                         delete fp;
02054                         return f2;
02055                 }
02056                 return fp;
02057         }
02058         else if (type==3 || type==4) {
02059                 int h,i,j,kx,ky,lx,ly;
02060 
02061                 EMData *fft=do_fft();
02062 
02063                 // map for x,y -> radius for speed
02064                 int rmax=(get_xsize()+1)/2;
02065                 float *rmap=(float *)malloc(rmax*rmax*sizeof(float));
02066                 for (i=0; i<rmax; i++) {
02067                         for (j=0; j<rmax; j++) {
02068 #ifdef _WIN32
02069                                 rmap[i+j*rmax]=_hypotf((float)i,(float)j);
02070 #else
02071                                 rmap[i+j*rmax]=hypot((float)i,(float)j);
02072 #endif  //_WIN32
02073 //                              printf("%d\t%d\t%f\n",i,j,rmap[i+j*rmax]);
02074                         }
02075                 }
02076 
02077                 EMData *fp=new EMData(rmax*2+2,rmax*2,16);
02078 
02079                 fp->set_complex(1);
02080                 fp->to_zero();
02081 
02082                 // Two vectors in to complex space (kx,ky) and (lx,ly)
02083                 // We are computing the bispectrum, f(k).f(l).f*(k+l)
02084                 // but integrating out two dimensions, leaving |k|,|l|
02085                 for (kx=-rmax+1; kx<rmax; kx++) {
02086                         for (ky=-rmax+1; ky<rmax; ky++) {
02087                                 for (lx=-rmax+1; lx<rmax; lx++) {
02088                                         for (ly=-rmax+1; ly<rmax; ly++) {
02089                                                 int ax=kx+lx;
02090                                                 int ay=ky+ly;
02091                                                 if (abs(ax)>=rmax || abs(ay)>=rmax) continue;
02092                                                 float rr1=rmap[abs(kx)+rmax*abs(ky)];
02093                                                 float rr2=rmap[abs(lx)+rmax*abs(ly)];
02094                                                 int r1=(int)floor(.5+rr1);
02095                                                 int r2=(int)floor(.5+rr2);
02096 //                                              if (r1>500 ||r2>500) printf("%d\t%d\t%d\t%d\t%d\t%d\n",kx,ky,lx,ly,r1,r2);
02097 //                                              float r3=rmap[ax+rmax*ay];
02098                                                 if (r1+r2>=rmax || rr1==0 ||rr2==0) continue;
02099 
02100                                                 std::complex<float> p=fft->get_complex_at(kx,ky)*fft->get_complex_at(lx,ly)*conj(fft->get_complex_at(ax,ay));
02101                                                 int dot=(int)floor((kx*lx+ky*ly)/(rr1*rr2)*7.5);                                        // projection of k on l 0-31
02102                                                 if (dot<0) dot=16+dot;
02103 //                                              int dot=(int)floor((kx*lx+ky*ly)/(rr1*rr2)*7.5+8.0);                                    // projection of k on l 0-15
02104                                                 fp->set_value_at(r1*2,r2,dot,p.real()+fp->get_value_at(r1*2,r2,dot));           // We keep only the real component in anticipation of zero phase sum
02105 //                                              fp->set_value_at(r1*2,rmax*2-r2-1,  fp->get_value_at(r1*2,r2));         // We keep only the real component in anticipation of zero phase sum
02106 //                                              fp->set_value_at(r1*2+1,r2,p.real()+fp->get_value_at(r1*2+1,r2));               // We keep only the real component in anticipation of zero phase sum
02107                                                 fp->set_value_at(r1*2+1,r2,dot,fp->get_value_at(r1*2+1,r2,dot)+1);                      // a normalization counter
02108                                         }
02109                                 }
02110                         }
02111                 }
02112 
02113                 // Normalizes the pixels based on the accumulated counts then sets the imaginary components back to zero
02114                 for (i=0; i<rmax*2; i+=2) {
02115                         for (j=0; j<rmax; j++) {
02116                                 for (h=0; h<16; h++) {
02117                                         float norm=fp->get_value_at(i+1,j,h);
02118 //                                      fp->set_value_at(i,rmax*2-j-1,h,cbrt(fp->get_value_at(i,j,h)/(norm==0?1.0:norm)));
02119 //                                      fp->set_value_at(i,j,h,cbrt(fp->get_value_at(i,j,h)/(norm==0?1.0:norm)));
02120                                         fp->set_value_at(i,rmax*2-j-1,h,(fp->get_value_at(i,j,h)/(norm==0.0f?1.0f:norm)));
02121                                         fp->set_value_at(i,j,h,(fp->get_value_at(i,j,h)/(norm==0.0f?1.0f:norm)));
02122         //                              fp->set_value_at(i,rmax*2-j-1,fp->get_value_at(i,j)/(norm==0?1.0:norm));
02123         //                              fp->set_value_at(i,j,fp->get_value_at(i,j)/(norm==0?1.0:norm));
02124                                         fp->set_value_at(i+1,j,h,0.0);
02125                                 }
02126                         }
02127                 }
02128 
02129                 free(rmap);
02130                 if (type==4) {
02131                         EMData *f2=fp->do_ift();
02132                         if (f2->get_value_at(0,0,0)<0) f2->mult(-1.0f);
02133                         f2->process_inplace("xform.phaseorigin.tocorner");
02134                         delete fp;
02135                         return f2;
02136                 }
02137                 return fp;
02138         }
02139         throw UnexpectedBehaviorException("There is not implementation for the parameters you specified");
02140 }

EMData * EMData::make_rotational_footprint_cmc bool  unwrap = true  ) 
 

Definition at line 1731 of file emdata.cpp.

References calc_mutual_correlation(), EMData(), get_edge_mean(), get_xsize(), get_ysize(), get_zsize(), nx, nx, ny, nz, process_inplace(), rot_fp, set_complex(), set_size(), sub(), to_one(), unwrap(), and update_stat().

Referenced by EMAN::RotationalAligner::align_180_ambiguous().

01731                                                           {
01732         ENTERFUNC;
01733         update_stat();
01734         // Note that rotational_footprint caching saves a large amount of time
01735         // but this is at the expense of memory. Note that a policy is hardcoded here,
01736         // that is that caching is only employed when premasked is false and unwrap
01737         // is true - this is probably going to be what is used in most scenarios
01738         // as advised by Steve Ludtke - In terms of performance this caching doubles the metric
01739         // generated by e2speedtest.
01740         if ( rot_fp != 0 && unwrap == true) {
01741                 return new EMData(*rot_fp);
01742         }
01743 
01744         static EMData obj_filt;
01745         EMData* filt = &obj_filt;
01746         filt->set_complex(true);
01747 
01748 
01749         // The filter object is nothing more than a cached high pass filter
01750         // Ultimately it is used an argument to the EMData::mult(EMData,prevent_complex_multiplication (bool))
01751         // function in calc_mutual_correlation. Note that in the function the prevent_complex_multiplication
01752         // set to true, which is used for speed reasons.
01753         if (filt->get_xsize() != nx+2-(nx%2) || filt->get_ysize() != ny ||
01754                    filt->get_zsize() != nz ) {
01755                 filt->set_size(nx+2-(nx%2), ny, nz);
01756                 filt->to_one();
01757 
01758                 filt->process_inplace("filter.highpass.gauss", Dict("cutoff_abs", 1.5f/nx));
01759         }
01760 
01761         EMData *ccf = this->calc_mutual_correlation(this, true,filt);
01762         ccf->sub(ccf->get_edge_mean());
01763         EMData *result = ccf->unwrap();
01764         delete ccf; ccf = 0;
01765 
01766         EXITFUNC;
01767         if ( unwrap == true)
01768         {
01769         // this if statement reflects a strict policy of caching in only one scenario see comments at beginning of function block
01770 
01771 // Note that the if statement at the beginning of this function ensures that rot_fp is not zero, so there is no need
01772 // to throw any exception
01773 // if ( rot_fp != 0 ) throw UnexpectedBehaviorException("The rotational foot print is only expected to be cached if it is not NULL");
01774 
01775 // Here is where the caching occurs - the rot_fp takes ownsherhip of the pointer, and a deep copied EMData object is returned.
01776 // The deep copy invokes a cost in terms of CPU cycles and memory, but prevents the need for complicated memory management (reference counting)
01777                 rot_fp = result;
01778                 return new EMData(*rot_fp);
01779         }
01780         else return result;
01781 }

EMData * EMData::make_rotational_footprint_e1 bool  unwrap = true  ) 
 

Definition at line 1819 of file emdata.cpp.

References calc_mutual_correlation(), EMData(), get_edge_mean(), get_xsize(), get_ysize(), get_zsize(), insert_clip(), nx, ny, nz, process(), process_inplace(), rot_fp, set_complex(), set_size(), sub(), to_one(), to_value(), UnexpectedBehaviorException, unwrap(), and update_stat().

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

01820 {
01821         ENTERFUNC;
01822 
01823         update_stat();
01824         // Note that rotational_footprint caching saves a large amount of time
01825         // but this is at the expense of memory. Note that a policy is hardcoded here,
01826         // that is that caching is only employed when premasked is false and unwrap
01827         // is true - this is probably going to be what is used in most scenarios
01828         // as advised by Steve Ludtke - In terms of performance this caching doubles the metric
01829         // generated by e2speedtest.
01830         if ( rot_fp != 0 && unwrap == true) {
01831                 return new EMData(*rot_fp);
01832         }
01833 
01834         static EMData obj_filt;
01835         EMData* filt = &obj_filt;
01836         filt->set_complex(true);
01837 //      Region filt_region;
01838 
01839 //      if (nx & 1) {
01840 //              LOGERR("even image xsize only");                throw ImageFormatException("even image xsize only");
01841 //      }
01842 
01843         int cs = (((nx * 7 / 4) & 0xfffff8) - nx) / 2; // this pads the image to 1 3/4 * size with result divis. by 8
01844 
01845         static EMData big_clip;
01846         int big_x = nx+2*cs;
01847         int big_y = ny+2*cs;
01848         int big_z = 1;
01849         if ( nz != 1 ) {
01850                 big_z = nz+2*cs;
01851         }
01852 
01853 
01854         if ( big_clip.get_xsize() != big_x || big_clip.get_ysize() != big_y || big_clip.get_zsize() != big_z ) {
01855                 big_clip.set_size(big_x,big_y,big_z);
01856         }
01857         // It is important to set all newly established pixels around the boundaries to the mean
01858         // If this is not done then the associated rotational alignment routine breaks, in fact
01859         // everythin just goes foo.
01860 
01861         big_clip.to_value(get_edge_mean());
01862 
01863         if (nz != 1) {
01864                 big_clip.insert_clip(this,IntPoint(cs,cs,cs));
01865         } else  {
01866                 big_clip.insert_clip(this,IntPoint(cs,cs,0));
01867         }
01868         
01869         // The filter object is nothing more than a cached high pass filter
01870         // Ultimately it is used an argument to the EMData::mult(EMData,prevent_complex_multiplication (bool))
01871         // function in calc_mutual_correlation. Note that in the function the prevent_complex_multiplication
01872         // set to true, which is used for speed reasons.
01873         if (filt->get_xsize() != big_clip.get_xsize() +2-(big_clip.get_xsize()%2) || filt->get_ysize() != big_clip.get_ysize() ||
01874                    filt->get_zsize() != big_clip.get_zsize()) {
01875                 filt->set_size(big_clip.get_xsize() + 2-(big_clip.get_xsize()%2), big_clip.get_ysize(), big_clip.get_zsize());
01876                 filt->to_one();
01877                 filt->process_inplace("filter.highpass.gauss", Dict("cutoff_abs", 1.5f/nx));
01878 #ifdef EMAN2_USING_CUDA
01879                 /*
01880                 if(EMData::usecuda == 1 && big_clip.cudarwdata)
01881                 {
01882                         filt->copy_to_cuda(); // since this occurs just once for many images, we don't pay much of a speed pentalty here, and we avoid the hassel of messing with sparx
01883                 }
01884                 */
01885 #endif
01886         }
01887 #ifdef EMAN2_USING_CUDA
01888         /*
01889         if(EMData::usecuda == 1 && big_clip.cudarwdata && !filt->cudarwdata)
01890         {
01891                 filt->copy_to_cuda(); // since this occurs just once for many images, we don't pay much of a speed pentalty here, and we avoid the hassel of messing with sparx
01892         }
01893         */
01894 #endif
01895         
01896         EMData *mc = big_clip.calc_mutual_correlation(&big_clip, true,filt);
01897         mc->sub(mc->get_edge_mean());
01898 
01899         static EMData sml_clip;
01900         int sml_x = nx * 3 / 2;
01901         int sml_y = ny * 3 / 2;
01902         int sml_z = 1;
01903         if ( nz != 1 ) {
01904                 sml_z = nz * 3 / 2;
01905         }
01906 
01907         if ( sml_clip.get_xsize() != sml_x || sml_clip.get_ysize() != sml_y || sml_clip.get_zsize() != sml_z ) {
01908                 sml_clip.set_size(sml_x,sml_y,sml_z);   }
01909         if (nz != 1) {
01910                 sml_clip.insert_clip(mc,IntPoint(-cs+nx/4,-cs+ny/4,-cs+nz/4));
01911         } else {
01912                 sml_clip.insert_clip(mc,IntPoint(-cs+nx/4,-cs+ny/4,0));         // same as padding change above
01913         }
01914                 
01915         delete mc; mc = 0;
01916         EMData * result = NULL;
01917         
01918         if (nz == 1) {
01919                 if (!unwrap) {
01920 #ifdef EMAN2_USING_CUDA
01921                         //if(EMData::usecuda == 1 && sml_clip.cudarwdata) throw UnexpectedBehaviorException("shap masking is not yet supported by CUDA");
01922 #endif
01923                         result = sml_clip.process("mask.sharp", Dict("outer_radius", -1, "value", 0));
01924 
01925                 }
01926                 else {
01927                         result = sml_clip.unwrap();
01928                 }
01929         }
01930         else {
01931                 // I am not sure why there is any consideration of non 2D images, but it was here
01932                 // in the first port so I kept when I cleaned this function up (d.woolford)
01933 //              result = clipped_mc;
01934                 result = new EMData(sml_clip);
01935         }
01936         
01937 #ifdef EMAN2_USING_CUDA
01938         //if (EMData::usecuda == 1) sml_clip.roneedsanupdate(); //If we didn't do this then unwrap would use data from the previous call of this function, happens b/c sml_clip is static
01939 #endif
01940         EXITFUNC;
01941         if ( unwrap == true)
01942         { // this if statement reflects a strict policy of caching in only one scenario see comments at beginning of function block
01943 
01944                 // Note that the if statement at the beginning of this function ensures that rot_fp is not zero, so there is no need
01945                 // to throw any exception
01946                 if ( rot_fp != 0 ) throw UnexpectedBehaviorException("The rotational foot print is only expected to be cached if it is not NULL");
01947 
01948                 // Here is where the caching occurs - the rot_fp takes ownsherhip of the pointer, and a deep copied EMData object is returned.
01949                 // The deep copy invokes a cost in terms of CPU cycles and memory, but prevents the need for complicated memory management (reference counting)
01950                 rot_fp = result;
01951                 return new EMData(*rot_fp);
01952         }
01953         else return result;
01954 }

vector< Vec3i > EMData::mask_contig_region const float &  val,
const Vec3i seed
 

Definition at line 1383 of file emdata_metadata.cpp.

References find_region(), v, and EMAN::Vec3i.

01383                                                                               {
01384         Vec3i coord(seed[0],seed[1],seed[2]);
01385         vector<Vec3i> region;
01386         region.push_back(coord);
01387         vector<Vec3i> find_region_input = region;
01388         while (true) {
01389                 vector<Vec3i> v = find_region(this,find_region_input, value, region);
01390                 if (v.size() == 0 ) break;
01391                 else find_region_input = v;
01392         }
01393         return region;
01394 }

float EMData::max_3D_pixel_error const Transform t1,
const Transform t2,
float  r
 

Definition at line 945 of file emdata.cpp.

References EMAN::Transform::inverse(), max, sqrt(), t, v, and EMAN::Vec3f.

00945                                                                                    {
00946 
00947         Transform t;
00948         int r0 = (int)r;
00949         float ddmax = 0.0f;
00950 
00951         t = t2*t1.inverse();
00952         for (int i=0; i<int(2*M_PI*r0+0.5); i++) {
00953                 float ang = (float)i/r;
00954                 Vec3f v = Vec3f(r0*cos(ang), r0*sin(ang), 0.0f);
00955                 Vec3f d = t*v-v;
00956 #ifdef _WIN32
00957                 ddmax = _cpp_max(ddmax,d[0]*d[0]+d[1]*d[1]+d[2]*d[2]);
00958 #else
00959                 ddmax = std::max(ddmax,d[0]*d[0]+d[1]*d[1]+d[2]*d[2]);
00960 #endif  //_WIN32
00961         }
00962         return std::sqrt(ddmax);
00963 }

void EMData::mult const EMData image,
bool  prevent_complex_multiplication = false
 

multiply each pixel of this image with each pixel of some other same-size image.

Parameters:
image The image multiplied to 'this' image.
prevent_complex_multiplication if the image is complex, this flag will override complex multiplication and just multiply each pixel by the other
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 501 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), imag(), ImageFormatException, is_real(), nx, ny, nz, real(), and update().

00502 {
00503         ENTERFUNC;
00504 
00505         if (nx != em.get_xsize() || ny != em.get_ysize() || nz != em.get_zsize()) {
00506                 throw ImageFormatException( "can not multiply images that are not the same size");
00507         }
00508         else if( (is_real()^em.is_real()) == true )
00509         {
00510                 throw ImageFormatException( "can not multiply real and complex images.");
00511         }
00512         else
00513         {
00514                 const float *src_data = em.get_data();
00515                 size_t size = nxyz;
00516                 float* data = get_data();
00517                 if( is_real() || prevent_complex_multiplication )
00518                 {
00519                         for (size_t i = 0; i < size; i++) {
00520                                 data[i] *= src_data[i];
00521                         }
00522                 }
00523                 else
00524                 {
00525                         typedef std::complex<float> comp;
00526                         for( size_t i = 0; i < size; i+=2 )
00527                         {
00528                                 comp c_src( src_data[i], src_data[i+1] );
00529                                 comp c_rdat( data[i], data[i+1] );
00530                                 comp c_result = c_src * c_rdat;
00531                                 data[i] = c_result.real();
00532                                 data[i+1] = c_result.imag();
00533                         }
00534                 }
00535                 update();
00536         }
00537 
00538         EXITFUNC;
00539 }

void EMData::mult float  f  ) 
 

multiply a float number to each pixel value of the image.

Parameters:
f The float multiplied to 'this' image.

Definition at line 473 of file emdata_core.cpp.

References ap2ri(), data, emdata_processor_mult(), get_data(), is_complex(), nx, ny, nz, and update().

00474 {
00475         ENTERFUNC;
00476 
00477 // this will cause a crash if CUDA is used(no rdata) and a complex map is given.....
00478         if (is_complex()) {
00479                 ap2ri();
00480         }
00481         if (f != 1.0) {
00482 #ifdef EMAN2_USING_CUDA
00483                 if (EMData::usecuda == 1 && cudarwdata) { //doesn't make any sense to use RO, esp on compute devices >= 2.0
00484                         //cout << "CUDA mult" << endl;
00485                         emdata_processor_mult(cudarwdata,f,nx,ny,nz);
00486                         EXITFUNC;
00487                         return;
00488                 }
00489 #endif // EMAN2_USING_CUDA
00490                 float* data = get_data();
00491                 size_t size = nxyz;
00492                 for (size_t i = 0; i < size; i++) {
00493                         data[i] *= f;
00494                 }
00495                 update();
00496         }
00497         EXITFUNC;
00498 }

void EMAN::EMData::mult int  n  )  [inline]
 

multiply an integer number to each pixel value of the image.

Parameters:
n The integer multiplied to 'this' image.

Definition at line 1814 of file emdata.h.

Referenced by calc_fast_sigma_image(), calc_flcf(), calc_mutual_correlation(), div(), do_ift(), do_ift_inplace(), EMAN::BackProjectionReconstructor::finish(), make_footprint(), EMAN::Averager::mult(), EMAN::operator *(), operator *=(), EMAN::operator-(), EMAN::operator/(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::CtfSimProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), EMAN::TomoTiltAngleWeightProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::IndexMaskFileProcessor::process_inplace(), EMAN::LocalNormProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), and refalifn().

void EMData::mult_complex_efficient const EMData em,
const int  radius
 

Definition at line 541 of file emdata_core.cpp.

References data, get_data(), get_ndim(), get_xsize(), get_ysize(), get_zsize(), ImageDimensionException, ImageFormatException, is_real(), nx, nxy, and update().

Referenced by calc_mutual_correlation().

00542 {
00543         ENTERFUNC;
00544 
00545         if( is_real() || em.is_real() )throw ImageFormatException( "can call mult_complex_efficient unless both images are complex");
00546 
00547 
00548         const float *src_data = em.get_data();
00549 
00550         size_t i_radius = radius;
00551         size_t k_radius = 1;
00552         size_t j_radius = 1;
00553         int ndim = get_ndim();
00554 
00555         if (ndim != em.get_ndim()) throw ImageDimensionException("Can't do that");
00556 
00557         if ( ndim == 3 ) {
00558                 k_radius = radius;
00559                 j_radius = radius;
00560         } else if ( ndim == 2 ) {
00561                 j_radius = radius;
00562         }
00563 
00564 
00565         int s_nx = em.get_xsize();
00566         int s_nxy = s_nx*em.get_ysize();
00567 
00568         size_t r_size = nxyz;
00569         int s_size = s_nxy*em.get_zsize();
00570         float* data = get_data();
00571 
00572         for (size_t k = 0; k < k_radius; ++k ) {
00573                 for (size_t j = 0; j < j_radius; j++) {
00574                         for (size_t i = 0; i < i_radius; i++) {
00575                                 int r_idx = k*nxy + j*nx + i;
00576                                 int s_idx = k*s_nxy + j*s_nx + i;
00577                                 data[r_idx] *= src_data[s_idx];
00578                                 data[r_size-r_idx-1] *= src_data[s_size-s_idx-1];
00579                         }
00580                 }
00581         }
00582 
00583         update();
00584 
00585         EXITFUNC;
00586 }

EMData * EMData::mult_radial EMData radial  ) 
 

Multiply radially a 2-D or 3-D image by a 1-D image.

Parameters:
radial the 1-D image multiply to
Exceptions:
ImageDimensionException If 'this' image is 1D.
Returns:
2-D or 3-D radially multiplied image

Definition at line 688 of file emdata_sparx.cpp.

References copy_head(), get_xsize(), ImageDimensionException, LOGERR, nx, ny, nz, set_array_offsets(), sqrt(), to_zero(), and update().

00688                                           {
00689 
00690         ENTERFUNC;
00691         if ( ny == 1 && nz == 1 ) {
00692                 LOGERR("Input image must be 2-D or 3-D!");
00693                 throw ImageDimensionException("Input image must be 2-D or 3-D!");
00694         }
00695 
00696         EMData* result = this->copy_head();
00697 
00698         result->to_zero();
00699         result->set_array_offsets(-nx/2, -ny/2, -nz/2);
00700         this->set_array_offsets(-nx/2, -ny/2, -nz/2);
00701         int rmax = radial->get_xsize();
00702         int i, j, k, ir;
00703         float r;
00704         for ( k = -nz/2; k < nz/2+nz%2; k++) {
00705                 for ( j = -ny/2; j < ny/2+ny%2; j++) {
00706                         for ( i = -nx/2; i < nx/2+nx%2; i++)  {
00707                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00708                                 ir = int(r);
00709                                 if(ir < rmax-1)  (*result)(i,j,k) = (*this)(i,j,k) * ((*radial)(ir)+((*radial)(ir+1)-(*radial)(ir))*(r - float(ir)));
00710                         }
00711                 }
00712         }
00713         result->update();
00714         result->set_array_offsets(0,0,0);
00715         this->set_array_offsets(0,0,0);
00716         EXITFUNC;
00717         return result;
00718 }

void EMData::nn EMData wptr,
EMData myfft,
const Transform tf,
int  mult = 1
 

Nearest Neighbor interpolation.

Modifies the current object.

Parameters:
wptr Normalization data.
myfft FFT data.
tf Transform reference
mult 

Definition at line 1179 of file emdata_sparx.cpp.

References attr_dict, get_array_offsets(), mult(), ny, onelinenn(), onelinenn_mult(), and set_array_offsets().

Referenced by EMAN::nn4Reconstructor::insert_padfft_slice().

01180 {
01181         ENTERFUNC;
01182         int nxc = attr_dict["nxc"]; // # of complex elements along x
01183         // let's treat nr, bi, and local data as matrices
01184         vector<int> saved_offsets = get_array_offsets();
01185         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01186         set_array_offsets(0,1,1);
01187         myfft->set_array_offsets(0,1);
01188         // loop over frequencies in y
01189         //for(int i = 0; i <= 2; i++){{for(int l = 0; l <= 2; l++) std::cout<<"  "<<tf[l][i];}std::cout<<std::endl;};std::cout<<std::endl;
01190         //Dict tt = tf.get_rotation("spider");
01191         //std::cout << static_cast<float>(tt["phi"]) << " " << static_cast<float>(tt["theta"]) << " " << static_cast<float>(tt["psi"]) << std::endl;
01192         if( mult == 1 ) {
01193                 for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn(iy, ny, nxc, wptr, myfft, tf);
01194         } else {
01195                 for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_mult(iy, ny, nxc, wptr, myfft, tf, mult);
01196         }
01197 
01198         set_array_offsets(saved_offsets);
01199         myfft->set_array_offsets(myfft_saved_offsets);
01200         EXITFUNC;
01201 }

void EMData::nn_ctf EMData w,
EMData myfft,
const Transform tf,
int  mult
 

Nearest Neighbor interpolation.

Modifies the current object.

Parameters:
w Normalization data.
myfft FFT data.
tf Transform reference
mult 

Definition at line 1724 of file emdata_sparx.cpp.

References attr_dict, get_array_offsets(), get_attr(), ctf_store::init(), mult(), ny, onelinenn_ctf(), and set_array_offsets().

Referenced by EMAN::nn4_ctfReconstructor::insert_padfft_slice().

01724                                                                       {
01725         ENTERFUNC;
01726         int nxc = attr_dict["nxc"]; // # of complex elements along x
01727         // let's treat nr, bi, and local data as matrices
01728         vector<int> saved_offsets = get_array_offsets();
01729         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01730         set_array_offsets(0,1,1);
01731         myfft->set_array_offsets(0,1);
01732 
01733         Ctf* ctf = myfft->get_attr("ctf");
01734         ctf_store::init( ny, ctf );
01735         if(ctf) {delete ctf; ctf=0;}
01736 
01737         // loop over frequencies in y
01738         for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_ctf(iy, ny, nxc, w, myfft, tf, mult);
01739         set_array_offsets(saved_offsets);
01740         myfft->set_array_offsets(myfft_saved_offsets);
01741         EXITFUNC;
01742 }

void EMData::nn_ctf_applied EMData w,
EMData myfft,
const Transform tf,
int  mult
 

Nearest Neighbor interpolation.

Modifies the current object. here it is assumed the projection data was already multiplied by the ctf...

Parameters:
w Normalization data.
myfft FFT data.
tf Transform reference
mult 

Definition at line 1745 of file emdata_sparx.cpp.

References attr_dict, get_array_offsets(), get_attr(), ctf_store::init(), mult(), ny, onelinenn_ctf_applied(), and set_array_offsets().

Referenced by EMAN::nn4_ctfReconstructor::insert_padfft_slice().

01745                                                                               {
01746         ENTERFUNC;
01747         int nxc = attr_dict["nxc"]; // # of complex elements along x
01748         // let's treat nr, bi, and local data as matrices
01749         vector<int> saved_offsets = get_array_offsets();
01750         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01751         set_array_offsets(0,1,1);
01752         myfft->set_array_offsets(0,1);
01753 
01754         Ctf* ctf = myfft->get_attr( "ctf" );
01755         ctf_store::init( ny, ctf );
01756         if(ctf) {delete ctf; ctf=0;}
01757         //}
01758 
01759         // loop over frequencies in y
01760         for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_ctf_applied(iy, ny, nxc, w, myfft, tf, mult);
01761         set_array_offsets(saved_offsets);
01762         myfft->set_array_offsets(myfft_saved_offsets);
01763         EXITFUNC;
01764 }

void EMData::nn_SSNR EMData wptr,
EMData wptr2,
EMData myfft,
const Transform tf,
int  mult = 1
 

Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.

Parameters:
wptr Normalization data.
wptr2 
myfft FFT data.
tf Transform reference
mult 

Definition at line 1332 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), is_fftodd(), norm(), nx, ny, ny, nz, and set_array_offsets().

Referenced by EMAN::nnSSNR_Reconstructor::insert_padfft_slice().

01333 {
01334         ENTERFUNC;
01335         int nxc = attr_dict["nxc"];
01336 
01337         vector<int> saved_offsets = get_array_offsets();
01338         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01339 
01340         set_array_offsets(0,1,1);
01341         myfft->set_array_offsets(0,1);
01342 
01343         int iymin = is_fftodd() ? -ny/2 : -ny/2 + 1 ;
01344         int iymax = ny/2;
01345         int izmin = is_fftodd() ? -nz/2 : -nz/2 + 1 ;
01346         int izmax = nz/2;
01347 
01348         for (int iy = iymin; iy <= iymax; iy++) {
01349                 int jp = iy >= 0 ? iy+1 : ny+iy+1; //checked, works for both odd and even
01350                 for (int ix = 0; ix <= nxc; ix++) {
01351                         if (( 4*(ix*ix+iy*iy) < ny*ny ) && !( ix == 0 && iy < 0 ) ) {
01352                                 float xnew = ix*tf[0][0] + iy*tf[1][0];
01353                                 float ynew = ix*tf[0][1] + iy*tf[1][1];
01354                                 float znew = ix*tf[0][2] + iy*tf[1][2];
01355                                 std::complex<float> btq;
01356                                 if (xnew < 0.0) {
01357                                         xnew = -xnew; // ensures xnew>=0.0
01358                                         ynew = -ynew;
01359                                         znew = -znew;
01360                                         btq = conj(myfft->cmplx(ix,jp));
01361                                 } else {
01362                                         btq = myfft->cmplx(ix,jp);
01363                                 }
01364                                 int ixn = int(xnew + 0.5 + nx) - nx; // ensures ixn >= 0
01365                                 int iyn = int(ynew + 0.5 + ny) - ny;
01366                                 int izn = int(znew + 0.5 + nz) - nz;
01367                                 if ((ixn <= nxc) && (iyn >= iymin) && (iyn <= iymax) && (izn >= izmin) && (izn <= izmax)) {
01368                                         if (ixn >= 0) {
01369                                                 int iza, iya;
01370                                                 if (izn >= 0)  iza = izn + 1;
01371                                                 else           iza = nz + izn + 1;
01372 
01373                                                 if (iyn >= 0) iya = iyn + 1;
01374                                                 else          iya = ny + iyn + 1;
01375 
01376                                                 cmplx(ixn,iya,iza) += btq;
01377                                                 (*wptr)(ixn,iya,iza)++;
01378                                                 (*wptr2)(ixn,iya,iza) += norm(btq);
01379                                         } else {
01380                                                 int izt, iyt;
01381                                                 if (izn > 0) izt = nz - izn + 1;
01382                                                 else         izt = -izn + 1;
01383 
01384                                                 if (iyn > 0) iyt = ny - iyn + 1;
01385                                                 else         iyt = -iyn + 1;
01386 
01387                                                 cmplx(-ixn,iyt,izt) += std::conj(btq);
01388                                                 (*wptr)(-ixn,iyt,izt)++;
01389                                                 (*wptr2)(-ixn,iyt,izt) += std::norm(btq);
01390                                         }
01391                                 }
01392                         }
01393                 }
01394         }
01395         set_array_offsets(saved_offsets);
01396         myfft->set_array_offsets(myfft_saved_offsets);
01397         EXITFUNC;
01398 }

void EMData::nn_SSNR_ctf EMData wptr,
EMData wptr2,
EMData wptr3,
EMData myfft,
const Transform tf,
int  mult = 1
 

Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.

Parameters:
wptr Normalization data.
wptr2 
wptr3 
myfft 
tf Transform reference
mult 

Definition at line 2107 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), get_attr(), ctf_store::get_ctf(), ctf_store::init(), is_fftodd(), norm(), nx, ny, ny, nz, and set_array_offsets().

Referenced by EMAN::nnSSNR_ctfReconstructor::insert_padfft_slice().

02107 {
02108         /***   Preparing terms for SSNR
02109               m_wvolume F^3D Wiener volume
02110              wptr   ctf^2
02111             wptr5  ctf^2*|P^2D->3D(F^3D)|^2
02112            wptr4  2*Real(conj(F_k^2D)*ctf*P^2D->3D(F^3D))
02113           wptr2  F_k^2D*conj(F_k^2D) or |F_k^2D|^2
02114           Kn is counted in the previous routine, and won't be
02115          calculated any more.
02116                                                     ***/
02117         ENTERFUNC;
02118         int nxc = attr_dict["nxc"];
02119         vector<int> saved_offsets = get_array_offsets();
02120         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
02121         set_array_offsets(0,1,1);
02122         myfft->set_array_offsets(0,1);
02123 
02124         Ctf* ctf = myfft->get_attr("ctf");
02125         ctf_store::init( ny, ctf );
02126         int iymin = is_fftodd() ? -ny/2 : -ny/2 + 1;
02127         int iymax = ny/2;
02128         int izmin = is_fftodd() ? -nz/2 : -nz/2 + 1;
02129         int izmax = nz/2;
02130 //      std::complex<float> tmpq, tmp2;
02131         for (int iy = iymin; iy <= iymax; iy++) {
02132                 int jp = iy >= 0 ? iy+1 : ny+iy+1; //checked, works for both odd and even
02133                 for (int ix = 0; ix <= nxc; ix++) {
02134                         int r2 = ix*ix+iy*iy;
02135                         if (( 4*r2 < ny*ny ) && !( ix == 0 && iy < 0 ) ) {
02136                                 float  ctf = ctf_store::get_ctf( r2, ix, iy )*10.f;// ???PAP
02137                                 float xnew = ix*tf[0][0] + iy*tf[1][0];
02138                                 float ynew = ix*tf[0][1] + iy*tf[1][1];
02139                                 float znew = ix*tf[0][2] + iy*tf[1][2];
02140                                 std::complex<float> btq;
02141                                 if (xnew < 0.0) {
02142                                         xnew = -xnew; // ensures xnew>=0.0
02143                                         ynew = -ynew;
02144                                         znew = -znew;
02145                                         btq = conj(myfft->cmplx(ix,jp));
02146                                 } else  {
02147                                         btq = myfft->cmplx(ix,jp);
02148                                 }
02149                                 int ixn = int(xnew + 0.5 + nx) - nx; // ensures ixn >= 0
02150                                 int iyn = int(ynew + 0.5 + ny) - ny;
02151                                 int izn = int(znew + 0.5 + nz) - nz;
02152                                 if ((ixn <= nxc) && (iyn >= iymin) && (iyn <= iymax) && (izn >= izmin) && (izn <= izmax)) {
02153                                         if (ixn >= 0) {
02154                                                 int iza, iya;
02155                                                 if (izn >= 0) iza = izn + 1;
02156                                                 else          iza = nz + izn + 1;
02157 
02158                                                 if (iyn >= 0) iya = iyn + 1;
02159                                                 else          iya = ny + iyn + 1;
02160 
02161                                                 cmplx(ixn,iya,iza)    += btq*ctf;
02162                                                 (*wptr)(ixn,iya,iza)  += ctf*ctf;
02163                                                 (*wptr2)(ixn,iya,iza) += std::norm(btq);
02164                                                 (*wptr3)(ixn,iya,iza) += 1;
02165                                         } else {
02166                                                 int izt, iyt;
02167                                                 if (izn > 0)  izt = nz - izn + 1;
02168                                                 else          izt = -izn + 1;
02169 
02170                                                 if (iyn > 0) iyt = ny - iyn + 1;
02171                                                 else         iyt = -iyn + 1;
02172 
02173                                                 cmplx(-ixn,iyt,izt)    += std::conj(btq)*ctf;
02174                                                 (*wptr) (-ixn,iyt,izt) += ctf*ctf;
02175                                                 (*wptr2)(-ixn,iyt,izt) += std::norm(btq);
02176                                                 (*wptr3)(-ixn,iyt,izt) += 1;
02177                                         }
02178                                 }
02179                         }
02180                 }
02181         }
02182         set_array_offsets(saved_offsets);
02183         myfft->set_array_offsets(myfft_saved_offsets);
02184         if(ctf) {delete ctf; ctf=0;}
02185         EXITFUNC;
02186 }
02187 

EMData * EMData::norm_pad bool  do_norm,
int  npad = 1,
int  valtype = 0
 

Normalize, pad, and Fourier extend convenience function.

Purpose: Create a new [normalized] [zero-padded] Fourier image.
Method: Normalize (if requested), pad with zeros (if
requested), extend along x for fft, and return the new image.
Parameters:
[in] do_norm If true then perform normalization.
[in] npad Amount of zero-padding to use (defaults to 2 if do_pad is true).
valtype 
Returns:
[normalized,] [zero-padded,] [ft-extended] input image.

Definition at line 6639 of file emdata_sparx.cpp.

References nx, and ny.

Referenced by calc_fourier_shell_correlation(), EMAN::Processor::EMFourierFilterFunc(), EMAN::fourierproduct(), EMAN::padfft_slice(), EMAN::periodogram(), EMAN::FourierGriddingProjector::project3d(), EMAN::Util::WTF(), and EMAN::Util::WTM().

06644                    { // Normalization requested
06645                 mean = this->get_attr("mean");
06646                 stddev = this->get_attr("sigma");
06647         }
06648         // sanity check
06649         if (npad < 1) npad = 1;
06650         int nxpad = npad*nx;
06651         int nypad = npad*ny;
06652         int nzpad = npad*nz;
06653         if (1 == ny) {
06654                 // 1-d image, don't want to pad along y or z
06655                 // Also, assuming that we can't have an image sized as nx=5, ny=1, nz=5.
06656                 nypad = ny;
06657                 nzpad = nz;
06658         } else if (nz == 1) {
06659                 // 2-d image, don't want to pad along z
06660                 nzpad = nz;
06661         }
06662         size_t bytes;
06663         size_t offset;
06664         // Not currently fft-extended, so we want to extend for ffts
06665         offset = 2 - nxpad%2;
06666         bytes = nx*sizeof(float);
06667         EMData* fpimage = copy_head();
06668         fpimage->set_size(nxpad+offset, nypad, nzpad);
06669         int xstart = 0, ystart = 0, zstart = 0;
06670         if( npad > 1) {
06671                 if( valtype==0 ) {
06672                         fpimage->to_zero();
06673                 } else {
06674                         float val = circumference(this, 1);
06675                         float* data = fpimage->get_data();
06676                         int nxyz = (nxpad+offset)*nypad*nzpad;
06677                         for( int i=0; i < nxyz; ++i )  data[i] = val;
06678                 }
06679 
06680                 xstart = (nxpad - nx)/2 + nx%2;
06681                 if(ny > 1) {
06682                         ystart = (nypad - ny)/2 + ny%2;
06683                         if(nz > 1) {
06684                                 zstart = (nzpad - nz)/2 + nz%2;
06685                         }
06686                 }
06687         }
06688 
06689 
06690         vector<int> saved_offsets = this->get_array_offsets();
06691         this->set_array_offsets( 0, 0, 0 );
06692         for (int iz = 0; iz < nz; iz++) {
06693                 for (int iy = 0; iy < ny; iy++) {
06694                         memcpy(&(*fpimage)(xstart,iy+ystart,iz+zstart), &(*this)(0,iy,iz), bytes);
06695                 }
06696         }
06697         this->set_array_offsets( saved_offsets );
06698 
06699 
06700         //  Perform the actual normalization (only on the
06701         //  non-zero section of the image)
06702         if (donorm) { // Normalization requested
06703                 for (int iz = zstart; iz < nz+zstart; iz++)
06704                         for (int iy = ystart; iy < ny+ystart; iy++)
06705                                 for (int ix = xstart; ix < nx+xstart; ix++)
06706                                         (*fpimage)(ix,iy,iz) = ((*fpimage)(ix,iy,iz)-mean)/stddev;
06707         }
06708 
06709         fpimage->set_fftpad(true);
06710         fpimage->set_attr("npad", npad);
06711         if (offset == 1) fpimage->set_fftodd(true);
06712         else             fpimage->set_fftodd(false);
06713         return fpimage;
06714 }
06715 
06716 void EMData::center_origin()

EMData * EMData::oneDfftPolar int  size,
float  rmax,
float  MAXR
 

Definition at line 4049 of file emdata.cpp.

References do_fft_inplace(), get_data(), in, set_complex(), set_size(), and update().

Referenced by EMAN::FRM2DAligner::align().

04049                                                             {           // sent MAXR value here later!!
04050         float *pcs=get_data();
04051         EMData *imagepcsfft = new EMData;
04052         imagepcsfft->set_size((size+2), (int)MAXR+1, 1);
04053         float *d=imagepcsfft->get_data();
04054 
04055         EMData *data_in=new EMData;
04056         data_in->set_size(size,1,1);
04057         float *in=data_in->get_data();
04058 
04059         for(int row=0; row<=(int)MAXR; ++row){
04060                 if(row<=(int)rmax) {
04061                         for(int i=0; i<size;++i)        in[i] = pcs[i+row*size]; // ming
04062                         data_in->set_complex(false);
04063                         data_in->do_fft_inplace();
04064                         for(int j=0;j<size+2;j++)  d[j+row*(size+2)]=in[j];
04065                 }
04066                 else for(int j=0;j<size+2;j++) d[j+row*(size+2)]=0.0;
04067         }
04068         imagepcsfft->update();
04069         delete data_in;
04070         return imagepcsfft;
04071 }

void EMData::onelinenn int  j,
int  n,
int  n2,
EMData wptr,
EMData bi,
const Transform tf
 

Helper function for method nn.

Parameters:
j y fourier index (frequency)
n number of real elements.
n2 Number of complex elements.
wptr Normalization matrix [0:n2][1:n][1:n]
bi Fourier transform matrix [0:n2][1:n]
tf Transform reference

Definition at line 1050 of file emdata_sparx.cpp.

References bi, and cmplx().

Referenced by nn().

01051 {
01052         //std::cout<<"   onelinenn  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01053         int jp = (j >= 0) ? j+1 : n+j+1;
01054         //for(int i = 0; i <= 2; i++){{for(int l = 0; l <= 2; l++) std::cout<<"  "<<tf[l][i];}std::cout<<std::endl;};std::cout<<std::endl;
01055         // loop over x
01056         for (int i = 0; i <= n2; i++) {
01057                 if (((i*i+j*j) < n*n/4) && !((0 == i) && (j < 0))) {
01058 //        if ( !((0 == i) && (j < 0))) {
01059                         float xnew = i*tf[0][0] + j*tf[1][0];
01060                         float ynew = i*tf[0][1] + j*tf[1][1];
01061                         float znew = i*tf[0][2] + j*tf[1][2];
01062                         std::complex<float> btq;
01063                         if (xnew < 0.) {
01064                                 xnew = -xnew;
01065                                 ynew = -ynew;
01066                                 znew = -znew;
01067                                 btq = conj(bi->cmplx(i,jp));
01068                         } else {
01069                                 btq = bi->cmplx(i,jp);
01070                         }
01071                         int ixn = int(xnew + 0.5 + n) - n;
01072                         int iyn = int(ynew + 0.5 + n) - n;
01073                         int izn = int(znew + 0.5 + n) - n;
01074                         
01075                         int iza, iya;
01076                         if (izn >= 0)  iza = izn + 1;
01077                         else           iza = n + izn + 1;
01078 
01079                         if (iyn >= 0) iya = iyn + 1;
01080                         else          iya = n + iyn + 1;
01081 
01082                         cmplx(ixn,iya,iza) += btq;
01083                         //std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<btq<<std::endl;
01084                         (*wptr)(ixn,iya,iza)++;
01085                         
01086                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2)  && (izn >= -n2) && (izn <= n2)) {
01087                                 if (ixn >= 0) {
01088                                         int iza, iya;
01089                                         if (izn >= 0)  iza = izn + 1;
01090                                         else           iza = n + izn + 1;
01091 
01092                                         if (iyn >= 0) iya = iyn + 1;
01093                                         else          iya = n + iyn + 1;
01094 
01095                                         cmplx(ixn,iya,iza) += btq;
01096                                         //std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<btq<<std::endl;
01097                                         (*wptr)(ixn,iya,iza)++;
01098                                 } else {
01099                                         int izt, iyt;
01100                                         if (izn > 0) izt = n - izn + 1;
01101                                         else         izt = -izn + 1;
01102 
01103                                         if (iyn > 0) iyt = n - iyn + 1;
01104                                         else         iyt = -iyn + 1;
01105 
01106                                         cmplx(-ixn,iyt,izt) += conj(btq);
01107                                         //std::cout<<" *  "<<j<<"  "<<ixn<<"  "<<iyt<<"  "<<izt<<"  "<<btq<<std::endl;
01108                                         (*wptr)(-ixn,iyt,izt)++;
01109                                 }
01110                         }*/
01111                 }
01112         }
01113 }

void EMData::onelinenn_ctf int  j,
int  n,
int  n2,
EMData w,
EMData bi,
const Transform tf,
int  mult
 

Helper function for method nn4_ctf.

Parameters:
j y fourier index (frequency)
n number of real elements.
n2 Number of complex elements.
w Normalization matrix [0:n2][1:n][1:n]
bi Fourier transform matrix [0:n2][1:n]
tf Transform reference
mult 

Definition at line 1633 of file emdata_sparx.cpp.

References bi, cmplx(), get_attr_default(), ctf_store::get_ctf(), and mult().

Referenced by nn_ctf().

01633                                                                                                      {
01634 //std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01635 
01636         int remove = bi->get_attr_default( "remove", 0 );
01637 
01638         int jp = (j >= 0) ? j+1 : n+j+1;
01639         // loop over x
01640         for (int i = 0; i <= n2; i++) {
01641                 int r2 = i*i+j*j;
01642                 if ( (r2<n*n/4) && !((0==i) && (j<0)) ) {
01643                         float ctf = ctf_store::get_ctf( r2, i, j ); //This is in 2D projection plane
01644                         float xnew = i*tf[0][0] + j*tf[1][0];
01645                         float ynew = i*tf[0][1] + j*tf[1][1];
01646                         float znew = i*tf[0][2] + j*tf[1][2];
01647                         std::complex<float> btq;
01648                         if (xnew < 0.) {
01649                                 xnew = -xnew;
01650                                 ynew = -ynew;
01651                                 znew = -znew;
01652                                 btq = conj(bi->cmplx(i,jp));
01653                         } else  btq = bi->cmplx(i,jp);
01654                         int ixn = int(xnew + 0.5 + n) - n;
01655                         int iyn = int(ynew + 0.5 + n) - n;
01656                         int izn = int(znew + 0.5 + n) - n;
01657 
01658                         int iza, iya;
01659                         if (izn >= 0)  iza = izn + 1;
01660                         else           iza = n + izn + 1;
01661 
01662                         if (iyn >= 0) iya = iyn + 1;
01663                         else          iya = n + iyn + 1;
01664 
01665                         if(remove > 0 ) {
01666                                 cmplx(ixn,iya,iza) -= btq*ctf*float(mult);
01667                                 (*w)(ixn,iya,iza)  -= ctf*ctf*mult;
01668                         } else {
01669                                 cmplx(ixn,iya,iza) += btq*ctf*float(mult);
01670                                 (*w)(ixn,iya,iza)  += ctf*ctf*mult;
01671                         }
01672 
01673                 }
01674         }
01675 }

void EMData::onelinenn_ctf_applied int  j,
int  n,
int  n2,
EMData w,
EMData bi,
const Transform tf,
int  mult
 

Helper function for method nn4_ctf.

here it is assumed the projection data was already multiplied by the ctf...

Parameters:
j y fourier index (frequency)
n number of real elements.
n2 Number of complex elements.
w Normalization matrix [0:n2][1:n][1:n]
bi Fourier transform matrix [0:n2][1:n]
tf Transform reference
mult 

Definition at line 1677 of file emdata_sparx.cpp.

References bi, cmplx(), get_attr_default(), ctf_store::get_ctf(), and mult().

Referenced by nn_ctf_applied().

01678                                                                                 {//std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01679 
01680         int remove = bi->get_attr_default( "remove", 0 );
01681 
01682         int jp = (j >= 0) ? j+1 : n+j+1;
01683         // loop over x
01684         for (int i = 0; i <= n2; i++) {
01685                 int r2 = i*i + j*j;
01686                 if ( (r2< n*n/4) && !((0==i) && (j< 0)) ) {
01687                         float  ctf = ctf_store::get_ctf(r2, i, j);
01688 
01689                          //        if ( !((0 == i) && (j < 0))) {
01690                         float xnew = i*tf[0][0] + j*tf[1][0];
01691                         float ynew = i*tf[0][1] + j*tf[1][1];
01692                         float znew = i*tf[0][2] + j*tf[1][2];
01693                         std::complex<float> btq;
01694                         if (xnew < 0.) {
01695                                 xnew = -xnew;
01696                                 ynew = -ynew;
01697                                 znew = -znew;
01698                                 btq = conj(bi->cmplx(i,jp));
01699                         } else  btq = bi->cmplx(i,jp);
01700                         int ixn = int(xnew + 0.5 + n) - n;
01701                         int iyn = int(ynew + 0.5 + n) - n;
01702                         int izn = int(znew + 0.5 + n) - n;
01703                         
01704                         int iza, iya;
01705                         if (izn >= 0)  iza = izn + 1;
01706                         else           iza = n + izn + 1;
01707 
01708                         if (iyn >= 0) iya = iyn + 1;
01709                         else          iya = n + iyn + 1;
01710 
01711                         if( remove > 0 ) {
01712                                 cmplx(ixn,iya,iza) -= btq*float(mult);
01713                                 (*w)(ixn,iya,iza) -= mult*ctf*ctf;
01714                         } else {
01715                                 cmplx(ixn,iya,iza) += btq*float(mult);
01716                                 (*w)(ixn,iya,iza) += mult*ctf*ctf;
01717                         }
01718 
01719                 }
01720         }
01721 }

void EMData::onelinenn_mult int  j,
int  n,
int  n2,
EMData wptr,
EMData bi,
const Transform tf,
int  mult
 

Definition at line 1116 of file emdata_sparx.cpp.

References bi, cmplx(), and mult().

Referenced by nn().

01117 {
01118         //std::cout<<"   onelinenn  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01119         int jp = (j >= 0) ? j+1 : n+j+1;
01120         //for(int i = 0; i <= 1; i++){for(int l = 0; l <= 2; l++){std::cout<<"  "<<tf[i][l]<<"  "<<std::endl;}}
01121         // loop over x
01122         for (int i = 0; i <= n2; i++) {
01123         if (((i*i+j*j) < n*n/4) && !((0 == i) && (j < 0))) {
01124 //        if ( !((0 == i) && (j < 0))) {
01125                         float xnew = i*tf[0][0] + j*tf[1][0];
01126                         float ynew = i*tf[0][1] + j*tf[1][1];
01127                         float znew = i*tf[0][2] + j*tf[1][2];
01128                         std::complex<float> btq;
01129                         if (xnew < 0.) {
01130                                 xnew = -xnew;
01131                                 ynew = -ynew;
01132                                 znew = -znew;
01133                                 btq = conj(bi->cmplx(i,jp));
01134                         } else {
01135                                 btq = bi->cmplx(i,jp);
01136                         }
01137                         int ixn = int(xnew + 0.5 + n) - n;
01138                         int iyn = int(ynew + 0.5 + n) - n;
01139                         int izn = int(znew + 0.5 + n) - n;
01140                         
01141                         
01142                         int iza, iya;
01143                         if (izn >= 0)  iza = izn + 1;
01144                         else           iza = n + izn + 1;
01145 
01146                         if (iyn >= 0) iya = iyn + 1;
01147                         else          iya = n + iyn + 1;
01148 
01149                         cmplx(ixn,iya,iza) += btq*float(mult);
01150                         (*wptr)(ixn,iya,iza)+=float(mult);
01151                         
01152                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2)  && (izn >= -n2) && (izn <= n2)) {
01153                                 if (ixn >= 0) {
01154                                         int iza, iya;
01155                                         if (izn >= 0)  iza = izn + 1;
01156                                         else           iza = n + izn + 1;
01157 
01158                                         if (iyn >= 0) iya = iyn + 1;
01159                                         else          iya = n + iyn + 1;
01160 
01161                                         cmplx(ixn,iya,iza) += btq*float(mult);
01162                                         (*wptr)(ixn,iya,iza)+=float(mult);
01163                                 } else {
01164                                         int izt, iyt;
01165                                         if (izn > 0) izt = n - izn + 1;
01166                                         else         izt = -izn + 1;
01167 
01168                                         if (iyn > 0) iyt = n - iyn + 1;
01169                                         else         iyt = -iyn + 1;
01170 
01171                                         cmplx(-ixn,iyt,izt) += conj(btq)*float(mult);
01172                                         (*wptr)(-ixn,iyt,izt)+=float(mult);
01173                                 }
01174                         }*/
01175                 }
01176         }
01177 }

EMData & EMData::operator *= const EMData em  ) 
 

Definition at line 918 of file emdata_core.cpp.

References mult(), and update().

00919 {
00920         mult(em);
00921         update();
00922         return *this;
00923 }

EMData & EMData::operator *= float  n  ) 
 

Definition at line 883 of file emdata_core.cpp.

References mult(), and update().

00884 {
00885         mult(n);
00886         update();
00887         return *this;
00888 }

float& EMAN::EMData::operator() const size_t  ix  )  const [inline]
 

Definition at line 2352 of file emdata.h.

float& EMAN::EMData::operator() const int  ix,
const int  iy
const [inline]
 

Definition at line 2340 of file emdata.h.

float& EMAN::EMData::operator() const int  ix,
const int  iy,
const int  iz
const [inline]
 

Overload operator() for array indexing.

Definition at line 2330 of file emdata.h.

EMData & EMData::operator+= const EMData em  ) 
 

Definition at line 902 of file emdata_core.cpp.

References add(), and update().

00903 {
00904         add(em);
00905         update();
00906         return *this;
00907 }

EMData & EMData::operator+= float  n  ) 
 

Definition at line 868 of file emdata_core.cpp.

References add(), and update().

00869 {
00870         add(n);
00871         update();
00872         return *this;
00873 }

EMData & EMData::operator-= const EMData em  ) 
 

Definition at line 910 of file emdata_core.cpp.

References sub(), and update().

00911 {
00912         sub(em);
00913         update();
00914         return *this;
00915 }

EMData & EMData::operator-= float  n  ) 
 

Definition at line 876 of file emdata_core.cpp.

00877 {
00878         *this += (-n);
00879         return *this;
00880 }

EMData & EMData::operator/= const EMData em  ) 
 

Definition at line 926 of file emdata_core.cpp.

References div(), and update().

00927 {
00928         div(em);
00929         update();
00930         return *this;
00931 }

EMData & EMData::operator/= float  n  ) 
 

Definition at line 891 of file emdata_core.cpp.

References LOGERR.

00892 {
00893         if (n == 0) {
00894                 LOGERR("divided by zero");
00895                 return *this;
00896         }
00897         *this *= (1.0f / n);
00898         return *this;
00899 }

bool EMData::operator== const EMData that  )  const
 

Change the equality check for memory address check, i.e.

two EMData objects are considered equal only when they are same object from the same memory address.

Definition at line 2988 of file emdata.cpp.

02988                                                 {
02989         if(this != &that) {
02990                 return false;
02991         }
02992         else {
02993                 return true;
02994         }
02995 }

void EMData::pad_corner float *  pad_image  ) 
 

Definition at line 4014 of file emdata_sparx.cpp.

04018                                                 {

vector< float > EMData::peak_ccf float  hf_p  ) 
 

Peak (with a radius of hf_p) search for particle picking:.

Parameters:
hf_p 

Definition at line 6024 of file emdata_sparx.cpp.

References nx, and ny.

06038                           {
06039     // static assignment so we don't have to re-evaluate
06040     i__1 = i-1;
06041     i__2 = i+1;
06042     for (j=half;j<=ny;++j) {
06043       j__1 = j-1;
06044       j__2 = j+1;
06045 
06046       if((buf(i,j)>0.0f)&&buf(i,j)>buf(i,j__1)) {
06047         if(buf(i,j)>buf(i,j__2)) {
06048           if(buf(i,j)>buf(i__1,j)) {
06049             if(buf(i,j)>buf(i__2,j)) {
06050               if(buf(i,j)>buf(i__1,j__1)) {
06051                 if((buf(i,j))> buf(i__1,j__2)) {
06052                   if(buf(i,j)>buf(i__2,j__1)) {
06053                     if(buf(i,j)> buf(i__2,j__2)) {
06054 
06055                       // found a peak
06056                       // empty list?
06057                       if (peaks.size()==0) {
06058                         // yes, so just push the peak onto the list
06059                         peaks.push_back(Pixel(i,j,0,buf(i,j)));
06060 
06061                       } else {
06062                         // not empty list. check neighbourhood for peaks
06063                         // logical not in the name is awkward. renamed to overlap
06064                         bool overlap = false;
06065                         //int  size = peaks.size();
06066 
06067                         // list of peaks to be deleted, if the current peak is the largest (see below).
06068                         //    list contains iterators to the original list, which will have to be processed
06069                         //    back to front (i.e. LIFO: stl::stack)
06070                         std::stack <vector<Pixel>::iterator> delete_stack;
06071 
06072                         // loop over all peaks found so far. this would be nicer with iterators
06073                         for (vector<Pixel>::iterator it=peaks.begin();it!=peaks.end();++it) {
06074                         // for ( int kk= 0; kk< size; kk++) {
06075                         //  vector<Pixel>::iterator it = peaks.begin()+kk;
06076 
06077                           // calc L2 distance
06078                           float radius=((*it).x-float(i))*((*it).x-float(i))+((*it).y-float(j))*((*it).y-float(j));
06079                           if (radius <= hf_p2 ) {
06080                             // peaks overlap
06081                             if( buf(i,j) > (*it).value) {
06082                               // this peak (indexed by (i,j)) is larger, mark the old for deletion
06083                               //    however, we have to be careful. if there is a larger peak within the vicinity of
06084                               //    the new one, this new peak is not marked as such, and the deletion of prior low
06085                               //    peaks should not continued. to make sure this deletion does not happen, we have
06086                               //    to make sure we cycle through all peaks within the vicinity, and only delete smaller
06087                               //    peaks if this new one is the largest in the vicinity.
06088                               delete_stack.push(it);
06089 
06090                               //(*it).x = -half; // this marks entry to be deleted, since it's smaller than the new one
06091 
06092 
06093                             } else {
06094                               overlap = true;
06095                               // old peak is larger, ignore this one. since it's enough to know there is some peak larger
06096                               //    than this one, we can break out of the peak list loop, instead of continuing.
06097                               break;
06098                             }
06099                           }
06100                         }
06101 
06102                         // check whether we need to delete anything. this is marked by the flag overlap == false
06103                         // loop over all peaks and clean out redundant ones
06104                         if (false == overlap) {
06105                           vector<Pixel>::iterator delete_iterator;
06106                           while (!delete_stack.empty()) {
06107                             // pop empties the stack from the back. since we are dealing with iterators, we need to delete
06108                             //    from the back, so as to keep the rest stack intact upon deletion.
06109                             delete_iterator = delete_stack.top();
06110                             peaks.erase(delete_iterator);
06111                             delete_stack.pop();
06112                           }
06113                           // before pushing the peak, we need to check whether max queue length is exceeded and delete
06114                           //     peaks if necessary.
06115                           // XXX: remove hardcoded value!
06116                           if (! (peaks.size() < 2000 )) {
06117 
06118                             //cout << ".";
06119                             // we need to delete a peak first.
06120                             // - resort list to get lowest peak at the back
06121                             sort(peaks.begin(), peaks.end(), peakcmp);
06122 
06123                             // - remove lowest peak
06124                             peaks.pop_back();
06125                           }
06126 
06127                           // push the new peak onto the list of peaks
06128                           peaks.push_back(Pixel(i,j,0,buf(i,j)));
06129                           //cout << "done." << endl;
06130 
06131                         } else {
06132                           // this peak too small and is ignored, so delete_list is ignored as well. make sure delete_list
06133                           //    is empty. probably redundant because of scope, but better safe than sorry.....
06134                           while (!delete_stack.empty()) delete_stack.pop();
06135                         }
06136                       }
06137                     }
06138                   }}}}}}}
06139     }
06140   }
06141 
06142   // we have peaks, so build a results vector.
06143   if(peaks.size()>0) {
06144     // sort peaks by size
06145     sort(peaks.begin(),peaks.end(), peakcmp);
06146     // and push all peaks to the results vector
06147     for (vector<Pixel>::iterator it = peaks.begin(); it != peaks.end(); it++) {
06148       // XXX: this format is necessary for Boost to work???
06149       res.push_back((*it).value);
06150       res.push_back(static_cast<float>((*it).x));
06151       res.push_back(static_cast<float>((*it).y));
06152     }
06153   } else {
06154     // only one or zero (?) entries
06155     res.push_back(buf(0,0,0));
06156     res.insert(res.begin(),1,0.0);
06157   }
06158   return res;
06159 }
06160 
06161 EMData* EMData::get_pow(float n_pow)

vector< float > EMData::peak_search int  ml,
float  invert
 

Search specified number peaks in 1D, 2D, or 3D real images.

and output the peaks in descendent order: The numbers coming out are: image dimension, then 1D: pixel value, x coord, relative peak value, x coord( NX/2 center), ... 2D: pixel value, x coord, y coord, realative peak value, x coord(NX/2 center) y coord(NY/2 center) ... 3D pixel value, x coord, y coord, z coord, realative peak value, x coord(NX/2 center) y coord(NY/2 center) z coord(NZ/2 center) The function is supposed to return 0 dimension and first pixel value (0,0,0) when the image is constant. ...

Parameters:
[in] ml 
[in] invert 

Definition at line 5021 of file emdata_sparx.cpp.

References nx, nx, and ny.

05038                           {
05039         case(1):
05040                 for(i=0;i<=nx-1;++i)  {
05041                         i__1 = (i-1+nx)%nx;
05042                         i__2 = (i+1)%nx;
05043                         // Commented by Yang on 05/14/07
05044                         // I changed the following line from > to >=, or in some rare cases (the peak happens to be flat), it will fail to find the peak.
05045                         //  03/07/08  I undid the change.  If you change the comparison, it changes the meaning of peak definition.
05046                         float qbf = buf(i)*invert;
05047                         peak_check = qbf > buf(i__1)*invert && qbf > buf(i__2)*invert;
05048                         if(peak_check) {
05049                                 if(count < ml) {
05050                                         count++;
05051                                         peaks.push_back( Pixel(i, 0, 0, qbf) );
05052                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05053                                 } else {
05054                                         if( qbf > (peaks.back()).value ) {
05055                                                 //  do the switch and sort again
05056                                                 peaks.pop_back();
05057                                                 peaks.push_back( Pixel(i, 0, 0, qbf) );
05058                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05059                                         }
05060                                 }
05061                         }
05062                 }
05063         break;
05064         case(2):
05065         /*  Removed boundary conditions, PAP 03/10/08
05066                 for(j=0;j<=ny-1;++j)  {
05067                         j__1 = (j-1+ny)%ny;
05068                         j__2 = (j+1)%ny;
05069                         for(i=0;i<=nx-1;++i) {
05070                                 i__1 = (i-1+nx)%nx;
05071                                 i__2 = (i+1)%nx;
05072         */
05073                 for(j=1;j<=ny-2;++j)  {
05074                         j__1 = j-1;
05075                         j__2 = j+1;
05076                         for(i=1;i<=nx-2;++i) {
05077                                 i__1 = i-1;
05078                                 i__2 = i+1;
05079                                 float qbf = buf(i,j)*invert;
05080                                 peak_check = (qbf > buf(i,j__1)*invert) && (qbf > buf(i,j__2)*invert);
05081                                 if(peak_check) {
05082                                         peak_check = (qbf > buf(i__1,j)*invert) && (qbf > buf(i__2,j)*invert);
05083                                         if(peak_check) {
05084                                                 peak_check = (qbf > buf(i__1,j__1)*invert) && (qbf > buf(i__1,j__2)*invert);
05085                                                 if(peak_check) {
05086                                                         peak_check = (qbf > buf(i__2,j__1)*invert) && (qbf > buf(i__2,j__2)*invert);
05087                                                         if(peak_check) {
05088                                                                 if(count < ml) {
05089                                                                         count++;
05090                                                                         peaks.push_back( Pixel(i, j, 0, qbf) );
05091                                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05092                                                                 } else {
05093                                                                         if( qbf > (peaks.back()).value ) {
05094                                                                                 //  do the switch and sort again
05095                                                                                 peaks.pop_back();
05096                                                                                 peaks.push_back( Pixel(i, j, 0, qbf) );
05097                                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05098                                                                         }
05099                                                                 }
05100                                                         }
05101                                                 }
05102                                         }
05103                                 }
05104                         }
05105                 }
05106         break;
05107         case(3):  //looks ugly, but it is the best I can do,  PAP 03/07/08
05108         /*  Removed boundary conditions, PAP 03/10/08
05109                 for(k=0;k<=nz-1;++k) {
05110                         kz.clear();
05111                         k__1 = (k-1+nz)%nz;
05112                         k__2 = (k+1)%nz;
05113                         kz.push_back(k__1);
05114                         kz.push_back(k);
05115                         kz.push_back(k__2);
05116                         for(j=0;j<=ny-1;++j) {
05117                                 jy.clear();
05118                                 j__1 = (j-1+ny)%ny;
05119                                 j__2 = (j+1)%ny;
05120                                 jy.push_back(j__1);
05121                                 jy.push_back(j);
05122                                 jy.push_back(j__2);
05123                                 for(i=0;i<=nx-1;++i) {
05124                                         ix.clear();
05125                                         i__1 = (i-1+nx)%nx;
05126                                         i__2 = (i+1)%nx;
05127         */
05128                 for(k=1; k<=nz-2; ++k) {
05129                         kz.clear();
05130                         kz.push_back(k-1);
05131                         kz.push_back(k);
05132                         kz.push_back(k+1);
05133                         for(j=1; j<=ny-2; ++j) {
05134                                 jy.clear();
05135                                 jy.push_back(j-1);
05136                                 jy.push_back(j);
05137                                 jy.push_back(j+1);
05138                                 for(i=1; i<=nx-2; ++i) {
05139                                         ix.clear();
05140                                         ix.push_back(i-1);
05141                                         ix.push_back(i);
05142                                         ix.push_back(i+1);
05143                                         float qbf = buf(i,j,k)*invert;
05144                                         peak_check = qbf > buf(ix[0],jy[0],kz[0])*invert;
05145                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0])*invert;
05146                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0])*invert;
05147                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0])*invert;
05148                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0])*invert;
05149                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0])*invert;
05150                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0])*invert;
05151                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0])*invert;
05152                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0])*invert;
05153                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1])*invert;
05154                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1])*invert;
05155                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1])*invert;
05156                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1])*invert;
05157                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1])*invert;
05158                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1])*invert;
05159                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1])*invert;
05160                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1])*invert;
05161                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1])*invert;
05162                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2])*invert;
05163                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2])*invert;
05164                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2])*invert;
05165                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2])*invert;
05166                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2])*invert;
05167                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2])*invert;
05168                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2])*invert;
05169                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2])*invert;
05170                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2])*invert;
05171                                         if(peak_check) {
05172                                                 if(count < ml) {
05173                                                         count++;
05174                                                         peaks.push_back( Pixel(i, j, k, qbf) );
05175                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05176                                                 } else {
05177                                                         if( qbf > (peaks.back()).value ) {
05178                                                                 //  do the switch and sort again
05179                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05180                                                                 peaks.pop_back();
05181                                                                 peaks.push_back( Pixel(i, j, k, qbf) );
05182                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05183                                                         }
05184                                                 }
05185                                         }
05186                                         }}}}}}}}}}}}}}}}}}}}}}}}}
05187                                 }
05188                         }
05189                 }
05190                 //  Add circular closure for x direction: needed for circular ccf,
05191                 //  should not have adverse impact on other code.  PAP -7/22/08
05192                 for(k=1; k<=nz-2; ++k) {
05193                         kz.clear();
05194                         kz.push_back(k-1);
05195                         kz.push_back(k);
05196                         kz.push_back(k+1);
05197                         for(j=1; j<=ny-2; ++j) {
05198                                 jy.clear();
05199                                 jy.push_back(j-1);
05200                                 jy.push_back(j);
05201                                 jy.push_back(j+1);
05202                                 for(i=0; i<=0; ++i) {
05203                                         ix.clear();
05204                                         ix.push_back(nx-1);
05205                                         ix.push_back(i);
05206                                         ix.push_back(i+1);
05207                                         float qbf = buf(i,j,k)*invert;
05208                                         peak_check = qbf > buf(ix[0],jy[0],kz[0])*invert;
05209                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0])*invert;
05210                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0])*invert;
05211                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0])*invert;
05212                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0])*invert;
05213                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0])*invert;
05214                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0])*invert;
05215                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0])*invert;
05216                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0])*invert;
05217                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1])*invert;
05218                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1])*invert;
05219                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1])*invert;
05220                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1])*invert;
05221                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1])*invert;
05222                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1])*invert;
05223                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1])*invert;
05224                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1])*invert;
05225                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1])*invert;
05226                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2])*invert;
05227                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2])*invert;
05228                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2])*invert;
05229                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2])*invert;
05230                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2])*invert;
05231                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2])*invert;
05232                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2])*invert;
05233                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2])*invert;
05234                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2])*invert;
05235                                         if(peak_check) {
05236                                                 if(count < ml) {
05237                                                         count++;
05238                                                         peaks.push_back( Pixel(i, j, k, qbf) );
05239                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05240                                                 } else {
05241                                                         if( qbf > (peaks.back()).value ) {
05242                                                                 //  do the switch and sort again
05243                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05244                                                                 peaks.pop_back();
05245                                                                 peaks.push_back( Pixel(i, j, k, qbf) );
05246                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05247                                                         }
05248                                                 }
05249                                         }
05250                                         }}}}}}}}}}}}}}}}}}}}}}}}}
05251                                 }
05252                                 for(i=nx-1; i<=nx-1; ++i) {
05253                                         ix.clear();
05254                                         ix.push_back(i-1);
05255                                         ix.push_back(i);
05256                                         ix.push_back(0);
05257                                         float qbf = buf(i,j,k)*invert;
05258                                         peak_check = qbf > buf(ix[0],jy[0],kz[0])*invert;
05259                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0])*invert;
05260                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0])*invert;
05261                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0])*invert;
05262                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0])*invert;
05263                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0])*invert;
05264                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0])*invert;
05265                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0])*invert;
05266                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0])*invert;
05267                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1])*invert;
05268                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1])*invert;
05269                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1])*invert;
05270                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1])*invert;
05271                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1])*invert;
05272                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1])*invert;
05273                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1])*invert;
05274                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1])*invert;
05275                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1])*invert;
05276                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2])*invert;
05277                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2])*invert;
05278                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2])*invert;
05279                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2])*invert;
05280                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2])*invert;
05281                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2])*invert;
05282                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2])*invert;
05283                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2])*invert;
05284                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2])*invert;
05285                                         if(peak_check) {
05286                                                 if(count < ml) {
05287                                                         count++;
05288                                                         peaks.push_back( Pixel(i, j, k, qbf) );
05289                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05290                                                 } else {
05291                                                         if( qbf > (peaks.back()).value ) {
05292                                                                 //  do the switch and sort again
05293                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05294                                                                 peaks.pop_back();
05295                                                                 peaks.push_back( Pixel(i, j, k, qbf) );
05296                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05297                                                         }
05298                                                 }
05299                                         }
05300                                         }}}}}}}}}}}}}}}}}}}}}}}}}
05301                                 }
05302                         }
05303                 }
05304         break;
05305 /*      case(5):  //looks ugly, but it is the best I can do,  PAP 03/07/08
05306         int nu = buf.get_usize();
05307         int nv = buf.get_vsize();
05308         vector<int> lu, mv;
05309                 for(m=1; m<=nv-2; ++m) {
05310                         mv.clear();
05311                         mv.push_back(m-1);
05312                         mv.push_back(m);
05313                         mv.push_back(m+1);
05314                 for(l=1; l<=nu-2; ++l) {
05315                         lu.clear();
05316                         lu.push_back(l-1);
05317                         lu.push_back(l);
05318                         lu.push_back(l+1);
05319                 for(k=1; k<=nz-2; ++k) {
05320                         kz.clear();
05321                         kz.push_back(k-1);
05322                         kz.push_back(k);
05323                         kz.push_back(k+1);
05324                         for(j=1; j<=ny-2; ++j) {
05325                                 jy.clear();
05326                                 jy.push_back(j-1);
05327                                 jy.push_back(j);
05328                                 jy.push_back(j+1);
05329                                 for(i=1; i<=nx-2; ++i) {
05330                                         ix.clear();
05331                                         ix.push_back(i-1);
05332                                         ix.push_back(i);
05333                                         ix.push_back(i+1);
05334                                         float qbf = buf(i,j,k,l,m)*invert;
05335                                         peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[0],mv[0])*invert;
05336                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[0],mv[0])*invert;
05337                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[0],mv[0])*invert;
05338                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[0],mv[0])*invert;
05339                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[0],mv[0])*invert;
05340                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[0],mv[0])*invert;
05341                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[0],mv[0])*invert;
05342                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[0],mv[0])*invert;
05343                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[0],mv[0])*invert;
05344                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[0],mv[0])*invert;
05345                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[0],mv[0])*invert;
05346                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[0],mv[0])*invert;
05347                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[0],mv[0])*invert;
05348                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[0],mv[0])*invert;
05349                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[0],mv[0])*invert;
05350                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[0],mv[0])*invert;
05351                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[0],mv[0])*invert;
05352                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[0],mv[0])*invert;
05353                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[0],mv[0])*invert;
05354                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[0],mv[0])*invert;
05355                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[0],mv[0])*invert;
05356                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[0],mv[0])*invert;
05357                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[0],mv[0])*invert;
05358                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[0],mv[0])*invert;
05359                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[0],mv[0])*invert;
05360                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[0],mv[0])*invert;
05361                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[0],mv[0])*invert;
05362 
05363                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[1],mv[0])*invert;
05364                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[1],mv[0])*invert;
05365                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[1],mv[0])*invert;
05366                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[1],mv[0])*invert;
05367                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[1],mv[0])*invert;
05368                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[1],mv[0])*invert;
05369                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[1],mv[0])*invert;
05370                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[1],mv[0])*invert;
05371                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[1],mv[0])*invert;
05372                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[1],mv[0])*invert;
05373                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[1],mv[0])*invert;
05374                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[1],mv[0])*invert;
05375                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[1],mv[0])*invert;
05376                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[1],mv[0])*invert;
05377                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[1],mv[0])*invert;
05378                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[1],mv[0])*invert;
05379                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[1],mv[0])*invert;
05380                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[1],mv[0])*invert;
05381                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[1],mv[0])*invert;
05382                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[1],mv[0])*invert;
05383                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[1],mv[0])*invert;
05384                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[1],mv[0])*invert;
05385                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[1],mv[0])*invert;
05386                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[1],mv[0])*invert;
05387                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[1],mv[0])*invert;
05388                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[1],mv[0])*invert;
05389                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[1],mv[0])*invert;
05390 
05391                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[2],mv[0])*invert;
05392                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[2],mv[0])*invert;
05393                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[2],mv[0])*invert;
05394                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[2],mv[0])*invert;
05395                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[2],mv[0])*invert;
05396                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[2],mv[0])*invert;
05397                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[2],mv[0])*invert;
05398                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[2],mv[0])*invert;
05399                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[2],mv[0])*invert;
05400                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[2],mv[0])*invert;
05401                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[2],mv[0])*invert;
05402                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[2],mv[0])*invert;
05403                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[2],mv[0])*invert;
05404                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[2],mv[0])*invert;
05405                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[2],mv[0])*invert;
05406                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[2],mv[0])*invert;
05407                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[2],mv[0])*invert;
05408                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[2],mv[0])*invert;
05409                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[2],mv[0])*invert;
05410                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[2],mv[0])*invert;
05411                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[2],mv[0])*invert;
05412                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[2],mv[0])*invert;
05413                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[2],mv[0])*invert;
05414                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[2],mv[0])*invert;
05415                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[2],mv[0])*invert;
05416                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[2],mv[0])*invert;
05417                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[2],mv[0])*invert;
05418 
05419 
05420                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[0],mv[1])*invert;
05421                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[0],mv[1])*invert;
05422                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[0],mv[1])*invert;
05423                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[0],mv[1])*invert;
05424                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[0],mv[1])*invert;
05425                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[0],mv[1])*invert;
05426                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[0],mv[1])*invert;
05427                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[0],mv[1])*invert;
05428                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[0],mv[1])*invert;
05429                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[0],mv[1])*invert;
05430                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[0],mv[1])*invert;
05431                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[0],mv[1])*invert;
05432                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[0],mv[1])*invert;
05433                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[0],mv[1])*invert;
05434                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[0],mv[1])*invert;
05435                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[0],mv[1])*invert;
05436                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[0],mv[1])*invert;
05437                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[0],mv[1])*invert;
05438                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[0],mv[1])*invert;
05439                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[0],mv[1])*invert;
05440                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[0],mv[1])*invert;
05441                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[0],mv[1])*invert;
05442                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[0],mv[1])*invert;
05443                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[0],mv[1])*invert;
05444                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[0],mv[1])*invert;
05445                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[0],mv[1])*invert;
05446                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[0],mv[1])*invert;
05447 
05448                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[1],mv[1])*invert;
05449                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[1],mv[1])*invert;
05450                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[1],mv[1])*invert;
05451                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[1],mv[1])*invert;
05452                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[1],mv[1])*invert;
05453                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[1],mv[1])*invert;
05454                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[1],mv[1])*invert;
05455                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[1],mv[1])*invert;
05456                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[1],mv[1])*invert;
05457                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[1],mv[1])*invert;
05458                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[1],mv[1])*invert;
05459                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[1],mv[1])*invert;
05460                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[1],mv[1])*invert;
05461                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[1],mv[1])*invert;
05462                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[1],mv[1])*invert;
05463                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[1],mv[1])*invert;
05464                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[1],mv[1])*invert;
05465                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[1],mv[1])*invert;
05466                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[1],mv[1])*invert;
05467                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[1],mv[1])*invert;
05468                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[1],mv[1])*invert;
05469                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[1],mv[1])*invert;
05470                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[1],mv[1])*invert;
05471                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[1],mv[1])*invert;
05472                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[1],mv[1])*invert;
05473                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[1],mv[1])*invert;
05474                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[1],mv[1])*invert;
05475 
05476                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[2],mv[1])*invert;
05477                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[2],mv[1])*invert;
05478                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[2],mv[1])*invert;
05479                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[2],mv[1])*invert;
05480                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[2],mv[1])*invert;
05481                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[2],mv[1])*invert;
05482                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[2],mv[1])*invert;
05483                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[2],mv[1])*invert;
05484                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[2],mv[1])*invert;
05485                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[2],mv[1])*invert;
05486                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[2],mv[1])*invert;
05487                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[2],mv[1])*invert;
05488                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[2],mv[1])*invert;
05489                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[2],mv[1])*invert;
05490                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[2],mv[1])*invert;
05491                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[2],mv[1])*invert;
05492                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[2],mv[1])*invert;
05493                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[2],mv[1])*invert;
05494                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[2],mv[1])*invert;
05495                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[2],mv[1])*invert;
05496                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[2],mv[1])*invert;
05497                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[2],mv[1])*invert;
05498                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[2],mv[1])*invert;
05499                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[2],mv[1])*invert;
05500                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[2],mv[1])*invert;
05501                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[2],mv[1])*invert;
05502                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[2],mv[1])*invert;
05503 
05504 
05505                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[0],mv[2])*invert;
05506                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[0],mv[2])*invert;
05507                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[0],mv[2])*invert;
05508                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[0],mv[2])*invert;
05509                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[0],mv[2])*invert;
05510                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[0],mv[2])*invert;
05511                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[0],mv[2])*invert;
05512                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[0],mv[2])*invert;
05513                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[0],mv[2])*invert;
05514                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[0],mv[2])*invert;
05515                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[0],mv[2])*invert;
05516                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[0],mv[2])*invert;
05517                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[0],mv[2])*invert;
05518                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[0],mv[2])*invert;
05519                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[0],mv[2])*invert;
05520                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[0],mv[2])*invert;
05521                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[0],mv[2])*invert;
05522                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[0],mv[2])*invert;
05523                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[0],mv[2])*invert;
05524                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[0],mv[2])*invert;
05525                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[0],mv[2])*invert;
05526                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[0],mv[2])*invert;
05527                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[0],mv[2])*invert;
05528                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[0],mv[2])*invert;
05529                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[0],mv[2])*invert;
05530                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[0],mv[2])*invert;
05531                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[0],mv[2])*invert;
05532 
05533                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[1],mv[2])*invert;
05534                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[1],mv[2])*invert;
05535                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[1],mv[2])*invert;
05536                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[1],mv[2])*invert;
05537                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[1],mv[2])*invert;
05538                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[1],mv[2])*invert;
05539                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[1],mv[2])*invert;
05540                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[1],mv[2])*invert;
05541                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[1],mv[2])*invert;
05542                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[1],mv[2])*invert;
05543                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[1],mv[2])*invert;
05544                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[1],mv[2])*invert;
05545                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[1],mv[2])*invert;
05546                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[1],mv[2])*invert;
05547                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[1],mv[2])*invert;
05548                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[1],mv[2])*invert;
05549                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[1],mv[2])*invert;
05550                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[1],mv[2])*invert;
05551                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[1],mv[2])*invert;
05552                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[1],mv[2])*invert;
05553                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[1],mv[2])*invert;
05554                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[1],mv[2])*invert;
05555                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[1],mv[2])*invert;
05556                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[1],mv[2])*invert;
05557                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[1],mv[2])*invert;
05558                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[1],mv[2])*invert;
05559                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[1],mv[2])*invert;
05560 
05561                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[0],lu[2],mv[2])*invert;
05562                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0],lu[2],mv[2])*invert;
05563                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0],lu[2],mv[2])*invert;
05564                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0],lu[2],mv[2])*invert;
05565                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0],lu[2],mv[2])*invert;
05566                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0],lu[2],mv[2])*invert;
05567                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0],lu[2],mv[2])*invert;
05568                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0],lu[2],mv[2])*invert;
05569                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0],lu[2],mv[2])*invert;
05570                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1],lu[2],mv[2])*invert;
05571                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1],lu[2],mv[2])*invert;
05572                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1],lu[2],mv[2])*invert;
05573                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1],lu[2],mv[2])*invert;
05574                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1],lu[2],mv[2])*invert;
05575                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1],lu[2],mv[2])*invert;
05576                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1],lu[2],mv[2])*invert;
05577                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1],lu[2],mv[2])*invert;
05578                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1],lu[2],mv[2])*invert;
05579                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2],lu[2],mv[2])*invert;
05580                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2],lu[2],mv[2])*invert;
05581                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2],lu[2],mv[2])*invert;
05582                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2],lu[2],mv[2])*invert;
05583                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2],lu[2],mv[2])*invert;
05584                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2],lu[2],mv[2])*invert;
05585                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2],lu[2],mv[2])*invert;
05586                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2],lu[2],mv[2])*invert;
05587                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],lu[2],mv[2])*invert;
05588                                         if(peak_check) {
05589                                                 if(count < ml) {
05590                                                         count++;
05591                                                         //peaks.push_back( Pixel(i, j, k, l, m, qbf) );
05592                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05593                                                 } else {
05594                                                         if( qbf > (peaks.back()).value ) {
05595                                                                 //  do the switch and sort again
05596                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05597                                                                 peaks.pop_back();
05598                                                                 //peaks.push_back( Pixel(i, j, k, l, m, qbf) );
05599                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05600                                                         }
05601                                                 }
05602                                         }
05603                                         }}}}}}}}}}}}}}}}}}}}}}}}}}
05604                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05605                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05606                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05607                                         }}}}}}}}}}}}}}}}}}}}}}}}}}
05608                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05609                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05610                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05611                                         }}}}}}}}}}}}}}}}}}}}}}}}}}}
05612                                 }
05613                         }
05614                 }
05615                 }
05616                 }
05617                 //  Add circular closure for x, y, and z directions: needed for circular ccf,
05618                 //  should not have adverse impact on other code.  PAP 11/7/08
05619                 for(m=1; m<=nv-2; ++m) {
05620                         mv.clear();
05621                         mv.push_back(m-1);
05622                         mv.push_back(m);
05623                         mv.push_back(m+1);
05624                 for(l=1; l<=nu-2; ++l) {
05625                         lu.clear();
05626                         lu.push_back(l-1);
05627                         lu.push_back(l);
05628                         lu.push_back(l+1);
05629                 for(k=1; k<=nz-2; ++k) {
05630                         kz.clear();
05631                         kz.push_back(k-1);
05632                         kz.push_back(k);
05633                         kz.push_back(k+1);
05634                         for(j=1; j<=ny-2; ++j) {
05635                                 jy.clear();
05636                                 jy.push_back(j-1);
05637                                 jy.push_back(j);
05638                                 jy.push_back(j+1);
05639                                 for(i=0; i<=0; ++i) {
05640                                         ix.clear();
05641                                         ix.push_back(nx-1);
05642                                         ix.push_back(i);
05643                                         ix.push_back(i+1);
05644                                         float qbf = buf(i,j,k)*invert;
05645                                         peak_check = qbf > buf(ix[0],jy[0],kz[0])*invert;
05646                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0])*invert;
05647                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0])*invert;
05648                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0])*invert;
05649                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0])*invert;
05650                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0])*invert;
05651                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0])*invert;
05652                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0])*invert;
05653                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0])*invert;
05654                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1])*invert;
05655                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1])*invert;
05656                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1])*invert;
05657                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1])*invert;
05658                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1])*invert;
05659                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1])*invert;
05660                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1])*invert;
05661                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1])*invert;
05662                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1])*invert;
05663                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2])*invert;
05664                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2])*invert;
05665                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2])*invert;
05666                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2])*invert;
05667                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2])*invert;
05668                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2])*invert;
05669                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2])*invert;
05670                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2])*invert;
05671                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2])*invert;
05672                                         if(peak_check) {
05673                                                 if(count < ml) {
05674                                                         count++;
05675                                                         peaks.push_back( Pixel(i, j, k, qbf) );
05676                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05677                                                 } else {
05678                                                         if( qbf > (peaks.back()).value ) {
05679                                                                 //  do the switch and sort again
05680                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05681                                                                 peaks.pop_back();
05682                                                                 peaks.push_back( Pixel(i, j, k, qbf) );
05683                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05684                                                         }
05685                                                 }
05686                                         }
05687                                         }}}}}}}}}}}}}}}}}}}}}}}}}
05688                                 }
05689                                 for(i=nx-1; i<=nx-1; ++i) {
05690                                         ix.clear();
05691                                         ix.push_back(i-1);
05692                                         ix.push_back(i);
05693                                         ix.push_back(0);
05694                                         float qbf = buf(i,j,k)*invert;
05695                                         peak_check = qbf > buf(ix[0],jy[0],kz[0])*invert;
05696                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[0])*invert;
05697                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[0])*invert;
05698                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[0])*invert;
05699                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[0])*invert;
05700                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[0])*invert;
05701                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[0])*invert;
05702                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[0])*invert;
05703                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[0])*invert;
05704                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[1])*invert;
05705                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[1])*invert;
05706                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[1])*invert;
05707                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[1])*invert;
05708                                         //if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[1])*invert;
05709                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[1])*invert;
05710                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[1])*invert;
05711                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[1])*invert;
05712                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[1])*invert;
05713                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[0],kz[2])*invert;
05714                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[0],kz[2])*invert;
05715                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[0],kz[2])*invert;
05716                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[1],kz[2])*invert;
05717                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[1],kz[2])*invert;
05718                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[1],kz[2])*invert;
05719                                         if( peak_check ) {peak_check = qbf > buf(ix[0],jy[2],kz[2])*invert;
05720                                         if( peak_check ) {peak_check = qbf > buf(ix[1],jy[2],kz[2])*invert;
05721                                         if( peak_check ) {peak_check = qbf > buf(ix[2],jy[2],kz[2],3,3)*invert;
05722                                         if(peak_check) {
05723                                                 if(count < ml) {
05724                                                         count++;
05725                                                         peaks.push_back( Pixel(i, j, k, qbf) );
05726                                                         if(count == ml-1) sort(peaks.begin(), peaks.end(), peakcmp);
05727                                                 } else {
05728                                                         if( qbf > (peaks.back()).value ) {
05729                                                                 //  do the switch and sort again
05730                                                                 //cout << qbf<<"   "<< (peaks.back()).value <<"   "<< (*peaks.begin()).value <<endl;
05731                                                                 peaks.pop_back();
05732                                                                 peaks.push_back( Pixel(i, j, k, qbf) );
05733                                                                 if(ml > 1) sort(peaks.begin(), peaks.end(), peakcmp);
05734                                                         }
05735                                                 }
05736                                         }
05737                                         }}}}}}}}}}}}}}}}}}}}}}}}}
05738                                 }
05739                         }
05740                 }
05741                 }
05742                 }
05743         break;*/
05744         }
05745         // do we have a peak list yet?
05746         if (peaks.begin() != peaks.end()) {
05747           // yes. sort it
05748           sort(peaks.begin(), peaks.end(), peakcmp);
05749 
05750           int count = 0;
05751 
05752           float xval = (*peaks.begin()).value;
05753           // loop over all peaks
05754           for (vector<Pixel>::iterator it = peaks.begin(); it != peaks.end(); it++)  {
05755             // current peak count
05756             count++;
05757             // is current peak count below max?
05758             if(count <= ml) {
05759               // yes, so append it
05760               res.push_back((*it).value);
05761               res.push_back(static_cast<float>((*it).x));
05762 
05763               if(img_dim > 1) {
05764                 res.push_back(static_cast<float>((*it).y));
05765                 if(nz > 1) res.push_back(static_cast<float>((*it).z));
05766               }
05767 
05768               if(xval != 0.0) res.push_back((*it).value/xval);
05769               else            res.push_back((*it).value);
05770               res.push_back((*it).x-float(int(nx/2)));
05771               if(img_dim >1) {
05772                 res.push_back((*it).y-float(int(ny/2)));
05773                 if(nz>1)   res.push_back((*it).z-float(nz/2));
05774               }
05775             }
05776           }
05777           res.insert(res.begin(),1,img_dim);
05778         } else {
05779           // no peak list. build empty list
05780           res.push_back(buf(0,0,0));
05781           res.insert(res.begin(),1,0.0);
05782         }
05783 
05784         // return results list
05785         return res;
05786 }
05787 
05788 #define rdata(i,j,k) rdata[(i-1)+((j-1)+(k-1)*ny)*(size_t)nx]

bool EMData::peakcmp const Pixel p1,
const Pixel p2
[static, private]
 

Definition at line 4948 of file emdata_sparx.cpp.

04950                                                      {

EMData * EMData::phase  )  const
 

return phase part of a complex image as a real image format

Returns:
EMData * a real image which is the phase part of this image
Exceptions:
InvalidCallException if this image is a real image or is in real/imaginary format

Definition at line 1259 of file emdata_core.cpp.

References data, EMData(), get_data(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_real(), is_ri(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_size(), and update().

01260 {
01261         ENTERFUNC;
01262 
01263         EMData * e = new EMData();
01264 
01265         if( is_real() ) {
01266                 delete e;
01267                 throw InvalidCallException("No imaginary part for a real image, this function call require a complex image.");
01268         }
01269         else {
01270                 if(is_ri()) {
01271                         delete e;
01272                         throw InvalidCallException("This image is in real/imaginary format, this function call require a complex image in amplitude/phase format.");
01273                 }
01274 
01275                 int nx = get_xsize();
01276                 int ny = get_ysize();
01277                 int nz = get_zsize();
01278                 e->set_size(nx/2, ny, nz);
01279                 float * edata = e->get_data();
01280                 float * data = get_data();
01281                 size_t idx1, idx2;
01282                 for( int i=0; i<nx; ++i ) {
01283                         for( int j=0; j<ny; ++j ) {
01284                                 for( int k=0; k<nz; ++k ) {
01285                                         if( i%2 == 1 ) {
01286                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01287                                                 idx2 = i+j*nx+k*nx*ny;
01288                                                 //complex data in format [real, complex, real, complex...]
01289                                                 edata[idx1] = data[idx2];
01290                                         }
01291                                 }
01292                         }
01293                 }
01294         }
01295 
01296         e->set_complex(false);
01297         if(e->get_ysize()==1 && e->get_zsize()==1) {
01298                 e->set_complex_x(false);
01299         }
01300         e->update();
01301         return e;
01302 
01303         EXITFUNC;
01304 }

vector< float > EMData::phase_cog  ) 
 

Calculate the Phase approximation to center of gravity This operations works for 1-2-3-d images.

Returns:
both the center of gravity and the phase approximated center of gravity values.

Definition at line 5794 of file emdata_sparx.cpp.

References C, nx, and rdata.

Referenced by ali3d_d(), and EMAN::PhaseToMassCenterProcessor::process_inplace().

05797                            {
05798                 P = 8*atan(1.0f)/nx;
05799                 for (i=1;i<=nx;i++) {
05800                         C += cos(P * (i-1)) * rdata(i,j,k);
05801                         S += sin(P * (i-1)) * rdata(i,j,k);
05802                 }
05803                 F1 = atan2(S,C);
05804                 if (F1 < 0.0)  F1 += 8*atan(1.0f);
05805                 SNX = F1/P +1.0f;
05806                 SNX = SNX - ((nx/2)+1);
05807                 ph_cntog.push_back(SNX);
05808 #ifdef _WIN32
05809                 ph_cntog.push_back((float)Util::round(SNX));
05810 #else
05811                 ph_cntog.push_back(round(SNX));
05812 #endif //_WIN32
05813         } else if (get_ndim()==2)  {
05814 #ifdef _WIN32
05815                 float SNY;
05816                 float T=0.0f;
05817                 vector<float> X;
05818                 X.resize(nx);
05819 #else
05820                 float SNY,X[nx],T=0.f;
05821 #endif  //_WIN32
05822                 for ( i=1;i<=nx;i++) X(i)=0.0;
05823                 P = 8*atan(1.0f)/ny;
05824                 for(j=1;j<=ny;j++) {
05825                         T=0.f;
05826                         for(i=1;i<=nx;i++) {
05827                                 T += rdata(i,j,k);
05828                                 X(i)+=rdata(i,j,k);
05829                         }
05830                         C += cos(P*(j-1))*T;
05831                         S += sin(P*(j-1))*T;
05832                 }
05833                 F1=atan2(S,C);
05834                 if(F1<0.0)  F1 += 8*atan(1.0f);
05835                 SNY = F1/P +1.0f;
05836                 C=0.f;  S=0.f;
05837                 P = 8*atan(1.0f)/nx;
05838                 for(i=1;i<=nx;i++) {
05839                         C += cos(P*(i-1))*X(i);
05840                         S += sin(P*(i-1))*X(i);
05841                 }
05842                 F1=atan2(S,C);
05843                 if(F1<0.0) F1 += 8*atan(1.0f);
05844                 SNX = F1/P +1.0f;
05845                 SNX = SNX - ((nx/2)+1);
05846                 SNY = SNY - ((ny/2)+1);
05847                 ph_cntog.push_back(SNX); ph_cntog.push_back(SNY);
05848 #ifdef _WIN32
05849                  ph_cntog.push_back((float)Util::round(SNX)); ph_cntog.push_back((float)Util::round(SNY));
05850 #else
05851                  ph_cntog.push_back(round(SNX)); ph_cntog.push_back(round(SNY));
05852 #endif  //_WIN32
05853         } else {
05854 #ifdef _WIN32
05855                 float val=0.f,sum1=0.f, SNY,SNZ;
05856                 vector<float> X;
05857                 X.resize(nx);
05858                 vector<float> Y;
05859                 Y.resize(ny);
05860                 vector<float> Z;
05861                 Z.resize(nz);
05862 #else
05863                 float val=0.f, sum1=0.f, X[nx], Y[ny], Z[nz], SNY, SNZ;
05864 #endif  //_WIN32
05865                  for (i=1;i<=nx;i++)  X(i)=0.0;
05866                  for (j=1;j<=ny;j++)  Y(j)=0.0;
05867                  for (k=1;k<=nz;k++)  Z(k)=0.0;
05868                  for(k=1;k<=nz;k++)  {
05869                         for(j=1;j<=ny;j++) {
05870                                 sum1=0.f;
05871                                 for(i=1;i<=nx;i++)  {
05872                                         val = rdata(i,j,k);
05873                                         sum1 += val;
05874                                         X(i) += val;
05875                                 }
05876                                 Y(j) += sum1;
05877                                 Z(k) += sum1;
05878                         }
05879                 }
05880                 P = 8*atan(1.0f)/nx;
05881                 for (i=1;i<=nx;i++) {
05882                         C += cos(P*(i-1))*X(i);
05883                         S += sin(P*(i-1))*X(i);
05884                 }
05885                 F1=atan2(S,C);
05886                 if(F1<0.0) F1 += 8*atan(1.0f);
05887                 SNX = F1/P +1.0f;
05888                 C=0.f;  S=0.f;
05889                 P = 8*atan(1.0f)/ny;
05890                 for(j=1;j<=ny;j++) {
05891                         C += cos(P*(j-1))*Y(j);
05892                         S += sin(P*(j-1))*Y(j);
05893                 }
05894                 F1=atan2(S,C);
05895                 if(F1<0.0)  F1 += 8*atan(1.0f);
05896                 SNY = F1/P +1.0f;
05897                 C=0.f;  S=0.f;
05898                 P = 8*atan(1.0f)/nz;
05899                 for(k=1;k<=nz;k++) {
05900                         C += cos(P*(k-1))*Z(k);
05901                         S += sin(P*(k-1))*Z(k);
05902                 }
05903                 F1=atan2(S,C);
05904                 if(F1<0.0)  F1 += 8*atan(1.0f);
05905                 SNZ = F1/P +1.0f;
05906                 SNX = SNX - ((nx/2)+1);
05907                 SNY = SNY - ((ny/2)+1);
05908                 SNZ = SNZ - ((nz/2)+1);
05909                 ph_cntog.push_back(SNX); ph_cntog.push_back(SNY); ph_cntog.push_back(SNZ);
05910 #ifdef _WIN32
05911                 ph_cntog.push_back((float)Util::round(SNX)); ph_cntog.push_back((float)Util::round(SNY)); ph_cntog.push_back((float)Util::round(SNZ));
05912 #else
05913                 ph_cntog.push_back(round(SNX)); ph_cntog.push_back(round(SNY));ph_cntog.push_back(round(SNZ));
05914 #endif
05915         }
05916         return ph_cntog;
05917 }
05918 #undef rdata
05919 #undef X

EMData * EMData::power int  n  )  const
 

return a image to the power of n

Parameters:
n the power of this image
Returns:
a image which is the nth power of this image
Exceptions:
InvalidValueException n must be >= 0

Definition at line 934 of file emdata_core.cpp.

References copy(), InvalidValueException, to_one(), and update().

00935 {
00936         ENTERFUNC;
00937 
00938         if( n<0 ) {
00939                 throw InvalidValueException(n, "the power of negative integer not supported.");
00940         }
00941 
00942         EMData * r = this->copy();
00943         if( n == 0 ) {
00944                 r->to_one();
00945         }
00946         else if( n>1 ) {
00947                 for( int i=1; i<n; i++ ) {
00948                         *r *= *this;
00949                 }
00950         }
00951 
00952         r->update();
00953         return r;
00954 
00955         EXITFUNC;
00956 }

void EMData::print_image const string  str = string(""),
ostream &  out = std::cout
 

Print the image data to a file stream (standard out by default).

Parameters:
out Output stream; cout by default.
str Message string to be printed.

Definition at line 428 of file emdata_io.cpp.

References get_xsize(), get_ysize(), get_zsize(), nx, ny, and nz.

00428                                                        {
00429         out << "Printing EMData object: " << str << std::endl;
00430         int nx = get_xsize();
00431         int ny = get_ysize();
00432         int nz = get_zsize();
00433         for (int iz = 0; iz < nz; iz++) {
00434                 out << "(z = " << iz << " slice)" << std::endl;
00435                 for (int ix = 0; ix < nx; ix++) {
00436                         for (int iy = 0; iy < ny; iy++) {
00437                                 out << setiosflags(std::ios::fixed)
00438                                         << setiosflags(std::ios_base::scientific)
00439                                         << std::setw(12)
00440                                          << std::setprecision(5) << (*this)(ix,iy,iz) << "  ";
00441                                 if (((iy+1) % 6) == 0) {
00442                                         out << std::endl << "   ";
00443                                 }
00444                         }
00445                         out << std::endl;
00446                 }
00447         }
00448 }

EMData * EMData::process Processor p  )  const
 

Call the process with an instance od Processor, usually this instance can be get by (in Python) Processors.get("name", {'k':v, 'k':v}).

Parameters:
p the processor pointer

Definition at line 86 of file emdata_modular.cpp.

References EMAN::Processor::process().

00087 {
00088         ENTERFUNC;
00089         EMData * result = 0;
00090         if(p) {
00091                 result = p->process(this);
00092         }
00093         return result;
00094         EXITFUNC;
00095 }

EMData * EMData::process const string &  processorname,
const Dict params = Dict()
const
 

Apply a processor with its parameters on a copy of this image, return result as a a new image.

The returned image may or may not be the same size as this image.

Parameters:
processorname Processor Name.
params Processor parameters in a keyed dictionary.
Returns:
the processed result, a new image
Exceptions:
NotExistingObjectError If the processor doesn't exist.

Definition at line 69 of file emdata_modular.cpp.

References EMAN::Processor::process().

Referenced by EMAN::RT3DSymmetryAligner::align(), EMAN::RT3DSphereAligner::align(), EMAN::RT3DGridAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::align(), EMAN::SymAlignProcessorQuat::align(), EMAN::RefineAlignerCG::align(), EMAN::RefineAligner::align(), EMAN::SymAlignProcessor::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotatePrecenterAligner::align(), EMAN::RotationalAligner::align(), EMAN::TranslationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), EMAN::SqEuclideanCmp::cmp(), make_rotational_footprint_e1(), EMAN::BackProjectionReconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::ScaleTransformProcessor::process(), EMAN::ApplySymProcessor::process(), refalifn(), refalifn3dquat(), symquat(), EMAN::RT3DSymmetryAligner::xform_align_nbest(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00070 {
00071         ENTERFUNC;
00072         Processor *f = Factory < Processor >::get(processorname, params);
00073         EMData * result = 0;
00074         if (f) {
00075                 result = f->process(this);
00076                 if( f )
00077                 {
00078                         delete f;
00079                         f = 0;
00080                 }
00081         }
00082         return result;
00083         EXITFUNC;
00084 }

void EMData::process_inplace Processor p  ) 
 

Call the process_inplace with an instance od Processor, usually this instancecan be get by (in Python) Processors.get("name", {'k':v, 'k':v}).

Parameters:
p the processor pointer

Definition at line 60 of file emdata_modular.cpp.

References EMAN::Processor::process_inplace().

00061 {
00062         ENTERFUNC;
00063         if(p) {
00064                 p->process_inplace(this);
00065         }
00066         EXITFUNC;
00067 }

void EMData::process_inplace const string &  processorname,
const Dict params = Dict()
 

Apply a processor with its parameters on this image.

Parameters:
processorname Processor Name.
params Processor parameters in a keyed dictionary.
Exceptions:
NotExistingObjectError If the processor doesn't exist.

Definition at line 45 of file emdata_modular.cpp.

References EMAN::Processor::process_inplace().

Referenced by EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), ali3d_d(), EMAN::Refine3DAlignerGrid::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::TranslationalAligner::align(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_fast_sigma_image(), calc_flcf(), calc_mutual_correlation(), EMAN::TomoCccCmp::cmp(), EMAN::FFTResampleProcessor::fft_resample(), FH2Real(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::FourierReconstructorSimple2D::finish(), get_circle_mean(), main(), make_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::multi_processors(), EMAN::padfft_slice(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::BackProjectionReconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::ScaleTransformProcessor::process(), EMAN::CtfSimProcessor::process(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::IndexMaskFileProcessor::process_inplace(), EMAN::LocalNormProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), read_binedimage(), translate(), EMAN::Util::twoD_to_3D_ali(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00046 {
00047         ENTERFUNC;
00048         Processor *f = Factory < Processor >::get(processorname, params);
00049         if (f) {
00050                 f->process_inplace(this);
00051                 if( f )
00052                 {
00053                         delete f;
00054                         f = 0;
00055                 }
00056         }
00057         EXITFUNC;
00058 }

EMData * EMData::project const string &  projector_name,
const Transform t3d
 

Calculate the projection of this image and return the result.

Parameters:
projector_name Projection algorithm name.
t3d Transform object used to do projection.
Exceptions:
NotExistingObjectError If the projection algorithm doesn't exist.
Returns:
The result image.

Definition at line 173 of file emdata_modular.cpp.

References EMAN::Projector::project3d().

00174 {
00175         ENTERFUNC;
00176         EMData *result = 0;
00177         Dict params;
00178         params["transform"] = (Transform*) &t3d;
00179         Projector *p = Factory < Projector >::get(projector_name, params);
00180         if (p) {
00181                 result = p->project3d(this);
00182                 if( p )
00183                 {
00184                         delete p;
00185                         p = 0;
00186                 }
00187         }
00188 
00189         EXITFUNC;
00190         return result;
00191 }

EMData * EMData::project const string &  projector_name,
const Dict params = Dict()
 

Calculate the projection of this image and return the result.

Parameters:
projector_name Projection algorithm name.
params Projection Algorithm parameters.
Exceptions:
NotExistingObjectError If the projection algorithm doesn't exist.
Returns:
The result image.

Definition at line 154 of file emdata_modular.cpp.

References EMAN::Projector::project3d().

Referenced by ali3d_d(), and main().

00155 {
00156         ENTERFUNC;
00157         EMData *result = 0;
00158         Projector *p = Factory < Projector >::get(projector_name, params);
00159         if (p) {
00160                 result = p->project3d(this);
00161                 if( p )
00162                 {
00163                         delete p;
00164                         p = 0;
00165                 }
00166         }
00167 
00168         EXITFUNC;
00169         return result;
00170 }

void EMData::read_binedimage const string &  filename,
int  img_index = 0,
int  binfactor = 0,
bool  fast = false,
bool  is_3d = false
 

read in a binned image, bin while reading.

For use in huge files(tomograms)

Parameters:
filename The image file name.
img_index The nth image you want to read.
binfactor The amout you want to bin by. Must be an integer
fast Only bin xy slice every binfactor intervals, otherwise meanshrink z
is_3d Whether to treat the image as a single 3D or a set of 2Ds. This is a hint for certain image formats which has no difference between 3D image and set of 2Ds.
Exceptions:
ImageFormatException 
ImageReadException 

Definition at line 141 of file emdata_io.cpp.

References attr_dict, EMAN::EMUtil::em_memcpy(), EMData(), EMAN::Dict::erase(), get_data(), EMAN::EMUtil::get_imageio(), EMAN::Dict::has_key(), ImageFormatException, ImageReadException, EMAN::ImageIO::is_complex_mode(), nx, ny, nz, process_inplace(), EMAN::ImageIO::read_header(), read_image(), save_byteorder_to_dict(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), and update().

00142 {
00143         ENTERFUNC;
00144         
00145         ImageIO *imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY);
00146         
00147         if (!imageio) {
00148                 throw ImageFormatException("cannot create an image io");
00149         }
00150         else {
00151                 int err = imageio->read_header(attr_dict, img_index, 0, is_3d);
00152                 if (err) {
00153                         throw ImageReadException(filename, "imageio read header failed");
00154                 }
00155                 else {
00156                         attr_dict["source_path"] = filename;
00157                         attr_dict["source_n"] = img_index;
00158                         if (imageio->is_complex_mode()) {
00159                                 set_complex(true);
00160                                 set_fftpad(true);
00161                         }
00162                         if (attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1) {
00163                                 set_fftodd(true);
00164                         }
00165                         if ((int) attr_dict["is_complex_ri"] == 1) {
00166                                 set_ri(true);
00167                         }
00168                         save_byteorder_to_dict(imageio);
00169 
00170                         int ori_nx = nx = attr_dict["nx"];
00171                         int ori_ny = ny = attr_dict["ny"];
00172                         int ori_nz = nz = attr_dict["nz"];
00173                         attr_dict.erase("nx");
00174                         attr_dict.erase("ny");
00175                         attr_dict.erase("nz");
00176                         
00177                         // At this point nx, ny and nz are all reduced by binfactor
00178                         set_size(nx/binfactor, ny/binfactor, nz/binfactor);
00179 
00180                         //here is where we read in the binned data
00181                         EMData* tempdata = new EMData();
00182                         size_t sizeofslice = nx*ny*sizeof(float);
00183                         
00184                         //zbin factor use 1 to speed binning(but don't benfit by averaging in Z)
00185                         int zbin = binfactor;
00186                         if(fast) zbin = 1;
00187                         //verbose
00188                         float percent = 0.1f;
00189                         for(int k = 0; k < ori_nz; k+=binfactor){
00190                                 if(k > ori_nz*percent){ 
00191                                         cout << float(k)/float(ori_nz) << "% Done!" << endl;
00192                                         percent+=0.1f;
00193                                 }
00194                                 // read in a slice region
00195                                 const Region* binregion = new Region(0,0,k,ori_nx,ori_ny,zbin);
00196                                 tempdata->read_image(filename, 0, false, binregion);
00197                                 // shrink the slice
00198                                 if (binfactor > 1) tempdata->process_inplace("math.meanshrink",Dict("n",binfactor));
00199                                 size_t offset = nx*ny*k/binfactor;
00200                                 //add slice to total
00201                                 EMUtil::em_memcpy(get_data()+offset,tempdata->get_data(),sizeofslice);
00202                                 delete binregion;
00203                         }
00204                         
00205                         delete tempdata;
00206                         update();
00207                 }
00208         }
00209 
00210 #ifndef IMAGEIO_CACHE
00211         if( imageio )
00212         {
00213 #ifdef HDFIO_CACHE
00214                 if(dynamic_cast<HdfIO2*>(imageio)==NULL && dynamic_cast<HdfIO*>(imageio)==NULL) {
00215 #endif  //HDFIO_CACHE
00216                         delete imageio;
00217                         imageio = 0;
00218 #ifdef HDFIO_CACHE
00219                 }
00220 #endif  //HDFIO_CACHE
00221         }
00222 #endif  //IMAGEIO_CACHE
00223 
00224         EXITFUNC;
00225 }

void EMData::read_data string  fsp,
size_t  loc,
const Region area = 0,
const int  file_nx = 0,
const int  file_ny = 0,
const int  file_nz = 0
 

Read the image pixel data in native byte order from a disk file.

The image should already have the correct dimensions.

Parameters:
fsp The filename to read the image data from
loc Location to seek to in the file before writing (size_t)
area The image region you want to read, default 0 means read the whole image
file_nx Image x size.
file_ny Image y size.
file_nz Image z size.
Author:
Steve Ludtke
Date:
Mon Jun 23, 2008

Definition at line 235 of file emdata_metadata.cpp.

References FileAccessException, get_data(), and portable_fseek().

00235                                                                                                                         {
00236         FILE *f = 0;
00237         f=fopen(fsp.c_str(), "rb");
00238         if (!f) throw FileAccessException(fsp);
00239         int fnx = nx;
00240         if (file_nx != 0) fnx = file_nx;
00241         int fny = ny;
00242         if (file_ny != 0) fny = file_ny;
00243         int fnz = nz;
00244         if (file_nz != 0) fnz = file_nz;
00245 
00246         portable_fseek(f,loc,SEEK_SET);
00247         EMUtil::process_region_io(get_data(), f, ImageIO::READ_ONLY,
00248                                                           0, 4,fnx,fny,fnz,area);
00249 //      portable_fseek(f,loc,SEEK_SET);
00250 //      if (fread(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00251         fclose(f);
00252 }

void EMData::read_image const string &  filename,
int  img_index = 0,
bool  header_only = false,
const Region region = 0,
bool  is_3d = false
 

read an image file and stores its information to this EMData object.

If a region is given, then only read a region of the image file. The region will be this EMData object. The given region must be inside the given image file. Otherwise, an error will be created.

Parameters:
filename The image file name.
img_index The nth image you want to read.
header_only To read only the header or both header and data.
region To read only a region of the image.
is_3d Whether to treat the image as a single 3D or a set of 2Ds. This is a hint for certain image formats which has no difference between 3D image and set of 2Ds.
Exceptions:
ImageFormatException 
ImageReadException 

Definition at line 51 of file emdata_io.cpp.

References attr_dict, EMAN::EMUtil::em_free(), EMAN::Dict::erase(), get_data(), EMAN::Region::get_depth(), EMAN::Region::get_height(), EMAN::EMUtil::get_imageio(), EMAN::Region::get_width(), EMAN::Dict::has_key(), ImageFormatException, ImageReadException, EMAN::ImageIO::is_complex_mode(), nx, ny, nz, rdata, EMAN::ImageIO::read_data(), EMAN::ImageIO::read_header(), save_byteorder_to_dict(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), to_zero(), and update().

Referenced by EMAN::PCA::dopca_ooc(), EMAN::TestUtil::dump_image_from_file(), EMData(), EMAN::Util::eval(), EMAN::PCA::Lanczos_ooc(), main(), ParseAlignOptions(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::IndexMaskFileProcessor::process_inplace(), read_binedimage(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), recons3d_4nn(), and EMAN::TestUtil::verify_image_file_by_mode().

00053 {
00054         ENTERFUNC;
00055 
00056         ImageIO *imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY);
00057 
00058         if (!imageio) {
00059                 throw ImageFormatException("cannot create an image io");
00060         }
00061         else {
00062                 int err = imageio->read_header(attr_dict, img_index, region, is_3d);
00063                 if (err) {
00064                         throw ImageReadException(filename, "imageio read header failed");
00065                 }
00066                 else {
00067                         LstIO * myLstIO = dynamic_cast<LstIO *>(imageio);
00068                         if(!myLstIO)    attr_dict["source_path"] = filename;    //"source_path" is set to full path of reference image for LstIO, so skip this statement
00069                         attr_dict["source_n"] = img_index;
00070                         if (imageio->is_complex_mode()) {
00071                                 set_complex(true);
00072                                 set_fftpad(true);
00073                         }
00074                         if (attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1) {
00075                                 set_fftodd(true);
00076                         }
00077                         if ((int) attr_dict["is_complex_ri"] == 1) {
00078                                 set_ri(true);
00079                         }
00080                         save_byteorder_to_dict(imageio);
00081 
00082                         nx = attr_dict["nx"];
00083                         ny = attr_dict["ny"];
00084                         nz = attr_dict["nz"];
00085                         attr_dict.erase("nx");
00086                         attr_dict.erase("ny");
00087                         attr_dict.erase("nz");
00088 
00089                         if (!nodata) {
00090 
00091                                 if (region) {
00092                                         nx = (int)region->get_width();
00093                                         if (nx <= 0) nx = 1;
00094                                         ny = (int)region->get_height();
00095                                         if (ny <= 0) ny = 1;
00096                                         nz = (int)region->get_depth();
00097                                         if (nz <= 0) nz = 1;
00098                                         set_size(nx,ny,nz);
00099                                         to_zero(); // This could be avoided in favor of setting only the regions that were not read to to zero... but tedious
00100                                 } // else the dimensions of the file being read match those of this
00101                                 else {
00102                                         set_size(nx, ny, nz);
00103                                 }
00104 
00105                                 // If GPU features are enabled there is  danger that rdata will
00106                                 // not be allocated, but set_size takes care of this, so this
00107                                 // should be safe.
00108                                 int err = imageio->read_data(get_data(), img_index, region, is_3d);
00109                                 if (err) {
00110                                         throw ImageReadException(filename, "imageio read data failed");
00111                                 }
00112                                 else {
00113                                         update();
00114                                 }
00115                         }
00116                         else {
00117                                 if (rdata!=0) EMUtil::em_free(rdata);
00118                                 rdata=0;
00119                         }
00120                                 
00121                 }
00122         }
00123 
00124 #ifndef IMAGEIO_CACHE
00125         if( imageio )
00126         {
00127 #ifdef HDFIO_CACHE
00128                 if(dynamic_cast<HdfIO2*>(imageio)==NULL && dynamic_cast<HdfIO*>(imageio)==NULL) {
00129 #endif  //HDFIO_CACHE
00130                         delete imageio;
00131                         imageio = 0;
00132 #ifdef HDFIO_CACHE
00133                 }
00134 #endif  //HDFIO_CACHE
00135         }
00136 #endif  //IMAGEIO_CACHE
00137 
00138         EXITFUNC;
00139 }

vector< shared_ptr< EMData > > EMData::read_images const string &  filename,
vector< int >  img_indices = vector< int >(),
bool  header_only = false
[static]
 

Read a set of images from file specified by 'filename'.

Which images are read is set by 'img_indices'.

Parameters:
filename The image file name.
img_indices Which images are read. If it is empty, all images are read. If it is not empty, only those in this array are read.
header_only If true, only read image header. If false, read both data and header.
Returns:
The set of images read from filename.

Definition at line 450 of file emdata_io.cpp.

References EMData(), ImageReadException, OutofRangeException, EMAN::Dict::size(), and v.

00452 {
00453         ENTERFUNC;
00454 
00455         int total_img = EMUtil::get_image_count(filename);
00456         size_t num_img = img_indices.size();
00457 
00458         for (size_t i = 0; i < num_img; i++) {
00459                 if (img_indices[i] < 0 && img_indices[i] >= total_img) {
00460                         throw OutofRangeException(0, total_img, img_indices[i], "image index");
00461                 }
00462         }
00463 
00464         size_t n = (num_img == 0 ? total_img : num_img);
00465 
00466         vector< shared_ptr<EMData> > v;
00467         for (size_t j = 0; j < n; j++) {
00468                 shared_ptr<EMData> d(new EMData());
00469                 size_t k = (num_img == 0 ? j : img_indices[j]);
00470                 try {
00471                         d->read_image(filename, (int)k, header_only);
00472                 }
00473                 catch(E2Exception &e) {
00474                         throw(e);
00475                 }
00476                 if ( d != 0 )
00477                 {
00478                         v.push_back(d);
00479                 }
00480                 else
00481                         throw ImageReadException(filename, "imageio read data failed");
00482         }
00483 
00484         EXITFUNC;
00485         return v;
00486 }

vector< shared_ptr< EMData > > EMData::read_images_ext const string &  filename,
int  img_index_start,
int  img_index_end,
bool  header_only = false,
const string &  ext = ""
[static]
 

Read a set of images from file specified by 'filename'.

If the given 'ext' is not empty, replace 'filename's extension it. Images with index from img_index_start to img_index_end are read.

Parameters:
filename The image file name.
img_index_start Starting image index.
img_index_end Ending image index.
header_only If true, only read image header. If false, read both data and header.
ext The new image filename extension.
Returns:
The set of images read from filename.

Definition at line 489 of file emdata_io.cpp.

References EMData(), InvalidValueException, OutofRangeException, and v.

00492 {
00493         ENTERFUNC;
00494 
00495         if (img_index_end < img_index_start) {
00496                 throw InvalidValueException(img_index_end, "image index end < image index start");
00497         }
00498         string new_filename = filename;
00499         new_filename = new_filename.insert(new_filename.rfind("."), ext);
00500         int num_img = EMUtil::get_image_count(new_filename);
00501 
00502         if (img_index_start < 0 || img_index_start >= num_img) {
00503                 throw OutofRangeException(0, num_img-1, img_index_start, "image index start");
00504         }
00505 
00506         if (img_index_end >= num_img) {
00507                 img_index_end = num_img - 1;
00508         }
00509 
00510         vector < shared_ptr<EMData> >v;
00511 
00512         for (int i = img_index_start; i < img_index_end; i++) {
00513                 shared_ptr<EMData> d(new EMData());
00514                 try {
00515                         d->read_image(new_filename, i, header_only);
00516                 }
00517                 catch(E2Exception &e) {
00518                         throw(e);
00519                 }
00520                 v.push_back(d);
00521         }
00522         EXITFUNC;
00523         return v;
00524 }

EMData * EMData::real  )  const
 

return real part of a complex image as a real image format, if this image is a real image, return a copy of this image.

Returns:
a real image which is the real part of this image.

Definition at line 1049 of file emdata_core.cpp.

References copy(), data, EMData(), get_data(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_real(), is_ri(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_size(), and update().

Referenced by add_complex_at(), EMAN::newfile_store::add_tovol(), div(), FH2F(), mult(), real2FH(), and set_complex_at().

01050 {
01051         ENTERFUNC;
01052 
01053         EMData * e = new EMData();
01054 
01055         if( is_real() ) // a real image, return a copy of itself
01056         {
01057                 e = this->copy();
01058         }
01059         else //for a complex image
01060         {
01061                 if( !is_ri() )
01062                 {
01063                         delete e;
01064                         throw InvalidCallException("This image is in amplitude/phase format, this function call require a complex image in real/imaginary format.");
01065                 }
01066                 int nx = get_xsize();
01067                 int ny = get_ysize();
01068                 int nz = get_zsize();
01069                 e->set_size(nx/2, ny, nz);
01070                 float * edata = e->get_data();
01071                 float * data = get_data();
01072                 size_t idx1, idx2;
01073                 for( int i=0; i<nx; ++i )
01074                 {
01075                         for( int j=0; j<ny; ++j )
01076                         {
01077                                 for( int k=0; k<nz; ++k )
01078                                 {
01079                                         if( i%2 == 0 )
01080                                         {
01081                                                 //complex data in format [real, complex, real, complex...]
01082                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01083                                                 idx2 = i+j*nx+k*nx*ny;
01084                                                 edata[idx1] = data[idx2];
01085                                         }
01086                                 }
01087                         }
01088                 }
01089         }
01090 
01091         e->set_complex(false);
01092         if(e->get_ysize()==1 && e->get_zsize()==1) {
01093                 e->set_complex_x(false);
01094         }
01095         e->update();
01096         return e;
01097 
01098         EXITFUNC;
01099 }

EMData * EMData::real2complex float  img = 0.0f  )  const
 

create a complex image from a real image, this complex image is in real/imaginary format

Parameters:
img give an artificial imaginary part
Returns:
a complex image which is generated from a real image
Exceptions:
InvalidCallException this function can not be called by complex image

Definition at line 1306 of file emdata_core.cpp.

References EMData(), get_xsize(), get_ysize(), get_zsize(), InvalidCallException, is_complex(), nx, nx, ny, ny, nz, set_complex(), set_complex_x(), set_ri(), set_size(), and update().

01307 {
01308         ENTERFUNC;
01309 
01310         if( is_complex() ) {
01311                 throw InvalidCallException("This function call only apply to real image");
01312         }
01313 
01314         EMData * e = new EMData();
01315         int nx = get_xsize();
01316         int ny = get_ysize();
01317         int nz = get_zsize();
01318         e->set_size(nx*2, ny, nz);
01319 
01320         for( int k=0; k<nz; ++k ) {
01321                 for( int j=0; j<ny; ++j ) {
01322                         for( int i=0; i<nx; ++i ) {
01323                                 (*e)(i*2,j,k) = (*this)(i,j,k);
01324                                 (*e)(i*2+1,j,k) = img;
01325                         }
01326                 }
01327         }
01328 
01329         e->set_complex(true);
01330         if(e->get_ysize()==1 && e->get_zsize()==1) {
01331                 e->set_complex_x(true);
01332         }
01333         e->set_ri(true);
01334         e->update();
01335         return e;
01336 
01337         EXITFUNC;
01338 }

EMData * EMData::real2FH float  OverSamplekB  ) 
 

returns the fourier harmonic transform (FH) image of the current image (in real space).

The current image is not changed. The result is in real/imaginary format. The FH switch is set on.

Parameters:
OverSamplekB is a parameter controlling the fineness of the Fourier sampling
Returns:
the Fourier Harmonic image

Definition at line 54 of file emdata_sparx.cpp.

References copy(), get_xsize(), get_ysize(), get_zsize(), imag(), ImageFormatException, is_complex(), LOGERR, nx, nx, ny, ny, nz, Radialize(), real(), set_complex(), set_complex_x(), set_fftodd(), set_FH(), set_ri(), set_size(), spline_mat(), to_zero(), and update().

00055 {
00056         int nx        = get_xsize();
00057         int ny        = get_ysize();
00058         int nz        = get_zsize();
00059         int Center  = (int) floor( (nx+1.0)/2.0 +.01);
00060 #ifdef DEBUG
00061         printf("nx=%d, ny=%d, nz=%d Center=%d\n", nx,ny,nz, Center);
00062 #endif  //DEBUG
00063         float ScalFactor=4.1f;
00064         gsl_set_error_handler_off();
00065 
00066         if ( (nz==1) && (nx==ny) && (!is_complex())  && (Center*2)==(nx+1)){
00067 #ifdef DEBUG
00068                 printf("entered if \n");fflush(stdout);
00069 #endif  //DEBUG
00070 //              MArray2D ImBW = this ->get_2dview();
00071                 EMData*  ImBW = this ;
00072                 int Size=nx;
00073                 int iMax = (int) floor( (Size-1.0)/2 +.01);
00074                 int CountMax = (iMax+2)*(iMax+1)/2;
00075                 int *PermMatTr  = new int[CountMax];
00076                 float *RValsSorted  = new float[CountMax];
00077                 float *weightofkValsSorted = new float[CountMax];
00078                 int *SizeReturned = new int[1];
00079                 Util::Radialize(PermMatTr, RValsSorted,weightofkValsSorted,Size, SizeReturned);
00080                 int RIntMax= SizeReturned[0];
00081 
00082                 int mMax = (int) floor( ScalFactor*RValsSorted[RIntMax-1]+10.0);
00083 
00084                 int kIntMax=2+ (int) floor( RValsSorted[RIntMax-1]*OverSamplekB);
00085                 float *kVec2Use= new float[kIntMax];
00086                 for (int kk=0; kk<kIntMax; kk++){
00087                         kVec2Use[kk]= ((float) kk)/OverSamplekB;}
00088 
00089                 float *krVec= new float[kIntMax*RIntMax];
00090                 int Count=0;
00091                 for (int jk=0; jk<kIntMax; jk++ ){
00092                         for (int jR=0; jR<RIntMax; jR++ ){
00093                                 krVec[Count]=2.0f*M_PI*RValsSorted[jR]
00094                                         *kVec2Use[jk]/( (float) Size);
00095                                 Count++;
00096 //                              printf("krVec[%d]=%f \n",Count,krVec[Count-1]);fflush(stdout);
00097                 }} // end building up krVec
00098                 float krVecMin= kVec2Use[1]*RValsSorted[1];
00099                 float krVecMax = krVec[kIntMax*RIntMax-1]+krVecMin;
00100                 int Number2Use = (int) floor(OverSamplekB*krVecMax+1.0);
00101                 float *krVec2Use      = new float[Number2Use+1];
00102                 float *sampledBesselJ = new float[Number2Use+1];
00103 #ifdef DEBUG
00104                 printf("Size=%d, iMax=%d, SizeReturned=%d, RIntMax=%d, \n"
00105                       "mMax=%d, kIntMax=%d, krVecMin=%f, krVecMax=%f,  Number2Use=%d  \n\n",
00106                         Size, iMax, SizeReturned[0], RIntMax, mMax, kIntMax,
00107                                krVecMin,krVecMax,Number2Use);fflush(stdout);
00108 #endif  //DEBUG
00109                 for (int jkr=0; jkr<= Number2Use; jkr++) {
00110                         krVec2Use[jkr] =((float)jkr)*krVecMax/
00111                                     ((float)Number2Use);
00112 //                      printf("krVec2Use[%d]=%f \n",jkr+1,krVec2Use[jkr]);fflush(stdout);
00113                 }
00114 
00115 
00116                 EMData* rhoOfkmB = copy(); // glibc detected ** malloc(); memory corruption
00117 //              printf("finished O \n");fflush(stdout);
00118                 rhoOfkmB->set_size(2*(mMax+1),kIntMax);
00119                 rhoOfkmB->to_zero();
00120 //              MArray2D rhoOfkmB = FH->get_2dview();
00121 
00122                 int CenterM= Center-1; // to convert from Matlab to C++
00123                 std::complex <float> *rhoOfRandmTemp = new std::complex <float>[RIntMax];
00124                 std::complex <float> rhoTemp;
00125 
00126                 int PCount=0;
00127 
00128                 for (int m=0; m <=mMax; m++){
00129                 //    if m==mMax, tic, end
00130                         std::complex <float> tempF(0.0f,-1.0f);
00131                         std::complex <float> overallFactor = pow(tempF,m);  //(-i)^m ;  % I dropped off the 2 pi
00132                         std::complex <float> mI(0.0f,static_cast<float>(m));
00133                         for (int ii=0; ii< RIntMax; ii++){ rhoOfRandmTemp[ii]=0;}
00134                         for (int jx=0; jx <Center ; jx++) {
00135                                 for (int jy=0; jy <=jx; jy++){
00136                                         float fjx=float(jx);
00137                                         float fjy= float(jy);
00138                                         Count = (jx*jx+jx)/2 +1 +jy;
00139                                         PCount = PermMatTr[Count-1];
00140 //                                      printf("PCount=%d, Count=%d \n", PCount, Count);
00141                                         rhoTemp =  std::complex <float> ((*ImBW)(CenterM+jx,CenterM+jy)) *exp(mI* std::complex <float> (atan2(+fjy,+fjx)))
00142                                          +   std::complex <float> ((*ImBW)(CenterM+jx,CenterM-jy)) * exp(mI*std::complex <float>(atan2(-fjy,+fjx)))
00143                                          +   std::complex <float> ((*ImBW)(CenterM-jx,CenterM+jy)) * exp(mI*std::complex <float>(atan2(+fjy,-fjx)))
00144                                          +   std::complex <float> ((*ImBW)(CenterM-jx,CenterM-jy)) * exp(mI*std::complex <float>(atan2(-fjy,-fjx)))
00145                                          +   std::complex <float> ((*ImBW)(CenterM+jy,CenterM+jx)) * exp(mI*std::complex <float>(atan2(+fjx,+fjy)))
00146                                          +   std::complex <float> ((*ImBW)(CenterM+jy,CenterM-jx)) * exp(mI*std::complex <float>(atan2(-fjx,+fjy)))
00147                                          +   std::complex <float> ((*ImBW)(CenterM-jy,CenterM+jx)) * exp(mI*std::complex <float>(atan2(+fjx,-fjy)))
00148                                          +   std::complex <float> ((*ImBW)(CenterM-jy,CenterM-jx)) * exp(mI*std::complex <float>(atan2(-fjx,-fjy)));
00149                                         if (((jx+jy)==0)&&(m>0) ){
00150                                                 rhoTemp=0;}
00151 //                      printf("m=%d, jx=%d, jy=%d, rhoTemp= %f+ %f i\n", m,jx,jy,(rhoTemp.real()), (rhoTemp.imag()) );fflush(stdout);
00152 //                      {" %f,%f %f,%f %f,%f %f,%f \n",
00153 //                             ImBW[CenterM+jx][CenterM+jy] ,ImBW[CenterM+jx][CenterM-jy]  , ImBW[CenterM-jx][CenterM+jy] ,ImBW[CenterM-jx][CenterM-jy],
00154 //                             ImBW[CenterM+jy][CenterM+jx] ,ImBW[CenterM+jy][CenterM-jx]  , ImBW[CenterM-jy][CenterM+jx] ,ImBW[CenterM-jy][CenterM-jx]);
00155                                         rhoOfRandmTemp[PCount-1] +=
00156                                             rhoTemp/((float)pow(2.,(int)( (jx==0)  +(jy==0)+ (jy==jx))));
00157 
00158                         }} // end walk through lattice
00159 //                      printf("\n m=%d rhoOfRandmTemp" ,m  );fflush(stdout);
00160 //                      for (int ss=0; ss< RIntMax; ss++){
00161 //                              printf(" %3.1f+ %3.1fi \t",(rhoOfRandmTemp[ss].real()), (rhoOfRandmTemp[ss].imag())   );fflush(stdout);}
00162 
00163 // calculate product
00164 
00165                         float tempp;
00166 //                      printf("\n m=%d sampledBesselJ" ,m  );fflush(stdout);
00167                         for (int st=0; st<= Number2Use; st++){
00168                                 tempp=krVec2Use[st];
00169                                 sampledBesselJ[st] = static_cast<float>(gsl_sf_bessel_Jn(m,tempp));
00170 //                              printf(" %3.2f  \t",sampledBesselJ[st]   );fflush(stdout);
00171                         } // good so far
00172 
00173 //                      sampledBesselJ  = BesselJ(m,krVec2Use);
00174                         float *tempMB = new float [kIntMax*RIntMax];
00175                         Util::spline_mat(krVec2Use, sampledBesselJ, Number2Use+1,krVec,tempMB,kIntMax*RIntMax );
00176 //                      printf("\n tempMB m=%d y2" ,m  );fflush(stdout);
00177                         std::complex <float> *rowV = new std::complex <float> [kIntMax];
00178 
00179 //                      for (int st=0; st< kIntMax*RIntMax; st++){printf(" %3.2f  \t",tempMB[st]   );fflush(stdout);} // good so far
00180 
00181 //   tempMB,krVec is in blocks of RIntMax
00182 //                      printf("\n rowV m=%d \t" ,m  );fflush(stdout);
00183                         for (int st=0; st < kIntMax; st++) {
00184                                         rowV[st]=0;
00185                                         for (int sv=0; sv < RIntMax; sv++) {
00186                                                 rowV[st]+=  rhoOfRandmTemp[sv] *tempMB[sv+st*RIntMax];
00187                                         }
00188                                          rowV[st] *= overallFactor;
00189 //                                      printf(" %1.3f +%1.3fi \t" , rowV[st].real(), rowV[st].imag() );fflush(stdout);
00190                         }
00191                         for (int st=0; st < kIntMax; st++) {
00192                                 (*rhoOfkmB)(2*m  ,st) = rowV[st].real();
00193                                 (*rhoOfkmB)(2*m+1,st) = rowV[st].imag();
00194                         }
00195 //                      rowV = overallFactor*rhoOfRandmTemp*tempMBB;
00196 //                      rhoOfkmB(m+1,1:kIntMax) = rowV ;
00197 
00198 //                      if m==mMax, toc, end
00199 
00200 // %'final interpolation'
00201 // %     rhoOfkm(m+1,:) = spline(kVec2Use,rowV,RValsSorted); ;
00202 
00203 
00204                 } // ends m loop
00205 
00206                 update();
00207                 rhoOfkmB-> update();
00208                 rhoOfkmB->set_complex(true);
00209                 if(rhoOfkmB->get_ysize()==1 && rhoOfkmB->get_zsize()==1) {
00210                         rhoOfkmB->set_complex_x(true);
00211                 }
00212         rhoOfkmB->set_ri(true);
00213         rhoOfkmB->set_FH(true);
00214         rhoOfkmB->set_fftodd(true);
00215                 return rhoOfkmB;
00216         } else {
00217                 LOGERR("2D real square odd image expected.");
00218                 throw ImageFormatException("2D real square odd image expected.");
00219         }
00220 }

void EMData::render_amp24 int  x,
int  y,
int  xsize,
int  ysize,
int  bpl,
float  scale,
int  min_gray,
int  max_gray,
float  min_render,
float  max_render,
void *  ref,
void   cmap(void *, int coord, unsigned char *tri)
 

Render the image into a 24-bit image.

2D image only.

Parameters:
x 
y 
xsize 
ysize 
bpl 
scale 
min_gray 
max_gray 
min_render 
max_render 
ref 
cmap 
Exceptions:
ImageDimensionException If the image is not 2D.

Definition at line 696 of file emdata_transform.cpp.

References br, data, get_data(), get_ndim(), ImageDimensionException, is_complex(), nx, nx, ny, ny, ri2ap(), and t.

00700 {
00701         ENTERFUNC;
00702 
00703         if (get_ndim() != 2) {
00704                 throw ImageDimensionException("2D only");
00705         }
00706 
00707         if (is_complex()) {
00708                 ri2ap();
00709         }
00710 
00711         if (render_max <= render_min) {
00712                 render_max = render_min + 0.01f;
00713         }
00714 
00715         std::string ret=std::string();
00716         ret.resize(iysize*bpl);
00717         unsigned char *data=(unsigned char *)ret.data();
00718 
00719         float rm = render_min;
00720         float inv_scale = 1.0f / scale;
00721         int ysize = iysize;
00722         int xsize = ixsize;
00723         const int scale_n = 100000;
00724 
00725         int ymin = 0;
00726         if ( iysize * inv_scale > ny) {
00727                 ymin = (int) (iysize - ny / inv_scale);
00728         }
00729         float gs = (maxgray - mingray) / (render_max - render_min);
00730         if (render_max < render_min) {
00731                 gs = 0;
00732                 rm = FLT_MAX;
00733         }
00734         int dsx = -1;
00735         int dsy = 0;
00736         if (inv_scale == floor(inv_scale)) {
00737                 dsx = (int) inv_scale;
00738                 dsy = (int) (inv_scale * nx);
00739         }
00740         int addi = 0;
00741         int addr = 0;
00742 
00743         if (dsx == -1) {
00744                 addi = (int) floor(inv_scale);
00745                 addr = (int) (scale_n * (inv_scale - floor(inv_scale)));
00746         }
00747 
00748         int remx = 0;
00749         int remy = 0;
00750         int xmin = 0;
00751         if (x0 < 0) {
00752                 xmin = (int) (-x0 / inv_scale);
00753                 xsize -= (int) floor(x0 / inv_scale);
00754                 x0 = 0;
00755         }
00756 
00757         if ((xsize - xmin) * inv_scale > (nx - x0)) {
00758                 xsize = (int) ((nx - x0) / inv_scale + xmin);
00759         }
00760         int ymax = ysize - 1;
00761         if (y0 < 0) {
00762                 ymax = (int) (ysize + y0 / inv_scale - 1);
00763                 ymin += (int) floor(y0 / inv_scale);
00764                 y0 = 0;
00765         }
00766 
00767 
00768         if (xmin < 0) {
00769                 xmin = 0;
00770         }
00771 
00772         if (ymin < 0) {
00773                 ymin = 0;
00774         }
00775         if (xsize > ixsize) {
00776                 xsize = ixsize;
00777         }
00778         if (ymax > iysize) {
00779                 ymax = iysize;
00780         }
00781 
00782         int lmax = nx * ny - 1;
00783         unsigned char tri[3];
00784         float* image_data = get_data();
00785         if (is_complex()) {
00786                 if (dsx != -1) {
00787                         int l = y0 * nx;
00788                         for (int j = ymax; j >= ymin; j--) {
00789                                 int ll = x0;
00790                                 for (int i = xmin; i < xsize; i++, ll += dsx) {
00791                                         if (l + ll > lmax || ll >= nx - 2) {
00792                                                 break;
00793                                         }
00794                                         int kk = 0;
00795                                         if (ll >= nx / 2) {
00796                                                 if (l >= (ny - inv_scale) * nx) {
00797                                                         kk = 2 * (ll - nx / 2) + 2;
00798                                                 }
00799                                                 else {
00800                                                         kk = 2 * (ll - nx / 2) + l + 2 + nx;
00801                                                 }
00802                                         }
00803                                         else {
00804                                                 kk = nx * ny - (l + 2 * ll) - 2;
00805                                         }
00806                                         int k = 0;
00807                                         float t = image_data[kk];
00808                                         if (t <= rm) {
00809                                                 k = mingray;
00810                                         }
00811                                         else if (t >= render_max) {
00812                                                 k = maxgray;
00813                                         }
00814                                         else {
00815                                                 k = (int) (gs * (t - render_min));
00816                                                 k += mingray;
00817                                         }
00818                                         tri[0] = static_cast < unsigned char >(k);
00819                                         cmap(ref, kk, tri);
00820                                         data[i * 3 + j * bpl] = tri[0];
00821                                         data[i * 3 + 1 + j * bpl] = tri[1];
00822                                         data[i * 3 + 2 + j * bpl] = tri[2];
00823                                 }
00824                                 l += dsy;
00825                         }
00826                 }
00827                 else {
00828                         remy = 10;
00829                         for (int j = ymax, l = y0 * nx; j >= ymin; j--) {
00830                                 int br = l;
00831                                 remx = 10;
00832                                 for (int i = xmin, ll = x0; i < xsize - 1; i++) {
00833                                         if (l + ll > lmax || ll >= nx - 2) {
00834                                                 break;
00835                                         }
00836                                         int kk = 0;
00837                                         if (ll >= nx / 2) {
00838                                                 if (l >= (ny * nx - nx)) {
00839                                                         kk = 2 * (ll - nx / 2) + 2;
00840                                                 }
00841                                                 else {
00842                                                         kk = 2 * (ll - nx / 2) + l + 2 + nx;
00843                                                 }
00844                                         }
00845                                         else {
00846                                                 kk = nx * ny - (l + 2 * ll) - 2;
00847                                         }
00848                                         int k = 0;
00849                                         float t = image_data[kk];
00850                                         if (t <= rm) {
00851                                                 k = mingray;
00852                                         }
00853                                         else if (t >= render_max) {
00854                                                 k = maxgray;
00855                                         }
00856                                         else {
00857                                                 k = (int) (gs * (t - render_min));
00858                                                 k += mingray;
00859                                         }
00860                                         tri[0] = static_cast < unsigned char >(k);
00861                                         cmap(ref, kk, tri);
00862                                         data[i * 3 + j * bpl] = tri[0];
00863                                         data[i * 3 + 1 + j * bpl] = tri[1];
00864                                         data[i * 3 + 2 + j * bpl] = tri[2];
00865                                         ll += addi;
00866                                         remx += addr;
00867                                         if (remx > scale_n) {
00868                                                 remx -= scale_n;
00869                                                 ll++;
00870                                         }
00871                                 }
00872                                 l = br + addi * nx;
00873                                 remy += addr;
00874                                 if (remy > scale_n) {
00875                                         remy -= scale_n;
00876                                         l += nx;
00877                                 }
00878                         }
00879                 }
00880         }
00881         else {
00882                 if (dsx != -1) {
00883                         for (int j = ymax, l = x0 + y0 * nx; j >= ymin; j--) {
00884                                 int br = l;
00885                                 for (int i = xmin; i < xsize; i++, l += dsx) {
00886                                         if (l > lmax) {
00887                                                 break;
00888                                         }
00889                                         float t = image_data[l];
00890                                         int k = 0;
00891                                         if (t <= rm) {
00892                                                 k = mingray;
00893                                         }
00894                                         else if (t >= render_max) {
00895                                                 k = maxgray;
00896                                         }
00897                                         else {
00898                                                 k = (int) (gs * (t - render_min));
00899                                                 k += mingray;
00900                                         }
00901                                         tri[0] = static_cast < unsigned char >(k);
00902                                         cmap(ref, l, tri);
00903                                         data[i * 3 + j * bpl] = tri[0];
00904                                         data[i * 3 + 1 + j * bpl] = tri[1];
00905                                         data[i * 3 + 2 + j * bpl] = tri[2];
00906                                 }
00907                                 l = br + dsy;
00908                         }
00909                 }
00910                 else {
00911                         remy = 10;
00912                         for (int j = ymax, l = x0 + y0 * nx; j >= ymin; j--) {
00913                                 int br = l;
00914                                 remx = 10;
00915                                 for (int i = xmin; i < xsize; i++) {
00916                                         if (l > lmax) {
00917                                                 break;
00918                                         }
00919                                         float t = image_data[l];
00920                                         int k = 0;
00921                                         if (t <= rm) {
00922                                                 k = mingray;
00923                                         }
00924                                         else if (t >= render_max) {
00925                                                 k = maxgray;
00926                                         }
00927                                         else {
00928                                                 k = (int) (gs * (t - render_min));
00929                                                 k += mingray;
00930                                         }
00931                                         tri[0] = static_cast < unsigned char >(k);
00932                                         cmap(ref, l, tri);
00933                                         data[i * 3 + j * bpl] = tri[0];
00934                                         data[i * 3 + 1 + j * bpl] = tri[1];
00935                                         data[i * 3 + 2 + j * bpl] = tri[2];
00936                                         l += addi;
00937                                         remx += addr;
00938                                         if (remx > scale_n) {
00939                                                 remx -= scale_n;
00940                                                 l++;
00941                                         }
00942                                 }
00943                                 l = br + addi * nx;
00944                                 remy += addr;
00945                                 if (remy > scale_n) {
00946                                         remy -= scale_n;
00947                                         l += nx;
00948                                 }
00949                         }
00950                 }
00951         }
00952 
00953         EXITFUNC;
00954 }

std::string EMAN::EMData::render_amp8 int  x,
int  y,
int  xsize,
int  ysize,
int  bpl,
float  scale,
int  min_gray,
int  max_gray,
float  min_render,
float  max_render,
float  gamma,
int  flags
 

Render the image into an 8-bit image.

2D images only. flags provide a way to do unusual things with this function, such as calculating a histogram of the rendered area.

Parameters:
x origin of the area to render
y 
xsize size of the area to render in output pixels
ysize 
bpl bytes per line, if asrgb remember *3
scale scale factor for rendering
min_gray minimum gray value to render (0-255)
max_gray maximum gray value to render (0-255)
min_render float image density corresponding to min_gray
max_render float image density corresponding to max_gray
gamma 
flags 1-duplicate each output pixel 3x for RGB rendering,2-add a 256 int greyscale histogram to the end of the image array,4-invert y axis,8-render 32 bit 0xffRRGGBB
Exceptions:
ImageDimensionException If the image is not 2D.

std::string EMData::render_ap24 int  x,
int  y,
int  xsize,
int  ysize,
int  bpl,
float  scale,
int  min_gray,
int  max_gray,
float  min_render,
float  max_render,
float  gamma,
int  flags
 

Render the image into an 8-bit image.

2D images only. flags provide a way to do unusual things with this function, such as calculating a histogram of the rendered area.

Parameters:
x origin of the area to render
y 
xsize size of the area to render in output pixels
ysize 
bpl bytes per line, if asrgb remember *3
scale scale factor for rendering
min_gray minimum gray value to render (0-255)
max_gray maximum gray value to render (0-255)
min_render float image density corresponding to min_gray
max_render float image density corresponding to max_gray
gamma 
flags 1-duplicate each output pixel 3x for RGB rendering,2-add a 256 int greyscale histogram to the end of the image array,4-invert y axis,8-render 32 bit 0xffRRGGBB
Exceptions:
ImageDimensionException If the image is not 2D.

Definition at line 420 of file emdata_transform.cpp.

References br, data, get_data(), get_ndim(), ImageDimensionException, is_complex(), nx, nx, ny, ny, ri2ap(), t, x, and y.

00423 {
00424         ENTERFUNC;
00425 
00426         int asrgb;
00427         int hist=(flags&2)/2;
00428         int invy=(flags&4)?1:0;
00429 
00430         if (!is_complex()) throw ImageDimensionException("complex only");
00431 
00432         if (get_ndim() != 2) {
00433                 throw ImageDimensionException("2D only");
00434         }
00435 
00436         if (is_complex()) ri2ap();
00437 
00438         if (render_max <= render_min) {
00439                 render_max = render_min + 0.01f;
00440         }
00441 
00442         if (gamma<=0) gamma=1.0;
00443 
00444         // Calculating a full floating point gamma for
00445         // each pixel in the image slows rendering unacceptably
00446         // however, applying a gamma-mapping to an 8 bit colorspace
00447         // has unaccepable accuracy. So, we oversample the 8 bit colorspace
00448         // as a 12 bit colorspace and apply the gamma mapping to that
00449         // This should produce good accuracy for gamma values
00450         // larger than 0.5 (and a high upper limit)
00451         static int smg0=0,smg1=0;       // while this destroys threadsafety in the rendering process
00452         static float sgam=0;            // it is necessary for speed when rendering large numbers of small images
00453         static unsigned char gammamap[4096];
00454         if (gamma!=1.0 && (smg0!=mingray || smg1!=maxgray || sgam!=gamma)) {
00455                 for (int i=0; i<4096; i++) {
00456                         if (mingray<maxgray) gammamap[i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00457                         else gammamap[4095-i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00458                 }
00459         }
00460         smg0=mingray;   // so we don't recompute the map unless something changes
00461         smg1=maxgray;
00462         sgam=gamma;
00463 
00464         if (flags&8) asrgb=4;
00465         else if (flags&1) asrgb=3;
00466         else throw ImageDimensionException("must set flag 1 or 8");
00467 
00468         std::string ret=std::string();
00469 //      ret.resize(iysize*bpl);
00470         ret.assign(iysize*bpl+hist*1024,char(mingray));
00471         unsigned char *data=(unsigned char *)ret.data();
00472         unsigned int *histd=(unsigned int *)(data+iysize*bpl);
00473         if (hist) {
00474                 for (int i=0; i<256; i++) histd[i]=0;
00475         }
00476 
00477         float rm = render_min;
00478         float inv_scale = 1.0f / scale;
00479         int ysize = iysize;
00480         int xsize = ixsize;
00481 
00482         int ymin = 0;
00483         if (iysize * inv_scale > ny) {
00484                 ymin = (int) (iysize - ny / inv_scale);
00485         }
00486 
00487         float gs = (maxgray - mingray) / (render_max - render_min);
00488         float gs2 = 4095.999f / (render_max - render_min);
00489 //      float gs2 = 1.0 / (render_max - render_min);
00490         if (render_max < render_min) {
00491                 gs = 0;
00492                 rm = FLT_MAX;
00493         }
00494 
00495         int dsx = -1;
00496         int dsy = 0;
00497         int remx = 0;
00498         int remy = 0;
00499         const int scale_n = 100000;
00500 
00501         int addi = 0;
00502         int addr = 0;
00503         if (inv_scale == floor(inv_scale)) {
00504                 dsx = (int) inv_scale;
00505                 dsy = (int) (inv_scale * nx);
00506         }
00507         else {
00508                 addi = (int) floor(inv_scale);
00509                 addr = (int) (scale_n * (inv_scale - floor(inv_scale)));
00510         }
00511 
00512         int xmin = 0;
00513         if (x0 < 0) {
00514                 xmin = (int) (-x0 / inv_scale);
00515                 xsize -= (int) floor(x0 / inv_scale);
00516                 x0 = 0;
00517         }
00518 
00519         if ((xsize - xmin) * inv_scale > (nx - x0)) {
00520                 xsize = (int) ((nx - x0) / inv_scale + xmin);
00521         }
00522         int ymax = ysize - 1;
00523         if (y0 < 0) {
00524                 ymax = (int) (ysize + y0 / inv_scale - 1);
00525                 ymin += (int) floor(y0 / inv_scale);
00526                 y0 = 0;
00527         }
00528 
00529         if (xmin < 0) xmin = 0;
00530         if (ymin < 0) ymin = 0;
00531         if (xsize > ixsize) xsize = ixsize;
00532         if (ymax > iysize) ymax = iysize;
00533 
00534         int lmax = nx * ny - 1;
00535 
00536         int mid=nx*ny/2;
00537         float* image_data = get_data();
00538         if (dsx != -1) {
00539                 int l = y0 * nx;
00540                 for (int j = ymax; j >= ymin; j--) {
00541                         int ll = x0;
00542                         for (int i = xmin; i < xsize; i++) {
00543                                 if (l + ll > lmax || ll >= nx - 2) break;
00544 
00545                                 int k = 0;
00546                                 unsigned char p;
00547                                 int ph;
00548                                 if (ll >= nx / 2) {
00549                                         if (l >= (ny - inv_scale) * nx) k = 2 * (ll - nx / 2) + 2;
00550                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
00551                                         if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00552                                         else k+=mid;
00553                                         ph = (int)(image_data[k+1]*768/(2.0*M_PI))+384; // complex phase as integer 0-767
00554                                 }
00555                                 else {
00556                                         k = nx * ny - (l + 2 * ll) - 2;
00557                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00558                                         if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00559                                         else k+=mid;
00560                                 }
00561                                 float t = image_data[k];
00562                                 if (t <= rm)  p = mingray;
00563                                 else if (t >= render_max) p = maxgray;
00564                                 else if (gamma!=1.0) {
00565                                         k=(int)(gs2 * (t-render_min));          // map float value to 0-4096 range
00566                                         p = gammamap[k];                                        // apply gamma using precomputed gamma map
00567                                 }
00568                                 else {
00569                                         p = (unsigned char) (gs * (t - render_min));
00570                                         p += mingray;
00571                                 }
00572                                 if (ph<256) {
00573                                         data[i * asrgb + j * bpl] = p*(255-ph)/256;
00574                                         data[i * asrgb + j * bpl+1] = p*ph/256;
00575                                         data[i * asrgb + j * bpl+2] = 0;
00576                                 }
00577                                 else if (ph<512) {
00578                                         data[i * asrgb + j * bpl+1] = p*(511-ph)/256;
00579                                         data[i * asrgb + j * bpl+2] = p*(ph-256)/256;
00580                                         data[i * asrgb + j * bpl] = 0;
00581                                 }
00582                                 else {
00583                                         data[i * asrgb + j * bpl+2] = p*(767-ph)/256;
00584                                         data[i * asrgb + j * bpl] = p*(ph-512)/256;
00585                                         data[i * asrgb + j * bpl+1] = 0;
00586                                 }
00587                                 if (hist) histd[p]++;
00588                                 ll += dsx;
00589                         }
00590                         l += dsy;
00591                 }
00592         }
00593         else {
00594                 remy = 10;
00595                 int l = y0 * nx;
00596                 for (int j = ymax; j >= ymin; j--) {
00597                         int br = l;
00598                         remx = 10;
00599                         int ll = x0;
00600                         for (int i = xmin; i < xsize - 1; i++) {
00601                                 if (l + ll > lmax || ll >= nx - 2) {
00602                                         break;
00603                                 }
00604                                 int k = 0;
00605                                 unsigned char p;
00606                                 int ph;
00607                                 if (ll >= nx / 2) {
00608                                         if (l >= (ny * nx - nx)) k = 2 * (ll - nx / 2) + 2;
00609                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
00610                                         if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00611                                         else k+=mid;
00612                                         ph = (int)(image_data[k+1]*768/(2.0*M_PI))+384; // complex phase as integer 0-767
00613                                 }
00614                                 else {
00615                                         k = nx * ny - (l + 2 * ll) - 2;
00616                                         if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00617                                         else k+=mid;
00618                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00619                                 }
00620 
00621                                 float t = image_data[k];
00622                                 if (t <= rm)
00623                                         p = mingray;
00624                                 else if (t >= render_max) {
00625                                         p = maxgray;
00626                                 }
00627                                 else if (gamma!=1.0) {
00628                                         k=(int)(gs2 * (t-render_min));          // map float value to 0-4096 range
00629                                         p = gammamap[k];                                        // apply gamma using precomputed gamma map
00630                                 }
00631                                 else {
00632                                         p = (unsigned char) (gs * (t - render_min));
00633                                         p += mingray;
00634                                 }
00635                                 if (ph<256) {
00636                                         data[i * asrgb + j * bpl] = p*(255-ph)/256;
00637                                         data[i * asrgb + j * bpl+1] = p*ph/256;
00638                                         data[i * asrgb + j * bpl+2] = 0;
00639                                 }
00640                                 else if (ph<512) {
00641                                         data[i * asrgb + j * bpl+1] = p*(511-ph)/256;
00642                                         data[i * asrgb + j * bpl+2] = p*(ph-256)/256;
00643                                         data[i * asrgb + j * bpl] = 0;
00644                                 }
00645                                 else {
00646                                         data[i * asrgb + j * bpl+2] = p*(767-ph)/256;
00647                                         data[i * asrgb + j * bpl] = p*(ph-512)/256;
00648                                         data[i * asrgb + j * bpl+1] = 0;
00649                                 }
00650                                 if (hist) histd[p]++;
00651                                 ll += addi;
00652                                 remx += addr;
00653                                 if (remx > scale_n) {
00654                                         remx -= scale_n;
00655                                         ll++;
00656                                 }
00657                         }
00658                         l = br + addi * nx;
00659                         remy += addr;
00660                         if (remy > scale_n) {
00661                                 remy -= scale_n;
00662                                 l += nx;
00663                         }
00664                 }
00665         }
00666 
00667         // this replicates r -> g,b
00668         if (asrgb==4) {
00669                 for (int j=ymin*bpl; j<=ymax*bpl; j+=bpl) {
00670                         for (int i=xmin; i<xsize*4; i+=4) {
00671                                 data[i+j+3]=255;
00672                         }
00673                 }
00674         }
00675 
00676         EXITFUNC;
00677 
00678         // ok, ok, not the most efficient place to do this, but it works
00679         if (invy) {
00680                 int x,y;
00681                 char swp;
00682                 for (y=0; y<iysize/2; y++) {
00683                         for (x=0; x<ixsize; x++) {
00684                                 swp=ret[y*bpl+x];
00685                                 ret[y*bpl+x]=ret[(iysize-y-1)*bpl+x];
00686                                 ret[(iysize-y-1)*bpl+x]=swp;
00687                         }
00688                 }
00689         }
00690 
00691     //  return PyString_FromStringAndSize((const char*) data,iysize*bpl);
00692         return ret;
00693 }

EMData * EMData::replace_amplitudes EMData image,
bool  RetReal = true
 

Definition at line 7325 of file emdata_sparx.cpp.

References nx, and ny.

07333                           {
07334                 // fimage must remain pristine
07335                 fp = this->copy();
07336         } else {
07337                 fp = this->norm_pad( false, 1);
07338                 fp->do_fft_inplace();
07339         }
07340         float *fout = fp->get_data();
07341         float *fint = image->get_data();
07342         for ( int iz = 0; iz < nz; iz++) {
07343                 for ( int iy = 0; iy < ny; iy++) {
07344                         for ( int ix = 0; ix < nx; ix+=2) {
07345                                 float qt = fint(ix,iy,iz)*fint(ix,iy,iz)+fint(ix+1,iy,iz)*fint(ix+1,iy,iz);
07346                                 float rt = fout(ix,iy,iz)*fout(ix,iy,iz)+fout(ix+1,iy,iz)*fout(ix+1,iy,iz);
07347                                 if(rt > 1.0e-20) {
07348                                                 fout(ix,iy,iz) *= (qt/rt);
07349                                                 fout(ix+1,iy,iz) *= (qt/rt);
07350                                 } else {
07351                                                 qt = std::sqrt(qt/2.0f);
07352                                                 fout(ix,iy,iz) = qt;
07353                                                 fout(ix+1,iy,iz) = qt;
07354                                 }
07355                         }
07356                 }
07357         }
07358 
07359         fp->set_ri(1);
07360         fp->set_fftpad(true);
07361         fp->set_attr("npad", 1);
07362         if (nx%2 == 1) fp->set_fftodd(true);
07363         else fp->set_fftodd(false);
07364         if(RetReal) {
07365                 fp->do_ift_inplace();
07366                 fp->depad();
07367         }
07368         fp->set_array_offsets(0,0,0);
07369         fp->update();
07370 
07371         return fp;
07372 }
07373 #undef fint
07374 #undef fout
07375 

float EMAN::EMData::restrict1 float  x,
int  nx
[inline, static]
 

Definition at line 2831 of file emdata.h.

float EMAN::EMData::restrict2 float  x,
int  nx
[inline, static]
 

Definition at line 2840 of file emdata.h.

void EMData::ri2ap  ) 
 

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

Definition at line 990 of file emdata_transform.cpp.

References data, get_data(), is_complex(), is_ri(), nx, ny, set_ri(), and update().

Referenced by add_incoherent(), EMAN::OptVarianceCmp::cmp(), get_fft_amplitude(), 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::LowpassRandomPhaseProcessor::process_inplace(), render_amp24(), and render_ap24().

00991 {
00992         ENTERFUNC;
00993 
00994         if (!is_complex() || !is_ri()) {
00995                 return;
00996         }
00997 
00998         float * data = get_data();
00999 
01000         size_t size = (size_t)nx * ny * nz;
01001         for (size_t i = 0; i < size; i += 2) {
01002 #ifdef  _WIN32
01003                 float f = (float)_hypot(data[i], data[i + 1]);
01004 #else
01005                 float f = (float)hypot(data[i], data[i + 1]);
01006 #endif
01007                 if (data[i] == 0 && data[i + 1] == 0) {
01008                         data[i + 1] = 0;
01009                 }
01010                 else {
01011                         data[i + 1] = atan2(data[i + 1], data[i]);
01012                 }
01013                 data[i] = f;
01014         }
01015 
01016         set_ri(false);
01017         update();
01018         EXITFUNC;
01019 }

void EMData::ri2inten  ) 
 

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 970 of file emdata_transform.cpp.

References ap2ri(), data, get_data(), is_complex(), is_ri(), nx, ny, set_attr(), and update().

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

00971 {
00972         ENTERFUNC;
00973 
00974         if (!is_complex()) return;
00975         if (!is_ri()) ap2ri();
00976 
00977         float * data = get_data();
00978         size_t size = (size_t)nx * ny * nz;
00979         for (size_t i = 0; i < size; i += 2) {
00980                 data[i]=data[i]*data[i]+data[i+1]*data[i+1];
00981                 data[i+1]=0;
00982         }
00983 
00984         set_attr("is_intensity", int(1));
00985         update();
00986         EXITFUNC;
00987 }

EMData * EMData::rot_scale_conv float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale = 1.0
 

Rotate-Shift-Scale-Circulantly image using convolution.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] ang Rotation angle in degrees.
[in] delx Amount to shift rotation origin along x
[in] dely Amount to shift rotation origin along y
[in] kb convolution kernel
[in] scale Scaling factor (default=1.0)
Exceptions:
ImageDimensionException can not rotate 1 D image
ImageDimensionException can not rotate 3 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2947 of file emdata_sparx.cpp.

References nx, ny, nz, q, t, x, and y.

02996                                          {
02997                 float y = float(iy) - shiftyc;
02998                 float ycang = y*cang/scale + yc;
02999                 float ysang = -y*sang/scale + xc;
03000                 for (int ix = 0; ix < nxn; ix++) {
03001                         float x = float(ix) - shiftxc;
03002                         float xold = x*cang/scale + ysang-ixs;// have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
03003                         float yold = x*sang/scale + ycang-iys;
03004 
03005                         xold = restrict1(xold, nx);
03006                         yold = restrict1(yold, ny);
03007 
03008                         int inxold = int(Util::round(xold)); int inyold = int(Util::round(yold));
03009                         sum=0.0f;    w=0.0f;
03010                         for (int m1 =kbmin; m1 <=kbmax; m1++) t[m1-kbmin] = kb.i0win_tab(xold - inxold-m1);
03011                         if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03012                                 for (int m2 =kbmin; m2 <=kbmax; m2++) {
03013                                         float qt = kb.i0win_tab(yold - inyold-m2);
03014                                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03015                                                 float q = t[m1-kbmin]*qt;
03016                                                 sum += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q; w+=q;
03017                                         }
03018                                 }
03019                         } else {
03020                                 for (int m2 =kbmin; m2 <=kbmax; m2++) {
03021                                         float qt = kb.i0win_tab(yold - inyold-m2);
03022                                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03023                                                 float q = t[m1-kbmin]*qt;
03024                                                 sum += (*this)(inxold+m1,inyold+m2)*q; w+=q;}
03025                                         }
03026                         }
03027                         (*ret)(ix,iy)=sum/w;
03028                 }
03029         }
03030         if (t) free(t);
03031         set_array_offsets(saved_offsets);
03032         return ret;
03033 }
03034 
03035 // Notes by Yang on 10/02/07

EMData * EMData::rot_scale_conv7 float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale_input
 

Definition at line 3039 of file emdata_sparx.cpp.

References nx, ny, nz, t, x, and y.

Referenced by EMAN::Util::ccc_images_G(), and EMAN::Util::twoD_fine_ali_G().

03086                                          {
03087                 float y = float(iy) - shiftyc;
03088                 float ycang = y*cang/scale + yc;
03089                 float ysang = -y*sang/scale + xc;
03090                 for (int ix = 0; ix < nxn; ix++) {
03091                         float x = float(ix) - shiftxc;
03092                         float xold = x*cang/scale + ysang-ixs;// have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
03093                         float yold = x*sang/scale + ycang-iys;
03094 
03095                         xold = restrict1(xold, nx);
03096                         yold = restrict1(yold, ny);
03097 
03098                         int inxold = int(Util::round(xold)); int inyold = int(Util::round(yold));
03099                         sum=0.0f;    w=0.0f;
03100 
03101                         float tablex1 = kb.i0win_tab(xold-inxold+3);
03102                         float tablex2 = kb.i0win_tab(xold-inxold+2);
03103                         float tablex3 = kb.i0win_tab(xold-inxold+1);
03104                         float tablex4 = kb.i0win_tab(xold-inxold);
03105                         float tablex5 = kb.i0win_tab(xold-inxold-1);
03106                         float tablex6 = kb.i0win_tab(xold-inxold-2);
03107                         float tablex7 = kb.i0win_tab(xold-inxold-3);
03108 
03109                         float tabley1 = kb.i0win_tab(yold-inyold+3);
03110                         float tabley2 = kb.i0win_tab(yold-inyold+2);
03111                         float tabley3 = kb.i0win_tab(yold-inyold+1);
03112                         float tabley4 = kb.i0win_tab(yold-inyold);
03113                         float tabley5 = kb.i0win_tab(yold-inyold-1);
03114                         float tabley6 = kb.i0win_tab(yold-inyold-2);
03115                         float tabley7 = kb.i0win_tab(yold-inyold-3);
03116 
03117                         int x1, x2, x3, x4, x5, x6, x7, y1, y2, y3, y4, y5, y6, y7;
03118 
03119                         if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03120                                 x1 = (inxold-3+nx)%nx;
03121                                 x2 = (inxold-2+nx)%nx;
03122                                 x3 = (inxold-1+nx)%nx;
03123                                 x4 = (inxold  +nx)%nx;
03124                                 x5 = (inxold+1+nx)%nx;
03125                                 x6 = (inxold+2+nx)%nx;
03126                                 x7 = (inxold+3+nx)%nx;
03127 
03128                                 y1 = (inyold-3+ny)%ny;
03129                                 y2 = (inyold-2+ny)%ny;
03130                                 y3 = (inyold-1+ny)%ny;
03131                                 y4 = (inyold  +ny)%ny;
03132                                 y5 = (inyold+1+ny)%ny;
03133                                 y6 = (inyold+2+ny)%ny;
03134                                 y7 = (inyold+3+ny)%ny;
03135                         } else {
03136                                 x1 = inxold-3;
03137                                 x2 = inxold-2;
03138                                 x3 = inxold-1;
03139                                 x4 = inxold;
03140                                 x5 = inxold+1;
03141                                 x6 = inxold+2;
03142                                 x7 = inxold+3;
03143 
03144                                 y1 = inyold-3;
03145                                 y2 = inyold-2;
03146                                 y3 = inyold-1;
03147                                 y4 = inyold;
03148                                 y5 = inyold+1;
03149                                 y6 = inyold+2;
03150                                 y7 = inyold+3;
03151                         }
03152                         sum    =   ( (*this)(x1,y1)*tablex1 + (*this)(x2,y1)*tablex2 + (*this)(x3,y1)*tablex3 +
03153                                      (*this)(x4,y1)*tablex4 + (*this)(x5,y1)*tablex5 + (*this)(x6,y1)*tablex6 +
03154                                      (*this)(x7,y1)*tablex7 ) * tabley1 +
03155                                    ( (*this)(x1,y2)*tablex1 + (*this)(x2,y2)*tablex2 + (*this)(x3,y2)*tablex3 +
03156                                      (*this)(x4,y2)*tablex4 + (*this)(x5,y2)*tablex5 + (*this)(x6,y2)*tablex6 +
03157                                      (*this)(x7,y2)*tablex7 ) * tabley2 +
03158                                    ( (*this)(x1,y3)*tablex1 + (*this)(x2,y3)*tablex2 + (*this)(x3,y3)*tablex3 +
03159                                      (*this)(x4,y3)*tablex4 + (*this)(x5,y3)*tablex5 + (*this)(x6,y3)*tablex6 +
03160                                      (*this)(x7,y3)*tablex7 ) * tabley3 +
03161                                    ( (*this)(x1,y4)*tablex1 + (*this)(x2,y4)*tablex2 + (*this)(x3,y4)*tablex3 +
03162                                      (*this)(x4,y4)*tablex4 + (*this)(x5,y4)*tablex5 + (*this)(x6,y4)*tablex6 +
03163                                      (*this)(x7,y4)*tablex7 ) * tabley4 +
03164                                    ( (*this)(x1,y5)*tablex1 + (*this)(x2,y5)*tablex2 + (*this)(x3,y5)*tablex3 +
03165                                      (*this)(x4,y5)*tablex4 + (*this)(x5,y5)*tablex5 + (*this)(x6,y5)*tablex6 +
03166                                      (*this)(x7,y5)*tablex7 ) * tabley5 +
03167                                    ( (*this)(x1,y6)*tablex1 + (*this)(x2,y6)*tablex2 + (*this)(x3,y6)*tablex3 +
03168                                      (*this)(x4,y6)*tablex4 + (*this)(x5,y6)*tablex5 + (*this)(x6,y6)*tablex6 +
03169                                      (*this)(x7,y6)*tablex7 ) * tabley6 +
03170                                    ( (*this)(x1,y7)*tablex1 + (*this)(x2,y7)*tablex2 + (*this)(x3,y7)*tablex3 +
03171                                      (*this)(x4,y7)*tablex4 + (*this)(x5,y7)*tablex5 + (*this)(x6,y7)*tablex6 +
03172                                      (*this)(x7,y7)*tablex7 ) * tabley7;
03173 
03174                         w = (tablex1+tablex2+tablex3+tablex4+tablex5+tablex6+tablex7) *
03175                             (tabley1+tabley2+tabley3+tabley4+tabley5+tabley6+tabley7);
03176 
03177                         (*ret)(ix,iy)=sum/w;
03178                 }
03179         }
03180         if (t) free(t);
03181         set_array_offsets(saved_offsets);
03182         return ret;
03183 }
03184 
03185 EMData* EMData::downsample(Util::sincBlackman& kb, float scale) {

EMData * EMData::rot_scale_conv_new float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale = 1.0
 

Definition at line 3236 of file emdata_sparx.cpp.

References data, nx, ny, nz, x, and y.

03279                                          {
03280                 float y = float(iy) - shiftyc;
03281                 float ycang = y*cang/scale + yc;
03282                 float ysang = -y*sang/scale + xc;
03283                 for (int ix = 0; ix < nxn; ix++) {
03284                         float x = float(ix) - shiftxc;
03285                         float xold = x*cang/scale + ysang-ixs;// have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
03286                         float yold = x*sang/scale + ycang-iys;
03287 
03288                         (*ret)(ix,iy) = Util::get_pixel_conv_new(nx, ny, 1, xold, yold, 1, data, kb);
03289                 }
03290         }
03291         set_array_offsets(saved_offsets);
03292         return ret;
03293 }
03294 
03295 EMData* EMData::rot_scale_conv_new_3D(float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel& kb, float scale_input, bool wrap) {

EMData * EMData::rot_scale_conv_new_3D float  phi,
float  theta,
float  psi,
float  delx,
float  dely,
float  delz,
Util::KaiserBessel kb,
float  scale = 1.0,
bool  wrap = false
 

Definition at line 3297 of file emdata_sparx.cpp.

References nx, ny, and nz.

03313                 {
03314                 delx = restrict2(delx, nx);
03315                 dely = restrict2(dely, ny);
03316                 delz = restrict2(delz, nz);
03317         }
03318         // center of big image,
03319         int xc = nxn;
03320         int ixs = nxn%2;  // extra shift on account of odd-sized images
03321         int yc = nyn;
03322         int iys = nyn%2;
03323         int zc = nzn;
03324         int izs = nzn%2;
03325         // center of small image
03326         int xcn = nxn/2;
03327         int ycn = nyn/2;
03328         int zcn = nzn/2;
03329         // shifted center for rotation
03330         float shiftxc = xcn + delx;
03331         float shiftyc = ycn + dely;
03332         float shiftzc = zcn + delz;
03333         // bounds if origin at center
03334         float zmin = -nz/2.0f;
03335         float ymin = -ny/2.0f;
03336         float xmin = -nx/2.0f;
03337         float zmax = -zmin;
03338         float ymax = -ymin;
03339         float xmax = -xmin;
03340         if (0 == nx%2) xmax--;
03341         if (0 == ny%2) ymax--;
03342         if (0 == nz%2) zmax--;
03343 
03344         float* data = this->get_data();
03345 
03346         float cf = cos(phi);   float sf = sin(phi);
03347         float ct = cos(theta); float st = sin(theta);
03348         float cp = cos(psi);   float sp = sin(psi);
03349         // rotation matrix (the transpose is used in the loop to get (xold,yold,zold)):
03350         float a11 =  cp*ct*cf-sp*sf; float a12 =  cp*ct*sf+sp*cf; float a13 = -cp*st;
03351         float a21 = -sp*ct*cf-cp*sf; float a22 = -sp*ct*sf+cp*cf; float a23 =  sp*st;
03352         float a31 =  st*cf;          float a32 =  st*sf;          float a33 =  ct;
03353         for (int iz = 0; iz < nzn; iz++) {
03354                 float z = (float(iz) - shiftzc)/scale;
03355                 float zco1 = a31*z+xc;
03356                 float zco2 = a32*z+yc;
03357                 float zco3 = a33*z+zc;
03358                 for (int iy = 0; iy < nyn; iy++) {
03359                         float y = (float(iy) - shiftyc)/scale;
03360                         float yco1 = zco1+a21*y;
03361                         float yco2 = zco2+a22*y;
03362                         float yco3 = zco3+a23*y;
03363                         for (int ix = 0; ix < nxn; ix++) {
03364                                 float x = (float(ix) - shiftxc)/scale;
03365                                 float xold = yco1+a11*x-ixs; //have to add the fraction on account of odd-sized images for which Fourier zero-padding changes the center location
03366                                 float yold = yco2+a12*x-iys;
03367                                 float zold = yco3+a13*x-izs;
03368                                 if(!wrap && (xold<0.0 || xold>nx-1 || yold<0.0 || yold>ny-1 || zold<0.0 || zold>nz-1))
03369                                         (*ret)(ix,iy,iz) = 0.0;
03370                                 else
03371                                         (*ret)(ix,iy,iz) = Util::get_pixel_conv_new(nx, ny, nz, xold, yold, zold, data, kb);
03372                         }
03373                 }
03374         }
03375         set_array_offsets(saved_offsets);
03376         return ret;
03377 }
03378 
03379 EMData* EMData::rot_scale_conv_new_background(float ang, float delx, float dely, Util::KaiserBessel& kb, float scale_input) {

EMData * EMData::rot_scale_conv_new_background float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale = 1.0
 

Definition at line 3381 of file emdata_sparx.cpp.

References data, nx, ny, nz, x, and y.

03427                                          {
03428                 float y = float(iy) - shiftyc;
03429                 float ycang = y*cang/scale + yc;
03430                 float ysang = -y*sang/scale + xc;
03431                 for (int ix = 0; ix < nxn; ix++) {
03432                         float x = float(ix) - shiftxc;
03433                         float xold = x*cang/scale + ysang-ixs;// have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
03434                         float yold = x*sang/scale + ycang-iys;
03435 
03436                         (*ret)(ix,iy) = Util::get_pixel_conv_new_background(nx, ny, 1, xold, yold, 1, data, kb, ix, iy);
03437                 }
03438         }
03439         set_array_offsets(saved_offsets);
03440         return ret;
03441 }
03442 
03443 EMData* EMData::rot_scale_conv_new_background_3D(float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel& kb, float scale_input, bool wrap) {

EMData * EMData::rot_scale_conv_new_background_3D float  phi,
float  theta,
float  psi,
float  delx,
float  dely,
float  delz,
Util::KaiserBessel kb,
float  scale = 1.0,
bool  wrap = false
 

Definition at line 3445 of file emdata_sparx.cpp.

References nx, ny, and nz.

03461                  {
03462                 delx = restrict2(delx, nx);
03463                 dely = restrict2(dely, ny);
03464                 delz = restrict2(delz, nz);
03465         }
03466         // center of big image,
03467         int xc = nxn;
03468         int ixs = nxn%2;  // extra shift on account of odd-sized images
03469         int yc = nyn;
03470         int iys = nyn%2;
03471         int zc = nzn;
03472         int izs = nzn%2;
03473         // center of small image
03474         int xcn = nxn/2;
03475         int ycn = nyn/2;
03476         int zcn = nzn/2;
03477         // shifted center for rotation
03478         float shiftxc = xcn + delx;
03479         float shiftyc = ycn + dely;
03480         float shiftzc = zcn + delz;
03481         // bounds if origin at center
03482         float zmin = -nz/2.0f;
03483         float ymin = -ny/2.0f;
03484         float xmin = -nx/2.0f;
03485         float zmax = -zmin;
03486         float ymax = -ymin;
03487         float xmax = -xmin;
03488         if (0 == nx%2) xmax--;
03489         if (0 == ny%2) ymax--;
03490         if (0 == nz%2) zmax--;
03491 
03492         float* data = this->get_data();
03493 
03494         float cf = cos(phi);   float sf = sin(phi);
03495         float ct = cos(theta); float st = sin(theta);
03496         float cp = cos(psi);   float sp = sin(psi);
03497         // rotation matrix (the transpose is used in the loop to get (xold,yold,zold)):
03498         float a11 =  cp*ct*cf-sp*sf; float a12 =  cp*ct*sf+sp*cf; float a13 = -cp*st;
03499         float a21 = -sp*ct*cf-cp*sf; float a22 = -sp*ct*sf+cp*cf; float a23 =  sp*st;
03500         float a31 =  st*cf;          float a32 =  st*sf;          float a33 =  ct;
03501         for (int iz = 0; iz < nzn; iz++) {
03502                 float z = (float(iz) - shiftzc)/scale;
03503                 float zco1 = a31*z+xc;
03504                 float zco2 = a32*z+yc;
03505                 float zco3 = a33*z+zc;
03506                 for (int iy = 0; iy < nyn; iy++) {
03507                         float y = (float(iy) - shiftyc)/scale;
03508                         float yco1 = zco1+a21*y;
03509                         float yco2 = zco2+a22*y;
03510                         float yco3 = zco3+a23*y;
03511                         for (int ix = 0; ix < nxn; ix++) {
03512                                 float x = (float(ix) - shiftxc)/scale;
03513                                 float xold = yco1+a11*x-ixs; //have to add the fraction on account on odd-sized images for which Fourier zero-padding changes the center location
03514                                 float yold = yco2+a12*x-iys;
03515                                 float zold = yco3+a13*x-izs;
03516                                 if(!wrap && (xold<0.0 || xold>nx-1 || yold<0.0 || yold>ny-1 || zold<0.0 || zold>nz-1))
03517                                         (*ret)(ix,iy,iz) = 0.0;
03518                                 else
03519                                         (*ret)(ix,iy,iz) = Util::get_pixel_conv_new_background(nx, ny, nz, xold, yold, zold, data, kb, ix, iy);
03520                         }
03521                 }
03522         }
03523         set_array_offsets(saved_offsets);
03524         return ret;
03525 }
03526 
03527 

EMData * EMData::rot_scale_trans const Transform RA  ) 
 

Rotate-Shift-Scale-Circulantly image.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] RA Transform object
Exceptions:
ImageDimensionException can not rotate 1 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2442 of file emdata_sparx.cpp.

References in, nx, nx, ny, ny, nz, t, EMAN::Vec3f, x, and y.

Referenced by symvol().

02451                     {
02452         float  p1, p2, p3, p4;
02453         float delx = translations.at(0);
02454         float dely = translations.at(1);
02455         delx = restrict2(delx, nx);
02456         dely = restrict2(dely, ny);
02457         int xc = nx/2;
02458         int yc = ny/2;
02459 //         shifted center for rotation
02460         float shiftxc = xc + delx;
02461         float shiftyc = yc + dely;
02462                 for (int iy = 0; iy < ny; iy++) {
02463                         float y = float(iy) - shiftyc;
02464                         float ysang = y*RAinv[0][1]+xc;
02465                         float ycang = y*RAinv[1][1]+yc;
02466                         for (int ix = 0; ix < nx; ix++) {
02467                                 float x = float(ix) - shiftxc;
02468                                 float xold = x*RAinv[0][0] + ysang;
02469                                 float yold = x*RAinv[1][0] + ycang;
02470 
02471                                 xold = restrict1(xold, nx);
02472                                 yold = restrict1(yold, ny);
02473 
02474                                 int xfloor = int(xold);
02475                                 int yfloor = int(yold);
02476                                 float t = xold-xfloor;
02477                                 float u = yold-yfloor;
02478                                 if(xfloor == nx -1 && yfloor == ny -1) {
02479 
02480                                     p1 =in[xfloor   + yfloor*ny];
02481                                         p2 =in[ yfloor*ny];
02482                                         p3 =in[0];
02483                                         p4 =in[xfloor];
02484                                 } else if(xfloor == nx - 1) {
02485 
02486                                         p1 =in[xfloor   + yfloor*ny];
02487                                         p2 =in[           yfloor*ny];
02488                                         p3 =in[          (yfloor+1)*ny];
02489                                         p4 =in[xfloor   + (yfloor+1)*ny];
02490                                 } else if(yfloor == ny - 1) {
02491 
02492                                         p1 =in[xfloor   + yfloor*ny];
02493                                         p2 =in[xfloor+1 + yfloor*ny];
02494                                         p3 =in[xfloor+1 ];
02495                                         p4 =in[xfloor   ];
02496                                 } else {
02497                                         p1 =in[xfloor   + yfloor*ny];
02498                                         p2 =in[xfloor+1 + yfloor*ny];
02499                                         p3 =in[xfloor+1 + (yfloor+1)*ny];
02500                                         p4 =in[xfloor   + (yfloor+1)*ny];
02501                                 }
02502                                 (*ret)(ix,iy) = p1 + u * ( p4 - p1) + t * ( p2 - p1 + u *(p3-p2-p4+p1));
02503                         } //ends x loop
02504                 } // ends y loop
02505                 set_array_offsets(saved_offsets);
02506                 return ret;
02507         } else {
02508 //               This begins the 3D version trilinear interpolation.
02509 
02510         float delx = translations.at(0);
02511         float dely = translations.at(1);
02512         float delz = translations.at(2);
02513         delx = restrict2(delx, nx);
02514         dely = restrict2(dely, ny);
02515         delz = restrict2(delz, nz);
02516         int xc = nx/2;
02517         int yc = ny/2;
02518         int zc = nz/2;
02519 //         shifted center for rotation
02520         float shiftxc = xc + delx;
02521         float shiftyc = yc + dely;
02522         float shiftzc = zc + delz;
02523 
02524                 for (int iz = 0; iz < nz; iz++) {
02525                         float z = float(iz) - shiftzc;
02526                         float xoldz = z*RAinv[0][2]+xc;
02527                         float yoldz = z*RAinv[1][2]+yc;
02528                         float zoldz = z*RAinv[2][2]+zc;
02529                         for (int iy = 0; iy < ny; iy++) {
02530                                 float y = float(iy) - shiftyc;
02531                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02532                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02533                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02534                                 for (int ix = 0; ix < nx; ix++) {
02535                                         float x = float(ix) - shiftxc;
02536                                         float xold = xoldzy + x*RAinv[0][0] ;
02537                                         float yold = yoldzy + x*RAinv[1][0] ;
02538                                         float zold = zoldzy + x*RAinv[2][0] ;
02539 
02540                                         xold = restrict1(xold, nx);
02541                                         yold = restrict1(yold, ny);
02542                                         zold = restrict1(zold, nz);
02543 
02544 
02545                                         int IOX = int(xold);
02546                                         int IOY = int(yold);
02547                                         int IOZ = int(zold);
02548 
02549                                         #ifdef _WIN32
02550                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
02551                                         #else
02552                                         int IOXp1 = std::min( nx-1 ,IOX+1);
02553                                         #endif  //_WIN32
02554 
02555                                         #ifdef _WIN32
02556                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
02557                                         #else
02558                                         int IOYp1 = std::min( ny-1 ,IOY+1);
02559                                         #endif  //_WIN32
02560 
02561                                         #ifdef _WIN32
02562                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
02563                                         #else
02564                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
02565                                         #endif  //_WIN32
02566 
02567                                         float dx = xold-IOX;
02568                                         float dy = yold-IOY;
02569                                         float dz = zold-IOZ;
02570 
02571                                         float a1 = in(IOX,IOY,IOZ);
02572                                         float a2 = in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZ);
02573                                         float a3 = in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZ);
02574                                         float a4 = in(IOX,IOY,IOZp1) - in(IOX,IOY,IOZ);
02575                                         float a5 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOYp1,IOZ) + in(IOXp1,IOYp1,IOZ);
02576                                         float a6 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZp1) + in(IOXp1,IOY,IOZp1);
02577                                         float a7 = in(IOX,IOY,IOZ) - in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZp1) + in(IOX,IOYp1,IOZp1);
02578                                         float a8 = in(IOXp1,IOY,IOZ) + in(IOX,IOYp1,IOZ)+ in(IOX,IOY,IOZp1)
02579                                                         - in(IOX,IOY,IOZ)- in(IOXp1,IOYp1,IOZ) - in(IOXp1,IOY,IOZp1)
02580                                                         - in(IOX,IOYp1,IOZp1) + in(IOXp1,IOYp1,IOZp1);
02581                                         (*ret)(ix,iy,iz) = a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
02582                                 } //ends x loop
02583                         } // ends y loop
02584                 } // ends z loop
02585 
02586                 set_array_offsets(saved_offsets);
02587                 return ret;
02588 
02589 /*     This entire section has to go somewhere for quadratic 3D interpolation PAP 12/29/07
02590 //               This begins the 3D version triquadratic interpolation.
02591 
02592         float delx = translations.at(0);
02593         float dely = translations.at(1);
02594         float delz = translations.at(2);
02595         if(delx >= 0.0f) { delx = fmod(delx, float(nx));} else {delx = -fmod(-delx, float(nx));}
02596         if(dely >= 0.0f) { dely = fmod(dely, float(ny));} else {dely = -fmod(-dely, float(ny));}
02597         if(dely >= 0.0f) { delz = fmod(delz, float(nz));} else {delz = -fmod(-delz, float(nz));}
02598         int xc = nx/2;
02599         int yc = ny/2;
02600         int zc = nz/2;
02601 //         shifted center for rotation
02602         float shiftxc = xc + delx;
02603         float shiftyc = yc + dely;
02604         float shiftzc = zc + delz;
02605 //                  set up array to use later
02606 //
02607                 int xArr[27];
02608                 int yArr[27];
02609                 int zArr[27];
02610                 float fdata[27];
02611 
02612                 for (int iL=0; iL<27 ; iL++){  // need this indexing array later
02613                         xArr[iL]  =  (int) (fmod((float)iL,3.0f) - 1.0f);
02614                         yArr[iL]  =  (int)( fmod( ((float) (iL/3) ),3.0f)- 1.0f);
02615                         zArr[iL]  = ((int) (iL/9)  ) -1;
02616 //                      printf("iL=%d, \t xArr=%d, \t yArr=%d, \t zArr=%d \n",iL, xArr[iL],yArr[iL],zArr[iL]);
02617                 }
02618 
02619 //              for (int iz = 0; iz < nz; iz++) {for (int iy = 0; iy < ny; iy++) {for (int ix = 0; ix < nx; ix++) {
02620 //                    (*ret)(ix,iy,iz) = 0;}}}   // initialize returned data
02621 
02622                 for (int iz = 0; iz < nz; iz++) {
02623                         float z = float(iz) - shiftzc;
02624                         float xoldz = z*RAinv[0][2]+xc;
02625                         float yoldz = z*RAinv[1][2]+yc;
02626                         float zoldz = z*RAinv[2][2]+zc;
02627                         for (int iy = 0; iy < ny; iy++) {
02628                                 float y = float(iy) - shiftyc;
02629                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02630                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02631                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02632                                 for (int ix = 0; ix < nx; ix++) {
02633                                         float x = float(ix) - shiftxc;
02634                                         float xold = xoldzy + x*RAinv[0][0] ;
02635                                         float yold = yoldzy + x*RAinv[1][0] ;
02636                                         float zold = zoldzy + x*RAinv[2][0] ;
02637 
02638 
02639                                 if (xold < 0.0f) xold = fmod((int(xold/float(nx))+1)*nx-xold, float(nx));
02640                                 else if (xold > (float) (nx-1) ) xold = fmod(xold, float(nx));
02641                                 if (yold < 0.0f) yold =fmod((int(yold/float(ny))+1)*ny-yold, float(ny));
02642                                 else if (yold > (float) (ny-1) ) yold = fmod(yold, float(ny));
02643                                 if (zold < 0.0f) zold =fmod((int(zold/float(nz))+1)*nz-zold, float(nz));
02644                                 else if (zold > (float) (nz-1) ) zold = fmod(zold, float(nz));
02645 
02646                                 //  what follows does not accelerate the code; moreover, I doubt it is correct PAP 12/29/07
02647                                 //while ( xold >= (float)(nx) )  xold -= nx;
02648                                 //while ( xold < 0.0f )         xold += nx;
02649                                 //while ( yold >= (float)(ny) )  yold -= ny;
02650                                 //while ( yold < 0.0f )         yold += ny;
02651                                 //while ( zold >= (float)(nz) )  zold -= nz;
02652                                 //while ( zold < 0.0f )         zold += nz;
02653 
02654 //         This is currently coded the way  SPIDER coded it,
02655 //            changing floor to round  in the next 3 lines below may be better
02656 //                                      int IOX = (int) floor(xold); // This is the center of the array
02657 //                                      int IOY = (int) floor(yold ); // In the next loop we interpolate
02658 //                                      int IOZ = (int) floor(zold ); //  If floor is used dx is positive
02659                                         int IOX = int(xold);
02660                                         int IOY = int(yold);
02661                                         int IOZ = int(zold);
02662 
02663                                         float dx = xold-IOX; //remainder(xold,1);  //  now |dx| <= .5
02664                                         float dy = yold-IOY; //remainder(yold,1);
02665                                         float dz = zold-IOZ; //remainder(zold,1);
02666 
02667 //                                      printf(" IOX=%d \t IOY=%d \t IOZ=%d \n", IOX, IOY, IOZ);
02668 //                                      if (IOX>=0 && IOX<nx  && IOY>=0 && IOY < ny && IOZ >= 0 && IOZ < nz ) {
02669 //                                              ROTATED POSITION IS INSIDE OF VOLUME
02670 //                                              FIND INTENSITIES ON 3x3x3 COORDINATE GRID;
02671 //                                     Solution is wrapped
02672                                                 for  (int iL=0; iL<27 ; iL++){
02673                                                         int xCoor = (int) fmod(IOX+xArr[iL] + nx + .0001f, (float) nx);
02674                                                         int yCoor = (int) fmod(IOY+yArr[iL] + ny + .0001f, (float) ny);
02675                                                         int zCoor = (int) fmod(IOZ+zArr[iL] + nz + .0001f, (float) nz);
02676                                                         fdata[iL] = (*this)( xCoor, yCoor ,zCoor );
02677 //                                                      if (iy==iz && iz==0){printf(" fdata=%f \n", fdata[iL]);}
02678 //                                              }
02679                                         }
02680 
02681                                         (*ret)(ix,iy,iz) = Util::triquad(dx, dy, dz, fdata);
02682 //                                      (*ret)(ix,iy,iz) = Util:: trilinear_interpolate(fdata[13],fdata[14],fdata[16],
02683 //                                                                                      fdata[17],fdata[22],fdata[23],
02684 //                                                                                      fdata[25],fdata[26],dx, dy, dz);
02685 //      p1 iL=13,   xArr= 0,         yArr= 0,         zArr= 0
02686 //      p2 iL=14,   xArr= 1,         yArr= 0,         zArr= 0
02687 //      p3 iL=16,   xArr= 0,         yArr= 1,         zArr= 0
02688 //      p4 iL=17,   xArr= 1,         yArr= 1,         zArr= 0
02689 //      p5 iL=22,   xArr= 0,         yArr= 0,         zArr= 1
02690 //      p6 iL=23,   xArr= 1,         yArr= 0,         zArr= 1
02691 //      p7 iL=25,   xArr= 0,         yArr= 1,         zArr= 1
02692 //      p8 iL=26,   xArr= 1,         yArr= 1,         zArr= 1
02693 
02694 
02695 
02696                                 } //ends x loop
02697                         } // ends y loop
02698                 } // ends z loop
02699 
02700                 set_array_offsets(saved_offsets);
02701                 return ret;
02702 */
02703         }
02704 }
02705 #undef  in
02706 

EMData * EMData::rot_scale_trans2D float  ang,
float  delx = 0.0f,
float  dely = 0.0f,
float  scale = 1.0f
 

Rotate-Shift-Scale-Circulantly image.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] ang Rotation angle in degrees.
[in] delx Amount to shift rotation origin along x
[in] dely Amount to shift rotation origin along y
[in] scale Scaling factor (default=1.0)
Exceptions:
ImageDimensionException can not rotate 1 D image
ImageDimensionException can not rotate 3 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2360 of file emdata_sparx.cpp.

References nx, ny, nz, x, and y.

Referenced by EMAN::Util::ccc_images(), main(), and EMAN::Util::twoD_fine_ali().

02363                   {
02364                 vector<int> saved_offsets = get_array_offsets();
02365                 set_array_offsets(0,0,0);
02366                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02367                 EMData* ret = copy_head();
02368                 delx = restrict2(delx, nx);
02369                 dely = restrict2(dely, ny);
02370                 // center of image
02371                 int xc = nx/2;
02372                 int yc = ny/2;
02373                 // shifted center for rotation
02374                 float shiftxc = xc + delx;
02375                 float shiftyc = yc + dely;
02376                 // trig
02377                 float cang = cos(ang);
02378                 float sang = sin(ang);
02379                         for (int iy = 0; iy < ny; iy++) {
02380                                 float y = float(iy) - shiftyc;
02381                                 float ycang = y*cang/scale + yc;
02382                                 float ysang = -y*sang/scale + xc;
02383                                 for (int ix = 0; ix < nx; ix++) {
02384                                         float x = float(ix) - shiftxc;
02385                                         float xold = x*cang/scale + ysang ;
02386                                         float yold = x*sang/scale + ycang ;
02387                                         //  quadri is taking care of cyclic count
02388                                         (*ret)(ix,iy) = Util::quadri(xold+1.0f, yold+1.0f, nx, ny, get_data());
02389                                            //have to add one as quadri uses Fortran counting
02390                                 }
02391                         }
02392                 set_array_offsets(saved_offsets);
02393                 return ret;
02394         } else {
02395                 throw ImageDimensionException("Volume not currently supported");
02396         }
02397 }
02398 

EMData * EMData::rot_scale_trans2D_background float  ang,
float  delx = 0.0f,
float  dely = 0.0f,
float  scale = 1.0f
 

Rotate-Shift-Scale image.

In contrast to rot_scale_trans2D, wrap aroud is not done circulantly so as to prevent artifacts from occurring.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] ang Rotation angle in degrees.
[in] delx Amount to shift rotation origin along x (default=0.0)
[in] dely Amount to shift rotation origin along y (default=0.0)
[in] scale Scaling factor (default=1.0)
Exceptions:
ImageDimensionException can not rotate 1 D image
ImageDimensionException can not rotate 3 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2400 of file emdata_sparx.cpp.

References nx, ny, nz, x, and y.

02403                   {
02404                 vector<int> saved_offsets = get_array_offsets();
02405                 set_array_offsets(0,0,0);
02406                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02407                 EMData* ret = copy_head();
02408                 delx = restrict2(delx, nx);
02409                 dely = restrict2(dely, ny);
02410                 // center of image
02411                 int xc = nx/2;
02412                 int yc = ny/2;
02413                 // shifted center for rotation
02414                 float shiftxc = xc + delx;
02415                 float shiftyc = yc + dely;
02416                 // trig
02417                 float cang = cos(ang);
02418                 float sang = sin(ang);
02419                         for (int iy = 0; iy < ny; iy++) {
02420                                 float y = float(iy) - shiftyc;
02421                                 float ycang = y*cang/scale + yc;
02422                                 float ysang = -y*sang/scale + xc;
02423                                 for (int ix = 0; ix < nx; ix++) {
02424                                         float x = float(ix) - shiftxc;
02425                                         float xold = x*cang/scale + ysang ;
02426                                         float yold = x*sang/scale + ycang ;
02427                                         //  in quadri_background, wrap around is not done circulantly; if (xold,yold) is not in the image, then it's replaced by (ix,iy)
02428                                         (*ret)(ix,iy) = Util::quadri_background(xold+1.0f, yold+1.0f, nx, ny, get_data(),ix+1,iy+1);
02429                                            //have to add one as quadri uses Fortran counting
02430                                 }
02431                         }
02432                 set_array_offsets(saved_offsets);
02433                 return ret;
02434         } else {
02435                 throw ImageDimensionException("Volume not currently supported");
02436         }
02437 }
02438 

EMData * EMData::rot_scale_trans_background const Transform RA  ) 
 

Rotate-Shift-Scale image.

In contrast to rot_scale_trans, wrap around is not done circulantly so as to prevent artifacts occurring during rotation.

If the image is a volume, then all slices are rotated/translated/scaled.

Parameters:
[in] RA Transform object
Exceptions:
ImageDimensionException can not rotate 1 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2712 of file emdata_sparx.cpp.

References in, nx, ny, nz, EMAN::Vec3f, x, and y.

02719                     {
02720         float  p1, p2, p3, p4;
02721         float delx = translations.at(0);
02722         float dely = translations.at(1);
02723         delx = restrict2(delx, nx);
02724         dely = restrict2(dely, ny);
02725         int xc = nx/2;
02726         int yc = ny/2;
02727 //         shifted center for rotation
02728         float shiftxc = xc + delx;
02729         float shiftyc = yc + dely;
02730                 for (int iy = 0; iy < ny; iy++) {
02731                         float y = float(iy) - shiftyc;
02732                         float ysang = y*RAinv[0][1]+xc;
02733                         float ycang = y*RAinv[1][1]+yc;
02734                         for (int ix = 0; ix < nx; ix++) {
02735                                 float x = float(ix) - shiftxc;
02736                                 float xold = x*RAinv[0][0] + ysang;
02737                                 float yold = x*RAinv[1][0] + ycang;
02738 
02739                                 // if (xold,yold) is outside the image, then let xold = ix and yold = iy
02740 
02741                 if ( (xold < 0.0f) || (xold >= (float)(nx)) || (yold < 0.0f) || (yold >= (float)(ny)) ){
02742                                     xold = (float)ix;
02743                                         yold = (float)iy;
02744                                 }
02745 
02746                                 int xfloor = int(xold);
02747                                 int yfloor = int(yold);
02748                                 float t = xold-xfloor;
02749                                 float u = yold-yfloor;
02750                                 if(xfloor == nx -1 && yfloor == ny -1) {
02751 
02752                                     p1 =in[xfloor   + yfloor*ny];
02753                                         p2 =in[ yfloor*ny];
02754                                         p3 =in[0];
02755                                         p4 =in[xfloor];
02756                                 } else if(xfloor == nx - 1) {
02757 
02758                                         p1 =in[xfloor   + yfloor*ny];
02759                                         p2 =in[           yfloor*ny];
02760                                         p3 =in[          (yfloor+1)*ny];
02761                                         p4 =in[xfloor   + (yfloor+1)*ny];
02762                                 } else if(yfloor == ny - 1) {
02763 
02764                                         p1 =in[xfloor   + yfloor*ny];
02765                                         p2 =in[xfloor+1 + yfloor*ny];
02766                                         p3 =in[xfloor+1 ];
02767                                         p4 =in[xfloor   ];
02768                                 } else {
02769 
02770                                         p1 =in[xfloor   + yfloor*ny];
02771                                         p2 =in[xfloor+1 + yfloor*ny];
02772                                         p3 =in[xfloor+1 + (yfloor+1)*ny];
02773                                         p4 =in[xfloor   + (yfloor+1)*ny];
02774                                 }
02775                                 (*ret)(ix,iy) = p1 + u * ( p4 - p1) + t * ( p2 - p1 + u *(p3-p2-p4+p1));
02776                         } //ends x loop
02777                 } // ends y loop
02778                 set_array_offsets(saved_offsets);
02779                 return ret;
02780         } else {
02781 //               This begins the 3D version trilinear interpolation.
02782 
02783         float delx = translations.at(0);
02784         float dely = translations.at(1);
02785         float delz = translations.at(2);
02786         delx = restrict2(delx, nx);
02787         dely = restrict2(dely, ny);
02788         delz = restrict2(delz, nz);
02789         int xc = nx/2;
02790         int yc = ny/2;
02791         int zc = nz/2;
02792 //         shifted center for rotation
02793         float shiftxc = xc + delx;
02794         float shiftyc = yc + dely;
02795         float shiftzc = zc + delz;
02796 
02797                 for (int iz = 0; iz < nz; iz++) {
02798                         float z = float(iz) - shiftzc;
02799                         float xoldz = z*RAinv[0][2]+xc;
02800                         float yoldz = z*RAinv[1][2]+yc;
02801                         float zoldz = z*RAinv[2][2]+zc;
02802                         for (int iy = 0; iy < ny; iy++) {
02803                                 float y = float(iy) - shiftyc;
02804                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02805                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02806                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02807                                 for (int ix = 0; ix < nx; ix++) {
02808                                         float x = float(ix) - shiftxc;
02809                                         float xold = xoldzy + x*RAinv[0][0] ;
02810                                         float yold = yoldzy + x*RAinv[1][0] ;
02811                                         float zold = zoldzy + x*RAinv[2][0] ;
02812 
02813                                         // if (xold,yold,zold) is outside the image, then let xold = ix, yold = iy and zold=iz
02814 
02815                     if ( (xold < 0.0f) || (xold >= (float)(nx)) || (yold < 0.0f) || (yold >= (float)(ny))  || (zold < 0.0f) || (zold >= (float)(nz)) ){
02816                                          xold = (float)ix;
02817                                              yold = (float)iy;
02818                                                  zold = (float)iz;
02819                                         }
02820 
02821                                         int IOX = int(xold);
02822                                         int IOY = int(yold);
02823                                         int IOZ = int(zold);
02824 
02825                                         #ifdef _WIN32
02826                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
02827                                         #else
02828                                         int IOXp1 = std::min( nx-1 ,IOX+1);
02829                                         #endif  //_WIN32
02830 
02831                                         #ifdef _WIN32
02832                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
02833                                         #else
02834                                         int IOYp1 = std::min( ny-1 ,IOY+1);
02835                                         #endif  //_WIN32
02836 
02837                                         #ifdef _WIN32
02838                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
02839                                         #else
02840                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
02841                                         #endif  //_WIN32
02842 
02843                                         float dx = xold-IOX;
02844                                         float dy = yold-IOY;
02845                                         float dz = zold-IOZ;
02846 
02847                                         float a1 = in(IOX,IOY,IOZ);
02848                                         float a2 = in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZ);
02849                                         float a3 = in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZ);
02850                                         float a4 = in(IOX,IOY,IOZp1) - in(IOX,IOY,IOZ);
02851                                         float a5 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOYp1,IOZ) + in(IOXp1,IOYp1,IOZ);
02852                                         float a6 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZp1) + in(IOXp1,IOY,IOZp1);
02853                                         float a7 = in(IOX,IOY,IOZ) - in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZp1) + in(IOX,IOYp1,IOZp1);
02854                                         float a8 = in(IOXp1,IOY,IOZ) + in(IOX,IOYp1,IOZ)+ in(IOX,IOY,IOZp1)
02855                                                         - in(IOX,IOY,IOZ)- in(IOXp1,IOYp1,IOZ) - in(IOXp1,IOY,IOZp1)
02856                                                         - in(IOX,IOYp1,IOZp1) + in(IOXp1,IOYp1,IOZp1);
02857                                         (*ret)(ix,iy,iz) = a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
02858                                 } //ends x loop
02859                         } // ends y loop
02860                 } // ends z loop
02861 
02862                 set_array_offsets(saved_offsets);
02863                 return ret;
02864 
02865         }
02866 }
02867 #undef  in
02868 

void EMData::rotate float  az,
float  alt,
float  phi
 

Rotate this image.

DEPRECATED USE EMData::Transform

Parameters:
az Rotation euler angle az in EMAN convention.
alt Rotation euler angle alt in EMAN convention.
phi Rotation euler angle phi in EMAN convention.

Definition at line 927 of file emdata.cpp.

References t, and transform().

00928 {
00929         Dict d("type","eman");
00930         d["az"] = az;
00931         d["alt"] = alt;
00932         d["phi"] = phi;
00933         Transform t(d);
00934         transform(t);
00935 }

void EMData::rotate const Transform t  ) 
 

Rotate this image.

DEPRECATED USE EMData::transform()

Parameters:
t Transformation rotation.

Definition at line 939 of file emdata.cpp.

References t, and transform().

Referenced by frm_2d_Align(), and main().

00940 {
00941         cout << "Deprecation warning in EMData::rotate. Please consider using EMData::transform() instead " << endl;
00942         transform(t);
00943 }

void EMAN::EMData::rotate_180  )  [inline]
 

Fast rotation by 180 degrees.

Square 2D image only.

Exceptions:
ImageFormatException If the image is not square.
ImageDimensionException If the image is not 2D.

Definition at line 3441 of file emdata.h.

void EMData::rotate_translate float  az,
float  alt,
float  phi,
float  dx,
float  dy,
float  dz,
float  pdx,
float  pdy,
float  pdz
 

Rotate then translate the image.

DEPRECATED USE EMData::Transform

Parameters:
az Rotation euler angle az in EMAN convention.
alt Rotation euler angle alt in EMAN convention.
phi Rotation euler angle phi in EMAN convention.
dx Translation distance in x direction.
dy Translation distance in y direction.
dz Translation distance in z direction.
pdx Pretranslation distance in x direction.
pdy Pretranslation distance in y direction.
pdz Pretranslation distance in z direction.

Definition at line 976 of file emdata.cpp.

References phi, rotate_translate(), EMAN::Transform::set_pre_trans(), EMAN::Transform::set_rotation(), EMAN::Transform::set_trans(), t, and EMAN::Vec3f.

00978 {
00979         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00980 //      Transform3D t(Vec3f(dx, dy, dz), az, alt, phi, Vec3f(pdx,pdy,pdz));
00981 //      rotate_translate(t);
00982 
00983         Transform t;
00984         t.set_pre_trans(Vec3f(dx, dy, dz));
00985         t.set_rotation(Dict("type", "eman", "az", az, "alt", alt, "phi", phi));
00986         t.set_trans(pdx, pdy, pdz);
00987         rotate_translate(t);
00988 }

void EMData::rotate_translate float  az,
float  alt,
float  phi,
float  dx,
float  dy,
float  dz
 

Rotate then translate the image.

DEPRECATED USE EMData::Transform

Parameters:
az Rotation euler angle az in EMAN convention.
alt Rotation euler angle alt in EMAN convention.
phi Rotation euler angle phi in EMAN convention.
dx Translation distance in x direction.
dy Translation distance in y direction.
dz Translation distance in z direction.

Definition at line 965 of file emdata.cpp.

References phi, rotate_translate(), EMAN::Transform::set_rotation(), EMAN::Transform::set_trans(), and t.

00966 {
00967         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00968 //      Transform3D t( az, alt, phi,Vec3f(dx, dy, dz));
00969         Transform t;
00970         t.set_rotation(Dict("type", "eman", "az", az, "alt", alt, "phi", phi));
00971         t.set_trans(dx, dy, dz);
00972         rotate_translate(t);
00973 }

void EMAN::EMData::rotate_translate const Transform t  )  [inline]
 

Apply a transformation to the image.

DEPRECATED USE EMData::Transform

Parameters:
t transform object that describes the transformation to be applied to the image.

Definition at line 3397 of file emdata.h.

Referenced by main(), and rotate_translate().

void EMData::rotate_x int  dx  ) 
 

This performs a translation of each line along x with wraparound.

This is equivalent to a rotation when performed on 'unwrapped' maps.

Parameters:
dx Translation distance align x direction.
Exceptions:
ImageDimensionException If the image is 3D.

Definition at line 1179 of file emdata.cpp.

References data, get_data(), get_ndim(), ImageDimensionException, nx, update(), x, and y.

Referenced by EMAN::RTFExhaustiveAligner::align().

01180 {
01181         ENTERFUNC;
01182 
01183         if (get_ndim() > 2) {
01184                 throw ImageDimensionException("no 3D image");
01185         }
01186 
01187 
01188         size_t row_size = nx * sizeof(float);
01189         float *tmp = (float*)EMUtil::em_malloc(row_size);
01190         float * data = get_data();
01191 
01192         for (int y = 0; y < ny; y++) {
01193                 int y_nx = y * nx;
01194                 for (int x = 0; x < nx; x++) {
01195                         tmp[x] = data[y_nx + (x + dx) % nx];
01196                 }
01197                 EMUtil::em_memcpy(&data[y_nx], tmp, row_size);
01198         }
01199 
01200         update();
01201         if( tmp )
01202         {
01203                 delete[]tmp;
01204                 tmp = 0;
01205         }
01206         EXITFUNC;
01207 }

EMData * EMData::rotavg  ) 
 

Create a (1-D) rotationally averaged image.

Exceptions:
ImageDimensionException If 'this' image is 1D.
Returns:
1-D rotationally-averaged image

Definition at line 533 of file emdata_sparx.cpp.

References abs, EMData(), get_array_offsets(), get_attr_default(), ImageDimensionException, LOGERR, max, min, nx, ny, nz, set_array_offsets(), set_size(), sqrt(), to_zero(), and update().

Referenced by rotavg_i().

00533                        {
00534 
00535         int rmax;
00536 
00537         ENTERFUNC;
00538 
00539 
00540         if (ny<2 && nz <2) {
00541                 LOGERR("No 1D images.");
00542                 throw ImageDimensionException("No 1D images!");
00543         }
00544         
00545         float apix[3];
00546         apix[0] = get_attr_default("apix_x",1.0);
00547         apix[1] = get_attr_default("apix_y",1.0);
00548         apix[2] = get_attr_default("apix_z",1.0);
00549         float min_apix = *std::min_element(&apix[0],&apix[3]);
00550         //here,only the relative value of apix_x, apix_y, apix_z are considered
00551         float apix_x = apix[0]/min_apix;
00552         float apix_y = apix[1]/min_apix;
00553         float apix_z = 1.0;
00554         if( nz > 1) 
00555                 apix_z=apix[2]/min_apix;
00556         float apix_x2 = apix_x*apix_x;
00557         float apix_y2 = apix_y*apix_y;
00558         float apix_z2 = apix_z*apix_z;
00559         
00560         vector<int> saved_offsets = get_array_offsets();
00561         set_array_offsets(-nx/2,-ny/2,-nz/2);
00562         
00563         
00564 #ifdef _WIN32
00565         //int rmax = _cpp_min(nx/2 + nx%2, ny/2 + ny%2);
00566         if ( nz == 1 ) {
00567                 rmax = _cpp_min( nx/2 + nx%2, ny/2 + ny%2);
00568         } else {
00569                 rmax = _cpp_min(nx/2 + nx%2, _cpp_min(ny/2 + ny%2, nz/2 + nz%2));
00570         }
00571 #else
00572         //int rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00573         if ( nz == 1 ) {
00574                 rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00575         } else {
00576                 rmax = std::min(nx/2 + nx%2, std::min(ny/2 + ny%2, nz/2 + nz%2));
00577         }
00578 #endif  //_WIN32
00579 
00580         float rmax_ratio = 0.0;
00581         if (rmax == nx/2 + nx%2 )
00582                 rmax_ratio = apix_x;
00583         else if (rmax == ny/2 + ny%2)
00584                 rmax_ratio = apix_y;
00585         else
00586                 rmax_ratio = apix_z;
00587         
00588         EMData* ret = new EMData();
00589         ret->set_size(rmax+1, 1, 1);
00590         ret->to_zero();
00591         vector<float> count(rmax+1);
00592         for (int k = -nz/2; k < nz/2 + nz%2; k++) {
00593                 if (abs( k*apix_z) > rmax*rmax_ratio ) continue;
00594                 for (int j = -ny/2; j < ny/2 + ny%2; j++) {
00595                         if (abs( j*apix_y ) > rmax*rmax_ratio) continue;
00596                         for (int i = -nx/2; i < nx/2 + nx%2; i++) {
00597                                 float r = std::sqrt(float(k*k*apix_z2) + float(j*j*apix_y2) + float(i*i*apix_x2))/rmax_ratio;
00598                                 int ir = int(r);
00599                                 if (ir >= rmax) continue;
00600                                 float frac = r - float(ir);
00601                                 (*ret)(ir) += (*this)(i,j,k)*(1.0f - frac);
00602                                 (*ret)(ir+1) += (*this)(i,j,k)*frac;
00603                                 count[ir] += 1.0f - frac;
00604                                 count[ir+1] += frac;
00605                         }
00606                 }
00607         }
00608         for (int ir = 0; ir <= rmax; ir++) {
00609         #ifdef _WIN32
00610                 (*ret)(ir) /= _cpp_max(count[ir],1.0f);
00611         #else
00612                 (*ret)(ir) /= std::max(count[ir],1.0f);
00613         #endif  //_WIN32
00614         }
00615 
00616         set_array_offsets(saved_offsets);
00617         ret->update();
00618         EXITFUNC;
00619         return ret;
00620 }

EMData * EMData::rotavg_i  ) 
 

Create a 2-D or 3-D rotationally averaged image.

Exceptions:
ImageDimensionException If 'this' image is 1D.
Returns:
2-D or 3-D rotationally-averaged image

Definition at line 622 of file emdata_sparx.cpp.

References abs, EMData(), ImageDimensionException, LOGERR, min, nx, nx, ny, ny, nz, rotavg(), set_array_offsets(), set_size(), sqrt(), to_zero(), and update().

00622                          {
00623 
00624         int rmax;
00625         ENTERFUNC;
00626         if ( ny == 1 && nz == 1 ) {
00627                 LOGERR("Input image must be 2-D or 3-D!");
00628                 throw ImageDimensionException("Input image must be 2-D or 3-D!");
00629         }
00630 
00631         EMData* avg1D  = new EMData();
00632         EMData* result = new EMData();
00633 
00634         result->set_size(nx,ny,nz);
00635         result->to_zero();
00636         result->set_array_offsets(-nx/2, -ny/2, -nz/2);
00637 
00638         if ( nz == 1 ) {
00639 #ifdef  _WIN32
00640                 rmax = _cpp_min(nx/2 + nx%2, ny/2 + ny%2);
00641         } else {
00642                 rmax = _cpp_min(nx/2 + nx%2, _cpp_min(ny/2 + ny%2, nz/2 + nz%2));
00643 #else
00644                 rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00645         } else {
00646                 rmax = std::min(nx/2 + nx%2, std::min(ny/2 + ny%2, nz/2 + nz%2));
00647 #endif  //_WIN32
00648         }
00649 
00650         avg1D = rotavg();
00651         float padded_value = 0.0, r;
00652         int i, j, k, ir;
00653         size_t number_of_pixels = 0;
00654         for ( k = -nz/2; k < nz/2 + nz%2; k++) {
00655                 if (abs(k) > rmax) continue;
00656                 for ( j = -ny/2; j < ny/2 + ny%2; j++) {
00657                         if (abs(j) > rmax) continue;
00658                         for (i = -nx/2; i < nx/2 + nx%2; i++) {
00659                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00660                                 ir = int(r);
00661                                 if (ir > rmax || ir < rmax-2 ) continue ;
00662                                 else {
00663                                         padded_value += (*avg1D)(ir) ;
00664                                         number_of_pixels++ ;
00665                                 }
00666                         }
00667                 }
00668         }
00669         padded_value /= number_of_pixels;
00670         for ( k = -nz/2; k < nz/2 + nz%2; k++) {
00671                 for ( j = -ny/2; j < ny/2 + ny%2; j++) {
00672                         for ( i = -nx/2; i < nx/2 + nx%2; i++)  {
00673                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00674                                 ir = int(r);
00675                                 if (ir >= rmax) (*result)(i,j,k) = padded_value ;
00676                                 else            (*result)(i,j,k) = (*avg1D)(ir)+((*avg1D)(ir+1)-(*avg1D)(ir))*(r - float(ir));
00677 
00678                         }
00679                 }
00680         }
00681         result->update();
00682         result->set_array_offsets(0,0,0);
00683         EXITFUNC;
00684         return result;
00685 }

void EMData::save_byteorder_to_dict ImageIO imageio  )  [private]
 

Definition at line 4185 of file emdata.cpp.

References attr_dict, and EMAN::ImageIO::is_image_big_endian().

Referenced by read_binedimage(), and read_image().

04186 {
04187         string image_endian = "ImageEndian";
04188         string host_endian = "HostEndian";
04189 
04190         if (imageio->is_image_big_endian()) {
04191                 attr_dict[image_endian] = "big";
04192         }
04193         else {
04194                 attr_dict[image_endian] = "little";
04195         }
04196 
04197         if (ByteOrder::is_host_big_endian()) {
04198                 attr_dict[host_endian] = "big";
04199         }
04200         else {
04201                 attr_dict[host_endian] = "little";
04202         }
04203 }

void EMData::scale float  scale_factor  ) 
 

scale the image by a factor.

Parameters:
scale_factor scale factor.

Definition at line 854 of file emdata.cpp.

References EMAN::Transform::set_scale(), t, and transform().

Referenced by do_ift(), and do_ift_inplace().

00855 {
00856         ENTERFUNC;
00857         Transform t;
00858         t.set_scale(s);
00859         transform(t);
00860         EXITFUNC;
00861 }

void EMData::scale_pixel float  scale_factor  )  const
 

Scale the angstrom per pixel of this image by a uniform amount Alters the EMData metadata I had to make this function public for access from the Processors (David Woolford).

Author:
Unknown

Definition at line 1281 of file emdata_metadata.cpp.

References EMAN::Ctf::apix, attr_dict, and EMAN::Dict::has_key().

Referenced by EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), EMAN::TransformProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::TransformProcessor::process_inplace(), and EMAN::FFTResampleProcessor::process_inplace().

01282 {
01283         attr_dict["apix_x"] = ((float) attr_dict["apix_x"]) * scale;
01284         attr_dict["apix_y"] = ((float) attr_dict["apix_y"]) * scale;
01285         attr_dict["apix_z"] = ((float) attr_dict["apix_z"]) * scale;
01286         if (attr_dict.has_key("ctf")) {
01287                 Ctf *ctf=(Ctf *)attr_dict["ctf"];
01288                 ctf->apix*=scale;
01289                 attr_dict["ctf"]=ctf;
01290                 if(ctf) {delete ctf; ctf=0;}
01291         }
01292 }

void EMAN::EMData::set_array_offsets vector< int >  offsets  )  [inline]
 

Definition at line 2369 of file emdata.h.

void EMAN::EMData::set_array_offsets const int  xoff_ = 0,
const int  yoff_ = 0,
const int  zoff_ = 0
[inline]
 

Set the array offsets.

Definition at line 2363 of file emdata.h.

Referenced by EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nnSSNR_ctfReconstructor::buildNorm2Volume(), EMAN::nnSSNR_Reconstructor::buildNorm2Volume(), EMAN::nnSSNR_ctfReconstructor::buildNorm3Volume(), EMAN::nnSSNR_ctfReconstructor::buildNormVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nnSSNR_Reconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), EMAN::QuadMinDotCmp::cmp(), EMAN::Processor::EMFourierFilterFunc(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), EMAN::fourierproduct(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), mult_radial(), nn(), nn_ctf(), nn_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), EMAN::Util::pack_complex_to_real(), EMAN::periodogram(), rotavg(), rotavg_i(), EMAN::rsconvolution(), symplane0(), symplane1(), and symplane2().

void EMData::set_attr const string &  key,
EMObject  val
 

Set a header attribute's value.

Parameters:
key The header attribute name.
val The attribute value.

Definition at line 1214 of file emdata_metadata.cpp.

References attr_dict, key, and LOGWARN.

Referenced by EMAN::TomoAverager::add_image(), ali3d_d(), EMAN::RT3DSymmetryAligner::align(), EMAN::RT3DSphereAligner::align(), EMAN::RT3DGridAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::align(), EMAN::SymAlignProcessorQuat::align(), EMAN::RefineAlignerCG::align(), EMAN::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotatePrecenterAligner::align(), EMAN::RotationalAligner::align(), EMAN::TranslationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), EMAN::ScaleAlignerABS::align_using_base(), EMAN::SVDAnalyzer::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), calc_mutual_correlation(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), compute_missingwedge(), EMAN::SetSFProcessor::create_radial_func(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::AbsMaxMinAverager::finish(), EMAN::MinMaxAverager::finish(), EMAN::FourierWeightAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), frm_2d_Align(), EMAN::file_store::get_image(), EMAN::Util::hans(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::padfft_slice(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), EMAN::NewFourierProcessor::preprocess(), EMAN::LowpassAutoBProcessor::preprocess(), EMAN::FourierProcessor::preprocess(), EMAN::HighpassAutoPeakProcessor::preprocess(), EMAN::Reconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::NewFourierProcessor::preprocessandconvertpars(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::PhaseToMassCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ri2inten(), set_attr_dict(), wustl_mm::SkeletonMaker::VolumeData::SetOrigin(), wustl_mm::SkeletonMaker::VolumeData::SetSpacing(), EMAN::FourierReconstructor::setup(), and EMAN::FourierReconstructor::setup_seed().

01215 {
01216         /* Ignore dimension attribute. */
01217         if(key == "nx" || key == "ny" || key == "nz")
01218         {
01219                 printf("Ignore setting dimension attribute %s. Use set_size if you need resize this EMData object.", key.c_str());
01220                 return;
01221         }
01222 
01223         if(rdata) {     //skip following for header only image
01224                 /* Ignore 'read only' attribute. */
01225                 if(key == "sigma" ||
01226                         key == "sigma_nonzero" ||
01227                         key == "square_sum" ||
01228                         key == "maximum" ||
01229                         key == "minimum" ||
01230                         key == "mean" ||
01231                         key == "mean_nonzero" )
01232                 {
01233                         LOGWARN("Ignore setting read only attribute %s", key.c_str());
01234                         return;
01235                 }
01236         }
01237 
01238         attr_dict[key] = val;
01239 }

void EMData::set_attr_dict const Dict new_dict  ) 
 

Merge the new values with the existing dictionary.

Parameters:
new_dict The new attribute dictionary.

Definition at line 1178 of file emdata_metadata.cpp.

References EMAN::Dict::end(), EMAN::Dict::erase(), EMAN::Dict::has_key(), EMAN::Dict::keys(), LOGWARN, and set_attr().

Referenced by ali3d_d().

01179 {
01180         /*set nx, ny nz may resize the image*/
01181         // This wasn't supposed to 'clip' the image, but just redefine the size --steve
01182         if( new_dict.has_key("nx") || new_dict.has_key("ny") || new_dict.has_key("nz") ) {
01183                 LOGWARN("Warning: Ignored setting dimension size by modifying attribute!!!");
01184                 const_cast<Dict&>(new_dict).erase("nx");
01185                 const_cast<Dict&>(new_dict).erase("ny");
01186                 const_cast<Dict&>(new_dict).erase("nz");
01187         }
01188 
01189         vector<string> new_keys = new_dict.keys();
01190         vector<string>::const_iterator it;
01191         for(it = new_keys.begin(); it!=new_keys.end(); ++it) {
01192                 this->set_attr(*it, new_dict[*it]);
01193         }
01194 }

void EMData::set_attr_dict_explicit const Dict new_dict  )  [private]
 

Make the attributes of this EMData exactly equal to the argument dictionary Originally introduced because set_attr_dict does automatic resizing, which is undersirable in some circumstances.

Parameters:
new_dict The attribute dictionary that will become this image's attribute dictionary.

Definition at line 1196 of file emdata_metadata.cpp.

References attr_dict.

01197 {
01198         attr_dict = new_dict;
01199 }

void EMData::set_attr_python const string &  key,
EMObject  val
 

Set a header attribute's value from Python.

Parameters:
key The header attribute name.
val The attribute value.

Definition at line 1241 of file emdata_metadata.cpp.

References attr_dict, copy(), EMAN::EMObject::get_type(), key, LOGWARN, t, and v.

01242 {
01243         /* Ignore dimension attribute. */
01244         if(key == "nx" || key == "ny" || key == "nz")
01245         {
01246                 printf("Ignore setting dimension attribute %s. Use set_size if you need resize this EMData object.", key.c_str());
01247                 return;
01248         }
01249 
01250         /* Ignore 'read only' attribute. */
01251         if(key == "sigma" ||
01252                   key == "sigma_nonzero" ||
01253                   key == "square_sum" ||
01254                   key == "maximum" ||
01255                   key == "minimum" ||
01256                   key == "mean" ||
01257                   key == "mean_nonzero" )
01258         {
01259                 LOGWARN("Ignore setting read only attribute %s", key.c_str());
01260                 return;
01261         }
01262 
01263         EMObject::ObjectType argtype = val.get_type();
01264         if (argtype == EMObject::EMDATA) {
01265                 EMData* e = (EMData*) val;
01266                 e = e->copy();
01267                 EMObject v(e);
01268                 attr_dict[key] = v;
01269         }
01270         else if (argtype == EMObject::TRANSFORM) {
01271                 Transform* t = new Transform(*((Transform*) val));
01272                 EMObject v(t);
01273                 attr_dict[key] = v;
01274                 delete t; t=0;
01275         } else {
01276                 attr_dict[key] = val;
01277         }
01278 
01279 }

void EMAN::EMData::set_changecount int  c  )  [inline]
 

Definition at line 1258 of file emdata.h.

void EMData::set_col const EMData data,
int  col_index
 

Set one column of a 2D image.

Parameters:
data The column image data.
col_index Index of the column.
Exceptions:
ImageDimensionException If this image is not 2D.

Definition at line 719 of file emdata_core.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and update().

00720 {
00721         ENTERFUNC;
00722 
00723         if (get_ndim() != 2) {
00724                 throw ImageDimensionException("2D image only");
00725         }
00726         if (d->get_ndim() != 1) {
00727                 throw ImageDimensionException("1D image only");
00728         }
00729 
00730         float *dst = get_data();
00731         float *src = d->get_data();
00732 
00733         for (int i = 0; i < ny; i++) {
00734                 dst[i * nx + n] = src[i];
00735         }
00736 
00737         update();
00738         EXITFUNC;
00739 }

void EMAN::EMData::set_complex bool  is_complex  )  [inline]
 

Mark this image as a complex image.

Parameters:
is_complex If true, a complex image. If false, a real image.

Definition at line 1050 of file emdata.h.

Referenced by absi(), EMAN::FourierWeightAverager::add_image(), EMAN::Util::addn_img(), EMAN::FRM2DAligner::align(), amplitude(), EMAN::ChaoProjector::backproject3d(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::Util::ctf_img(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), FH2F(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), frm_2d_Align(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), imag(), EMAN::Util::madn_scalar(), make_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::Util::muln_img(), EMAN::Util::mult_scalar(), oneDfftPolar(), EMAN::PointArray::pdb2mrc_by_nfft(), phase(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), read_binedimage(), read_image(), real(), real2complex(), real2FH(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), EMAN::Util::subn_img(), and EMAN::Util::TwoDTestFunc().

void EMData::set_complex_at const int &  x,
const int &  y,
const int &  z,
const std::complex< float > &  val
 

Set complex<float> value at x,y,z.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny x nz image, a nx+2 x ny x nz image will be produced, and values using this function can go from -nx/2 to nx/2 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. This function differs from cmplx() which will interpret x,y directly as pixel coordinates

Parameters:
x x coordinate
y y coordinate
z z coordinate
val complex<float> value to set
Returns:
The complex pixel at x,y

Definition at line 184 of file emdata_core.cpp.

References abs, imag(), nx, ny, nz, rdata, real(), x, and y.

00184                                                                                                {
00185 if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return;
00186 //if (x==0 && (y!=0 || z!=0)) set_complex_at(0,-y,-z,conj(val));
00187 
00188 // for x=0, we need to insert the value in 2 places
00189 // complex conjugate insertion. Removed due to ambiguity with returned index
00190 /*if (x==0 && (y!=0 || z!=0)) {
00191         size_t idx=(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nx*ny;
00192         rdata[idx]=(float)val.real();
00193         rdata[idx+1]=(float)-val.imag();
00194 }*/
00195 
00196 size_t idx;
00197 if (x<0) {
00198         idx=-x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00199         rdata[idx]=(float)val.real();
00200         rdata[idx+1]=-(float)val.imag();
00201         return;
00202 }
00203 
00204 idx=x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00205 rdata[idx]=(float)val.real();
00206 rdata[idx+1]=(float)val.imag();
00207 
00208 return;
00209 }

void EMData::set_complex_at const int &  x,
const int &  y,
const std::complex< float > &  val
 

Set complex<float> value at x,y.

This assumes the image is a standard real/imaginary image with the complex origin in the first memory location. If you take the fft of a real nx x ny image, a nx+2 x ny image will be produced, and values using this function can go from -nx/2-1 to nx/2+1 and -ny/2 to ny/2. It will automatically deal with wraparound and complex conjugate issues for -x. This function differs from cmplx() which will interpret x,y directly as pixel coordinates

Parameters:
x x coordinate
y y coordinate
val complex<float> value to set
Returns:
The complex pixel at x,y

Definition at line 175 of file emdata_core.cpp.

References abs, imag(), nx, ny, rdata, real(), x, and y.

Referenced by EMAN::FourierWeightAverager::add_image(), and EMAN::FourierWeightAverager::finish().

00175                                                                                   {
00176         if (abs(x)>=nx/2 || abs(y)>ny/2) return;
00177         if (x>=0 && y>=0) { rdata[ x*2+y*nx]=val.real(); rdata[x*2+y*nx+1]=val.imag(); }
00178         else if (x>0 && y<0) { rdata[ x*2+(ny+y)*nx]=val.real(); rdata[x*2+(ny+y)*nx+1]=val.imag(); }
00179         else if (x<0 && y>0) { rdata[-x*2+(ny-y)*nx]=val.real(); rdata[-x*2+(ny-y)*nx+1]=-val.imag(); }
00180         else { rdata[-x*2-y*nx]=val.real(); rdata[-x*2+-y*nx+1]=-val.imag(); }
00181         return;
00182 }

void EMAN::EMData::set_complex_size int  nx,
int  ny = 1,
int  nz = 1
[inline]
 

Resize 'this' complex image.

Parameters:
nx x size of this image.
ny y size of this image.
nz z size of this image.

Definition at line 665 of file emdata.h.

00760                                           {

void EMAN::EMData::set_complex_x bool  is_complex_x  )  [inline]
 

Definition at line 1085 of file emdata.h.

Referenced by absi(), amplitude(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), FH2F(), get_fft_amplitude(), get_fft_phase(), imag(), phase(), real(), real2complex(), and real2FH().

void EMData::set_ctf Ctf ctf  ) 
 

Set the CTF parameter of this image.

Parameters:
ctf The CTF parameter object.

Definition at line 806 of file emdata_metadata.cpp.

References attr_dict, and EMAN::Ctf::to_vector().

00807 {
00808         ENTERFUNC;
00809 
00810         vector<float> vctf = new_ctf->to_vector();
00811         attr_dict["ctf"] = vctf;
00812 
00813         EXITFUNC;
00814 }

void EMAN::EMData::set_data float *  data  )  [inline]
 

Definition at line 383 of file emdata.h.

00391                                    : an algorithm that transforms an original

void EMAN::EMData::set_data float *  data,
const int  x,
const int  y,
const int  z
[inline]
 

Set the data explicitly data pointer must be allocated using malloc!

Parameters:
data a pointer to the pixel data which is stored in memory. Takes possession
x the number of pixels in the x direction
y the number of pixels in the y direction
z the number of pixels in the z direction

Definition at line 370 of file emdata.h.

Referenced by EMAN::ScaleAligner::align(), EMAN::ScaleAlignerABS::align_using_base(), wustl_mm::SkeletonMaker::VolumeData::Pad(), EMAN::TransformProcessor::process_inplace(), and EMAN::TransposeProcessor::process_inplace().

00391                                    : an algorithm that transforms an original

void EMData::set_data_pickle std::string  vf  ) 
 

Definition at line 1308 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

01309 {
01310 //      if (rdata) printf("rdata exists\n");
01311 //      rdata = (float *)malloc(nx*ny*nz*sizeof(float));
01312 //      std::copy(vf.begin(), vf.end(), rdata);
01313         EMUtil::em_memcpy(get_data(),vf.data(),(size_t)nx*ny*nz*sizeof(float));
01314 
01315 }

void EMAN::EMData::set_fftodd bool  is_fftodd  )  [inline]
 

Mark this image as having (real-space) odd nx.

Parameters:
is_fftodd If true, mark as nx odd; If false, mark as nx not odd.

Definition at line 1220 of file emdata.h.

Referenced by EMAN::Util::addn_img(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::Util::ctf_img(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), frm_2d_Align(), EMAN::Util::madn_scalar(), EMAN::Util::muln_img(), EMAN::Util::mult_scalar(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), read_binedimage(), read_image(), real2FH(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), EMAN::Util::subn_img(), and EMAN::Util::TwoDTestFunc().

void EMAN::EMData::set_fftpad bool  is_fftpadded  )  [inline]
 

Mark this image as already extended along x for ffts.

Parameters:
is_fftpadded If true, mark as padded along x; If false, mark as not padded along x.

Definition at line 1188 of file emdata.h.

Referenced by EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), read_binedimage(), and read_image().

void EMAN::EMData::set_FH bool  is_FH  )  [inline]
 

Mark this complex image as a FH image.

Parameters:
is_FH If true, a FH image. If false, not a FH image.

Definition at line 1033 of file emdata.h.

Referenced by FH2F(), and real2FH().

void EMAN::EMData::set_flags int  f  )  [inline]
 

Definition at line 1248 of file emdata.h.

void EMAN::EMData::set_flipped bool  is_flipped  )  [inline]
 

Mark this image as flipped.

Parameters:
is_flipped If true, mark this image as flipped; If false, mark this image as not flipped.

Definition at line 1120 of file emdata.h.

void EMAN::EMData::set_nxc int  nxc  )  [inline]
 

Set the number of complex elements along x.

Parameters:
nxc is the number of complex elements along x.

Definition at line 1234 of file emdata.h.

Referenced by EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nnSSNR_ctfReconstructor::finish(), and EMAN::nnSSNR_Reconstructor::finish().

void EMAN::EMData::set_path const string &  new_path  )  [inline]
 

Set the path.

Parameters:
new_path The new path.

Definition at line 673 of file emdata.h.

Referenced by calc_mutual_correlation(), and get_clip().

00760                                           {

void EMAN::EMData::set_pathnum int  n  )  [inline]
 

Set the number of paths.

Parameters:
n The number of paths.

Definition at line 682 of file emdata.h.

Referenced by get_clip().

00760                                           {

void EMAN::EMData::set_ri bool  is_ri  )  [inline]
 

Mark this image as a real/imaginary format complex image.

Parameters:
is_ri If true, mark as real/imaginary format; If false, mark as amp/phase format.

Definition at line 1155 of file emdata.h.

Referenced by EMAN::FRM2DAligner::align(), ap2ri(), EMAN::ChaoProjector::backproject3d(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::Util::ctf_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), FH2F(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), frm_2d_Align(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), read_binedimage(), read_image(), real2complex(), real2FH(), ri2ap(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), to_one(), to_zero(), and EMAN::Util::TwoDTestFunc().

void EMAN::EMData::set_rotation const Transform t3d  )  [inline]
 

Define the 3D orientation of this particle Orientation information is extracted from a Transform object and stored internally in EMAN (az,alt,phi) format.

Parameters:
t3d a Transform object containing the particle orientation

Definition at line 628 of file emdata.h.

00760                                           {

void EMAN::EMData::set_rotation float  az,
float  alt,
float  phi
[inline]
 

Define the 3D orientation of this particle, also used to indicate relative rotations for reconstructions.

Parameters:
az 'az' Euler angle in EMAN convention.
alt 'alt' Euler angle in EMAN convention.
phi 'phi' Euler angle in EMAN convention.

Definition at line 614 of file emdata.h.

Referenced by main().

00760                                           {

void EMData::set_row const EMData data,
int  row_index
 

Set one row of a 1D/2D image.

Parameters:
data The row image data.
row_index Index of the row.
Exceptions:
ImageDimensionException If this image is 3D.

Definition at line 678 of file emdata_core.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and update().

00679 {
00680         ENTERFUNC;
00681 
00682         if (get_ndim() > 2) {
00683                 throw ImageDimensionException("1D/2D image only");
00684         }
00685         if (d->get_ndim() != 1) {
00686                 throw ImageDimensionException("1D image only");
00687         }
00688 
00689         float *dst = get_data();
00690         float *src = d->get_data();
00691         memcpy(dst + nx * row_index, src, nx * sizeof(float));
00692         update();
00693         EXITFUNC;
00694 }

void EMAN::EMData::set_shuffled bool  is_shuffled  )  [inline]
 

Mark this image as a shuffled image.

Parameters:
is_shuffled If true, a shuffled image. If false, not a shuffled image.

Definition at line 1015 of file emdata.h.

Referenced by FH2F(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), and EMAN::Util::TwoDTestFunc().

01021       : set ts=4 noet nospell: */
01022 set ts=4 noet nospell: */

void EMData::set_size int  nx,
int  ny = 1,
int  nz = 1,
bool  noalloc = false
 

Resize this EMData's main board memory pointer.

Parameters:
nx x size of this image.
ny y size of this image.
nz z size of this image.
Exceptions:
BadAllocException if memory allocation returns a null pointer

Definition at line 833 of file emdata_metadata.cpp.

References BadAllocException, get_data(), InvalidValueException, nx, nxy, nxyz, ny, ny, nz, rdata, supp, update(), x, and y.

Referenced by absi(), EMAN::IterationAverager::add_image(), EMAN::ImageAverager::add_image(), ali3d_d(), EMAN::FRM2DAligner::align(), amplitude(), EMAN::SVDAnalyzer::analyze(), EMAN::varimax::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), bispecRotTransInvN(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nnSSNR_ctfReconstructor::buildNorm2Volume(), EMAN::nnSSNR_Reconstructor::buildNorm2Volume(), EMAN::nnSSNR_ctfReconstructor::buildNorm3Volume(), EMAN::nnSSNR_ctfReconstructor::buildNormVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nnSSNR_Reconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccfx(), clip_inplace(), common_lines(), common_lines_real(), EMAN::Util::compress_image_mask(), compute_missingwedge(), copy_head(), EMAN::Util::Crosrng_msg(), EMAN::Util::Crosrng_msg_m(), EMAN::Util::Crosrng_msg_s(), EMAN::Util::ctf2_rimg(), EMAN::Util::ctf_img(), EMAN::Util::ctf_rimg(), EMAN::Util::decimate(), do_fft(), do_fft_inplace(), do_ift(), do_radon(), EMAN::PCA::dopca_lan(), EMAN::PCA::dopca_ooc(), EMData(), extract_box(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), frm_2d_Align(), EMAN::Util::get_biggest_cluster(), get_circle_mean(), get_clip(), get_col(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_rotated_clip(), get_row(), EMAN::Util::get_slice(), get_top_half(), EMAN::Util::im_diff(), imag(), little_big_dot(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::Util::move_points(), EMAN::Util::multiref_peaks_ali2d(), EMAN::Util::multiref_peaks_compress_ali2d(), oneDfftPolar(), operator=(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), phase(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::DirectionalSumProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_binedimage(), read_image(), ReadVandBcast(), real(), real2complex(), real2FH(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), EMAN::Util::reconstitute_image_mask(), rotavg(), rotavg_i(), EMAN::rsconvolution(), EMAN::varimax::set_params(), EMAN::PCAlarge::set_params(), EMAN::PCAsmall::set_params(), wustl_mm::SkeletonMaker::VolumeData::SetSize(), EMAN::BackProjectionReconstructor::setup(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), EMAN::FourierReconstructor::setup_seed(), symvol(), EMAN::Util::TwoDTestFunc(), unwrap(), unwrap_largerR(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00834 {
00835         ENTERFUNC;
00836 
00837         if (x <= 0) {
00838                 throw InvalidValueException(x, "x size <= 0");
00839         }
00840         else if (y <= 0) {
00841                 throw InvalidValueException(y, "y size <= 0");
00842         }
00843         else if (z <= 0) {
00844                 throw InvalidValueException(z, "z size <= 0");
00845         }
00846 
00847 #ifdef MEMDEBUG2
00848         printf("EMDATA sz  %4d    %p (%d,%d,%d)\n",EMData::totalalloc,this,x,y,z);
00849 #endif
00850 
00851 
00852         int old_nx = nx;
00853 
00854         size_t size = (size_t)x*y*z*sizeof(float);
00855         
00856         if (noalloc) {
00857                 nx = x;
00858                 ny = y;
00859                 nz = z;
00860                 nxy = nx*ny;
00861                 nxyz = (size_t)nx*ny*nz;
00862                 return;
00863         }
00864         
00865         if (rdata != 0) {
00866                 rdata = (float*)EMUtil::em_realloc(rdata,size);
00867         } else {
00868                 // Just pass on this for a while....see what happens
00869                 rdata = (float*)EMUtil::em_malloc(size);
00870         }
00871 //      rdata = static_cast < float *>(realloc(rdata, size));
00872         if ( rdata == 0 )
00873         {
00874                 stringstream ss;
00875                 string gigs;
00876                 ss << (float) size/1000000000.0;
00877                 ss >> gigs;
00878                 string message = "Cannot allocate " + gigs + " GB - not enough memory.";
00879                 throw BadAllocException(message);
00880         }
00881 
00882         nx = x;
00883         ny = y;
00884         nz = z;
00885         nxy = nx*ny;
00886         nxyz = (size_t)nx*ny*nz;
00887 
00888 // once the object is resized, the CUDA need to be updated
00889 #ifdef EMAN2_USING_CUDA
00890         if(cudarwdata) {
00891                 //cout << "rw free on set size" << endl;
00892                 rw_free();
00893                 rw_alloc();
00894         }
00895         if(cudarodata) {
00896                 ro_free();
00897                 ro_alloc();
00898         }
00899 #endif // EMAN2_USING_CUDA
00900 
00901         if (old_nx == 0) {
00902                 EMUtil::em_memset(get_data(),0,size);
00903         }
00904 
00905         if (supp) {
00906                 EMUtil::em_free(supp);
00907                 supp = 0;
00908         }
00909 
00910         update();
00911         EXITFUNC;
00912 }

void EMData::set_supp_pickle int  i  ) 
 

Definition at line 1322 of file emdata_metadata.cpp.

References supp.

01323 {
01324         this->supp = 0;
01325 }

void EMAN::EMData::set_translation float  dx,
float  dy,
float  dz
[inline]
 

Set 'this' images' translation vector from the original location.

Parameters:
dx The translation distance in x direction.
dy The translation distance in y direction.
dz The translation distance in z direction.

Definition at line 583 of file emdata.h.

00760                                           {

void EMAN::EMData::set_translation const Vec3f t  )  [inline]
 

Set 'this' images' translation vector from the original location.

Parameters:
t The new translation vector.

Definition at line 571 of file emdata.h.

00760                                           {

void EMAN::EMData::set_value_at int  x,
float  v
[inline]
 

Set the pixel density value at coordinate (x).

1D image only.

Parameters:
x The x coordinate.
v The pixel density value at coordinate (x).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2277 of file emdata.h.

void EMAN::EMData::set_value_at int  x,
int  y,
float  v
[inline]
 

Set the pixel density value at coordinates (x,y).

2D image only.

Parameters:
x The x coordinate.
y The y coordinate.
v The pixel density value at coordinates (x,y).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2236 of file emdata.h.

void EMAN::EMData::set_value_at int  x,
int  y,
int  z,
float  v
[inline]
 

Set the pixel density value at coordinates (x,y,z).

This implementation does bounds checking.

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
v The pixel density value at coordinates (x,y,z).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2178 of file emdata.h.

Referenced by EMAN::MinMaxAverager::add_image(), EMAN::FourierWeightAverager::add_image(), bispecRotTransInvDirect(), bispecRotTransInvN(), common_lines(), compute_missingwedge(), EMAN::PointArray::distmx(), find_group(), get_rotated_clip(), EMAN::TestTomoImage::insert_rectangle(), make_footprint(), EMAN::DirectionalSumProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::TestImageEllipse::process_inplace(), EMAN::TestImageHollowEllipse::process_inplace(), EMAN::TestImageSphericalWave::process_inplace(), EMAN::TestImageGradient::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::BoxingTools::set_radial_non_zero(), EMAN::BoxingTools::set_region(), wustl_mm::SkeletonMaker::VolumeData::SetDataAt(), EMAN::Util::svdcmp(), and EMAN::WatershedProcessor::watershed().

void EMAN::EMData::set_value_at_fast int  x,
float  v
[inline]
 

Set the pixel density value at coordinate (x).

1D image only.

Parameters:
x The x coordinate.
v The pixel density value at coordinate (x).

Definition at line 2297 of file emdata.h.

void EMAN::EMData::set_value_at_fast int  x,
int  y,
float  v
[inline]
 

Set the pixel density value at coordinates (x,y).

2D image only. The validity of x, y, is not checked.

Parameters:
x The x coordinate.
y The y coordinate.
v The pixel density value at coordinates (x,y).

Definition at line 2262 of file emdata.h.

void EMAN::EMData::set_value_at_fast int  x,
int  y,
int  z,
float  v
[inline]
 

Set the pixel density value at coordinates (x,y,z).

The validity of x, y, and z is not checked. This implementation has no bounds checking.

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
v The pixel density value at coordinates (x,y,z).

Definition at line 2210 of file emdata.h.

Referenced by EMAN::ImageAverager::add_image(), EMAN::Rotate180Processor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::TestImageLineWave::process_inplace(), EMAN::StripeXYProcessor::process_inplace(), and EMAN::NonConvexProcessor::process_inplace().

void EMAN::EMData::set_value_at_index int  i,
float  v
[inline]
 

Set the pixel density value at index.

Parameters:
i The index.
v The value.

Definition at line 2223 of file emdata.h.

void EMData::set_xyz_origin float  origin_x,
float  origin_y,
float  origin_z
 

Set the x,y,z origin of the image.

Parameters:
origin_x the x origin
origin_y the y origin
origin_z the z origin

Definition at line 3113 of file emdata.cpp.

References attr_dict.

Referenced by clip_inplace(), and get_clip().

03114 {
03115         attr_dict["origin_x"] = origin_x;
03116         attr_dict["origin_y"] = origin_y;
03117         attr_dict["origin_z"] = origin_z;
03118 }

void EMAN::EMData::set_xyzoff int  x,
int  y,
int  z
[inline]
 

Definition at line 1278 of file emdata.h.

float * EMData::setup4slice bool  redo = true  ) 
 

Set up for fftslice operations.

When interpolating in fourier space there is a little problem when we get close to x=0, since f(-x,-y,-z) = f(x,y,z)* . So this makes a supplementary array that allows for up to +-2 point interpolation all the way to the origin in x.

3D only; complex image only

Parameters:
redo If true, recalculate the supplementary array.
Exceptions:
ImageFormatException If the image is not a complex image.
ImageDimensionException If the image is not 3D.
Returns:
The supplementary array.

Definition at line 790 of file emdata.cpp.

References data, get_data(), get_ndim(), ImageDimensionException, ImageFormatException, is_complex(), nx, nxy, ny, ny, nz, supp, x, and y.

Referenced by EMAN::GaussFFTProjector::interp_ft_3d().

00791 {
00792         ENTERFUNC;
00793 
00794         if (!is_complex()) {
00795                 throw ImageFormatException("complex image only");
00796         }
00797 
00798         if (get_ndim() != 3) {
00799                 throw ImageDimensionException("3D only");
00800         }
00801 
00802         if (supp) {
00803                 if (redo) {
00804                         EMUtil::em_free(supp);
00805                         supp = 0;
00806                 }
00807                 else {
00808                         EXITFUNC;
00809                         return supp;
00810                 }
00811         }
00812 
00813         const int SUPP_ROW_SIZE = 8;
00814         const int SUPP_ROW_OFFSET = 4;
00815         const int supp_size = SUPP_ROW_SIZE + SUPP_ROW_OFFSET;
00816 
00817         supp = (float *) EMUtil::em_calloc(supp_size * ny * nz, sizeof(float));
00818         int nxy = nx * ny;
00819         int supp_xy = supp_size * ny;
00820         float * data = get_data();
00821 
00822         for (int z = 0; z < nz; z++) {
00823                 size_t cur_z1 = z * nxy;
00824                 size_t cur_z2 = z * supp_xy;
00825 
00826                 for (int y = 0; y < ny; y++) {
00827                         size_t cur_y1 = y * nx;
00828                         size_t cur_y2 = y * supp_size;
00829 
00830                         for (int x = 0; x < SUPP_ROW_SIZE; x++) {
00831                                 size_t k = (x + SUPP_ROW_OFFSET) + cur_y2 + cur_z2;
00832                                 supp[k] = data[x + cur_y1 + cur_z1];
00833                         }
00834                 }
00835         }
00836 
00837         for (int z = 1, zz = nz - 1; z < nz; z++, zz--) {
00838                 size_t cur_z1 = zz * nxy;
00839                 size_t cur_z2 = z * supp_xy;
00840 
00841                 for (int y = 1, yy = ny - 1; y < ny; y++, yy--) {
00842                         supp[y * 12 + cur_z2] = data[4 + yy * nx + cur_z1];
00843                         supp[1 + y * 12 + cur_z2] = -data[5 + yy * nx + cur_z1];
00844                         supp[2 + y * 12 + cur_z2] = data[2 + yy * nx + cur_z1];
00845                         supp[3 + y * 12 + cur_z2] = -data[3 + yy * nx + cur_z1];
00846                 }
00847         }
00848 
00849         EXITFUNC;
00850         return supp;
00851 }

float EMData::sget_value_at size_t  i  )  const
 

A safer, slower way to get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.

The validity of i is checked. If i is out of range, return 0;

Parameters:
i 1D data array index.
Returns:
The pixel density value

Definition at line 819 of file emdata_core.cpp.

References get_data(), and nx.

00820 {
00821         size_t size = nx*ny;
00822         size *= nz;
00823         if (i >= size) {
00824                 return 0;
00825         }
00826         return get_data()[i];
00827 }

float EMData::sget_value_at int  x,
int  y
const
 

A safer, slower way to get the pixel density value at coordinates (x,y).

2D only. The validity of x, y is checked. If the coordinates are out of range, return 0;

Parameters:
x The x coordinate.
y The y coordinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 810 of file emdata_core.cpp.

References get_data(), nx, x, and y.

00811 {
00812         if (x < 0 || x >= nx || y < 0 || y >= ny) {
00813                 return 0;
00814         }
00815         return get_data()[x + y * nx];
00816 }

float EMData::sget_value_at int  x,
int  y,
int  z
const
 

A safer, slower way to get the pixel density value at coordinates (x,y,z).

The validity of x, y, and z is checked. If the coordinates are out of range, return 0;

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 801 of file emdata_core.cpp.

References get_data(), nx, ny, x, and y.

Referenced by sget_value_at_interp().

00802 {
00803         if (x < 0 || x >= nx || y < 0 || y >= ny || z < 0 || z >= nz) {
00804                 return 0;
00805         }
00806         return get_data()[(size_t)x + (size_t)y * (size_t)nx + (size_t)z * (size_t)nxy];
00807 }

float EMData::sget_value_at_interp float  x,
float  y,
float  z
const
 

Get the pixel density value at interpolation of (x,y,z).

The validity of x, y, and z is checked.

Parameters:
x The x coordinate.
y The y coordinate.
z The z coordinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 845 of file emdata_core.cpp.

References EMAN::Util::fast_floor(), sget_value_at(), EMAN::Util::trilinear_interpolate(), x, and y.

00846 {
00847         int x = (int) Util::fast_floor(xx);
00848         int y = (int) Util::fast_floor(yy);
00849         int z = (int) Util::fast_floor(zz);
00850 
00851         float p1 = sget_value_at(x, y, z);
00852         float p2 = sget_value_at(x + 1, y, z);
00853         float p3 = sget_value_at(x, y + 1, z);
00854         float p4 = sget_value_at(x + 1, y + 1, z);
00855 
00856         float p5 = sget_value_at(x, y, z + 1);
00857         float p6 = sget_value_at(x + 1, y, z + 1);
00858         float p7 = sget_value_at(x, y + 1, z + 1);
00859         float p8 = sget_value_at(x + 1, y + 1, z + 1);
00860 
00861         float result = Util::trilinear_interpolate(p1, p2, p3, p4, p5, p6, p7, p8,
00862                                                                                            xx - x, yy - y, zz - z);
00863 
00864         return result;
00865 }

float EMData::sget_value_at_interp float  x,
float  y
const
 

Get pixel density value at interpolation of (x,y).

The validity of x, y is checked.2D image only.

Parameters:
x The x coordinate.
y The y coordinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 830 of file emdata_core.cpp.

References EMAN::Util::bilinear_interpolate(), EMAN::Util::fast_floor(), sget_value_at(), x, and y.

Referenced by get_rotated_clip(), and insert_scaled_sum().

00831 {
00832         int x = static_cast < int >(Util::fast_floor(xx));
00833         int y = static_cast < int >(Util::fast_floor(yy));
00834 
00835         float p1 = sget_value_at(x, y);
00836         float p2 = sget_value_at(x + 1, y);
00837         float p3 = sget_value_at(x, y + 1);
00838         float p4 = sget_value_at(x + 1, y + 1);
00839 
00840         float result = Util::bilinear_interpolate(p1, p2, p3, p4, xx - x, yy - y);
00841         return result;
00842 }

void EMData::shuffle_pad_corner float *  pad_image  ) 
 

Definition at line 4020 of file emdata_sparx.cpp.

References nx.

EMData * EMData::sqrt  )  const
 

return square root of current image

Returns:
a image which is the square root of this image
Exceptions:
ImageFormatException real image only

Definition at line 959 of file emdata_core.cpp.

References copy(), data, get_data(), ImageFormatException, InvalidValueException, is_complex(), sqrt(), and update().

00960 {
00961         ENTERFUNC;
00962 
00963         if (is_complex()) {
00964                 throw ImageFormatException("real image only");
00965         }
00966 
00967         EMData * r = this->copy();
00968         float * new_data = r->get_data();
00969         float * data = get_data();
00970         size_t size = nxyz;
00971         for (size_t i = 0; i < size; ++i) {
00972                 if(data[i] < 0) {
00973                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
00974                 }
00975                 else {
00976                         if(data[i]) {   //do nothing with pixel has value zero
00977                                 new_data[i] = std::sqrt(data[i]);
00978                         }
00979                 }
00980         }
00981 
00982         r->update();
00983         return r;
00984 
00985         EXITFUNC;
00986 }

void EMData::sub const EMData image  ) 
 

subtract a same-size image from this image pixel by pixel.

Parameters:
image The image subtracted from 'this' image.
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 448 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_real(), nx, ny, nz, and update().

00449 {
00450         ENTERFUNC;
00451 
00452         if (nx != em.get_xsize() || ny != em.get_ysize() || nz != em.get_zsize()) {
00453                 throw ImageFormatException("images not same sizes");
00454         }
00455         else if( (is_real()^em.is_real()) == true )
00456         {
00457                 throw ImageFormatException( "not support sub between real image and complex image");
00458         }
00459         else {
00460                 const float *src_data = em.get_data();
00461                 size_t size = nxyz;
00462                 float* data = get_data();
00463 
00464                 for (size_t i = 0; i < size; i++) {
00465                         data[i] -= src_data[i];
00466                 }
00467                 update();
00468         }
00469         EXITFUNC;
00470 }

void EMData::sub float  f  ) 
 

subtract a float number to each pixel value of the image.

Parameters:
f The float number subtracted from 'this' image.

Definition at line 401 of file emdata_core.cpp.

References data, get_data(), ImageFormatException, is_complex(), is_real(), nx, ny, nz, subtract_cuda(), and update().

Referenced by calc_fast_sigma_image(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::operator-(), operator-=(), EMAN::StripeXYProcessor::process_inplace(), and EMAN::FlattenBackgroundProcessor::process_inplace().

00402 {
00403         ENTERFUNC;
00404         
00405 #ifdef EMAN2_USING_CUDA
00406                 if (EMData::usecuda == 1 && cudarwdata) {
00407                         if(f != 0){
00408                                 subtract_cuda(cudarwdata, f, nx, ny, nz);
00409                         }
00410                         EXITFUNC;
00411                         return;
00412                 }
00413 #endif // EMAN2_USING_CUDA
00414 
00415         float* data = get_data();
00416         if( is_real() )
00417         {
00418                 if (f != 0) {
00419                         size_t size = nxyz;
00420                         for (size_t i = 0; i < size; i++) {
00421                                 data[i] -= f;
00422                         }
00423                 }
00424                 update();
00425         }
00426         else if( is_complex() )
00427         {
00428                 if( f != 0 )
00429                 {
00430                         size_t size = nxyz;
00431                         for( size_t i=0; i<size; i+=2 )
00432                         {
00433                                 data[i] -= f;
00434                         }
00435                 }
00436                 update();
00437         }
00438         else
00439         {
00440                 throw ImageFormatException("This image is neither a real nor a complex image.");
00441         }
00442 
00443         EXITFUNC;
00444 }

void EMData::subsquare const EMData image  ) 
 

subtract the squared value of each pixel from a same-size image to this image.

Parameters:
image The image whose square is subtracted from 'this' image.
Exceptions:
ImageFormatException If the 2 images are not same size.

Definition at line 376 of file emdata_core.cpp.

References data, get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), nx, ny, nz, and update().

00377 {
00378         ENTERFUNC;
00379         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00380                 throw ImageFormatException( "images not same sizes");
00381         }
00382         else if( this->is_complex() || image.is_complex() )
00383         {
00384                 throw ImageFormatException( "Cannot addsquare() with complex images");
00385         }
00386         else {
00387 
00388                 const float *src_data = image.get_data();
00389                 size_t size = nxyz;
00390                 float* data = get_data();
00391 
00392                 for (size_t i = 0; i < size; i++) {
00393                         data[i] -= src_data[i]*src_data[i];
00394                 }
00395                 update();
00396         }
00397         EXITFUNC;
00398 }

void EMData::symplane0 EMData norm  ) 
 

Calculate Wiener summation from the inserted 2D slice put the summation into 3D grids using nearest neighbour approximation a.

Map the 2D coordinates of the interted slice into 3D grid using 3D transformation b. calculate 2D CTF_K^2 and CTF_K*F_K, and put them on the voxel of 3D volume c. count the number of images entering each boxel wptr3

Definition at line 1402 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

Referenced by EMAN::nn4Reconstructor::finish().

01402                                    {
01403         ENTERFUNC;
01404         int nxc = attr_dict["nxc"];
01405         int n = nxc*2;
01406         // let's treat the local data as a matrix
01407         vector<int> saved_offsets = get_array_offsets();
01408         set_array_offsets(0,1,1);
01409         for (int iza = 2; iza <= nxc; iza++) {
01410                 for (int iya = 2; iya <= nxc; iya++) {
01411                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01412                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01413                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01414                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01415                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01416                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01417                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01418                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01419                 }
01420         }
01421         for (int iya = 2; iya <= nxc; iya++) {
01422                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01423                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01424                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01425                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01426         }
01427         for (int iza = 2; iza <= nxc; iza++) {
01428                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01429                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01430                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01431                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01432         }
01433         EXITFUNC;
01434 }

void EMData::symplane0_ctf EMData w  ) 
 

Symmetrize plane 0 Modifies the current object.

Parameters:
w Normalization data.

Definition at line 2287 of file emdata_sparx.cpp.

References attr_dict.

Referenced by EMAN::nn4_ctfReconstructor::finish().

02293                                              {
02294                 for (int iya = 2; iya <= nxc; iya++) {
02295                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
02296                         (*w)(0,iya,iza) += (*w)(0,n-iya+2,n-iza+2);
02297                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
02298                         (*w)(0,n-iya+2,n-iza+2) = (*w)(0,iya,iza);
02299                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
02300                         (*w)(0,n-iya+2,iza) += (*w)(0,iya,n-iza+2);
02301                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
02302                         (*w)(0,iya,n-iza+2) = (*w)(0,n-iya+2,iza);
02303                 }
02304         }
02305         for (int iya = 2; iya <= nxc; iya++) {
02306                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
02307                 (*w)(0,iya,1) += (*w)(0,n-iya+2,1);
02308                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
02309                 (*w)(0,n-iya+2,1) = (*w)(0,iya,1);
02310         }
02311         for (int iza = 2; iza <= nxc; iza++) {
02312                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
02313                 (*w)(0,1,iza) += (*w)(0,1,n-iza+2);
02314                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
02315                 (*w)(0,1,n-iza+2) = (*w)(0,1,iza);
02316         }
02317         EXITFUNC;
02318 }
02319 

void EMData::symplane0_rect EMData w  ) 
 

Definition at line 2321 of file emdata_sparx.cpp.

References nx, ny, and nz.

Referenced by EMAN::nn4_ctf_rectReconstructor::finish(), and EMAN::nn4_rectReconstructor::finish().

02332                                              {
02333                 for (int iya = 2; iya <= nyc; iya++) {
02334                         cmplx(0,iya,iza) += conj(cmplx(0,ny-iya+2,nz-iza+2));
02335                         (*w)(0,iya,iza) += (*w)(0,ny-iya+2,nz-iza+2);
02336                         cmplx(0,ny-iya+2,nz-iza+2) = conj(cmplx(0,iya,iza));
02337                         (*w)(0,ny-iya+2,nz-iza+2) = (*w)(0,iya,iza);
02338                         cmplx(0,ny-iya+2,iza) += conj(cmplx(0,iya,nz-iza+2));
02339                         (*w)(0,ny-iya+2,iza) += (*w)(0,iya,nz-iza+2);
02340                         cmplx(0,iya,nz-iza+2) = conj(cmplx(0,ny-iya+2,iza));
02341                         (*w)(0,iya,nz-iza+2) = (*w)(0,ny-iya+2,iza);
02342                 }
02343         }
02344         for (int iya = 2; iya <= nyc; iya++) {
02345                 cmplx(0,iya,1) += conj(cmplx(0,ny-iya+2,1));
02346                 (*w)(0,iya,1) += (*w)(0,ny-iya+2,1);
02347                 cmplx(0,ny-iya+2,1) = conj(cmplx(0,iya,1));
02348                 (*w)(0,ny-iya+2,1) = (*w)(0,iya,1);
02349         }
02350         for (int iza = 2; iza <= nzc; iza++) {
02351                 cmplx(0,1,iza) += conj(cmplx(0,1,nz-iza+2));
02352                 (*w)(0,1,iza) += (*w)(0,1,nz-iza+2);
02353                 cmplx(0,1,nz-iza+2) = conj(cmplx(0,1,iza));
02354                 (*w)(0,1,nz-iza+2) = (*w)(0,1,iza);
02355         }
02356         EXITFUNC;
02357 }
02358 

void EMData::symplane1 EMData norm,
EMData norm2
 

Symmetrize plane 0 Modifies the current object.

Parameters:
norm Normalization data.
norm2 

Definition at line 1436 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

Referenced by EMAN::nnSSNR_Reconstructor::finish().

01436                                                   {
01437         ENTERFUNC;
01438         int nxc = attr_dict["nxc"];
01439         int n = nxc*2;
01440         vector<int> saved_offsets = get_array_offsets();
01441         set_array_offsets(0,1,1);
01442         for (int iza = 2; iza <= nxc; iza++) {
01443                 for (int iya = 2; iya <= nxc; iya++) {
01444                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01445                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01446                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01447                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01448                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01449                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01450                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01451                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01452                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01453                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01454                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01455                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01456                 }
01457         }
01458         for (int iya = 2; iya <= nxc; iya++) {
01459                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01460                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01461                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01462                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01463                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01464                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01465         }
01466         for (int iza = 2; iza <= nxc; iza++) {
01467                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01468                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01469                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01470                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01471                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01472                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01473         }
01474         EXITFUNC;
01475 }

void EMData::symplane2 EMData norm,
EMData norm2,
EMData norm3
 

Symmetrize plane 0 Modifies the current object.

Parameters:
norm Normalization data.
norm2 
norm3 

Definition at line 1477 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

Referenced by EMAN::nnSSNR_ctfReconstructor::finish().

01477                                                                  {
01478         ENTERFUNC;
01479         int nxc = attr_dict["nxc"];
01480         int n = nxc*2;
01481         vector<int> saved_offsets = get_array_offsets();
01482         set_array_offsets(0,1,1);
01483         for (int iza = 2; iza <= nxc; iza++) {
01484                 for (int iya = 2; iya <= nxc; iya++) {
01485                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01486                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01487                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01488                         (*wptr3)(0,iya,iza) += (*wptr3)(0,n-iya+2,n-iza+2);
01489 
01490                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01491                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01492                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01493                         (*wptr3)(0,n-iya+2,n-iza+2) = (*wptr3)(0,iya,iza);
01494 
01495                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01496                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01497                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01498                         (*wptr3)(0,n-iya+2,iza) += (*wptr3)(0,iya,n-iza+2);
01499 
01500                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01501                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01502                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01503                         (*wptr3)(0,iya,n-iza+2) = (*wptr3)(0,n-iya+2,iza);
01504                 }
01505         }
01506         for (int iya = 2; iya <= nxc; iya++) {
01507                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01508                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01509                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01510                 (*wptr3)(0,iya,1) += (*wptr3)(0,n-iya+2,1);
01511 
01512                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01513                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01514                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01515                 (*wptr3)(0,n-iya+2,1) = (*wptr3)(0,iya,1);
01516         }
01517         for (int iza = 2; iza <= nxc; iza++) {
01518                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01519                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01520                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01521                 (*wptr3)(0,1,iza) += (*wptr3)(0,1,n-iza+2);
01522 
01523                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01524                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01525                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01526                 (*wptr3)(0,1,n-iza+2) = (*wptr3)(0,1,iza);
01527         }
01528         EXITFUNC;
01529 }

EMData * EMData::symvol string  symmetry  ) 
 

Symmetrize volume in real space.

Parameters:
[in] symmetry Point group of the target volume.
Returns:
New symmetrized volume object.

Definition at line 983 of file emdata_sparx.cpp.

References EMAN::Transform::get_sym(), nx, ny, nz, rot_scale_trans(), set_size(), to_zero(), and update().

00983                                        {
00984         ENTERFUNC;
00985         int nsym = Transform::get_nsym(symString); // number of symmetries
00986         Transform sym;
00987         // set up output volume
00988         EMData *svol = new EMData;
00989         svol->set_size(nx, ny, nz);
00990         svol->to_zero();
00991         // actual work -- loop over symmetries and symmetrize
00992         for (int isym = 0; isym < nsym; isym++) {
00993                 Transform rm = sym.get_sym(symString, isym);
00994                 EMData* symcopy = this -> rot_scale_trans(rm);
00995                 *svol += (*symcopy);
00996                 delete symcopy;
00997         }
00998         *svol /=  ((float) nsym);
00999         svol->update();
01000         EXITFUNC;
01001         return svol;
01002 }

void EMData::to_one  ) 
 

set all the pixel values = 1.

Definition at line 1357 of file emdata_core.cpp.

References is_complex(), set_ri(), to_value(), and update().

Referenced by EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), EMAN::filt_erosion_(), get_circle_mean(), EMAN::Util::im_diff(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::operator/(), power(), and EMAN::Util::WTM().

01358 {
01359         ENTERFUNC;
01360 
01361         if (is_complex()) {
01362                 set_ri(true);
01363         }
01364         else {
01365                 set_ri(false);
01366         }
01367         to_value(1.0);
01368 
01369         update();
01370         EXITFUNC;
01371 }

void EMData::to_value const float &  value  ) 
 

set all the pixel values to a value.

Definition at line 1373 of file emdata_core.cpp.

References data, get_data(), get_size(), nx, ny, nz, to_value_cuda(), and update().

Referenced by get_clip(), wustl_mm::SkeletonMaker::VolumeData::InitializeVolumeData(), make_rotational_footprint_e1(), EMAN::FourierReconstructor::setup_seed(), to_one(), and to_zero().

01374 {
01375         ENTERFUNC;
01376 
01377 #ifdef EMAN2_USING_CUDA
01378         if(EMData::usecuda == 1 && cudarwdata){
01379                 to_value_cuda(cudarwdata, value, nx, ny, nz);
01380                 return;
01381         }
01382 #endif // EMAN2_USING_CUDA
01383         float* data = get_data();
01384 
01385         //the em_memset has segfault for >8GB image, use std::fill() instead, though may be slower
01386 //      if ( value != 0 ) std::fill(data,data+get_size(),value);
01387 //      else EMUtil::em_memset(data, 0, nxyz * sizeof(float)); // This might be faster, I don't know
01388 
01389         std::fill(data,data+get_size(),value);
01390 
01391         update();
01392         EXITFUNC;
01393 }

void EMData::to_zero  ) 
 

Set all the pixel value = 0.

Definition at line 1340 of file emdata_core.cpp.

References is_complex(), set_ri(), to_value(), and update().

Referenced by EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::FourierWeightAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctf_rectReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4_rectReconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nnSSNR_ctfReconstructor::buildNorm2Volume(), EMAN::nnSSNR_Reconstructor::buildNorm2Volume(), EMAN::nnSSNR_ctfReconstructor::buildNorm3Volume(), EMAN::nnSSNR_ctfReconstructor::buildNormVolume(), EMAN::nn4_ctf_rectReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nnSSNR_Reconstructor::buildNormVolume(), EMAN::nn4_rectReconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccfx(), EMAN::FourierReconstructor::clear(), EMAN::PointArray::distmx(), do_radon(), EMData(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_median_(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::Util::get_biggest_cluster(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), little_big_dot(), make_footprint(), EMAN::Util::move_points(), mult_radial(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_image(), real2FH(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), rotavg(), rotavg_i(), EMAN::rsconvolution(), EMAN::FourierReconstructor::setup(), symvol(), EMAN::Util::TwoDTestFunc(), EMAN::Util::WTF(), and EMAN::ReconstructorVolumeData::zero_memory().

01341 {
01342         ENTERFUNC;
01343 
01344         if (is_complex()) {
01345                 set_ri(true);
01346         }
01347         else {
01348                 set_ri(false);
01349         }
01350 
01351         //EMUtil::em_memset(get_data(), 0, nxyz * sizeof(float));
01352         to_value(0.0);
01353         update();
01354         EXITFUNC;
01355 }

void EMAN::EMData::transform const Transform t  )  [inline]
 

Transform the image.

Parameters:
t the transform object that describes the transformation to be applied to the image.

Definition at line 3386 of file emdata.h.

Referenced by EMAN::RTFSlowExhaustiveAligner::align(), common_lines_real(), do_radon(), EMAN::BackProjectionReconstructor::finish(), main(), EMAN::BackProjectionReconstructor::preprocess_slice(), EMAN::TestImageSinewave::process_inplace(), rotate(), and scale().

void EMData::translate const Vec3i translation  ) 
 

Translate this image.

integer only translation could be done faster, without interpolation.

Parameters:
translation The translation distance vector.

Definition at line 888 of file emdata.cpp.

References all_translation, process_inplace(), and EMAN::Vec3i.

00889 {
00890         ENTERFUNC;
00891 
00892         //if traslation is 0, do nothing
00893         if( translation[0] == 0 && translation[1] == 0 && translation[2] == 0) {
00894                 EXITFUNC;
00895                 return;
00896         }
00897 
00898         Dict params("trans",static_cast< vector<int> >(translation));
00899         process_inplace("xform.translate.int",params);
00900 
00901         // update() - clip_inplace does the update
00902         all_translation += translation;
00903 
00904         EXITFUNC;
00905 }

void EMData::translate int  dx,
int  dy,
int  dz
 

Translate this image.

integer only translation could be done faster, without interpolation.

Parameters:
dx Translation distance in x direction.
dy Translation distance in y direction.
dz Translation distance in z direction.

Definition at line 864 of file emdata.cpp.

References translate(), and EMAN::Vec3i.

00865 {
00866         ENTERFUNC;
00867         translate(Vec3i(dx, dy, dz));
00868         EXITFUNC;
00869 }

void EMData::translate const Vec3f translation  ) 
 

Translate this image.

Parameters:
translation The translation distance vector.

Definition at line 908 of file emdata.cpp.

References all_translation, process_inplace(), EMAN::Transform::set_trans(), t, and EMAN::Vec3f.

00909 {
00910         ENTERFUNC;
00911 
00912         if( translation[0] == 0.0f && translation[1] == 0.0f && translation[2] == 0.0f ) {
00913                 EXITFUNC;
00914                 return;
00915         }
00916 
00917         Transform* t = new Transform();
00918         t->set_trans(translation);
00919         process_inplace("xform",Dict("transform",t));
00920         delete t;
00921 
00922         all_translation += translation;
00923         EXITFUNC;
00924 }

void EMData::translate float  dx,
float  dy,
float  dz
 

Translate this image.

Parameters:
dx Translation distance in x direction.
dy Translation distance in y direction.
dz Translation distance in z direction.

Definition at line 872 of file emdata.cpp.

References EMAN::Vec3f.

Referenced by EMAN::FRM2DAligner::align(), frm_2d_Align(), main(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::PhaseToMassCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), and translate().

00873 {
00874         ENTERFUNC;
00875         int dx_ = Util::round(dx);
00876         int dy_ = Util::round(dy);
00877         int dz_ = Util::round(dz);
00878         if( ( (dx-dx_) == 0 ) && ( (dy-dy_) == 0 ) && ( (dz-dz_) == 0 )) {
00879                 translate(dx_, dy_, dz_);
00880         }
00881         else {
00882                 translate(Vec3f(dx, dy, dz));
00883         }
00884         EXITFUNC;
00885 }

void EMData::uncut_slice EMData *const   map,
const Transform tr
const
 

Opposite of the cut_slice().

It will take a slice and insert the data into a real 3D map. It does not interpolate, it uses the nearest neighbor.

Parameters:
map The real 3D map.
tr Orientation of the slice.
Exceptions:
NullPointerException If map is NULL.
ImageDimensionException If this image is not 2D.
ImageDimensionException If map image is not 3D.
ImageFormatException If this image is complex
ImageFormatException If map is complex
Author:
David Woolford (adapted from an original version by Steve Ludtke)
Date:
Feb 2008

Definition at line 4073 of file emdata.cpp.

References get_data(), get_ndim(), get_xsize(), get_ysize(), get_zsize(), ImageDimensionException, ImageFormatException, is_complex(), NullPointerException, nx, ny, update(), EMAN::Vec3f, x, and y.

04074 {
04075         ENTERFUNC;
04076 
04077         if (!map) throw NullPointerException("NULL image");
04078         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
04079         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
04080         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
04081         // Now check for complex images - this is really just being thorough
04082         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
04083         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
04084 
04085 //      Transform3D r( 0, 0, 0); // EMAN by default
04086 //      if (!ort) {
04087 //              ort = &r;
04088 //      }
04089 
04090         float *ddata = map->get_data();
04091         float *sdata = get_data();
04092 
04093         int map_nx = map->get_xsize();
04094         int map_ny = map->get_ysize();
04095         int map_nz = map->get_zsize();
04096         int map_nxy = map_nx * map_ny;
04097         float map_nz_round_limit = (float) map_nz-0.5f;
04098         float map_ny_round_limit = (float) map_ny-0.5f;
04099         float map_nx_round_limit = (float) map_nx-0.5f;
04100 /*
04101         Vec3f posttrans = ort->get_posttrans();
04102         Vec3f pretrans = ort->get_pretrans();*/
04103 
04104         int ymax = ny/2;
04105         if ( ny % 2 == 1 ) ymax += 1;
04106         int xmax = nx/2;
04107         if ( nx % 2 == 1 ) xmax += 1;
04108         for (int y = -ny/2; y < ymax; y++) {
04109                 for (int x = -nx/2; x < xmax; x++) {
04110                         Vec3f coord(x,y,0);
04111                         Vec3f soln = transform*coord;
04112 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
04113 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
04114 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
04115 //
04116 //                      xx += map_nx/2;
04117 //                      yy += map_ny/2;
04118 //                      zz += map_nz/2;
04119 //
04120                         float xx = soln[0]+map_nx/2;
04121                         float yy = soln[1]+map_ny/2;
04122                         float zz = soln[2]+map_nz/2;
04123 
04124                         // These 0.5 offsets are here because the round function rounds to the nearest whole number.
04125                         if (xx < -0.5 || yy < -0.5 || zz < -0.5 || xx >= map_nx_round_limit || yy >= map_ny_round_limit || zz >= map_nz_round_limit) continue;
04126 
04127                         size_t k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * (size_t)map_nxy;
04128                         int l = (x+nx/2) + (y+ny/2) * nx;
04129                         ddata[k] = sdata[l];
04130                 }
04131         }
04132 
04133         map->update();
04134         EXITFUNC;
04135 }

EMData * EMData::unwrap_largerR int  r1,
int  r2,
int  xs,
float  rmax_f
 

Definition at line 3972 of file emdata.cpp.

References get_data(), get_xsize(), get_ysize(), norm(), set_size(), t, update(), x, and y.

Referenced by EMAN::FRM2DAligner::align().

03972                                                                  {
03973         float *d,*dd;
03974         int do360=2;
03975         int rmax = (int)(rmax_f+0.5f);
03976         unsigned long i;
03977         unsigned int nvox=get_xsize()*get_ysize();//ming
03978         float maxmap=0.0f, minmap=0.0f;
03979         float temp=0.0f, diff_den=0.0f, norm=0.0f;
03980         float cut_off_va =0.0f;
03981 
03982         d=get_data();
03983         maxmap=-1000000.0f;
03984         minmap=1000000.0f;
03985         for (i=0;i<nvox;i++){
03986                 if(d[i]>maxmap) maxmap=d[i];
03987                 if(d[i]<minmap) minmap=d[i];
03988         }
03989         diff_den = maxmap-minmap;
03990         for(i=0;i<nvox;i++) {
03991                 temp = (d[i]-minmap)/diff_den;
03992                 if(cut_off_va != 0.0) {               // cut off the lowerset ?% noisy information
03993                         if(temp < cut_off_va)
03994                                 d[i] = 0.0f;                   // set the empty part density=0.0
03995                         else
03996                                 d[i] = temp-cut_off_va;
03997                 }
03998                 else    d[i] = temp;
03999         }
04000 
04001         for(i=0;i<nvox;i++) {
04002                 temp=d[i];
04003                 norm += temp*temp;
04004         }
04005         for(i=0;i<nvox;i++)             d[i] /= norm;                      //  y' = y/norm(y)
04006 
04007         if (xs<1) {
04008                 xs = (int) floor(do360*M_PI*get_ysize()/4); // ming
04009                 xs=Util::calc_best_fft_size(xs); // ming
04010         }
04011         if (r1<0) r1=0;
04012         float maxext=ceil(0.6f*std::sqrt((float)(get_xsize()*get_xsize()+get_ysize()*get_ysize())));// ming add std::
04013 
04014         if (r2<r1) r2=(int)maxext;
04015         EMData *ret = new EMData;
04016 
04017         ret->set_size(xs,r2+1,1);
04018 
04019         dd=ret->get_data();
04020 
04021         for (int i=0; i<xs; i++) {
04022                 float si=sin(i*M_PI*2/xs);
04023                 float co=cos(i*M_PI*2/xs);
04024                 for (int r=0; r<=maxext; r++) {
04025                         float x=(r+r1)*co+get_xsize()/2; // ming
04026                         float y=(r+r1)*si+get_ysize()/2; // ming
04027                         if(x<0.0 || x>=get_xsize()-1.0 || y<0.0 || y>=get_ysize()-1.0 || r>rmax){    //Ming , ~~~~ rmax need pass here
04028                                 for(;r<=r2;r++)                                   // here r2=MAXR
04029                                         dd[i+r*xs]=0.0;
04030                         break;
04031                     }
04032                         int x1=(int)floor(x);
04033                         int y1=(int)floor(y);
04034                         float t=x-x1;
04035                         float u=y-y1;
04036                         float f11= d[x1+y1*get_xsize()]; // ming
04037                         float f21= d[(x1+1)+y1*get_xsize()]; // ming
04038                         float f12= d[x1+(y1+1)*get_xsize()]; // ming
04039                         float f22= d[(x1+1)+(y1+1)*get_xsize()]; // ming
04040                         dd[i+r*xs] = (1-t)*(1-u)*f11+t*(1-u)*f21+t*u*f22+(1-t)*u*f12;
04041                 }
04042         }
04043         update();
04044         ret->update();
04045         return ret;
04046 }

void EMAN::EMData::update  )  [inline]
 

Mark EMData as changed, statistics, etc will be updated at need.

Definition at line 415 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), add(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), add_incoherent(), EMAN::Util::addn_img(), addsquare(), EMAN::TranslationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::ScaleAlignerABS::align_using_base(), amplitude(), ap2ri(), apply_radial_func(), average_circ_sub(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), calc_ccf(), calc_ccfx(), calc_mutual_correlation(), clip_inplace(), EMAN::Util::cml_prepare_line(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), common_lines(), common_lines_real(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), convolute(), copy_empty_head(), copy_head(), EMAN::Util::ctf2_rimg(), EMAN::Util::ctf_img(), EMAN::Util::ctf_rimg(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), EMAN::PointArray::distmx(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), EMData(), EMAN::Processor::EMFourierFilterFunc(), FH2F(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::AbsMaxMinAverager::finish(), EMAN::MinMaxAverager::finish(), EMAN::FourierWeightAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), EMAN::fourierproduct(), get_clip(), get_col(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_rotated_clip(), get_row(), get_top_half(), EMAN::Util::im_diff(), imag(), insert_clip(), insert_scaled_sum(), little_big_dot(), log(), log10(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), mult_radial(), EMAN::Util::mult_scalar(), EMAN::Util::Normalize_ring(), oneDfftPolar(), operator *=(), operator+=(), operator-=(), operator/=(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), phase(), power(), EMAN::BinarySkeletonizerProcessor::process(), EMAN::TransformProcessor::process(), EMAN::DirectionalSumProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::BinarySkeletonizerProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::TransformProcessor::process_inplace(), EMAN::MirrorProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImageNoiseGauss::process_inplace(), EMAN::TestImageNoiseUniformRand::process_inplace(), EMAN::TestImageEllipse::process_inplace(), EMAN::TestImageHollowEllipse::process_inplace(), EMAN::TestImageCirclesphere::process_inplace(), EMAN::TestImageSquarecube::process_inplace(), EMAN::TestImageSinewaveCircular::process_inplace(), EMAN::TestImageSinewave::process_inplace(), EMAN::TestImageSphericalWave::process_inplace(), EMAN::TestImagePureGaussian::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageAxes::process_inplace(), EMAN::TestImageGradient::process_inplace(), EMAN::TestImageGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::CtfSimProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AddNoiseProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::NonConvexProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::FFTResampleProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_binedimage(), read_image(), real(), real2complex(), real2FH(), EMAN::Util::reconstitute_image_mask(), EMAN::PointArray::replace_by_summation(), ri2ap(), ri2inten(), rotate_x(), rotavg(), rotavg_i(), EMAN::rsconvolution(), set_col(), EMAN::PointArray::set_from_density_map(), EMAN::Util::set_line(), set_row(), set_size(), EMAN::FourierReconstructor::setup(), sqrt(), sub(), EMAN::Util::sub_fav(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), symvol(), to_one(), to_value(), to_zero(), EMAN::Util::TwoDTestFunc(), uncut_slice(), unwrap(), unwrap_largerR(), EMAN::Util::update_fav(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00439                           : this routine will modify the 'this' and 'with' to contain

void EMData::update_stat  )  const [private]
 

Definition at line 2909 of file emdata.cpp.

References attr_dict, data, flags, get_data(), is_complex(), is_ri(), max, min, nx, ny, rdata, rot_fp, sqrt(), and v.

Referenced by get_attr(), get_attr_dict(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), and write_image().

02910 {
02911         ENTERFUNC;
02912 //      printf("update stat %f %d\n",(float)attr_dict["mean"],flags);
02913         if (!(flags & EMDATA_NEEDUPD))
02914         {
02915                 EXITFUNC;
02916                 return;
02917         }
02918         if (rdata==0) return;
02919 
02920         float* data = get_data();
02921         float max = -FLT_MAX;
02922         float min = -max;
02923 
02924         double sum = 0;
02925         double square_sum = 0;
02926 
02927         int step = 1;
02928         if (is_complex() && !is_ri()) {
02929                 step = 2;
02930         }
02931 
02932         int n_nonzero = 0;
02933 
02934         size_t size = (size_t)nx*ny*nz;
02935         for (size_t i = 0; i < size; i += step) {
02936                 float v = data[i];
02937         #ifdef _WIN32
02938                 max = _cpp_max(max,v);
02939                 min = _cpp_min(min,v);
02940         #else
02941                 max=std::max<float>(max,v);
02942                 min=std::min<float>(min,v);
02943         #endif  //_WIN32
02944                 sum += v;
02945                 square_sum += v * (double)(v);
02946                 if (v != 0) n_nonzero++;
02947         }
02948 
02949         size_t n = size / step;
02950         double mean = sum / n;
02951 
02952 #ifdef _WIN32
02953         float sigma = (float)std::sqrt( _cpp_max(0.0,(square_sum - sum*sum / n)/(n-1)));
02954         n_nonzero = _cpp_max(1,n_nonzero);
02955         double sigma_nonzero = std::sqrt( _cpp_max(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02956 #else
02957         float sigma = (float)std::sqrt(std::max<double>(0.0,(square_sum - sum*sum / n)/(n-1)));
02958         n_nonzero = std::max<int>(1,n_nonzero);
02959         double sigma_nonzero = std::sqrt(std::max<double>(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02960 #endif  //_WIN32
02961         double mean_nonzero = sum / n_nonzero; // previous version overcounted! G2
02962 
02963         attr_dict["minimum"] = min;
02964         attr_dict["maximum"] = max;
02965         attr_dict["mean"] = (float)(mean);
02966         attr_dict["sigma"] = (float)(sigma);
02967         attr_dict["square_sum"] = (float)(square_sum);
02968         attr_dict["mean_nonzero"] = (float)(mean_nonzero);
02969         attr_dict["sigma_nonzero"] = (float)(sigma_nonzero);
02970         attr_dict["is_complex"] = (int) is_complex();
02971         attr_dict["is_complex_ri"] = (int) is_ri();
02972 
02973         flags &= ~EMDATA_NEEDUPD;
02974 
02975         if (rot_fp != 0)
02976         {
02977                 delete rot_fp; rot_fp = 0;
02978         }
02979 
02980         EXITFUNC;
02981 //      printf("done stat %f %f %f\n",(float)mean,(float)max,(float)sigma);
02982 }

EMData * EMData::window_center int  l  ) 
 

Window the center of an image.

Often an image is padded with zeros for fourier interpolation. In that case the desired lxlxl volume (or lxl area) lies in the center of a larger volume (or area). This routine creates a new object that contains only the desired window. (This routine is a thin wrapper around get_clip.)

Parameters:
l Length of the window.
Returns:
An image object that has been windowed.

Definition at line 744 of file emdata.cpp.

References get_clip(), get_ndim(), ImageDimensionException, ImageFormatException, is_complex(), is_fftodd(), is_fftpadded(), and LOGERR.

Referenced by EMAN::FourierGriddingProjector::project3d(), and EMAN::Util::twoD_to_3D_ali().

00744                                    {
00745         ENTERFUNC;
00746         // sanity checks
00747         int n = nx;
00748         if (is_complex()) {
00749                 LOGERR("Need real-space data for window_center()");
00750                 throw ImageFormatException(
00751                         "Complex input image; real-space expected.");
00752         }
00753         if (is_fftpadded()) {
00754                 // image has been fft-padded, compute the real-space size
00755                 n -= (2 - int(is_fftodd()));
00756         }
00757         int corner = n/2 - l/2;
00758         int ndim = get_ndim();
00759         EMData* ret;
00760         switch (ndim) {
00761                 case 3:
00762                         if ((n != ny) || (n != nz)) {
00763                                 LOGERR("Need the real-space image to be cubic.");
00764                                 throw ImageFormatException(
00765                                                 "Need cubic real-space image.");
00766                         }
00767                         ret = get_clip(Region(corner, corner, corner, l, l, l));
00768                         break;
00769                 case 2:
00770                         if (n != ny) {
00771                                 LOGERR("Need the real-space image to be square.");
00772                                 throw ImageFormatException(
00773                                                 "Need square real-space image.");
00774                         }
00775                         //cout << "Using corner " << corner << endl;
00776                         ret = get_clip(Region(corner, corner, l, l));
00777                         break;
00778                 case 1:
00779                         ret = get_clip(Region(corner, l));
00780                         break;
00781                 default:
00782                         throw ImageDimensionException(
00783                                         "window_center only supports 1-d, 2-d, and 3-d images");
00784         }
00785         return ret;
00786         EXITFUNC;
00787 }

void EMData::write_data string  fsp,
size_t  loc,
const Region *const   area = 0,
const int  file_nx = 0,
const int  file_ny = 0,
const int  file_nz = 0
 

Dump the image pixel data in native byte order to a disk file.

Parameters:
fsp The filename to write the image data to
loc Location to seek to in the file before writing (size_t)
area The image region you want to read, default 0 means read the whole image
file_nx Image x size.
file_ny Image y size.
file_nz Image z size.
Author:
Steve Ludtke
Date:
Mon Jun 23, 2008

Definition at line 205 of file emdata_metadata.cpp.

References FileAccessException, get_data(), nx, ny, nz, portable_fseek(), and UnexpectedBehaviorException.

00205                                                                                                                         {
00206 
00207         if (area) {
00208                 struct stat fileinfo;
00209                 if ( stat(fsp.c_str(),&fileinfo) != 0 ) throw UnexpectedBehaviorException("To write an image using a region the file must already exist and be the correct dimensions");
00210         }
00211 
00212 
00213         FILE *f = 0;
00214         f=fopen(fsp.c_str(), "rb+");
00215         if (!f) f=fopen(fsp.c_str(), "wb");
00216         if (!f) throw FileAccessException(fsp);
00217         portable_fseek(f,loc,SEEK_SET);
00218         if (!area) {
00219                 if (fwrite(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00220         } else {
00221                 int fnx = nx;
00222                 if (file_nx != 0) fnx = file_nx;
00223                 int fny = ny;
00224                 if (file_ny != 0) fny = file_ny;
00225                 int fnz = nz;
00226                 if (file_nz != 0) fnz = file_nz;
00227 
00228                 EMUtil::process_region_io(get_data(), f, ImageIO::READ_WRITE,
00229                                                                   0, 4,fnx,fny,fnz,area);
00230         }
00231         fclose(f);
00232 //      printf("WROTE %s %ld %ld\n",fsp.c_str(),loc,nx*ny*nz);
00233 }

void EMData::write_image const string &  filename,
int  img_index = 0,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false,
const Region region = 0,
EMUtil::EMDataType  filestoragetype = EMUtil::EM_FLOAT,
bool  use_host_endian = true
 

write the header and data out to an image.

If the img_index = -1, append the image to the given image file.

If the given image file already exists, this image format only stores 1 image, and no region is given, then truncate the image file to zero length before writing data out. For header writing only, no truncation happens.

If a region is given, then write a region only.

Parameters:
filename The image file name.
img_index The nth image to write as.
imgtype Write to the given image format type. if not specified, use the 'filename' extension to decide.
header_only To write only the header or both header and data.
region Define the region to write to.
filestoragetype The image data type used in the output file.
use_host_endian To write in the host computer byte order.
Exceptions:
ImageFormatException 
ImageWriteException 

Definition at line 229 of file emdata_io.cpp.

References attr_dict, fft_shuffle(), EMAN::ImageIO::flush(), get_data(), ImageFormatException, ImageWriteException, is_complex(), is_shuffled(), EMAN::ImageIO::is_single_image_format(), LOGVAR, path, UnexpectedBehaviorException, update_stat(), EMAN::ImageIO::write_data(), and EMAN::ImageIO::write_header().

Referenced by ali3d_d(), append_image(), bispecRotTransInvDirect(), bispecRotTransInvN(), EMAN::OptVarianceCmp::cmp(), EMAN::PCA::dopca_ooc(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::TomoAverager::finish(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::StripeXYProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), unified(), and write_lst().

00234 {
00235         ENTERFUNC;
00236 
00237         struct stat fileinfo;
00238         if ( region && stat(filename.c_str(),&fileinfo) != 0 ) throw UnexpectedBehaviorException("To write an image using a region the file must already exist and be the correct dimensions");
00239 
00240         if (is_complex() && is_shuffled())
00241                 fft_shuffle();
00242 
00243         if (imgtype == EMUtil::IMAGE_UNKNOWN) {
00244                 const char *ext = strrchr(filename.c_str(), '.');
00245                 if (ext) {
00246                         ext++;
00247                         imgtype = EMUtil::get_image_ext_type(ext);
00248                 }
00249         }
00250         ImageIO::IOMode rwmode = ImageIO::READ_WRITE;
00251 
00252         //set "nx", "ny", "nz" and "changecount" in attr_dict, since they are taken out of attribute dictionary
00253         attr_dict["nx"] = nx;
00254         attr_dict["ny"] = ny;
00255         attr_dict["nz"] = nz;
00256         attr_dict["changecount"] = changecount;
00257 
00258 #ifndef HDFIO_CACHE
00259         if (Util::is_file_exist(filename)) {
00260                 LOGVAR("file exists");
00261                 if (!header_only && region == 0) {
00262                         ImageIO * tmp_imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY,
00263                                                                                                                 imgtype);
00264                         if (tmp_imageio->is_single_image_format()) {
00265                                 rwmode = ImageIO::WRITE_ONLY;
00266                         }
00267 
00268 #ifndef IMAGEIO_CACHE
00269                         if( tmp_imageio )
00270                         {
00271                                 delete tmp_imageio;
00272                                 tmp_imageio = 0;
00273                         }
00274 #endif  //IMAGEIO_CACHE
00275                 }
00276         }
00277 #endif  //HDFIO_CACHE
00278 
00279         LOGVAR("getimageio %d",rwmode);
00280         ImageIO *imageio = EMUtil::get_imageio(filename, rwmode, imgtype);
00281         if (!imageio) {
00282                 throw ImageFormatException("cannot create an image io");
00283         }
00284         else {
00285                 update_stat();
00286                 /* Let each image format decide how to deal with negative image_index*/
00287 //              if (img_index < 0) {
00288 //                      img_index = imageio->get_nimg();
00289 //              }
00290                 LOGVAR("header write %d",img_index);
00291 
00292                 switch(filestoragetype) {
00293                 case EMUtil::EM_UINT:
00294                         attr_dict["datatype"] = (int)EMUtil::EM_UINT;
00295                         break;
00296                 case EMUtil::EM_USHORT:
00297                         attr_dict["datatype"] = (int)EMUtil::EM_USHORT;
00298                         break;
00299                 case EMUtil::EM_SHORT:
00300                         attr_dict["datatype"] = (int)EMUtil::EM_SHORT;
00301                         break;
00302                 case EMUtil::EM_CHAR:
00303                         attr_dict["datatype"] = (int)EMUtil::EM_CHAR;
00304                         break;
00305                 case EMUtil::EM_UCHAR:
00306                         attr_dict["datatype"] = (int)EMUtil::EM_UCHAR;
00307                         break;
00308                 default:
00309                         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;; //default float
00310                 }
00311 
00312                 int err = imageio->write_header(attr_dict, img_index, region, filestoragetype,
00313                                                                                 use_host_endian);
00314                 if (err) {
00315                         throw ImageWriteException(filename, "imageio write header failed");
00316                 }
00317                 else {
00318                         if (!header_only) {
00319                                 if (imgtype == EMUtil::IMAGE_LST) {
00320                                         const char *reffile = attr_dict["LST.reffile"];
00321                                         if (strcmp(reffile, "") == 0) {
00322                                                 reffile = path.c_str();
00323                                         }
00324                                         int refn = attr_dict["LST.refn"];
00325                                         if (refn < 0) {
00326                                                 refn = pathnum;
00327                                         }
00328 
00329                                         const char *comment = attr_dict["LST.comment"];
00330                                         char *lstdata = new char[1024];
00331                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00332                                         if(strcmp(comment, "") != 0) {
00333                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00334                                         }
00335                                         else {
00336                                                 strcat(lstdata, "\n");
00337                                         }
00338                                         err = imageio->write_data((float*)lstdata, img_index,
00339                                                                                           region, filestoragetype, use_host_endian);
00340                                         if( lstdata )
00341                                         {
00342                                                 delete [] lstdata;
00343                                                 lstdata = 0;
00344                                         }
00345                                 }
00346                                 if (imgtype == EMUtil::IMAGE_LSTFAST) {
00347                                         const char *reffile = attr_dict["LST.reffile"];
00348                                         if (strcmp(reffile, "") == 0) {
00349                                                 reffile = path.c_str();
00350                                         }
00351                                         int refn = attr_dict["LST.refn"];
00352                                         if (refn < 0) {
00353                                                 refn = pathnum;
00354                                         }
00355 
00356                                         const char *comment = attr_dict["LST.comment"];
00357                                         char *lstdata = new char[1024];
00358                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00359                                         if(strcmp(comment, "") != 0) {
00360                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00361                                         }
00362                                         else {
00363                                                 strcat(lstdata, "\n");
00364                                         }
00365                                         err = imageio->write_data((float*)lstdata, img_index,
00366                                                                                           region, filestoragetype, use_host_endian);
00367                                         if( lstdata )
00368                                         {
00369                                                 delete [] lstdata;
00370                                                 lstdata = 0;
00371                                         }
00372                                 }
00373                                 else {
00374                                         err = imageio->write_data(get_data(), img_index, region, filestoragetype,
00375                                                                                           use_host_endian);
00376                                 }
00377                                 if (err) {
00378                                         imageio->flush();
00379                                         throw ImageWriteException(filename, "imageio write data failed");
00380                                 }
00381                         }
00382                 }
00383         }
00384         //PNG image already do cleaning in write_data function.
00385         if (!(imgtype == EMUtil::IMAGE_PNG)) {
00386                 imageio->flush();
00387         }
00388 
00389 #ifndef IMAGEIO_CACHE
00390         if( imageio )
00391         {
00392 #ifdef HDFIO_CACHE
00393                 if(dynamic_cast<HdfIO2*>(imageio)==NULL && dynamic_cast<HdfIO*>(imageio)==NULL) {
00394 #endif  //HDFIO_CACHE
00395                         delete imageio;
00396                         imageio = 0;
00397 #ifdef HDFIO_CACHE
00398                 }
00399 #endif  //HDFIO_CACHE
00400         }
00401 #endif  //IMAGEIO_CACHE
00402 
00403         EXITFUNC;
00404 }

void EMData::write_lst const string &  filename,
const string &  reffile = "",
int  refn = -1,
const string &  comment = ""
 

Append data to a LST image file.

Parameters:
filename The LST image file name.
reffile Reference file name.
refn The reference file number.
comment The comment to the added reference file.
See also:
lstio.h

Definition at line 416 of file emdata_io.cpp.

References attr_dict, and write_image().

00418 {
00419         ENTERFUNC;
00420         attr_dict["LST.reffile"] = reffile;
00421         attr_dict["LST.refn"] = refn;
00422         attr_dict["LST.comment"] = comment;
00423         write_image(filename, -1, EMUtil::IMAGE_LST, false);
00424         EXITFUNC;
00425 }

vector< Dict > EMData::xform_align_nbest const string &  aligner_name,
EMData to_img,
const Dict params = Dict(),
const unsigned int  nsoln = 1,
const string &  cmp_name = "dot",
const Dict cmp_params = Dict()
 

Align this image with another image, return the parameters of the "n best" solutions See Aligner::xform_align_nbest for more comments.

Parameters:
aligner_name Alignment algorithm name.
to_img The image 'this' image aligns to.
params Alignment algorithm parameters in a keyed dictionary.
nsoln the number of solutions you want to receive in the return vector.
cmp_name Comparison algorithm used in alignment.
cmp_params Parameter dictionary for comparison algorithm.
Exceptions:
NotExistingObjectError If the alignment algorithm doesn't exist.
Returns:
an ordered vector of Dicts of length nsoln. The Dicts in the vector have keys "score" (i.e. correlation score) and "xform.align3d" (Transform containing the alignment)

Definition at line 140 of file emdata_modular.cpp.

References EMAN::Aligner::xform_align_nbest().

00143 {
00144         ENTERFUNC;
00145         Aligner *a = Factory < Aligner >::get(aligner_name, params);
00146         vector<Dict> result;
00147         if (a) {
00148                 result = a->xform_align_nbest(this,to_img,nsoln,cmp_name,cmp_params);
00149         }
00150 
00151         return result;
00152 }

void EMData::zero_corner_circulant const int  radius = 0  ) 
 

Zero the pixels in the bottom left corner of the image If radius is greater than 1, than circulant zeroing occurs assuming that the center of operation starts in the bottom left corner and proceed outwards to the NE and backwards in a circulant fashion towards the SW.

Intended to zero the area corresponding to the middle of the image, as generated by calc_ccf

Parameters:
radius the radius to the zeroing operation
Exceptions:
ImageDimensionException if nx > 1 and nx < 2*radius + 1
ImageDimensionException if ny > 1 and ny < 2*radius + 1
ImageDimensionException if nz > 1 and nz < 2*radius + 1

Definition at line 1432 of file emdata.cpp.

References get_value_at_wrap(), ImageDimensionException, nx, ny, nz, x, and y.

Referenced by EMAN::TranslationalAligner::align().

01433 {
01434         if ( nz > 1 && nz < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nz is too small");
01435         if ( ny > 1 && ny < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - ny is too small");
01436         if ( nx > 1 && nx < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nx is too small");
01437 
01438         int it_z = radius;
01439         int it_y = radius;
01440         int it_x = radius;
01441 
01442         if ( nz == 1 ) it_z = 0;
01443         if ( ny == 1 ) it_y = 0;
01444         if ( nx == 1 ) it_z = 0;
01445 
01446         if ( nz == 1 && ny == 1 )
01447         {
01448                 for ( int x = -it_x; x <= it_x; ++x )
01449                         get_value_at_wrap(x) = 0;
01450 
01451         }
01452         else if ( nz == 1 )
01453         {
01454                 for ( int y = -it_y; y <= it_y; ++y)
01455                         for ( int x = -it_x; x <= it_x; ++x )
01456                                 get_value_at_wrap(x,y) = 0;
01457         }
01458         else
01459         {
01460                 for( int z = -it_z; z <= it_z; ++z )
01461                         for ( int y = -it_y; y <= it_y; ++y)
01462                                 for ( int x = -it_x; x < it_x; ++x )
01463                                         get_value_at_wrap(x,y,z) = 0;
01464 
01465         }
01466 
01467 }


Friends And Related Function Documentation

friend class GLUtil [friend]
 

Definition at line 89 of file emdata.h.


Member Data Documentation

Vec3f EMAN::EMData::all_translation [private]
 

translation from the original location

Definition at line 3934 of file emdata.h.

Referenced by copy_empty_head(), copy_head(), operator=(), and translate().

Dict EMAN::EMData::attr_dict [mutable, private]
 

to store all image header info

Definition at line 3913 of file emdata.h.

Referenced by clip_inplace(), copy_empty_head(), copy_head(), del_attr(), depad(), depad_corner(), EMData(), get_attr(), get_attr_default(), get_attr_dict(), get_clip(), get_ctf(), get_top_half(), nn(), nn_ctf(), nn_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), operator=(), read_binedimage(), read_image(), save_byteorder_to_dict(), scale_pixel(), set_attr(), set_attr_dict_explicit(), set_attr_python(), set_ctf(), set_xyz_origin(), symplane0(), symplane0_ctf(), symplane1(), symplane2(), update_stat(), write_image(), and write_lst().

int EMAN::EMData::changecount [private]
 

Definition at line 3926 of file emdata.h.

Referenced by get_attr(), and operator=().

int EMAN::EMData::flags [mutable, private]
 

flags

Definition at line 3924 of file emdata.h.

Referenced by copy_empty_head(), copy_head(), get_attr(), operator=(), and update_stat().

int EMAN::EMData::nx [private]
 

image size

Definition at line 3928 of file emdata.h.

Referenced by absi(), add(), add_complex_at(), add_incoherent(), addsquare(), amplitude(), ap2ri(), average_circ_sub(), calc_az_dist(), calc_ccf(), calc_ccfx(), calc_center_density(), calc_dist(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_highest_locations(), calc_hist(), calc_max_index(), calc_max_location(), calc_max_location_wrap(), calc_min_index(), calc_min_location(), calc_n_highest_locations(), calc_sigma_diff(), cconj(), clip_inplace(), cog(), compute_missingwedge(), copy_head(), cut_slice(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), dot_rotate_translate(), downsample(), EMData(), equal(), extract_box(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), extractpoint(), fft_shuffle(), FH2F(), fouriergridrot2d(), fouriergridrot_shift2d(), get_2dcview(), get_3dcview(), get_3dcviewptr(), get_attr(), get_circle_mean(), get_clip(), get_col(), get_complex_at(), get_complex_index(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), get_pixel_conv(), get_pixel_conv7(), get_pixel_filtered(), get_rotated_clip(), get_row(), get_top_half(), get_value_at_wrap(), imag(), insert_clip(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), insert_scaled_sum(), little_big_dot(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), mult(), mult_complex_efficient(), mult_radial(), nn_SSNR(), nn_SSNR_ctf(), operator=(), peak_search(), phase(), print_image(), read_binedimage(), read_image(), real(), real2complex(), real2FH(), render_amp24(), render_ap24(), ri2ap(), ri2inten(), rot_scale_conv(), rot_scale_conv7(), rot_scale_conv_new(), rot_scale_conv_new_3D(), rot_scale_conv_new_background(), rot_scale_conv_new_background_3D(), rot_scale_trans(), rot_scale_trans2D(), rot_scale_trans2D_background(), rot_scale_trans_background(), rotate_x(), rotavg(), rotavg_i(), set_col(), set_complex_at(), set_data_pickle(), set_row(), set_size(), setup4slice(), sget_value_at(), shuffle_pad_corner(), sub(), subsquare(), symplane0_rect(), symvol(), to_value(), uncut_slice(), unwrap(), update_stat(), write_data(), and zero_corner_circulant().

int EMAN::EMData::nxy [private]
 

image size

Definition at line 3928 of file emdata.h.

Referenced by calc_highest_locations(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), extract_box(), get_edge_mean(), mult_complex_efficient(), set_size(), and setup4slice().

size_t EMAN::EMData::nxyz [private]
 

Definition at line 3929 of file emdata.h.

Referenced by insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), and set_size().

int EMAN::EMData::ny [private]
 

image size

Definition at line 3928 of file emdata.h.

Referenced by absi(), add(), add_complex_at(), add_incoherent(), addsquare(), amplitude(), ap2ri(), average_circ_sub(), calc_az_dist(), calc_ccf(), calc_ccfx(), calc_center_density(), calc_dist(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_hist(), calc_max_location_wrap(), calc_sigma_diff(), clip_inplace(), cog(), compute_missingwedge(), copy_head(), cut_slice(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), dot_rotate_translate(), downsample(), EMData(), equal(), extract_box(), fft_shuffle(), FH2F(), get_2dcview(), get_2dview(), get_attr(), get_circle_mean(), get_clip(), get_col(), get_complex_at(), get_complex_index(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), get_pixel_conv(), get_pixel_conv7(), get_pixel_filtered(), get_rotated_clip(), get_top_half(), get_value_at_wrap(), getconvpt2d_kbi0(), imag(), insert_clip(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), little_big_dot(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), mult(), mult_radial(), nn(), nn_ctf(), nn_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), operator=(), phase(), print_image(), read_binedimage(), read_image(), real(), real2complex(), real2FH(), render_amp24(), render_ap24(), ri2ap(), ri2inten(), rot_scale_conv(), rot_scale_conv7(), rot_scale_conv_new(), rot_scale_conv_new_3D(), rot_scale_conv_new_background(), rot_scale_conv_new_background_3D(), rot_scale_trans(), rot_scale_trans2D(), rot_scale_trans2D_background(), rot_scale_trans_background(), rotavg(), rotavg_i(), set_complex_at(), set_data_pickle(), set_size(), setup4slice(), sget_value_at(), sub(), subsquare(), symplane0_rect(), symvol(), to_value(), uncut_slice(), unwrap(), update_stat(), write_data(), and zero_corner_circulant().

int EMAN::EMData::nz [private]
 

image size

Definition at line 3928 of file emdata.h.

Referenced by absi(), add(), add_complex_at(), addsquare(), amplitude(), ap2ri(), average_circ_sub(), calc_ccf(), calc_ccfx(), calc_fast_sigma_image(), calc_flcf(), calc_fourier_shell_correlation(), calc_max_location_wrap(), calc_radial_dist(), cog(), compute_missingwedge(), copy_head(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), downsample(), EMData(), extract_box(), fft_shuffle(), FH2F(), get_3dcview(), get_3dcviewptr(), get_3dview(), get_circle_mean(), get_clip(), get_complex_at(), get_complex_index(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), get_pixel_conv7(), get_pixel_filtered(), get_rotated_clip(), get_top_half(), get_value_at_wrap(), imag(), insert_clip(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), little_big_dot(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), mult(), mult_radial(), nn_SSNR(), nn_SSNR_ctf(), operator=(), phase(), print_image(), read_binedimage(), read_image(), real(), real2complex(), real2FH(), rot_scale_conv(), rot_scale_conv7(), rot_scale_conv_new(), rot_scale_conv_new_3D(), rot_scale_conv_new_background(), rot_scale_conv_new_background_3D(), rot_scale_trans(), rot_scale_trans2D(), rot_scale_trans2D_background(), rot_scale_trans_background(), rotavg(), rotavg_i(), set_complex_at(), set_data_pickle(), set_size(), setup4slice(), sub(), subsquare(), symplane0_rect(), symvol(), to_value(), write_data(), and zero_corner_circulant().

string EMAN::EMData::path [private]
 

Definition at line 3937 of file emdata.h.

Referenced by copy_empty_head(), copy_head(), get_clip(), operator=(), and write_image().

int EMAN::EMData::pathnum [private]
 

Definition at line 3938 of file emdata.h.

Referenced by copy_empty_head(), copy_head(), get_clip(), and operator=().

float* EMAN::EMData::rdata [mutable, private]
 

image real data

Definition at line 3915 of file emdata.h.

Referenced by add_complex_at(), clip_inplace(), cog(), do_fft_inplace(), do_ift(), EMData(), free_memory(), free_rdata(), get_complex_at(), operator=(), phase_cog(), read_image(), set_complex_at(), set_size(), and update_stat().

EMData* EMAN::EMData::rot_fp [mutable, private]
 

This is a cached rotational footprint, can save much time.

Definition at line 3941 of file emdata.h.

Referenced by EMData(), free_memory(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), operator=(), and update_stat().

float* EMAN::EMData::supp [private]
 

supplementary data array

Definition at line 3917 of file emdata.h.

Referenced by free_memory(), set_size(), set_supp_pickle(), and setup4slice().

int EMData::totalalloc = 0 [static]
 

Definition at line 72 of file emdata.cpp.

int EMAN::EMData::xoff [private]
 

array index offsets

Definition at line 3931 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::yoff [private]
 

array index offsets

Definition at line 3931 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::zoff [private]
 

array index offsets

Definition at line 3931 of file emdata.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:00 2013 for EMAN2 by  doxygen 1.3.9.1