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 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 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)
 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
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, 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, 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, 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)
 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, 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().
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.

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 3850 of file emdata.h.

enum EMAN::EMData::FFTPLACE
 

Enumeration values:
FFT_OUT_OF_PLACE 
FFT_IN_PLACE 

Definition at line 3178 of file emdata.h.

enum EMAN::EMData::WINDOWPLACE
 

Enumeration values:
WINDOW_OUT_OF_PLACE 
WINDOW_IN_PLACE 

Definition at line 3179 of file emdata.h.


Constructor & Destructor Documentation

EMData::EMData  ) 
 

Construct an empty EMData instance.

It has no image data.

Definition at line 73 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(), copy(), copy_empty_head(), copy_head(), do_radon(), EMData(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), 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_images(), read_images_ext(), real(), real2complex(), rotavg(), rotavg_i(), and unwrap().

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

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

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

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

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),
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 1153 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().

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

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 336 of file emdata_core.cpp.

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

00337 {
00338         ENTERFUNC;
00339         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00340                 throw ImageFormatException( "images not same sizes");
00341         }
00342         else if( (is_real()^image.is_real()) == true )
00343         {
00344                 throw ImageFormatException( "not support add between real image and complex image");
00345         }
00346         else {
00347 
00348                 const float *src_data = image.get_data();
00349                 size_t size = nxyz;
00350                 float* data = get_data();
00351 
00352                 for (size_t i = 0; i < size; i++) {
00353                         data[i] += src_data[i];
00354                 }
00355                 update();
00356         }
00357         EXITFUNC;
00358 }

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::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 
00281 //#ifdef EMAN2_USING_CUDA
00282 //                      if ( gpu_operation_preferred () && !keepzero ) {
00283 //                              EMDataForCuda tmp = get_data_struct_for_cuda();
00284 //                              emdata_processor_add(&tmp,f);
00285 //                              gpu_update();
00286 //                              EXITFUNC;
00287 //                              return;
00288 //                      }
00289 //#endif // EMAN2_USING_CUDA
00290                         size_t size = nxyz;
00291                         if (keepzero) {
00292                                 for (size_t i = 0; i < size; i++) {
00293                                         if (data[i]) data[i] += f;
00294                                 }
00295                         }
00296                         else {
00297                                 for (size_t i = 0; i < size; i++) {
00298                                         data[i] += f;
00299                                 }
00300                         }
00301                         update();
00302                 }
00303         }
00304         else if( is_complex() )
00305         {
00306                 if( f!=0 )
00307                 {
00308                         update();
00309                         size_t size = (size_t)nx*ny*nz; //size of data
00310                         if( keepzero )
00311                         {
00312                                 for(size_t i=0; i<size; i+=2)
00313                                 {
00314                                         if (data[i]) data[i] += f;
00315                                 }
00316                         }
00317                         else
00318                         {
00319                                 for(size_t i=0; i<size; i+=2)
00320                                 {
00321                                         data[i] += f;
00322                                 }
00323                         }
00324                 }
00325         }
00326         else
00327         {
00328                 throw ImageFormatException("This image is neither a real nor a complex image.");
00329         }
00330         update();
00331         EXITFUNC;
00332 }

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

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

03147 {
03148         ENTERFUNC;
03149 
03150         if (!obj) {
03151                 LOGERR("NULL image");
03152                 throw NullPointerException("NULL image");
03153         }
03154 
03155         if (!obj->is_complex() || !is_complex()) {
03156                 throw ImageFormatException("complex images only");
03157         }
03158 
03159         if (!EMUtil::is_same_size(this, obj)) {
03160                 throw ImageFormatException("images not same size");
03161         }
03162 
03163         ri2ap();
03164         obj->ri2ap();
03165 
03166         float *dest = get_data();
03167         float *src = obj->get_data();
03168         size_t size = (size_t)nx * ny * nz;
03169         for (size_t j = 0; j < size; j += 2) {
03170 #ifdef  _WIN32
03171                 dest[j] = (float) _hypot(src[j], dest[j]);
03172 #else
03173                 dest[j] = (float) hypot(src[j], dest[j]);
03174 #endif  //_WIN32
03175                 dest[j + 1] = 0;
03176         }
03177 
03178         obj->update();
03179         update();
03180         EXITFUNC;
03181 }

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 361 of file emdata_core.cpp.

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

00362 {
00363         ENTERFUNC;
00364         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00365                 throw ImageFormatException( "images not same sizes");
00366         }
00367         else if( this->is_complex() || image.is_complex() )
00368         {
00369                 throw ImageFormatException( "Cannot addsquare() with complex images");
00370         }
00371         else {
00372 
00373                 const float *src_data = image.get_data();
00374                 size_t size = nxyz;
00375                 float* data = get_data();
00376 
00377                 for (size_t i = 0; i < size; i++) {
00378                         data[i] += src_data[i]*src_data[i];
00379                 }
00380                 update();
00381         }
00382         EXITFUNC;
00383 }

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(), 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 1220 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().

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

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 EMAN::CtfAverager::add_image(), 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::GaussFFTProjector::project3d(), and ri2inten().

00957 {
00958         ENTERFUNC;
00959 
00960         if (!is_complex() || is_ri()) {
00961                 return;
00962         }
00963 
00964 //#ifdef EMAN2_USING_CUDA
00965 //      if (gpu_operation_preferred()) {
00966 //              EMDataForCuda tmp = get_data_struct_for_cuda();
00967 //              emdata_ap2ri(&tmp);
00968 //              set_ri(true);
00969 //              gpu_update();
00970 //              EXITFUNC;
00971 //              return;
00972 //      }
00973 //#endif
00974 
00975         Util::ap2ri(get_data(), (size_t)nx * ny * nz);
00976         set_ri(true);
00977         update();
00978         EXITFUNC;
00979 }

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 304 of file emdata_io.cpp.

References write_image().

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

00306 {
00307         ENTERFUNC;
00308         write_image(filename, -1, imgtype, header_only, 0);
00309         EXITFUNC;
00310 }

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 2567 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::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), and EMAN::FourierProcessor::process_inplace().

02568 {
02569         ENTERFUNC;
02570 
02571         if (!is_complex()) throw ImageFormatException("apply_radial_func requires a complex image");
02572 
02573         int n = static_cast < int >(array.size());
02574 
02575         if (n*step>2.0) printf("Warning, apply_radial_func takes x0 and step with respect to Nyquist (0.5)\n");
02576 
02577 //      printf("%f %f %f\n",array[0],array[25],array[50]);
02578 
02579         ap2ri();
02580 
02581         size_t ndims = get_ndim();
02582         float * data = get_data();
02583         if (ndims == 2) {
02584                 int k = 0;
02585                 for (int j = 0; j < ny; j++) {
02586                         for (int i = 0; i < nx; i += 2, k += 2) {
02587                                 float r;
02588 #ifdef  _WIN32
02589                                 if (j<ny/2) r = (float)_hypot(i/(float)(nx*2), j/(float)ny);
02590                                 else r = (float)_hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02591 #else
02592                                 if (j<ny/2) r = (float)hypot(i/(float)(nx*2), j/(float)ny);
02593                                 else r = (float)hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02594 #endif  //_WIN32
02595                                 r = (r - x0) / step;
02596 
02597                                 int l = 0;
02598                                 if (interp) {
02599                                         l = (int) floor(r);
02600                                 }
02601                                 else {
02602                                         l = (int) floor(r + 1);
02603                                 }
02604 
02605 
02606                                 float f = 0;
02607                                 if (l >= n - 2) {
02608                                         f = array[n - 1];
02609                                 }
02610                                 else {
02611                                         if (interp) {
02612                                                 r -= l;
02613                                                 f = (array[l] * (1.0f - r) + array[l + 1] * r);
02614                                         }
02615                                         else {
02616                                                 f = array[l];
02617                                         }
02618                                 }
02619 
02620                                 data[k] *= f;
02621                                 data[k + 1] *= f;
02622                         }
02623                 }
02624         }
02625         else if (ndims == 3) {
02626                 int k = 0;
02627                 for (int m = 0; m < nz; m++) {
02628                         float mnz;
02629                         if (m<nz/2) mnz=m*m/(float)(nz*nz);
02630                         else { mnz=(nz-m)/(float)nz; mnz*=mnz; }
02631 
02632                         for (int j = 0; j < ny; j++) {
02633                                 float jny;
02634                                 if (j<ny/2) jny= j*j/(float)(ny*ny);
02635                                 else { jny=(ny-j)/(float)ny; jny*=jny; }
02636 
02637                                 for (int i = 0; i < nx; i += 2, k += 2) {
02638                                         float r = std::sqrt((i * i / (nx*nx*4.0f)) + jny + mnz);
02639                                         r = (r - x0) / step;
02640 
02641                                         int l = 0;
02642                                         if (interp) {
02643                                                 l = (int) floor(r);
02644                                         }
02645                                         else {
02646                                                 l = (int) floor(r + 1);
02647                                         }
02648 
02649 
02650                                         float f = 0;
02651                                         if (l >= n - 2) {
02652                                                 f = array[n - 1];
02653                                         }
02654                                         else {
02655                                                 if (interp) {
02656                                                         r -= l;
02657                                                         f = (array[l] * (1.0f - r) + array[l + 1] * r);
02658                                                 }
02659                                                 else {
02660                                                         f = array[l];
02661                                                 }
02662                                         }
02663 
02664                                         data[k] *= f;
02665                                         data[k + 1] *= f;
02666                                 }
02667                         }
02668                 }
02669 
02670         }
02671 
02672         update();
02673         EXITFUNC;
02674 }

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

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

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

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 1061 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().

01062 {
01063 
01064         int EndP = this -> get_xsize(); // length(fTrueVec);
01065         int Mid  = (int) ((1+EndP)/2);
01066         int End = 2*Mid-1;
01067 
01068         int CountxyMax = End*End;
01069 
01070         int   *SortfkInds       = new    int[CountxyMax];
01071         int   *kVecX            = new    int[CountxyMax];
01072         int   *kVecY            = new    int[CountxyMax];
01073         float *fkVecR           = new  float[CountxyMax];
01074         float *fkVecI           = new  float[CountxyMax];
01075         float *absD1fkVec       = new  float[CountxyMax];
01076         float *absD1fkVecSorted = new  float[CountxyMax];
01077 
01078         float *jxjyatan2         = new  float[End*End]; //  jxjyatan2[jy*End + jx]  = atan2(jy+1-Mid , jx +1 -Mid);
01079 
01080         EMData * ThisCopy = new EMData(End,End);
01081 
01082         for (int jx=0; jx <End ; jx++) {
01083                 for (int jy=0; jy <End ; jy++) {
01084                         float ValNow = this -> get_value_at(jx,jy);
01085                         ThisCopy -> set_value_at(jx,jy,ValNow);
01086 //              cout<< " jxM= " << jx+1<<" jyM= " << jy+1<< "ValNow" << ValNow << endl; //    Works
01087         }}
01088 
01089 
01090         EMData* fk = ThisCopy -> do_fft();
01091         fk          ->process_inplace("xform.fourierorigin.tocenter");
01092 
01093 //      EMData* fk
01094         EMData* fkRCopy = new EMData(End,End);
01095         EMData* fkICopy = new EMData(End,End);
01096         EMData* fkCopy  = new EMData(End,End);
01097 
01098 
01099         for  (int jCount= 0; jCount<End*End; jCount++) {
01100 //              jCount = jy*End + jx;
01101                 int jx             = jCount%End ;
01102                 int jy             = (jCount-jx)/End ;
01103                 jxjyatan2[jCount]  = atan2((float)(jy+1-Mid) , (float)(jx +1-Mid));
01104         }
01105 
01106 
01107         for (int kEx= 0; kEx<2*Mid; kEx=kEx+2) { // kEx twice the value of the Fourier
01108                                                 // x variable: EMAN index for real, imag
01109                 int kx    = kEx/2;              // kx  is  the value of the Fourier variable
01110                 int kIx   = kx+Mid-1; // This is the value of the index for a matlab image (-1)
01111                 int kCx   =  -kx ;
01112                 int kCIx  = kCx+ Mid-1 ;
01113                 for (int kEy= 0 ; kEy<End; kEy++) { // This is the value of the EMAN index
01114                         int kIy              =  kEy       ; //  This is the value of the index for a matlab image (-1)
01115                         int ky               =  kEy+1-Mid; // (kEy+ Mid-1)%End - Mid+1 ;  // This is the actual value of the Fourier variable
01116                         float realVal        =  fk -> get_value_at(kEx  ,kEy) ;
01117                         float imagVal        =  fk -> get_value_at(kEx+1,kEy) ;
01118                         float absVal         =  ::sqrt(realVal*realVal+imagVal*imagVal);
01119                         float fkAng          =  atan2(imagVal,realVal);
01120 
01121                         float NewRealVal   ;
01122                         float NewImagVal   ;
01123                         float AngMatlab    ;
01124 
01125                         if (kIx==Mid-1) {
01126 //                              AngMatlab = -fkAng - 2.*M_PI*(kIy+ 1-Mid)*(Mid)/End;
01127 //                      cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << AngMatlab << endl;
01128                         }
01129 
01130                         if (kIx>Mid-1){
01131 //                      cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << AngMatlab << endl;
01132                         }
01133 
01134                         AngMatlab = fkAng - 2.0f*M_PI*(kx +ky)*(Mid)/End;
01135                         NewRealVal  =   absVal*cos(AngMatlab);
01136                         NewImagVal  =   absVal*sin(AngMatlab);
01137 
01138 
01139                         fkVecR[kIy+kIx *End] =  NewRealVal ;
01140                         fkVecR[kIy+kCIx*End] =  NewRealVal ;
01141                         fkVecI[kIy+kIx *End] =  NewImagVal ;
01142                         fkVecI[kIy+kCIx*End] = -NewImagVal ;
01143                         absD1fkVec[kIy + kIx  *End] = absVal;
01144                         absD1fkVec[kIy + kCIx *End] = absVal;
01145                         kVecX[kIy+kIx  *End] =  kx      ;
01146                         kVecX[kIy+kCIx *End] =  kCx    ;
01147                         kVecY[kIy+kIx  *End] =  ky     ;
01148                         kVecY[kIy+kCIx *End] =  ky     ;
01149 //                      printf("kx=%d,ky=%d,tempVal =%f+ i %4.2f \n",kx,ky,realVal,imagVal );
01150 //                      cout << "kx = " << kx << "; ky = "<< ky << "; val is" << realVal<<"+ i "<<imagVal<< endl;
01151 
01152 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; fkAng*9/ 2pi is " << fkAng*9/2/M_PI<<  endl;
01153 //                      cout << "kIMx = "<< kIx+1 << "; kIMy = "<< kIy+1 <<"; absval is " << absVal<<  "; realval is " << NewRealVal<< "; imagval is " << NewImagVal<< endl;
01154                         fkCopy  -> set_value_at(kIx ,kIy, absVal);
01155                         fkCopy  -> set_value_at(kCIx,kIy, absVal);
01156                         fkRCopy -> set_value_at(kIx, kIy, NewRealVal);
01157                         fkRCopy -> set_value_at(kCIx,kIy, NewRealVal);
01158                         fkICopy -> set_value_at(kIx, kIy, NewImagVal);
01159                         fkICopy -> set_value_at(kCIx,kIy,-NewImagVal);
01160 
01161                 }
01162         }
01163 #ifdef _WIN32
01164         _unlink("fkCopy.???");
01165         _unlink("fk?Copy.???");
01166 #else
01167         system("rm -f fkCopy.???");
01168         system("rm -f fk?Copy.???");
01169 #endif  //_WIN32
01170         fkCopy  -> write_image("fkCopy.img");
01171         fkRCopy -> write_image("fkRCopy.img");
01172         fkICopy -> write_image("fkICopy.img");
01173 
01174         cout << "Starting the sort "<< endl;
01175 
01176         vector< pair<float, int> > absInds;
01177         for(int i  = 0; i < CountxyMax; ++i ) {
01178                 pair<float,int> p;
01179                 p = make_pair(absD1fkVec[i],i); // p = make_pair(rand(),i);
01180                 absInds.push_back( p);
01181         }
01182 
01183         std::sort(absInds.begin(),absInds.end());
01184 
01185         for(int i  = 0; i < CountxyMax; ++i ) {
01186                 pair<float,int> p   ;
01187                 p = absInds[i]         ;
01188                 absD1fkVecSorted[CountxyMax-1-i] =  p.first ;
01189                 SortfkInds[CountxyMax-1-i]       =  p.second ;
01190         }
01191 
01192         cout << "Ending the sort "<< endl;
01193 
01194 // 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};
01195 
01196 
01197         for(int i  = 0; i < CountxyMax; ++i ) {  // creates a new fkVec
01198                 int Si  = SortfkInds[i];
01199                 int kIx = (int)  Si/End;  kIx = (int)  i/End; // i = kIx*End+kIy
01200 //              int kIy = Si  - kIx*End;  kIy = i  - kIx*End;
01201 //              int iC = (End-1-kIx)*End + (End-1-kIy);
01202 //              if (i<30) { cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " valAft=" << absD1fkVecSorted[i]<< " valBef="  <<     absD1fkVec[Si] << "  SortfkInds = " << Si <<endl; }// This worked
01203 //              cout<< "i= " << i << " kIx= " << kIx << " kIy=" << kIy << " fkVecR[i] =" << fkVecR[i]<< " fkVecI[i]="  << fkVecI[i] <<"  angle[i]= "  << fkAng << endl;
01204         }
01205         cout<< "Ratio of Last Amplitude to First Amplitude= " << absD1fkVecSorted[NK] /absD1fkVecSorted[0]  << endl;
01206 
01207 //      pause;
01208 
01209 //      for(int i  = 0; i < NK; ++i ) { // Prints out the new fkVec ,  CountxyMax
01210 //              int Si= SortfkInds[i];
01211 //              int kIx = (int)  Si/End; // i = kIx*End+kIy
01212 //              int kIy = Si  - kIx*End;
01213 //              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;
01214 //      }
01215 
01216 //       angEMAN+angMat+angDiff    =0  mod 2 pi
01217 
01218 //      angDiff=  2*pi*((-4):4)*(Mid)/End; angEMAN+angMat+angDiff= integer*2 *pi
01219 //              [  absD1fkVecSorted, SortfkInds] =sort( absD1fkVec,'descend') ;
01220 //      Util::sort_mat(&absD1fkVec[0],&absD1fkVec[Countxy],&SortfkInds[0],&SortfkInds[Countxy]);
01221 
01222 
01223 //      Let radial sampling be 0:0.5:(Mid-1)
01224 
01225  //     int NK=  min(12,CountxyMax) ;
01226 
01227 
01228 
01229         cout << "NK = " << NK << endl;
01230         float frR= 3.0/4.0;
01231         int LradRange= (int) (floor(Mid/frR)) ;
01232 
01233         float *radRange = new float[LradRange]; //= 0:.75:(Mid-1);
01234         radRange[0]=0;
01235         for (int irad=1; irad < LradRange; irad++){
01236                         radRange[irad] = radRange[irad-1] + frR; }
01237 
01238 
01239 
01240          // should equal to (2*Mid-1)
01241         cout << "Starting the calculation of invariants for N= " << N << endl;
01242 
01243 /*      int NMax=5;            */
01244 
01245         EMData* RotTransInv = new EMData();
01246         RotTransInv -> set_size(LradRange,LradRange);
01247 
01248 
01249 //      float  *RotTransInv       = new float[LradRange*LradRange ] ;
01250 //      float  *RotTransInvN      = new float[LradRange*LradRange*(NMax+1) ] ;
01251 
01252 //      for (int N=0 ; N<NMax; N++) {
01253 
01254         for (int jr1=0; jr1 < LradRange ; jr1++ ) { // LradRange
01255                 float r1= radRange[jr1];
01256 //              cout << "Pre jr2 "<< endl;
01257                 for (int jr2=0;  jr2<LradRange;  jr2++ ) { //LradRange
01258                         float r2= radRange[jr2];
01259                         float RotTransInvTemp=0;
01260                         for (int jCountkxy =0; jCountkxy<NK; jCountkxy++){
01261                                 int Countkxy =SortfkInds[jCountkxy] ;   // 1: CountxyMax
01262                                 int kx = kVecX[Countkxy] ;
01263                                 int ky = kVecY[Countkxy] ;
01264                                 float k2 = (float)(kx*kx+ky*ky);
01265                                 if (k2==0) { continue;}
01266                                 float phiK =0;
01267                                 if (k2>0) phiK= jxjyatan2[ (ky+Mid-1)*End + kx+Mid-1];  phiK= atan2((float)ky,(float)kx);
01268 
01269                                 float fkR     = fkVecR[Countkxy] ;
01270                                 float fkI     = fkVecI[Countkxy]  ;
01271 /*                              printf("jCountkxy=%d, Countkxy=%d,absD1fkVec(Countkxy)=%f,\t\t kx=%d, ky=%d \n", jCountkxy, Countkxy, absD1fkVec[Countkxy], kx, ky);*/
01272 
01273                                 for (int jCountqxy =0; jCountqxy<NK; jCountqxy++){
01274                                         int Countqxy =SortfkInds[jCountqxy] ;   // Countqxy is the index for absD1fkVec
01275                                         int qx   = kVecX[Countqxy] ;
01276                                         int qy   = kVecY[Countqxy] ;
01277                                         int q2   = qx*qx+qy*qy;
01278                                         if (q2==0) {continue;}
01279                                         float phiQ =0;
01280                                         if (q2>0) phiQ = jxjyatan2[ (qy+Mid-1)*End + qx+Mid-1];   phiQ=atan2((float)qy,(float)qx);
01281                                         float fqR     = fkVecR[Countqxy]  ;
01282                                         float fqI     = fkVecI[Countqxy]  ;
01283                                         int kCx  = (-kx-qx);
01284                                         int kCy  = (-ky-qy);
01285                                         int kCIx = ((kCx+Mid+2*End)%End);// labels of the image in C
01286                                         int kCIy = ((kCy+Mid+2*End)%End);
01287                                         kCx  = kCIx-Mid; // correct
01288                                         kCy  = kCIy-Mid; // correct
01289                                         int CountCxy = kCIx*End+kCIy;
01290                                         float fCR     = fkVecR[CountCxy];
01291                                         float fCI     = fkVecI[CountCxy];
01292                                         if (jr1+jr2==-1) {
01293                                         printf("jCountqxy=%d , Countqxy=%d, absD1fkVec(Countqxy)=%f,qx=%d, qy=%d \n", jCountqxy, Countqxy, absD1fkVec[Countqxy],qx, qy);
01294                                         printf(" CountCxy=%d,absD1fkVec[CountCxy]=%f,  kCx=%d,     kCy=%d \n",CountCxy, absD1fkVec[CountCxy], kCx, kCy );
01295                                         }
01296                                         for (int p=0; p<NK; p++){
01297 //                                              printf("p=%d, SortfkInds[p]=%d, CountCxy =%d \n", p,SortfkInds[p], CountCxy);
01298                                                 if (SortfkInds[p]==CountCxy){
01299                                                         float Arg1 = 2.0f*M_PI*r1*::sqrt((float) q2)/End;
01300                                                         float Arg2 = 2.0f*M_PI*r2*::sqrt((float) k2)/End;
01301 //                                                      printf("Arg1=%4.2f, Arg2=%4.2f,  \n",Arg1, Arg2 );
01302 //                                                      if (Arg1+ Arg2<15) {
01303                                                                 float bispectemp  = (fkR*(fqR*fCR -fqI*fCI) -fkI*(fqI*fCR  +fqR*fCI))
01304                                                                 * cos(N*(phiK-phiQ+M_PI));
01305                                                                 bispectemp  -= (fkR*(fqR*fCI + fqI*fCR) +fkI*(fqR*fCR - fqI*fCI))
01306                                                                 * sin(N*(phiK-phiQ+M_PI));
01307                                                                 float bess1 = calc_bessel(N, Arg1 );
01308                                                                 float bess2 = calc_bessel(N, Arg2 );
01309 //                      printf("fkr=%4.2f, fqr=%4.2f, bess1=%4.2f,bess2=%4.2f \n",fkR, fqR, bess1, bess2);
01310 /*                      printf("p =%d, SortfkInds[p]=%d, CountCxy=%d, Arg1 =%4.2f, bess1=%4.2f,  \n",
01311                                 p, SortfkInds[p],CountCxy, Arg1, bess1);*/
01312                                                                 RotTransInvTemp   = RotTransInvTemp  + bispectemp  * bess1*bess2 ;
01313 //                                                      }
01314                                                 }
01315                                         }
01316                                 } // jCountqxy
01317                         } // jCountkxy
01318                         RotTransInv -> set_value_at(jr1,jr2, RotTransInvTemp)   ;
01319 /*              RotTransInvN[jr1 + LradRange*jr2+LradRange*LradRange*N] = RotTransInvTemp  ;*/
01320                 } //jr2
01321         } //jr1
01322 // }//N
01323 
01324         return  RotTransInv ;
01325 
01326 
01327 }

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

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

02352 {
02353         ENTERFUNC;
02354 
02355         a0=a0*M_PI/180.0f;
02356         da=da*M_PI/180.0f;
02357 
02358         if (get_ndim() > 2) {
02359                 throw ImageDimensionException("no 3D image");
02360         }
02361 
02362         float *yc = new float[n];
02363 
02364         vector<float>   vd(n);
02365         for (int i = 0; i < n; i++) {
02366                 yc[i] = 0.00001f;
02367         }
02368 
02369         float * data = get_data();
02370         if (is_complex()) {
02371                 int c = 0;
02372                 for (int y = 0; y < ny; y++) {
02373                         for (int x = 0; x < nx; x += 2, c += 2) {
02374                                 int x1 = x / 2;
02375                                 int y1 = y<ny/2?y:y-ny;
02376                                 float r = (float)Util::hypot_fast(x1,y1);
02377 
02378                                 if (r >= rmin && r <= rmax) {
02379                                         float a = 0;
02380 
02381                                         if (y != ny / 2 || x != 0) {
02382                                                 a = (atan2((float)y1, (float)x1) - a0) / da;
02383                                         }
02384 
02385                                         int i = (int)(floor(a));
02386                                         a -= i;
02387 
02388                                         if (i == 0) {
02389                                                 vd[0] += data[c] * (1.0f - a);
02390                                                 yc[0] += (1.0f - a);
02391                                         }
02392                                         else if (i == n - 1) {
02393                                                 vd[n - 1] += data[c] * a;
02394                                                 yc[n - 1] += a;
02395                                         }
02396                                         else if (i > 0 && i < (n - 1)) {
02397                                                 float h = 0;
02398                                                 if (is_ri()) {
02399 #ifdef  _WIN32
02400                                                         h = (float)_hypot(data[c], data[c + 1]);
02401 #else
02402                                                         h = (float)hypot(data[c], data[c + 1]);
02403 #endif  //_WIN32
02404                                                 }
02405                                                 else {
02406                                                         h = data[c];
02407                                                 }
02408 
02409                                                 vd[i] += h * (1.0f - a);
02410                                                 yc[i] += (1.0f - a);
02411                                                 vd[i + 1] += h * a;
02412                                                 yc[i + 1] += a;
02413                                         }
02414                                 }
02415                         }
02416                 }
02417         }
02418         else {
02419                 int c = 0;
02420                 float half_nx = (nx - 1) / 2.0f;
02421                 float half_ny = (ny - 1) / 2.0f;
02422 
02423                 for (int y = 0; y < ny; y++) {
02424                         for (int x = 0; x < nx; x++, c++) {
02425                                 float y1 = y - half_ny;
02426                                 float x1 = x - half_nx;
02427 #ifdef  _WIN32
02428                                 float r = (float)_hypot(x1, y1);
02429 #else
02430                                 float r = (float)hypot(x1, y1);
02431 #endif
02432 
02433                                 if (r >= rmin && r <= rmax) {
02434                                         float a = 0;
02435                                         if (x1 != 0 || y1 != 0) {
02436                                                 a = atan2(y1, x1);
02437                                                 if (a < 0) {
02438                                                         a += M_PI * 2;
02439                                                 }
02440                                         }
02441 
02442                                         a = (a - a0) / da;
02443                                         int i = static_cast < int >(floor(a));
02444                                         a -= i;
02445 
02446                                         if (i == 0) {
02447                                                 vd[0] += data[c] * (1.0f - a);
02448                                                 yc[0] += (1.0f - a);
02449                                         }
02450                                         else if (i == n - 1) {
02451                                                 vd[n - 1] += data[c] * a;
02452                                                 yc[n - 1] += (a);
02453                                         }
02454                                         else if (i > 0 && i < (n - 1)) {
02455                                                 vd[i] += data[c] * (1.0f - a);
02456                                                 yc[i] += (1.0f - a);
02457                                                 vd[i + 1] += data[c] * a;
02458                                                 yc[i + 1] += a;
02459                                         }
02460                                 }
02461                         }
02462                 }
02463         }
02464 
02465 
02466         for (int i = 0; i < n; i++) {
02467                 vd[i] /= yc[i];
02468         }
02469 
02470         if( yc )
02471         {
02472                 delete[]yc;
02473                 yc = 0;
02474         }
02475 
02476         return vd;
02477 
02478         EXITFUNC;
02479 }

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

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

03185 {
03186         ENTERFUNC;
03187 
03188         if (get_ndim() != 1) {
03189                 throw ImageDimensionException("'this' image is 1D only");
03190         }
03191 
03192         if (second_img->get_xsize() != nx || ny != 1) {
03193                 throw ImageFormatException("image xsize not same");
03194         }
03195 
03196         if (y_index > second_img->get_ysize() || y_index < 0) {
03197                 return -1;
03198         }
03199 
03200         float ret = 0;
03201         float *d1 = get_data();
03202         float *d2 = second_img->get_data() + second_img->get_xsize() * y_index;
03203 
03204         for (int i = 0; i < nx; i++) {
03205                 ret += Util::square(d1[i] - d2[i]);
03206         }
03207         EXITFUNC;
03208         return std::sqrt(ret);
03209 }

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 3212 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().

03213 {
03214         ENTERFUNC;
03215 
03216         bool maskflag = false;
03217         if (mask == 0) {
03218                 mask = new EMData(nx,ny,nz);
03219                 mask->process_inplace("testimage.circlesphere");
03220                 maskflag = true;
03221         }
03222 
03223         if (get_ndim() != mask->get_ndim() ) throw ImageDimensionException("The dimensions do not match");
03224 
03225         int mnx = mask->get_xsize(); int mny = mask->get_ysize(); int mnz = mask->get_zsize();
03226 
03227         if ( mnx > nx || mny > ny || mnz > nz)
03228                 throw ImageDimensionException("Can not calculate variance map using an image that is larger than this image");
03229 
03230         size_t P = 0;
03231         for(size_t i = 0; i < mask->get_size(); ++i){
03232                 if (mask->get_value_at(i) != 0){
03233                         ++P;
03234                 }
03235         }
03236         float normfac = 1.0f/(float)P;
03237 
03238 //      bool undoclip = false;
03239 
03240         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03241 //      if ( mnx < nx || mny < ny || mnz < nz) {
03242         Region r;
03243         if (ny == 1) r = Region((mnx-nxc)/2,nxc);
03244         else if (nz == 1) r = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03245         else r = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03246         mask->clip_inplace(r,0.0);
03247         //Region r((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03248         //mask->clip_inplace(r);
03249         //undoclip = true;
03250         //}
03251 
03252         // Here we generate the local average of the squares
03253         Region r2;
03254         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03255         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03256         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03257         EMData* squared = get_clip(r2,get_edge_mean());
03258 
03259         EMData* tmp = squared->copy();
03260         Dict pow;
03261         pow["pow"] = 2.0f;
03262         squared->process_inplace("math.pow",pow);
03263         EMData* s = mask->convolute(squared);//ming, mask squared exchange
03264         squared->mult(normfac);
03265 
03266         EMData* m = mask->convolute(tmp);//ming, tmp mask exchange
03267         m->mult(normfac);
03268         m->process_inplace("math.pow",pow);
03269         delete tmp; tmp = 0;
03270         s->sub(*m);
03271         // Here we finally generate the standard deviation image
03272         s->process_inplace("math.sqrt");
03273 
03274 //      if ( undoclip ) {
03275 //              Region r((nx-mnx)/2, (ny-mny)/2, (nz-mnz)/2,mnx,mny,mnz);
03276 //              mask->clip_inplace(r);
03277 //      }
03278 
03279         if (maskflag) {
03280                 delete mask;
03281                 mask = 0;
03282         } else {
03283                 Region r;
03284                 if (ny == 1) r = Region((nxc-mnx)/2,mnx);
03285                 else if (nz == 1) r = Region((nxc-mnx)/2, (nyc-mny)/2,mnx,mny);
03286                 else r = Region((nxc-mnx)/2, (nyc-mny)/2,(nzc-mnz)/2,mnx,mny,mnz);
03287                 mask->clip_inplace(r);
03288         }
03289 
03290         delete squared;
03291         delete m;
03292 
03293         s->process_inplace("xform.phaseorigin.tocenter");
03294         Region r3;
03295         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03296         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03297         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03298         s->clip_inplace(r3);
03299         EXITFUNC;
03300         return s;
03301 }

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 3305 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().

03306 {
03307         ENTERFUNC;
03308         EMData *this_copy=this;
03309         this_copy=copy();
03310 
03311         int mnx = with->get_xsize(); int mny = with->get_ysize(); int mnz = with->get_zsize();
03312         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03313 
03314         // Ones is a circular/spherical mask, consisting of 1s.
03315         EMData* ones = new EMData(mnx,mny,mnz);
03316         ones->process_inplace("testimage.circlesphere");
03317 
03318         // Get a copy of with, we will eventually resize it
03319         EMData* with_resized = with->copy();
03320         with_resized->process_inplace("normalize");
03321         with_resized->mult(*ones);
03322 
03323         EMData* s = calc_fast_sigma_image(ones);// Get the local sigma image
03324 
03325         Region r1;
03326         if (ny == 1) r1 = Region((mnx-nxc)/2,nxc);
03327         else if (nz == 1) r1 = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03328         else r1 = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03329         with_resized->clip_inplace(r1,0.0);
03330 
03331         Region r2;
03332         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03333         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03334         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03335         this_copy->clip_inplace(r2,0.0);
03336 
03337         EMData* corr = this_copy->calc_ccf(with_resized); // the ccf results should have same size as sigma
03338 
03339         corr->process_inplace("xform.phaseorigin.tocenter");
03340         Region r3;
03341         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03342         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03343         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03344         corr->clip_inplace(r3);
03345 
03346         corr->div(*s);
03347 
03348         delete with_resized; delete ones; delete this_copy; delete s;
03349         EXITFUNC;
03350         return corr;
03351 }

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

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

02272 {
02273         ENTERFUNC;
02274 
02275         static size_t prime[] = { 1, 3, 7, 11, 17, 23, 37, 59, 127, 253, 511 };
02276 
02277         if (histmin == histmax) {
02278                 histmin = get_attr("minimum");
02279                 histmax = get_attr("maximum");
02280         }
02281 
02282         vector <float> hist(hist_size, 0.0);
02283 
02284         int p0 = 0;
02285         int p1 = 0;
02286         size_t size = (size_t)nx * ny * nz;
02287         if (size < 300000) {
02288                 p0 = 0;
02289                 p1 = 0;
02290         }
02291         else if (size < 2000000) {
02292                 p0 = 2;
02293                 p1 = 3;
02294         }
02295         else if (size < 8000000) {
02296                 p0 = 4;
02297                 p1 = 6;
02298         }
02299         else {
02300                 p0 = 7;
02301                 p1 = 9;
02302         }
02303 
02304         if (is_complex() && p0 > 0) {
02305                 p0++;
02306                 p1++;
02307         }
02308 
02309         size_t di = 0;
02310 //      float norm = 0;
02311         size_t n = hist.size();
02312 
02313         float * data = get_data();
02314         for (int k = p0; k <= p1; ++k) {
02315                 if (is_complex()) {
02316                         di = prime[k] * 2;
02317                 }
02318                 else {
02319                         di = prime[k];
02320                 }
02321 
02322 //              norm += (float)size / (float) di;
02323                 float w = (float)n / (histmax - histmin);
02324 
02325                 for(size_t i=0; i<=size-di; i += di) {
02326                         float val;
02327                         if (cont != 1.0f || brt != 0)val = cont*(data[i]+brt);
02328                         else val = data[i];
02329                         int j = Util::round((val - histmin) * w);
02330                         if (j >= 0 && j < (int) n) {
02331                                 hist[j] += 1;
02332                         }
02333                 }
02334         }
02335 /*
02336         for (size_t i = 0; i < hist.size(); ++i) {
02337                 if (norm != 0) {
02338                         hist[i] = hist[i] / norm;
02339                 }
02340         }
02341 */
02342         return hist;
02343 
02344         EXITFUNC;
02345 }

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 2115 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().

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

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

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

02785 {
02786         ENTERFUNC;
02787 
02788         if (nz > 1) {
02789                 LOGERR("2D images only.");
02790                 throw ImageDimensionException("2D images only");
02791         }
02792 
02793         vector<float>ret(n*nwedge);
02794         vector<float>norm(n*nwedge);
02795 
02796         int x,y,i;
02797         int step=is_complex()?2:1;
02798         float astep=static_cast<float>(M_PI*2.0/nwedge);
02799         float* data = get_data();
02800         for (i=0; i<n*nwedge; i++) ret[i]=norm[i]=0.0;
02801 
02802         // We do 2D separately to avoid the hypot3 call
02803         for (y=i=0; y<ny; y++) {
02804                 for (x=0; x<nx; x+=step,i+=step) {
02805                         float r,v,a;
02806                         if (is_complex()) {
02807 #ifdef  _WIN32
02808                                 r=static_cast<float>(_hypot(x/2.0,y<ny/2?y:ny-y));              // origin at 0,0; periodic
02809 #else
02810                                 r=static_cast<float>(hypot(x/2.0,y<ny/2?y:ny-y));               // origin at 0,0; periodic
02811 #endif
02812                                 a=atan2(float(y<ny/2?y:ny-y),x/2.0f);
02813                                 if (!inten) {
02814 #ifdef  _WIN32
02815                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02816 #else
02817                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02818 #endif  //_WIN32
02819                                         else v=data[i];                                                 // amp/phase, just get amp
02820                                 } else {
02821                                         if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02822                                         else v=data[i]*data[i];
02823                                 }
02824                         }
02825                         else {
02826 #ifdef  _WIN32
02827                                 r=static_cast<float>(_hypot(x-nx/2,y-ny/2));
02828 #else
02829                                 r=static_cast<float>(hypot(x-nx/2,y-ny/2));
02830 #endif  //_WIN32
02831                                 a=atan2(float(y-ny/2),float(x-nx/2));
02832                                 if (inten) v=data[i]*data[i];
02833                                 else v=data[i];
02834                         }
02835                         int bin=n*int((a+M_PI)/astep);
02836                         if (bin>=nwedge) bin=nwedge-1;
02837                         r=(r-x0)/dx;
02838                         int f=int(r);   // safe truncation, so floor isn't needed
02839                         r-=float(f);    // r is now the fractional spacing between bins
02840                         if (f>=0 && f<n) {
02841                                 ret[f+bin]+=v*(1.0f-r);
02842                                 norm[f+bin]+=(1.0f-r);
02843                                 if (f<n-1) {
02844                                         ret[f+1+bin]+=v*r;
02845                                         norm[f+1+bin]+=r;
02846                                 }
02847                         }
02848                 }
02849         }
02850 
02851         for (i=0; i<n*nwedge; i++) ret[i]/=norm[i]?norm[i]:1.0f;        // Normalize
02852         EXITFUNC;
02853 
02854         return ret;
02855 }

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 2676 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(), and EMAN::FourierAnlProcessor::process_inplace().

02677 {
02678         ENTERFUNC;
02679 
02680         vector<float>ret(n);
02681         vector<float>norm(n);
02682 
02683         int x,y,z,i;
02684         int step=is_complex()?2:1;
02685         int isinten=get_attr_default("is_intensity",0);
02686 
02687         if (isinten&&!inten) { throw InvalidParameterException("Must set inten for calc_radial_dist with intensity image"); }
02688 
02689         for (i=0; i<n; i++) ret[i]=norm[i]=0.0;
02690         float * data = get_data();
02691 
02692         // We do 2D separately to avoid the hypot3 call
02693         if (nz==1) {
02694                 for (y=i=0; y<ny; y++) {
02695                         for (x=0; x<nx; x+=step,i+=step) {
02696                                 float r,v;
02697                                 if (step==2) {          //complex
02698                                         if (x==0 && y>ny/2) continue;
02699                                         r=(float)(Util::hypot_fast(x/2,y<ny/2?y:ny-y));         // origin at 0,0; periodic
02700                                         if (!inten) {
02701 #ifdef  _WIN32
02702                                                 if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02703 #else
02704                                                 if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02705 #endif
02706                                                 else v=data[i];                                                 // amp/phase, just get amp
02707                                         } else {
02708                                                 if (isinten) v=data[i];
02709                                                 else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02710                                                 else v=data[i]*data[i];
02711                                         }
02712                                 }
02713                                 else {
02714                                         r=(float)(Util::hypot_fast(x-nx/2,y-ny/2));
02715                                         if (inten) v=data[i]*data[i];
02716                                         else v=data[i];
02717                                 }
02718                                 r=(r-x0)/dx;
02719                                 int f=int(r);   // safe truncation, so floor isn't needed
02720                                 r-=float(f);    // r is now the fractional spacing between bins
02721 //                              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);
02722                                 if (f>=0 && f<n) {
02723                                         ret[f]+=v*(1.0f-r);
02724                                         norm[f]+=(1.0f-r);
02725                                         if (f<n-1) {
02726                                                 ret[f+1]+=v*r;
02727                                                 norm[f+1]+=r;
02728                                         }
02729                                 }
02730                         }
02731                 }
02732         }
02733         else {
02734                 size_t i;       //3D file may have >2G size
02735                 for (z=i=0; z<nz; ++z) {
02736                         for (y=0; y<ny; ++y) {
02737                                 for (x=0; x<nx; x+=step,i+=step) {
02738                                         float r,v;
02739                                         if (step==2) {  //complex
02740                                                 if (x==0 && z<nz/2) continue;
02741                                                 if (x==0 && z==nz/2 && y<ny/2) continue;
02742                                                 r=Util::hypot3(x/2,y<ny/2?y:ny-y,z<nz/2?z:nz-z);        // origin at 0,0; periodic
02743                                                 if (!inten) {
02744 #ifdef  _WIN32
02745                                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02746 #else
02747                                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02748 #endif  //_WIN32
02749                                                         else v=data[i];                                                 // amp/phase, just get amp
02750                                                 } else {
02751                                                         if (isinten) v=data[i];
02752                                                         else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02753                                                         else v=data[i]*data[i];
02754                                                 }
02755                                         }
02756                                         else {
02757                                                 r=Util::hypot3(x-nx/2,y-ny/2,z-nz/2);
02758                                                 if (inten) v=data[i]*data[i];
02759                                                 else v=data[i];
02760                                         }
02761                                         r=(r-x0)/dx;
02762                                         int f=int(r);   // safe truncation, so floor isn't needed
02763                                         r-=float(f);    // r is now the fractional spacing between bins
02764                                         if (f>=0 && f<n) {
02765                                                 ret[f]+=v*(1.0f-r);
02766                                                 norm[f]+=(1.0f-r);
02767                                                 if (f<n-1) {
02768                                                         ret[f+1]+=v*r;
02769                                                         norm[f+1]+=r;
02770                                                 }
02771                                         }
02772                                 }
02773                         }
02774                 }
02775         }
02776 
02777         for (i=0; i<n; i++) ret[i]/=norm[i]?norm[i]:1.0f;       // Normalize
02778 
02779         EXITFUNC;
02780 
02781         return ret;
02782 }

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

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

02857                    {
02858         ENTERFUNC;
02859         if (!is_complex() || !is_ri())
02860                 throw ImageFormatException("EMData::conj requires a complex, ri image");
02861         int nxreal = nx -2 + int(is_fftodd());
02862         int nxhalf = nxreal/2;
02863         for (int iz = 0; iz < nz; iz++)
02864                 for (int iy = 0; iy < ny; iy++)
02865                         for (int ix = 0; ix <= nxhalf; ix++)
02866                                 cmplx(ix,iy,iz) = conj(cmplx(ix,iy,iz));
02867         EXITFUNC;
02868 }

void EMData::center_origin  ) 
 

Definition at line 6759 of file emdata_sparx.cpp.

References ImageFormatException, is_complex(), LOGERR, and update().

06760 {
06761         ENTERFUNC;
06762         if (is_complex()) {
06763                 LOGERR("Real image expected. Input image is complex.");
06764                 throw ImageFormatException("Real image expected. Input image is complex.");
06765         }
06766         for (int iz = 0; iz < nz; iz++) {
06767                 for (int iy = 0; iy < ny; iy++) {
06768                         for (int ix = 0; ix < nx; ix++) {
06769                                 // next line multiplies by +/- 1
06770                                 (*this)(ix,iy,iz) *= -2*((ix+iy+iz)%2) + 1;
06771                         }
06772                 }
06773         }
06774         update();
06775         EXITFUNC;
06776 }

void EMData::center_origin_fft  ) 
 

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

Definition at line 6796 of file emdata_sparx.cpp.

References cmplx(), get_array_offsets(), ImageFormatException, is_complex(), is_fftodd(), is_ri(), LOGERR, LOGWARN, nx, ny, set_array_offsets(), and update().

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

06797 {
06798         ENTERFUNC;
06799         if (!is_complex()) {
06800                 LOGERR("complex image expected. Input image is real image.");
06801                 throw ImageFormatException("complex image expected. Input image is real image.");
06802         }
06803 
06804         if (!is_ri()) {
06805                 LOGWARN("Only RI should be used. ");
06806         }
06807         vector<int> saved_offsets = get_array_offsets();
06808         // 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
06809         //                                                 and even, so we can ignore the difference...
06810         //                         in short, as nx is extended, it should be  ix in [0,(nx-2)/2],  corrected PAP 05/20
06811         set_array_offsets(0,1,1);
06812         int nxc = nx/2;
06813 
06814         if (is_fftodd()) {
06815                 for (int iz = 1; iz <= nz; iz++) {
06816                         for (int iy = 1; iy <= ny; iy++) {
06817                                 for (int ix = 0; ix < nxc; ix++) {
06818                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06819                                         float temp = float(iz-1+iy-1+ix)/float(ny)*M_PI;
06820                                         complex<float> temp2 = complex<float>(cos(temp), -sin(temp));
06821                                         cmplx(ix,iy,iz) *= temp2;
06822                                 }
06823                         }
06824                 }
06825         } else {
06826                 for (int iz = 1; iz <= nz; iz++) {
06827                         for (int iy = 1; iy <= ny; iy++) {
06828                                 for (int ix = 0; ix < nxc; ix++) {
06829                                         // next line multiplies by +/- 1
06830                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06831                                 }
06832                         }
06833                 }
06834         }
06835         set_array_offsets(saved_offsets);
06836         update();
06837         EXITFUNC;
06838 }

void EMData::center_origin_yz  ) 
 

Definition at line 6778 of file emdata_sparx.cpp.

References ImageFormatException, is_complex(), LOGERR, and update().

06779 {
06780         ENTERFUNC;
06781         if (is_complex()) {
06782                 LOGERR("Real image expected. Input image is complex.");
06783                 throw ImageFormatException("Real image expected. Input image is complex.");
06784         }
06785         for (int iz = 0; iz < nz; iz++) {
06786                 for (int iy = (iz+1)%2; iy < ny; iy+=2) {
06787                         for (int ix = 0; ix < nx; ix++) {
06788                                 (*this)(ix,iy,iz) *= -1;
06789                         }
06790                 }
06791         }
06792         update();
06793         EXITFUNC;
06794 }

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

turn off updates.

Useful to avoid wasteful recacling stats

Definition at line 402 of file emdata.h.

00408                                 : this method internally just calls the

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::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::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::Util::ccc_images(), EMAN::Util::ccc_images_G(), frm_2d_Align(), main(), EMAN::Util::twoD_fine_ali(), EMAN::Util::twoD_fine_ali_G(), EMAN::Util::twoD_to_3D_ali(), EMAN::RT3DSymmetryAligner::xform_align_nbest(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

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 2384 of file emdata.h.

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

Definition at line 2373 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 2362 of file emdata.h.

Referenced by EMAN::newfile_store::add_image(), cconj(), center_origin_fft(), EMAN::Processor::EMFourierFilterFunc(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), extractpoint(), EMAN::Util::extractpoint2(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), fouriergridrot2d(), fouriergridrot_shift2d(), 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(), symplane0_ctf(), symplane0_rect(), 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::conjg  ) 
 

Definition at line 6218 of file emdata_sparx.cpp.

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

06219 {
06220         if(this->is_complex()) {
06221                 EMData* buf_new = this->copy_head();
06222                 float *in  = this->get_data();
06223                 float *out = buf_new->get_data();
06224                 for(size_t i=0; i<(size_t)nx*ny*nz; i+=2) {out[i] = in[i]; out[i+1] = -in[i+1];}
06225                 return buf_new;
06226         } else throw ImageFormatException("image has to be complex");
06227 }

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 3353 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().

03354 {
03355         ENTERFUNC;
03356 
03357         EMData *f1 = do_fft();
03358         if (!f1) {
03359                 LOGERR("FFT returns NULL image");
03360                 throw NullPointerException("FFT returns NULL image");
03361         }
03362 
03363         f1->ap2ri();
03364 
03365         EMData *cf = 0;
03366         if (with) {
03367                 cf = with->do_fft();
03368                 if (!cf) {
03369                         LOGERR("FFT returns NULL image");
03370                         throw NullPointerException("FFT returns NULL image");
03371                 }
03372                 cf->ap2ri();
03373         }
03374         else {
03375                 cf = f1->copy();
03376         }
03377         //printf("cf_x=%d, f1y=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f1->get_ysize(),this->get_xsize(),with->get_xsize());
03378         if (with && !EMUtil::is_same_size(f1, cf)) {
03379                 LOGERR("images not same size");
03380                 throw ImageFormatException("images not same size");
03381         }
03382 
03383         float *rdata1 = f1->get_data();
03384         float *rdata2 = cf->get_data();
03385         size_t cf_size = (size_t)cf->get_xsize() * cf->get_ysize() * cf->get_zsize();
03386 
03387         float re,im;
03388 
03389         for (size_t i = 0; i < cf_size; i += 2) {
03390                 re = rdata1[i] * rdata2[i] - rdata1[i + 1] * rdata2[i + 1];
03391                 im = rdata1[i + 1] * rdata2[i] + rdata1[i] * rdata2[i + 1];
03392                 rdata2[i]=re;
03393                 rdata2[i+1]=im;
03394         }
03395         cf->update();
03396         EMData *f2 = cf->do_ift();//ming change cf to cf_temp
03397         //printf("cf_x=%d, f2x=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f2->get_xsize(),this->get_xsize(),with->get_xsize());
03398         if( cf )
03399         {
03400                 delete cf;
03401                 cf = 0;
03402         }
03403 
03404         if( f1 )
03405         {
03406                 delete f1;
03407                 f1=0;
03408         }
03409 
03410         EXITFUNC;
03411         return f2;
03412 }

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::MinMaxAverager::add_image(), EMAN::FRM2DAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateTranslateAligner::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(), filter_by_image(), Four_ds(), Four_shuf_ds_cen_us(), EMAN::fourierproduct(), FourInterpol(), 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::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::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), real(), real2FH(), replace_amplitudes(), 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::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::Util::addn_img(), average_circ_sub(), conjg(), delete_disconnected_regions(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_ift(), downsample(), fouriergridrot2d(), fouriergridrot_shift2d(), FourTruncate(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), get_pow(), helicise(), helicise_grid(), little_big_dot(), EMAN::Util::madn_scalar(), EMAN::Util::muln_img(), mult_radial(), EMAN::Util::mult_scalar(), norm_pad(), EMAN::Util::pad(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), 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(), 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 3809 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.

03810 {
03811         ENTERFUNC;
03812 
03813         if (!map) throw NullPointerException("NULL image");
03814         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
03815         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
03816         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
03817         // Now check for complex images - this is really just being thorough
03818         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
03819         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
03820 
03821 
03822         float *sdata = map->get_data();
03823         float *ddata = get_data();
03824 
03825         int map_nx = map->get_xsize();
03826         int map_ny = map->get_ysize();
03827         int map_nz = map->get_zsize();
03828         int map_nxy = map_nx * map_ny;
03829 
03830         int ymax = ny/2;
03831         if ( ny % 2 == 1 ) ymax += 1;
03832         int xmax = nx/2;
03833         if ( nx % 2 == 1 ) xmax += 1;
03834         for (int y = -ny/2; y < ymax; y++) {
03835                 for (int x = -nx/2; x < xmax; x++) {
03836                         Vec3f coord(x,y,0);
03837                         Vec3f soln = transform*coord;
03838 
03839 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
03840 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
03841 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
03842 
03843 
03844 //                      xx += map_nx/2;
03845 //                      yy += map_ny/2;
03846 //                      zz += map_nz/2;
03847 
03848                         float xx = soln[0]+map_nx/2;
03849                         float yy = soln[1]+map_ny/2;
03850                         float zz = soln[2]+map_nz/2;
03851 
03852                         int l = (x+nx/2) + (y+ny/2) * nx;
03853 
03854                         float t = xx - floor(xx);
03855                         float u = yy - floor(yy);
03856                         float v = zz - floor(zz);
03857 
03858                         if (xx < 0 || yy < 0 || zz < 0 ) {
03859                                 ddata[l] = 0;
03860                                 continue;
03861                         }
03862                         if (interpolate) {
03863                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03864                                         ddata[l] = 0;
03865                                         continue;
03866                                 }
03867                                 int k = (int) (Util::fast_floor(xx) + Util::fast_floor(yy) * map_nx + Util::fast_floor(zz) * map_nxy);
03868 
03869 
03870                                 if (xx < (map_nx - 1) && yy < (map_ny - 1) && zz < (map_nz - 1)) {
03871                                         ddata[l] = Util::trilinear_interpolate(sdata[k],
03872                                                                 sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03873                                                                 sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03874                                                                 sdata[k + map_nx + map_nxy + 1],t, u, v);
03875                                 }
03876                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03877                                         ddata[l] += sdata[k];
03878                                 }
03879                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) ) {
03880                                         ddata[l] +=     Util::linear_interpolate(sdata[k], sdata[k + map_nxy],v);
03881                                 }
03882                                 else if ( xx == (map_nx - 1) && zz == (map_nz - 1) ) {
03883                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + map_nx],u);
03884                                 }
03885                                 else if ( yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03886                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + 1],t);
03887                                 }
03888                                 else if ( xx == (map_nx - 1) ) {
03889                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + map_nx], sdata[k + map_nxy], sdata[k + map_nxy + map_nx],u,v);
03890                                 }
03891                                 else if ( yy == (map_ny - 1) ) {
03892                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nxy], sdata[k + map_nxy + 1],t,v);
03893                                 }
03894                                 else if ( zz == (map_nz - 1) ) {
03895                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nx], sdata[k + map_nx + 1],t,u);
03896                                 }
03897 
03898 //                              if (k >= map->get_size()) {
03899 //                                      cout << xx << " " << yy << " " <<  zz << " " << endl;
03900 //                                      cout << k << " " << get_size() << endl;
03901 //                                      cout << get_xsize() << " " << get_ysize() << " " << get_zsize() << endl;
03902 //                                      throw;
03903 //                                      }
03904 //
03905 //                              ddata[l] = Util::trilinear_interpolate(sdata[k],
03906 //                                              sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03907 //                                              sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03908 //                                              sdata[k + map_nx + map_nxy + 1],t, u, v);
03909                         }
03910                         else {
03911                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03912                                         ddata[l] = 0;
03913                                         continue;
03914                                 }
03915                                 size_t k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * (size_t)map_nxy;
03916                                 ddata[l] = sdata[k];
03917                         }
03918 
03919                 }
03920         }
03921 
03922         update();
03923 
03924         EXITFUNC;
03925 }

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

Printing EMData params for debugging purpose.

Definition at line 3825 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 1196 of file emdata_metadata.cpp.

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

Referenced by del_attr_dict().

01197 {
01198         attr_dict.erase(attr_name);
01199 }

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 1201 of file emdata_metadata.cpp.

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

01202 {
01203         vector<string>::const_iterator it;
01204         for(it=del_keys.begin(); it!=del_keys.end(); ++it) {
01205                 this->del_attr(*it);
01206         }
01207 }

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 6229 of file emdata_sparx.cpp.

References copy_head(), get_ndim(), ImageDimensionException, ImageFormatException, is_complex(), nx, ny, nz, to_zero(), and update().

06229                                                                   {
06230         if (3 != get_ndim())
06231                 throw ImageDimensionException("delete_disconnected_regions needs a 3-D image.");
06232         if (is_complex())
06233                 throw ImageFormatException("delete_disconnected_regions requires a real image");
06234         if ((*this)(ix+nx/2,iy+ny/2,iz+nz/2) == 0)
06235                 throw ImageDimensionException("delete_disconnected_regions starting point is zero.");
06236 
06237         EMData* result = this->copy_head();
06238         result->to_zero();
06239         (*result)(ix+nx/2,iy+ny/2,iz+nz/2) = (*this)(ix+nx/2,iy+ny/2,iz+nz/2);
06240         bool kpt = true;
06241         //cout << "  delete   "<<(*result)(ix+nx/2,iy+ny/2,iz+nz/2)<<endl;
06242         while(kpt) {
06243                 kpt = false;
06244                 for (int cz = 1; cz < nz-1; cz++) {
06245                         for (int cy = 1; cy < ny-1; cy++) {
06246                                 for (int cx = 1; cx < nx-1; cx++) {
06247                                         if((*result)(cx,cy,cz) == 1) {
06248                                                 for (int lz = -1; lz <= 1; lz++) {
06249                                                         for (int ly = -1; ly <= 1; ly++) {
06250                                                                 for (int lx = -1; lx <= 1; lx++) {
06251                                                                         if(((*this)(cx+lx,cy+ly,cz+lz) == 1) && ((*result)(cx+lx,cy+ly,cz+lz) == 0))  {
06252                                                                                 (*result)(cx+lx,cy+ly,cz+lz) = 1;
06253                                                                                 kpt = true;
06254                                                                         }
06255                                                                 }
06256                                                         }
06257                                                 }
06258                                         }
06259                                 }
06260                         }
06261                 }
06262         }
06263         result->update();
06264         return result;
06265 }

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 6523 of file emdata_sparx.cpp.

References attr_dict, get_array_offsets(), get_data(), ImageFormatException, is_complex(), is_fftodd(), nx, ny, nz, set_array_offsets(), set_attr(), set_complex(), set_complex_x(), set_fftodd(), set_fftpad(), set_size(), and update().

Referenced by EMAN::Processor::EMFourierFilterFunc(), filter_by_image(), 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(), Four_ds(), Four_shuf_ds_cen_us(), EMAN::fourierproduct(), FourInterpol(), FourTruncate(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), replace_amplitudes(), EMAN::Util::WTF(), and EMAN::Util::WTM().

06523                    {
06524         if (is_complex())
06525                 throw ImageFormatException("Depadding of complex images not supported");
06526         vector<int> saved_offsets = get_array_offsets();
06527         set_array_offsets(0,0,0);
06528         int npad = attr_dict["npad"];
06529         if (0 == npad) npad = 1;
06530         int offset = is_fftodd() ? 1 : 2;
06531         int nxold = (nx - offset)/npad;
06532 #ifdef _WIN32
06533         int nyold = _cpp_max(ny/npad, 1);
06534         int nzold = _cpp_max(nz/npad, 1);
06535 #else
06536         int nyold = std::max<int>(ny/npad, 1);
06537         int nzold = std::max<int>(nz/npad, 1);
06538 #endif  //_WIN32
06539         int xstart = 0, ystart = 0, zstart = 0;
06540         if( npad > 1) {
06541                 xstart = (nx - offset - nxold)/2 + nxold%2;
06542                 if(ny > 1) {
06543                         ystart = (ny - nyold)/2 + nyold%2;
06544                         if(nz > 1) {
06545                                 zstart = (nz - nzold)/2 + nzold%2;
06546                         }
06547                 }
06548         }
06549         int bytes = nxold*sizeof(float);
06550         float* dest = get_data();
06551         for (int iz=0; iz < nzold; iz++) {
06552                 for (int iy = 0; iy < nyold; iy++) {
06553                         memmove(dest, &(*this)(xstart,iy+ystart,iz+zstart), bytes);
06554                         dest += nxold;
06555                 }
06556         }
06557         set_size(nxold, nyold, nzold);
06558         set_attr("npad", 1);
06559         set_fftpad(false);
06560         set_fftodd(false);
06561         set_complex(false);
06562         if(ny==1 && nz==1) set_complex_x(false);
06563         set_array_offsets(saved_offsets);
06564         update();
06565         EXITFUNC;
06566 }

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 6575 of file emdata_sparx.cpp.

References attr_dict, get_array_offsets(), get_data(), ImageFormatException, is_complex(), is_fftodd(), nx, ny, nz, set_array_offsets(), set_attr(), set_complex(), set_complex_x(), set_fftodd(), set_fftpad(), set_size(), and update().

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

06575                           {
06576         if(is_complex())
06577                 throw ImageFormatException("Depadding of complex images not allowed");
06578         vector<int> saved_offsets = get_array_offsets();
06579         set_array_offsets(0,0,0);
06580         int npad = attr_dict["npad"];
06581         if(0 == npad) npad = 1;
06582         int offset = is_fftodd() ? 1 : 2;
06583         int nxold = (nx - offset)/npad;
06584 #ifdef _WIN32
06585         int nyold = _cpp_max(ny/npad, 1);
06586         int nzold = _cpp_max(nz/npad, 1);
06587 #else
06588         int nyold = std::max<int>(ny/npad, 1);
06589         int nzold = std::max<int>(nz/npad, 1);
06590 #endif  //_WIN32
06591         size_t bytes = nxold*sizeof(float);
06592         float* dest = get_data();
06593         for (int iz=0; iz < nzold; iz++) {
06594                 for (int iy = 0; iy < nyold; iy++) {
06595                         memmove(dest, &(*this)(0,iy,iz), bytes);
06596                         dest += nxold;
06597                 }
06598         }
06599         set_size(nxold, nyold, nzold);
06600         set_attr("npad", 1);
06601         set_fftpad(false);
06602         set_fftodd(false);
06603         set_complex(false);
06604         if(ny==1 && nz==1) set_complex_x(false);
06605         set_array_offsets(saved_offsets);
06606         update();
06607         EXITFUNC;
06608 }

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 610 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().

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

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 599 of file emdata_core.cpp.

References InvalidValueException, and mult().

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

00600 {
00601         ENTERFUNC;
00602         if ( f == 0 ) {
00603                 throw InvalidValueException(f,"Can not divide by zero");
00604         }
00605         mult(1.0f/f);
00606         EXITFUNC;
00607 }

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 4225 of file emdata_sparx.cpp.

References get_array_offsets(), ImageFormatException, is_complex(), nx, ny, set_array_offsets(), and EMAN::Util::KaiserBessel::sinhwin().

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

04225                                                  {
04226         
04227         if (is_complex())
04228                 throw ImageFormatException("divkbsinh requires a real image.");
04229         vector<int> saved_offsets = get_array_offsets();
04230         set_array_offsets(0,0,0);
04231         // Note that the following loops will work for 1-, 2-, and 3-D
04232         // images, since the "extra" weights will be 1.0.  (For example,
04233         // for a 2-d image iz=0, nz=1, so iz-nz/2 = 0 - 1/2 = 0, since
04234         // the division is an integer division.)
04235         for (int iz=0; iz < nz; iz++) {
04236                 float wz = kb.sinhwin(static_cast<float>(iz-nz/2));
04237                 for (int iy=0; iy < ny; iy++) {
04238                         float wy = kb.sinhwin(static_cast<float>(iy-ny/2));
04239                         for (int ix=0; ix < nx; ix++) {
04240                                 float wx = kb.sinhwin(static_cast<float>(ix-nx/2));
04241                                 float w = wx*wy*wz;
04242                                 (*this)(ix,iy,iz) /= w;
04243                         }
04244                 }
04245         }
04246         set_array_offsets(saved_offsets);
04247 }

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

Definition at line 4249 of file emdata_sparx.cpp.

References get_array_offsets(), ImageFormatException, is_complex(), nx, ny, set_array_offsets(), and EMAN::Util::KaiserBessel::sinhwin().

04249                                                                                                                  {
04250 
04251         if (is_complex())
04252                 throw ImageFormatException("divkbsinh requires a real image.");
04253         vector<int> saved_offsets = get_array_offsets();
04254         set_array_offsets(0,0,0);
04255         // Note that the following loops will work for 1-, 2-, and 3-D
04256         // images, since the "extra" weights will be 1.0.  (For example,
04257         // for a 2-d image iz=0, nz=1, so iz-nz/2 = 0 - 1/2 = 0, since
04258         // the division is an integer division.)
04259         for (int iz=0; iz < nz; iz++) {
04260                 float wz = kbz.sinhwin(static_cast<float>(iz-nz/2));
04261                 for (int iy=0; iy < ny; iy++) {
04262                         float wy = kby.sinhwin(static_cast<float>(iy-ny/2));
04263                         for (int ix=0; ix < nx; ix++) {
04264                                 float wx = kbx.sinhwin(static_cast<float>(ix-nx/2));
04265                                 float w = wx*wy*wz;
04266                                 (*this)(ix,iy,iz) /= w;
04267                         }
04268                 }
04269         }
04270         
04271         set_array_offsets(saved_offsets);
04272 }

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::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::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(), common_lines(), convolute(), EMAN::MatchSFProcessor::create_radial_func(), FourInterpol(), FourTruncate(), main(), make_footprint(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::FFTResampleProcessor::process(), EMAN::Wiener2DFourierProcessor::process(), EMAN::Wiener2DAutoAreaProcessor::process(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), 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 not supported yet.");
00066                 throw ImageFormatException("real image expected. Input image is complex image.");
00067                 exit;
00068 #endif // NATIVE_FFT
00069 
00070                         EMData *temp_in=copy();
00071                         EMData *dat= copy_head();
00072                         int offset;
00073                         if(is_fftpadded()) {
00074                                 offset = is_fftodd() ? 1 : 2;
00075                         }
00076                         else offset=0;
00077                         //printf("offset=%d\n",offset);
00078                         EMfft::complex_to_complex_nd(temp_in->get_data(),dat->get_data(),nx-offset,ny,nz);
00079 
00080                         if(dat->get_ysize()==1 && dat->get_zsize()==1) dat->set_complex_x(true);
00081 
00082                         dat->update();
00083                         delete temp_in;
00084                         EXITFUNC;
00085                         return dat;
00086                 }
00087 
00088         else{
00089         int nxreal = nx;
00090         int offset = 2 - nx%2;
00091         int nx2 = nx + offset;
00092         EMData* dat = copy_head();
00093         dat->set_size(nx2, ny, nz);
00094         //dat->to_zero();  // do not need it, real_to_complex will do it right anyway
00095         if (offset == 1) dat->set_fftodd(true);
00096         else             dat->set_fftodd(false);
00097 
00098         float *d = dat->get_data();
00099         //std::cout<<" do_fft "<<rdata[5]<<"  "<<d[5]<<std::endl;
00100         EMfft::real_to_complex_nd(get_data(), d, nxreal, ny, nz);
00101 
00102         dat->update();
00103         dat->set_fftpad(true);
00104         dat->set_complex(true);
00105         if(dat->get_ysize()==1 && dat->get_zsize()==1) dat->set_complex_x(true);
00106         dat->set_ri(true);
00107 
00108         EXITFUNC;
00109         return dat;
00110         }
00111 }

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 113 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(), filter_by_image(), EMAN::fourierproduct(), oneDfftPolar(), EMAN::padfft_slice(), EMAN::periodogram(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::FFTProcessor::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::FourierGriddingProjector::project3d(), replace_amplitudes(), EMAN::Util::WTF(), and EMAN::Util::WTM().

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

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 325 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::CtfAverager::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::TomoAverager::finish(), frm_2d_Align(), main(), make_footprint(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::Wiener2DFourierProcessor::process(), EMAN::FileFourierProcessor::process_inplace(), EMAN::SNRProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), and EMAN::GaussFFTProjector::project3d().

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

EMData * EMData::do_ift_inplace  ) 
 

Definition at line 387 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::PhaseCmp::cmp(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), filter_by_image(), 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(), Four_ds(), Four_shuf_ds_cen_us(), EMAN::fourierproduct(), FourInterpol(), FourTruncate(), EMAN::FFTProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::FourierGriddingProjector::project3d(), replace_amplitudes(), EMAN::Util::twoD_to_3D_ali(), EMAN::Util::WTF(), and EMAN::Util::WTM().

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

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 1379 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().

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

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 658 of file emdata_core.cpp.

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

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

00659 {
00660         ENTERFUNC;
00661         if (!with) {
00662                 throw NullPointerException("Null EMData Image");
00663         }
00664         DotCmp dot_cmp;
00665         float r = -dot_cmp.cmp(this, with);
00666         EXITFUNC;
00667         return r;
00668 }

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

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

Referenced by refalifnfast().

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

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

Definition at line 3256 of file emdata_sparx.cpp.

References copy_head(), get_array_offsets(), get_pixel_filtered(), nx, ny, nz, set_array_offsets(), set_size(), to_zero(), x, and y.

03256                                                             {
03257 
03258         /*int M = kb.get_sB_size();
03259         int kbmin = -M/2;
03260         int kbmax = -kbmin;*/
03261 
03262         int nxn, nyn, nzn;
03263         nxn = (int)(nx*scale); nyn = (int)(ny*scale); nzn = (int)(nz*scale);
03264 
03265         vector<int> saved_offsets = get_array_offsets();
03266         set_array_offsets(0,0,0);
03267         EMData* ret = this->copy_head();
03268 #ifdef _WIN32
03269         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03270 #else
03271         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03272 #endif  //_WIN32
03273         ret->to_zero();  //we will leave margins zeroed.
03274 
03275         // scan new, find pixels in old
03276         for (int iy =0; iy < nyn; iy++) {
03277                 float y = float(iy)/scale;
03278                 for (int ix = 0; ix < nxn; ix++) {
03279                         float x = float(ix)/scale;
03280                         (*ret)(ix,iy) = this->get_pixel_filtered(x, y, 1.0f, kb);
03281                 }
03282         }
03283         set_array_offsets(saved_offsets);
03284         return ret;
03285 }

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 4300 of file emdata_sparx.cpp.

References abs, cmplx(), EMData(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, ImageFormatException, EMAN::Transform::invert(), is_complex(), nx, ny, set_array_offsets(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_shuffled(), set_size(), to_zero(), and EMAN::Vec3f.

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

04300                                                                        {
04301         if (!is_complex())
04302                 throw ImageFormatException("extractplane requires a complex image");
04303         if (nx%2 != 0)
04304                 throw ImageDimensionException("extractplane requires nx to be even");
04305         int nxreal = nx - 2;
04306         if (nxreal != ny || nxreal != nz)
04307                 throw ImageDimensionException("extractplane requires ny == nx == nz");
04308         // build complex result image
04309         EMData* res = new EMData();
04310         res->set_size(nx,ny,1);
04311         res->to_zero();
04312         res->set_complex(true);
04313         res->set_fftodd(false);
04314         res->set_fftpad(true);
04315         res->set_ri(true);
04316         // Array offsets: (0..nhalf,-nhalf..nhalf-1,-nhalf..nhalf-1)
04317         int n = nxreal;
04318         int nhalf = n/2;
04319         vector<int> saved_offsets = get_array_offsets();
04320         set_array_offsets(0,-nhalf,-nhalf);
04321         res->set_array_offsets(0,-nhalf,0);
04322         // set up some temporary weighting arrays
04323         int kbsize =  kb.get_window_size();
04324         int kbmin  = -kbsize/2;
04325         int kbmax  = -kbmin;
04326         float* wy0 = new float[kbmax - kbmin + 1];
04327         float* wy  = wy0 - kbmin; // wy[kbmin:kbmax]
04328         float* wx0 = new float[kbmax - kbmin + 1];
04329         float* wx  = wx0 - kbmin;
04330         float* wz0 = new float[kbmax - kbmin + 1];
04331         float* wz  = wz0 - kbmin;
04332         float rim = nhalf*float(nhalf);
04333         int count = 0;
04334         float wsum = 0.f;
04335         Transform tftrans = tf; // need transpose of tf here for consistency
04336         tftrans.invert();      // with spider
04337         for (int jy = -nhalf; jy < nhalf; jy++) 
04338         {
04339                 for (int jx = 0; jx <= nhalf; jx++) 
04340                 {
04341                         Vec3f nucur((float)jx, (float)jy, 0.f);
04342                         Vec3f nunew = tftrans*nucur;
04343                         float xnew = nunew[0], ynew = nunew[1], znew = nunew[2];
04344                         if (xnew*xnew+ynew*ynew+znew*znew <= rim) 
04345                         {
04346                                 count++;
04347                                 std::complex<float> btq(0.f,0.f);
04348                                 bool flip = false;
04349                                 if (xnew < 0.f) {
04350                                         flip = true;
04351                                         xnew = -xnew;
04352                                         ynew = -ynew;
04353                                         znew = -znew;
04354                                 }
04355                                 int ixn = int(Util::round(xnew));
04356                                 int iyn = int(Util::round(ynew));
04357                                 int izn = int(Util::round(znew));
04358                                 // populate weight arrays
04359                                 for (int i=kbmin; i <= kbmax; i++) {
04360                                         int izp = izn + i;
04361                                         wz[i] = kb.i0win_tab(znew - izp);
04362                                         int iyp = iyn + i;
04363                                         wy[i] = kb.i0win_tab(ynew - iyp);
04364                                         int ixp = ixn + i;
04365                                         wx[i] = kb.i0win_tab(xnew - ixp);
04366 
04367                                 }
04368                                 // restrict weight arrays to non-zero elements
04369                                 int lnbz = 0;
04370                                 for (int iz = kbmin; iz <= -1; iz++) {
04371                                         if (wz[iz] != 0.f) {
04372                                                 lnbz = iz;
04373                                                 break;
04374                                         }
04375                                 }
04376                                 int lnez = 0;
04377                                 for (int iz = kbmax; iz >= 1; iz--) {
04378                                         if (wz[iz] != 0.f) {
04379                                                 lnez = iz;
04380                                                 break;
04381                                         }
04382                                 }
04383                                 int lnby = 0;
04384                                 for (int iy = kbmin; iy <= -1; iy++) {
04385                                         if (wy[iy] != 0.f) {
04386                                                 lnby = iy;
04387                                                 break;
04388                                         }
04389                                 }
04390                                 int lney = 0;
04391                                 for (int iy = kbmax; iy >= 1; iy--) {
04392                                         if (wy[iy] != 0.f) {
04393                                                 lney = iy;
04394                                                 break;
04395                                         }
04396                                 }
04397                                 int lnbx = 0;
04398                                 for (int ix = kbmin; ix <= -1; ix++) {
04399                                         if (wx[ix] != 0.f) {
04400                                                 lnbx = ix;
04401                                                 break;
04402                                         }
04403                                 }
04404                                 int lnex = 0;
04405                                 for (int ix = kbmax; ix >= 1; ix--) {
04406                                         if (wx[ix] != 0.f) {
04407                                                 lnex = ix;
04408                                                 break;
04409                                         }
04410                                 }
04411                                 if    (ixn >= -kbmin      && ixn <= nhalf-1-kbmax
04412                                    && iyn >= -nhalf-kbmin && iyn <= nhalf-1-kbmax
04413                                    && izn >= -nhalf-kbmin && izn <= nhalf-1-kbmax) {
04414                                         // interior points
04415                                         for (int lz = lnbz; lz <= lnez; lz++) {
04416                                                 int izp = izn + lz;
04417                                                 for (int ly=lnby; ly<=lney; ly++) {
04418                                                         int iyp = iyn + ly;
04419                                                         float ty = wz[lz]*wy[ly];
04420                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04421                                                                 int ixp = ixn + lx;
04422                                                                 float wg = wx[lx]*ty;
04423                                                                 btq += cmplx(ixp,iyp,izp)*wg;
04424                                                                 wsum += wg;
04425                                                         }
04426                                                 }
04427                                         }
04428                                 } else {
04429                                         // points "sticking out"
04430                                         for (int lz = lnbz; lz <= lnez; lz++) {
04431                                                 int izp = izn + lz;
04432                                                 for (int ly=lnby; ly<=lney; ly++) {
04433                                                         int iyp = iyn + ly;
04434                                                         float ty = wz[lz]*wy[ly];
04435                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04436                                                                 int ixp = ixn + lx;
04437                                                                 float wg = wx[lx]*ty;
04438                                                                 bool mirror = false;
04439                                                                 int ixt(ixp), iyt(iyp), izt(izp);
04440                                                                 if (ixt > nhalf || ixt < -nhalf) {
04441                                                                         ixt = Util::sgn(ixt)
04442                                                                                   *(n - abs(ixt));
04443                                                                         iyt = -iyt;
04444                                                                         izt = -izt;
04445                                                                         mirror = !mirror;
04446                                                                 }
04447                                                                 if (iyt >= nhalf || iyt < -nhalf) {
04448                                                                         if (ixt != 0) {
04449                                                                                 ixt = -ixt;
04450                                                                                 iyt = Util::sgn(iyt)
04451                                                                                           *(n - abs(iyt));
04452                                                                                 izt = -izt;
04453                                                                                 mirror = !mirror;
04454                                                                         } else {
04455                                                                                 iyt -= n*Util::sgn(iyt);
04456                                                                         }
04457                                                                 }
04458                                                                 if (izt >= nhalf || izt < -nhalf) {
04459                                                                         if (ixt != 0) {
04460                                                                                 ixt = -ixt;
04461                                                                                 iyt = -iyt;
04462                                                                                 izt = Util::sgn(izt)
04463                                                                                           *(n - abs(izt));
04464                                                                                 mirror = !mirror;
04465                                                                         } else {
04466                                                                                 izt -= Util::sgn(izt)*n;
04467                                                                         }
04468                                                                 }
04469                                                                 if (ixt < 0) {
04470                                                                         ixt = -ixt;
04471                                                                         iyt = -iyt;
04472                                                                         izt = -izt;
04473                                                                         mirror = !mirror;
04474                                                                 }
04475                                                                 if (iyt == nhalf) iyt = -nhalf;
04476                                                                 if (izt == nhalf) izt = -nhalf;
04477                                                                 if (mirror)   btq += conj(cmplx(ixt,iyt,izt))*wg;
04478                                                                 else          btq += cmplx(ixt,iyt,izt)*wg;
04479                                                                 wsum += wg;
04480                                                         }
04481                                                 }
04482                                         }
04483                                 }
04484                                 if (flip)  res->cmplx(jx,jy) = conj(btq);
04485                                 else       res->cmplx(jx,jy) = btq;
04486                         }
04487                 }
04488         }
04489         for (int jy = -nhalf; jy < nhalf; jy++)
04490                 for (int jx = 0; jx <= nhalf; jx++)
04491                         res->cmplx(jx,jy) *= count/wsum;
04492         delete[] wx0; delete[] wy0; delete[] wz0;
04493         set_array_offsets(saved_offsets);
04494         res->set_array_offsets(0,0,0);
04495         res->set_shuffled(true);
04496         return res;
04497 }

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

Definition at line 4504 of file emdata_sparx.cpp.

References abs, cmplx(), EMData(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, ImageFormatException, EMAN::Transform::invert(), is_complex(), nx, ny, nz, set_array_offsets(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_shuffled(), set_size(), to_zero(), and EMAN::Vec3f.

04504                                                                                                                           {
04505         
04506 
04507         if (!is_complex())
04508                 throw ImageFormatException("extractplane requires a complex image");
04509         if (nx%2 != 0)
04510                 throw ImageDimensionException("extractplane requires nx to be even");
04511 
04512         int nxfromz = nz+2;
04513         int nxcircal = nxfromz - 2;
04514         EMData* res = new EMData();
04515         res->set_size(nxfromz,nz,1);
04516         res->to_zero();
04517         res->set_complex(true);
04518         res->set_fftodd(false);
04519         res->set_fftpad(true);
04520         res->set_ri(true);
04521         // Array offsets: (0..nhalf,-nhalf..nhalf-1,-nhalf..nhalf-1)
04522         int n = nxcircal;
04523         int nhalf = n/2;
04524         int nxhalf = (nx-2)/2;
04525         int nyhalf = ny/2;
04526         int nzhalf = nz/2;
04527         
04528         vector<int> saved_offsets = get_array_offsets();
04529         set_array_offsets(0, -nyhalf, -nzhalf);
04530         res->set_array_offsets(0,-nhalf,0);
04531         // set up some temporary weighting arrays
04532         int kbxsize =  kbx.get_window_size();
04533         int kbxmin  = -kbxsize/2;
04534         int kbxmax  = -kbxmin;
04535 
04536         int kbysize =  kby.get_window_size();
04537         int kbymin  = -kbysize/2;
04538         int kbymax  = -kbymin;
04539 
04540         int kbzsize =  kbz.get_window_size();
04541         int kbzmin  = -kbzsize/2;
04542         int kbzmax  = -kbzmin;
04543 
04544         //std::cout<<"kb size x,y,z=="<<kbxsize<<" "<<kbysize<<" "<<kbzsize<<std::endl;
04545         float* wy0 = new float[kbymax - kbymin + 1];
04546         float* wy  = wy0 - kbymin; // wy[kbmin:kbmax]
04547         float* wx0 = new float[kbxmax - kbxmin + 1];
04548         float* wx  = wx0 - kbxmin;
04549         float* wz0 = new float[kbzmax - kbzmin + 1];
04550         float* wz  = wz0 - kbzmin;
04551         float rim = nhalf*float(nhalf);
04552         int count = 0;
04553         float wsum = 0.f;
04554         Transform tftrans = tf; // need transpose of tf here for consistency
04555         tftrans.invert();      // with spider
04556         float xratio=float(nx-2)/float(nz);
04557         float yratio=float(ny)/float(nz);
04558         //std::cout<<"xratio,yratio=="<<xratio<<" "<<yratio<<std::endl;
04559         for (int jy = -nhalf; jy < nhalf; jy++) 
04560         {
04561                 for (int jx = 0; jx <= nhalf; jx++) 
04562                 {
04563                         Vec3f nucur((float)jx, (float)jy, 0.f);
04564                         Vec3f nunew = tftrans*nucur;
04565                         float xnew = nunew[0]*xratio, ynew = nunew[1]*yratio, znew = nunew[2];
04566                         
04567                         if (nunew[0]*nunew[0]+nunew[1]*nunew[1]+nunew[2]*nunew[2] <= rim)
04568                         {
04569                                 count++;
04570                                 std::complex<float> btq(0.f,0.f);
04571                                 bool flip = false;
04572                                 if (xnew < 0.f) {
04573                                         flip = true;
04574                                         xnew = -xnew;
04575                                         ynew = -ynew;
04576                                         znew = -znew;
04577                                 }
04578                                 int ixn = int(Util::round(xnew));
04579                                 int iyn = int(Util::round(ynew));
04580                                 int izn = int(Util::round(znew));
04581                                 // populate weight arrays
04582                                 for (int i=kbzmin; i <= kbzmax; i++) {
04583                                         int izp = izn + i;
04584                                         wz[i] = kbz.i0win_tab(znew - izp);
04585                                         }
04586                                 for (int i=kbymin; i <= kbymax; i++) {
04587                                         int iyp = iyn + i;
04588                                         wy[i] = kby.i0win_tab(ynew - iyp);
04589                                         }
04590                                 for (int i=kbxmin; i <= kbxmax; i++) {
04591                                         int ixp = ixn + i;
04592                                         wx[i] = kbx.i0win_tab(xnew - ixp);
04593                                         }
04594                 
04595 
04596                                 
04597                                 // restrict weight arrays to non-zero elements
04598                                 int lnbz = 0;
04599                                 for (int iz = kbzmin; iz <= -1; iz++) {
04600                                         if (wz[iz] != 0.f) {
04601                                                 lnbz = iz;
04602                                                 break;
04603                                         }
04604                                 }
04605                                 int lnez = 0;
04606                                 for (int iz = kbzmax; iz >= 1; iz--) {
04607                                         if (wz[iz] != 0.f) {
04608                                                 lnez = iz;
04609                                                 break;
04610                                         }
04611                                 }
04612                                 int lnby = 0;
04613                                 for (int iy = kbymin; iy <= -1; iy++) {
04614                                         if (wy[iy] != 0.f) {
04615                                                 lnby = iy;
04616                                                 break;
04617                                         }
04618                                 }
04619                                 int lney = 0;
04620                                 for (int iy = kbymax; iy >= 1; iy--) {
04621                                         if (wy[iy] != 0.f) {
04622                                                 lney = iy;
04623                                                 break;
04624                                         }
04625                                 }
04626                                 int lnbx = 0;
04627                                 for (int ix = kbxmin; ix <= -1; ix++) {
04628                                         if (wx[ix] != 0.f) {
04629                                                 lnbx = ix;
04630                                                 break;
04631                                         }
04632                                 }
04633                                 int lnex = 0;
04634                                 for (int ix = kbxmax; ix >= 1; ix--) {
04635                                         if (wx[ix] != 0.f) {
04636                                                 lnex = ix;
04637                                                 break;
04638                                         }
04639                                 }
04640                                 if    (ixn >= -kbxmin      && ixn <= nxhalf-1-kbxmax
04641                                    && iyn >= -nyhalf-kbymin && iyn <= nyhalf-1-kbymax
04642                                    && izn >= -nzhalf-kbzmin && izn <= nzhalf-1-kbzmax) {
04643                                         // interior points
04644                                         for (int lz = lnbz; lz <= lnez; lz++) {
04645                                                 int izp = izn + lz;
04646                                                 for (int ly=lnby; ly<=lney; ly++) {
04647                                                         int iyp = iyn + ly;
04648                                                         float ty = wz[lz]*wy[ly];
04649                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04650                                                                 int ixp = ixn + lx;
04651                                                                 float wg = wx[lx]*ty;
04652                                                                 btq += cmplx(ixp,iyp,izp)*wg;
04653                                                                 wsum += wg;
04654                                                         }
04655                                                 }
04656                                         }
04657                                 } 
04658                                 else {
04659                                         // points "sticking out"
04660                                         for (int lz = lnbz; lz <= lnez; lz++) {
04661                                                 int izp = izn + lz;
04662                                                 for (int ly=lnby; ly<=lney; ly++) {
04663                                                         int iyp = iyn + ly;
04664                                                         float ty = wz[lz]*wy[ly];
04665                                                         for (int lx=lnbx; lx<=lnex; lx++) {
04666                                                                 int ixp = ixn + lx;
04667                                                                 float wg = wx[lx]*ty;
04668                                                                 bool mirror = false;
04669                                                                 int ixt(ixp), iyt(iyp), izt(izp);
04670                                                                 if (ixt > nxhalf || ixt < -nxhalf) {
04671                                                                         ixt = Util::sgn(ixt)
04672                                                                                   *(nx-2-abs(ixt));
04673                                                                         iyt = -iyt;
04674                                                                         izt = -izt;
04675                                                                         mirror = !mirror;
04676                                                                 }
04677                                                                 if (iyt >= nyhalf || iyt < -nyhalf) {
04678                                                                         if (ixt != 0) {
04679                                                                                 ixt = -ixt;
04680                                                                                 iyt = Util::sgn(iyt)
04681                                                                                           *(ny - abs(iyt));
04682                                                                                 izt = -izt;
04683                                                                                 mirror = !mirror;
04684                                                                         } else {
04685                                                                                 iyt -= ny*Util::sgn(iyt);
04686                                                                         }
04687                                                                 }
04688                                                                 if (izt >= nzhalf || izt < -nzhalf) {
04689                                                                         if (ixt != 0) {
04690                                                                                 ixt = -ixt;
04691                                                                                 iyt = -iyt;
04692                                                                                 izt = Util::sgn(izt)
04693                                                                                           *(nz - abs(izt));
04694                                                                                 mirror = !mirror;
04695                                                                         } else {
04696                                                                                 izt -= Util::sgn(izt)*nz;
04697                                                                         }
04698                                                                 }
04699                                                                 if (ixt < 0) {
04700                                                                         ixt = -ixt;
04701                                                                         iyt = -iyt;
04702                                                                         izt = -izt;
04703                                                                         mirror = !mirror;
04704                                                                 }
04705                                                                 if (iyt == nyhalf) iyt = -nyhalf;
04706                                                                 if (izt == nzhalf) izt = -nzhalf;
04707                                                                 if (mirror)   btq += conj(cmplx(ixt,iyt,izt))*wg;
04708                                                                 else          btq += cmplx(ixt,iyt,izt)*wg;
04709                                                                 wsum += wg;
04710                                                         }
04711                                                 }
04712                                         }
04713                                 }
04714                                 if (flip)  res->cmplx(jx,jy) = conj(btq);
04715                                 else       res->cmplx(jx,jy) = btq;
04716                         }
04717                 }
04718         }
04719         for (int jy = -nhalf; jy < nhalf; jy++)
04720                 for (int jx = 0; jx <= nhalf; jx++)
04721                         res->cmplx(jx,jy) *= count/wsum;
04722         delete[] wx0; delete[] wy0; delete[] wz0;
04723         set_array_offsets(saved_offsets);
04724         res->set_array_offsets(0,0,0);
04725         res->set_shuffled(true);
04726         return res;
04727 }

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

Definition at line 4731 of file emdata_sparx.cpp.

References abs, cmplx(), EMData(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, ImageFormatException, EMAN::Transform::invert(), is_complex(), nx, ny, nz, set_array_offsets(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_shuffled(), set_size(), sqrt(), to_zero(), and EMAN::Vec3f.

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

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

Definition at line 3891 of file emdata_sparx.cpp.

References abs, cmplx(), EMData(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, ImageFormatException, is_complex(), nx, set_array_offsets(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), and to_zero().

03892 {
03893         if (!is_complex())
03894                 throw ImageFormatException("extractline requires a fourier image");
03895         if (nx%2 != 0)
03896                 throw ImageDimensionException("extractline requires nx to be even");
03897         int nxreal = nx - 2;
03898         if (nxreal != ny)
03899                 throw ImageDimensionException("extractline requires ny == nx");
03900         // build complex result image
03901         EMData* res = new EMData();
03902         res->set_size(nx,1,1);
03903         res->to_zero();
03904         res->set_complex(true);
03905         res->set_fftodd(false);
03906         res->set_fftpad(true);
03907         res->set_ri(true);
03908         // Array offsets: (0..nhalf,-nhalf..nhalf-1)
03909         int n = nxreal;
03910         int nhalf = n/2;
03911         vector<int> saved_offsets = get_array_offsets();
03912         set_array_offsets(0,-nhalf,-nhalf);
03913 
03914         // set up some temporary weighting arrays
03915         int kbsize = kb.get_window_size();
03916         int kbmin = -kbsize/2;
03917         int kbmax = -kbmin;
03918         float* wy0 = new float[kbmax - kbmin + 1];
03919         float* wy = wy0 - kbmin; // wy[kbmin:kbmax]
03920         float* wx0 = new float[kbmax - kbmin + 1];
03921         float* wx = wx0 - kbmin;
03922 
03923         int   count = 0;
03924         float wsum = 0.f;
03925         bool  flip = (nuxnew < 0.f);
03926 
03927         for (int jx = 0; jx <= nhalf; jx++) {
03928                 float xnew = jx*nuxnew, ynew = jx*nuynew;
03929                 count++;
03930                 std::complex<float> btq(0.f,0.f);
03931                 if (flip) {
03932                         xnew = -xnew;
03933                         ynew = -ynew;
03934                 }
03935                 int ixn = int(Util::round(xnew));
03936                 int iyn = int(Util::round(ynew));
03937                 // populate weight arrays
03938                 for (int i=kbmin; i <= kbmax; i++) {
03939                         int iyp = iyn + i;
03940                         wy[i] = kb.i0win_tab(ynew - iyp);
03941                         int ixp = ixn + i;
03942                         wx[i] = kb.i0win_tab(xnew - ixp);
03943                 }
03944                 // restrict weight arrays to non-zero elements
03945 
03946                 int lnby = 0;
03947                 for (int iy = kbmin; iy <= -1; iy++) {
03948                         if (wy[iy] != 0.f) {
03949                                 lnby = iy;
03950                                 break;
03951                         }
03952                 }
03953                 int lney = 0;
03954                 for (int iy = kbmax; iy >= 1; iy--) {
03955                         if (wy[iy] != 0.f) {
03956                                 lney = iy;
03957                                 break;
03958                         }
03959                 }
03960                 int lnbx = 0;
03961                 for (int ix = kbmin; ix <= -1; ix++) {
03962                         if (wx[ix] != 0.f) {
03963                                 lnbx = ix;
03964                                 break;
03965                         }
03966                 }
03967                 int lnex = 0;
03968                 for (int ix = kbmax; ix >= 1; ix--) {
03969                         if (wx[ix] != 0.f) {
03970                                 lnex = ix;
03971                                 break;
03972                         }
03973                 }
03974                 if (ixn >= -kbmin && ixn <= nhalf-1-kbmax
03975                                 && iyn >= -nhalf-kbmin && iyn <= nhalf-1-kbmax) {
03976                         // interior points
03977                         for (int ly=lnby; ly<=lney; ly++) {
03978                                 int iyp = iyn + ly;
03979                                 for (int lx=lnbx; lx<=lnex; lx++) {
03980                                         int ixp = ixn + lx;
03981                                         float wg = wx[lx]*wy[ly];
03982                                         btq += cmplx(ixp,iyp)*wg;
03983                                         wsum += wg;
03984                                 }
03985                         }
03986                 } else {
03987                         // points "sticking out"
03988                         for (int ly=lnby; ly<=lney; ly++) {
03989                                 int iyp = iyn + ly;
03990                                 for (int lx=lnbx; lx<=lnex; lx++) {
03991                                         int ixp = ixn + lx;
03992                                         float wg = wx[lx]*wy[ly];
03993                                         bool mirror = false;
03994                                         int ixt(ixp), iyt(iyp);
03995                                         if (ixt > nhalf || ixt < -nhalf) {
03996                                                 ixt = Util::sgn(ixt)*(n - abs(ixt));
03997                                                 iyt = -iyt;
03998                                                 mirror = !mirror;
03999                                         }
04000                                         if (iyt >= nhalf || iyt < -nhalf) {
04001                                                 if (ixt != 0) {
04002                                                         ixt = -ixt;
04003                                                         iyt = Util::sgn(iyt)*(n - abs(iyt));
04004                                                         mirror = !mirror;
04005                                                 } else {
04006                                                         iyt -= n*Util::sgn(iyt);
04007                                                 }
04008                                         }
04009                                         if (ixt < 0) {
04010                                                 ixt = -ixt;
04011                                                 iyt = -iyt;
04012                                                 mirror = !mirror;
04013                                         }
04014                                         if (iyt == nhalf) iyt = -nhalf;
04015                                         if (mirror) btq += conj(cmplx(ixt,iyt))*wg;
04016                                         else        btq += cmplx(ixt,iyt)*wg;
04017                                         wsum += wg;
04018                                 }
04019                         }
04020                 }
04021                 if (flip) res->cmplx(jx) = conj(btq);
04022                 else      res->cmplx(jx) = btq;
04023         }
04024         for (int jx = 0; jx <= nhalf; jx++)  res->cmplx(jx) *= count/wsum;
04025 
04026         delete[] wx0; delete[] wy0;
04027         set_array_offsets(saved_offsets);
04028         res->set_array_offsets(0,0,0);
04029         return res;
04030 }

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 3779 of file emdata_sparx.cpp.

References cmplx(), get_ndim(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, ImageFormatException, is_complex(), and nx.

03779                                                                                        {
03780         if (2 != get_ndim())
03781                 throw ImageDimensionException("extractpoint needs a 2-D image.");
03782         if (!is_complex())
03783                 throw ImageFormatException("extractpoint requires a fourier image");
03784         int nxreal = nx - 2;
03785         if (nxreal != ny)
03786                 throw ImageDimensionException("extractpoint requires ny == nx");
03787         int nhalf = nxreal/2;
03788         int kbsize = kb.get_window_size();
03789         int kbmin = -kbsize/2;
03790         int kbmax = -kbmin;
03791         bool flip = (nuxnew < 0.f);
03792         if (flip) {
03793                 nuxnew *= -1;
03794                 nuynew *= -1;
03795         }
03796         // put (xnew,ynew) on a grid.  The indices will be wrong for
03797         // the Fourier elements in the image, but the grid sizing will
03798         // be correct.
03799         int ixn = int(Util::round(nuxnew));
03800         int iyn = int(Util::round(nuynew));
03801         // set up some temporary weighting arrays
03802         float* wy0 = new float[kbmax - kbmin + 1];
03803         float* wy = wy0 - kbmin; // wy[kbmin:kbmax]
03804         float* wx0 = new float[kbmax - kbmin + 1];
03805         float* wx = wx0 - kbmin;
03806         for (int i = kbmin; i <= kbmax; i++) {
03807                         int iyp = iyn + i;
03808                         wy[i] = kb.i0win_tab(nuynew - iyp);
03809                         int ixp = ixn + i;
03810                         wx[i] = kb.i0win_tab(nuxnew - ixp);
03811         }
03812         // restrict loops to non-zero elements
03813         int iymin = 0;
03814         for (int iy = kbmin; iy <= -1; iy++) {
03815                 if (wy[iy] != 0.f) {
03816                         iymin = iy;
03817                         break;
03818                 }
03819         }
03820         int iymax = 0;
03821         for (int iy = kbmax; iy >= 1; iy--) {
03822                 if (wy[iy] != 0.f) {
03823                         iymax = iy;
03824                         break;
03825                 }
03826         }
03827         int ixmin = 0;
03828         for (int ix = kbmin; ix <= -1; ix++) {
03829                 if (wx[ix] != 0.f) {
03830                         ixmin = ix;
03831                         break;
03832                 }
03833         }
03834         int ixmax = 0;
03835         for (int ix = kbmax; ix >= 1; ix--) {
03836                 if (wx[ix] != 0.f) {
03837                         ixmax = ix;
03838                         break;
03839                 }
03840         }
03841         float wsum = 0.0f;
03842         for (int iy = iymin; iy <= iymax; iy++)
03843                 for (int ix = ixmin; ix <= ixmax; ix++)
03844                         wsum += wx[ix]*wy[iy];
03845         std::complex<float> result(0.f,0.f);
03846         if ((ixn >= -kbmin) && (ixn <= nhalf-1-kbmax) && (iyn >= -nhalf-kbmin) && (iyn <= nhalf-1-kbmax)) {
03847                 // (xin,yin) not within window border from the edge
03848                 for (int iy = iymin; iy <= iymax; iy++) {
03849                         int iyp = iyn + iy;
03850                         for (int ix = ixmin; ix <= ixmax; ix++) {
03851                                 int ixp = ixn + ix;
03852                                 float w = wx[ix]*wy[iy];
03853                                 std::complex<float> val = cmplx(ixp,iyp);
03854                                 result += val*w;
03855                         }
03856                 }
03857         } else {
03858                 // points that "stick out"
03859                 for (int iy = iymin; iy <= iymax; iy++) {
03860                         int iyp = iyn + iy;
03861                         for (int ix = ixmin; ix <= ixmax; ix++) {
03862                                 int ixp = ixn + ix;
03863                                 bool mirror = false;
03864                                 int ixt= ixp, iyt= iyp;
03865                                 if (ixt < 0) {
03866                                         ixt = -ixt;
03867                                         iyt = -iyt;
03868                                         mirror = !mirror;
03869                                 }
03870                                 if (ixt > nhalf) {
03871                                         ixt = nxreal - ixt;
03872                                         iyt = -iyt;
03873                                         mirror = !mirror;
03874                                 }
03875                                 if (iyt > nhalf-1)  iyt -= nxreal;
03876                                 if (iyt < -nhalf)   iyt += nxreal;
03877                                 float w = wx[ix]*wy[iy];
03878                                 std::complex<float> val = this->cmplx(ixt,iyt);
03879                                 if (mirror)  result += conj(val)*w;
03880                                 else         result += val*w;
03881                         }
03882                 }
03883         }
03884         if (flip)  result = conj(result)/wsum;
03885         else       result /= wsum;
03886         delete [] wx0;
03887         delete [] wy0;
03888         return result;
03889 }

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 4040 of file emdata_sparx.cpp.

References get_array_offsets(), ImageFormatException, is_complex(), is_shuffled(), nx, ny, nz, set_array_offsets(), set_shuffled(), swapx(), and update().

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

04040                          {
04041         if (!is_complex())
04042                 throw ImageFormatException("fft_shuffle requires a fourier image");
04043         vector<int> offsets = get_array_offsets();
04044         set_array_offsets(); // clear offsets before shuffling
04045         EMData& self = *this;
04046         int nyhalf = ny/2;
04047         int nzhalf = nz/2;
04048         int nbytes = nx*sizeof(float);
04049         float* temp = new float[nx];
04050         for (int iz=0; iz < nz; iz++)
04051                 for (int iy=0; iy < nyhalf; iy++)
04052                         swapx(&self(0,iy,iz),&self(0,iy+nyhalf,iz),temp,nbytes);
04053         if (nz > 1) {
04054                 for (int iy=0; iy < ny; iy++)
04055                         for (int iz=0; iz < nzhalf; iz++)
04056                                 swapx(&self(0,iy,iz),&self(0,iy,iz+nzhalf),temp,nbytes);
04057         }
04058         set_shuffled(!is_shuffled()); // toggle
04059         set_array_offsets(offsets); // reset offsets
04060         update();
04061         delete[] temp;
04062 }

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 7312 of file emdata_sparx.cpp.

References cmplx(), copy(), depad(), do_fft_inplace(), do_ift_inplace(), fint, get_data(), get_xsize(), get_ysize(), get_zsize(), is_complex(), is_fftodd(), norm_pad(), nx, ny, nz, set_array_offsets(), set_attr(), set_fftodd(), set_fftpad(), set_ri(), and update().

07312                                                            {
07313 
07314 
07315         bool   complex_input = this->is_complex();
07316         nx  = this->get_xsize();
07317         ny  = this->get_ysize();
07318         nz  = this->get_zsize();
07319         int nox;
07320         if (complex_input) nox = (nx - 2 + this->is_fftodd()); else nox = nx;
07321 
07322         int lsd2 = (nox + 2 - nox%2) / 2; // Extended x-dimension of the complex image
07323 
07324         EMData* fp = NULL; // output image
07325         if(complex_input) {
07326                 // fimage must remain pristine
07327                 fp = this->copy();
07328         } else {
07329                 fp = this->norm_pad( false, 1);
07330                 fp->do_fft_inplace();
07331         }
07332         fp->set_array_offsets(1,1,1);
07333         int nx2 = nox/2;
07334         int ny2 = ny/2;
07335         int nz2 = nz/2;
07336         float *fint = image->get_data();
07337         for ( int iz = 1; iz <= nz; iz++) {
07338                 int jz=nz2-iz+1; if(jz<0) jz += nz;
07339                 for ( int iy = 1; iy <= ny; iy++) {
07340                         int jy=ny2-iy+1; if(jy<0) jy += ny;
07341                         for ( int ix = 1; ix <= lsd2; ix++) {
07342                                 int jx = nx2-ix+1;
07343                                 fp->cmplx(ix,iy,iz) *= fint(jx,jy,jz);
07344                         }
07345                 }
07346         }
07347 
07348         fp->set_ri(1);
07349         fp->set_fftpad(true);
07350         fp->set_attr("npad", 1);
07351         if (nx%2 == 1) fp->set_fftodd(true);
07352         else fp->set_fftodd(false);
07353         if(RetReal) {
07354                 fp->do_ift_inplace();
07355                 fp->depad();
07356         }
07357         fp->set_array_offsets(0,0,0);
07358         fp->update();
07359 
07360         return fp;
07361 }

float EMData::find_3d_threshold float  mass,
float  pixel_size
 

Definition at line 5975 of file emdata_sparx.cpp.

References abs, C, get_attr(), get_ndim(), ImageDimensionException, min, nx, nx, ny, R, and rdata.

05976 {
05977         /* Exception Handle */
05978         if(get_ndim()!=3)
05979                 throw ImageDimensionException("The image should be 3D");
05980         /* ===============================================================*/
05981 
05982         /* Calculation of the volume of the voxels */
05983         float density_1_mole, vol_1_mole, vol_angstrom;
05984         int  vol_voxels;
05985         density_1_mole = static_cast<float>( (mass*1000.0f)/avagadro );
05986         vol_1_mole =  static_cast<float>( density_1_mole/density_protein );
05987         vol_angstrom =  static_cast<float>( vol_1_mole*(double)pow((double)pow(10.0,8),3) );
05988         vol_voxels = static_cast<int> (vol_angstrom/(double)pow(pixel_size,3));
05989         /* ===============================================================*/
05990 
05991 
05992         float thr1 = get_attr("maximum");
05993         float thr3 = get_attr("minimum");
05994         float thr2 = (thr1-thr3)/2 + thr3;
05995         size_t size = (size_t)nx*ny*nz;
05996         float x0 = thr1,x3 = thr3,x1,x2,THR=0;
05997 
05998         #ifdef _WIN32
05999                 int ILE = _cpp_min(nx*ny*nx,_cpp_max(1,vol_voxels));
06000         #else
06001                 int ILE = std::min(nx*ny*nx,std::max(1,vol_voxels));
06002         #endif  //_WIN32
06003 
06004         if (abs(thr3-thr2)>abs(thr2-thr1)) {
06005                 x1=thr2;
06006                 x2=thr2+C*(thr3-thr2);
06007         } else {
06008                 x2=thr2;
06009                 x1=thr2-C*(thr2-thr1);
06010         }
06011 
06012         int cnt1=0,cnt2=0;
06013         for (size_t i=0;i<size;++i) {
06014                 if(rdata[i]>=x1)  cnt1++;
06015                 if(rdata[i]>=x2)  cnt2++;
06016         }
06017         float LF1 = static_cast<float>( cnt1 - ILE );
06018         float F1 = LF1*LF1;
06019         float LF2 = static_cast<float>( cnt2 - ILE );
06020         float F2 = LF2*LF2;
06021 
06022         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)))
06023         {
06024                 if(F2 < F1) {
06025                         x0=x1;
06026                         x1=x2;
06027                         x2 = R*x1 + C*x3;
06028                         F1=F2;
06029                         int cnt=0;
06030                         for(size_t i=0;i<size;++i)
06031                                 if(rdata[i]>=x2)
06032                                         cnt++;
06033                         LF2 = static_cast<float>( cnt - ILE );
06034                         F2 = LF2*LF2;
06035                 } else {
06036                         x3=x2;
06037                         x2=x1;
06038                         x1=R*x2 + C*x0;
06039                         F2=F1;
06040                         int cnt=0;
06041                         for(size_t i=0;i<size;++i)
06042                                 if(rdata[i]>=x1)
06043                                         cnt++;
06044                         LF1 = static_cast<float>( cnt - ILE );
06045                         F1 = LF1*LF1;
06046                 }
06047         }
06048 
06049         if(F1 < F2) {
06050                 ILE = static_cast<int> (LF1 + ILE);
06051                 THR = x1;
06052         } else {
06053                 ILE = static_cast<int> (LF2 + ILE);
06054                 THR = x2;
06055         }
06056         return THR;
06057 
06058 }

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 7180 of file emdata_sparx.cpp.

References copy(), depad(), do_ift_inplace(), fint, fout, get_data(), nx, ny, nz, set_complex(), set_fftodd(), set_ri(), set_size(), to_zero(), and update().

07180                                                                  {
07181 
07182         int nyn, nzn, lsd, lsdn, inx, iny, inz;
07183         int i, j;
07184 
07185         if(ny > 1) {
07186                 nyn = nyni;
07187                 if(nz > 1) {
07188                         nzn = nzni;
07189                 }  else {
07190                         nzn = 1;
07191                 }
07192         } else {
07193                 nyn = 1; nzn = 1;
07194         }
07195         lsd = nx-2 + 2 - nx%2;
07196         lsdn = nxn + 2 - nxn%2;
07197 //  do out of place ft
07198         EMData *temp_ft = this->copy();
07199         EMData *ret = this->copy();
07200         ret->set_size(lsdn, nyn, nzn);
07201         ret->to_zero();
07202         float *fout = ret->get_data();
07203         float *fint = temp_ft->get_data();
07204 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07205 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07206 //      float  sq2 = 1.0f/std::sqrt(2.0f);
07207         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
07208         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
07209         inx = nxn-(nx-2); iny = nyn - ny; inz = nzn - nz;
07210         for (j=1; j<=nyn; j++)
07211                 for (i=1; i<=lsdn; i++)
07212                         fout(i,j,1)=fint((i-1)/2*4+2-i%2,j*2-1,1);
07213         ret->set_complex(true);
07214         ret->set_ri(1);
07215         //ret->set_fftpad(true);
07216         //ret->set_attr("npad", 1);
07217         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07218         if(RetReal) {
07219                 ret->do_ift_inplace();
07220                 ret->depad();
07221         }
07222         ret->update();
07223 
07224         delete temp_ft;
07225         temp_ft = 0;
07226         return ret;
07227 }

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

Definition at line 7229 of file emdata_sparx.cpp.

References copy(), depad(), do_ift_inplace(), fint, fout, get_data(), nx, ny, ny, set_complex(), set_fftodd(), set_ri(), set_size(), sqrt(), to_zero(), and update().

07229                                                                         {
07230 
07231         int nyn, nzn, lsd, lsdn, inx, iny, inz;
07232         int i, j;
07233 
07234         nyn = nyni;
07235         nzn = 1;
07236         lsd = nx;
07237         lsdn = nxn + 2 - nxn%2;
07238 
07239         EMData *temp_ft = this->copy();
07240         EMData *ret = this->copy();
07241         ret->set_size(lsdn, nyn, nzn);
07242         ret->to_zero();
07243         float *fout = ret->get_data();
07244         float *fint = temp_ft->get_data();
07245 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07246 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07247         float  sq2 = 1.0f/std::sqrt(2.0f);
07248 
07249         for (size_t i = 0; i < (size_t)lsd*ny*nz; i++)  fint[i] *= 4;
07250 
07251         inx = nxn-(nx-2); iny = nyn - ny; inz = nzn - nz;
07252         for (j=1; j<=ny/4; j++)
07253                 for (i=1; i<=(nx-2)/2+2; i++) {
07254                         int g = (i-1)/2+1;
07255                         if ((g+j)%2 == 0) {
07256                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1+ny/2,1);
07257                         } else {
07258                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1+ny/2,1);
07259                         }
07260                 }
07261 
07262         for (j=ny/4+1; j<=ny/4+1; j++)
07263                 for (i=1; i<=(nx-2)/2+2; i++) {
07264                         int g = (i-1)/2+1;
07265                         if ((g+j)%2 == 0) {
07266                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07267                         } else {
07268                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07269                         }
07270                 }
07271 
07272         for (j=ny/4+2; j<=ny/2; j++)
07273                 for (i=1; i<=(nx-2)/2+2; i++) {
07274                         int g = (i-1)/2+1;
07275                         if ((g+j)%2 == 0) {
07276                                 fout(i,j+ny/2,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07277                         } else {
07278                                 fout(i,j+ny/2,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07279                         }
07280                 }
07281 
07282         if (nx%2 == 0) {
07283                 for (j=1; j<=nyn; j++) {
07284                         fout((nx-2)/2+1,j,1) *= sq2;
07285                         fout((nx-2)/2+2,j,1) *= sq2;
07286                 }
07287                 for (i=1; i<=lsd/2+1; i++) {
07288                         fout(i,ny/4+1+ny/2,1) = sq2*fout(i,ny/4+1,1);
07289                         fout(i,ny/4+1,1) *= sq2;
07290                 }
07291         }
07292 
07293         ret->set_complex(true);
07294         ret->set_ri(1);
07295 
07296         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07297         if(RetReal) {
07298                 ret->do_ift_inplace();
07299                 ret->depad();
07300         }
07301         ret->update();
07302 
07303         delete temp_ft;
07304         temp_ft = 0;
07305         return ret;
07306 }

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

Definition at line 4135 of file emdata_sparx.cpp.

References cmplx(), copy_head(), extractpoint2(), fft_shuffle(), get_ndim(), ImageDimensionException, ImageFormatException, is_complex(), is_fftodd(), is_shuffled(), nx, ny, set_array_offsets(), and update().

04135                                                                              {
04136         if (2 != get_ndim())
04137                 throw ImageDimensionException("fouriergridrot2d needs a 2-D image.");
04138         if (!is_complex())
04139                 throw ImageFormatException("fouriergridrot2d requires a fourier image");
04140         int nxreal = nx - 2 + int(is_fftodd());
04141         if (nxreal != ny)
04142                 throw ImageDimensionException("fouriergridrot2d requires ny == nx(real)");
04143         if (0 != nxreal%2)
04144                 throw ImageDimensionException("fouriergridrot2d needs an even image.");
04145         if (scale == 0.0f) scale = 1.0f;
04146         int nxhalf = nxreal/2;
04147         int nyhalf = ny/2;
04148         float cir = (float)((nxhalf-1)*(nxhalf-1));
04149 
04150         if (!is_shuffled()) fft_shuffle();
04151 
04152         EMData* result = copy_head();
04153         set_array_offsets(0,-nyhalf);
04154         result->set_array_offsets(0,-nyhalf);
04155 
04156 
04157 
04158         ang = ang*(float)DGR_TO_RAD;
04159         float cang = cos(ang);
04160         float sang = sin(ang);
04161         for (int iy = -nyhalf; iy < nyhalf; iy++) {
04162                 float ycang = iy*cang;
04163                 float ysang = iy*sang;
04164                 for (int ix = 0; ix <= nxhalf; ix++) {
04165                         float nuxold = (ix*cang - ysang)*scale;
04166                         float nuyold = (ix*sang + ycang)*scale;
04167                         if (nuxold*nuxold+nuyold*nuyold<cir) result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04168                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04169                 }
04170         }
04171         result->set_array_offsets();
04172         result->fft_shuffle(); // reset to an unshuffled result
04173         result->update();
04174         set_array_offsets();
04175         fft_shuffle(); // reset to an unshuffled complex image
04176         return result;
04177 }

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

Definition at line 4179 of file emdata_sparx.cpp.

References cmplx(), copy_head(), extractpoint2(), fft_shuffle(), get_ndim(), ImageDimensionException, ImageFormatException, is_complex(), is_fftodd(), is_shuffled(), nx, ny, set_array_offsets(), and update().

04179                                                                                           {
04180         if (2 != get_ndim())
04181                 throw ImageDimensionException("fouriergridrot_shift2d needs a 2-D image.");
04182         if (!is_complex())
04183                 throw ImageFormatException("fouriergridrot_shift2d requires a fourier image");
04184         int nxreal = nx - 2 + int(is_fftodd());
04185         if (nxreal != ny)
04186                 throw ImageDimensionException("fouriergridrot_shift2d requires ny == nx(real)");
04187         if (0 != nxreal%2)
04188                 throw ImageDimensionException("fouriergridrot_shift2d needs an even image.");
04189         int nxhalf = nxreal/2;
04190         int nyhalf = ny/2;
04191 
04192         if (!is_shuffled()) fft_shuffle();
04193 
04194         EMData* result = copy_head();
04195         set_array_offsets(0, -nyhalf);
04196         result->set_array_offsets(0, -nyhalf);
04197 
04198         ang = ang*(float)DGR_TO_RAD;
04199         float cang = cos(ang);
04200         float sang = sin(ang);
04201         float temp = -2.0f*M_PI/nxreal;
04202         for (int iy = -nyhalf; iy < nyhalf; iy++) {
04203                 float ycang = iy*cang;
04204                 float ysang = iy*sang;
04205                 for (int ix = 0; ix <= nxhalf; ix++) {
04206                         float nuxold = ix*cang - ysang;
04207                         float nuyold = ix*sang + ycang;
04208                         result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04209                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04210                         float phase_ang = temp*(sx*ix+sy*iy);
04211                         result->cmplx(ix,iy) *= complex<float>(cos(phase_ang), sin(phase_ang));
04212                 }
04213         }
04214         result->set_array_offsets();
04215         result->fft_shuffle(); // reset to an unshuffled result
04216         result->update();
04217         set_array_offsets();
04218         fft_shuffle(); // reset to an unshuffled complex image
04219         return result;
04220 }

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

Definition at line 6843 of file emdata_sparx.cpp.

References copy(), depad(), do_fft(), do_ift_inplace(), fint, fout, get_data(), ImageDimensionException, ImageFormatException, is_complex(), nx, nx, ny, ny, nz, set_attr(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), sqrt(), to_zero(), and update().

06843                                                                       {
06844 
06845         int nyn, nzn, lsd, lsdn, inx, iny, inz;
06846         int i, j, k;
06847         if (is_complex())
06848                 throw ImageFormatException("Input image has to be real");
06849 
06850         if(ny > 1) {
06851                 nyn = nyni;
06852                 if(nz > 1) {
06853                         nzn = nzni;
06854                 }  else {
06855                         nzn = 1;
06856                 }
06857         } else {
06858                 nyn = 1; nzn = 1;
06859         }
06860         if(nxn<nx || nyn<ny || nzn<nz)  throw ImageDimensionException("Cannot reduce the image size");
06861         lsd = nx + 2 - nx%2;
06862         lsdn = nxn + 2 - nxn%2;
06863 //  do out of place ft
06864         EMData *temp_ft = do_fft();
06865         EMData *ret = this->copy();
06866         ret->set_size(lsdn, nyn, nzn);
06867         ret->to_zero();
06868         float *fout = ret->get_data();
06869         float *fint = temp_ft->get_data();
06870 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
06871 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
06872         float  sq2 = 1.0f/std::sqrt(2.0f);
06873         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
06874         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
06875         inx = nxn-nx; iny = nyn - ny; inz = nzn - nz;
06876         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);
06877         if(nyn>1) {
06878         //cout << "  " <<nxn<<"  " <<nyn<<" A " <<nzn<<endl;
06879                 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);
06880                 if(nzn>1) {
06881                         for (k=nz/2+2+inz; k<=nzn; k++) {
06882                                 for (j=1; j<=ny/2+1; j++) {
06883                                         for (i=1; i<=lsd; i++) {
06884                                                 fout(i,j,k)=fint(i,j,k-inz);
06885                                         }
06886                                 }
06887                                 for (j=ny/2+2+iny; j<=nyn; j++) {
06888                                         for (i=1; i<=lsd; i++) {
06889                                                 fout(i,j,k)=fint(i,j-iny,k-inz);
06890                                         }
06891                                 }
06892                         }
06893                 }
06894         }
06895 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
06896 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
06897 //       ELEMENT.
06898         if(nx%2 == 0 && inx !=0) {
06899                 for (k=1; k<=nzn; k++) {
06900                         for (j=1; j<=nyn; j++) {
06901                                 fout(nx+1,j,k) *= sq2;
06902                                 fout(nx+2,j,k) *= sq2;
06903                         }
06904                 }
06905                 if(nyn>1) {
06906                         for (k=1; k<=nzn; k++) {
06907                           for (i=1; i<=lsd; i++) {
06908                             fout(i,ny/2+1+iny,k) = sq2*fout(i,ny/2+1,k);
06909                             fout(i,ny/2+1,k) *= sq2;
06910                           }
06911                         }
06912                         if(nzn>1) {
06913                                 for (j=1; j<=nyn; j++) {
06914                                         for (i=1; i<=lsd; i++) {
06915                                                 fout(i,j,nz/2+1+inz) = sq2*fout(i,j,nz/2+1);
06916                                                 fout(i,j,nz/2+1) *= sq2;
06917                                         }
06918                                 }
06919                         }
06920                 }
06921         }
06922         ret->set_complex(true);
06923 /*
06924 //  For padding from odd to even dimension additional shift by 1 pixel is necessary.
06925         float  xshift = 0.f, yshift = 0.f, zshift = 0.f;
06926         int nyn2, nzn2;
06927         if(nxn > nx && nx%2 == 1)  xshift = 1.0f;
06928         if(ny > 1) {
06929                 if(nyn > ny && ny%2 == 1)  yshift = 1.0f;
06930                 nyn2 = nyn/2;
06931                 if(nz > 1) {
06932                         if(nzn > nz && nz%2 == 1)  zshift = 1.0f;
06933                         nzn2 = nzn/2;
06934                 }  else {
06935                         nzn2 = 0;
06936                 }
06937         } else {
06938                 nyn2 = 0; nzn2 = 0;
06939         }
06940         if(xshift == 1.0 || yshift == 1.0 || zshift == 1.0)  {
06941                 ret->set_array_offsets(1,1,1);
06942                 int  lsdn2 = lsd/2;
06943                 for (int iz = 1; iz <= nzn; iz++) {
06944                         int jz=iz-1; if(jz>nzn2) jz=jz-nzn;
06945                         for (int iy = 1; iy <= nyn; iy++) {
06946                                 int jy=iy-1; if(jy>nyn2) jy=jy-nyn;
06947                                 for (int ix = 1; ix <= lsdn2; ix++) {
06948                                         int jx=ix-1;
06949                                         ret->cmplx(ix,iy,iz) *=
06950                                         exp(-float(twopi)*iimag*(xshift*jx/nxn + yshift*jy/nyn+ zshift*jz/nzn));
06951                                 }
06952                         }
06953                 }
06954                 ret->set_array_offsets(0,0,0);
06955         }*/
06956         ret->set_ri(1);
06957         ret->set_fftpad(true);
06958         ret->set_attr("npad", 1);
06959         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
06960         if(RetReal) {
06961                 ret->do_ift_inplace();
06962                 ret->depad();
06963         }
06964         ret->update();
06965 
06966         /*Dict d1 = temp_ft->get_attr_dict();
06967         Dict d2 = ret->get_attr_dict();
06968         printf("-----------------Attribute Dict for temp_ft--------------\n");
06969         EMUtil::dump_dict(d1);
06970         printf("-----------------Attribute Dict for ret--------------\n");
06971         EMUtil::dump_dict(d2);*/
06972         delete temp_ft;
06973         temp_ft = 0;
06974         return ret;
06975 }

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 6977 of file emdata_sparx.cpp.

References copy_head(), depad(), do_fft(), do_ift_inplace(), fint, fout, get_data(), ImageDimensionException, is_complex(), nx, ny, nz, set_attr(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), and update().

06977                                                                       {
06978 
06979         int nyn, nzn, lsd, lsdn, inx, iny, inz;
06980         int i, j, k;
06981         float  *fint;
06982         EMData *temp_ft = NULL;
06983         //if (is_complex())
06984         //      throw ImageFormatException("Input image has to be real");
06985 
06986         if(ny > 1) {
06987                 nyn = nyni;
06988                 if(nz > 1) {
06989                         nzn = nzni;
06990                 }  else {
06991                         nzn = 1;
06992                 }
06993         } else {
06994                 nyn = 1; nzn = 1;
06995         }
06996         if (is_complex()) {
06997                 nx = nx - 2 + nx%2;
06998                 fint = get_data();
06999         } else {
07000                 //  do out of place ft
07001                 temp_ft = do_fft();
07002                 fint = temp_ft->get_data();
07003         }
07004         if(nxn>nx || nyn>ny || nzn>nz)  throw ImageDimensionException("Cannot increase the image size");
07005         lsd = nx + 2 - nx%2;
07006         lsdn = nxn + 2 - nxn%2;
07007         EMData *ret = this->copy_head();
07008         ret->set_size(lsdn, nyn, nzn);
07009         float *fout = ret->get_data();
07010 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07011 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07012         //float  sq2 = std::sqrt(2.0f);
07013         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
07014         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
07015         inx = nx - nxn;  iny = ny - nyn;  inz = nz - nzn;
07016         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);
07017         if(nyn>1) {
07018                 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);
07019                 if(nzn>1) {
07020                         for (k=nzn/2+2; k<=nzn; k++) {
07021                                 for (j=1; j<=nyn/2+1; j++) {
07022                                         for (i=1; i<=lsdn; i++) {
07023                                                 fout(i,j,k)=fint(i,j,k+inz);
07024                                         }
07025                                 }
07026                                 for (j=nyn/2+2; j<=nyn; j++) {
07027                                         for (i=1; i<=lsdn; i++) {
07028                                                 fout(i,j,k)=fint(i,j+iny,k+inz);
07029                                         }
07030                                 }
07031                         }
07032                 }
07033         }
07034 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
07035 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
07036 //       ELEMENT.
07037         /*
07038         if(nxn%2 == 0 && inx !=0) {
07039                 for (k=1; k<=nzn; k++) {
07040                         for (j=1; j<=nyn; j++) {
07041                                 fout(nxn+1,j,k) *= sq2;
07042                                 fout(nxn+2,j,k) *= sq2;
07043                         }
07044                 }
07045                 if(nyn>1) {
07046                         for (k=1; k<=nzn; k++) {
07047                           for (i=1; i<=lsdn; i++) {
07048                             fout(i,nyn/2+1+iny,k) = sq2*fout(i,nyn/2+1,k);
07049                             fout(i,nyn/2+1,k) *= sq2;
07050                           }
07051                         }
07052                         if(nzn>1) {
07053                                 for (j=1; j<=nyn; j++) {
07054                                         for (i=1; i<=lsdn; i++) {
07055                                                 fout(i,j,nzn/2+1+inz) = sq2*fout(i,j,nzn/2+1);
07056                                                 fout(i,j,nzn/2+1) *= sq2;
07057                                         }
07058                                 }
07059                         }
07060                 }
07061         }*/
07062         ret->set_complex(true);
07063         ret->set_ri(1);
07064         ret->set_fftpad(true);
07065         ret->set_attr("npad", 1);
07066         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07067         if(RetReal) {
07068                 ret->do_ift_inplace();
07069                 ret->depad();
07070         }
07071         ret->update();
07072 
07073         /*Dict d1 = temp_ft->get_attr_dict();
07074         Dict d2 = ret->get_attr_dict();
07075         printf("-----------------Attribute Dict for temp_ft--------------\n");
07076         EMUtil::dump_dict(d1);
07077         printf("-----------------Attribute Dict for ret--------------\n");
07078         EMUtil::dump_dict(d2);*/
07079         if (!is_complex()) {
07080                 delete temp_ft;
07081                 temp_ft = 0;
07082         }
07083         return ret;
07084 }

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 1015 of file emdata_metadata.cpp.

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

01016 {
01017         const int ndims = 2;
01018         if (get_ndim() != ndims) {
01019                 throw ImageDimensionException("2D only");
01020         }
01021         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
01022         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
01023         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
01024         boost::array<std::size_t,ndims> bases={{x0, y0}};
01025         marray.reindex(bases);
01026         return marray;
01027 }

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 956 of file emdata_metadata.cpp.

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

00957 {
00958         const int ndims = 2;
00959         if (get_ndim() != ndims) {
00960                 throw ImageDimensionException("2D only");
00961         }
00962         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00963         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00964         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00965         return marray;
00966 }

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 990 of file emdata_metadata.cpp.

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

00991 {
00992         const int ndims = 2;
00993         if (get_ndim() != ndims) {
00994                 throw ImageDimensionException("2D only");
00995         }
00996         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00997         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00998         boost::array<std::size_t,ndims> bases={{x0, y0}};
00999         marray.reindex(bases);
01000         return marray;
01001 }

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 935 of file emdata_metadata.cpp.

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

00936 {
00937         const int ndims = 2;
00938         if (get_ndim() != ndims) {
00939                 throw ImageDimensionException("2D only");
00940         }
00941         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00942         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00943         return marray;
00944 }

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 1030 of file emdata_metadata.cpp.

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

01031 {
01032         const int ndims = 3;
01033         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
01034         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
01035         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
01036         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
01037         marray.reindex(bases);
01038         return marray;
01039 }

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 969 of file emdata_metadata.cpp.

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

00970 {
00971         const int ndims = 3;
00972         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00973         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00974         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00975         return marray;
00976 }

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 979 of file emdata_metadata.cpp.

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

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

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 1004 of file emdata_metadata.cpp.

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

01005 {
01006         const int ndims = 3;
01007         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
01008         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
01009         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
01010         marray.reindex(bases);
01011         return marray;
01012 }

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 947 of file emdata_metadata.cpp.

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

00948 {
00949         const int ndims = 3;
00950         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00951         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00952         return marray;
00953 }

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 1317 of file emdata_metadata.cpp.

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

01318 {
01319 
01320         if (thres < 0 || thres > 1){
01321                 LOGERR("threshold bust be between 0 and 1.");
01322                 throw InvalidValueException(thres, "thres: 0 <= thres <= 1");
01323         }
01324                 
01325         EMData * amps = get_fft_amplitude();
01326         vector<float> ampvector = amps->get_data_as_vector();
01327         // 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!
01328         sort (ampvector.begin(), ampvector.end()); 
01329         int thresidx = int(thres * ampvector.size());
01330         float thresamp =  ampvector[thresidx];
01331 
01332         return thresamp;
01333 }

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

Definition at line 2352 of file emdata.h.

Referenced by center_origin_fft(), EMAN::QuadMinDotCmp::cmp(), depad(), depad_corner(), divkbsinh(), divkbsinh_rect(), downsample(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), fft_shuffle(), getconvpt2d_kbi0(), helicise_grid(), insert_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), nn(), nn_ctf(), nn_ctf_applied(), nn_SSNR(), nn_SSNR_ctf(), norm_pad(), 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(), EMAN::rsconvolution(), symplane0(), symplane0_ctf(), symplane0_rect(), 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 1051 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::TomoAverager::add_image(), ali3d_d(), EMAN::RefineAligner::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::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), 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(), find_3d_threshold(), 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(), 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::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(), norm_pad(), EMAN::Util::pad(), EMAN::LowpassAutoBProcessor::preprocess(), EMAN::Wiener2DFourierProcessor::process(), EMAN::SymAlignProcessor::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::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::StandardProjector::project3d(), ReadStackandDist(), ReadStackandDist_Cart(), recons3d_4nn(), and EMAN::PointArray::set_from_density_map().

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

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 1134 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::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(), and rotavg().

01135 {
01136         ENTERFUNC;
01137 
01138         if(attr_dict.has_key(key)) {
01139                 return get_attr(key);
01140         }
01141         else {
01142                 return em_obj;
01143         }
01144 
01145         EXITFUNC;
01146 }

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 1148 of file emdata_metadata.cpp.

References attr_dict, and update_stat().

Referenced by EMAN::CtfAverager::add_image(), EMAN::TestUtil::dump_emdata(), main(), EMAN::NewFourierProcessor::preprocess(), EMAN::LowpassAutoBProcessor::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().

01149 {
01150         update_stat();
01151         
01152         Dict tmp=Dict(attr_dict);
01153         tmp["nx"]=nx;
01154         tmp["ny"]=ny;
01155         tmp["nz"]=nz;
01156         tmp["changecount"]=changecount;
01157 
01158         return tmp;
01159 }

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

Definition at line 1233 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 706 of file emdata_core.cpp.

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

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

00707 {
00708         ENTERFUNC;
00709 
00710         if (get_ndim() != 2) {
00711                 throw ImageDimensionException("2D image only");
00712         }
00713 
00714         EMData *ret = new EMData();
00715         ret->set_size(ny, 1, 1);
00716         float *dst = ret->get_data();
00717         float *src = get_data();
00718 
00719         for (int i = 0; i < ny; i++) {
00720                 dst[i] = src[i * nx + col_index];
00721         }
00722 
00723         ret->update();
00724         EXITFUNC;
00725         return ret;
00726 }

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::WienerFourierReconstructor::do_insert_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), 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 1978 of file emdata.h.

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

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 344 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(), operator==(), EMAN::TransformProcessor::transform(), and unwrap().

00355 {

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::CtfAverager::add_image(), 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 338 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::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::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::RotationalAligner::align_180_ambiguous(), amplitude(), EMAN::SVDAnalyzer::analyze(), EMAN::varimax::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), ap2ri(), apmd(), apmq(), apply_radial_func(), 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(), circumference(), 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(), 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_0_180(), EMAN::Util::Crosrng_psi_0_180_no_mirror(), EMAN::Util::Crosrng_sm_psi(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), depad(), depad_corner(), 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(), EMAN::Util::eval(), filter_by_image(), EMAN::CtfAverager::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), Four_ds(), Four_shuf_ds_cen_us(), EMAN::Phase180Processor::fourier_phaseshift180(), FourInterpol(), FourTruncate(), 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_pixel_conv7(), get_pow(), get_row(), EMAN::Util::get_slice(), get_top_half(), get_value_at_wrap(), helicise_grid(), 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(), norm_pad(), EMAN::Util::Normalize_ring(), EMAN::ReconstructorVolumeData::normalize_threed(), oneDfftPolar(), operator==(), 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::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::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::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::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), 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(), replace_amplitudes(), EMAN::PointArray::replace_by_summation(), ri2ap(), ri2inten(), 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(), 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 903 of file emdata.h.

Referenced by get_amplitude_thres().

std::string EMData::get_data_pickle  )  const
 

Definition at line 1286 of file emdata_metadata.cpp.

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

01287 {
01288 //      vector<float> vf;
01289 //      vf.resize(nx*ny*nz);
01290 //      std::copy(rdata, rdata+nx*ny*nz, vf.begin());
01291 
01292         std::string vf((const char *)get_data(),nx*ny*nz*sizeof(float));
01293 
01294         return vf;
01295 }

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 1223 of file emdata.h.

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

Get image dimension.

Returns:
image dimension.

Definition at line 914 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(), delete_disconnected_regions(), do_ift(), do_radon(), EMAN::PCA::dopca_ooc(), dot_rotate_translate(), EMAN::Processor::EMFourierFilterFunc(), extractpoint(), EMAN::FFTResampleProcessor::fft_resample(), find_3d_threshold(), fouriergridrot2d(), fouriergridrot_shift2d(), get_2dcview(), get_2dview(), get_clip(), EMAN::IntTranslateProcessor::get_clip_region(), get_col(), get_fft_amplitude(), get_fft_phase(), get_row(), get_top_half(), helicise(), helicise_grid(), insert_scaled_sum(), EMAN::PCA::Lanczos(), EMAN::PCA::Lanczos_ooc(), little_big_dot(), main(), mult_complex_efficient(), peak_search(), phase_cog(), 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::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 1272 of file emdata.h.

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

Definition at line 1277 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 3582 of file emdata_sparx.cpp.

References EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), nx, ny, nz, q, and restrict2().

03582                                                                                       {
03583 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03584 
03585         int K     = kb.get_window_size();
03586         int kbmin = -K/2;
03587         int kbmax = -kbmin;
03588         int kbc   = kbmax+1;
03589 
03590         float pixel =0.0f;
03591         float w=0.0f;
03592 
03593         delx = restrict2(delx, nx);
03594         int inxold = int(Util::round(delx));
03595         if(ny<2) {  //1D
03596                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03597                         //  loop for ends
03598                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03599                                 float q = kb.i0win_tab(delx - inxold-m1);
03600                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03601                         }
03602                 } else {
03603                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03604                                 float q = kb.i0win_tab(delx - inxold-m1);
03605                                 pixel += (*this)(inxold+m1)*q; w+=q;
03606                         }
03607                 }
03608 
03609         } else if(nz<2) {  // 2D
03610                 dely = restrict2(dely, ny);
03611                 int inyold = int(Util::round(dely));
03612                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03613                         //  loop for strips
03614                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03615                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03616                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q; w+=q;}
03617                         }
03618                 } else {
03619                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03620                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03621                                 pixel += (*this)(inxold+m1,inyold+m2)*q; w+=q;}
03622                         }
03623                 }
03624         } else {  //  3D
03625                 dely = restrict2(dely, ny);
03626                 int inyold = int(Util::round(dely));
03627                 delz = restrict2(delz, nz);
03628                 int inzold = int(Util::round(delz));
03629                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03630                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03631                         //  loop for strips
03632                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03633                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03634                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03635                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03636                         }
03637                 } else {
03638                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03639                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03640                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03641                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03642                         }
03643                 }
03644         }
03645         return pixel/w;
03646 }

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

Definition at line 3726 of file emdata_sparx.cpp.

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

03726                                                                                        {
03727 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03728 
03729         float *image=(this->get_data());
03730         int nx = this->get_xsize();
03731         int ny = this->get_ysize();
03732         int nz = this->get_zsize();
03733 
03734         float result;
03735 
03736         result = Util::get_pixel_conv_new(nx,ny,nz,delx,dely,delz,image,kb);
03737         return result;
03738 }

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

Definition at line 3649 of file emdata_sparx.cpp.

References EMAN::Util::sincBlackman::get_sB_size(), nx, ny, q, EMAN::Util::sincBlackman::sBwin_tab(), and t.

Referenced by downsample().

03649                                                                                      {
03650 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03651 
03652         int K     = kb.get_sB_size();
03653         int kbmin = -K/2;
03654         int kbmax = -kbmin;
03655         int kbc   = kbmax+1;
03656 
03657         float pixel =0.0f;
03658         float w=0.0f;
03659 
03660         //delx = restrict2(delx, nx);   //  In this function the old location is always within the      image
03661         int inxold = int(Util::round(delx));
03662         /*if(ny<2) {  //1D
03663                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03664                         //  loop for ends
03665                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03666                                 float q = kb.sBwin_tab(delx - inxold-m1);
03667                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03668                         }
03669                 } else {
03670                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03671                                 float q = kb.sBwin_tab(delx - inxold-m1);
03672                                 pixel += (*this)(inxold+m1)*q; w+=q;
03673                         }
03674                 }
03675 
03676         } else if(nz<2) {  // 2D*/
03677                 //dely = restrict2(dely, ny);
03678                 int inyold = int(Util::round(dely));
03679                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03680                         //  loop for strips
03681                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03682                                 float t = kb.sBwin_tab(dely - inyold-m2);
03683                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03684                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03685                                         pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q;
03686                                         w += q;
03687                                 }
03688                         }
03689                 } else {
03690                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03691                                 float t = kb.sBwin_tab(dely - inyold-m2);
03692                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03693                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03694                                         pixel += (*this)(inxold+m1,inyold+m2)*q;
03695                                         w += q;
03696                                 }
03697                         }
03698                 }
03699         /*} else {  //  3D
03700                 dely = restrict2(dely, ny);
03701                 int inyold = int(Util::round(dely));
03702                 delz = restrict2(delz, nz);
03703                 int inzold = int(Util::round(delz));
03704                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03705                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03706                         //  loop for strips
03707                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03708                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03709                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03710                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03711                         }
03712                 } else {
03713                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03714                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03715                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03716                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03717                         }
03718                 }
03719         }*/
03720         return pixel/w;
03721 }

EMData * EMData::get_pow float  n_pow  ) 
 

Definition at line 6209 of file emdata_sparx.cpp.

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

06210 {
06211         EMData* buf_new = this->copy_head();
06212         float *in  = this->get_data();
06213         float *out = buf_new->get_data();
06214         for(size_t i=0; i<(size_t)nx*ny*nz; ++i) out[i] = pow(in[i],n_pow);
06215         return buf_new;
06216 }

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 671 of file emdata_core.cpp.

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

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

00672 {
00673         ENTERFUNC;
00674 
00675         if (get_ndim() > 2) {
00676                 throw ImageDimensionException("1D/2D image only");
00677         }
00678 
00679         EMData *ret = new EMData();
00680         ret->set_size(nx, 1, 1);
00681         memcpy(ret->get_data(), get_data() + nx * row_index, nx * sizeof(float));
00682         ret->update();
00683         EXITFUNC;
00684         return ret;
00685 }

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 895 of file emdata.h.

Referenced by calc_fast_sigma_image(), operator==(), 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 1307 of file emdata_metadata.cpp.

01308 {
01309         return 0;
01310 }

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 572 of file emdata.h.

Referenced by main().

00748                                           {

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 541 of file emdata.h.

00748                                           {

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 1930 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 cooridinate.
y The y cooridinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 1917 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 cooridinate.
y The y cooridinate.
z The z cooridinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 1897 of file emdata.h.

Referenced by EMAN::MinMaxAverager::add_image(), EMAN::BoxingTools::auto_correlation_pick(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_fast_sigma_image(), EMAN::XYZCmp::cmp(), common_lines(), EMAN::MarchingCubes::draw_cube(), find_pixels_with_value(), EMAN::BoxingTools::find_radial_max(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::BoxingTools::get_min_delta_profile(), EMAN::MarchingCubes::get_normal(), wustl_mm::SkeletonMaker::VolumeData::GetDataAt(), EMAN::BoxingTools::hi_brid(), EMAN::BoxingTools::is_local_maximum(), make_footprint(), EMAN::MarchingCubes::marching_cube(), EMAN::PointArray::match_points(), printImage(), EMAN::DirectionalSumProcessor::process(), EMAN::TransposeProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::TransposeProcessor::process_inplace(), EMAN::RealToFFTProcessor::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 1905 of file emdata.h.

float & EMData::get_value_at_wrap int  x  ) 
 

Definition at line 751 of file emdata_core.cpp.

References get_data(), nx, and x.

00752 {
00753         if (x < 0) x = nx + x;
00754         return get_data()[x];
00755 }

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 cooridinate.
Returns:
The pixel density value at circulant coordinates (x).

Definition at line 785 of file emdata_core.cpp.

References get_data(), nx, and x.

00786 {
00787         if (x < 0) x = nx - x;
00788         return get_data()[x];
00789 }

float & EMData::get_value_at_wrap int  x,
int  y
 

Definition at line 757 of file emdata_core.cpp.

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

00758 {
00759         if (x < 0) x = nx + x;
00760         if (y < 0) y = ny + y;
00761 
00762         return get_data()[x + y * nx];
00763 }

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 cooridinate.
y The y cooridinate.
Returns:
The pixel density value at circulant coordinates (x,y).

Definition at line 791 of file emdata_core.cpp.

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

00792 {
00793         if (x < 0) x = nx - x;
00794         if (y < 0) y = ny - y;
00795 
00796         return get_data()[x + y * nx];
00797 }

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

Definition at line 765 of file emdata_core.cpp.

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

00766 {
00767         
00768 #ifdef EMAN2_USING_CUDA 
00769         if(EMData::usecuda == 1 && cudarwdata){
00770                 float result = get_value_at_wrap_cuda(cudarwdata, x, y, z, nx, ny, nz); // this should work....
00771                 return result;
00772         }
00773 #endif
00774         int lx = x;
00775         int ly = y;
00776         int lz = z;
00777 
00778         if (lx < 0) lx = nx + lx;
00779         if (ly < 0) ly = ny + ly;
00780         if (lz < 0) lz = nz + lz;
00781 
00782         return get_data()[lx + ly * nx + lz * nxy];
00783 }

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 cooridinate.
y The y cooridinate.
z The z cooridinate.
Returns:
The pixel density value at circulant coordinates (x,y,z).

Definition at line 799 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(), EMAN::RT3DSphereAligner::xform_align_nbest(), EMAN::RT3DGridAligner::xform_align_nbest(), and zero_corner_circulant().

00800 {
00801         ptrdiff_t lx = x;
00802         ptrdiff_t ly = y;
00803         ptrdiff_t lz = z;
00804         if (lx < 0) lx = nx + lx;
00805         if (ly < 0) ly = ny + ly;
00806         if (lz < 0) lz = nz + lz;
00807 
00808         return get_data()[lx + ly * nx + lz * nxy];
00809 }

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

Definition at line 1243 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 868 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::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::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::FRM2DAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::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(), EMAN::MarchingCubes::calculate_min_max_vals(), circumf(), circumf_rect(), circumference(), 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::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::MarchingCubes::draw_cube(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), filter_by_image(), find_group(), EMAN::BoxingTools::find_radial_max(), EMAN::WatershedProcessor::find_region(), find_region(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::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(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), EMAN::BoxingTools::get_min_delta_profile(), get_pixel_conv7(), 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::MarchingCubes::marching_cube(), 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(), norm_pad(), EMAN::Util::Normalize_ring(), operator==(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::padfft_slice(), peak_ccf(), peak_search(), 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::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::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::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::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::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(), replace_amplitudes(), 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(), symplane0_rect(), 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().

00868                                 {
00869                                         prv_y_back = prv_ny - new_ny - ytrans;
00870                                         y_iter -= prv_y_back;
00871                                 }

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

Definition at line 1248 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 877 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::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::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::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(), EMAN::MarchingCubes::calculate_min_max_vals(), circumf(), circumf_rect(), circumference(), EMAN::FourierReconstructor::clear(), EMAN::XYZCmp::cmp(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::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::MarchingCubes::draw_cube(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), filter_by_image(), 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::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(), get_pixel_conv7(), 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(), EMAN::MarchingCubes::marching_cube(), 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(), norm_pad(), EMAN::Util::Normalize_ring(), operator==(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::padfft_slice(), peak_ccf(), peak_search(), 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::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::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::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::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::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), real(), real2complex(), real2FH(), recons3d_4nn(), EMAN::Util::reconstitute_image_mask(), refalifnfast(), replace_amplitudes(), 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(), symplane0_rect(), 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().

00887                                                 {}

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

Definition at line 1253 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 886 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::CtfAverager::add_image(), EMAN::IterationAverager::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(), EMAN::MarchingCubes::calculate_min_max_vals(), circumf(), circumf_rect(), circumference(), EMAN::FourierReconstructor::clear(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::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::MarchingCubes::draw_cube(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), filter_by_image(), 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(), get_pixel_conv7(), 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_rect_slice(), insert_rect_slice_ctf(), insert_rect_slice_ctf_applied(), 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(), EMAN::MarchingCubes::marching_cube(), 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(), norm_pad(), EMAN::Util::Normalize_ring(), operator==(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), peak_search(), 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::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::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::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::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::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), ReadVandBcast(), real(), real2complex(), real2FH(), EMAN::Util::reconstitute_image_mask(), replace_amplitudes(), EMAN::rsconvolution(), EMAN::MarchingCubes::set_data(), 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(), symplane0_rect(), 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().

00887                                                 {}
00888 
00889                         int prv_nx, prv_ny, prv_nz, new_nx, new_ny, new_nz;

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 3740 of file emdata_sparx.cpp.

References abs, get_array_offsets(), InvalidValueException, nx, ny, set_array_offsets(), x, and y.

03740                                                                                        {
03741         const int nxhalf = nx/2;
03742         const int nyhalf = ny/2;
03743         const int bd = size/2;
03744         float* wxarr = new float[size];
03745         float* wyarr = new float[size];
03746         float* wx = wxarr + bd; // wx[-bd] = wxarr[0]
03747         float* wy = wyarr + bd;
03748         int ixc = int(x + 0.5f*Util::sgn(x));
03749         int iyc = int(y + 0.5f*Util::sgn(y));
03750         if (abs(ixc) > nxhalf)
03751                 throw InvalidValueException(ixc, "getconv: X value out of range");
03752         if (abs(iyc) > nyhalf)
03753                 throw InvalidValueException(ixc, "getconv: Y value out of range");
03754         for (int i = -bd; i <= bd; i++) {
03755                 int iyp = iyc + i;
03756                 wy[i] = win(y - iyp);
03757                 int ixp = ixc + i;
03758                 wx[i] = win(x - ixp);
03759         }
03760         vector<int> saved_offsets = get_array_offsets();
03761         set_array_offsets(-nxhalf, -nyhalf);
03762         float conv = 0.f, wsum = 0.f;
03763         for (int iy = -bd; iy <= bd; iy++) {
03764                 int iyp = iyc + iy;
03765                 for (int ix = -bd; ix <= bd; ix++) {
03766                         int ixp = ixc + ix;
03767                         float wg = wx[ix]*wy[iy];
03768                         conv += (*this)(ixp,iyp)*wg;
03769                         wsum += wg;
03770                 }
03771         }
03772         set_array_offsets(saved_offsets);
03773         delete [] wxarr;
03774         delete [] wyarr;
03775         //return conv/wsum;
03776         return conv;
03777 }

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

function for MarchingCubes, for 3D image display

Returns:
the resolution

Definition at line 3812 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 822 of file emdata.h.

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

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 411 of file emdata.h.

Referenced by EMAN::CtfAverager::add_image(), and 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 6270 of file emdata_sparx.cpp.

References copy_head(), get_ndim(), ImageDimensionException, ImageFormatException, InvalidValueException, is_complex(), min, nx, nx, ny, ny, nz, to_zero(), and update().

06270                                                                                                               {
06271         if (3 != get_ndim())
06272                 throw ImageDimensionException("helicise needs a 3-D image.");
06273         if (is_complex())
06274                 throw ImageFormatException("helicise requires a real image");
06275         EMData* result = this->copy_head();
06276         result->to_zero();
06277         int nyc = ny/2;
06278         int nxc = nx/2;
06279         int vl = nz-1; //lengh of the volume in pixel
06280         if ( section_use < dp/int(vl*pixel_size) )      
06281                 section_use = (dp)/int(vl*pixel_size);
06282                 
06283         float nb = vl*(1.0f - section_use)/2.0f;
06284 
06285         float ne =  nb+vl*section_use;
06286         int numst = int( (ne-nb)*pixel_size/dp );
06287         
06288         
06289         float r2, ir;
06290         if(radius < 0.0f) r2 = (float)((nxc-1)*(nxc-1));
06291         else r2 = radius*radius;
06292         if(minrad < 0.0f) ir = 0.0f;
06293         else ir = minrad*minrad;
06294         for (int k = 0; k<nz; k++) {
06295                 int nst1 = int ( (nb-k)*pixel_size/dp) -1;
06296                 int nst2 = int ( (ne-k)*pixel_size/dp) +1;
06297                 for (int j = 0; j<ny; j++) {
06298                         int jy = j - nyc;
06299                         int jj = jy*jy;
06300                         for (int i = 0; i<nx; i++) {
06301                                 int ix = i - nxc;
06302                                 float d2 = (float)(ix*ix + jj);
06303                                 if(d2 <= r2 && d2>=ir) {
06304                                         int nq = 0;
06305                                         for ( int ist = nst1; ist < nst2; ist++) {
06306                                                 float zold = (k*pixel_size + ist*dp)/pixel_size;
06307                                                 
06308                                                 if(zold >= nb && zold <= ne) {
06309                                                         // now x-y position
06310                                                         float cphi = ist*dphi*(float)DGR_TO_RAD;
06311                                                         float ca = cos(cphi);
06312                                                         float sa = sin(cphi);
06313                                                         float xold = ix*ca - jy*sa + nxc;
06314                                                         float yold = ix*sa + jy*ca + nyc;
06315                                                         nq++;
06316 
06317         int IOZ = int(zold);
06318         //  Do tri-linear interpolation
06319         int IOX = int(xold);
06320         int IOY = int(yold);
06321         //int IOZ = int(zold);
06322 
06323         #ifdef _WIN32
06324         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
06325         #else
06326         int IOXp1 = std::min( nx-1 ,IOX+1);
06327         #endif  //_WIN32
06328 
06329         #ifdef _WIN32
06330         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
06331         #else
06332         int IOYp1 = std::min( ny-1 ,IOY+1);
06333         #endif  //_WIN32
06334 
06335         #ifdef _WIN32
06336         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
06337         #else
06338         int IOZp1 = std::min( nz-1 ,IOZ+1);
06339         #endif  //_WIN32
06340 
06341         float dx = xold-IOX;
06342         float dy = yold-IOY;
06343         float dz = zold-IOZ;
06344 
06345         float a1 = (*this)(IOX,IOY,IOZ);
06346         float a2 = (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZ);
06347         float a3 = (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZ);
06348         float a4 = (*this)(IOX,IOY,IOZp1) - (*this)(IOX,IOY,IOZ);
06349         float a5 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) + (*this)(IOXp1,IOYp1,IOZ);
06350         float a6 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOXp1,IOY,IOZp1);
06351         float a7 = (*this)(IOX,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOX,IOYp1,IOZp1);
06352         float a8 = (*this)(IOXp1,IOY,IOZ) + (*this)(IOX,IOYp1,IOZ)+ (*this)(IOX,IOY,IOZp1)
06353                         - (*this)(IOX,IOY,IOZ)- (*this)(IOXp1,IOYp1,IOZ) - (*this)(IOXp1,IOY,IOZp1)
06354                         - (*this)(IOX,IOYp1,IOZp1) + (*this)(IOXp1,IOYp1,IOZp1);
06355 
06356 
06357 
06358                                                         (*result)(i,j,k) += a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
06359                                                         if(nq == numst) break;
06360                                                 }
06361                                         }
06362                                         if(nq != numst)
06363                                                 throw InvalidValueException(nq, "Helicise: incorrect number of repeats encoutered.");
06364                                 }
06365                         }
06366                 }
06367         }
06368         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 ;
06369 
06370         result->update();
06371         return result;
06372 }

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 6376 of file emdata_sparx.cpp.

References copy_head(), data, get_array_offsets(), get_data(), get_ndim(), get_pixel_conv_new(), ImageDimensionException, ImageFormatException, InvalidValueException, is_complex(), nx, ny, nz, scale(), set_array_offsets(), set_size(), to_zero(), and update().

06376                                                                                                                                          {
06377         std::cout<<"111111"<<std::endl;
06378         if (3 != get_ndim())
06379                 throw ImageDimensionException("helicise needs a 3-D image.");
06380         if (is_complex())
06381                 throw ImageFormatException("helicise requires a real image");
06382         //begin griding
06383         //if (scale_input == 0.0f) scale_input = 1.0f;
06384         float  scale = 0.5f;//*scale_input;
06385 
06386         
06387         int nxn = nx/2; int nyn = ny/2; int nzn = nz/2;
06388 
06389         vector<int> saved_offsets = get_array_offsets();
06390         set_array_offsets(0,0,0);
06391         EMData* ret = this->copy_head();
06392 #ifdef _WIN32
06393         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
06394 #else
06395         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
06396 #endif  //_WIN32
06397         ret->to_zero();  //we will leave margins zeroed.
06398 
06399         // center of big image,
06400         int xc = nxn;
06401         int ixs = nxn%2;  // extra shift on account of odd-sized images
06402         int yc = nyn;
06403         int iys = nyn%2;
06404         int zc = nzn;
06405         int izs = nzn%2;
06406         // center of small image
06407         int xcn = nxn/2;
06408         int ycn = nyn/2;
06409         int zcn = nzn/2;
06410         // shifted center for rotation
06411         float shiftxc = xcn; // + delx;
06412         float shiftyc = ycn; // + dely;
06413         float shiftzc = zcn; // + delz;
06414         // bounds if origin at center
06415         float zmin = -nz/2.0f;
06416         float ymin = -ny/2.0f;
06417         float xmin = -nx/2.0f;
06418         float zmax = -zmin;
06419         float ymax = -ymin;
06420         float xmax = -xmin;
06421         if (0 == nx%2) xmax--;
06422         if (0 == ny%2) ymax--;
06423         if (0 == nz%2) zmax--;
06424 
06425         float* data = this->get_data();
06426 
06427         
06428         // rotation matrix (the transpose is used in the loop to get (xold,yold,zold)):
06429          
06430         //float a13 = -0.0f;    float a23 =  0.0f;
06431         //float a31 =  0.0f;          float a32 =  0.0f;          float a33 =  1.0f;
06432                 
06433         //end gridding
06434 
06435         
06436         int nyc = nyn/2;
06437         int nxc = nxn/2;
06438         int nb = int(nzn*(1.0f - section_use)/2.);
06439         int ne = nzn - nb -1;
06440         int numst = int(nzn*section_use*pixel_size/dp);
06441         // how many steps needed total, fewer will be used, only those that fall between nb and ne
06442         int nst = int(nzn*pixel_size/dp);
06443         float r2, ir;
06444         if(radius < 0.0f) r2 = (float)((nxc-1)*(nxc-1));
06445         else r2 = radius*radius;
06446         if(minrad < 0.0f) ir = 0.0f;
06447         else ir = minrad*minrad;
06448         
06449         for (int k = 0; k<nzn; k++) {
06450                 for (int j = 0; j<nyn; j++) {
06451                         int jy = j - nyc;
06452                         int jj = jy*jy;
06453                         for (int i = 0; i<nxn; i++) {
06454                                 int ix = i - nxc;
06455                                 float d2 = (float)(ix*ix + jj);
06456                                 if(d2 <= r2 && d2>=ir) {
06457                                         int nq = 0;
06458                                         for ( int ist = -nst; ist <= nst; ist++) {
06459                                                 float zold = (k*pixel_size + ist*dp)/pixel_size;
06460                                                 int IOZ = int(zold);
06461                                                 if(IOZ >= nb && IOZ <= ne) {
06462                                                 
06463                                                         float cphi = ist*dphi*(float)DGR_TO_RAD;
06464                                                         float ca = cos(cphi);
06465                                                         float sa = sin(cphi);
06466                                                         
06467                                                         float xold = ix*ca - jy*sa + nxc;
06468                                                         float yold = ix*sa + jy*ca + nyc;
06469                                                         
06470                                                         float xold_big = (xold-shiftxc)/scale - ixs + xc;
06471                                                         float yold_big = (yold-shiftyc)/scale - iys + yc;
06472                                                         float zold_big = (zold-shiftzc)/scale - izs + zc;
06473                                                         
06474                                                         /*float a11 =  ca; float a12 =  sa;
06475                                                         float a21 = -sa; float a22 = ca;
06476                                                         
06477                                                         float z = (zold - shiftzc)/scale;
06478                                                         float zco1 = a31*z+xc;
06479                                                         float zco2 = a32*z+yc;
06480                                                         float zco3 = a33*z+zc;
06481                                                                                                                 
06482                                                         float y = (float(j) - shiftyc)/scale;
06483                                                         float yco1 = zco1+a21*y;
06484                                                         float yco2 = zco2+a22*y;
06485                                                         float yco3 = zco3+a23*y;
06486                                                         
06487                                                         float x = (float(i) - shiftxc)/scale;
06488                                                         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
06489                                                         float yold_big = yco2+a12*x-iys;
06490                                                         float zold_big = yco3+a13*x-izs;*/
06491                                                         
06492                                                                                                 
06493                                                         nq++;
06494                                                         
06495                                                                 
06496                                                         (*ret)(i,j,k) += Util::get_pixel_conv_new(nx, ny, nz, xold_big, yold_big, zold_big, data, kb);
06497                                                         
06498                                                         
06499                                                         if(nq == numst) break;
06500                                                 }
06501                                         }
06502                                         if(nq != numst)
06503                                                 throw InvalidValueException(nq, "Helicise: incorrect number of repeats encoutered.");
06504                                 }
06505                         }
06506                 }
06507         }
06508         
06509         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 ;
06510         set_array_offsets(saved_offsets);
06511         ret->update();
06512         return ret;
06513 }

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 1112 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().

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

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

Definition at line 1204 of file emdata_sparx.cpp.

References cmplx(), get_array_offsets(), get_zsize(), mult(), nx, 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] = 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] = 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         nz = get_zsize();
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;
01264                                 
01265                                 //binlinear interpolation
01266                                 float xp = coordinate_2d_square[0];
01267                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nz+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                                         }
01284                                 else {
01285                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01286                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
01287                                         
01288                                         }
01289                                         
01290                                 c1 = lin_interpolated;
01291                                 
01292                                 //now nearest neighborhood interpolation
01293                                 
01294                                 std::complex<float> btq;
01295                                 if ( coordinate_3dnew[0] < 0.) {
01296                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
01297                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
01298                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
01299                                         btq = conj(c1);
01300                                         } else {
01301                                         btq = c1;
01302                                         }
01303                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
01304                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
01305                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
01306 
01307                                 int iza, iya;
01308                                 if (izn >= 0)  iza = izn + 1;
01309                                 else           iza = nz + izn + 1;
01310 
01311                                 if (iyn >= 0) iya = iyn + 1;
01312                                 else          iya = ny + iyn + 1;
01313 
01314                                 cmplx(ixn,iya,iza) += btq*float(mult);
01315                                 (*w)(ixn,iya,iza) += mult;
01316                                         
01317                                 }
01318                         }
01319                             
01320                 }
01321 
01322 
01323         //end insert rectanular fft
01324                 
01325         set_array_offsets(saved_offsets);
01326         myfft->set_array_offsets(myfft_saved_offsets);
01327         EXITFUNC;
01328 
01329 }

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

helper function to insert rectangualr slice for ctf rect case

Definition at line 1835 of file emdata_sparx.cpp.

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

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

01836 {
01837         ENTERFUNC;
01838         vector<int> saved_offsets = get_array_offsets();
01839         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01840         set_array_offsets(0,1,1);
01841         myfft->set_array_offsets(0,1);
01842         
01843         // insert rectangular fft from my nn4_rect code
01844 
01845         Vec2f coordinate_2d_square;
01846         Vec3f coordinate_3dnew;
01847         Vec3f axis_newx;
01848         Vec3f axis_newy;
01849         Vec3f tempv;
01850         
01851         //begin of scaling factor calculation
01852         //unit vector x,y of 2D fft transformed to new positon after rotation and scaling
01853         axis_newx[0] = xratio*0.5f*(sizeofprojection*npad)*trans[0][0];
01854         axis_newx[1] = yratio*0.5f*(sizeofprojection*npad)*trans[0][1];
01855         axis_newx[2] = 0.5f*(sizeofprojection*npad)*trans[0][2];
01856 
01857         float ellipse_length_x = std::sqrt(axis_newx[0]*axis_newx[0]+axis_newx[1]*axis_newx[1]+axis_newx[2]*axis_newx[2]);
01858         
01859         int ellipse_length_x_int = int(ellipse_length_x);
01860         float ellipse_step_x = 0.5f*(sizeofprojection*npad)/float(ellipse_length_x_int);
01861         float xscale = ellipse_step_x;//scal increased
01862 
01863         axis_newy[0] = xratio*0.5f*(sizeofprojection*npad)*trans[1][0];
01864         axis_newy[1] = yratio*0.5f*(sizeofprojection*npad)*trans[1][1];
01865         axis_newy[2] = 0.5f*(sizeofprojection*npad)*trans[1][2];
01866 
01867 
01868 
01869         float ellipse_length_y = std::sqrt(axis_newy[0]*axis_newy[0]+axis_newy[1]*axis_newy[1]+axis_newy[2]*axis_newy[2]);
01870         int ellipse_length_y_int = int(ellipse_length_y);
01871         float ellipse_step_y = 0.5f*(sizeofprojection*npad)/float(ellipse_length_y_int);
01872         float yscale = ellipse_step_y;
01873         //end of scaling factor calculation
01874         std::complex<float> c1;
01875         nz = get_zsize();
01876         Ctf* ctf = myfft->get_attr( "ctf" );
01877         ctf_store_new::init( nz, ctf );
01878         if(ctf) {delete ctf; ctf=0;}
01879         int remove = myfft->get_attr_default( "remove", 0 );
01880 
01881         float r2=0.25f*sizeofprojection*npad*sizeofprojection*npad;
01882         float r2_at_point;
01883         
01884         for(int i=0;i<ellipse_length_x_int;i++) {
01885                 for(int j=-1*ellipse_length_y_int+1; j<=ellipse_length_y_int; j++) {
01886                     
01887                         r2_at_point=i*xscale*i*xscale+j*yscale*j*yscale;
01888                         if(r2_at_point<=r2 && ! ((0==i) && (j<0))) {
01889                                 
01890                                 float ctf_value = ctf_store_new::get_ctf( r2_at_point );
01891                                 coordinate_2d_square[0] = xscale*float(i);
01892                                 coordinate_2d_square[1] = yscale*float(j);
01893                                 float xnew = coordinate_2d_square[0]*trans[0][0] + coordinate_2d_square[1]*trans[1][0];
01894                                 float ynew = coordinate_2d_square[0]*trans[0][1] + coordinate_2d_square[1]*trans[1][1];
01895                                 float znew = coordinate_2d_square[0]*trans[0][2] + coordinate_2d_square[1]*trans[1][2];
01896                                 coordinate_3dnew[0] =xnew*xratio;
01897                                 coordinate_3dnew[1] = ynew*yratio;
01898                                 coordinate_3dnew[2] = znew;
01899                                 
01900                                 //binlinear interpolation
01901                                 float xp = coordinate_2d_square[0];
01902                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nz+coordinate_2d_square[1]+1;
01903                                 std::complex<float> lin_interpolated(0,0);
01904                                 int xlow=int(xp),xhigh=int(xp)+1;
01905                                 int ylow=int(yp),yhigh=int(yp)+1;
01906                                 float tx=xp-xlow,ty=yp-ylow;
01907 
01908                                 
01909                                 if(j == -1) {
01910                                         
01911                                         if(ylow<yp)
01912                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01913                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty) + myfft->cmplx(xhigh,yhigh)*tx*ty;
01914                                         else 
01915                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)
01916                                                 + myfft->cmplx(xhigh,ylow)*tx;
01917                                                                         
01918                                         }
01919                                 else {
01920                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
01921                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
01922                                         
01923                                         }
01924                                         
01925                                 c1 = lin_interpolated;
01926                                 
01927                                 //now nearest neighborhood interpolation
01928                                 
01929                                 std::complex<float> btq;
01930                                 if ( coordinate_3dnew[0] < 0.) {
01931                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
01932                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
01933                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
01934                                         btq = conj(c1);
01935                                         } else {
01936                                         btq = c1;
01937                                         }
01938                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
01939                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
01940                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
01941 
01942                                 int iza, iya;
01943                                 if (izn >= 0)  iza = izn + 1;
01944                                 else           iza = nz + izn + 1;
01945 
01946                                 if (iyn >= 0) iya = iyn + 1;
01947                                 else          iya = ny + iyn + 1;
01948 
01949                                 if(remove > 0 ) {
01950                                         cmplx(ixn,iya,iza) -= btq*ctf_value*float(mult);
01951                                         (*w)(ixn,iya,iza) -= ctf_value*ctf_value*mult;
01952                                         } else {
01953                                         cmplx(ixn,iya,iza) += btq*ctf_value*float(mult);
01954                                         (*w)(ixn,iya,iza) += ctf_value*ctf_value*mult;
01955                                         }
01956                                         
01957                                 }
01958                         }
01959                             
01960                 }
01961 
01962 
01963         //end insert rectanular fft
01964                 
01965         set_array_offsets(saved_offsets);
01966         myfft->set_array_offsets(myfft_saved_offsets);
01967         EXITFUNC;
01968 
01969 }

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

Definition at line 1972 of file emdata_sparx.cpp.

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

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

01973 {
01974         ENTERFUNC;
01975         vector<int> saved_offsets = get_array_offsets();
01976         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01977         set_array_offsets(0,1,1);
01978         myfft->set_array_offsets(0,1);
01979         
01980         // insert rectangular fft from my nn4_rect code
01981 
01982         Vec2f coordinate_2d_square;
01983         Vec3f coordinate_3dnew;
01984         Vec3f axis_newx;
01985         Vec3f axis_newy;
01986         Vec3f tempv;
01987         
01988         //begin of scaling factor calculation
01989         //unit vector x,y of 2D fft transformed to new positon after rotation and scaling
01990         axis_newx[0] = xratio*0.5f*(sizeofprojection*npad)*trans[0][0];
01991         axis_newx[1] = yratio*0.5f*(sizeofprojection*npad)*trans[0][1];
01992         axis_newx[2] = 0.5f*(sizeofprojection*npad)*trans[0][2];
01993 
01994         float ellipse_length_x = std::sqrt(axis_newx[0]*axis_newx[0]+axis_newx[1]*axis_newx[1]+axis_newx[2]*axis_newx[2]);
01995         
01996         int ellipse_length_x_int = int(ellipse_length_x);
01997         float ellipse_step_x = 0.5f*(sizeofprojection*npad)/float(ellipse_length_x_int);
01998         float xscale = ellipse_step_x;//scal increased
01999 
02000         axis_newy[0] = xratio*0.5f*(sizeofprojection*npad)*trans[1][0];
02001         axis_newy[1] = yratio*0.5f*(sizeofprojection*npad)*trans[1][1];
02002         axis_newy[2] = 0.5f*(sizeofprojection*npad)*trans[1][2];
02003 
02004 
02005 
02006         float ellipse_length_y = std::sqrt(axis_newy[0]*axis_newy[0]+axis_newy[1]*axis_newy[1]+axis_newy[2]*axis_newy[2]);
02007         int ellipse_length_y_int = int(ellipse_length_y);
02008         float ellipse_step_y = 0.5f*(sizeofprojection*npad)/float(ellipse_length_y_int);
02009         float yscale = ellipse_step_y;
02010         //end of scaling factor calculation
02011         std::complex<float> c1;
02012         nz = get_zsize();
02013         Ctf* ctf = myfft->get_attr( "ctf" );
02014         ctf_store_new::init( nz, ctf );
02015         if(ctf) {delete ctf; ctf=0;}
02016         int remove = myfft->get_attr_default( "remove", 0 );
02017 
02018         float r2=0.25f*sizeofprojection*npad*sizeofprojection*npad;
02019         float r2_at_point;
02020         
02021         for(int i=0;i<ellipse_length_x_int;i++) {
02022                 for(int j=-1*ellipse_length_y_int+1; j<=ellipse_length_y_int; j++) {
02023                     
02024                         r2_at_point=i*xscale*i*xscale+j*yscale*j*yscale;
02025                         if(r2_at_point<=r2 && ! ((0==i) && (j<0))) {
02026                                 
02027                                 float ctf_value = ctf_store_new::get_ctf( r2_at_point );
02028                                 coordinate_2d_square[0] = xscale*float(i);
02029                                 coordinate_2d_square[1] = yscale*float(j);
02030                                 float xnew = coordinate_2d_square[0]*trans[0][0] + coordinate_2d_square[1]*trans[1][0];
02031                                 float ynew = coordinate_2d_square[0]*trans[0][1] + coordinate_2d_square[1]*trans[1][1];
02032                                 float znew = coordinate_2d_square[0]*trans[0][2] + coordinate_2d_square[1]*trans[1][2];
02033                                 coordinate_3dnew[0] =xnew*xratio;
02034                                 coordinate_3dnew[1] = ynew*yratio;
02035                                 coordinate_3dnew[2] = znew;
02036                                 
02037                                 //binlinear interpolation
02038                                 float xp = coordinate_2d_square[0];
02039                                 float yp = ( coordinate_2d_square[1] >= 0) ? coordinate_2d_square[1]+1 : nz+coordinate_2d_square[1]+1;
02040                                 std::complex<float> lin_interpolated(0,0);
02041                                 int xlow=int(xp),xhigh=int(xp)+1;
02042                                 int ylow=int(yp),yhigh=int(yp)+1;
02043                                 float tx=xp-xlow,ty=yp-ylow;
02044 
02045                                 
02046                                 if(j == -1) {
02047                                         
02048                                         if(ylow<yp)
02049                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
02050                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty) + myfft->cmplx(xhigh,yhigh)*tx*ty;
02051                                         else 
02052                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)
02053                                                 + myfft->cmplx(xhigh,ylow)*tx;
02054                                                                         
02055                                         }
02056                                 else {
02057                                                 lin_interpolated=myfft->cmplx(xlow,ylow)*(1-tx)*(1-ty) + myfft->cmplx(xlow,yhigh)*(1-tx)*ty
02058                                                 + myfft->cmplx(xhigh,ylow)*tx*(1-ty)+ myfft->cmplx(xhigh,yhigh)*tx*ty;
02059                                         
02060                                         }
02061                                         
02062                                 c1 = lin_interpolated;
02063                                 
02064                                 //now nearest neighborhood interpolation
02065                                 
02066                                 std::complex<float> btq;
02067                                 if ( coordinate_3dnew[0] < 0.) {
02068                                         coordinate_3dnew[0] = -coordinate_3dnew[0];
02069                                         coordinate_3dnew[1] = -coordinate_3dnew[1];
02070                                         coordinate_3dnew[2] = -coordinate_3dnew[2];
02071                                         btq = conj(c1);
02072                                         } else {
02073                                         btq = c1;
02074                                         }
02075                                 int ixn = int(coordinate_3dnew[0] + 0.5 + nx) - nx;
02076                                 int iyn = int(coordinate_3dnew[1] + 0.5 + ny) - ny;
02077                                 int izn = int(coordinate_3dnew[2] + 0.5 + nz) - nz;
02078 
02079                                 int iza, iya;
02080                                 if (izn >= 0)  iza = izn + 1;
02081                                 else           iza = nz + izn + 1;
02082 
02083                                 if (iyn >= 0) iya = iyn + 1;
02084                                 else          iya = ny + iyn + 1;
02085 
02086                                 if(remove > 0 ) {
02087                                         cmplx(ixn,iya,iza) -= btq*float(mult);
02088                                         (*w)(ixn,iya,iza) -= ctf_value*ctf_value*mult;
02089                                         } else {
02090                                         cmplx(ixn,iya,iza) += btq*float(mult);
02091                                         (*w)(ixn,iya,iza) += ctf_value*ctf_value*mult;
02092                                         }
02093                                         
02094                                 }
02095                         }
02096                             
02097                 }
02098 
02099 
02100         //end insert rectanular fft
02101                 
02102         set_array_offsets(saved_offsets);
02103         myfft->set_array_offsets(myfft_saved_offsets);
02104         EXITFUNC;
02105 
02106 }

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 1874 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.

01876 {
01877         ENTERFUNC;
01878         float * data = get_data();
01879         if (get_ndim()==3) {
01880                 // Start by determining the region to operate on
01881                 int xs=(int)floor(block->get_xsize()*scale/2.0);
01882                 int ys=(int)floor(block->get_ysize()*scale/2.0);
01883                 int zs=(int)floor(block->get_zsize()*scale/2.0);
01884                 int x0=(int)center[0]-xs;
01885                 int x1=(int)center[0]+xs;
01886                 int y0=(int)center[1]-ys;
01887                 int y1=(int)center[1]+ys;
01888                 int z0=(int)center[2]-zs;
01889                 int z1=(int)center[2]+zs;
01890 
01891                 if (x1<0||y1<0||z1<0||x0>get_xsize()||y0>get_ysize()||z0>get_zsize()) return;   // object is completely outside the target volume
01892 
01893                 // make sure we stay inside the volume
01894                 if (x0<0) x0=0;
01895                 if (y0<0) y0=0;
01896                 if (z0<0) z0=0;
01897                 if (x1>=get_xsize()) x1=get_xsize()-1;
01898                 if (y1>=get_ysize()) y1=get_ysize()-1;
01899                 if (z1>=get_zsize()) z1=get_zsize()-1;
01900 
01901                 float bx=block->get_xsize()/2.0f;
01902                 float by=block->get_ysize()/2.0f;
01903                 float bz=block->get_zsize()/2.0f;
01904 
01905                 size_t idx;
01906                 for (int x=x0; x<=x1; x++) {
01907                         for (int y=y0; y<=y1; y++) {
01908                                 for (int z=z0; z<=z1; z++) {
01909                                         idx = x + y * nx + (size_t)z * nx * ny;
01910                                         data[idx] +=
01911                                                 block->sget_value_at_interp((x-center[0])/scale+bx,(y-center[1])/scale+by,(z-center[2])/scale+bz);
01912                                 }
01913                         }
01914                 }
01915                 update();
01916         }
01917         else if (get_ndim()==2) {
01918                 // Start by determining the region to operate on
01919                 int xs=(int)floor(block->get_xsize()*scale/2.0);
01920                 int ys=(int)floor(block->get_ysize()*scale/2.0);
01921                 int x0=(int)center[0]-xs;
01922                 int x1=(int)center[0]+xs;
01923                 int y0=(int)center[1]-ys;
01924                 int y1=(int)center[1]+ys;
01925 
01926                 if (x1<0||y1<0||x0>get_xsize()||y0>get_ysize()) return; // object is completely outside the target volume
01927 
01928                 // make sure we stay inside the volume
01929                 if (x0<0) x0=0;
01930                 if (y0<0) y0=0;
01931                 if (x1>=get_xsize()) x1=get_xsize()-1;
01932                 if (y1>=get_ysize()) y1=get_ysize()-1;
01933 
01934                 float bx=block->get_xsize()/2.0f;
01935                 float by=block->get_ysize()/2.0f;
01936 
01937                 for (int x=x0; x<=x1; x++) {
01938                         for (int y=y0; y<=y1; y++) {
01939                                 data[x + y * nx] +=
01940                                         block->sget_value_at_interp((x-center[0])/scale+bx,(y-center[1])/scale+by);
01941                         }
01942                 }
01943                 update();
01944         }
01945         else {
01946                 LOGERR("insert_scaled_sum supports only 2D and 3D data");
01947                 throw ImageDimensionException("2D/3D only");
01948         }
01949 
01950         EXITFUNC;
01951 }

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

Is this a complex image?

Returns:
Whether this is a complex image or not.

Definition at line 966 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(), 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(), center_origin(), center_origin_fft(), center_origin_yz(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::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(), conjg(), EMAN::MatchSFProcessor::create_radial_func(), cut_slice(), EMAN::Util::cyclicshift(), delete_disconnected_regions(), depad(), depad_corner(), EMAN::Util::div_filter(), EMAN::Util::div_img(), divkbsinh(), divkbsinh_rect(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::Processor::EMFourierFilterFunc(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), extractpoint(), EMAN::FFTResampleProcessor::fft_resample(), fft_shuffle(), filter_by_image(), find_pixels_with_value(), EMAN::Phase180Processor::fourier_phaseshift180(), fouriergridrot2d(), fouriergridrot_shift2d(), EMAN::fourierproduct(), FourInterpol(), FourTruncate(), get_attr(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), helicise(), helicise_grid(), 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(), norm_pad(), EMAN::periodogram(), 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::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(), replace_amplitudes(), 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 1045 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 1182 of file emdata.h.

Referenced by EMAN::Util::addn_img(), calc_fourier_shell_correlation(), cconj(), center_origin_fft(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), depad(), depad_corner(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::Processor::EMFourierFilterFunc(), filter_by_image(), fouriergridrot2d(), fouriergridrot_shift2d(), 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(), replace_amplitudes(), EMAN::Util::subn_img(), and window_center().

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 1149 of file emdata.h.

Referenced by do_fft(), do_fft_inplace(), and window_center().

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

Is this a FH image?

Returns:
Whether this is a FH image or not.

Definition at line 949 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 1079 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 985 of file emdata.h.

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

00989         {

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 1115 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(), center_origin_fft(), 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 932 of file emdata.h.

Referenced by fft_shuffle(), fouriergridrot2d(), fouriergridrot_shift2d(), 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 1288 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().

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

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 999 of file emdata_core.cpp.

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

01000 {
01001         ENTERFUNC;
01002 
01003         if (is_complex()) {
01004                 throw ImageFormatException("real image only");
01005         }
01006 
01007         EMData * r = this->copy();
01008         float * new_data = r->get_data();
01009         float * data = get_data();
01010         size_t size = nxyz;
01011         for (size_t i = 0; i < size; ++i) {
01012                 if(data[i] < 0) {
01013                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
01014                 }
01015                 else {
01016                         if(data[i]) {   //do nothing with pixel has value zero
01017                                 new_data[i] = std::log(data[i]);
01018                         }
01019                 }
01020         }
01021 
01022         r->update();
01023         return r;
01024 
01025         EXITFUNC;
01026 }

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 1029 of file emdata_core.cpp.

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

01030 {
01031         ENTERFUNC;
01032 
01033         if (is_complex()) {
01034                 throw ImageFormatException("real image only");
01035         }
01036 
01037         EMData * r = this->copy();
01038         float * new_data = r->get_data();
01039         float * data = get_data();
01040         size_t size = nxyz;
01041         for (size_t i = 0; i < size; ++i) {
01042                 if(data[i] < 0) {
01043                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
01044                 }
01045                 else {
01046                         if(data[i]) {   //do nothing with pixel has value zero
01047                                 new_data[i] = std::log10(data[i]);
01048                         }
01049                 }
01050         }
01051 
01052         r->update();
01053         return r;
01054 
01055         EXITFUNC;
01056 }

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 1928 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.

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

EMData * EMData::make_rotational_footprint_cmc bool  unwrap = true  ) 
 

Definition at line 1708 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().

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

EMData * EMData::make_rotational_footprint_e1 bool  unwrap = true  ) 
 

Definition at line 1795 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().

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

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

Definition at line 1373 of file emdata_metadata.cpp.

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

01373                                                                               {
01374         Vec3i coord(seed[0],seed[1],seed[2]);
01375         vector<Vec3i> region;
01376         region.push_back(coord);
01377         vector<Vec3i> find_region_input = region;
01378         while (true) {
01379                 vector<Vec3i> v = find_region(this,find_region_input, value, region);
01380                 if (v.size() == 0 ) break;
01381                 else find_region_input = v;
01382         }
01383         return region;
01384 }

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(), 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                 Vec3f v = Vec3f(r0*cos((float)i), r0*sin((float)i), 0);
00954                 Vec3f d = t*v-v;
00955                 float dd = d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
00956                 if (dd > ddmax) ddmax = dd; 
00957         }
00958         return std::sqrt(ddmax);
00959 }

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 511 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().

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

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 483 of file emdata_core.cpp.

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

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

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 1794 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::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(), and EMAN::SNREvalProcessor::process_inplace().

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

Definition at line 551 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().

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

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 1792 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().

01792                                                                       {
01793         ENTERFUNC;
01794         int nxc = attr_dict["nxc"]; // # of complex elements along x
01795         // let's treat nr, bi, and local data as matrices
01796         vector<int> saved_offsets = get_array_offsets();
01797         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01798         set_array_offsets(0,1,1);
01799         myfft->set_array_offsets(0,1);
01800 
01801         Ctf* ctf = myfft->get_attr("ctf");
01802         ctf_store::init( ny, ctf );
01803         if(ctf) {delete ctf; ctf=0;}
01804 
01805         // loop over frequencies in y
01806         for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_ctf(iy, ny, nxc, w, myfft, tf, mult);
01807         set_array_offsets(saved_offsets);
01808         myfft->set_array_offsets(myfft_saved_offsets);
01809         EXITFUNC;
01810 }

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 1813 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().

01813                                                                               {
01814         ENTERFUNC;
01815         int nxc = attr_dict["nxc"]; // # of complex elements along x
01816         // let's treat nr, bi, and local data as matrices
01817         vector<int> saved_offsets = get_array_offsets();
01818         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01819         set_array_offsets(0,1,1);
01820         myfft->set_array_offsets(0,1);
01821 
01822         Ctf* ctf = myfft->get_attr( "ctf" );
01823         ctf_store::init( ny, ctf );
01824         if(ctf) {delete ctf; ctf=0;}
01825         //}
01826 
01827         // loop over frequencies in y
01828         for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_ctf_applied(iy, ny, nxc, w, myfft, tf, mult);
01829         set_array_offsets(saved_offsets);
01830         myfft->set_array_offsets(myfft_saved_offsets);
01831         EXITFUNC;
01832 }

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 1333 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().

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

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 2177 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().

02178 {
02179         /***   Preparing terms for SSNR
02180               m_wvolume F^3D Wiener volume
02181              wptr   ctf^2
02182             wptr5  ctf^2*|P^2D->3D(F^3D)|^2
02183            wptr4  2*Real(conj(F_k^2D)*ctf*P^2D->3D(F^3D))
02184           wptr2  F_k^2D*conj(F_k^2D) or |F_k^2D|^2
02185           Kn is counted in the previous routine, and won't be
02186          calculated any more.
02187                                                     ***/
02188         ENTERFUNC;
02189         int nxc = attr_dict["nxc"];
02190         vector<int> saved_offsets = get_array_offsets();
02191         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
02192         set_array_offsets(0,1,1);
02193         myfft->set_array_offsets(0,1);
02194 
02195         Ctf* ctf = myfft->get_attr("ctf");
02196         ctf_store::init( ny, ctf );
02197         int iymin = is_fftodd() ? -ny/2 : -ny/2 + 1;
02198         int iymax = ny/2;
02199         int izmin = is_fftodd() ? -nz/2 : -nz/2 + 1;
02200         int izmax = nz/2;
02201 //      std::complex<float> tmpq, tmp2;
02202         for (int iy = iymin; iy <= iymax; iy++) {
02203                 int jp = iy >= 0 ? iy+1 : ny+iy+1; //checked, works for both odd and even
02204                 for (int ix = 0; ix <= nxc; ix++) {
02205                         int r2 = ix*ix+iy*iy;
02206                         if (( 4*r2 < ny*ny ) && !( ix == 0 && iy < 0 ) ) {
02207                                 float  ctf = ctf_store::get_ctf( r2 )*10.f;
02208                                 float xnew = ix*tf[0][0] + iy*tf[1][0];
02209                                 float ynew = ix*tf[0][1] + iy*tf[1][1];
02210                                 float znew = ix*tf[0][2] + iy*tf[1][2];
02211                                 std::complex<float> btq;
02212                                 if (xnew < 0.0) {
02213                                         xnew = -xnew; // ensures xnew>=0.0
02214                                         ynew = -ynew;
02215                                         znew = -znew;
02216                                         btq = conj(myfft->cmplx(ix,jp));
02217                                 } else  {
02218                                         btq = myfft->cmplx(ix,jp);
02219                                 }
02220                                 int ixn = int(xnew + 0.5 + nx) - nx; // ensures ixn >= 0
02221                                 int iyn = int(ynew + 0.5 + ny) - ny;
02222                                 int izn = int(znew + 0.5 + nz) - nz;
02223                                 if ((ixn <= nxc) && (iyn >= iymin) && (iyn <= iymax) && (izn >= izmin) && (izn <= izmax)) {
02224                                         if (ixn >= 0) {
02225                                                 int iza, iya;
02226                                                 if (izn >= 0) iza = izn + 1;
02227                                                 else          iza = nz + izn + 1;
02228 
02229                                                 if (iyn >= 0) iya = iyn + 1;
02230                                                 else          iya = ny + iyn + 1;
02231 
02232                                                 cmplx(ixn,iya,iza)    += btq*ctf;
02233                                                 (*wptr)(ixn,iya,iza)  += ctf*ctf;
02234                                                 (*wptr2)(ixn,iya,iza) += std::norm(btq);
02235                                                 (*wptr3)(ixn,iya,iza) += 1;
02236                                         } else {
02237                                                 int izt, iyt;
02238                                                 if (izn > 0)  izt = nz - izn + 1;
02239                                                 else          izt = -izn + 1;
02240 
02241                                                 if (iyn > 0) iyt = ny - iyn + 1;
02242                                                 else         iyt = -iyn + 1;
02243 
02244                                                 cmplx(-ixn,iyt,izt)    += std::conj(btq)*ctf;
02245                                                 (*wptr) (-ixn,iyt,izt) += ctf*ctf;
02246                                                 (*wptr2)(-ixn,iyt,izt) += std::norm(btq);
02247                                                 (*wptr3)(-ixn,iyt,izt) += 1;
02248                                         }
02249                                 }
02250                         }
02251                 }
02252         }
02253         set_array_offsets(saved_offsets);
02254         myfft->set_array_offsets(myfft_saved_offsets);
02255         if(ctf) {delete ctf; ctf=0;}
02256         EXITFUNC;
02257 }

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 6680 of file emdata_sparx.cpp.

References circumference(), copy_head(), data, get_array_offsets(), get_attr(), get_data(), get_xsize(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), nx, nx, nxyz, ny, ny, nz, set_array_offsets(), set_attr(), set_fftodd(), set_fftpad(), set_size(), and to_zero().

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

06680                                                            {
06681         if (this->is_complex())
06682                 throw ImageFormatException("Padding of complex images not supported");
06683         int nx = this->get_xsize();
06684         int ny = this->get_ysize();
06685         int nz = this->get_zsize();
06686         float mean = 0., stddev = 1.;
06687         if(donorm) { // Normalization requested
06688                 mean = this->get_attr("mean");
06689                 stddev = this->get_attr("sigma");
06690         }
06691         // sanity check
06692         if (npad < 1) npad = 1;
06693         int nxpad = npad*nx;
06694         int nypad = npad*ny;
06695         int nzpad = npad*nz;
06696         if (1 == ny) {
06697                 // 1-d image, don't want to pad along y or z
06698                 // Also, assuming that we can't have an image sized as nx=5, ny=1, nz=5.
06699                 nypad = ny;
06700                 nzpad = nz;
06701         } else if (nz == 1) {
06702                 // 2-d image, don't want to pad along z
06703                 nzpad = nz;
06704         }
06705         size_t bytes;
06706         size_t offset;
06707         // Not currently fft-extended, so we want to extend for ffts
06708         offset = 2 - nxpad%2;
06709         bytes = nx*sizeof(float);
06710         EMData* fpimage = copy_head();
06711         fpimage->set_size(nxpad+offset, nypad, nzpad);
06712         int xstart = 0, ystart = 0, zstart = 0;
06713         if( npad > 1) {
06714                 if( valtype==0 ) {
06715                         fpimage->to_zero();
06716                 } else {
06717                         float val = circumference(this, 1);
06718                         float* data = fpimage->get_data();
06719                         int nxyz = (nxpad+offset)*nypad*nzpad;
06720                         for( int i=0; i < nxyz; ++i )  data[i] = val;
06721                 }
06722 
06723                 xstart = (nxpad - nx)/2 + nx%2;
06724                 if(ny > 1) {
06725                         ystart = (nypad - ny)/2 + ny%2;
06726                         if(nz > 1) {
06727                                 zstart = (nzpad - nz)/2 + nz%2;
06728                         }
06729                 }
06730         }
06731 
06732 
06733         vector<int> saved_offsets = this->get_array_offsets();
06734         this->set_array_offsets( 0, 0, 0 );
06735         for (int iz = 0; iz < nz; iz++) {
06736                 for (int iy = 0; iy < ny; iy++) {
06737                         memcpy(&(*fpimage)(xstart,iy+ystart,iz+zstart), &(*this)(0,iy,iz), bytes);
06738                 }
06739         }
06740         this->set_array_offsets( saved_offsets );
06741 
06742 
06743         //  Perform the actual normalization (only on the
06744         //  non-zero section of the image)
06745         if (donorm) { // Normalization requested
06746                 for (int iz = zstart; iz < nz+zstart; iz++)
06747                         for (int iy = ystart; iy < ny+ystart; iy++)
06748                                 for (int ix = xstart; ix < nx+xstart; ix++)
06749                                         (*fpimage)(ix,iy,iz) = ((*fpimage)(ix,iy,iz)-mean)/stddev;
06750         }
06751 
06752         fpimage->set_fftpad(true);
06753         fpimage->set_attr("npad", npad);
06754         if (offset == 1) fpimage->set_fftodd(true);
06755         else             fpimage->set_fftodd(false);
06756         return fpimage;
06757 }

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

Definition at line 4004 of file emdata.cpp.

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

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

04004                                                             {           // sent MAXR value here later!!
04005         float *pcs=get_data();
04006         EMData *imagepcsfft = new EMData;
04007         imagepcsfft->set_size((size+2), (int)MAXR+1, 1);
04008         float *d=imagepcsfft->get_data();
04009 
04010         EMData *data_in=new EMData;
04011         data_in->set_size(size,1,1);
04012         float *in=data_in->get_data();
04013 
04014         for(int row=0; row<=(int)MAXR; ++row){
04015                 if(row<=(int)rmax) {
04016                         for(int i=0; i<size;++i)        in[i] = pcs[i+row*size]; // ming
04017                         data_in->set_complex(false);
04018                         data_in->do_fft_inplace();
04019                         for(int j=0;j<size+2;j++)  d[j+row*(size+2)]=in[j];
04020                 }
04021                 else for(int j=0;j<size+2;j++) d[j+row*(size+2)]=0.0;
04022         }
04023         imagepcsfft->update();
04024         delete data_in;
04025         return imagepcsfft;
04026 }

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 1625 of file emdata_sparx.cpp.

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

Referenced by nn_ctf().

01626                                                                                 {//std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01627 
01628         int remove = bi->get_attr_default( "remove", 0 );
01629 
01630         int jp = (j >= 0) ? j+1 : n+j+1;
01631         // loop over x
01632         for (int i = 0; i <= n2; i++) {
01633                 int r2 = i*i+j*j;
01634                 if ( (r2<n*n/4) && !((0==i) && (j<0)) ) {
01635                         float  ctf = ctf_store::get_ctf( r2 );
01636                         float xnew = i*tf[0][0] + j*tf[1][0];
01637                         float ynew = i*tf[0][1] + j*tf[1][1];
01638                         float znew = i*tf[0][2] + j*tf[1][2];
01639                         std::complex<float> btq;
01640                         if (xnew < 0.) {
01641                                 xnew = -xnew;
01642                                 ynew = -ynew;
01643                                 znew = -znew;
01644                                 btq = conj(bi->cmplx(i,jp));
01645                         } else  btq = bi->cmplx(i,jp);
01646                         int ixn = int(xnew + 0.5 + n) - n;
01647                         int iyn = int(ynew + 0.5 + n) - n;
01648                         int izn = int(znew + 0.5 + n) - n;
01649                         
01650                         int iza, iya;
01651                         if (izn >= 0)  iza = izn + 1;
01652                         else           iza = n + izn + 1;
01653 
01654                         if (iyn >= 0) iya = iyn + 1;
01655                         else          iya = n + iyn + 1;
01656 
01657                         if(remove > 0 ) {
01658                                 cmplx(ixn,iya,iza) -= btq*ctf*float(mult);
01659                                 (*w)(ixn,iya,iza) -= ctf*ctf*mult;
01660                         } else {
01661                                 cmplx(ixn,iya,iza) += btq*ctf*float(mult);
01662                                 (*w)(ixn,iya,iza) += ctf*ctf*mult;
01663                         }
01664 
01665                                        //       std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<ctf<<std::endl;
01666                 
01667                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2) && (izn >= -n2) && (izn <= n2)) {
01668                                 if (ixn >= 0) {
01669                                         int iza, iya;
01670                                         if (izn >= 0)  iza = izn + 1;
01671                                         else           iza = n + izn + 1;
01672 
01673                                         if (iyn >= 0) iya = iyn + 1;
01674                                         else          iya = n + iyn + 1;
01675 
01676                                         if(remove > 0 ) {
01677                                             cmplx(ixn,iya,iza) -= btq*ctf*float(mult);
01678                                             (*w)(ixn,iya,iza) -= ctf*ctf*mult;
01679                                         } else {
01680                                             cmplx(ixn,iya,iza) += btq*ctf*float(mult);
01681                                             (*w)(ixn,iya,iza) += ctf*ctf*mult;
01682                                         }
01683 
01684                                        //       std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<ctf<<std::endl;
01685                                 } else {
01686                                         int izt, iyt;
01687                                         if (izn > 0) izt = n - izn + 1;
01688                                         else         izt = -izn + 1;
01689 
01690                                         if (iyn > 0) iyt = n - iyn + 1;
01691                                         else         iyt = -iyn + 1;
01692 
01693                                         if( remove > 0 ) {
01694                                             cmplx(-ixn,iyt,izt) -= conj(btq)*ctf*float(mult);
01695                                             (*w)(-ixn,iyt,izt) -= ctf*ctf*float(mult);
01696                                         } else {
01697                                             cmplx(-ixn,iyt,izt) += conj(btq)*ctf*float(mult);
01698                                             (*w)(-ixn,iyt,izt) += ctf*ctf*float(mult);
01699                                         }
01700 
01701                                         //      std::cout<<" *  " << j << "  " <<-ixn << "  " << iyt << "  " << izt << "  " << ctf <<std::endl;
01702                                 }
01703                         }*/
01704                 }
01705         }
01706 }

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 1708 of file emdata_sparx.cpp.

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

Referenced by nn_ctf_applied().

01709                                                                                 {//std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01710 
01711         int remove = bi->get_attr_default( "remove", 0 );
01712 
01713         int jp = (j >= 0) ? j+1 : n+j+1;
01714         // loop over x
01715         for (int i = 0; i <= n2; i++) {
01716                 int r2 = i*i + j*j;
01717                 if ( (r2< n*n/4) && !((0==i) && (j< 0)) ) {
01718                         float  ctf = ctf_store::get_ctf(r2);
01719 
01720                          //        if ( !((0 == i) && (j < 0))) {
01721                         float xnew = i*tf[0][0] + j*tf[1][0];
01722                         float ynew = i*tf[0][1] + j*tf[1][1];
01723                         float znew = i*tf[0][2] + j*tf[1][2];
01724                         std::complex<float> btq;
01725                         if (xnew < 0.) {
01726                                 xnew = -xnew;
01727                                 ynew = -ynew;
01728                                 znew = -znew;
01729                                 btq = conj(bi->cmplx(i,jp));
01730                         } else  btq = bi->cmplx(i,jp);
01731                         int ixn = int(xnew + 0.5 + n) - n;
01732                         int iyn = int(ynew + 0.5 + n) - n;
01733                         int izn = int(znew + 0.5 + n) - n;
01734                         
01735                         int iza, iya;
01736                         if (izn >= 0)  iza = izn + 1;
01737                         else           iza = n + izn + 1;
01738 
01739                         if (iyn >= 0) iya = iyn + 1;
01740                         else          iya = n + iyn + 1;
01741 
01742                         if( remove > 0 ) {
01743                                 cmplx(ixn,iya,iza) -= btq*float(mult);
01744                                 (*w)(ixn,iya,iza) -= mult*ctf*ctf;
01745                         } else {
01746                                 cmplx(ixn,iya,iza) += btq*float(mult);
01747                                 (*w)(ixn,iya,iza) += mult*ctf*ctf;
01748                         }
01749 
01750 
01751                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2) && (izn >= -n2) && (izn <= n2)) {
01752                                 if (ixn >= 0) {
01753                                         int iza, iya;
01754                                         if (izn >= 0)  iza = izn + 1;
01755                                         else           iza = n + izn + 1;
01756 
01757                                         if (iyn >= 0) iya = iyn + 1;
01758                                         else          iya = n + iyn + 1;
01759 
01760                                         if( remove > 0 ) {
01761                                                 cmplx(ixn,iya,iza) -= btq*float(mult);
01762                                                 (*w)(ixn,iya,iza) -= mult*ctf*ctf;
01763                                         } else {
01764                                                 cmplx(ixn,iya,iza) += btq*float(mult);
01765                                                 (*w)(ixn,iya,iza) += mult*ctf*ctf;
01766                                         }
01767 
01768                                 } else {
01769                                         int izt, iyt;
01770                                         if (izn > 0) izt = n - izn + 1;
01771                                         else         izt = -izn + 1;
01772 
01773                                         if (iyn > 0) iyt = n - iyn + 1;
01774                                         else         iyt = -iyn + 1;
01775 
01776 
01777                                         if( remove > 0 ) {
01778                                                 cmplx(-ixn,iyt,izt) -= conj(btq)*float(mult);
01779                                                 (*w)(-ixn,iyt,izt) -= mult*ctf*ctf;
01780                                         } else {
01781                                                 cmplx(-ixn,iyt,izt) += conj(btq)*float(mult);
01782                                                 (*w)(-ixn,iyt,izt) += mult*ctf*ctf;
01783                                         }
01784                                         //std::cout<<" *  "<<j<<"  "<<ixn<<"  "<<iyt<<"  "<<izt<<"  "<<btq<<std::endl;
01785                                 }
01786                         }*/
01787                 }
01788         }
01789 }

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 928 of file emdata_core.cpp.

References mult(), and update().

00929 {
00930         mult(em);
00931         update();
00932         return *this;
00933 }

EMData & EMData::operator *= float  n  ) 
 

Definition at line 893 of file emdata_core.cpp.

References mult(), and update().

00894 {
00895         mult(n);
00896         update();
00897         return *this;
00898 }

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

Definition at line 2330 of file emdata.h.

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

Definition at line 2318 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 2308 of file emdata.h.

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

Definition at line 912 of file emdata_core.cpp.

References add(), and update().

00913 {
00914         add(em);
00915         update();
00916         return *this;
00917 }

EMData & EMData::operator+= float  n  ) 
 

Definition at line 878 of file emdata_core.cpp.

References add(), and update().

00879 {
00880         add(n);
00881         update();
00882         return *this;
00883 }

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

Definition at line 920 of file emdata_core.cpp.

References sub(), and update().

00921 {
00922         sub(em);
00923         update();
00924         return *this;
00925 }

EMData & EMData::operator-= float  n  ) 
 

Definition at line 886 of file emdata_core.cpp.

00887 {
00888         *this += (-n);
00889         return *this;
00890 }

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

Definition at line 936 of file emdata_core.cpp.

References div(), and update().

00937 {
00938         div(em);
00939         update();
00940         return *this;
00941 }

EMData & EMData::operator/= float  n  ) 
 

Definition at line 901 of file emdata_core.cpp.

References LOGERR.

00902 {
00903         if (n == 0) {
00904                 LOGERR("divided by zero");
00905                 return *this;
00906         }
00907         *this *= (1.0f / n);
00908         return *this;
00909 }

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

Definition at line 2956 of file emdata.cpp.

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

02956                                                 {
02957         if (that.get_xsize() != nx || that.get_ysize() != ny || that.get_zsize() != nz ) return false;
02958 
02959         const float*  d1 = that.get_const_data();
02960         float* d2 = get_data();
02961 
02962         for(size_t i =0; i < get_size(); ++i,++d1,++d2) {
02963                 if ((*d1) != (*d2)) return false;
02964         }
02965         return true;
02966 
02967 }

void EMData::pad_corner float *  pad_image  ) 
 

Definition at line 4064 of file emdata_sparx.cpp.

References nx.

04064                                         {
04065         size_t nbytes = nx*sizeof(float);
04066         for (int iy=0; iy<ny; iy++)
04067                 memcpy(&(*this)(0,iy), pad_image+3+(iy+3)*nx, nbytes);
04068 }

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 6070 of file emdata_sparx.cpp.

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

06071 {
06072 
06073   // cout << "peak ccf starting up" << endl;
06074 
06075   EMData & buf = *this;
06076   vector<Pixel> peaks;
06077   int half=int(hf_p);
06078   float hf_p2 = hf_p*hf_p;
06079   int i,j;
06080   int i__1,i__2;
06081   int j__1,j__2;
06082   vector<float>res;
06083   int nx = buf.get_xsize()-half;
06084   int ny = buf.get_ysize()-half;
06085   // iterate over image
06086   for(i=half; i<=nx; ++i) {
06087     // static assignment so we don't have to re-evaluate
06088     i__1 = i-1;
06089     i__2 = i+1;
06090     for (j=half;j<=ny;++j) {
06091       j__1 = j-1;
06092       j__2 = j+1;
06093 
06094       if((buf(i,j)>0.0f)&&buf(i,j)>buf(i,j__1)) {
06095         if(buf(i,j)>buf(i,j__2)) {
06096           if(buf(i,j)>buf(i__1,j)) {
06097             if(buf(i,j)>buf(i__2,j)) {
06098               if(buf(i,j)>buf(i__1,j__1)) {
06099                 if((buf(i,j))> buf(i__1,j__2)) {
06100                   if(buf(i,j)>buf(i__2,j__1)) {
06101                     if(buf(i,j)> buf(i__2,j__2)) {
06102 
06103                       // found a peak
06104                       // empty list?
06105                       if (peaks.size()==0) {
06106                         // yes, so just push the peak onto the list
06107                         peaks.push_back(Pixel(i,j,0,buf(i,j)));
06108 
06109                       } else {
06110                         // not empty list. check neighbourhood for peaks
06111                         // logical not in the name is awkward. renamed to overlap
06112                         bool overlap = false;
06113                         //int  size = peaks.size();
06114 
06115                         // list of peaks to be deleted, if the current peak is the largest (see below).
06116                         //    list contains iterators to the original list, which will have to be processed
06117                         //    back to front (i.e. LIFO: stl::stack)
06118                         std::stack <vector<Pixel>::iterator> delete_stack;
06119 
06120                         // loop over all peaks found so far. this would be nicer with iterators
06121                         for (vector<Pixel>::iterator it=peaks.begin();it!=peaks.end();++it) {
06122                         // for ( int kk= 0; kk< size; kk++) {
06123                         //  vector<Pixel>::iterator it = peaks.begin()+kk;
06124 
06125                           // calc L2 distance
06126                           float radius=((*it).x-float(i))*((*it).x-float(i))+((*it).y-float(j))*((*it).y-float(j));
06127                           if (radius <= hf_p2 ) {
06128                             // peaks overlap
06129                             if( buf(i,j) > (*it).value) {
06130                               // this peak (indexed by (i,j)) is larger, mark the old for deletion
06131                               //    however, we have to be careful. if there is a larger peak within the vicinity of
06132                               //    the new one, this new peak is not marked as such, and the deletion of prior low
06133                               //    peaks should not continued. to make sure this deletion does not happen, we have
06134                               //    to make sure we cycle through all peaks within the vicinity, and only delete smaller
06135                               //    peaks if this new one is the largest in the vicinity.
06136                               delete_stack.push(it);
06137 
06138                               //(*it).x = -half; // this marks entry to be deleted, since it's smaller than the new one
06139 
06140 
06141                             } else {
06142                               overlap = true;
06143                               // old peak is larger, ignore this one. since it's enough to know there is some peak larger
06144                               //    than this one, we can break out of the peak list loop, instead of continuing.
06145                               break;
06146                             }
06147                           }
06148                         }
06149 
06150                         // check whether we need to delete anything. this is marked by the flag overlap == false
06151                         // loop over all peaks and clean out redundant ones
06152                         if (false == overlap) {
06153                           vector<Pixel>::iterator delete_iterator;
06154                           while (!delete_stack.empty()) {
06155                             // pop empties the stack from the back. since we are dealing with iterators, we need to delete
06156                             //    from the back, so as to keep the rest stack intact upon deletion.
06157                             delete_iterator = delete_stack.top();
06158                             peaks.erase(delete_iterator);
06159                             delete_stack.pop();
06160                           }
06161                           // before pushing the peak, we need to check whether max queue length is exceeded and delete
06162                           //     peaks if necessary.
06163                           // XXX: remove hardcoded value!
06164                           if (! (peaks.size() < 2000 )) {
06165 
06166                             //cout << ".";
06167                             // we need to delete a peak first.
06168                             // - resort list to get lowest peak at the back
06169                             sort(peaks.begin(), peaks.end(), peakcmp);
06170 
06171                             // - remove lowest peak
06172                             peaks.pop_back();
06173                           }
06174 
06175                           // push the new peak onto the list of peaks
06176                           peaks.push_back(Pixel(i,j,0,buf(i,j)));
06177                           //cout << "done." << endl;
06178 
06179                         } else {
06180                           // this peak too small and is ignored, so delete_list is ignored as well. make sure delete_list
06181                           //    is empty. probably redundant because of scope, but better safe than sorry.....
06182                           while (!delete_stack.empty()) delete_stack.pop();
06183                         }
06184                       }
06185                     }
06186                   }}}}}}}
06187     }
06188   }
06189 
06190   // we have peaks, so build a results vector.
06191   if(peaks.size()>0) {
06192     // sort peaks by size
06193     sort(peaks.begin(),peaks.end(), peakcmp);
06194     // and push all peaks to the results vector
06195     for (vector<Pixel>::iterator it = peaks.begin(); it != peaks.end(); it++) {
06196       // XXX: this format is necessary for Boost to work???
06197       res.push_back((*it).value);
06198       res.push_back(static_cast<float>((*it).x));
06199       res.push_back(static_cast<float>((*it).y));
06200     }
06201   } else {
06202     // only one or zero (?) entries
06203     res.push_back(buf(0,0,0));
06204     res.insert(res.begin(),1,0.0);
06205   }
06206   return res;
06207 }

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 5067 of file emdata_sparx.cpp.

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

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

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

Definition at line 4994 of file emdata_sparx.cpp.

References EMAN::Pixel::value.

04994                                                      {
04995     return (p1.value > p2.value);
04996 }

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 1269 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().

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

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 5840 of file emdata_sparx.cpp.

References C, get_ndim(), nx, ny, nz, rdata, X, Y, and Z.

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

05841 {
05842         vector<float> ph_cntog;
05843         int i=1,j=1,k=1;
05844         float C=0.f,S=0.f,P=0.f,F1=0.f,SNX;
05845         if (get_ndim()==1) {
05846                 P = 8*atan(1.0f)/nx;
05847                 for (i=1;i<=nx;i++) {
05848                         C += cos(P * (i-1)) * rdata(i,j,k);
05849                         S += sin(P * (i-1)) * rdata(i,j,k);
05850                 }
05851                 F1 = atan2(S,C);
05852                 if (F1 < 0.0)  F1 += 8*atan(1.0f);
05853                 SNX = F1/P +1.0f;
05854                 SNX = SNX - ((nx/2)+1);
05855                 ph_cntog.push_back(SNX);
05856 #ifdef _WIN32
05857                 ph_cntog.push_back((float)Util::round(SNX));
05858 #else
05859                 ph_cntog.push_back(round(SNX));
05860 #endif //_WIN32
05861         } else if (get_ndim()==2)  {
05862 #ifdef _WIN32
05863                 float SNY;
05864                 float T=0.0f;
05865                 vector<float> X;
05866                 X.resize(nx);
05867 #else
05868                 float SNY,X[nx],T=0.f;
05869 #endif  //_WIN32
05870                 for ( i=1;i<=nx;i++) X(i)=0.0;
05871                 P = 8*atan(1.0f)/ny;
05872                 for(j=1;j<=ny;j++) {
05873                         T=0.f;
05874                         for(i=1;i<=nx;i++) {
05875                                 T += rdata(i,j,k);
05876                                 X(i)+=rdata(i,j,k);
05877                         }
05878                         C += cos(P*(j-1))*T;
05879                         S += sin(P*(j-1))*T;
05880                 }
05881                 F1=atan2(S,C);
05882                 if(F1<0.0)  F1 += 8*atan(1.0f);
05883                 SNY = F1/P +1.0f;
05884                 C=0.f;  S=0.f;
05885                 P = 8*atan(1.0f)/nx;
05886                 for(i=1;i<=nx;i++) {
05887                         C += cos(P*(i-1))*X(i);
05888                         S += sin(P*(i-1))*X(i);
05889                 }
05890                 F1=atan2(S,C);
05891                 if(F1<0.0) F1 += 8*atan(1.0f);
05892                 SNX = F1/P +1.0f;
05893                 SNX = SNX - ((nx/2)+1);
05894                 SNY = SNY - ((ny/2)+1);
05895                 ph_cntog.push_back(SNX); ph_cntog.push_back(SNY);
05896 #ifdef _WIN32
05897                  ph_cntog.push_back((float)Util::round(SNX)); ph_cntog.push_back((float)Util::round(SNY));
05898 #else
05899                  ph_cntog.push_back(round(SNX)); ph_cntog.push_back(round(SNY));
05900 #endif  //_WIN32
05901         } else {
05902 #ifdef _WIN32
05903                 float val=0.f,sum1=0.f, SNY,SNZ;
05904                 vector<float> X;
05905                 X.resize(nx);
05906                 vector<float> Y;
05907                 Y.resize(ny);
05908                 vector<float> Z;
05909                 Z.resize(nz);
05910 #else
05911                 float val=0.f, sum1=0.f, X[nx], Y[ny], Z[nz], SNY, SNZ;
05912 #endif  //_WIN32
05913                  for (i=1;i<=nx;i++)  X(i)=0.0;
05914                  for (j=1;j<=ny;j++)  Y(j)=0.0;
05915                  for (k=1;k<=nz;k++)  Z(k)=0.0;
05916                  for(k=1;k<=nz;k++)  {
05917                         for(j=1;j<=ny;j++) {
05918                                 sum1=0.f;
05919                                 for(i=1;i<=nx;i++)  {
05920                                         val = rdata(i,j,k);
05921                                         sum1 += val;
05922                                         X(i) += val;
05923                                 }
05924                                 Y(j) += sum1;
05925                                 Z(k) += sum1;
05926                         }
05927                 }
05928                 P = 8*atan(1.0f)/nx;
05929                 for (i=1;i<=nx;i++) {
05930                         C += cos(P*(i-1))*X(i);
05931                         S += sin(P*(i-1))*X(i);
05932                 }
05933                 F1=atan2(S,C);
05934                 if(F1<0.0) F1 += 8*atan(1.0f);
05935                 SNX = F1/P +1.0f;
05936                 C=0.f;  S=0.f;
05937                 P = 8*atan(1.0f)/ny;
05938                 for(j=1;j<=ny;j++) {
05939                         C += cos(P*(j-1))*Y(j);
05940                         S += sin(P*(j-1))*Y(j);
05941                 }
05942                 F1=atan2(S,C);
05943                 if(F1<0.0)  F1 += 8*atan(1.0f);
05944                 SNY = F1/P +1.0f;
05945                 C=0.f;  S=0.f;
05946                 P = 8*atan(1.0f)/nz;
05947                 for(k=1;k<=nz;k++) {
05948                         C += cos(P*(k-1))*Z(k);
05949                         S += sin(P*(k-1))*Z(k);
05950                 }
05951                 F1=atan2(S,C);
05952                 if(F1<0.0)  F1 += 8*atan(1.0f);
05953                 SNZ = F1/P +1.0f;
05954                 SNX = SNX - ((nx/2)+1);
05955                 SNY = SNY - ((ny/2)+1);
05956                 SNZ = SNZ - ((nz/2)+1);
05957                 ph_cntog.push_back(SNX); ph_cntog.push_back(SNY); ph_cntog.push_back(SNZ);
05958 #ifdef _WIN32
05959                 ph_cntog.push_back((float)Util::round(SNX)); ph_cntog.push_back((float)Util::round(SNY)); ph_cntog.push_back((float)Util::round(SNZ));
05960 #else
05961                 ph_cntog.push_back(round(SNX)); ph_cntog.push_back(round(SNY));ph_cntog.push_back(round(SNZ));
05962 #endif
05963         }
05964         return ph_cntog;
05965 }

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 944 of file emdata_core.cpp.

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

00945 {
00946         ENTERFUNC;
00947 
00948         if( n<0 ) {
00949                 throw InvalidValueException(n, "the power of negative integer not supported.");
00950         }
00951 
00952         EMData * r = this->copy();
00953         if( n == 0 ) {
00954                 r->to_one();
00955         }
00956         else if( n>1 ) {
00957                 for( int i=1; i<n; i++ ) {
00958                         *r *= *this;
00959                 }
00960         }
00961 
00962         r->update();
00963         return r;
00964 
00965         EXITFUNC;
00966 }

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 325 of file emdata_io.cpp.

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

00325                                                        {
00326         out << "Printing EMData object: " << str << std::endl;
00327         int nx = get_xsize();
00328         int ny = get_ysize();
00329         int nz = get_zsize();
00330         for (int iz = 0; iz < nz; iz++) {
00331                 out << "(z = " << iz << " slice)" << std::endl;
00332                 for (int ix = 0; ix < nx; ix++) {
00333                         for (int iy = 0; iy < ny; iy++) {
00334                                 out << setiosflags(std::ios::fixed)
00335                                         << setiosflags(std::ios_base::scientific)
00336                                         << std::setw(12)
00337                                          << std::setprecision(5) << (*this)(ix,iy,iz) << "  ";
00338                                 if (((iy+1) % 6) == 0) {
00339                                         out << std::endl << "   ";
00340                                 }
00341                         }
00342                         out << std::endl;
00343                 }
00344         }
00345 }

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::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotatePrecenterAligner::align(), EMAN::RotationalAligner::align(), EMAN::TranslationalAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), EMAN::MarchingCubes::calculate_min_max_vals(), EMAN::SqEuclideanCmp::cmp(), make_rotational_footprint_e1(), EMAN::BackProjectionReconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::ScaleTransformProcessor::process(), EMAN::SymAlignProcessor::process(), EMAN::ApplySymProcessor::process(), refalifn(), refalifn3dquat(), 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::RotateTranslateAligner::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::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::FlattenBackgroundProcessor::process_inplace(), EMAN::SNREvalProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), 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_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, 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, 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(), 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                         attr_dict["source_path"] = filename;
00068                         attr_dict["source_n"] = img_index;
00069                         if (imageio->is_complex_mode()) {
00070                                 set_complex(true);
00071                                 set_fftpad(true);
00072                         }
00073                         if (attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1) {
00074                                 set_fftodd(true);
00075                         }
00076                         if ((int) attr_dict["is_complex_ri"] == 1) {
00077                                 set_ri(true);
00078                         }
00079                         save_byteorder_to_dict(imageio);
00080 
00081                         nx = attr_dict["nx"];
00082                         ny = attr_dict["ny"];
00083                         nz = attr_dict["nz"];
00084 
00085 //                      if(attr_dict.has_key("ctf")) {
00086 //                              flags |= EMDATA_HASCTFF;
00087 //                      }
00088 //                      else {
00089 //                              flags &= ~EMDATA_HASCTFF;
00090 //                      }
00091 
00092                         if (!nodata) {
00093 
00094                                 if (region) {
00095                                         nx = (int)region->get_width();
00096                                         if (nx <= 0) nx = 1;
00097                                         ny = (int)region->get_height();
00098                                         if (ny <= 0) ny = 1;
00099                                         nz = (int)region->get_depth();
00100                                         if (nz <= 0) nz = 1;
00101                                         set_size(nx,ny,nz);
00102                                         to_zero(); // This could be avoided in favor of setting only the regions that were not read to to zero... but tedious
00103                                 } // else the dimensions of the file being read match those of this
00104                                 else {
00105                                         set_size(nx, ny, nz);
00106                                 }
00107 
00108                                 // If GPU features are enabled there is  danger that rdata will
00109                                 // not be allocated, but set_size takes care of this, so this
00110                                 // should be safe.
00111                                 int err = imageio->read_data(get_data(), img_index, region, is_3d);
00112                                 if (err) {
00113                                         throw ImageReadException(filename, "imageio read data failed");
00114                                 }
00115                                 else {
00116                                         update();
00117                                 }
00118                         }
00119                 }
00120         }
00121 
00122 #ifndef IMAGEIO_CACHE
00123         if( imageio )
00124         {
00125                 delete imageio;
00126                 imageio = 0;
00127         }
00128 #endif
00129         EXITFUNC;
00130 }

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 347 of file emdata_io.cpp.

References EMData(), ImageReadException, OutofRangeException, EMAN::Dict::size(), and v.

00349 {
00350         ENTERFUNC;
00351 
00352         int total_img = EMUtil::get_image_count(filename);
00353         size_t num_img = img_indices.size();
00354 
00355         for (size_t i = 0; i < num_img; i++) {
00356                 if (img_indices[i] < 0 && img_indices[i] >= total_img) {
00357                         throw OutofRangeException(0, total_img, img_indices[i], "image index");
00358                 }
00359         }
00360 
00361         size_t n = (num_img == 0 ? total_img : num_img);
00362 
00363         vector< shared_ptr<EMData> > v;
00364         for (size_t j = 0; j < n; j++) {
00365                 shared_ptr<EMData> d(new EMData());
00366                 size_t k = (num_img == 0 ? j : img_indices[j]);
00367                 try {
00368                         d->read_image(filename, (int)k, header_only);
00369                 }
00370                 catch(E2Exception &e) {
00371                         throw(e);
00372                 }
00373                 if ( d != 0 )
00374                 {
00375                         v.push_back(d);
00376                 }
00377                 else
00378                         throw ImageReadException(filename, "imageio read data failed");
00379         }
00380 
00381         EXITFUNC;
00382         return v;
00383 }

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 386 of file emdata_io.cpp.

References EMData(), InvalidValueException, OutofRangeException, and v.

00389 {
00390         ENTERFUNC;
00391 
00392         if (img_index_end < img_index_start) {
00393                 throw InvalidValueException(img_index_end, "image index end < image index start");
00394         }
00395         string new_filename = filename;
00396         new_filename = new_filename.insert(new_filename.rfind("."), ext);
00397         int num_img = EMUtil::get_image_count(new_filename);
00398 
00399         if (img_index_start < 0 || img_index_start >= num_img) {
00400                 throw OutofRangeException(0, num_img-1, img_index_start, "image index start");
00401         }
00402 
00403         if (img_index_end >= num_img) {
00404                 img_index_end = num_img - 1;
00405         }
00406 
00407         vector < shared_ptr<EMData> >v;
00408 
00409         for (int i = img_index_start; i < img_index_end; i++) {
00410                 shared_ptr<EMData> d(new EMData());
00411                 try {
00412                         d->read_image(new_filename, i, header_only);
00413                 }
00414                 catch(E2Exception &e) {
00415                         throw(e);
00416                 }
00417                 v.push_back(d);
00418         }
00419         EXITFUNC;
00420         return v;
00421 }

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 1059 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().

01060 {
01061         ENTERFUNC;
01062 
01063         EMData * e = new EMData();
01064 
01065         if( is_real() ) // a real image, return a copy of itself
01066         {
01067                 e = this->copy();
01068         }
01069         else //for a complex image
01070         {
01071                 if( !is_ri() )
01072                 {
01073                         delete e;
01074                         throw InvalidCallException("This image is in amplitude/phase format, this function call require a complex image in real/imaginary format.");
01075                 }
01076                 int nx = get_xsize();
01077                 int ny = get_ysize();
01078                 int nz = get_zsize();
01079                 e->set_size(nx/2, ny, nz);
01080                 float * edata = e->get_data();
01081                 float * data = get_data();
01082                 size_t idx1, idx2;
01083                 for( int i=0; i<nx; ++i )
01084                 {
01085                         for( int j=0; j<ny; ++j )
01086                         {
01087                                 for( int k=0; k<nz; ++k )
01088                                 {
01089                                         if( i%2 == 0 )
01090                                         {
01091                                                 //complex data in format [real, complex, real, complex...]
01092                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01093                                                 idx2 = i+j*nx+k*nx*ny;
01094                                                 edata[idx1] = data[idx2];
01095                                         }
01096                                 }
01097                         }
01098                 }
01099         }
01100 
01101         e->set_complex(false);
01102         if(e->get_ysize()==1 && e->get_zsize()==1) {
01103                 e->set_complex_x(false);
01104         }
01105         e->update();
01106         return e;
01107 
01108         EXITFUNC;
01109 }

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 1316 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().

01317 {
01318         ENTERFUNC;
01319 
01320         if( is_complex() ) {
01321                 throw InvalidCallException("This function call only apply to real image");
01322         }
01323 
01324         EMData * e = new EMData();
01325         int nx = get_xsize();
01326         int ny = get_ysize();
01327         int nz = get_zsize();
01328         e->set_size(nx*2, ny, nz);
01329 
01330         for( int k=0; k<nz; ++k ) {
01331                 for( int j=0; j<ny; ++j ) {
01332                         for( int i=0; i<nx; ++i ) {
01333                                 (*e)(i*2,j,k) = (*this)(i,j,k);
01334                                 (*e)(i*2+1,j,k) = img;
01335                         }
01336                 }
01337         }
01338 
01339         e->set_complex(true);
01340         if(e->get_ysize()==1 && e->get_zsize()==1) {
01341                 e->set_complex_x(true);
01342         }
01343         e->set_ri(true);
01344         e->update();
01345         return e;
01346 
01347         EXITFUNC;
01348 }

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

References br, data, get_data(), get_ndim(), ImageDimensionException, is_complex(), nx, nx, ny, ny, ri2ap(), t, x, and y.

00427 {
00428         ENTERFUNC;
00429 
00430         int asrgb;
00431         int hist=(flags&2)/2;
00432         int invy=(flags&4)?1:0;
00433 
00434         if (!is_complex()) throw ImageDimensionException("complex only");
00435 
00436         if (get_ndim() != 2) {
00437                 throw ImageDimensionException("2D only");
00438         }
00439 
00440         if (is_complex()) ri2ap();
00441 
00442         if (render_max <= render_min) {
00443                 render_max = render_min + 0.01f;
00444         }
00445 
00446         if (gamma<=0) gamma=1.0;
00447 
00448         // Calculating a full floating point gamma for
00449         // each pixel in the image slows rendering unacceptably
00450         // however, applying a gamma-mapping to an 8 bit colorspace
00451         // has unaccepable accuracy. So, we oversample the 8 bit colorspace
00452         // as a 12 bit colorspace and apply the gamma mapping to that
00453         // This should produce good accuracy for gamma values
00454         // larger than 0.5 (and a high upper limit)
00455         static int smg0=0,smg1=0;       // while this destroys threadsafety in the rendering process
00456         static float sgam=0;            // it is necessary for speed when rendering large numbers of small images
00457         static unsigned char gammamap[4096];
00458         if (gamma!=1.0 && (smg0!=mingray || smg1!=maxgray || sgam!=gamma)) {
00459                 for (int i=0; i<4096; i++) {
00460                         if (mingray<maxgray) gammamap[i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00461                         else gammamap[4095-i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00462                 }
00463         }
00464         smg0=mingray;   // so we don't recompute the map unless something changes
00465         smg1=maxgray;
00466         sgam=gamma;
00467 
00468         if (flags&8) asrgb=4;
00469         else if (flags&1) asrgb=3;
00470         else throw ImageDimensionException("must set flag 1 or 8");
00471 
00472         std::string ret=std::string();
00473 //      ret.resize(iysize*bpl);
00474         ret.assign(iysize*bpl+hist*1024,char(mingray));
00475         unsigned char *data=(unsigned char *)ret.data();
00476         unsigned int *histd=(unsigned int *)(data+iysize*bpl);
00477         if (hist) {
00478                 for (int i=0; i<256; i++) histd[i]=0;
00479         }
00480 
00481         float rm = render_min;
00482         float inv_scale = 1.0f / scale;
00483         int ysize = iysize;
00484         int xsize = ixsize;
00485 
00486         int ymin = 0;
00487         if (iysize * inv_scale > ny) {
00488                 ymin = (int) (iysize - ny / inv_scale);
00489         }
00490 
00491         float gs = (maxgray - mingray) / (render_max - render_min);
00492         float gs2 = 4095.999f / (render_max - render_min);
00493 //      float gs2 = 1.0 / (render_max - render_min);
00494         if (render_max < render_min) {
00495                 gs = 0;
00496                 rm = FLT_MAX;
00497         }
00498 
00499         int dsx = -1;
00500         int dsy = 0;
00501         int remx = 0;
00502         int remy = 0;
00503         const int scale_n = 100000;
00504 
00505         int addi = 0;
00506         int addr = 0;
00507         if (inv_scale == floor(inv_scale)) {
00508                 dsx = (int) inv_scale;
00509                 dsy = (int) (inv_scale * nx);
00510         }
00511         else {
00512                 addi = (int) floor(inv_scale);
00513                 addr = (int) (scale_n * (inv_scale - floor(inv_scale)));
00514         }
00515 
00516         int xmin = 0;
00517         if (x0 < 0) {
00518                 xmin = (int) (-x0 / inv_scale);
00519                 xsize -= (int) floor(x0 / inv_scale);
00520                 x0 = 0;
00521         }
00522 
00523         if ((xsize - xmin) * inv_scale > (nx - x0)) {
00524                 xsize = (int) ((nx - x0) / inv_scale + xmin);
00525         }
00526         int ymax = ysize - 1;
00527         if (y0 < 0) {
00528                 ymax = (int) (ysize + y0 / inv_scale - 1);
00529                 ymin += (int) floor(y0 / inv_scale);
00530                 y0 = 0;
00531         }
00532 
00533         if (xmin < 0) xmin = 0;
00534         if (ymin < 0) ymin = 0;
00535         if (xsize > ixsize) xsize = ixsize;
00536         if (ymax > iysize) ymax = iysize;
00537 
00538         int lmax = nx * ny - 1;
00539 
00540         int mid=nx*ny/2;
00541         float* image_data = get_data();
00542         if (dsx != -1) {
00543                 int l = y0 * nx;
00544                 for (int j = ymax; j >= ymin; j--) {
00545                         int ll = x0;
00546                         for (int i = xmin; i < xsize; i++) {
00547                                 if (l + ll > lmax || ll >= nx - 2) break;
00548 
00549                                 int k = 0;
00550                                 unsigned char p;
00551                                 int ph;
00552                                 if (ll >= nx / 2) {
00553                                         if (l >= (ny - inv_scale) * nx) k = 2 * (ll - nx / 2) + 2;
00554                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
00555                                         ph = (int)(image_data[k+1]*768/(2.0*M_PI))+384; // complex phase as integer 0-767
00556                                 }
00557                                 else {
00558                                         k = nx * ny - (l + 2 * ll) - 2;
00559                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00560                                 }
00561                                 if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00562                                 else k+=mid;
00563                                 float t = image_data[k];
00564                                 if (t <= rm)  p = mingray;
00565                                 else if (t >= render_max) p = maxgray;
00566                                 else if (gamma!=1.0) {
00567                                         k=(int)(gs2 * (t-render_min));          // map float value to 0-4096 range
00568                                         p = gammamap[k];                                        // apply gamma using precomputed gamma map
00569                                 }
00570                                 else {
00571                                         p = (unsigned char) (gs * (t - render_min));
00572                                         p += mingray;
00573                                 }
00574                                 if (ph<256) {
00575                                         data[i * asrgb + j * bpl] = p*(255-ph)/256;
00576                                         data[i * asrgb + j * bpl+1] = p*ph/256;
00577                                         data[i * asrgb + j * bpl+2] = 0;
00578                                 }
00579                                 else if (ph<512) {
00580                                         data[i * asrgb + j * bpl+1] = p*(511-ph)/256;
00581                                         data[i * asrgb + j * bpl+2] = p*(ph-256)/256;
00582                                         data[i * asrgb + j * bpl] = 0;
00583                                 }
00584                                 else {
00585                                         data[i * asrgb + j * bpl+2] = p*(767-ph)/256;
00586                                         data[i * asrgb + j * bpl] = p*(ph-512)/256;
00587                                         data[i * asrgb + j * bpl+1] = 0;
00588                                 }
00589                                 if (hist) histd[p]++;
00590                                 ll += dsx;
00591                         }
00592                         l += dsy;
00593                 }
00594         }
00595         else {
00596                 remy = 10;
00597                 int l = y0 * nx;
00598                 for (int j = ymax; j >= ymin; j--) {
00599                         int br = l;
00600                         remx = 10;
00601                         int ll = x0;
00602                         for (int i = xmin; i < xsize - 1; i++) {
00603                                 if (l + ll > lmax || ll >= nx - 2) {
00604                                         break;
00605                                 }
00606                                 int k = 0;
00607                                 unsigned char p;
00608                                 int ph;
00609                                 if (ll >= nx / 2) {
00610                                         if (l >= (ny * nx - nx)) k = 2 * (ll - nx / 2) + 2;
00611                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
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                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00617                                 }
00618                                 if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00619                                 else k+=mid;
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 7365 of file emdata_sparx.cpp.

References copy(), depad(), do_fft_inplace(), do_ift_inplace(), fint, fout, get_data(), get_xsize(), get_ysize(), get_zsize(), is_complex(), is_fftodd(), norm_pad(), nx, ny, nz, set_array_offsets(), set_attr(), set_fftodd(), set_fftpad(), set_ri(), sqrt(), and update().

07365                                                               {
07366 
07367 
07368         bool   complex_input = this->is_complex();
07369         nx  = this->get_xsize();
07370         ny  = this->get_ysize();
07371         nz  = this->get_zsize();
07372         int nox;
07373         if (complex_input) nox = (nx - 2 + this->is_fftodd()); else nox = nx;
07374 
07375         EMData* fp = NULL; // output image
07376         if(complex_input) {
07377                 // fimage must remain pristine
07378                 fp = this->copy();
07379         } else {
07380                 fp = this->norm_pad( false, 1);
07381                 fp->do_fft_inplace();
07382         }
07383         float *fout = fp->get_data();
07384         float *fint = image->get_data();
07385         for ( int iz = 0; iz < nz; iz++) {
07386                 for ( int iy = 0; iy < ny; iy++) {
07387                         for ( int ix = 0; ix < nx; ix+=2) {
07388                                 float qt = fint(ix,iy,iz)*fint(ix,iy,iz)+fint(ix+1,iy,iz)*fint(ix+1,iy,iz);
07389                                 float rt = fout(ix,iy,iz)*fout(ix,iy,iz)+fout(ix+1,iy,iz)*fout(ix+1,iy,iz);
07390                                 if(rt > 1.0e-20) {
07391                                                 fout(ix,iy,iz) *= (qt/rt);
07392                                                 fout(ix+1,iy,iz) *= (qt/rt);
07393                                 } else {
07394                                                 qt = std::sqrt(qt/2.0f);
07395                                                 fout(ix,iy,iz) = qt;
07396                                                 fout(ix+1,iy,iz) = qt;
07397                                 }
07398                         }
07399                 }
07400         }
07401 
07402         fp->set_ri(1);
07403         fp->set_fftpad(true);
07404         fp->set_attr("npad", 1);
07405         if (nx%2 == 1) fp->set_fftodd(true);
07406         else fp->set_fftodd(false);
07407         if(RetReal) {
07408                 fp->do_ift_inplace();
07409                 fp->depad();
07410         }
07411         fp->set_array_offsets(0,0,0);
07412         fp->update();
07413 
07414         return fp;
07415 }

float EMAN::EMData::restrict1 float  x,
int  nx
[inline, static]
 

Definition at line 2809 of file emdata.h.

Referenced by rot_scale_conv(), rot_scale_conv7(), and rot_scale_trans().

float EMAN::EMData::restrict2 float  x,
int  nx
[inline, static]
 

Definition at line 2818 of file emdata.h.

Referenced by get_pixel_conv(), 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(), and rot_scale_trans_background().

void EMData::ri2ap  ) 
 

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

Definition at line 1012 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(), render_amp24(), and render_ap24().

01013 {
01014         ENTERFUNC;
01015 
01016         if (!is_complex() || !is_ri()) {
01017                 return;
01018         }
01019 //#ifdef EMAN2_USING_CUDA
01020 //      if (gpu_operation_preferred()) {
01021 //              EMDataForCuda tmp = get_data_struct_for_cuda();
01022 //              emdata_ri2ap(&tmp);
01023 //              set_ri(false);
01024 //              gpu_update();
01025 //              EXITFUNC;
01026 //              return;
01027 //      }
01028 //#endif
01029 
01030         float * data = get_data();
01031 
01032         size_t size = (size_t)nx * ny * nz;
01033         for (size_t i = 0; i < size; i += 2) {
01034 #ifdef  _WIN32
01035                 float f = (float)_hypot(data[i], data[i + 1]);
01036 #else
01037                 float f = (float)hypot(data[i], data[i + 1]);
01038 #endif
01039                 if (data[i] == 0 && data[i + 1] == 0) {
01040                         data[i + 1] = 0;
01041                 }
01042                 else {
01043                         data[i + 1] = atan2(data[i + 1], data[i]);
01044                 }
01045                 data[i] = f;
01046         }
01047 
01048         set_ri(false);
01049         update();
01050         EXITFUNC;
01051 }

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 981 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().

00982 {
00983         ENTERFUNC;
00984 
00985         if (!is_complex()) return;
00986         if (!is_ri()) ap2ri();
00987 
00988 //#ifdef EMAN2_USING_CUDA
00989 //      if (gpu_operation_preferred()) {
00990 //              EMDataForCuda tmp = get_data_struct_for_cuda();
00991 //              emdata_ri2inten(&tmp);
00992 //              set_attr("is_intensity", int(1));
00993 //              gpu_update();
00994 //              EXITFUNC;
00995 //              return;
00996 //      }
00997 //#endif
00998 
00999         float * data = get_data();
01000         size_t size = (size_t)nx * ny * nz;
01001         for (size_t i = 0; i < size; i += 2) {
01002                 data[i]=data[i]*data[i]+data[i+1]*data[i+1];
01003                 data[i+1]=0;
01004         }
01005 
01006         set_attr("is_intensity", int(1));
01007         update();
01008         EXITFUNC;
01009 }

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 3016 of file emdata_sparx.cpp.

References copy_head(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, nx, ny, nz, q, restrict1(), restrict2(), scale(), set_array_offsets(), set_size(), t, x, and y.

03016                                                                                                          {
03017         int nxn, nyn, nzn;
03018         if(scale_input == 0.0f) scale_input = 1.0f;
03019         //const float scale=0.5;
03020         float  scale = 0.5f*scale_input;
03021         float  sum, w;
03022         if (1 >= ny)
03023                 throw ImageDimensionException("Can't rotate 1D image");
03024         if (1 < nz)
03025                 throw ImageDimensionException("Volume not currently supported");
03026         nxn=nx/2;nyn=ny/2;nzn=nz/2;
03027 
03028         int K = kb.get_window_size();
03029         int kbmin = -K/2;
03030         int kbmax = -kbmin;
03031         int kbc = kbmax+1;
03032         vector<int> saved_offsets = get_array_offsets();
03033         set_array_offsets(0,0,0);
03034         EMData* ret = this->copy_head();
03035 #ifdef _WIN32
03036         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03037 #else
03038         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03039 #endif  //_WIN32
03040         //ret->to_zero();  //we will leave margins zeroed.
03041         delx = restrict2(delx, nx);
03042         dely = restrict2(dely, ny);
03043         // center of big image,
03044         int xc = nxn;
03045         int ixs = nxn%2;  // extra shift on account of odd-sized images
03046         int yc = nyn;
03047         int iys = nyn%2;
03048         // center of small image
03049         int xcn = nxn/2;
03050         int ycn = nyn/2;
03051         // shifted center for rotation
03052         float shiftxc = xcn + delx;
03053         float shiftyc = ycn + dely;
03054         // bounds if origin at center
03055         float ymin = -ny/2.0f;
03056         float xmin = -nx/2.0f;
03057         float ymax = -ymin;
03058         float xmax = -xmin;
03059         if (0 == nx%2) xmax--;
03060         if (0 == ny%2) ymax--;
03061 
03062         float   *t = (float*)calloc(kbmax-kbmin+1, sizeof(float));
03063 
03064         // trig
03065         float cang = cos(ang);
03066         float sang = sin(ang);
03067         for (int iy = 0; iy < nyn; iy++) {
03068                 float y = float(iy) - shiftyc;
03069                 float ycang = y*cang/scale + yc;
03070                 float ysang = -y*sang/scale + xc;
03071                 for (int ix = 0; ix < nxn; ix++) {
03072                         float x = float(ix) - shiftxc;
03073                         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
03074                         float yold = x*sang/scale + ycang-iys;
03075 
03076                         xold = restrict1(xold, nx);
03077                         yold = restrict1(yold, ny);
03078 
03079                         int inxold = int(Util::round(xold)); int inyold = int(Util::round(yold));
03080                         sum=0.0f;    w=0.0f;
03081                         for (int m1 =kbmin; m1 <=kbmax; m1++) t[m1-kbmin] = kb.i0win_tab(xold - inxold-m1);
03082                         if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03083                                 for (int m2 =kbmin; m2 <=kbmax; m2++) {
03084                                         float qt = kb.i0win_tab(yold - inyold-m2);
03085                                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03086                                                 float q = t[m1-kbmin]*qt;
03087                                                 sum += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q; w+=q;
03088                                         }
03089                                 }
03090                         } else {
03091                                 for (int m2 =kbmin; m2 <=kbmax; m2++) {
03092                                         float qt = kb.i0win_tab(yold - inyold-m2);
03093                                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03094                                                 float q = t[m1-kbmin]*qt;
03095                                                 sum += (*this)(inxold+m1,inyold+m2)*q; w+=q;}
03096                                         }
03097                         }
03098                         (*ret)(ix,iy)=sum/w;
03099                 }
03100         }
03101         if (t) free(t);
03102         set_array_offsets(saved_offsets);
03103         return ret;
03104 }

EMData * EMData::rot_scale_conv7 float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale_input
 

Definition at line 3108 of file emdata_sparx.cpp.

References copy_head(), get_array_offsets(), EMAN::Util::KaiserBessel::get_window_size(), EMAN::Util::KaiserBessel::i0win_tab(), ImageDimensionException, nx, ny, nz, restrict1(), restrict2(), scale(), set_array_offsets(), set_size(), t, x, and y.

Referenced by EMAN::Util::ccc_images_G(), and EMAN::Util::twoD_fine_ali_G().

03108                                                                                                           {
03109         int nxn, nyn, nzn;
03110         float  scale = 0.5f*scale_input;
03111         float  sum, w;
03112         if (1 >= ny)
03113                 throw ImageDimensionException("Can't rotate 1D image");
03114         if (1 < nz)
03115                 throw ImageDimensionException("Volume not currently supported");
03116         nxn = nx/2; nyn=ny/2; nzn=nz/2;
03117 
03118         int K = kb.get_window_size();
03119         int kbmin = -K/2;
03120         int kbmax = -kbmin;
03121         int kbc = kbmax+1;
03122         vector<int> saved_offsets = get_array_offsets();
03123         set_array_offsets(0,0,0);
03124         EMData* ret = this->copy_head();
03125 #ifdef _WIN32
03126         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03127 #else
03128         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03129 #endif  //_WIN32
03130         //ret->to_zero();  //we will leave margins zeroed.
03131         delx = restrict2(delx, nx);
03132         dely = restrict2(dely, ny);
03133         // center of big image,
03134         int xc = nxn;
03135         int ixs = nxn%2;  // extra shift on account of odd-sized images
03136         int yc = nyn;
03137         int iys = nyn%2;
03138         // center of small image
03139         int xcn = nxn/2;
03140         int ycn = nyn/2;
03141         // shifted center for rotation
03142         float shiftxc = xcn + delx;
03143         float shiftyc = ycn + dely;
03144         // bounds if origin at center
03145         float ymin = -ny/2.0f;
03146         float xmin = -nx/2.0f;
03147         float ymax = -ymin;
03148         float xmax = -xmin;
03149         if (0 == nx%2) xmax--;
03150         if (0 == ny%2) ymax--;
03151 
03152         float   *t = (float*)calloc(kbmax-kbmin+1, sizeof(float));
03153 
03154         // trig
03155         float cang = cos(ang);
03156         float sang = sin(ang);
03157         for (int iy = 0; iy < nyn; iy++) {
03158                 float y = float(iy) - shiftyc;
03159                 float ycang = y*cang/scale + yc;
03160                 float ysang = -y*sang/scale + xc;
03161                 for (int ix = 0; ix < nxn; ix++) {
03162                         float x = float(ix) - shiftxc;
03163                         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
03164                         float yold = x*sang/scale + ycang-iys;
03165 
03166                         xold = restrict1(xold, nx);
03167                         yold = restrict1(yold, ny);
03168 
03169                         int inxold = int(Util::round(xold)); int inyold = int(Util::round(yold));
03170                         sum=0.0f;    w=0.0f;
03171 
03172                         float tablex1 = kb.i0win_tab(xold-inxold+3);
03173                         float tablex2 = kb.i0win_tab(xold-inxold+2);
03174                         float tablex3 = kb.i0win_tab(xold-inxold+1);
03175                         float tablex4 = kb.i0win_tab(xold-inxold);
03176                         float tablex5 = kb.i0win_tab(xold-inxold-1);
03177                         float tablex6 = kb.i0win_tab(xold-inxold-2);
03178                         float tablex7 = kb.i0win_tab(xold-inxold-3);
03179 
03180                         float tabley1 = kb.i0win_tab(yold-inyold+3);
03181                         float tabley2 = kb.i0win_tab(yold-inyold+2);
03182                         float tabley3 = kb.i0win_tab(yold-inyold+1);
03183                         float tabley4 = kb.i0win_tab(yold-inyold);
03184                         float tabley5 = kb.i0win_tab(yold-inyold-1);
03185                         float tabley6 = kb.i0win_tab(yold-inyold-2);
03186                         float tabley7 = kb.i0win_tab(yold-inyold-3);
03187 
03188                         int x1, x2, x3, x4, x5, x6, x7, y1, y2, y3, y4, y5, y6, y7;
03189 
03190                         if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03191                                 x1 = (inxold-3+nx)%nx;
03192                                 x2 = (inxold-2+nx)%nx;
03193                                 x3 = (inxold-1+nx)%nx;
03194                                 x4 = (inxold  +nx)%nx;
03195                                 x5 = (inxold+1+nx)%nx;
03196                                 x6 = (inxold+2+nx)%nx;
03197                                 x7 = (inxold+3+nx)%nx;
03198 
03199                                 y1 = (inyold-3+ny)%ny;
03200                                 y2 = (inyold-2+ny)%ny;
03201                                 y3 = (inyold-1+ny)%ny;
03202                                 y4 = (inyold  +ny)%ny;
03203                                 y5 = (inyold+1+ny)%ny;
03204                                 y6 = (inyold+2+ny)%ny;
03205                                 y7 = (inyold+3+ny)%ny;
03206                         } else {
03207                                 x1 = inxold-3;
03208                                 x2 = inxold-2;
03209                                 x3 = inxold-1;
03210                                 x4 = inxold;
03211                                 x5 = inxold+1;
03212                                 x6 = inxold+2;
03213                                 x7 = inxold+3;
03214 
03215                                 y1 = inyold-3;
03216                                 y2 = inyold-2;
03217                                 y3 = inyold-1;
03218                                 y4 = inyold;
03219                                 y5 = inyold+1;
03220                                 y6 = inyold+2;
03221                                 y7 = inyold+3;
03222                         }
03223                         sum    =   ( (*this)(x1,y1)*tablex1 + (*this)(x2,y1)*tablex2 + (*this)(x3,y1)*tablex3 +
03224                                      (*this)(x4,y1)*tablex4 + (*this)(x5,y1)*tablex5 + (*this)(x6,y1)*tablex6 +
03225                                      (*this)(x7,y1)*tablex7 ) * tabley1 +
03226                                    ( (*this)(x1,y2)*tablex1 + (*this)(x2,y2)*tablex2 + (*this)(x3,y2)*tablex3 +
03227                                      (*this)(x4,y2)*tablex4 + (*this)(x5,y2)*tablex5 + (*this)(x6,y2)*tablex6 +
03228                                      (*this)(x7,y2)*tablex7 ) * tabley2 +
03229                                    ( (*this)(x1,y3)*tablex1 + (*this)(x2,y3)*tablex2 + (*this)(x3,y3)*tablex3 +
03230                                      (*this)(x4,y3)*tablex4 + (*this)(x5,y3)*tablex5 + (*this)(x6,y3)*tablex6 +
03231                                      (*this)(x7,y3)*tablex7 ) * tabley3 +
03232                                    ( (*this)(x1,y4)*tablex1 + (*this)(x2,y4)*tablex2 + (*this)(x3,y4)*tablex3 +
03233                                      (*this)(x4,y4)*tablex4 + (*this)(x5,y4)*tablex5 + (*this)(x6,y4)*tablex6 +
03234                                      (*this)(x7,y4)*tablex7 ) * tabley4 +
03235                                    ( (*this)(x1,y5)*tablex1 + (*this)(x2,y5)*tablex2 + (*this)(x3,y5)*tablex3 +
03236                                      (*this)(x4,y5)*tablex4 + (*this)(x5,y5)*tablex5 + (*this)(x6,y5)*tablex6 +
03237                                      (*this)(x7,y5)*tablex7 ) * tabley5 +
03238                                    ( (*this)(x1,y6)*tablex1 + (*this)(x2,y6)*tablex2 + (*this)(x3,y6)*tablex3 +
03239                                      (*this)(x4,y6)*tablex4 + (*this)(x5,y6)*tablex5 + (*this)(x6,y6)*tablex6 +
03240                                      (*this)(x7,y6)*tablex7 ) * tabley6 +
03241                                    ( (*this)(x1,y7)*tablex1 + (*this)(x2,y7)*tablex2 + (*this)(x3,y7)*tablex3 +
03242                                      (*this)(x4,y7)*tablex4 + (*this)(x5,y7)*tablex5 + (*this)(x6,y7)*tablex6 +
03243                                      (*this)(x7,y7)*tablex7 ) * tabley7;
03244 
03245                         w = (tablex1+tablex2+tablex3+tablex4+tablex5+tablex6+tablex7) *
03246                             (tabley1+tabley2+tabley3+tabley4+tabley5+tabley6+tabley7);
03247 
03248                         (*ret)(ix,iy)=sum/w;
03249                 }
03250         }
03251         if (t) free(t);
03252         set_array_offsets(saved_offsets);
03253         return ret;
03254 }

EMData * EMData::rot_scale_conv_new float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale = 1.0
 

Definition at line 3288 of file emdata_sparx.cpp.

References copy_head(), data, get_array_offsets(), get_data(), get_pixel_conv_new(), ImageDimensionException, nx, ny, nz, restrict2(), scale(), set_array_offsets(), set_size(), x, and y.

03288                                                                                                              {
03289 
03290         if (scale_input == 0.0f) scale_input = 1.0f;
03291         float  scale = 0.5f*scale_input;
03292 
03293         if (1 >= ny)
03294                 throw ImageDimensionException("Can't rotate 1D image");
03295         if (1 < nz)
03296                 throw ImageDimensionException("Use rot_scale_conv_new_3D for volumes");
03297         int nxn = nx/2; int nyn = ny/2; int nzn = nz/2;
03298 
03299         vector<int> saved_offsets = get_array_offsets();
03300         set_array_offsets(0,0,0);
03301         EMData* ret = this->copy_head();
03302 #ifdef _WIN32
03303         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03304 #else
03305         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03306 #endif  //_WIN32
03307         //ret->to_zero();  //we will leave margins zeroed.
03308         delx = restrict2(delx, nx);
03309         dely = restrict2(dely, ny);
03310         // center of big image,
03311         int xc = nxn;
03312         int ixs = nxn%2;  // extra shift on account of odd-sized images
03313         int yc = nyn;
03314         int iys = nyn%2;
03315         // center of small image
03316         int xcn = nxn/2;
03317         int ycn = nyn/2;
03318         // shifted center for rotation
03319         float shiftxc = xcn + delx;
03320         float shiftyc = ycn + dely;
03321         // bounds if origin at center
03322         float ymin = -ny/2.0f;
03323         float xmin = -nx/2.0f;
03324         float ymax = -ymin;
03325         float xmax = -xmin;
03326         if (0 == nx%2) xmax--;
03327         if (0 == ny%2) ymax--;
03328 
03329         float* data = this->get_data();
03330 
03331         float cang = cos(ang);
03332         float sang = sin(ang);
03333         for (int iy = 0; iy < nyn; iy++) {
03334                 float y = float(iy) - shiftyc;
03335                 float ycang = y*cang/scale + yc;
03336                 float ysang = -y*sang/scale + xc;
03337                 for (int ix = 0; ix < nxn; ix++) {
03338                         float x = float(ix) - shiftxc;
03339                         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
03340                         float yold = x*sang/scale + ycang-iys;
03341 
03342                         (*ret)(ix,iy) = Util::get_pixel_conv_new(nx, ny, 1, xold, yold, 1, data, kb);
03343                 }
03344         }
03345         set_array_offsets(saved_offsets);
03346         return ret;
03347 }

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 3349 of file emdata_sparx.cpp.

References copy_head(), data, get_array_offsets(), get_data(), get_pixel_conv_new(), ImageDimensionException, nx, ny, nz, phi, restrict2(), scale(), set_array_offsets(), set_size(), theta, x, and y.

03349                                                                                                                                                                {
03350 
03351         if (scale_input == 0.0f) scale_input = 1.0f;
03352         float  scale = 0.5f*scale_input;
03353 
03354         if (1 >= ny)
03355                 throw ImageDimensionException("Can't rotate 1D image");
03356         int nxn = nx/2; int nyn = ny/2; int nzn = nz/2;
03357 
03358         vector<int> saved_offsets = get_array_offsets();
03359         set_array_offsets(0,0,0);
03360         EMData* ret = this->copy_head();
03361 #ifdef _WIN32
03362         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03363 #else
03364         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03365 #endif  //_WIN32
03366         //ret->to_zero();  //we will leave margins zeroed.
03367         if(wrap){
03368                 delx = restrict2(delx, nx);
03369                 dely = restrict2(dely, ny);
03370                 delz = restrict2(delz, nz);
03371         }
03372         // center of big image,
03373         int xc = nxn;
03374         int ixs = nxn%2;  // extra shift on account of odd-sized images
03375         int yc = nyn;
03376         int iys = nyn%2;
03377         int zc = nzn;
03378         int izs = nzn%2;
03379         // center of small image
03380         int xcn = nxn/2;
03381         int ycn = nyn/2;
03382         int zcn = nzn/2;
03383         // shifted center for rotation
03384         float shiftxc = xcn + delx;
03385         float shiftyc = ycn + dely;
03386         float shiftzc = zcn + delz;
03387         // bounds if origin at center
03388         float zmin = -nz/2.0f;
03389         float ymin = -ny/2.0f;
03390         float xmin = -nx/2.0f;
03391         float zmax = -zmin;
03392         float ymax = -ymin;
03393         float xmax = -xmin;
03394         if (0 == nx%2) xmax--;
03395         if (0 == ny%2) ymax--;
03396         if (0 == nz%2) zmax--;
03397 
03398         float* data = this->get_data();
03399 
03400         float cf = cos(phi);   float sf = sin(phi);
03401         float ct = cos(theta); float st = sin(theta);
03402         float cp = cos(psi);   float sp = sin(psi);
03403         // rotation matrix (the transpose is used in the loop to get (xold,yold,zold)):
03404         float a11 =  cp*ct*cf-sp*sf; float a12 =  cp*ct*sf+sp*cf; float a13 = -cp*st;
03405         float a21 = -sp*ct*cf-cp*sf; float a22 = -sp*ct*sf+cp*cf; float a23 =  sp*st;
03406         float a31 =  st*cf;          float a32 =  st*sf;          float a33 =  ct;
03407         for (int iz = 0; iz < nzn; iz++) {
03408                 float z = (float(iz) - shiftzc)/scale;
03409                 float zco1 = a31*z+xc;
03410                 float zco2 = a32*z+yc;
03411                 float zco3 = a33*z+zc;
03412                 for (int iy = 0; iy < nyn; iy++) {
03413                         float y = (float(iy) - shiftyc)/scale;
03414                         float yco1 = zco1+a21*y;
03415                         float yco2 = zco2+a22*y;
03416                         float yco3 = zco3+a23*y;
03417                         for (int ix = 0; ix < nxn; ix++) {
03418                                 float x = (float(ix) - shiftxc)/scale;
03419                                 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
03420                                 float yold = yco2+a12*x-iys;
03421                                 float zold = yco3+a13*x-izs;
03422                                 if(!wrap && (xold<0.0 || xold>nx-1 || yold<0.0 || yold>ny-1 || zold<0.0 || zold>nz-1))
03423                                         (*ret)(ix,iy,iz) = 0.0;
03424                                 else
03425                                         (*ret)(ix,iy,iz) = Util::get_pixel_conv_new(nx, ny, nz, xold, yold, zold, data, kb);
03426                         }
03427                 }
03428         }
03429         set_array_offsets(saved_offsets);
03430         return ret;
03431 }

EMData * EMData::rot_scale_conv_new_background float  ang,
float  delx,
float  dely,
Util::KaiserBessel kb,
float  scale = 1.0
 

Definition at line 3433 of file emdata_sparx.cpp.

References copy_head(), data, get_array_offsets(), get_data(), get_pixel_conv_new_background(), ImageDimensionException, nx, ny, nz, restrict2(), scale(), set_array_offsets(), set_size(), x, and y.

03433                                                                                                                         {
03434 
03435         int nxn, nyn, nzn;
03436 
03437         if (scale_input == 0.0f) scale_input = 1.0f;
03438         float  scale = 0.5f*scale_input;
03439 
03440         if (1 >= ny)
03441                 throw ImageDimensionException("Can't rotate 1D image");
03442         if (1 < nz)
03443                 throw ImageDimensionException("Use rot_scale_conv_new_background_3D for volumes");
03444         nxn = nx/2; nyn = ny/2; nzn = nz/2;
03445 
03446         vector<int> saved_offsets = get_array_offsets();
03447         set_array_offsets(0,0,0);
03448         EMData* ret = this->copy_head();
03449 #ifdef _WIN32
03450         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03451 #else
03452         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03453 #endif  //_WIN32
03454         //ret->to_zero();  //we will leave margins zeroed.
03455         delx = restrict2(delx, nx);
03456         dely = restrict2(dely, ny);
03457         // center of big image,
03458         int xc = nxn;
03459         int ixs = nxn%2;  // extra shift on account of odd-sized images
03460         int yc = nyn;
03461         int iys = nyn%2;
03462         // center of small image
03463         int xcn = nxn/2;
03464         int ycn = nyn/2;
03465         // shifted center for rotation
03466         float shiftxc = xcn + delx;
03467         float shiftyc = ycn + dely;
03468         // bounds if origin at center
03469         float ymin = -ny/2.0f;
03470         float xmin = -nx/2.0f;
03471         float ymax = -ymin;
03472         float xmax = -xmin;
03473         if (0 == nx%2) xmax--;
03474         if (0 == ny%2) ymax--;
03475 
03476         float* data = this->get_data();
03477 
03478         // trig
03479         float cang = cos(ang);
03480         float sang = sin(ang);
03481         for (int iy = 0; iy < nyn; iy++) {
03482                 float y = float(iy) - shiftyc;
03483                 float ycang = y*cang/scale + yc;
03484                 float ysang = -y*sang/scale + xc;
03485                 for (int ix = 0; ix < nxn; ix++) {
03486                         float x = float(ix) - shiftxc;
03487                         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
03488                         float yold = x*sang/scale + ycang-iys;
03489 
03490                         (*ret)(ix,iy) = Util::get_pixel_conv_new_background(nx, ny, 1, xold, yold, 1, data, kb, ix, iy);
03491                 }
03492         }
03493         set_array_offsets(saved_offsets);
03494         return ret;
03495 }

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 3497 of file emdata_sparx.cpp.

References copy_head(), data, get_array_offsets(), get_data(), get_pixel_conv_new_background(), ImageDimensionException, nx, ny, nz, phi, restrict2(), scale(), set_array_offsets(), set_size(), theta, x, and y.

03497                                                                                                                                                                           {
03498 
03499         if (scale_input == 0.0f) scale_input = 1.0f;
03500         float  scale = 0.5f*scale_input;
03501 
03502         if (1 >= ny)
03503                 throw ImageDimensionException("Can't rotate 1D image");
03504         int nxn = nx/2; int nyn = ny/2; int nzn = nz/2;
03505 
03506         vector<int> saved_offsets = get_array_offsets();
03507         set_array_offsets(0,0,0);
03508         EMData* ret = this->copy_head();
03509 #ifdef _WIN32
03510         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03511 #else
03512         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03513 #endif  //_WIN32
03514         //ret->to_zero();  //we will leave margins zeroed.
03515         if (wrap){
03516                 delx = restrict2(delx, nx);
03517                 dely = restrict2(dely, ny);
03518                 delz = restrict2(delz, nz);
03519         }
03520         // center of big image,
03521         int xc = nxn;
03522         int ixs = nxn%2;  // extra shift on account of odd-sized images
03523         int yc = nyn;
03524         int iys = nyn%2;
03525         int zc = nzn;
03526         int izs = nzn%2;
03527         // center of small image
03528         int xcn = nxn/2;
03529         int ycn = nyn/2;
03530         int zcn = nzn/2;
03531         // shifted center for rotation
03532         float shiftxc = xcn + delx;
03533         float shiftyc = ycn + dely;
03534         float shiftzc = zcn + delz;
03535         // bounds if origin at center
03536         float zmin = -nz/2.0f;
03537         float ymin = -ny/2.0f;
03538         float xmin = -nx/2.0f;
03539         float zmax = -zmin;
03540         float ymax = -ymin;
03541         float xmax = -xmin;
03542         if (0 == nx%2) xmax--;
03543         if (0 == ny%2) ymax--;
03544         if (0 == nz%2) zmax--;
03545 
03546         float* data = this->get_data();
03547 
03548         float cf = cos(phi);   float sf = sin(phi);
03549         float ct = cos(theta); float st = sin(theta);
03550         float cp = cos(psi);   float sp = sin(psi);
03551         // rotation matrix (the transpose is used in the loop to get (xold,yold,zold)):
03552         float a11 =  cp*ct*cf-sp*sf; float a12 =  cp*ct*sf+sp*cf; float a13 = -cp*st;
03553         float a21 = -sp*ct*cf-cp*sf; float a22 = -sp*ct*sf+cp*cf; float a23 =  sp*st;
03554         float a31 =  st*cf;          float a32 =  st*sf;          float a33 =  ct;
03555         for (int iz = 0; iz < nzn; iz++) {
03556                 float z = (float(iz) - shiftzc)/scale;
03557                 float zco1 = a31*z+xc;
03558                 float zco2 = a32*z+yc;
03559                 float zco3 = a33*z+zc;
03560                 for (int iy = 0; iy < nyn; iy++) {
03561                         float y = (float(iy) - shiftyc)/scale;
03562                         float yco1 = zco1+a21*y;
03563                         float yco2 = zco2+a22*y;
03564                         float yco3 = zco3+a23*y;
03565                         for (int ix = 0; ix < nxn; ix++) {
03566                                 float x = (float(ix) - shiftxc)/scale;
03567                                 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
03568                                 float yold = yco2+a12*x-iys;
03569                                 float zold = yco3+a13*x-izs;
03570                                 if(!wrap && (xold<0.0 || xold>nx-1 || yold<0.0 || yold>ny-1 || zold<0.0 || zold>nz-1))
03571                                         (*ret)(ix,iy,iz) = 0.0;
03572                                 else
03573                                         (*ret)(ix,iy,iz) = Util::get_pixel_conv_new_background(nx, ny, nz, xold, yold, zold, data, kb, ix, iy);
03574                         }
03575                 }
03576         }
03577         set_array_offsets(saved_offsets);
03578         return ret;
03579 }

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 2512 of file emdata_sparx.cpp.

References EMAN::Vec3< Type >::at(), copy_head(), get_array_offsets(), get_data(), EMAN::Transform::get_trans(), ImageDimensionException, in, EMAN::Transform::inverse(), min, nx, nx, ny, ny, nz, restrict1(), restrict2(), set_array_offsets(), t, EMAN::Vec3f, x, and y.

Referenced by symvol().

02512                                            {
02513 
02514         EMData* ret = copy_head();
02515         float *in = this->get_data();
02516         vector<int> saved_offsets = get_array_offsets();
02517         set_array_offsets(0,0,0);
02518         Vec3f translations = RA.get_trans();
02519         Transform RAinv = RA.inverse();
02520 
02521         if (1 >= ny)  throw ImageDimensionException("Can't rotate 1D image");
02522         if (nz < 2) {
02523         float  p1, p2, p3, p4;
02524         float delx = translations.at(0);
02525         float dely = translations.at(1);
02526         delx = restrict2(delx, nx);
02527         dely = restrict2(dely, ny);
02528         int xc = nx/2;
02529         int yc = ny/2;
02530 //         shifted center for rotation
02531         float shiftxc = xc + delx;
02532         float shiftyc = yc + dely;
02533                 for (int iy = 0; iy < ny; iy++) {
02534                         float y = float(iy) - shiftyc;
02535                         float ysang = y*RAinv[0][1]+xc;
02536                         float ycang = y*RAinv[1][1]+yc;
02537                         for (int ix = 0; ix < nx; ix++) {
02538                                 float x = float(ix) - shiftxc;
02539                                 float xold = x*RAinv[0][0] + ysang;
02540                                 float yold = x*RAinv[1][0] + ycang;
02541 
02542                                 xold = restrict1(xold, nx);
02543                                 yold = restrict1(yold, ny);
02544 
02545                                 int xfloor = int(xold);
02546                                 int yfloor = int(yold);
02547                                 float t = xold-xfloor;
02548                                 float u = yold-yfloor;
02549                                 if(xfloor == nx -1 && yfloor == ny -1) {
02550 
02551                                     p1 =in[xfloor   + yfloor*ny];
02552                                         p2 =in[ yfloor*ny];
02553                                         p3 =in[0];
02554                                         p4 =in[xfloor];
02555                                 } else if(xfloor == nx - 1) {
02556 
02557                                         p1 =in[xfloor   + yfloor*ny];
02558                                         p2 =in[           yfloor*ny];
02559                                         p3 =in[          (yfloor+1)*ny];
02560                                         p4 =in[xfloor   + (yfloor+1)*ny];
02561                                 } else if(yfloor == ny - 1) {
02562 
02563                                         p1 =in[xfloor   + yfloor*ny];
02564                                         p2 =in[xfloor+1 + yfloor*ny];
02565                                         p3 =in[xfloor+1 ];
02566                                         p4 =in[xfloor   ];
02567                                 } else {
02568                                         p1 =in[xfloor   + yfloor*ny];
02569                                         p2 =in[xfloor+1 + yfloor*ny];
02570                                         p3 =in[xfloor+1 + (yfloor+1)*ny];
02571                                         p4 =in[xfloor   + (yfloor+1)*ny];
02572                                 }
02573                                 (*ret)(ix,iy) = p1 + u * ( p4 - p1) + t * ( p2 - p1 + u *(p3-p2-p4+p1));
02574                         } //ends x loop
02575                 } // ends y loop
02576                 set_array_offsets(saved_offsets);
02577                 return ret;
02578         } else {
02579 //               This begins the 3D version trilinear interpolation.
02580 
02581         float delx = translations.at(0);
02582         float dely = translations.at(1);
02583         float delz = translations.at(2);
02584         delx = restrict2(delx, nx);
02585         dely = restrict2(dely, ny);
02586         delz = restrict2(delz, nz);
02587         int xc = nx/2;
02588         int yc = ny/2;
02589         int zc = nz/2;
02590 //         shifted center for rotation
02591         float shiftxc = xc + delx;
02592         float shiftyc = yc + dely;
02593         float shiftzc = zc + delz;
02594 
02595                 for (int iz = 0; iz < nz; iz++) {
02596                         float z = float(iz) - shiftzc;
02597                         float xoldz = z*RAinv[0][2]+xc;
02598                         float yoldz = z*RAinv[1][2]+yc;
02599                         float zoldz = z*RAinv[2][2]+zc;
02600                         for (int iy = 0; iy < ny; iy++) {
02601                                 float y = float(iy) - shiftyc;
02602                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02603                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02604                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02605                                 for (int ix = 0; ix < nx; ix++) {
02606                                         float x = float(ix) - shiftxc;
02607                                         float xold = xoldzy + x*RAinv[0][0] ;
02608                                         float yold = yoldzy + x*RAinv[1][0] ;
02609                                         float zold = zoldzy + x*RAinv[2][0] ;
02610 
02611                                         xold = restrict1(xold, nx);
02612                                         yold = restrict1(yold, ny);
02613                                         zold = restrict1(zold, nz);
02614 
02615 
02616                                         int IOX = int(xold);
02617                                         int IOY = int(yold);
02618                                         int IOZ = int(zold);
02619 
02620                                         #ifdef _WIN32
02621                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
02622                                         #else
02623                                         int IOXp1 = std::min( nx-1 ,IOX+1);
02624                                         #endif  //_WIN32
02625 
02626                                         #ifdef _WIN32
02627                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
02628                                         #else
02629                                         int IOYp1 = std::min( ny-1 ,IOY+1);
02630                                         #endif  //_WIN32
02631 
02632                                         #ifdef _WIN32
02633                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
02634                                         #else
02635                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
02636                                         #endif  //_WIN32
02637 
02638                                         float dx = xold-IOX;
02639                                         float dy = yold-IOY;
02640                                         float dz = zold-IOZ;
02641 
02642                                         float a1 = in(IOX,IOY,IOZ);
02643                                         float a2 = in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZ);
02644                                         float a3 = in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZ);
02645                                         float a4 = in(IOX,IOY,IOZp1) - in(IOX,IOY,IOZ);
02646                                         float a5 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOYp1,IOZ) + in(IOXp1,IOYp1,IOZ);
02647                                         float a6 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZp1) + in(IOXp1,IOY,IOZp1);
02648                                         float a7 = in(IOX,IOY,IOZ) - in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZp1) + in(IOX,IOYp1,IOZp1);
02649                                         float a8 = in(IOXp1,IOY,IOZ) + in(IOX,IOYp1,IOZ)+ in(IOX,IOY,IOZp1)
02650                                                         - in(IOX,IOY,IOZ)- in(IOXp1,IOYp1,IOZ) - in(IOXp1,IOY,IOZp1)
02651                                                         - in(IOX,IOYp1,IOZp1) + in(IOXp1,IOYp1,IOZp1);
02652                                         (*ret)(ix,iy,iz) = a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
02653                                 } //ends x loop
02654                         } // ends y loop
02655                 } // ends z loop
02656 
02657                 set_array_offsets(saved_offsets);
02658                 return ret;
02659 
02660 /*     This entire section has to go somewhere for quadratic 3D interpolation PAP 12/29/07
02661 //               This begins the 3D version triquadratic interpolation.
02662 
02663         float delx = translations.at(0);
02664         float dely = translations.at(1);
02665         float delz = translations.at(2);
02666         if(delx >= 0.0f) { delx = fmod(delx, float(nx));} else {delx = -fmod(-delx, float(nx));}
02667         if(dely >= 0.0f) { dely = fmod(dely, float(ny));} else {dely = -fmod(-dely, float(ny));}
02668         if(dely >= 0.0f) { delz = fmod(delz, float(nz));} else {delz = -fmod(-delz, float(nz));}
02669         int xc = nx/2;
02670         int yc = ny/2;
02671         int zc = nz/2;
02672 //         shifted center for rotation
02673         float shiftxc = xc + delx;
02674         float shiftyc = yc + dely;
02675         float shiftzc = zc + delz;
02676 //                  set up array to use later
02677 //
02678                 int xArr[27];
02679                 int yArr[27];
02680                 int zArr[27];
02681                 float fdata[27];
02682 
02683                 for (int iL=0; iL<27 ; iL++){  // need this indexing array later
02684                         xArr[iL]  =  (int) (fmod((float)iL,3.0f) - 1.0f);
02685                         yArr[iL]  =  (int)( fmod( ((float) (iL/3) ),3.0f)- 1.0f);
02686                         zArr[iL]  = ((int) (iL/9)  ) -1;
02687 //                      printf("iL=%d, \t xArr=%d, \t yArr=%d, \t zArr=%d \n",iL, xArr[iL],yArr[iL],zArr[iL]);
02688                 }
02689 
02690 //              for (int iz = 0; iz < nz; iz++) {for (int iy = 0; iy < ny; iy++) {for (int ix = 0; ix < nx; ix++) {
02691 //                    (*ret)(ix,iy,iz) = 0;}}}   // initialize returned data
02692 
02693                 for (int iz = 0; iz < nz; iz++) {
02694                         float z = float(iz) - shiftzc;
02695                         float xoldz = z*RAinv[0][2]+xc;
02696                         float yoldz = z*RAinv[1][2]+yc;
02697                         float zoldz = z*RAinv[2][2]+zc;
02698                         for (int iy = 0; iy < ny; iy++) {
02699                                 float y = float(iy) - shiftyc;
02700                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02701                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02702                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02703                                 for (int ix = 0; ix < nx; ix++) {
02704                                         float x = float(ix) - shiftxc;
02705                                         float xold = xoldzy + x*RAinv[0][0] ;
02706                                         float yold = yoldzy + x*RAinv[1][0] ;
02707                                         float zold = zoldzy + x*RAinv[2][0] ;
02708 
02709 
02710                                 if (xold < 0.0f) xold = fmod((int(xold/float(nx))+1)*nx-xold, float(nx));
02711                                 else if (xold > (float) (nx-1) ) xold = fmod(xold, float(nx));
02712                                 if (yold < 0.0f) yold =fmod((int(yold/float(ny))+1)*ny-yold, float(ny));
02713                                 else if (yold > (float) (ny-1) ) yold = fmod(yold, float(ny));
02714                                 if (zold < 0.0f) zold =fmod((int(zold/float(nz))+1)*nz-zold, float(nz));
02715                                 else if (zold > (float) (nz-1) ) zold = fmod(zold, float(nz));
02716 
02717                                 //  what follows does not accelerate the code; moreover, I doubt it is correct PAP 12/29/07
02718                                 //while ( xold >= (float)(nx) )  xold -= nx;
02719                                 //while ( xold < 0.0f )         xold += nx;
02720                                 //while ( yold >= (float)(ny) )  yold -= ny;
02721                                 //while ( yold < 0.0f )         yold += ny;
02722                                 //while ( zold >= (float)(nz) )  zold -= nz;
02723                                 //while ( zold < 0.0f )         zold += nz;
02724 
02725 //         This is currently coded the way  SPIDER coded it,
02726 //            changing floor to round  in the next 3 lines below may be better
02727 //                                      int IOX = (int) floor(xold); // This is the center of the array
02728 //                                      int IOY = (int) floor(yold ); // In the next loop we interpolate
02729 //                                      int IOZ = (int) floor(zold ); //  If floor is used dx is positive
02730                                         int IOX = int(xold);
02731                                         int IOY = int(yold);
02732                                         int IOZ = int(zold);
02733 
02734                                         float dx = xold-IOX; //remainder(xold,1);  //  now |dx| <= .5
02735                                         float dy = yold-IOY; //remainder(yold,1);
02736                                         float dz = zold-IOZ; //remainder(zold,1);
02737 
02738 //                                      printf(" IOX=%d \t IOY=%d \t IOZ=%d \n", IOX, IOY, IOZ);
02739 //                                      if (IOX>=0 && IOX<nx  && IOY>=0 && IOY < ny && IOZ >= 0 && IOZ < nz ) {
02740 //                                              ROTATED POSITION IS INSIDE OF VOLUME
02741 //                                              FIND INTENSITIES ON 3x3x3 COORDINATE GRID;
02742 //                                     Solution is wrapped
02743                                                 for  (int iL=0; iL<27 ; iL++){
02744                                                         int xCoor = (int) fmod(IOX+xArr[iL] + nx + .0001f, (float) nx);
02745                                                         int yCoor = (int) fmod(IOY+yArr[iL] + ny + .0001f, (float) ny);
02746                                                         int zCoor = (int) fmod(IOZ+zArr[iL] + nz + .0001f, (float) nz);
02747                                                         fdata[iL] = (*this)( xCoor, yCoor ,zCoor );
02748 //                                                      if (iy==iz && iz==0){printf(" fdata=%f \n", fdata[iL]);}
02749 //                                              }
02750                                         }
02751 
02752                                         (*ret)(ix,iy,iz) = Util::triquad(dx, dy, dz, fdata);
02753 //                                      (*ret)(ix,iy,iz) = Util:: trilinear_interpolate(fdata[13],fdata[14],fdata[16],
02754 //                                                                                      fdata[17],fdata[22],fdata[23],
02755 //                                                                                      fdata[25],fdata[26],dx, dy, dz);
02756 //      p1 iL=13,   xArr= 0,         yArr= 0,         zArr= 0
02757 //      p2 iL=14,   xArr= 1,         yArr= 0,         zArr= 0
02758 //      p3 iL=16,   xArr= 0,         yArr= 1,         zArr= 0
02759 //      p4 iL=17,   xArr= 1,         yArr= 1,         zArr= 0
02760 //      p5 iL=22,   xArr= 0,         yArr= 0,         zArr= 1
02761 //      p6 iL=23,   xArr= 1,         yArr= 0,         zArr= 1
02762 //      p7 iL=25,   xArr= 0,         yArr= 1,         zArr= 1
02763 //      p8 iL=26,   xArr= 1,         yArr= 1,         zArr= 1
02764 
02765 
02766 
02767                                 } //ends x loop
02768                         } // ends y loop
02769                 } // ends z loop
02770 
02771                 set_array_offsets(saved_offsets);
02772                 return ret;
02773 */
02774         }
02775 }

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 2430 of file emdata_sparx.cpp.

References copy_head(), get_array_offsets(), get_data(), ImageDimensionException, nx, nx, ny, ny, nz, quadri(), restrict2(), set_array_offsets(), x, and y.

Referenced by EMAN::Util::ccc_images(), main(), and EMAN::Util::twoD_fine_ali().

02430                                                                                    { // quadratic, no background, 2D
02431         float ang=angDeg*M_PI/180.0f;
02432         if (1 >= ny)
02433                 throw ImageDimensionException("Can't rotate 1D image");
02434         if (nz<2) {
02435                 vector<int> saved_offsets = get_array_offsets();
02436                 set_array_offsets(0,0,0);
02437                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02438                 EMData* ret = copy_head();
02439                 delx = restrict2(delx, nx);
02440                 dely = restrict2(dely, ny);
02441                 // center of image
02442                 int xc = nx/2;
02443                 int yc = ny/2;
02444                 // shifted center for rotation
02445                 float shiftxc = xc + delx;
02446                 float shiftyc = yc + dely;
02447                 // trig
02448                 float cang = cos(ang);
02449                 float sang = sin(ang);
02450                         for (int iy = 0; iy < ny; iy++) {
02451                                 float y = float(iy) - shiftyc;
02452                                 float ycang = y*cang/scale + yc;
02453                                 float ysang = -y*sang/scale + xc;
02454                                 for (int ix = 0; ix < nx; ix++) {
02455                                         float x = float(ix) - shiftxc;
02456                                         float xold = x*cang/scale + ysang ;
02457                                         float yold = x*sang/scale + ycang ;
02458                                         //  quadri is taking care of cyclic count
02459                                         (*ret)(ix,iy) = Util::quadri(xold+1.0f, yold+1.0f, nx, ny, get_data());
02460                                            //have to add one as quadri uses Fortran counting
02461                                 }
02462                         }
02463                 set_array_offsets(saved_offsets);
02464                 return ret;
02465         } else {
02466                 throw ImageDimensionException("Volume not currently supported");
02467         }
02468 }

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 2470 of file emdata_sparx.cpp.

References copy_head(), get_array_offsets(), get_data(), ImageDimensionException, nx, nx, ny, ny, nz, quadri_background(), restrict2(), set_array_offsets(), x, and y.

02470                                                                                               { // quadratic, no background, 2D
02471     float ang=angDeg*M_PI/180.0f;
02472         if (1 >= ny)
02473                 throw ImageDimensionException("Can't rotate 1D image");
02474         if (nz<2) {
02475                 vector<int> saved_offsets = get_array_offsets();
02476                 set_array_offsets(0,0,0);
02477                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02478                 EMData* ret = copy_head();
02479                 delx = restrict2(delx, nx);
02480                 dely = restrict2(dely, ny);
02481                 // center of image
02482                 int xc = nx/2;
02483                 int yc = ny/2;
02484                 // shifted center for rotation
02485                 float shiftxc = xc + delx;
02486                 float shiftyc = yc + dely;
02487                 // trig
02488                 float cang = cos(ang);
02489                 float sang = sin(ang);
02490                         for (int iy = 0; iy < ny; iy++) {
02491                                 float y = float(iy) - shiftyc;
02492                                 float ycang = y*cang/scale + yc;
02493                                 float ysang = -y*sang/scale + xc;
02494                                 for (int ix = 0; ix < nx; ix++) {
02495                                         float x = float(ix) - shiftxc;
02496                                         float xold = x*cang/scale + ysang ;
02497                                         float yold = x*sang/scale + ycang ;
02498                                         //  in quadri_background, wrap around is not done circulantly; if (xold,yold) is not in the image, then it's replaced by (ix,iy)
02499                                         (*ret)(ix,iy) = Util::quadri_background(xold+1.0f, yold+1.0f, nx, ny, get_data(),ix+1,iy+1);
02500                                            //have to add one as quadri uses Fortran counting
02501                                 }
02502                         }
02503                 set_array_offsets(saved_offsets);
02504                 return ret;
02505         } else {
02506                 throw ImageDimensionException("Volume not currently supported");
02507         }
02508 }

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 2781 of file emdata_sparx.cpp.

References EMAN::Vec3< Type >::at(), copy_head(), get_array_offsets(), get_data(), EMAN::Transform::get_trans(), ImageDimensionException, in, EMAN::Transform::inverse(), min, nx, nx, ny, ny, nz, restrict2(), set_array_offsets(), t, EMAN::Vec3f, x, and y.

02781                                                       {
02782         EMData* ret = copy_head();
02783         float *in = this->get_data();
02784         vector<int> saved_offsets = get_array_offsets();
02785         set_array_offsets(0,0,0);
02786         Vec3f translations = RA.get_trans();
02787         Transform RAinv = RA.inverse();
02788 
02789         if (1 >= ny)  throw ImageDimensionException("Can't rotate 1D image");
02790         if (nz < 2) {
02791         float  p1, p2, p3, p4;
02792         float delx = translations.at(0);
02793         float dely = translations.at(1);
02794         delx = restrict2(delx, nx);
02795         dely = restrict2(dely, ny);
02796         int xc = nx/2;
02797         int yc = ny/2;
02798 //         shifted center for rotation
02799         float shiftxc = xc + delx;
02800         float shiftyc = yc + dely;
02801                 for (int iy = 0; iy < ny; iy++) {
02802                         float y = float(iy) - shiftyc;
02803                         float ysang = y*RAinv[0][1]+xc;
02804                         float ycang = y*RAinv[1][1]+yc;
02805                         for (int ix = 0; ix < nx; ix++) {
02806                                 float x = float(ix) - shiftxc;
02807                                 float xold = x*RAinv[0][0] + ysang;
02808                                 float yold = x*RAinv[1][0] + ycang;
02809 
02810                                 // if (xold,yold) is outside the image, then let xold = ix and yold = iy
02811 
02812                 if ( (xold < 0.0f) || (xold >= (float)(nx)) || (yold < 0.0f) || (yold >= (float)(ny)) ){
02813                                     xold = (float)ix;
02814                                         yold = (float)iy;
02815                                 }
02816 
02817                                 int xfloor = int(xold);
02818                                 int yfloor = int(yold);
02819                                 float t = xold-xfloor;
02820                                 float u = yold-yfloor;
02821                                 if(xfloor == nx -1 && yfloor == ny -1) {
02822 
02823                                     p1 =in[xfloor   + yfloor*ny];
02824                                         p2 =in[ yfloor*ny];
02825                                         p3 =in[0];
02826                                         p4 =in[xfloor];
02827                                 } else if(xfloor == nx - 1) {
02828 
02829                                         p1 =in[xfloor   + yfloor*ny];
02830                                         p2 =in[           yfloor*ny];
02831                                         p3 =in[          (yfloor+1)*ny];
02832                                         p4 =in[xfloor   + (yfloor+1)*ny];
02833                                 } else if(yfloor == ny - 1) {
02834 
02835                                         p1 =in[xfloor   + yfloor*ny];
02836                                         p2 =in[xfloor+1 + yfloor*ny];
02837                                         p3 =in[xfloor+1 ];
02838                                         p4 =in[xfloor   ];
02839                                 } else {
02840 
02841                                         p1 =in[xfloor   + yfloor*ny];
02842                                         p2 =in[xfloor+1 + yfloor*ny];
02843                                         p3 =in[xfloor+1 + (yfloor+1)*ny];
02844                                         p4 =in[xfloor   + (yfloor+1)*ny];
02845                                 }
02846                                 (*ret)(ix,iy) = p1 + u * ( p4 - p1) + t * ( p2 - p1 + u *(p3-p2-p4+p1));
02847                         } //ends x loop
02848                 } // ends y loop
02849                 set_array_offsets(saved_offsets);
02850                 return ret;
02851         } else {
02852 //               This begins the 3D version trilinear interpolation.
02853 
02854         float delx = translations.at(0);
02855         float dely = translations.at(1);
02856         float delz = translations.at(2);
02857         delx = restrict2(delx, nx);
02858         dely = restrict2(dely, ny);
02859         delz = restrict2(delz, nz);
02860         int xc = nx/2;
02861         int yc = ny/2;
02862         int zc = nz/2;
02863 //         shifted center for rotation
02864         float shiftxc = xc + delx;
02865         float shiftyc = yc + dely;
02866         float shiftzc = zc + delz;
02867 
02868                 for (int iz = 0; iz < nz; iz++) {
02869                         float z = float(iz) - shiftzc;
02870                         float xoldz = z*RAinv[0][2]+xc;
02871                         float yoldz = z*RAinv[1][2]+yc;
02872                         float zoldz = z*RAinv[2][2]+zc;
02873                         for (int iy = 0; iy < ny; iy++) {
02874                                 float y = float(iy) - shiftyc;
02875                                 float xoldzy = xoldz + y*RAinv[0][1] ;
02876                                 float yoldzy = yoldz + y*RAinv[1][1] ;
02877                                 float zoldzy = zoldz + y*RAinv[2][1] ;
02878                                 for (int ix = 0; ix < nx; ix++) {
02879                                         float x = float(ix) - shiftxc;
02880                                         float xold = xoldzy + x*RAinv[0][0] ;
02881                                         float yold = yoldzy + x*RAinv[1][0] ;
02882                                         float zold = zoldzy + x*RAinv[2][0] ;
02883 
02884                                         // if (xold,yold,zold) is outside the image, then let xold = ix, yold = iy and zold=iz
02885 
02886                     if ( (xold < 0.0f) || (xold >= (float)(nx)) || (yold < 0.0f) || (yold >= (float)(ny))  || (zold < 0.0f) || (zold >= (float)(nz)) ){
02887                                          xold = (float)ix;
02888                                              yold = (float)iy;
02889                                                  zold = (float)iz;
02890                                         }
02891 
02892                                         int IOX = int(xold);
02893                                         int IOY = int(yold);
02894                                         int IOZ = int(zold);
02895 
02896                                         #ifdef _WIN32
02897                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
02898                                         #else
02899                                         int IOXp1 = std::min( nx-1 ,IOX+1);
02900                                         #endif  //_WIN32
02901 
02902                                         #ifdef _WIN32
02903                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
02904                                         #else
02905                                         int IOYp1 = std::min( ny-1 ,IOY+1);
02906                                         #endif  //_WIN32
02907 
02908                                         #ifdef _WIN32
02909                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
02910                                         #else
02911                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
02912                                         #endif  //_WIN32
02913 
02914                                         float dx = xold-IOX;
02915                                         float dy = yold-IOY;
02916                                         float dz = zold-IOZ;
02917 
02918                                         float a1 = in(IOX,IOY,IOZ);
02919                                         float a2 = in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZ);
02920                                         float a3 = in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZ);
02921                                         float a4 = in(IOX,IOY,IOZp1) - in(IOX,IOY,IOZ);
02922                                         float a5 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOYp1,IOZ) + in(IOXp1,IOYp1,IOZ);
02923                                         float a6 = in(IOX,IOY,IOZ) - in(IOXp1,IOY,IOZ) - in(IOX,IOY,IOZp1) + in(IOXp1,IOY,IOZp1);
02924                                         float a7 = in(IOX,IOY,IOZ) - in(IOX,IOYp1,IOZ) - in(IOX,IOY,IOZp1) + in(IOX,IOYp1,IOZp1);
02925                                         float a8 = in(IOXp1,IOY,IOZ) + in(IOX,IOYp1,IOZ)+ in(IOX,IOY,IOZp1)
02926                                                         - in(IOX,IOY,IOZ)- in(IOXp1,IOYp1,IOZ) - in(IOXp1,IOY,IOZp1)
02927                                                         - in(IOX,IOYp1,IOZp1) + in(IOXp1,IOYp1,IOZp1);
02928                                         (*ret)(ix,iy,iz) = a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
02929                                 } //ends x loop
02930                         } // ends y loop
02931                 } // ends z loop
02932 
02933                 set_array_offsets(saved_offsets);
02934                 return ret;
02935 
02936         }
02937 }

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 3419 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 972 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.

00974 {
00975         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00976 //      Transform3D t(Vec3f(dx, dy, dz), az, alt, phi, Vec3f(pdx,pdy,pdz));
00977 //      rotate_translate(t);
00978 
00979         Transform t;
00980         t.set_pre_trans(Vec3f(dx, dy, dz));
00981         t.set_rotation(Dict("type", "eman", "az", az, "alt", alt, "phi", phi));
00982         t.set_trans(pdx, pdy, pdz);
00983         rotate_translate(t);
00984 }

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

References phi, rotate_translate(), EMAN::Transform::set_rotation(), EMAN::Transform::set_trans(), and t.

00962 {
00963         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00964 //      Transform3D t( az, alt, phi,Vec3f(dx, dy, dz));
00965         Transform t;
00966         t.set_rotation(Dict("type", "eman", "az", az, "alt", alt, "phi", phi));
00967         t.set_trans(dx, dy, dz);
00968         rotate_translate(t);
00969 }

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

References data, get_data(), get_ndim(), ImageDimensionException, nx, update(), x, and y.

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

01176 {
01177         ENTERFUNC;
01178 
01179         if (get_ndim() > 2) {
01180                 throw ImageDimensionException("no 3D image");
01181         }
01182 
01183 
01184         size_t row_size = nx * sizeof(float);
01185         float *tmp = (float*)EMUtil::em_malloc(row_size);
01186         float * data = get_data();
01187 
01188         for (int y = 0; y < ny; y++) {
01189                 int y_nx = y * nx;
01190                 for (int x = 0; x < nx; x++) {
01191                         tmp[x] = data[y_nx + (x + dx) % nx];
01192                 }
01193                 EMUtil::em_memcpy(&data[y_nx], tmp, row_size);
01194         }
01195 
01196         update();
01197         if( tmp )
01198         {
01199                 delete[]tmp;
01200                 tmp = 0;
01201         }
01202         EXITFUNC;
01203 }

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

References attr_dict, and EMAN::ImageIO::is_image_big_endian().

Referenced by read_image().

04127 {
04128         string image_endian = "ImageEndian";
04129         string host_endian = "HostEndian";
04130 
04131         if (imageio->is_image_big_endian()) {
04132                 attr_dict[image_endian] = "big";
04133         }
04134         else {
04135                 attr_dict[image_endian] = "little";
04136         }
04137 
04138         if (ByteOrder::is_host_big_endian()) {
04139                 attr_dict[host_endian] = "big";
04140         }
04141         else {
04142                 attr_dict[host_endian] = "little";
04143         }
04144 }

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(), do_ift_inplace(), helicise_grid(), rot_scale_conv(), rot_scale_conv7(), rot_scale_conv_new(), rot_scale_conv_new_3D(), rot_scale_conv_new_background(), and rot_scale_conv_new_background_3D().

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 1271 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().

01272 {
01273         attr_dict["apix_x"] = ((float) attr_dict["apix_x"]) * scale;
01274         attr_dict["apix_y"] = ((float) attr_dict["apix_y"]) * scale;
01275         attr_dict["apix_z"] = ((float) attr_dict["apix_z"]) * scale;
01276         if (attr_dict.has_key("ctf")) {
01277                 Ctf *ctf=(Ctf *)attr_dict["ctf"];
01278                 ctf->apix*=scale;
01279                 attr_dict["ctf"]=ctf;
01280                 if(ctf) {delete ctf; ctf=0;}
01281         }
01282 }

void EMAN::EMData::set_array_offsets vector< int >  offsets  )  [inline]
 

Definition at line 2347 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 2341 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(), center_origin_fft(), EMAN::QuadMinDotCmp::cmp(), depad(), depad_corner(), divkbsinh(), divkbsinh_rect(), downsample(), EMAN::Processor::EMFourierFilterFunc(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), fft_shuffle(), filter_by_image(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), fouriergridrot2d(), fouriergridrot_shift2d(), EMAN::fourierproduct(), getconvpt2d_kbi0(), helicise_grid(), 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(), norm_pad(), EMAN::Util::pack_complex_to_real(), EMAN::periodogram(), replace_amplitudes(), 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(), EMAN::rsconvolution(), symplane0(), symplane0_ctf(), symplane0_rect(), 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 1209 of file emdata_metadata.cpp.

References attr_dict, key, LOGWARN, nx, ny, nz, and set_size().

Referenced by EMAN::TomoAverager::add_image(), ali3d_d(), EMAN::RT3DSymmetryAligner::align(), EMAN::RT3DSphereAligner::align(), EMAN::RT3DGridAligner::align(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::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::RotationalAligner::align_180_ambiguous(), 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(), EMAN::SetSFProcessor::create_radial_func(), depad(), depad_corner(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), filter_by_image(), EMAN::CtfAverager::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::MinMaxAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), FourInterpol(), FourTruncate(), frm_2d_Align(), EMAN::file_store::get_image(), main(), EMAN::TestUtil::make_image_file_by_mode(), norm_pad(), EMAN::padfft_slice(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), EMAN::NewFourierProcessor::preprocess(), EMAN::LowpassAutoBProcessor::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::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), replace_amplitudes(), ri2inten(), set_attr_dict(), wustl_mm::SkeletonMaker::VolumeData::SetOrigin(), wustl_mm::SkeletonMaker::VolumeData::SetSpacing(), EMAN::FourierReconstructor::setup(), and EMAN::FourierReconstructor::setup_seed().

01210 {
01211         if( key == "nx" && nx != (int)val) { set_size((int)val,ny,nz); return; }
01212         if( key == "ny" && ny != (int)val) { set_size(nx,(int)val,nz); return; }
01213         if( key == "nz" && nz != (int)val) { set_size(nx,ny,(int)val); return; }
01214 
01215         /* Ignore 'read only' attribute. */
01216         if(key == "sigma" ||
01217                 key == "sigma_nonzero" ||
01218                 key == "square_sum" ||
01219                 key == "maximum" ||
01220                 key == "minimum" ||
01221                 key == "mean" ||
01222                 key == "mean_nonzero" )
01223         {
01224                 LOGWARN("Ignore setting read only attribute %s", key.c_str());
01225                 return;
01226         }
01227 
01228         attr_dict[key] = val;
01229 
01230 
01231 
01232 }

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 1161 of file emdata_metadata.cpp.

References EMAN::Dict::end(), EMAN::Dict::has_key(), EMAN::Dict::keys(), nx, ny, nz, set_attr(), and set_size().

Referenced by ali3d_d().

01162 {
01163         /*set nx, ny nz may resize the image*/
01164         // This wasn't supposed to 'clip' the image, but just redefine the size --steve
01165         if( ( new_dict.has_key("nx") && nx!=(int)new_dict["nx"] )
01166                 || ( new_dict.has_key("ny") && ny!=(int)new_dict["ny"] )
01167                 || ( new_dict.has_key("nz") && nz!=(int)new_dict["nz"] ) ) {
01168 
01169                 int newx, newy, newz;
01170                 newx = new_dict.has_key("nx") ? (int)new_dict["nx"] : nx;
01171                 newy = new_dict.has_key("ny") ? (int)new_dict["ny"] : ny;
01172                 newz = new_dict.has_key("nz") ? (int)new_dict["nz"] : nz;
01173 
01174                 set_size(newx,newy,newz);
01175 
01176 //              EMData * new_image = get_clip(Region((nx-newx)/2, (ny-newy)/2, (nz=newz)/2, newx, newy, newz));
01177 //              if(new_image) {
01178 //                      this->operator=(*new_image);
01179 //                      delete new_image;
01180 //                      new_image = 0;
01181 //              }
01182         }
01183 
01184         vector<string> new_keys = new_dict.keys();
01185         vector<string>::const_iterator it;
01186         for(it = new_keys.begin(); it!=new_keys.end(); ++it) {
01187                 this->set_attr(*it, new_dict[*it]);
01188         }
01189 }

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 1191 of file emdata_metadata.cpp.

References attr_dict.

01192 {
01193         attr_dict = new_dict;
01194 }

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 1234 of file emdata_metadata.cpp.

References attr_dict, copy(), EMAN::EMObject::get_type(), key, LOGWARN, nx, ny, nz, set_size(), t, and v.

01235 {
01236         if( key == "nx" && nx != (int)val) { set_size((int)val,ny,nz); return; }
01237         if( key == "ny" && ny != (int)val) { set_size(nx,(int)val,nz); return; }
01238         if( key == "nz" && nz != (int)val) { set_size(nx,ny,(int)val); return; }
01239 
01240         /* Ignore 'read only' attribute. */
01241         if(key == "sigma" ||
01242                   key == "sigma_nonzero" ||
01243                   key == "square_sum" ||
01244                   key == "maximum" ||
01245                   key == "minimum" ||
01246                   key == "mean" ||
01247                   key == "mean_nonzero" )
01248         {
01249                 LOGWARN("Ignore setting read only attribute %s", key.c_str());
01250                 return;
01251         }
01252 
01253         EMObject::ObjectType argtype = val.get_type();
01254         if (argtype == EMObject::EMDATA) {
01255                 EMData* e = (EMData*) val;
01256                 e = e->copy();
01257                 EMObject v(e);
01258                 attr_dict[key] = v;
01259         }
01260         else if (argtype == EMObject::TRANSFORM) {
01261                 Transform* t = new Transform(*((Transform*) val));
01262                 EMObject v(t);
01263                 attr_dict[key] = v;
01264                 delete t; t=0;
01265         } else {
01266                 attr_dict[key] = val;
01267         }
01268 
01269 }

void EMAN::EMData::set_changecount int  c  )  [inline]
 

Definition at line 1238 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 729 of file emdata_core.cpp.

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

00730 {
00731         ENTERFUNC;
00732 
00733         if (get_ndim() != 2) {
00734                 throw ImageDimensionException("2D image only");
00735         }
00736         if (d->get_ndim() != 1) {
00737                 throw ImageDimensionException("1D image only");
00738         }
00739 
00740         float *dst = get_data();
00741         float *src = d->get_data();
00742 
00743         for (int i = 0; i < ny; i++) {
00744                 dst[i * nx + n] = src[i];
00745         }
00746 
00747         update();
00748         EXITFUNC;
00749 }

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 1030 of file emdata.h.

Referenced by absi(), 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(), depad(), depad_corner(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), FH2F(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), FourTruncate(), 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::ChaoProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), 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.

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 645 of file emdata.h.

00748                                           {

void EMAN::EMData::set_complex_x bool  is_complex_x  )  [inline]
 

Definition at line 1065 of file emdata.h.

Referenced by absi(), amplitude(), depad(), depad_corner(), 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,
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 353 of file emdata.h.

Referenced by wustl_mm::SkeletonMaker::VolumeData::Pad(), EMAN::TransformProcessor::process_inplace(), and EMAN::TransposeProcessor::process_inplace().

00355                                          {
00356                         ENTERFUNC;
00357                         process_inplace("math.rotate.180",Dict());
00358                         EXITFUNC;
00359                 }
00360 
00361 

void EMData::set_data_pickle std::string  vf  ) 
 

Definition at line 1298 of file emdata_metadata.cpp.

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

01299 {
01300 //      if (rdata) printf("rdata exists\n");
01301 //      rdata = (float *)malloc(nx*ny*nz*sizeof(float));
01302 //      std::copy(vf.begin(), vf.end(), rdata);
01303         EMUtil::em_memcpy(get_data(),vf.data(),nx*ny*nz*sizeof(float));
01304 
01305 }

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 1200 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(), depad(), depad_corner(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), EMAN::FFTResampleProcessor::fft_resample(), FH2F(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), FourTruncate(), frm_2d_Align(), EMAN::Util::madn_scalar(), EMAN::Util::muln_img(), EMAN::Util::mult_scalar(), norm_pad(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), read_image(), real2FH(), replace_amplitudes(), 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 1168 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(), depad(), depad_corner(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), FourInterpol(), FourTruncate(), norm_pad(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), read_image(), and replace_amplitudes().

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 1013 of file emdata.h.

Referenced by FH2F(), and real2FH().

void EMAN::EMData::set_flags int  f  )  [inline]
 

Definition at line 1228 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 1100 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 1214 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 653 of file emdata.h.

Referenced by calc_mutual_correlation(), and get_clip().

00748                                           {

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

Set the number of paths.

Parameters:
n The number of paths.

Definition at line 662 of file emdata.h.

Referenced by get_clip().

00748                                           {

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 1135 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(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), FH2F(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), FourTruncate(), 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_image(), real2complex(), real2FH(), replace_amplitudes(), 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 608 of file emdata.h.

00748                                           {

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 594 of file emdata.h.

Referenced by main().

00748                                           {

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 688 of file emdata_core.cpp.

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

00689 {
00690         ENTERFUNC;
00691 
00692         if (get_ndim() > 2) {
00693                 throw ImageDimensionException("1D/2D image only");
00694         }
00695         if (d->get_ndim() != 1) {
00696                 throw ImageDimensionException("1D image only");
00697         }
00698 
00699         float *dst = get_data();
00700         float *src = d->get_data();
00701         memcpy(dst + nx * row_index, src, nx * sizeof(float));
00702         update();
00703         EXITFUNC;
00704 }

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 995 of file emdata.h.

Referenced by extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), fft_shuffle(), FH2F(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), and EMAN::Util::TwoDTestFunc().

01002       : set ts=4 noet nospell: */
01003 set ts=4 noet nospell: */

void EMData::set_size int  nx,
int  ny = 1,
int  nz = 1
 

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::CtfAverager::add_image(), 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(), copy_head(), EMAN::Util::Crosrng_msg(), EMAN::Util::Crosrng_msg_m(), EMAN::Util::Crosrng_msg_s(), EMAN::Util::ctf_img(), EMAN::Util::decimate(), depad(), depad_corner(), do_fft(), do_fft_inplace(), do_ift(), do_radon(), EMAN::PCA::dopca_lan(), EMAN::PCA::dopca_ooc(), downsample(), EMData(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), FourTruncate(), 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(), helicise_grid(), 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(), norm_pad(), 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::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), 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(), 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(), rotavg(), rotavg_i(), EMAN::rsconvolution(), set_attr(), set_attr_dict(), set_attr_python(), 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 (rdata != 0) {
00857                 rdata = (float*)EMUtil::em_realloc(rdata,size);
00858         } else {
00859                 // Just pass on this for a while....see what happens
00860                 rdata = (float*)EMUtil::em_malloc(size);
00861         }
00862 //      rdata = static_cast < float *>(realloc(rdata, size));
00863         if ( rdata == 0 )
00864         {
00865                 stringstream ss;
00866                 string gigs;
00867                 ss << (float) size/1000000000.0;
00868                 ss >> gigs;
00869                 string message = "Cannot allocate " + gigs + " GB - not enough memory.";
00870                 throw BadAllocException(message);
00871         }
00872 
00873         nx = x;
00874         ny = y;
00875         nz = z;
00876         nxy = nx*ny;
00877         nxyz = (size_t)nx*ny*nz;
00878 
00879 // once the object is resized, the CUDA need to be updated
00880 #ifdef EMAN2_USING_CUDA
00881         if(cudarwdata) {
00882                 //cout << "rw free on set size" << endl;
00883                 rw_free();
00884                 rw_alloc();
00885         }
00886         if(cudarodata) {
00887                 ro_free();
00888                 ro_alloc();
00889         }
00890 #endif // EMAN2_USING_CUDA
00891 
00892         if (old_nx == 0) {
00893                 EMUtil::em_memset(get_data(),0,size);
00894         }
00895 
00896         if (supp) {
00897                 EMUtil::em_free(supp);
00898                 supp = 0;
00899         }
00900 
00901         update();
00902         EXITFUNC;
00903 }

void EMData::set_supp_pickle int  i  ) 
 

Definition at line 1312 of file emdata_metadata.cpp.

References supp.

01313 {
01314         this->supp = 0;
01315 }

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 563 of file emdata.h.

00748                                           {

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 551 of file emdata.h.

00748                                           {

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 cooridinate.
v The pixel density value at coordinate (x).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2257 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 cooridinate.
y The y cooridinate.
v The pixel density value at coordinates (x,y).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2216 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 cooridinate.
y The y cooridinate.
z The z cooridinate.
v The pixel density value at coordinates (x,y,z).
Exceptions:
OutofRangeException wehn index out of image data's range.

Definition at line 2158 of file emdata.h.

Referenced by EMAN::MinMaxAverager::add_image(), bispecRotTransInvDirect(), bispecRotTransInvN(), common_lines(), 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::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 cooridinate.
v The pixel density value at coordinate (x).

Definition at line 2277 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 cooridinate.
y The y cooridinate.
v The pixel density value at coordinates (x,y).

Definition at line 2242 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 cooridinate.
y The y cooridinate.
z The z cooridinate.
v The pixel density value at coordinates (x,y,z).

Definition at line 2190 of file emdata.h.

Referenced by EMAN::Rotate180Processor::process_inplace(), EMAN::WaveletProcessor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), and EMAN::TestImageLineWave::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 2203 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 3068 of file emdata.cpp.

References attr_dict.

Referenced by clip_inplace(), and get_clip().

03069 {
03070         attr_dict["origin_x"] = origin_x;
03071         attr_dict["origin_y"] = origin_y;
03072         attr_dict["origin_z"] = origin_z;
03073 }

void EMAN::EMData::set_xyzoff int  x,
int  y,
int  z
[inline]
 

Definition at line 1258 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 829 of file emdata_core.cpp.

References get_data(), and nx.

00830 {
00831         size_t size = nx*ny;
00832         size *= nz;
00833         if (i >= size) {
00834                 return 0;
00835         }
00836         return get_data()[i];
00837 }

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 cooridinate.
y The y cooridinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 820 of file emdata_core.cpp.

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

00821 {
00822         if (x < 0 || x >= nx || y < 0 || y >= ny) {
00823                 return 0;
00824         }
00825         return get_data()[x + y * nx];
00826 }

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 cooridinate.
y The y cooridinate.
z The z cooridinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 811 of file emdata_core.cpp.

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

Referenced by sget_value_at_interp().

00812 {
00813         if (x < 0 || x >= nx || y < 0 || y >= ny || z < 0 || z >= nz) {
00814                 return 0;
00815         }
00816         return get_data()[(size_t)x + (size_t)y * (size_t)nx + (size_t)z * (size_t)nxy];
00817 }

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 cooridinate.
y The y cooridinate.
z The z cooridinate.
Returns:
The pixel density value at coordinates (x,y,z).

Definition at line 855 of file emdata_core.cpp.

References EMAN::Util::fast_floor(), sget_value_at(), EMAN::Util::trilinear_interpolate(), x, and y.

00856 {
00857         int x = (int) Util::fast_floor(xx);
00858         int y = (int) Util::fast_floor(yy);
00859         int z = (int) Util::fast_floor(zz);
00860 
00861         float p1 = sget_value_at(x, y, z);
00862         float p2 = sget_value_at(x + 1, y, z);
00863         float p3 = sget_value_at(x, y + 1, z);
00864         float p4 = sget_value_at(x + 1, y + 1, z);
00865 
00866         float p5 = sget_value_at(x, y, z + 1);
00867         float p6 = sget_value_at(x + 1, y, z + 1);
00868         float p7 = sget_value_at(x, y + 1, z + 1);
00869         float p8 = sget_value_at(x + 1, y + 1, z + 1);
00870 
00871         float result = Util::trilinear_interpolate(p1, p2, p3, p4, p5, p6, p7, p8,
00872                                                                                            xx - x, yy - y, zz - z);
00873 
00874         return result;
00875 }

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 cooridinate.
y The y cooridinate.
Returns:
The pixel density value at coordinates (x,y).

Definition at line 840 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().

00841 {
00842         int x = static_cast < int >(Util::fast_floor(xx));
00843         int y = static_cast < int >(Util::fast_floor(yy));
00844 
00845         float p1 = sget_value_at(x, y);
00846         float p2 = sget_value_at(x + 1, y);
00847         float p3 = sget_value_at(x, y + 1);
00848         float p4 = sget_value_at(x + 1, y + 1);
00849 
00850         float result = Util::bilinear_interpolate(p1, p2, p3, p4, xx - x, yy - y);
00851         return result;
00852 }

void EMData::shuffle_pad_corner float *  pad_image  ) 
 

Definition at line 4070 of file emdata_sparx.cpp.

References nx, nx, and ny.

04070                                                 {
04071         int nyhalf = ny/2;
04072         size_t nbytes = nx*sizeof(float);
04073         for (int iy = 0; iy < nyhalf; iy++)
04074                 memcpy(&(*this)(0,iy), pad_image+6+(iy+nyhalf+3)*nx, nbytes);
04075         for (int iy = nyhalf; iy < ny; iy++)
04076                 memcpy(&(*this)(0,iy), pad_image+6+(iy-nyhalf+3)*nx, nbytes);
04077 }

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 969 of file emdata_core.cpp.

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

00970 {
00971         ENTERFUNC;
00972 
00973         if (is_complex()) {
00974                 throw ImageFormatException("real image only");
00975         }
00976 
00977         EMData * r = this->copy();
00978         float * new_data = r->get_data();
00979         float * data = get_data();
00980         size_t size = nxyz;
00981         for (size_t i = 0; i < size; ++i) {
00982                 if(data[i] < 0) {
00983                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
00984                 }
00985                 else {
00986                         if(data[i]) {   //do nothing with pixel has value zero
00987                                 new_data[i] = std::sqrt(data[i]);
00988                         }
00989                 }
00990         }
00991 
00992         r->update();
00993         return r;
00994 
00995         EXITFUNC;
00996 }

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 458 of file emdata_core.cpp.

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

00459 {
00460         ENTERFUNC;
00461 
00462         if (nx != em.get_xsize() || ny != em.get_ysize() || nz != em.get_zsize()) {
00463                 throw ImageFormatException("images not same sizes");
00464         }
00465         else if( (is_real()^em.is_real()) == true )
00466         {
00467                 throw ImageFormatException( "not support sub between real image and complex image");
00468         }
00469         else {
00470                 const float *src_data = em.get_data();
00471                 size_t size = nxyz;
00472                 float* data = get_data();
00473 
00474                 for (size_t i = 0; i < size; i++) {
00475                         data[i] -= src_data[i];
00476                 }
00477                 update();
00478         }
00479         EXITFUNC;
00480 }

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 411 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-=(), and EMAN::FlattenBackgroundProcessor::process_inplace().

00412 {
00413         ENTERFUNC;
00414         
00415 #ifdef EMAN2_USING_CUDA
00416                 if (EMData::usecuda == 1 && cudarwdata) {
00417                         if(f != 0){
00418                                 subtract_cuda(cudarwdata, f, nx, ny, nz);
00419                         }
00420                         EXITFUNC;
00421                         return;
00422                 }
00423 #endif // EMAN2_USING_CUDA
00424 
00425         float* data = get_data();
00426         if( is_real() )
00427         {
00428                 if (f != 0) {
00429                         size_t size = nxyz;
00430                         for (size_t i = 0; i < size; i++) {
00431                                 data[i] -= f;
00432                         }
00433                 }
00434                 update();
00435         }
00436         else if( is_complex() )
00437         {
00438                 if( f != 0 )
00439                 {
00440                         size_t size = nxyz;
00441                         for( size_t i=0; i<size; i+=2 )
00442                         {
00443                                 data[i] -= f;
00444                         }
00445                 }
00446                 update();
00447         }
00448         else
00449         {
00450                 throw ImageFormatException("This image is neither a real nor a complex image.");
00451         }
00452 
00453         EXITFUNC;
00454 }

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 386 of file emdata_core.cpp.

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

00387 {
00388         ENTERFUNC;
00389         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00390                 throw ImageFormatException( "images not same sizes");
00391         }
00392         else if( this->is_complex() || image.is_complex() )
00393         {
00394                 throw ImageFormatException( "Cannot addsquare() with complex images");
00395         }
00396         else {
00397 
00398                 const float *src_data = image.get_data();
00399                 size_t size = nxyz;
00400                 float* data = get_data();
00401 
00402                 for (size_t i = 0; i < size; i++) {
00403                         data[i] -= src_data[i]*src_data[i];
00404                 }
00405                 update();
00406         }
00407         EXITFUNC;
00408 }

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 1403 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

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

01403                                    {
01404         ENTERFUNC;
01405         int nxc = attr_dict["nxc"];
01406         int n = nxc*2;
01407         // let's treat the local data as a matrix
01408         vector<int> saved_offsets = get_array_offsets();
01409         set_array_offsets(0,1,1);
01410         for (int iza = 2; iza <= nxc; iza++) {
01411                 for (int iya = 2; iya <= nxc; iya++) {
01412                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01413                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01414                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01415                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01416                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01417                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01418                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01419                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01420                 }
01421         }
01422         for (int iya = 2; iya <= nxc; iya++) {
01423                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01424                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01425                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01426                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01427         }
01428         for (int iza = 2; iza <= nxc; iza++) {
01429                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01430                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01431                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01432                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01433         }
01434         EXITFUNC;
01435 }

void EMData::symplane0_ctf EMData w  ) 
 

Symmetrize plane 0 Modifies the current object.

Parameters:
w Normalization data.

Definition at line 2357 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

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

02357                                     {
02358         ENTERFUNC;
02359         int nxc = attr_dict["nxc"];
02360         int n = nxc*2;
02361         // let's treat the local data as a matrix
02362         vector<int> saved_offsets = get_array_offsets();
02363         set_array_offsets(0,1,1);
02364         for (int iza = 2; iza <= nxc; iza++) {
02365                 for (int iya = 2; iya <= nxc; iya++) {
02366                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
02367                         (*w)(0,iya,iza) += (*w)(0,n-iya+2,n-iza+2);
02368                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
02369                         (*w)(0,n-iya+2,n-iza+2) = (*w)(0,iya,iza);
02370                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
02371                         (*w)(0,n-iya+2,iza) += (*w)(0,iya,n-iza+2);
02372                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
02373                         (*w)(0,iya,n-iza+2) = (*w)(0,n-iya+2,iza);
02374                 }
02375         }
02376         for (int iya = 2; iya <= nxc; iya++) {
02377                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
02378                 (*w)(0,iya,1) += (*w)(0,n-iya+2,1);
02379                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
02380                 (*w)(0,n-iya+2,1) = (*w)(0,iya,1);
02381         }
02382         for (int iza = 2; iza <= nxc; iza++) {
02383                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
02384                 (*w)(0,1,iza) += (*w)(0,1,n-iza+2);
02385                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
02386                 (*w)(0,1,n-iza+2) = (*w)(0,1,iza);
02387         }
02388         EXITFUNC;
02389 }

void EMData::symplane0_rect EMData w  ) 
 

Definition at line 2391 of file emdata_sparx.cpp.

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

Referenced by EMAN::nn4_ctf_rectReconstructor::finish(), and EMAN::nn4_rectReconstructor::finish().

02391                                      {
02392         ENTERFUNC;
02393         nx=get_xsize();
02394         ny=get_ysize();
02395         nz=get_zsize();
02396         int nzc=nz/2;
02397         int nyc=ny/2;
02398 
02399         
02400         // let's treat the local data as a matrix
02401         vector<int> saved_offsets = get_array_offsets();
02402         set_array_offsets(0,1,1);
02403         for (int iza = 2; iza <= nzc; iza++) {
02404                 for (int iya = 2; iya <= nyc; iya++) {
02405                         cmplx(0,iya,iza) += conj(cmplx(0,ny-iya+2,nz-iza+2));
02406                         (*w)(0,iya,iza) += (*w)(0,ny-iya+2,nz-iza+2);
02407                         cmplx(0,ny-iya+2,nz-iza+2) = conj(cmplx(0,iya,iza));
02408                         (*w)(0,ny-iya+2,nz-iza+2) = (*w)(0,iya,iza);
02409                         cmplx(0,ny-iya+2,iza) += conj(cmplx(0,iya,nz-iza+2));
02410                         (*w)(0,ny-iya+2,iza) += (*w)(0,iya,nz-iza+2);
02411                         cmplx(0,iya,nz-iza+2) = conj(cmplx(0,ny-iya+2,iza));
02412                         (*w)(0,iya,nz-iza+2) = (*w)(0,ny-iya+2,iza);
02413                 }
02414         }
02415         for (int iya = 2; iya <= nyc; iya++) {
02416                 cmplx(0,iya,1) += conj(cmplx(0,ny-iya+2,1));
02417                 (*w)(0,iya,1) += (*w)(0,ny-iya+2,1);
02418                 cmplx(0,ny-iya+2,1) = conj(cmplx(0,iya,1));
02419                 (*w)(0,ny-iya+2,1) = (*w)(0,iya,1);
02420         }
02421         for (int iza = 2; iza <= nzc; iza++) {
02422                 cmplx(0,1,iza) += conj(cmplx(0,1,nz-iza+2));
02423                 (*w)(0,1,iza) += (*w)(0,1,nz-iza+2);
02424                 cmplx(0,1,nz-iza+2) = conj(cmplx(0,1,iza));
02425                 (*w)(0,1,nz-iza+2) = (*w)(0,1,iza);
02426         }
02427         EXITFUNC;
02428 }

void EMData::symplane1 EMData norm,
EMData norm2
 

Symmetrize plane 0 Modifies the current object.

Parameters:
norm Normalization data.
norm2 

Definition at line 1437 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

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

01437                                                   {
01438         ENTERFUNC;
01439         int nxc = attr_dict["nxc"];
01440         int n = nxc*2;
01441         vector<int> saved_offsets = get_array_offsets();
01442         set_array_offsets(0,1,1);
01443         for (int iza = 2; iza <= nxc; iza++) {
01444                 for (int iya = 2; iya <= nxc; iya++) {
01445                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01446                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01447                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01448                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01449                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01450                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01451                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01452                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01453                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01454                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01455                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01456                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01457                 }
01458         }
01459         for (int iya = 2; iya <= nxc; iya++) {
01460                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01461                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01462                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01463                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01464                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01465                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01466         }
01467         for (int iza = 2; iza <= nxc; iza++) {
01468                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01469                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01470                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01471                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01472                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01473                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01474         }
01475         EXITFUNC;
01476 }

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 1478 of file emdata_sparx.cpp.

References attr_dict, cmplx(), get_array_offsets(), and set_array_offsets().

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

01478                                                                  {
01479         ENTERFUNC;
01480         int nxc = attr_dict["nxc"];
01481         int n = nxc*2;
01482         vector<int> saved_offsets = get_array_offsets();
01483         set_array_offsets(0,1,1);
01484         for (int iza = 2; iza <= nxc; iza++) {
01485                 for (int iya = 2; iya <= nxc; iya++) {
01486                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01487                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01488                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01489                         (*wptr3)(0,iya,iza) += (*wptr3)(0,n-iya+2,n-iza+2);
01490 
01491                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01492                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01493                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01494                         (*wptr3)(0,n-iya+2,n-iza+2) = (*wptr3)(0,iya,iza);
01495 
01496                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01497                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01498                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01499                         (*wptr3)(0,n-iya+2,iza) += (*wptr3)(0,iya,n-iza+2);
01500 
01501                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01502                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01503                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01504                         (*wptr3)(0,iya,n-iza+2) = (*wptr3)(0,n-iya+2,iza);
01505                 }
01506         }
01507         for (int iya = 2; iya <= nxc; iya++) {
01508                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01509                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01510                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01511                 (*wptr3)(0,iya,1) += (*wptr3)(0,n-iya+2,1);
01512 
01513                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01514                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01515                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01516                 (*wptr3)(0,n-iya+2,1) = (*wptr3)(0,iya,1);
01517         }
01518         for (int iza = 2; iza <= nxc; iza++) {
01519                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01520                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01521                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01522                 (*wptr3)(0,1,iza) += (*wptr3)(0,1,n-iza+2);
01523 
01524                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01525                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01526                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01527                 (*wptr3)(0,1,n-iza+2) = (*wptr3)(0,1,iza);
01528         }
01529         EXITFUNC;
01530 }

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 1367 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().

01368 {
01369         ENTERFUNC;
01370 
01371         if (is_complex()) {
01372                 set_ri(true);
01373         }
01374         else {
01375                 set_ri(false);
01376         }
01377         to_value(1.0);
01378 
01379         update();
01380         EXITFUNC;
01381 }

void EMData::to_value const float &  value  ) 
 

set all the pixel values to a value.

Definition at line 1383 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().

01384 {
01385         ENTERFUNC;
01386 
01387 #ifdef EMAN2_USING_CUDA
01388         if(EMData::usecuda == 1 && cudarwdata){
01389                 to_value_cuda(cudarwdata, value, nx, ny, nz);
01390                 return;
01391         }
01392 #endif // EMAN2_USING_CUDA
01393         float* data = get_data();
01394 
01395         //the em_memset has segfault for >8GB image, use std::fill() instead, though may be slower
01396 //      if ( value != 0 ) std::fill(data,data+get_size(),value);
01397 //      else EMUtil::em_memset(data, 0, nxyz * sizeof(float)); // This might be faster, I don't know
01398 
01399         std::fill(data,data+get_size(),value);
01400 
01401         update();
01402         EXITFUNC;
01403 }

void EMData::to_zero  ) 
 

Set all the pixel value = 0.

Definition at line 1350 of file emdata_core.cpp.

References is_complex(), set_ri(), to_value(), and update().

Referenced by EMAN::CtfAverager::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::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(), delete_disconnected_regions(), EMAN::PointArray::distmx(), do_radon(), downsample(), EMData(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_median_(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), EMAN::Util::get_biggest_cluster(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), helicise(), helicise_grid(), little_big_dot(), make_footprint(), EMAN::Util::move_points(), mult_radial(), norm_pad(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::FourierGriddingProjector::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().

01351 {
01352         ENTERFUNC;
01353 
01354         if (is_complex()) {
01355                 set_ri(true);
01356         }
01357         else {
01358                 set_ri(false);
01359         }
01360 
01361         //EMUtil::em_memset(get_data(), 0, nxyz * sizeof(float));
01362         to_value(0.0);
01363         update();
01364         EXITFUNC;
01365 }

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 3364 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("math.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 4061 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.

04062 {
04063         ENTERFUNC;
04064 
04065         if (!map) throw NullPointerException("NULL image");
04066         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
04067         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
04068         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
04069         // Now check for complex images - this is really just being thorough
04070         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
04071         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
04072 
04073 //      Transform3D r( 0, 0, 0); // EMAN by default
04074 //      if (!ort) {
04075 //              ort = &r;
04076 //      }
04077 
04078         float *ddata = map->get_data();
04079         float *sdata = get_data();
04080 
04081         int map_nx = map->get_xsize();
04082         int map_ny = map->get_ysize();
04083         int map_nz = map->get_zsize();
04084         int map_nxy = map_nx * map_ny;
04085         float map_nz_round_limit = (float) map_nz-0.5f;
04086         float map_ny_round_limit = (float) map_ny-0.5f;
04087         float map_nx_round_limit = (float) map_nx-0.5f;
04088 /*
04089         Vec3f posttrans = ort->get_posttrans();
04090         Vec3f pretrans = ort->get_pretrans();*/
04091 
04092         int ymax = ny/2;
04093         if ( ny % 2 == 1 ) ymax += 1;
04094         int xmax = nx/2;
04095         if ( nx % 2 == 1 ) xmax += 1;
04096         for (int y = -ny/2; y < ymax; y++) {
04097                 for (int x = -nx/2; x < xmax; x++) {
04098                         Vec3f coord(x,y,0);
04099                         Vec3f soln = transform*coord;
04100 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
04101 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
04102 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
04103 //
04104 //                      xx += map_nx/2;
04105 //                      yy += map_ny/2;
04106 //                      zz += map_nz/2;
04107 //
04108                         float xx = soln[0]+map_nx/2;
04109                         float yy = soln[1]+map_ny/2;
04110                         float zz = soln[2]+map_nz/2;
04111 
04112                         // These 0.5 offsets are here because the round function rounds to the nearest whole number.
04113                         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;
04114 
04115                         size_t k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * (size_t)map_nxy;
04116                         int l = (x+nx/2) + (y+ny/2) * nx;
04117                         ddata[k] = sdata[l];
04118                 }
04119         }
04120 
04121         map->update();
04122         EXITFUNC;
04123 }

EMData * EMData::unwrap_largerR int  r1,
int  r2,
int  xs,
float  rmax_f
 

Definition at line 3927 of file emdata.cpp.

References get_data(), get_xsize(), get_ysize(), norm(), set_size(), t, update(), x, and y.

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

03927                                                                  {
03928         float *d,*dd;
03929         int do360=2;
03930         int rmax = (int)(rmax_f+0.5f);
03931         unsigned long i;
03932         unsigned int nvox=get_xsize()*get_ysize();//ming
03933         float maxmap=0.0f, minmap=0.0f;
03934         float temp=0.0f, diff_den=0.0f, norm=0.0f;
03935         float cut_off_va =0.0f;
03936 
03937         d=get_data();
03938         maxmap=-1000000.0f;
03939         minmap=1000000.0f;
03940         for (i=0;i<nvox;i++){
03941                 if(d[i]>maxmap) maxmap=d[i];
03942                 if(d[i]<minmap) minmap=d[i];
03943         }
03944         diff_den = maxmap-minmap;
03945         for(i=0;i<nvox;i++) {
03946                 temp = (d[i]-minmap)/diff_den;
03947                 if(cut_off_va != 0.0) {               // cut off the lowerset ?% noisy information
03948                         if(temp < cut_off_va)
03949                                 d[i] = 0.0f;                   // set the empty part density=0.0
03950                         else
03951                                 d[i] = temp-cut_off_va;
03952                 }
03953                 else    d[i] = temp;
03954         }
03955 
03956         for(i=0;i<nvox;i++) {
03957                 temp=d[i];
03958                 norm += temp*temp;
03959         }
03960         for(i=0;i<nvox;i++)             d[i] /= norm;                      //  y' = y/norm(y)
03961 
03962         if (xs<1) {
03963                 xs = (int) floor(do360*M_PI*get_ysize()/4); // ming
03964                 xs=Util::calc_best_fft_size(xs); // ming
03965         }
03966         if (r1<0) r1=0;
03967         float maxext=ceil(0.6f*std::sqrt((float)(get_xsize()*get_xsize()+get_ysize()*get_ysize())));// ming add std::
03968 
03969         if (r2<r1) r2=(int)maxext;
03970         EMData *ret = new EMData;
03971 
03972         ret->set_size(xs,r2+1,1);
03973 
03974         dd=ret->get_data();
03975 
03976         for (int i=0; i<xs; i++) {
03977                 float si=sin(i*M_PI*2/xs);
03978                 float co=cos(i*M_PI*2/xs);
03979                 for (int r=0; r<=maxext; r++) {
03980                         float x=(r+r1)*co+get_xsize()/2; // ming
03981                         float y=(r+r1)*si+get_ysize()/2; // ming
03982                         if(x<0.0 || x>=get_xsize()-1.0 || y<0.0 || y>=get_ysize()-1.0 || r>rmax){    //Ming , ~~~~ rmax need pass here
03983                                 for(;r<=r2;r++)                                   // here r2=MAXR
03984                                         dd[i+r*xs]=0.0;
03985                         break;
03986                     }
03987                         int x1=(int)floor(x);
03988                         int y1=(int)floor(y);
03989                         float t=x-x1;
03990                         float u=y-y1;
03991                         float f11= d[x1+y1*get_xsize()]; // ming
03992                         float f21= d[(x1+1)+y1*get_xsize()]; // ming
03993                         float f12= d[x1+(y1+1)*get_xsize()]; // ming
03994                         float f22= d[(x1+1)+(y1+1)*get_xsize()]; // ming
03995                         dd[i+r*xs] = (1-t)*(1-u)*f11+t*(1-u)*f21+t*u*f22+(1-t)*u*f12;
03996                 }
03997         }
03998         update();
03999         ret->update();
04000         return ret;
04001 }

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

Mark EMData as changed, statistics, etc will be updated at need.

Definition at line 395 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), add(), EMAN::CtfAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), add_incoherent(), EMAN::Util::addn_img(), addsquare(), EMAN::TranslationalAligner::align(), amplitude(), ap2ri(), apply_radial_func(), average_circ_sub(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), calc_ccf(), calc_ccfx(), calc_mutual_correlation(), center_origin(), center_origin_fft(), center_origin_yz(), 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::ctf_img(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), delete_disconnected_regions(), depad(), depad_corner(), 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(), fft_shuffle(), FH2F(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::CtfAverager::finish(), EMAN::CtfCAutoAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::MinMaxAverager::finish(), EMAN::ImageAverager::finish(), EMAN::TomoAverager::finish(), Four_ds(), Four_shuf_ds_cen_us(), fouriergridrot2d(), fouriergridrot_shift2d(), EMAN::fourierproduct(), FourInterpol(), FourTruncate(), 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(), helicise(), helicise_grid(), 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::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::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::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_image(), real(), real2complex(), real2FH(), EMAN::Util::reconstitute_image_mask(), replace_amplitudes(), 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().

00408                                 : this method internally just calls the

void EMData::update_stat  )  const [private]
 

Definition at line 2882 of file emdata.cpp.

References attr_dict, data, flags, get_data(), is_complex(), is_ri(), max, min, nx, ny, 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().

02883 {
02884         ENTERFUNC;
02885 //      printf("update stat %f %d\n",(float)attr_dict["mean"],flags);
02886         if (!(flags & EMDATA_NEEDUPD))
02887         {
02888                 EXITFUNC;
02889                 return;
02890         }
02891 
02892         float* data = get_data();
02893         float max = -FLT_MAX;
02894         float min = -max;
02895 
02896         double sum = 0;
02897         double square_sum = 0;
02898 
02899         int step = 1;
02900         if (is_complex() && !is_ri()) {
02901                 step = 2;
02902         }
02903 
02904         int n_nonzero = 0;
02905 
02906         size_t size = (size_t)nx*ny*nz;
02907         for (size_t i = 0; i < size; i += step) {
02908                 float v = data[i];
02909         #ifdef _WIN32
02910                 max = _cpp_max(max,v);
02911                 min = _cpp_min(min,v);
02912         #else
02913                 max=std::max<float>(max,v);
02914                 min=std::min<float>(min,v);
02915         #endif  //_WIN32
02916                 sum += v;
02917                 square_sum += v * (double)(v);
02918                 if (v != 0) n_nonzero++;
02919         }
02920 
02921         size_t n = size / step;
02922         double mean = sum / n;
02923 
02924 #ifdef _WIN32
02925         float sigma = (float)std::sqrt( _cpp_max(0.0,(square_sum - sum*sum / n)/(n-1)));
02926         n_nonzero = _cpp_max(1,n_nonzero);
02927         double sigma_nonzero = std::sqrt( _cpp_max(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02928 #else
02929         float sigma = (float)std::sqrt(std::max<double>(0.0,(square_sum - sum*sum / n)/(n-1)));
02930         n_nonzero = std::max<int>(1,n_nonzero);
02931         double sigma_nonzero = std::sqrt(std::max<double>(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02932 #endif  //_WIN32
02933         double mean_nonzero = sum / n_nonzero; // previous version overcounted! G2
02934 
02935         attr_dict["minimum"] = min;
02936         attr_dict["maximum"] = max;
02937         attr_dict["mean"] = (float)(mean);
02938         attr_dict["sigma"] = (float)(sigma);
02939         attr_dict["square_sum"] = (float)(square_sum);
02940         attr_dict["mean_nonzero"] = (float)(mean_nonzero);
02941         attr_dict["sigma_nonzero"] = (float)(sigma_nonzero);
02942         attr_dict["is_complex"] = (int) is_complex();
02943         attr_dict["is_complex_ri"] = (int) is_ri();
02944 
02945         flags &= ~EMDATA_NEEDUPD;
02946 
02947         if (rot_fp != 0)
02948         {
02949                 delete rot_fp; rot_fp = 0;
02950         }
02951 
02952         EXITFUNC;
02953 //      printf("done stat %f %f %f\n",(float)mean,(float)max,(float)sigma);
02954 }

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 134 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::WatershedProcessor::process_inplace(), unified(), and write_lst().

00139 {
00140         ENTERFUNC;
00141 
00142         struct stat fileinfo;
00143         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");
00144 
00145         if (is_complex() && is_shuffled())
00146                 fft_shuffle();
00147 
00148         if (imgtype == EMUtil::IMAGE_UNKNOWN) {
00149                 const char *ext = strrchr(filename.c_str(), '.');
00150                 if (ext) {
00151                         ext++;
00152                         imgtype = EMUtil::get_image_ext_type(ext);
00153                 }
00154         }
00155         ImageIO::IOMode rwmode = ImageIO::READ_WRITE;
00156 
00157         //set "nx", "ny", "nz" and "changecount" in attr_dict, since they are taken out of attribute dictionary
00158         attr_dict["nx"] = nx;
00159         attr_dict["ny"] = ny;
00160         attr_dict["nz"] = nz;
00161         attr_dict["changecount"] = changecount;
00162 
00163         if (Util::is_file_exist(filename)) {
00164                 LOGVAR("file exists");
00165                 if (!header_only && region == 0) {
00166                         ImageIO * tmp_imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY,
00167                                                                                                                 imgtype);
00168                         if (tmp_imageio->is_single_image_format()) {
00169                                 rwmode = ImageIO::WRITE_ONLY;
00170                         }
00171 #ifndef IMAGEIO_CACHE
00172                         if( tmp_imageio )
00173                         {
00174                                 delete tmp_imageio;
00175                                 tmp_imageio = 0;
00176                         }
00177 #endif
00178                 }
00179         }
00180         LOGVAR("getimageio %d",rwmode);
00181         ImageIO *imageio = EMUtil::get_imageio(filename, rwmode, imgtype);
00182         if (!imageio) {
00183                 throw ImageFormatException("cannot create an image io");
00184         }
00185         else {
00186                 update_stat();
00187                 /* Let each image format decide how to deal with negative image_index*/
00188 //              if (img_index < 0) {
00189 //                      img_index = imageio->get_nimg();
00190 //              }
00191                 LOGVAR("header write %d",img_index);
00192 
00193                 switch(filestoragetype) {
00194                 case EMUtil::EM_UINT:
00195                         attr_dict["datatype"] = (int)EMUtil::EM_UINT;
00196                         break;
00197                 case EMUtil::EM_USHORT:
00198                         attr_dict["datatype"] = (int)EMUtil::EM_USHORT;
00199                         break;
00200                 case EMUtil::EM_SHORT:
00201                         attr_dict["datatype"] = (int)EMUtil::EM_SHORT;
00202                         break;
00203                 case EMUtil::EM_CHAR:
00204                         attr_dict["datatype"] = (int)EMUtil::EM_CHAR;
00205                         break;
00206                 case EMUtil::EM_UCHAR:
00207                         attr_dict["datatype"] = (int)EMUtil::EM_UCHAR;
00208                         break;
00209                 default:
00210                         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;; //default float
00211                 }
00212 
00213                 int err = imageio->write_header(attr_dict, img_index, region, filestoragetype,
00214                                                                                 use_host_endian);
00215                 if (err) {
00216                         throw ImageWriteException(filename, "imageio write header failed");
00217                 }
00218                 else {
00219                         if (!header_only) {
00220                                 if (imgtype == EMUtil::IMAGE_LST) {
00221                                         const char *reffile = attr_dict["LST.reffile"];
00222                                         if (strcmp(reffile, "") == 0) {
00223                                                 reffile = path.c_str();
00224                                         }
00225                                         int refn = attr_dict["LST.refn"];
00226                                         if (refn < 0) {
00227                                                 refn = pathnum;
00228                                         }
00229 
00230                                         const char *comment = attr_dict["LST.comment"];
00231                                         char *lstdata = new char[1024];
00232                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00233                                         if(strcmp(comment, "") != 0) {
00234                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00235                                         }
00236                                         else {
00237                                                 strcat(lstdata, "\n");
00238                                         }
00239                                         err = imageio->write_data((float*)lstdata, img_index,
00240                                                                                           region, filestoragetype, use_host_endian);
00241                                         if( lstdata )
00242                                         {
00243                                                 delete [] lstdata;
00244                                                 lstdata = 0;
00245                                         }
00246                                 }
00247                                 if (imgtype == EMUtil::IMAGE_LSTFAST) {
00248                                         const char *reffile = attr_dict["LST.reffile"];
00249                                         if (strcmp(reffile, "") == 0) {
00250                                                 reffile = path.c_str();
00251                                         }
00252                                         int refn = attr_dict["LST.refn"];
00253                                         if (refn < 0) {
00254                                                 refn = pathnum;
00255                                         }
00256 
00257                                         const char *comment = attr_dict["LST.comment"];
00258                                         char *lstdata = new char[1024];
00259                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00260                                         if(strcmp(comment, "") != 0) {
00261                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00262                                         }
00263                                         else {
00264                                                 strcat(lstdata, "\n");
00265                                         }
00266                                         err = imageio->write_data((float*)lstdata, img_index,
00267                                                                                           region, filestoragetype, use_host_endian);
00268                                         if( lstdata )
00269                                         {
00270                                                 delete [] lstdata;
00271                                                 lstdata = 0;
00272                                         }
00273                                 }
00274                                 else {
00275                                         err = imageio->write_data(get_data(), img_index, region, filestoragetype,
00276                                                                                           use_host_endian);
00277                                 }
00278                                 if (err) {
00279                                         imageio->flush();
00280                                         throw ImageWriteException(filename, "imageio write data failed");
00281                                 }
00282                         }
00283                 }
00284         }
00285         //PNG image already do cleaning in write_data function.
00286         if (!(imgtype == EMUtil::IMAGE_PNG)) {
00287                 imageio->flush();
00288         }
00289 
00290 #ifndef IMAGEIO_CACHE
00291         if( imageio )
00292         {
00293                 delete imageio;
00294                 imageio = 0;
00295         }
00296 #endif
00297 
00298 
00299 
00300         EXITFUNC;
00301 }

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 313 of file emdata_io.cpp.

References attr_dict, and write_image().

00315 {
00316         ENTERFUNC;
00317         attr_dict["LST.reffile"] = reffile;
00318         attr_dict["LST.refn"] = refn;
00319         attr_dict["LST.comment"] = comment;
00320         write_image(filename, -1, EMUtil::IMAGE_LST, false);
00321         EXITFUNC;
00322 }

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

References get_value_at_wrap(), ImageDimensionException, nx, ny, nz, x, and y.

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

01429 {
01430         if ( nz > 1 && nz < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nz is too small");
01431         if ( ny > 1 && ny < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - ny is too small");
01432         if ( nx > 1 && nx < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nx is too small");
01433 
01434         int it_z = radius;
01435         int it_y = radius;
01436         int it_x = radius;
01437 
01438         if ( nz == 1 ) it_z = 0;
01439         if ( ny == 1 ) it_y = 0;
01440         if ( nx == 1 ) it_z = 0;
01441 
01442         if ( nz == 1 && ny == 1 )
01443         {
01444                 for ( int x = -it_x; x <= it_x; ++x )
01445                         get_value_at_wrap(x) = 0;
01446 
01447         }
01448         else if ( nz == 1 )
01449         {
01450                 for ( int y = -it_y; y <= it_y; ++y)
01451                         for ( int x = -it_x; x <= it_x; ++x )
01452                                 get_value_at_wrap(x,y) = 0;
01453         }
01454         else
01455         {
01456                 for( int z = -it_z; z <= it_z; ++z )
01457                         for ( int y = -it_y; y <= it_y; ++y)
01458                                 for ( int x = -it_x; x < it_x; ++x )
01459                                         get_value_at_wrap(x,y,z) = 0;
01460 
01461         }
01462 
01463 }


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 3893 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 3872 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_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 3885 of file emdata.h.

Referenced by get_attr(), and operator=().

int EMAN::EMData::flags [mutable, private]
 

flags

Definition at line 3883 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 3887 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(), center_origin_fft(), clip_inplace(), cog(), conjg(), copy_head(), cut_slice(), delete_disconnected_regions(), depad(), depad_corner(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), dot_rotate_translate(), downsample(), EMData(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), extractline(), extractpoint(), fft_shuffle(), FH2F(), filter_by_image(), find_3d_threshold(), Four_ds(), Four_shuf_ds_cen_us(), fouriergridrot2d(), fouriergridrot_shift2d(), FourInterpol(), FourTruncate(), 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_pow(), get_rotated_clip(), get_row(), get_top_half(), get_value_at_wrap(), getconvpt2d_kbi0(), helicise(), helicise_grid(), 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(), norm_pad(), operator=(), operator==(), pad_corner(), peak_ccf(), peak_search(), phase(), phase_cog(), print_image(), read_image(), real(), real2complex(), real2FH(), render_amp24(), render_ap24(), replace_amplitudes(), 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_attr(), set_attr_dict(), set_attr_python(), 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 3887 of file emdata.h.

Referenced by calc_highest_locations(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), get_edge_mean(), mult_complex_efficient(), set_size(), and setup4slice().

size_t EMAN::EMData::nxyz [private]
 

Definition at line 3888 of file emdata.h.

Referenced by norm_pad(), and set_size().

int EMAN::EMData::ny [private]
 

image size

Definition at line 3887 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(), center_origin_fft(), clip_inplace(), cog(), conjg(), copy_head(), cut_slice(), delete_disconnected_regions(), depad(), depad_corner(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), dot_rotate_translate(), downsample(), EMData(), extract_plane(), extract_plane_rect(), extract_plane_rect_fast(), fft_shuffle(), FH2F(), filter_by_image(), find_3d_threshold(), Four_ds(), Four_shuf_ds_cen_us(), fouriergridrot2d(), fouriergridrot_shift2d(), FourInterpol(), FourTruncate(), 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_pow(), get_rotated_clip(), get_top_half(), get_value_at_wrap(), getconvpt2d_kbi0(), helicise(), helicise_grid(), 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(), norm_pad(), operator=(), operator==(), peak_ccf(), peak_search(), phase(), phase_cog(), print_image(), read_image(), real(), real2complex(), real2FH(), render_amp24(), render_ap24(), replace_amplitudes(), 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_attr(), set_attr_dict(), set_attr_python(), set_complex_at(), set_data_pickle(), 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::nz [private]
 

image size

Definition at line 3887 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(), copy_head(), delete_disconnected_regions(), depad(), depad_corner(), div(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), downsample(), EMData(), extract_plane_rect(), extract_plane_rect_fast(), fft_shuffle(), FH2F(), filter_by_image(), Four_ds(), FourInterpol(), FourTruncate(), 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_conv(), get_pixel_conv7(), get_rotated_clip(), get_top_half(), get_value_at_wrap(), helicise(), helicise_grid(), 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(), norm_pad(), operator=(), peak_search(), phase(), phase_cog(), print_image(), read_image(), real(), real2complex(), real2FH(), replace_amplitudes(), 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_attr(), set_attr_dict(), set_attr_python(), 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 3896 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 3897 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 3874 of file emdata.h.

Referenced by add_complex_at(), clip_inplace(), cog(), do_fft_inplace(), do_ift(), EMData(), find_3d_threshold(), free_memory(), free_rdata(), get_complex_at(), operator=(), phase_cog(), set_complex_at(), and set_size().

EMData* EMAN::EMData::rot_fp [mutable, private]
 

This is a cached rotational footprint, can save much time.

Definition at line 3900 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 3876 of file emdata.h.

Referenced by free_memory(), set_size(), set_supp_pickle(), and setup4slice().

int EMData::totalalloc = 0 [static]
 

Definition at line 71 of file emdata.cpp.

int EMAN::EMData::xoff [private]
 

array index offsets

Definition at line 3890 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::yoff [private]
 

array index offsets

Definition at line 3890 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::zoff [private]
 

array index offsets

Definition at line 3890 of file emdata.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:51:23 2011 for EMAN2 by  doxygen 1.3.9.1