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 *const 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.
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.
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).
int calc_min_index () const
 Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array.
int 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 Transform3D &t3d)
 Define the 3D orientation of this particle Orientation information is extracted from a Transform3D 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.
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 int 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).
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)
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)
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_rect (float pixel_size, float dp, float dphi, 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 (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 Transform3D &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 rotate_translate (const Transform3D &t)
 Rotate then translate the 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, 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)
 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< 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< 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 88 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 3799 of file emdata.h.

enum EMAN::EMData::FFTPLACE
 

Enumeration values:
FFT_OUT_OF_PLACE 
FFT_IN_PLACE 

Definition at line 3130 of file emdata.h.

enum EMAN::EMData::WINDOWPLACE
 

Enumeration values:
WINDOW_OUT_OF_PLACE 
WINDOW_IN_PLACE 

Definition at line 3131 of file emdata.h.


Constructor & Destructor Documentation

EMData::EMData  ) 
 

Construct an empty EMData instance.

It has no image data.

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

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

EMData::~EMData  ) 
 

Definition at line 290 of file emdata.cpp.

References free_memory().

00291 {
00292         ENTERFUNC;
00293         free_memory();
00294 #ifdef EMAN2_USING_CUDA
00295 //      cout << "Death comes to " << cuda_cache_handle << " " << this << endl;
00296         free_cuda_memory();
00297 #endif // EMAN2_USING_CUDA
00298         EMData::totalalloc--;
00299 #ifdef MEMDEBUG
00300         printf("EMDATA-  %4d    %p\n",EMData::totalalloc,this);
00301 #endif
00302         EXITFUNC;
00303 }

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

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

00099                                                       :
00100 #ifdef EMAN2_USING_CUDA
00101                 cuda_cache_handle(-1),
00102 #endif //EMAN2_USING_CUDA
00103                 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),
00104                 all_translation(),      path(filename), pathnum(image_index), rot_fp(0)
00105 {
00106         ENTERFUNC;
00107 
00108         attr_dict["apix_x"] = 1.0f;
00109         attr_dict["apix_y"] = 1.0f;
00110         attr_dict["apix_z"] = 1.0f;
00111 
00112         attr_dict["is_complex"] = int(0);
00113         attr_dict["is_complex_x"] = int(0);
00114         attr_dict["is_complex_ri"] = int(1);
00115 
00116         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;
00117 
00118         this->read_image(filename, image_index);
00119 
00120         update();
00121         EMData::totalalloc++;
00122 
00123         EXITFUNC;
00124 }

EMData::EMData int  nx,
int  ny,
int  nz = 1,
bool  is_real = true
 

# makes an image of the specified size, either real or complex.

For complex image, the user would specify the real-space dimensions.

Parameters:
nx size for x dimension
ny size for y dimension
nz size for z dimension, default 1
is_real boolean to specify real(true) or complex(false) image, default real

Definition at line 218 of file emdata.cpp.

References attr_dict, nx, ny, rdata, set_size(), to_zero(), and update().

00218                                                    :
00219 #ifdef EMAN2_USING_CUDA
00220                 cuda_cache_handle(-1),
00221 #endif //EMAN2_USING_CUDA
00222                 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),
00223                 all_translation(),      path(""), pathnum(0), rot_fp(0)
00224 {
00225         ENTERFUNC;
00226 
00227         // used to replace cube 'pixel'
00228         attr_dict["apix_x"] = 1.0f;
00229         attr_dict["apix_y"] = 1.0f;
00230         attr_dict["apix_z"] = 1.0f;
00231 
00232         if(is_real) {   // create a real image [nx, ny, nz]
00233                 attr_dict["is_complex"] = int(0);
00234                 attr_dict["is_complex_x"] = int(0);
00235                 attr_dict["is_complex_ri"] = int(1);
00236                 set_size(nx, ny, nz);
00237         }
00238         else {  //create a complex image which real dimension is [ny, ny, nz]
00239                 int new_nx = nx + 2 - nx%2;
00240                 set_size(new_nx, ny, nz);
00241 
00242                 attr_dict["is_complex"] = int(1);
00243 
00244                 if(ny==1 && nz ==1)     {
00245                         attr_dict["is_complex_x"] = int(1);
00246                 }
00247                 else {
00248                         attr_dict["is_complex_x"] = int(0);
00249                 }
00250 
00251                 attr_dict["is_complex_ri"] = int(1);
00252                 attr_dict["is_fftpad"] = int(1);
00253 
00254                 if(nx%2 == 1) {
00255                         attr_dict["is_fftodd"] = 1;
00256                 }
00257         }
00258 
00259         this->to_zero();
00260         update();
00261         EMData::totalalloc++;
00262 
00263         EXITFUNC;
00264 }

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

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

00267                                                                                         :
00268 #ifdef EMAN2_USING_CUDA
00269                 cuda_cache_handle(-1),
00270 #endif //EMAN2_USING_CUDA
00271                 attr_dict(attr_dict), rdata(data), supp(0), flags(0), changecount(0), nx(x), ny(y), nz(z), nxy(x*y), nxyz(x*y*z), xoff(0),
00272                 yoff(0), zoff(0), all_translation(), path(""), pathnum(0), rot_fp(0)
00273 {
00274         ENTERFUNC;
00275 
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 
00283         update();
00284         EXITFUNC;
00285 }


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

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

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

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

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

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

References data, emdata_processor_add(), 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::BackProjectionReconstructor::insert_slice(), EMAN::operator+(), operator+=(), EMAN::operator-(), EMAN::NormalizeRampNormVar::process_inplace(), and EMAN::SNREvalProcessor::process_inplace().

00261 {
00262         ENTERFUNC;
00263 
00264         float * data = get_data();
00265         if( is_real() )
00266         {
00267                 if (f != 0) {
00268 
00269 
00270 #ifdef EMAN2_USING_CUDA
00271                         if ( gpu_operation_preferred () && !keepzero ) {
00272                                 EMDataForCuda tmp = get_data_struct_for_cuda();
00273                                 emdata_processor_add(&tmp,f);
00274                                 gpu_update();
00275                                 EXITFUNC;
00276                                 return;
00277                         }
00278 #endif // EMAN2_USING_CUDA
00279                         size_t size = nxyz;
00280                         if (keepzero) {
00281                                 for (size_t i = 0; i < size; i++) {
00282                                         if (data[i]) data[i] += f;
00283                                 }
00284                         }
00285                         else {
00286                                 for (size_t i = 0; i < size; i++) {
00287                                         data[i] += f;
00288                                 }
00289                         }
00290                         update();
00291                 }
00292         }
00293         else if( is_complex() )
00294         {
00295                 if( f!=0 )
00296                 {
00297                         update();
00298                         size_t size = nx*ny*nz; //size of data
00299                         if( keepzero )
00300                         {
00301                                 for(size_t i=0; i<size; i+=2)
00302                                 {
00303                                         if (data[i]) data[i] += f;
00304                                 }
00305                         }
00306                         else
00307                         {
00308                                 for(size_t i=0; i<size; i+=2)
00309                                 {
00310                                         data[i] += f;
00311                                 }
00312                         }
00313                 }
00314         }
00315         else
00316         {
00317                 throw ImageFormatException("This image is neither a real nor a complex image.");
00318         }
00319         update();
00320         EXITFUNC;
00321 }

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

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

00227                                                                                                                                                                                      {
00228 if (abs(x)>=fullnx/2 || abs(y)>fullny/2 || abs(z)>fullnz/2) return nxyz;
00229 //if (x==0 && (y!=0 || z!=0)) add_complex_at(0,-y,-z,subx0,suby0,subz0,fullnx,fullny,fullnz,conj(val));
00230 // complex conjugate insertion. Removed due to ambiguity with returned index
00231 /*if (x==0&& (y!=0 || z!=0)) {
00232         int yy=y<=0?-y:fullny-y;
00233         int zz=z<=0?-z:fullnz-z;
00234 
00235         if (yy<suby0||zz<subz0||yy>=suby0+ny||zz>=subz0+nz) return nx*ny*nz;
00236 
00237         size_t idx=(yy-suby0)*nx+(zz-subz0)*nx*ny;
00238         rdata[idx]+=(float)val.real();
00239         rdata[idx+1]+=(float)-val.imag();
00240 }*/
00241 float cc=1.0;
00242 if (x<0) {
00243         x*=-1;
00244         y*=-1;
00245         z*=-1;
00246         cc=-1.0;
00247 }
00248 if (y<0) y=fullny+y;
00249 if (z<0) z=fullnz+z;
00250 
00251 if (x<subx0||y<suby0||z<subz0||x>=subx0+nx||y>=suby0+ny||z>=subz0+nz) return nxyz;
00252 
00253 size_t idx=(x-subx0)*2+(y-suby0)*(size_t)nx+(z-subz0)*(size_t)nx*ny;
00254 rdata[idx]+=(float)val.real();
00255 rdata[idx+1]+=cc*(float)val.imag();
00256 return idx;
00257 }

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

00200                                                                                                  {
00201 //if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return nxyz;
00202 if (x>=nx/2 || y>ny/2 || z>nz/2 || x<=-nx/2 || y<-ny/2 || z<-nz/2) return nxyz;
00203 
00204 // for x=0, we need to insert the value in 2 places
00205 // complex conjugate insertion. Removed due to ambiguity with returned index
00206 /*if (x==0 && (y!=0 || z!=0)) {
00207         size_t idx=(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nx*ny;
00208         rdata[idx]+=(float)val.real();
00209         rdata[idx+1]-=(float)val.imag();
00210 }*/
00211 
00212 size_t idx;
00213 if (x<0) {
00214         idx=-x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00215         rdata[idx]+=(float)val.real();
00216         rdata[idx+1]-=(float)val.imag();
00217         return idx;
00218 }
00219 
00220 idx=x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00221 rdata[idx]+=(float)val.real();
00222 rdata[idx+1]+=(float)val.imag();
00223 
00224 return idx;
00225 }

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

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

02947 {
02948         ENTERFUNC;
02949 
02950         if (!obj) {
02951                 LOGERR("NULL image");
02952                 throw NullPointerException("NULL image");
02953         }
02954 
02955         if (!obj->is_complex() || !is_complex()) {
02956                 throw ImageFormatException("complex images only");
02957         }
02958 
02959         if (!EMUtil::is_same_size(this, obj)) {
02960                 throw ImageFormatException("images not same size");
02961         }
02962 
02963         ri2ap();
02964         obj->ri2ap();
02965 
02966         float *dest = get_data();
02967         float *src = obj->get_data();
02968         size_t size = nx * ny * nz;
02969         for (size_t j = 0; j < size; j += 2) {
02970 #ifdef  _WIN32
02971                 dest[j] = (float) _hypot(src[j], dest[j]);
02972 #else
02973                 dest[j] = (float) hypot(src[j], dest[j]);
02974 #endif  //_WIN32
02975                 dest[j + 1] = 0;
02976         }
02977 
02978         obj->update();
02979         update();
02980         EXITFUNC;
02981 }

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

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

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

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

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

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

References write_image().

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

00303 {
00304         ENTERFUNC;
00305         write_image(filename, -1, imgtype, header_only, 0);
00306         EXITFUNC;
00307 }

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

02376 {
02377         ENTERFUNC;
02378 
02379         if (!is_complex()) throw ImageFormatException("apply_radial_func requires a complex image");
02380 
02381         int n = static_cast < int >(array.size());
02382 
02383         if (n*step>2.0) printf("Warning, apply_radial_func takes x0 and step with respect to Nyquist (0.5)\n");
02384 
02385 //      printf("%f %f %f\n",array[0],array[25],array[50]);
02386 
02387         ap2ri();
02388 
02389         size_t ndims = get_ndim();
02390         float * data = get_data();
02391         if (ndims == 2) {
02392                 int k = 0;
02393                 for (int j = 0; j < ny; j++) {
02394                         for (int i = 0; i < nx; i += 2, k += 2) {
02395                                 float r;
02396 #ifdef  _WIN32
02397                                 if (j<ny/2) r = (float)_hypot(i/(float)(nx*2), j/(float)ny);
02398                                 else r = (float)_hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02399 #else
02400                                 if (j<ny/2) r = (float)hypot(i/(float)(nx*2), j/(float)ny);
02401                                 else r = (float)hypot(i/(float)(nx*2), (ny-j)/(float)ny);
02402 #endif  //_WIN32
02403                                 r = (r - x0) / step;
02404 
02405                                 int l = 0;
02406                                 if (interp) {
02407                                         l = (int) floor(r);
02408                                 }
02409                                 else {
02410                                         l = (int) floor(r + 1);
02411                                 }
02412 
02413 
02414                                 float f = 0;
02415                                 if (l >= n - 2) {
02416                                         f = array[n - 1];
02417                                 }
02418                                 else {
02419                                         if (interp) {
02420                                                 r -= l;
02421                                                 f = (array[l] * (1.0f - r) + array[l + 1] * r);
02422                                         }
02423                                         else {
02424                                                 f = array[l];
02425                                         }
02426                                 }
02427 
02428                                 data[k] *= f;
02429                                 data[k + 1] *= f;
02430                         }
02431                 }
02432         }
02433         else if (ndims == 3) {
02434                 int k = 0;
02435                 for (int m = 0; m < nz; m++) {
02436                         float mnz;
02437                         if (m<nz/2) mnz=m*m/(float)(nz*nz);
02438                         else { mnz=(nz-m)/(float)nz; mnz*=mnz; }
02439 
02440                         for (int j = 0; j < ny; j++) {
02441                                 float jny;
02442                                 if (j<ny/2) jny= j*j/(float)(ny*ny);
02443                                 else { jny=(ny-j)/(float)ny; jny*=jny; }
02444 
02445                                 for (int i = 0; i < nx; i += 2, k += 2) {
02446                                         float r = std::sqrt((i * i / (nx*nx*4.0f)) + jny + mnz);
02447                                         r = (r - x0) / step;
02448 
02449                                         int l = 0;
02450                                         if (interp) {
02451                                                 l = (int) floor(r);
02452                                         }
02453                                         else {
02454                                                 l = (int) floor(r + 1);
02455                                         }
02456 
02457 
02458                                         float f = 0;
02459                                         if (l >= n - 2) {
02460                                                 f = array[n - 1];
02461                                         }
02462                                         else {
02463                                                 if (interp) {
02464                                                         r -= l;
02465                                                         f = (array[l] * (1.0f - r) + array[l + 1] * r);
02466                                                 }
02467                                                 else {
02468                                                         f = array[l];
02469                                                 }
02470                                         }
02471 
02472                                         data[k] *= f;
02473                                         data[k + 1] *= f;
02474                                 }
02475                         }
02476                 }
02477 
02478         }
02479 
02480         update();
02481         EXITFUNC;
02482 }

EMData * EMData::average_circ_sub  )  const
 

Subtract average outside of a circle.

Returns:
image with sbtracted average outside of a circle.

Definition at line 991 of file emdata_sparx.cpp.

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

Referenced by EMAN::padfft_slice().

00992 {
00993 //  this is written as though dimensions could be different, but in fact they should be all equal nx=ny=nz,
00994 //                                                           no check of this
00995         ENTERFUNC;
00996         const EMData* const image = this;
00997         EMData* newimg = copy_head();
00998         float *proj = image->get_data();
00999         float *pnewimg = newimg->get_data();
01000         //  Calculate average outside of a circle
01001         float r2 = static_cast<float>( (nx/2)*(nx/2) );
01002         float qs=0.0f;
01003         int m=0;
01004         int ncz = nz/2 + 1;
01005         int ncy = ny/2 + 1;
01006         int ncx = nx/2 + 1;
01007         for (int iz = 1; iz <= nz; iz++) {
01008                 float yy = static_cast<float>( (iz-ncz)*(iz-ncz) );
01009                 for (int iy = 1; iy <=ny; iy++) { float xx = yy + (iy-ncy)*(iy-ncy);
01010                         for (int ix = 1; ix <= nx; ix++) {
01011                                 if ( xx+float((ix-ncx)*(ix-ncx)) > r2 ) {
01012                                         qs += proj(ix,iy,iz);
01013                                         m++;
01014                                 }
01015                         }
01016                 }
01017         }
01018 
01019 
01020         if( m > 0 ) qs /= m;
01021 
01022         for (int iz = 1; iz <= nz; iz++)
01023                 for (int iy = 1; iy <= ny; iy++)
01024                         for (int ix = 1; ix <= nx; ix++)
01025                                         pnewimg(ix,iy,iz) = proj(ix,iy,iz) - qs;
01026         newimg->update();
01027         return newimg;
01028         EXITFUNC;
01029 }

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

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

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

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

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

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

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

02156 {
02157         ENTERFUNC;
02158 
02159         a0=a0*M_PI/180.0f;
02160         da=da*M_PI/180.0f;
02161 
02162         if (get_ndim() > 2) {
02163                 throw ImageDimensionException("no 3D image");
02164         }
02165 
02166         float *yc = new float[n];
02167 
02168         vector<float>   vd(n);
02169         for (int i = 0; i < n; i++) {
02170                 yc[i] = 0.00001f;
02171         }
02172 
02173         float * data = get_data();
02174         if (is_complex()) {
02175                 int c = 0;
02176                 for (int y = 0; y < ny; y++) {
02177                         for (int x = 0; x < nx; x += 2, c += 2) {
02178                                 int x1 = x / 2;
02179                                 int y1 = y<ny/2?y:y-ny;
02180                                 float r = (float)Util::hypot_fast(x1,y1);
02181 
02182                                 if (r >= rmin && r <= rmax) {
02183                                         float a = 0;
02184 
02185                                         if (y != ny / 2 || x != 0) {
02186                                                 a = (atan2((float)y1, (float)x1) - a0) / da;
02187                                         }
02188 
02189                                         int i = (int)(floor(a));
02190                                         a -= i;
02191 
02192                                         if (i == 0) {
02193                                                 vd[0] += data[c] * (1.0f - a);
02194                                                 yc[0] += (1.0f - a);
02195                                         }
02196                                         else if (i == n - 1) {
02197                                                 vd[n - 1] += data[c] * a;
02198                                                 yc[n - 1] += a;
02199                                         }
02200                                         else if (i > 0 && i < (n - 1)) {
02201                                                 float h = 0;
02202                                                 if (is_ri()) {
02203 #ifdef  _WIN32
02204                                                         h = (float)_hypot(data[c], data[c + 1]);
02205 #else
02206                                                         h = (float)hypot(data[c], data[c + 1]);
02207 #endif  //_WIN32
02208                                                 }
02209                                                 else {
02210                                                         h = data[c];
02211                                                 }
02212 
02213                                                 vd[i] += h * (1.0f - a);
02214                                                 yc[i] += (1.0f - a);
02215                                                 vd[i + 1] += h * a;
02216                                                 yc[i + 1] += a;
02217                                         }
02218                                 }
02219                         }
02220                 }
02221         }
02222         else {
02223                 int c = 0;
02224                 float half_nx = (nx - 1) / 2.0f;
02225                 float half_ny = (ny - 1) / 2.0f;
02226 
02227                 for (int y = 0; y < ny; y++) {
02228                         for (int x = 0; x < nx; x++, c++) {
02229                                 float y1 = y - half_ny;
02230                                 float x1 = x - half_nx;
02231 #ifdef  _WIN32
02232                                 float r = (float)_hypot(x1, y1);
02233 #else
02234                                 float r = (float)hypot(x1, y1);
02235 #endif
02236 
02237                                 if (r >= rmin && r <= rmax) {
02238                                         float a = 0;
02239                                         if (x1 != 0 || y1 != 0) {
02240                                                 a = atan2(y1, x1);
02241                                                 if (a < 0) {
02242                                                         a += M_PI * 2;
02243                                                 }
02244                                         }
02245 
02246                                         a = (a - a0) / da;
02247                                         int i = static_cast < int >(floor(a));
02248                                         a -= i;
02249 
02250                                         if (i == 0) {
02251                                                 vd[0] += data[c] * (1.0f - a);
02252                                                 yc[0] += (1.0f - a);
02253                                         }
02254                                         else if (i == n - 1) {
02255                                                 vd[n - 1] += data[c] * a;
02256                                                 yc[n - 1] += (a);
02257                                         }
02258                                         else if (i > 0 && i < (n - 1)) {
02259                                                 vd[i] += data[c] * (1.0f - a);
02260                                                 yc[i] += (1.0f - a);
02261                                                 vd[i + 1] += data[c] * a;
02262                                                 yc[i + 1] += a;
02263                                         }
02264                                 }
02265                         }
02266                 }
02267         }
02268 
02269 
02270         for (int i = 0; i < n; i++) {
02271                 vd[i] /= yc[i];
02272         }
02273 
02274         if( yc )
02275         {
02276                 delete[]yc;
02277                 yc = 0;
02278         }
02279 
02280         return vd;
02281 
02282         EXITFUNC;
02283 }

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

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

00275 {
00276         ENTERFUNC;
00277 
00278         float center = get_attr("mean");
00279         float sigma = get_attr("sigma");
00280         float ds = sigma / 2;
00281         size_t size = nx * ny * nz;
00282         float *d = get_data();
00283         float sigma1 = sigma / 20;
00284         float sigma2 = sigma / 1000;
00285 
00286         while (ds > sigma1) {
00287                 double sum = 0;
00288                 int norm = 0;
00289 
00290                 for (size_t i = 0; i < size; i++) {
00291                         if (fabs(d[i] - center) < ds) {
00292                                 sum += d[i];
00293                                 norm++;
00294                         }
00295                 }
00296                 if (!norm) {
00297                         break;
00298                 }
00299                 float mean = (float)(sum / norm);
00300                 if (fabs(mean - center) < sigma2) {
00301                         ds *= 0.5f;
00302                 }
00303                 center = mean;
00304         }
00305         EXITFUNC;
00306 
00307         return center;
00308 }

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

References data, get_data(), and nx.

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

00455 {
00456         float *data = get_data();
00457 
00458         //float sigma = get_attr("sigma");
00459         //float mean = get_attr("mean");
00460         float m = 0.0;
00461 
00462         FloatPoint com(0,0,0);
00463         for (int i = 0; i < nx; ++i) {
00464                 for (int j = 0; j < ny; ++j) {
00465                         int j2 = nx * j;
00466                         for (int k = 0; k < nz; ++k) {
00467                                 size_t l = i + j2 + k * nxy;
00468                                 if (data[l] >= threshold) {             // threshold out noise (and negative density)
00469                                         com[0] += i * data[l];
00470                                         com[1] += j * data[l];
00471                                         com[2] += k * data[l];
00472                                         m += data[l];
00473                                 }
00474                         }
00475                 }
00476         }
00477 
00478         com[0] /= m;
00479         com[1] /= m;
00480         com[2] /= m;
00481 
00482         return com;
00483 }

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

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

02985 {
02986         ENTERFUNC;
02987 
02988         if (get_ndim() != 1) {
02989                 throw ImageDimensionException("'this' image is 1D only");
02990         }
02991 
02992         if (second_img->get_xsize() != nx || ny != 1) {
02993                 throw ImageFormatException("image xsize not same");
02994         }
02995 
02996         if (y_index > second_img->get_ysize() || y_index < 0) {
02997                 return -1;
02998         }
02999 
03000         float ret = 0;
03001         float *d1 = get_data();
03002         float *d2 = second_img->get_data() + second_img->get_xsize() * y_index;
03003 
03004         for (int i = 0; i < nx; i++) {
03005                 ret += Util::square(d1[i] - d2[i]);
03006         }
03007         EXITFUNC;
03008         return std::sqrt(ret);
03009 }

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

03013 {
03014         ENTERFUNC;
03015 
03016         bool maskflag = false;
03017         if (mask == 0) {
03018                 mask = new EMData(nx,ny,nz);
03019                 mask->process_inplace("testimage.circlesphere");
03020                 maskflag = true;
03021         }
03022 
03023         if (get_ndim() != mask->get_ndim() ) throw ImageDimensionException("The dimensions do not match");
03024 
03025         int mnx = mask->get_xsize(); int mny = mask->get_ysize(); int mnz = mask->get_zsize();
03026 
03027         if ( mnx > nx || mny > ny || mnz > nz)
03028                 throw ImageDimensionException("Can not calculate variance map using an image that is larger than this image");
03029 
03030         size_t P = 0;
03031         for(size_t i = 0; i < mask->get_size(); ++i){
03032                 if (mask->get_value_at(i) != 0){
03033                         ++P;
03034                 }
03035         }
03036         float normfac = 1.0f/(float)P;
03037 
03038 //      bool undoclip = false;
03039 
03040         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03041 //      if ( mnx < nx || mny < ny || mnz < nz) {
03042         Region r;
03043         if (ny == 1) r = Region((mnx-nxc)/2,nxc);
03044         else if (nz == 1) r = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03045         else r = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03046         mask->clip_inplace(r,0.0);
03047         //Region r((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03048         //mask->clip_inplace(r);
03049         //undoclip = true;
03050         //}
03051 
03052         // Here we generate the local average of the squares
03053         Region r2;
03054         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03055         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03056         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03057         EMData* squared = get_clip(r2,get_edge_mean());
03058 
03059         EMData* tmp = squared->copy();
03060         Dict pow;
03061         pow["pow"] = 2.0f;
03062         squared->process_inplace("math.pow",pow);
03063         EMData* s = mask->convolute(squared);//ming, mask squared exchange
03064         squared->mult(normfac);
03065 
03066         EMData* m = mask->convolute(tmp);//ming, tmp mask exchange
03067         m->mult(normfac);
03068         m->process_inplace("math.pow",pow);
03069         delete tmp; tmp = 0;
03070         s->sub(*m);
03071         // Here we finally generate the standard deviation image
03072         s->process_inplace("math.sqrt");
03073 
03074 //      if ( undoclip ) {
03075 //              Region r((nx-mnx)/2, (ny-mny)/2, (nz-mnz)/2,mnx,mny,mnz);
03076 //              mask->clip_inplace(r);
03077 //      }
03078 
03079         if (maskflag) {
03080                 delete mask;
03081                 mask = 0;
03082         } else {
03083                 Region r;
03084                 if (ny == 1) r = Region((nxc-mnx)/2,mnx);
03085                 else if (nz == 1) r = Region((nxc-mnx)/2, (nyc-mny)/2,mnx,mny);
03086                 else r = Region((nxc-mnx)/2, (nyc-mny)/2,(nzc-mnz)/2,mnx,mny,mnz);
03087                 mask->clip_inplace(r);
03088         }
03089 
03090         delete squared;
03091         delete m;
03092 
03093         s->process_inplace("xform.phaseorigin.tocenter");
03094         Region r3;
03095         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03096         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03097         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03098         s->clip_inplace(r3);
03099         EXITFUNC;
03100         return s;
03101 }

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

03106 {
03107         ENTERFUNC;
03108         EMData *this_copy=this;
03109         this_copy=copy();
03110 
03111         int mnx = with->get_xsize(); int mny = with->get_ysize(); int mnz = with->get_zsize();
03112         int nxc = nx+mnx; int nyc = ny+mny; int nzc = nz+mnz;
03113 
03114         // Ones is a circular/spherical mask, consisting of 1s.
03115         EMData* ones = new EMData(mnx,mny,mnz);
03116         ones->process_inplace("testimage.circlesphere");
03117 
03118         // Get a copy of with, we will eventually resize it
03119         EMData* with_resized = with->copy();
03120         with_resized->process_inplace("normalize");
03121         with_resized->mult(*ones);
03122 
03123         EMData* s = calc_fast_sigma_image(ones);// Get the local sigma image
03124 
03125         Region r1;
03126         if (ny == 1) r1 = Region((mnx-nxc)/2,nxc);
03127         else if (nz == 1) r1 = Region((mnx-nxc)/2, (mny-nyc)/2,nxc,nyc);
03128         else r1 = Region((mnx-nxc)/2, (mny-nyc)/2,(mnz-nzc)/2,nxc,nyc,nzc);
03129         with_resized->clip_inplace(r1,0.0);
03130 
03131         Region r2;
03132         if (ny == 1) r2 = Region((nx-nxc)/2,nxc);
03133         else if (nz == 1) r2 = Region((nx-nxc)/2, (ny-nyc)/2,nxc,nyc);
03134         else r2 = Region((nx-nxc)/2, (ny-nyc)/2,(nz-nzc)/2,nxc,nyc,nzc);
03135         this_copy->clip_inplace(r2,0.0);
03136 
03137         EMData* corr = this_copy->calc_ccf(with_resized); // the ccf results should have same size as sigma
03138 
03139         corr->process_inplace("xform.phaseorigin.tocenter");
03140         Region r3;
03141         if (ny == 1) r3 = Region((nxc-nx)/2,nx);
03142         else if (nz == 1) r3 = Region((nxc-nx)/2, (nyc-ny)/2,nx,ny);
03143         else r3 = Region((nxc-nx)/2, (nyc-ny)/2,(nzc-nz)/2,nx,ny,nz);
03144         corr->clip_inplace(r3);
03145 
03146         corr->div(*s);
03147 
03148         delete with_resized; delete ones; delete this_copy; delete s;
03149         EXITFUNC;
03150         return corr;
03151 }

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

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

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

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

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

00503 {
00504         ENTERFUNC;
00505 
00506         vector<Pixel> result;
00507 
00508         int di = 1;
00509         if (is_complex() && !is_ri()) {
00510                 di = 2;
00511         }
00512 
00513         int nxy = nx * ny;
00514         float * data = get_data();
00515 
00516         for (int j = 0; j < nz; ++j) {
00517                 size_t cur_z = j * nxy;
00518 
00519                 for (int k = 0; k < ny; ++k) {
00520                         size_t cur_y = k * nx + cur_z;
00521 
00522                         for (int l = 0; l < nx; l += di) {
00523                                 float v =data[l + cur_y];
00524                                 if (v > threshold) {
00525                                         result.push_back(Pixel(l, k, j, v));
00526                                 }
00527                         }
00528                 }
00529         }
00530 
00531         std::sort(result.begin(), result.end());
00532 
00533         EXITFUNC;
00534         return result;
00535 }

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

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

02076 {
02077         ENTERFUNC;
02078 
02079         static size_t prime[] = { 1, 3, 7, 11, 17, 23, 37, 59, 127, 253, 511 };
02080 
02081         if (histmin == histmax) {
02082                 histmin = get_attr("minimum");
02083                 histmax = get_attr("maximum");
02084         }
02085 
02086         vector <float> hist(hist_size, 0.0);
02087 
02088         int p0 = 0;
02089         int p1 = 0;
02090         size_t size = nx * ny * nz;
02091         if (size < 300000) {
02092                 p0 = 0;
02093                 p1 = 0;
02094         }
02095         else if (size < 2000000) {
02096                 p0 = 2;
02097                 p1 = 3;
02098         }
02099         else if (size < 8000000) {
02100                 p0 = 4;
02101                 p1 = 6;
02102         }
02103         else {
02104                 p0 = 7;
02105                 p1 = 9;
02106         }
02107 
02108         if (is_complex() && p0 > 0) {
02109                 p0++;
02110                 p1++;
02111         }
02112 
02113         size_t di = 0;
02114 //      float norm = 0;
02115         size_t n = hist.size();
02116 
02117         float * data = get_data();
02118         for (int k = p0; k <= p1; ++k) {
02119                 if (is_complex()) {
02120                         di = prime[k] * 2;
02121                 }
02122                 else {
02123                         di = prime[k];
02124                 }
02125 
02126 //              norm += (float)size / (float) di;
02127                 float w = (float)n / (histmax - histmin);
02128 
02129                 for(size_t i=0; i<=size-di; i += di) {
02130                         float val;
02131                         if (cont != 1.0f || brt != 0)val = cont*(data[i]+brt);
02132                         else val = data[i];
02133                         int j = Util::round((val - histmin) * w);
02134                         if (j >= 0 && j < (int) n) {
02135                                 hist[j] += 1;
02136                         }
02137                 }
02138         }
02139 /*
02140         for (size_t i = 0; i < hist.size(); ++i) {
02141                 if (norm != 0) {
02142                         hist[i] = hist[i] / norm;
02143                 }
02144         }
02145 */
02146         return hist;
02147 
02148         EXITFUNC;
02149 }

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

References calc_max_location(), and nx.

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

00495 {
00496         IntPoint max_location = calc_max_location();
00497         int i = max_location[0] + max_location[1] * nx + max_location[2] * nx * ny;
00498         return i;
00499 }

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

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

Referenced by calc_max_index().

00387 {
00388         ENTERFUNC;
00389 
00390         int di = 1;
00391         if (is_complex() && !is_ri()) {
00392                 di = 2;
00393         }
00394 
00395         float max = -FLT_MAX;
00396         int max_x = 0;
00397         int max_y = 0;
00398         int max_z = 0;
00399         int nxy = nx * ny;
00400         float * data = get_data();
00401 
00402         for (int j = 0; j < nz; ++j) {
00403                 size_t cur_z = j * nxy;
00404 
00405                 for (int k = 0; k < ny; ++k) {
00406                         size_t cur_y = k * nx + cur_z;
00407 
00408                         for (int l = 0; l < nx; l += di) {
00409                                 float t = data[l + cur_y];
00410                                 if (t > max) {
00411                                         max_x = l;
00412                                         max_y = k;
00413                                         max_z = j;
00414                                         max = t;
00415                                 }
00416                         }
00417                 }
00418         }
00419 
00420         EXITFUNC;
00421         return IntPoint(max_x, max_y, max_z);
00422 }

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

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

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

00426 {
00427         int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
00428         if (maxdx == -1) maxshiftx = get_xsize()/4;
00429         if (maxdy == -1) maxshifty = get_ysize()/4;
00430         if (maxdz == -1) maxshiftz = get_zsize()/4;
00431 
00432         float max_value = -FLT_MAX;
00433 
00434         IntPoint peak(0,0,0);
00435         for (int k = -maxshiftz; k <= maxshiftz; k++) {
00436                 for (int j = -maxshifty; j <= maxshifty; j++) {
00437                         for (int i = -maxshiftx; i <= maxshiftx; i++) {
00438 
00439                                 float value = get_value_at_wrap(i,j,k);
00440 
00441                                 if (value > max_value) {
00442                                         max_value = value;
00443                                         peak[0] = i;
00444                                         peak[1] = j;
00445                                         peak[2] = k;
00446                                 }
00447                         }
00448                 }
00449         }
00450 
00451         return peak;
00452 }

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

References calc_min_location(), and nx.

00487 {
00488         IntPoint min_location = calc_min_location();
00489         int i = min_location[0] + min_location[1] * nx + min_location[2] * nx * ny;
00490         return i;
00491 }

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

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

Referenced by calc_min_index().

00349 {
00350         ENTERFUNC;
00351 
00352         int di = 1;
00353         if (is_complex() && !is_ri()) {
00354                 di = 2;
00355         }
00356 
00357         float min = FLT_MAX;
00358         int min_x = 0;
00359         int min_y = 0;
00360         int min_z = 0;
00361         int nxy = nx * ny;
00362         float * data = get_data();
00363 
00364         for (int j = 0; j < nz; ++j) {
00365                 size_t cur_z = j * nxy;
00366 
00367                 for (int k = 0; k < ny; ++k) {
00368                         size_t cur_y = k * nx + cur_z;
00369 
00370                         for (int l = 0; l < nx; l += di) {
00371                                 float t = data[l + cur_y];
00372                                 if (t < min) {
00373                                         min_x = l;
00374                                         min_y = k;
00375                                         min_z = j;
00376                                         min = t;
00377                                 }
00378                         }
00379                 }
00380         }
00381 
00382         return IntPoint(min_x, min_y, min_z);
00383 }

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

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

Referenced by make_rotational_footprint_cmc(), and make_rotational_footprint_e1().

01971 {
01972         ENTERFUNC;
01973 
01974         if (with && !EMUtil::is_same_size(this, with)) {
01975                 LOGERR("images not same size");
01976                 throw ImageFormatException( "images not same size");
01977         }
01978 
01979         EMData *this_fft = 0;
01980         this_fft = do_fft();
01981 
01982         if (!this_fft) {
01983 
01984                 LOGERR("FFT returns NULL image");
01985                 throw NullPointerException("FFT returns NULL image");
01986         }
01987 
01988         this_fft->ap2ri();
01989         EMData *cf = 0;
01990 
01991         if (with && with != this) {
01992                 cf = with->do_fft();
01993                 if (!cf) {
01994                         LOGERR("FFT returns NULL image");
01995                         throw NullPointerException("FFT returns NULL image");
01996                 }
01997                 cf->ap2ri();
01998         }
01999         else {
02000                 cf = this_fft->copy();
02001         }
02002 
02003         if (filter) {
02004                 if (!EMUtil::is_same_size(filter, cf)) {
02005                         LOGERR("improperly sized filter");
02006                         throw ImageFormatException("improperly sized filter");
02007                 }
02008 
02009                 cf->mult_complex_efficient(*filter,true);
02010                 this_fft->mult(*filter,true);
02011                 /*cf->mult_complex_efficient(*filter,5);
02012                 this_fft->mult_complex_efficient(*filter,5);*/
02013         }
02014 
02015         float *rdata1 = this_fft->get_data();
02016         float *rdata2 = cf->get_data();
02017         size_t this_fft_size = this_fft->get_xsize() * this_fft->get_ysize() * this_fft->get_zsize();
02018 
02019         if (with == this) {
02020                 for (size_t i = 0; i < this_fft_size; i += 2) {
02021                         rdata2[i] = std::sqrt(rdata1[i] * rdata2[i] + rdata1[i + 1] * rdata2[i + 1]);
02022                         rdata2[i + 1] = 0;
02023                 }
02024 
02025                 this_fft->update();
02026                 cf->update();
02027         }
02028         else {
02029                 for (size_t i = 0; i < this_fft_size; i += 2) {
02030                         rdata2[i] = (rdata1[i] * rdata2[i] + rdata1[i + 1] * rdata2[i + 1]);
02031                         rdata2[i + 1] = (rdata1[i + 1] * rdata2[i] - rdata1[i] * rdata2[i + 1]);
02032                 }
02033 
02034                 this_fft->update();
02035                 cf->update();
02036                 rdata1 = cf->get_data();
02037 
02038                 for (size_t i = 0; i < this_fft_size; i += 2) {
02039                         float t = Util::square(rdata1[i]) + Util::square(rdata1[i + 1]);
02040                         if (t != 0) {
02041                                 t = pow(t, (float) 0.25);
02042                                 rdata1[i] /= t;
02043                                 rdata1[i + 1] /= t;
02044                         }
02045                 }
02046                 cf->update();
02047         }
02048 
02049         EMData *f2 = cf->do_ift();
02050 
02051         if (tocenter) {
02052                 f2->process_inplace("xform.phaseorigin.tocenter");
02053         }
02054 
02055         if( cf )
02056         {
02057                 delete cf;
02058                 cf = 0;
02059         }
02060 
02061         if( this_fft )
02062         {
02063                 delete this_fft;
02064                 this_fft = 0;
02065         }
02066 
02067         f2->set_attr("label", "MCF");
02068         f2->set_path("/tmp/eman.mcf");
02069 
02070         EXITFUNC;
02071         return f2;
02072 }

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

00538 {
00539         ENTERFUNC;
00540 
00541         vector<Pixel> result;
00542 
00543         int di = 1;
00544         if (is_complex() && !is_ri()) {
00545                 di = 2;
00546         }
00547 
00548         // initialize with n elements
00549         float * data = get_data();
00550         for ( int i=0; i<n; i++) result.push_back(Pixel(0,0,0,data[0]));
00551 
00552         int nxy = nx * ny;
00553 
00554         for (int j = 0; j < nz; ++j) {
00555                 size_t cur_z = j * nxy;
00556 
00557                 for (int k = 0; k < ny; ++k) {
00558                         size_t cur_y = k * nx + cur_z;
00559 
00560                         for (int l = 0; l < nx; l += di) {
00561                                 float v =data[l + cur_y];
00562                                 if (v<result[n-1].value) continue;
00563                                 for (vector<Pixel>::iterator i=result.begin(); i<result.end(); i++) {
00564                                         if (v>(*i).value) { result.insert(i,Pixel(l, k, j, v)); result.pop_back(); break; }
00565                                 }
00566                         }
00567                 }
00568         }
00569 
00570         EXITFUNC;
00571         return result;
00572 }

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

02593 {
02594         ENTERFUNC;
02595 
02596         if (nz > 1) {
02597                 LOGERR("2D images only.");
02598                 throw ImageDimensionException("2D images only");
02599         }
02600 
02601         vector<float>ret(n*nwedge);
02602         vector<float>norm(n*nwedge);
02603 
02604         int x,y,i;
02605         int step=is_complex()?2:1;
02606         float astep=static_cast<float>(M_PI*2.0/nwedge);
02607         float* data = get_data();
02608         for (i=0; i<n*nwedge; i++) ret[i]=norm[i]=0.0;
02609 
02610         // We do 2D separately to avoid the hypot3 call
02611         for (y=i=0; y<ny; y++) {
02612                 for (x=0; x<nx; x+=step,i+=step) {
02613                         float r,v,a;
02614                         if (is_complex()) {
02615 #ifdef  _WIN32
02616                                 r=static_cast<float>(_hypot(x/2.0,y<ny/2?y:ny-y));              // origin at 0,0; periodic
02617 #else
02618                                 r=static_cast<float>(hypot(x/2.0,y<ny/2?y:ny-y));               // origin at 0,0; periodic
02619 #endif
02620                                 a=atan2(float(y<ny/2?y:ny-y),x/2.0f);
02621                                 if (!inten) {
02622 #ifdef  _WIN32
02623                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02624 #else
02625                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02626 #endif  //_WIN32
02627                                         else v=data[i];                                                 // amp/phase, just get amp
02628                                 } else {
02629                                         if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02630                                         else v=data[i]*data[i];
02631                                 }
02632                         }
02633                         else {
02634 #ifdef  _WIN32
02635                                 r=static_cast<float>(_hypot(x-nx/2,y-ny/2));
02636 #else
02637                                 r=static_cast<float>(hypot(x-nx/2,y-ny/2));
02638 #endif  //_WIN32
02639                                 a=atan2(float(y-ny/2),float(x-nx/2));
02640                                 if (inten) v=data[i]*data[i];
02641                                 else v=data[i];
02642                         }
02643                         int bin=n*int((a+M_PI)/astep);
02644                         if (bin>=nwedge) bin=nwedge-1;
02645                         r=(r-x0)/dx;
02646                         int f=int(r);   // safe truncation, so floor isn't needed
02647                         r-=float(f);    // r is now the fractional spacing between bins
02648                         if (f>=0 && f<n) {
02649                                 ret[f+bin]+=v*(1.0f-r);
02650                                 norm[f+bin]+=(1.0f-r);
02651                                 if (f<n-1) {
02652                                         ret[f+1+bin]+=v*r;
02653                                         norm[f+1+bin]+=r;
02654                                 }
02655                         }
02656                 }
02657         }
02658 
02659         for (i=0; i<n*nwedge; i++) ret[i]/=norm[i]?norm[i]:1.0f;        // Normalize
02660         EXITFUNC;
02661 
02662         return ret;
02663 }

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

02485 {
02486         ENTERFUNC;
02487 
02488         vector<float>ret(n);
02489         vector<float>norm(n);
02490 
02491         int x,y,z,i;
02492         int step=is_complex()?2:1;
02493         int isinten=get_attr_default("is_intensity",0);
02494 
02495         if (isinten&&!inten) { throw InvalidParameterException("Must set inten for calc_radial_dist with intensity image"); }
02496 
02497         for (i=0; i<n; i++) ret[i]=norm[i]=0.0;
02498         float * data = get_data();
02499 
02500         // We do 2D separately to avoid the hypot3 call
02501         if (nz==1) {
02502                 for (y=i=0; y<ny; y++) {
02503                         for (x=0; x<nx; x+=step,i+=step) {
02504                                 float r,v;
02505                                 if (step==2) {          //complex
02506                                         if (x==0 && y>ny/2) continue;
02507                                         r=(float)(Util::hypot_fast(x/2,y<ny/2?y:ny-y));         // origin at 0,0; periodic
02508                                         if (!inten) {
02509 #ifdef  _WIN32
02510                                                 if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02511 #else
02512                                                 if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02513 #endif
02514                                                 else v=data[i];                                                 // amp/phase, just get amp
02515                                         } else {
02516                                                 if (isinten) v=data[i];
02517                                                 else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02518                                                 else v=data[i]*data[i];
02519                                         }
02520                                 }
02521                                 else {
02522                                         r=(float)(Util::hypot_fast(x-nx/2,y-ny/2));
02523                                         if (inten) v=data[i]*data[i];
02524                                         else v=data[i];
02525                                 }
02526                                 r=(r-x0)/dx;
02527                                 int f=int(r);   // safe truncation, so floor isn't needed
02528                                 r-=float(f);    // r is now the fractional spacing between bins
02529 //                              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);
02530                                 if (f>=0 && f<n) {
02531                                         ret[f]+=v*(1.0f-r);
02532                                         norm[f]+=(1.0f-r);
02533                                         if (f<n-1) {
02534                                                 ret[f+1]+=v*r;
02535                                                 norm[f+1]+=r;
02536                                         }
02537                                 }
02538                         }
02539                 }
02540         }
02541         else {
02542                 size_t i;       //3D file may have >2G size
02543                 for (z=i=0; z<nz; ++z) {
02544                         for (y=0; y<ny; ++y) {
02545                                 for (x=0; x<nx; x+=step,i+=step) {
02546                                         float r,v;
02547                                         if (step==2) {  //complex
02548                                                 if (x==0 && z<nz/2) continue;
02549                                                 if (x==0 && z==nz/2 && y<ny/2) continue;
02550                                                 r=Util::hypot3(x/2,y<ny/2?y:ny-y,z<nz/2?z:nz-z);        // origin at 0,0; periodic
02551                                                 if (!inten) {
02552 #ifdef  _WIN32
02553                                                         if (is_ri()) v=static_cast<float>(_hypot(data[i],data[i+1]));   // real/imag, compute amplitude
02554 #else
02555                                                         if (is_ri()) v=static_cast<float>(hypot(data[i],data[i+1]));    // real/imag, compute amplitude
02556 #endif  //_WIN32
02557                                                         else v=data[i];                                                 // amp/phase, just get amp
02558                                                 } else {
02559                                                         if (isinten) v=data[i];
02560                                                         else if (is_ri()) v=data[i]*data[i]+data[i+1]*data[i+1];
02561                                                         else v=data[i]*data[i];
02562                                                 }
02563                                         }
02564                                         else {
02565                                                 r=Util::hypot3(x-nx/2,y-ny/2,z-nz/2);
02566                                                 if (inten) v=data[i]*data[i];
02567                                                 else v=data[i];
02568                                         }
02569                                         r=(r-x0)/dx;
02570                                         int f=int(r);   // safe truncation, so floor isn't needed
02571                                         r-=float(f);    // r is now the fractional spacing between bins
02572                                         if (f>=0 && f<n) {
02573                                                 ret[f]+=v*(1.0f-r);
02574                                                 norm[f]+=(1.0f-r);
02575                                                 if (f<n-1) {
02576                                                         ret[f+1]+=v*r;
02577                                                         norm[f+1]+=r;
02578                                                 }
02579                                         }
02580                                 }
02581                         }
02582                 }
02583         }
02584 
02585         for (i=0; i<n; i++) ret[i]/=norm[i]?norm[i]:1.0f;       // Normalize
02586 
02587         EXITFUNC;
02588 
02589         return ret;
02590 }

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

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

00312 {
00313         ENTERFUNC;
00314 
00315         float *d = get_data();
00316         float mean = get_attr("mean");
00317         float sigma = get_attr("sigma");
00318 
00319         double sum_up = 0;
00320         double sum_down = 0;
00321         int nup = 0;
00322         int ndown = 0;
00323 
00324         size_t size = nx * ny * nz;
00325 
00326         for (size_t i = 0; i < size; i++) {
00327                 if (d[i] > mean) {
00328                         sum_up += Util::square(d[i] - mean);
00329                         nup++;
00330                 }
00331                 else {
00332                         sum_down += Util::square(mean - d[i]);
00333                         ndown++;
00334                 }
00335         }
00336 
00337         float sigup = std::sqrt((float)sum_up / nup);
00338         float sigdown = std::sqrt((float)sum_down / ndown);
00339         float sig_diff = fabs(sigup - sigdown) / sigma;
00340 
00341 
00342         EXITFUNC;
00343         return sig_diff;
00344 
00345 }

void EMData::cconj  ) 
 

Replace the image its complex conjugate.

Exceptions:
ImageFormatException Image must be complex (and RI)

Definition at line 2665 of file emdata.cpp.

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

02665                    {
02666         ENTERFUNC;
02667         if (!is_complex() || !is_ri())
02668                 throw ImageFormatException("EMData::conj requires a complex, ri image");
02669         int nxreal = nx -2 + int(is_fftodd());
02670         int nxhalf = nxreal/2;
02671         for (int iz = 0; iz < nz; iz++)
02672                 for (int iy = 0; iy < ny; iy++)
02673                         for (int ix = 0; ix <= nxhalf; ix++)
02674                                 cmplx(ix,iy,iz) = conj(cmplx(ix,iy,iz));
02675         EXITFUNC;
02676 }

void EMData::center_origin  ) 
 

Definition at line 6682 of file emdata_sparx.cpp.

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

06683 {
06684         ENTERFUNC;
06685         if (is_complex()) {
06686                 LOGERR("Real image expected. Input image is complex.");
06687                 throw ImageFormatException("Real image expected. Input image is complex.");
06688         }
06689         for (int iz = 0; iz < nz; iz++) {
06690                 for (int iy = 0; iy < ny; iy++) {
06691                         for (int ix = 0; ix < nx; ix++) {
06692                                 // next line multiplies by +/- 1
06693                                 (*this)(ix,iy,iz) *= -2*((ix+iy+iz)%2) + 1;
06694                         }
06695                 }
06696         }
06697         update();
06698         EXITFUNC;
06699 }

void EMData::center_origin_fft  ) 
 

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

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

06720 {
06721         ENTERFUNC;
06722         if (!is_complex()) {
06723                 LOGERR("complex image expected. Input image is real image.");
06724                 throw ImageFormatException("complex image expected. Input image is real image.");
06725         }
06726 
06727         if (!is_ri()) {
06728                 LOGWARN("Only RI should be used. ");
06729         }
06730         vector<int> saved_offsets = get_array_offsets();
06731         // 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
06732         //                                                 and even, so we can ignore the difference...
06733         //                         in short, as nx is extended, it should be  ix in [0,(nx-2)/2],  corrected PAP 05/20
06734         set_array_offsets(0,1,1);
06735         int nxc = nx/2;
06736 
06737         if (is_fftodd()) {
06738                 for (int iz = 1; iz <= nz; iz++) {
06739                         for (int iy = 1; iy <= ny; iy++) {
06740                                 for (int ix = 0; ix < nxc; ix++) {
06741                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06742                                         float temp = float(iz-1+iy-1+ix)/float(ny)*M_PI;
06743                                         complex<float> temp2 = complex<float>(cos(temp), -sin(temp));
06744                                         cmplx(ix,iy,iz) *= temp2;
06745                                 }
06746                         }
06747                 }
06748         } else {
06749                 for (int iz = 1; iz <= nz; iz++) {
06750                         for (int iy = 1; iy <= ny; iy++) {
06751                                 for (int ix = 0; ix < nxc; ix++) {
06752                                         // next line multiplies by +/- 1
06753                                         cmplx(ix,iy,iz) *= float(-2*((ix+iy+iz)%2) + 1);
06754                                 }
06755                         }
06756                 }
06757         }
06758         set_array_offsets(saved_offsets);
06759         update();
06760         EXITFUNC;
06761 }

void EMData::center_origin_yz  ) 
 

Definition at line 6701 of file emdata_sparx.cpp.

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

06702 {
06703         ENTERFUNC;
06704         if (is_complex()) {
06705                 LOGERR("Real image expected. Input image is complex.");
06706                 throw ImageFormatException("Real image expected. Input image is complex.");
06707         }
06708         for (int iz = 0; iz < nz; iz++) {
06709                 for (int iy = (iz+1)%2; iy < ny; iy+=2) {
06710                         for (int ix = 0; ix < nx; ix++) {
06711                                 (*this)(ix,iy,iz) *= -1;
06712                         }
06713                 }
06714         }
06715         update();
06716         EXITFUNC;
06717 }

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

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

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

euclidean distance between two line

Parameters:
sinoj 
n1 
n2 

Definition at line 503 of file emdata_sparx.cpp.

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

00504 {
00505     int lnlen = get_xsize();
00506     float* line_1 = get_data() + n1 * lnlen;
00507     float* line_2 = sinoj->get_data() + n2 * lnlen;
00508     return dist(lnlen, line_1, line_2);
00509 }

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::Refine3DAligner::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::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 2336 of file emdata.h.

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

Definition at line 2325 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 2314 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 700 of file emdata_sparx.cpp.

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

00700                           {
00701 
00702         vector<float> cntog;
00703         int ndim = get_ndim();
00704         int i=1,j=1,k=1;
00705         float val,sum1=0.f,MX=0.f,RG=0.f,MY=0.f,MZ=0.f,r=0.f;
00706 
00707         if (ndim == 1) {
00708                 for ( i = 1;i <= nx; i++) {
00709                         val   = rdata(i,j,k);
00710                         sum1 += val;
00711                         MX   += ((i-1)*val);
00712                 }
00713                 MX=(MX/sum1);
00714                 for ( i = 1;i <= nx; i++) {
00715                         val   = rdata(i,j,k);
00716                         sum1 += val;
00717                         RG   += val*(square(MX - (i-1)));
00718                 }
00719                 RG=std::sqrt(RG/sum1);
00720                 MX=MX-(nx/2);
00721                 cntog.push_back(MX);
00722                 cntog.push_back(RG);
00723 #ifdef _WIN32
00724                 cntog.push_back((float)Util::round(MX));
00725 #else
00726                 cntog.push_back(round(MX));
00727 #endif  //_WIN32
00728         } else if (ndim == 2) {
00729                 for (j=1;j<=ny;j++) {
00730                         for (i=1;i<=nx;i++) {
00731                                 val = rdata(i,j,k);
00732                                 sum1 += val;
00733                                 MX   += ((i-1)*val);
00734                                 MY   += ((j-1)*val);
00735                         }
00736                 }
00737                 MX=(MX/sum1);
00738                 MY=(MY/sum1);
00739                 sum1=0.f;
00740                 RG=0.f;
00741                 for (j=1;j<=ny;j++) {
00742                         r = (square(MY-(j-1)));
00743                         for (i=1;i<=nx;i++) {
00744                                 val = rdata(i,j,k);
00745                                 sum1 += val;
00746                                 RG   += val*(square(MX - (i-1)) + r);
00747                         }
00748                 }
00749                 RG = std::sqrt(RG/sum1);
00750                 MX = MX - nx/2;
00751                 MY = MY - ny/2;
00752                 cntog.push_back(MX);
00753                 cntog.push_back(MY);
00754                 cntog.push_back(RG);
00755 #ifdef _WIN32
00756                 cntog.push_back((float)Util::round(MX));cntog.push_back((float)Util::round(MY));
00757 #else
00758                 cntog.push_back(round(MX));cntog.push_back(round(MY));
00759 #endif  //_WIN32
00760         } else {
00761                 for (k = 1;k <= nz;k++) {
00762                         for (j=1;j<=ny;j++) {
00763                                 for (i=1;i<=nx;i++) {
00764                                         val = rdata(i,j,k);
00765                                         sum1 += val;
00766                                         MX += ((i-1)*val);
00767                                         MY += ((j-1)*val);
00768                                         MZ += ((k-1)*val);
00769                                 }
00770                         }
00771                 }
00772                 MX = MX/sum1;
00773                 MY = MY/sum1;
00774                 MZ = MZ/sum1;
00775                 sum1=0.f;
00776                 RG=0.f;
00777                 for (k = 1;k <= nz;k++) {
00778                         for (j=1;j<=ny;j++) {
00779                                 float r = (square(MY-(j-1)) + square(MZ - (k-1)));
00780                                 for (i=1;i<=nx;i++) {
00781                                         val = rdata(i,j,k);
00782                                         sum1 += val;
00783                                         RG   += val*(square(MX - (i-1)) + r);
00784                                 }
00785                         }
00786                 }
00787                 RG = std::sqrt(RG/sum1);
00788                 MX = MX - nx/2;
00789                 MY = MY - ny/2;
00790                 MZ = MZ - nz/2;
00791                 cntog.push_back(MX);
00792                 cntog.push_back(MY);
00793                 cntog.push_back(MZ);
00794                 cntog.push_back(RG);
00795 #ifdef _WIN32
00796                 cntog.push_back((float)Util::round(MX));cntog.push_back((float)Util::round(MY));cntog.push_back((float)Util::round(MZ));
00797 #else
00798                 cntog.push_back(round(MX));cntog.push_back(round(MY));cntog.push_back(round(MZ));
00799 #endif  //_WIN32
00800         }
00801         return cntog;
00802 }

EMData * EMData::conjg  ) 
 

Definition at line 6190 of file emdata_sparx.cpp.

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

06191 {
06192         if(this->is_complex()) {
06193                 EMData* buf_new = this->copy_head();
06194                 float *in  = this->get_data();
06195                 float *out = buf_new->get_data();
06196                 for(int i=0; i<nx*ny*nz; i+=2) {out[i] = in[i]; out[i+1] = -in[i+1];}
06197                 return buf_new;
06198         } else throw ImageFormatException("image has to be complex");
06199 }

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

03154 {
03155         ENTERFUNC;
03156 
03157         EMData *f1 = do_fft();
03158         if (!f1) {
03159                 LOGERR("FFT returns NULL image");
03160                 throw NullPointerException("FFT returns NULL image");
03161         }
03162 
03163         f1->ap2ri();
03164 
03165         EMData *cf = 0;
03166         if (with) {
03167                 cf = with->do_fft();
03168                 if (!cf) {
03169                         LOGERR("FFT returns NULL image");
03170                         throw NullPointerException("FFT returns NULL image");
03171                 }
03172                 cf->ap2ri();
03173         }
03174         else {
03175                 cf = f1->copy();
03176         }
03177         //printf("cf_x=%d, f1y=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f1->get_ysize(),this->get_xsize(),with->get_xsize());
03178         if (with && !EMUtil::is_same_size(f1, cf)) {
03179                 LOGERR("images not same size");
03180                 throw ImageFormatException("images not same size");
03181         }
03182 
03183         float *rdata1 = f1->get_data();
03184         float *rdata2 = cf->get_data();
03185         size_t cf_size = cf->get_xsize() * cf->get_ysize() * cf->get_zsize();
03186 
03187         float re,im;
03188 
03189         for (size_t i = 0; i < cf_size; i += 2) {
03190                 re = rdata1[i] * rdata2[i] - rdata1[i + 1] * rdata2[i + 1];
03191                 im = rdata1[i + 1] * rdata2[i] + rdata1[i] * rdata2[i + 1];
03192                 rdata2[i]=re;
03193                 rdata2[i+1]=im;
03194         }
03195         cf->update();
03196         EMData *f2 = cf->do_ift();//ming change cf to cf_temp
03197         //printf("cf_x=%d, f2x=%d, thisx=%d, withx=%d\n",cf->get_xsize(),f2->get_xsize(),this->get_xsize(),with->get_xsize());
03198         if( cf )
03199         {
03200                 delete cf;
03201                 cf = 0;
03202         }
03203 
03204         if( f1 )
03205         {
03206                 delete f1;
03207                 f1=0;
03208         }
03209 
03210         EXITFUNC;
03211         return f2;
03212 }

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 82 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(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), EMAN::nn4Reconstructor::finish(), 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().

00083 {
00084         ENTERFUNC;
00085 
00086         EMData *ret = new EMData(*this);
00087 
00088         EXITFUNC;
00089         return ret;
00090 }

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 93 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::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_rect(), 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(), EMAN::Util::subn_img(), and EMAN::Util::window().

00094 {
00095         ENTERFUNC;
00096         EMData *ret = new EMData();
00097         ret->attr_dict = attr_dict;
00098 
00099         ret->set_size(nx, ny, nz);
00100         ret->flags = flags;
00101 
00102         ret->all_translation = all_translation;
00103 
00104         ret->path = path;
00105         ret->pathnum = pathnum;
00106 
00107 // should these be here? d.woolford I did not comment them out, merely place them here (commented out) to draw attention
00108 //      ret->xoff = xoff;
00109 //      ret->yoff = yoff;
00110 //      ret->zoff = zoff;
00111 //      ret->changecount = changecount;
00112 
00113         ret->update();
00114 
00115         EXITFUNC;
00116         return ret;
00117 }

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

03610 {
03611         ENTERFUNC;
03612 
03613         if (!map) throw NullPointerException("NULL image");
03614         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
03615         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
03616         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
03617         // Now check for complex images - this is really just being thorough
03618         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
03619         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
03620 
03621 
03622         float *sdata = map->get_data();
03623         float *ddata = get_data();
03624 
03625         int map_nx = map->get_xsize();
03626         int map_ny = map->get_ysize();
03627         int map_nz = map->get_zsize();
03628         int map_nxy = map_nx * map_ny;
03629 
03630         int ymax = ny/2;
03631         if ( ny % 2 == 1 ) ymax += 1;
03632         int xmax = nx/2;
03633         if ( nx % 2 == 1 ) xmax += 1;
03634         for (int y = -ny/2; y < ymax; y++) {
03635                 for (int x = -nx/2; x < xmax; x++) {
03636                         Vec3f coord(x,y,0);
03637                         Vec3f soln = transform*coord;
03638 
03639 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
03640 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
03641 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
03642 
03643 
03644 //                      xx += map_nx/2;
03645 //                      yy += map_ny/2;
03646 //                      zz += map_nz/2;
03647 
03648                         float xx = soln[0]+map_nx/2;
03649                         float yy = soln[1]+map_ny/2;
03650                         float zz = soln[2]+map_nz/2;
03651 
03652                         int l = (x+nx/2) + (y+ny/2) * nx;
03653 
03654                         float t = xx - floor(xx);
03655                         float u = yy - floor(yy);
03656                         float v = zz - floor(zz);
03657 
03658                         if (xx < 0 || yy < 0 || zz < 0 ) {
03659                                 ddata[l] = 0;
03660                                 continue;
03661                         }
03662                         if (interpolate) {
03663                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03664                                         ddata[l] = 0;
03665                                         continue;
03666                                 }
03667                                 int k = (int) (Util::fast_floor(xx) + Util::fast_floor(yy) * map_nx + Util::fast_floor(zz) * map_nxy);
03668 
03669 
03670                                 if (xx < (map_nx - 1) && yy < (map_ny - 1) && zz < (map_nz - 1)) {
03671                                         ddata[l] = Util::trilinear_interpolate(sdata[k],
03672                                                                 sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03673                                                                 sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03674                                                                 sdata[k + map_nx + map_nxy + 1],t, u, v);
03675                                 }
03676                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03677                                         ddata[l] += sdata[k];
03678                                 }
03679                                 else if ( xx == (map_nx - 1) && yy == (map_ny - 1) ) {
03680                                         ddata[l] +=     Util::linear_interpolate(sdata[k], sdata[k + map_nxy],v);
03681                                 }
03682                                 else if ( xx == (map_nx - 1) && zz == (map_nz - 1) ) {
03683                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + map_nx],u);
03684                                 }
03685                                 else if ( yy == (map_ny - 1) && zz == (map_nz - 1) ) {
03686                                         ddata[l] += Util::linear_interpolate(sdata[k], sdata[k + 1],t);
03687                                 }
03688                                 else if ( xx == (map_nx - 1) ) {
03689                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + map_nx], sdata[k + map_nxy], sdata[k + map_nxy + map_nx],u,v);
03690                                 }
03691                                 else if ( yy == (map_ny - 1) ) {
03692                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nxy], sdata[k + map_nxy + 1],t,v);
03693                                 }
03694                                 else if ( zz == (map_nz - 1) ) {
03695                                         ddata[l] += Util::bilinear_interpolate(sdata[k], sdata[k + 1], sdata[k + map_nx], sdata[k + map_nx + 1],t,u);
03696                                 }
03697 
03698 //                              if (k >= map->get_size()) {
03699 //                                      cout << xx << " " << yy << " " <<  zz << " " << endl;
03700 //                                      cout << k << " " << get_size() << endl;
03701 //                                      cout << get_xsize() << " " << get_ysize() << " " << get_zsize() << endl;
03702 //                                      throw;
03703 //                                      }
03704 //
03705 //                              ddata[l] = Util::trilinear_interpolate(sdata[k],
03706 //                                              sdata[k + 1], sdata[k + map_nx],sdata[k + map_nx + 1],
03707 //                                              sdata[k + map_nxy], sdata[k + map_nxy + 1], sdata[k + map_nx + map_nxy],
03708 //                                              sdata[k + map_nx + map_nxy + 1],t, u, v);
03709                         }
03710                         else {
03711                                 if ( xx > map_nx - 1 || yy > map_ny - 1 || zz > map_nz - 1) {
03712                                         ddata[l] = 0;
03713                                         continue;
03714                                 }
03715                                 int k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * map_nxy;
03716                                 ddata[l] = sdata[k];
03717                         }
03718 
03719                 }
03720         }
03721 
03722         update();
03723 
03724         EXITFUNC;
03725 }

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

Printing EMData params for debugging purpose.

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

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

Referenced by del_attr_dict().

01077 {
01078         attr_dict.erase(attr_name);
01079 }

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

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

01082 {
01083         vector<string>::const_iterator it;
01084         for(it=del_keys.begin(); it!=del_keys.end(); ++it) {
01085                 this->del_attr(*it);
01086         }
01087 }

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

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

06201                                                                   {
06202         if (3 != get_ndim())
06203                 throw ImageDimensionException("delete_disconnected_regions needs a 3-D image.");
06204         if (is_complex())
06205                 throw ImageFormatException("delete_disconnected_regions requires a real image");
06206         if ((*this)(ix+nx/2,iy+ny/2,iz+nz/2) == 0)
06207                 throw ImageDimensionException("delete_disconnected_regions starting point is zero.");
06208 
06209         EMData* result = this->copy_head();
06210         result->to_zero();
06211         (*result)(ix+nx/2,iy+ny/2,iz+nz/2) = (*this)(ix+nx/2,iy+ny/2,iz+nz/2);
06212         bool kpt = true;
06213         //cout << "  delete   "<<(*result)(ix+nx/2,iy+ny/2,iz+nz/2)<<endl;
06214         while(kpt) {
06215                 kpt = false;
06216                 for (int cz = 1; cz < nz-1; cz++) {
06217                         for (int cy = 1; cy < ny-1; cy++) {
06218                                 for (int cx = 1; cx < nx-1; cx++) {
06219                                         if((*result)(cx,cy,cz) == 1) {
06220                                                 for (int lz = -1; lz <= 1; lz++) {
06221                                                         for (int ly = -1; ly <= 1; ly++) {
06222                                                                 for (int lx = -1; lx <= 1; lx++) {
06223                                                                         if(((*this)(cx+lx,cy+ly,cz+lz) == 1) && ((*result)(cx+lx,cy+ly,cz+lz) == 0))  {
06224                                                                                 (*result)(cx+lx,cy+ly,cz+lz) = 1;
06225                                                                                 kpt = true;
06226                                                                         }
06227                                                                 }
06228                                                         }
06229                                                 }
06230                                         }
06231                                 }
06232                         }
06233                 }
06234         }
06235         result->update();
06236         return result;
06237 }

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

06446                    {
06447         if (is_complex())
06448                 throw ImageFormatException("Depadding of complex images not supported");
06449         vector<int> saved_offsets = get_array_offsets();
06450         set_array_offsets(0,0,0);
06451         int npad = attr_dict["npad"];
06452         if (0 == npad) npad = 1;
06453         int offset = is_fftodd() ? 1 : 2;
06454         int nxold = (nx - offset)/npad;
06455 #ifdef _WIN32
06456         int nyold = _cpp_max(ny/npad, 1);
06457         int nzold = _cpp_max(nz/npad, 1);
06458 #else
06459         int nyold = std::max<int>(ny/npad, 1);
06460         int nzold = std::max<int>(nz/npad, 1);
06461 #endif  //_WIN32
06462         int xstart = 0, ystart = 0, zstart = 0;
06463         if( npad > 1) {
06464                 xstart = (nx - offset - nxold)/2 + nxold%2;
06465                 if(ny > 1) {
06466                         ystart = (ny - nyold)/2 + nyold%2;
06467                         if(nz > 1) {
06468                                 zstart = (nz - nzold)/2 + nzold%2;
06469                         }
06470                 }
06471         }
06472         int bytes = nxold*sizeof(float);
06473         float* dest = get_data();
06474         for (int iz=0; iz < nzold; iz++) {
06475                 for (int iy = 0; iy < nyold; iy++) {
06476                         memmove(dest, &(*this)(xstart,iy+ystart,iz+zstart), bytes);
06477                         dest += nxold;
06478                 }
06479         }
06480         set_size(nxold, nyold, nzold);
06481         set_attr("npad", 1);
06482         set_fftpad(false);
06483         set_fftodd(false);
06484         set_complex(false);
06485         if(ny==1 && nz==1) set_complex_x(false);
06486         set_array_offsets(saved_offsets);
06487         update();
06488         EXITFUNC;
06489 }

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

06498                           {
06499         if(is_complex())
06500                 throw ImageFormatException("Depadding of complex images not allowed");
06501         vector<int> saved_offsets = get_array_offsets();
06502         set_array_offsets(0,0,0);
06503         int npad = attr_dict["npad"];
06504         if(0 == npad) npad = 1;
06505         int offset = is_fftodd() ? 1 : 2;
06506         int nxold = (nx - offset)/npad;
06507 #ifdef _WIN32
06508         int nyold = _cpp_max(ny/npad, 1);
06509         int nzold = _cpp_max(nz/npad, 1);
06510 #else
06511         int nyold = std::max<int>(ny/npad, 1);
06512         int nzold = std::max<int>(nz/npad, 1);
06513 #endif  //_WIN32
06514         int bytes = nxold*sizeof(float);
06515         float* dest = get_data();
06516         for (int iz=0; iz < nzold; iz++) {
06517                 for (int iy = 0; iy < nyold; iy++) {
06518                         memmove(dest, &(*this)(0,iy,iz), bytes);
06519                         dest += nxold;
06520                 }
06521         }
06522         set_size(nxold, nyold, nzold);
06523         set_attr("npad", 1);
06524         set_fftpad(false);
06525         set_fftodd(false);
06526         set_complex(false);
06527         if(ny==1 && nz==1) set_complex_x(false);
06528         set_array_offsets(saved_offsets);
06529         update();
06530         EXITFUNC;
06531 }

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

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

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

References InvalidValueException, and mult().

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

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

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

04197                                                  {
04198         
04199         if (is_complex())
04200                 throw ImageFormatException("divkbsinh requires a real image.");
04201         vector<int> saved_offsets = get_array_offsets();
04202         set_array_offsets(0,0,0);
04203         // Note that the following loops will work for 1-, 2-, and 3-D
04204         // images, since the "extra" weights will be 1.0.  (For example,
04205         // for a 2-d image iz=0, nz=1, so iz-nz/2 = 0 - 1/2 = 0, since
04206         // the division is an integer division.)
04207         for (int iz=0; iz < nz; iz++) {
04208                 float wz = kb.sinhwin(static_cast<float>(iz-nz/2));
04209                 for (int iy=0; iy < ny; iy++) {
04210                         float wy = kb.sinhwin(static_cast<float>(iy-ny/2));
04211                         for (int ix=0; ix < nx; ix++) {
04212                                 float wx = kb.sinhwin(static_cast<float>(ix-nx/2));
04213                                 float w = wx*wy*wz;
04214                                 (*this)(ix,iy,iz) /= w;
04215                         }
04216                 }
04217         }
04218         set_array_offsets(saved_offsets);
04219 }

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

Definition at line 4221 of file emdata_sparx.cpp.

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

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

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 214 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(), EMAN::FourierReconstructorSimple2D::insert_slice(), 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().

00215 {
00216         ENTERFUNC;
00217 
00218         if ( is_complex() ) {
00219                 LOGERR("real image expected. Input image is complex image.");
00220                 throw ImageFormatException("real image expected. Input image is complex image.");
00221         }
00222 
00223         size_t offset;
00224         int nxreal;
00225         get_data(); // Required call if GPU caching is being used. Otherwise harmless
00226         if (!is_fftpadded()) {
00227                 // need to extend the matrix along x
00228                 // meaning nx is the un-fftpadded size
00229                 nxreal = nx;
00230                 offset = 2 - nx%2;
00231                 if (1 == offset) set_fftodd(true);
00232                 else             set_fftodd(false);
00233                 int nxnew = nx + offset;
00234                 set_size(nxnew, ny, nz);
00235 
00236                 for (int iz = nz-1; iz >= 0; iz--) {
00237                         for (int iy = ny-1; iy >= 0; iy--) {
00238                                 for (int ix = nxreal-1; ix >= 0; ix--) {
00239                                         size_t oldxpos = ix + (iy + iz*ny)*nxreal;
00240                                         size_t newxpos = ix + (iy + iz*ny)*nxnew;
00241                                         (*this)(newxpos) = (*this)(oldxpos);
00242                                 }
00243                         }
00244                 }
00245                 set_fftpad(true);
00246         } else {
00247                 offset = is_fftodd() ? 1 : 2;
00248                 nxreal = nx - offset;
00249         }
00250         EMfft::real_to_complex_nd(rdata, rdata, nxreal, ny, nz);
00251 
00252         set_complex(true);
00253         if(ny==1 && nz==1)  set_complex_x(true);
00254         set_ri(true);
00255 
00256         update();
00257 
00258         EXITFUNC;
00259         return this;
00260 }

EMData * EMData::do_ift_inplace  ) 
 

Definition at line 332 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(), set_size(), 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().

00333 {
00334         ENTERFUNC;
00335 
00336         if (!is_complex()) {
00337                 LOGERR("complex image expected. Input image is real image.");
00338                 throw ImageFormatException("complex image expected. Input image is real image.");
00339         }
00340 
00341         if (!is_ri()) {
00342                 LOGWARN("run IFT on AP data, only RI should be used. ");
00343         }
00344         ap2ri();
00345 
00346         int offset = is_fftodd() ? 1 : 2;
00347         float* data = get_data();
00348         EMfft::complex_to_real_nd(data, data, nx - offset, ny, nz);
00349 
00350 #if defined     FFTW2 || defined FFTW3 || defined CUDA_FFT      //native fft and ACML already done normalization
00351         // SCALE the inverse FFT
00352         int nxo = nx - offset;
00353         float scale = 1.0f / (nxo * ny * nz);
00354         mult(scale);
00355 #endif //FFTW2 || FFTW3
00356 
00357 #ifndef CUDA_FFT
00358         set_fftpad(true);
00359 #else
00360         set_size(nx - offset, ny, nz);
00361 #endif
00362         set_complex(false);
00363         if(ny==1 && nz==1) set_complex_x(false);
00364         set_ri(false);
00365         update();
00366 
00367 
00368         EXITFUNC;
00369         return this;
00370 }

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

01341 {
01342         ENTERFUNC;
01343 
01344         if (get_ndim() != 2) {
01345                 throw ImageDimensionException("2D only");
01346         }
01347 
01348         if (nx != ny) {
01349                 throw ImageFormatException("square image only");
01350         }
01351 
01352         EMData *result = new EMData();
01353         result->set_size(nx, ny, 1);
01354         result->to_zero();
01355         float *result_data = result->get_data();
01356 
01357         EMData *this_copy = this;
01358         this_copy = copy();
01359 
01360         for (int i = 0; i < nx; i++) {
01361                 Transform t(Dict("type","2d","alpha",(float) M_PI * 2.0f * i / nx));
01362                 this_copy->transform(t);
01363 
01364                 float *copy_data = this_copy->get_data();
01365 
01366                 for (int y = 0; y < nx; y++) {
01367                         for (int x = 0; x < nx; x++) {
01368                                 if (Util::square(x - nx / 2) + Util::square(y - nx / 2) <= nx * nx / 4) {
01369                                         result_data[i + y * nx] += copy_data[x + y * nx];
01370                                 }
01371                         }
01372                 }
01373 
01374                 this_copy->update();
01375         }
01376 
01377         result->update();
01378 
01379         if( this_copy )
01380         {
01381                 delete this_copy;
01382                 this_copy = 0;
01383         }
01384 
01385         EXITFUNC;
01386         return result;
01387 }

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

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

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

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

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

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

Referenced by refalifnfast().

01167 {
01168         ENTERFUNC;
01169 
01170         if (!EMUtil::is_same_size(this, with)) {
01171                 LOGERR("images not same size");
01172                 throw ImageFormatException("images not same size");
01173         }
01174 
01175         if (get_ndim() == 3) {
01176                 LOGERR("1D/2D Images only");
01177                 throw ImageDimensionException("1D/2D only");
01178         }
01179 
01180         float *this_data = 0;
01181 
01182         this_data = get_data();
01183 
01184         float da_rad = da*(float)M_PI/180.0f;
01185 
01186         float *with_data = with->get_data();
01187         float mx0 = cos(da_rad);
01188         float mx1 = sin(da_rad);
01189         float y = -ny / 2.0f;
01190         float my0 = mx0 * (-nx / 2.0f - 1.0f) + nx / 2.0f - dx;
01191         float my1 = -mx1 * (-nx / 2.0f - 1.0f) + ny / 2.0f - dy;
01192         double result = 0;
01193 
01194         for (int j = 0; j < ny; j++) {
01195                 float x2 = my0 + mx1 * y;
01196                 float y2 = my1 + mx0 * y;
01197 
01198                 int ii = Util::fast_floor(x2);
01199                 int jj = Util::fast_floor(y2);
01200                 float t = x2 - ii;
01201                 float u = y2 - jj;
01202 
01203                 for (int i = 0; i < nx; i++) {
01204                         t += mx0;
01205                         u -= mx1;
01206 
01207                         if (t >= 1.0f) {
01208                                 ii++;
01209                                 t -= 1.0f;
01210                         }
01211 
01212                         if (u >= 1.0f) {
01213                                 jj++;
01214                                 u -= 1.0f;
01215                         }
01216 
01217                         if (t < 0) {
01218                                 ii--;
01219                                 t += 1.0f;
01220                         }
01221 
01222                         if (u < 0) {
01223                                 jj--;
01224                                 u += 1.0f;
01225                         }
01226 
01227                         if (ii >= 0 && ii <= nx - 2 && jj >= 0 && jj <= ny - 2) {
01228                                 int k0 = ii + jj * nx;
01229                                 int k1 = k0 + 1;
01230                                 int k2 = k0 + nx + 1;
01231                                 int k3 = k0 + nx;
01232 
01233                                 float tt = 1 - t;
01234                                 float uu = 1 - u;
01235                                 int idx = i + j * nx;
01236                                 if (mirror) idx = nx-1-i+j*nx; // mirroring of Transforms is always about the y axis
01237                                 result += (this_data[k0] * tt * uu + this_data[k1] * t * uu +
01238                                                    this_data[k2] * t * u + this_data[k3] * tt * u) * with_data[idx];
01239                         }
01240                 }
01241                 y += 1.0f;
01242         }
01243 
01244         EXITFUNC;
01245         return result;
01246 }

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

Definition at line 3238 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.

03238                                                             {
03239 
03240         /*int M = kb.get_sB_size();
03241         int kbmin = -M/2;
03242         int kbmax = -kbmin;*/
03243 
03244         int nxn, nyn, nzn;
03245         nxn = (int)(nx*scale); nyn = (int)(ny*scale); nzn = (int)(nz*scale);
03246 
03247         vector<int> saved_offsets = get_array_offsets();
03248         set_array_offsets(0,0,0);
03249         EMData* ret = this->copy_head();
03250 #ifdef _WIN32
03251         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03252 #else
03253         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03254 #endif  //_WIN32
03255         ret->to_zero();  //we will leave margins zeroed.
03256 
03257         // scan new, find pixels in old
03258         for (int iy =0; iy < nyn; iy++) {
03259                 float y = float(iy)/scale;
03260                 for (int ix = 0; ix < nxn; ix++) {
03261                         float x = float(ix)/scale;
03262                         (*ret)(ix,iy) = this->get_pixel_filtered(x, y, 1.0f, kb);
03263                 }
03264         }
03265         set_array_offsets(saved_offsets);
03266         return ret;
03267 }

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

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

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

Definition at line 4476 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.

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

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

Definition at line 4703 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.

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

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

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

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

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

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

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

04012                          {
04013         if (!is_complex())
04014                 throw ImageFormatException("fft_shuffle requires a fourier image");
04015         vector<int> offsets = get_array_offsets();
04016         set_array_offsets(); // clear offsets before shuffling
04017         EMData& self = *this;
04018         int nyhalf = ny/2;
04019         int nzhalf = nz/2;
04020         int nbytes = nx*sizeof(float);
04021         float* temp = new float[nx];
04022         for (int iz=0; iz < nz; iz++)
04023                 for (int iy=0; iy < nyhalf; iy++)
04024                         swapx(&self(0,iy,iz),&self(0,iy+nyhalf,iz),temp,nbytes);
04025         if (nz > 1) {
04026                 for (int iy=0; iy < ny; iy++)
04027                         for (int iz=0; iz < nzhalf; iz++)
04028                                 swapx(&self(0,iy,iz),&self(0,iy,iz+nzhalf),temp,nbytes);
04029         }
04030         set_shuffled(!is_shuffled()); // toggle
04031         set_array_offsets(offsets); // reset offsets
04032         update();
04033         delete[] temp;
04034 }

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

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

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

00445 {
00446         EMData* FFT= FH2F(Size,OverSamplekB,0);
00447         FFT->process_inplace("xform.fourierorigin.tocorner");
00448         EMData* eguess= FFT ->do_ift();
00449         return eguess;
00450 }  // ends FH2F

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

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

07235                                                            {
07236 
07237 
07238         bool   complex_input = this->is_complex();
07239         nx  = this->get_xsize();
07240         ny  = this->get_ysize();
07241         nz  = this->get_zsize();
07242         int nox;
07243         if (complex_input) nox = (nx - 2 + this->is_fftodd()); else nox = nx;
07244 
07245         int lsd2 = (nox + 2 - nox%2) / 2; // Extended x-dimension of the complex image
07246 
07247         EMData* fp = NULL; // output image
07248         if(complex_input) {
07249                 // fimage must remain pristine
07250                 fp = this->copy();
07251         } else {
07252                 fp = this->norm_pad( false, 1);
07253                 fp->do_fft_inplace();
07254         }
07255         fp->set_array_offsets(1,1,1);
07256         int nx2 = nox/2;
07257         int ny2 = ny/2;
07258         int nz2 = nz/2;
07259         float *fint = image->get_data();
07260         for ( int iz = 1; iz <= nz; iz++) {
07261                 int jz=nz2-iz+1; if(jz<0) jz += nz;
07262                 for ( int iy = 1; iy <= ny; iy++) {
07263                         int jy=ny2-iy+1; if(jy<0) jy += ny;
07264                         for ( int ix = 1; ix <= lsd2; ix++) {
07265                                 int jx = nx2-ix+1;
07266                                 fp->cmplx(ix,iy,iz) *= fint(jx,jy,jz);
07267                         }
07268                 }
07269         }
07270 
07271         fp->set_ri(1);
07272         fp->set_fftpad(true);
07273         fp->set_attr("npad", 1);
07274         if (nx%2 == 1) fp->set_fftodd(true);
07275         else fp->set_fftodd(false);
07276         if(RetReal) {
07277                 fp->do_ift_inplace();
07278                 fp->depad();
07279         }
07280         fp->set_array_offsets(0,0,0);
07281         fp->update();
07282 
07283         return fp;
07284 }

float EMData::find_3d_threshold float  mass,
float  pixel_size
 

Definition at line 5947 of file emdata_sparx.cpp.

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

05948 {
05949         /* Exception Handle */
05950         if(get_ndim()!=3)
05951                 throw ImageDimensionException("The image should be 3D");
05952         /* ===============================================================*/
05953 
05954         /* Calculation of the volume of the voxels */
05955         float density_1_mole, vol_1_mole, vol_angstrom;
05956         int  vol_voxels;
05957         density_1_mole = static_cast<float>( (mass*1000.0f)/avagadro );
05958         vol_1_mole =  static_cast<float>( density_1_mole/density_protein );
05959         vol_angstrom =  static_cast<float>( vol_1_mole*(double)pow((double)pow(10.0,8),3) );
05960         vol_voxels = static_cast<int> (vol_angstrom/(double)pow(pixel_size,3));
05961         /* ===============================================================*/
05962 
05963 
05964         float thr1 = get_attr("maximum");
05965         float thr3 = get_attr("minimum");
05966         float thr2 = (thr1-thr3)/2 + thr3;
05967         int size = nx*ny*nz;
05968         float x0 = thr1,x3 = thr3,x1,x2,THR=0;
05969 
05970         #ifdef _WIN32
05971                 int ILE = _cpp_min(nx*ny*nx,_cpp_max(1,vol_voxels));
05972         #else
05973                 int ILE = std::min(nx*ny*nx,std::max(1,vol_voxels));
05974         #endif  //_WIN32
05975 
05976         if (abs(thr3-thr2)>abs(thr2-thr1)) {
05977                 x1=thr2;
05978                 x2=thr2+C*(thr3-thr2);
05979         } else {
05980                 x2=thr2;
05981                 x1=thr2-C*(thr2-thr1);
05982         }
05983 
05984         int cnt1=0,cnt2=0;
05985         for (int i=0;i<size;i++) {
05986                 if(rdata[i]>=x1)  cnt1++;
05987                 if(rdata[i]>=x2)  cnt2++;
05988         }
05989         float LF1 = static_cast<float>( cnt1 - ILE );
05990         float F1 = LF1*LF1;
05991         float LF2 = static_cast<float>( cnt2 - ILE );
05992         float F2 = LF2*LF2;
05993 
05994         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)))
05995         {
05996                 if(F2 < F1) {
05997                         x0=x1;
05998                         x1=x2;
05999                         x2 = R*x1 + C*x3;
06000                         F1=F2;
06001                         int cnt=0;
06002                         for(int i=0;i<size;i++)
06003                                 if(rdata[i]>=x2)
06004                                         cnt++;
06005                         LF2 = static_cast<float>( cnt - ILE );
06006                         F2 = LF2*LF2;
06007                 } else {
06008                         x3=x2;
06009                         x2=x1;
06010                         x1=R*x2 + C*x0;
06011                         F2=F1;
06012                         int cnt=0;
06013                         for(int i=0;i<size;i++)
06014                                 if(rdata[i]>=x1)
06015                                         cnt++;
06016                         LF1 = static_cast<float>( cnt - ILE );
06017                         F1 = LF1*LF1;
06018                 }
06019         }
06020 
06021         if(F1 < F2) {
06022                 ILE = static_cast<int> (LF1 + ILE);
06023                 THR = x1;
06024         } else {
06025                 ILE = static_cast<int> (LF2 + ILE);
06026                 THR = x2;
06027         }
06028         return THR;
06029 
06030 }

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

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

00575 {
00576         ENTERFUNC;
00577         
00578         if ( is_complex() ) throw ImageFormatException("Error - find_pixels_with_value real only");
00579 
00580         vector<Pixel> result;
00581 
00582         for (int k = 0; k < nz; k++) {
00583                 for (int j = 0; j < ny; j++) {
00584                         for (int i = 0; i < nx; i++) {
00585                                 if (get_value_at(i,j,k)==val) result.push_back(Pixel(i,j,k,val));
00586                         }
00587                 }
00588         }
00589 
00590         EXITFUNC;
00591         return result;
00592 }

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

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

07103                                                                  {
07104 
07105         int nyn, nzn, lsd, lsdn, inx, iny, inz;
07106         int i, j;
07107 
07108         if(ny > 1) {
07109                 nyn = nyni;
07110                 if(nz > 1) {
07111                         nzn = nzni;
07112                 }  else {
07113                         nzn = 1;
07114                 }
07115         } else {
07116                 nyn = 1; nzn = 1;
07117         }
07118         lsd = nx-2 + 2 - nx%2;
07119         lsdn = nxn + 2 - nxn%2;
07120 //  do out of place ft
07121         EMData *temp_ft = this->copy();
07122         EMData *ret = this->copy();
07123         ret->set_size(lsdn, nyn, nzn);
07124         ret->to_zero();
07125         float *fout = ret->get_data();
07126         float *fint = temp_ft->get_data();
07127 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07128 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07129 //      float  sq2 = 1.0f/std::sqrt(2.0f);
07130         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
07131         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
07132         inx = nxn-(nx-2); iny = nyn - ny; inz = nzn - nz;
07133         for (j=1; j<=nyn; j++)
07134                 for (i=1; i<=lsdn; i++)
07135                         fout(i,j,1)=fint((i-1)/2*4+2-i%2,j*2-1,1);
07136         ret->set_complex(true);
07137         ret->set_ri(1);
07138         //ret->set_fftpad(true);
07139         //ret->set_attr("npad", 1);
07140         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07141         if(RetReal) {
07142                 ret->do_ift_inplace();
07143                 ret->depad();
07144         }
07145         ret->update();
07146 
07147         delete temp_ft;
07148         temp_ft = 0;
07149         return ret;
07150 }

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

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

07152                                                                         {
07153 
07154         int nyn, nzn, lsd, lsdn, inx, iny, inz;
07155         int i, j;
07156 
07157         nyn = nyni;
07158         nzn = 1;
07159         lsd = nx;
07160         lsdn = nxn + 2 - nxn%2;
07161 
07162         EMData *temp_ft = this->copy();
07163         EMData *ret = this->copy();
07164         ret->set_size(lsdn, nyn, nzn);
07165         ret->to_zero();
07166         float *fout = ret->get_data();
07167         float *fint = temp_ft->get_data();
07168 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
07169 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
07170         float  sq2 = 1.0f/std::sqrt(2.0f);
07171 
07172         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= 4;
07173 
07174         inx = nxn-(nx-2); iny = nyn - ny; inz = nzn - nz;
07175         for (j=1; j<=ny/4; j++)
07176                 for (i=1; i<=(nx-2)/2+2; i++) {
07177                         int g = (i-1)/2+1;
07178                         if ((g+j)%2 == 0) {
07179                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1+ny/2,1);
07180                         } else {
07181                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1+ny/2,1);
07182                         }
07183                 }
07184 
07185         for (j=ny/4+1; j<=ny/4+1; j++)
07186                 for (i=1; i<=(nx-2)/2+2; i++) {
07187                         int g = (i-1)/2+1;
07188                         if ((g+j)%2 == 0) {
07189                                 fout(i,j,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07190                         } else {
07191                                 fout(i,j,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07192                         }
07193                 }
07194 
07195         for (j=ny/4+2; j<=ny/2; j++)
07196                 for (i=1; i<=(nx-2)/2+2; i++) {
07197                         int g = (i-1)/2+1;
07198                         if ((g+j)%2 == 0) {
07199                                 fout(i,j+ny/2,1)=fint(g*4-2-i%2,j*2-1-ny/2,1);
07200                         } else {
07201                                 fout(i,j+ny/2,1)=-fint(g*4-2-i%2,j*2-1-ny/2,1);
07202                         }
07203                 }
07204 
07205         if (nx%2 == 0) {
07206                 for (j=1; j<=nyn; j++) {
07207                         fout((nx-2)/2+1,j,1) *= sq2;
07208                         fout((nx-2)/2+2,j,1) *= sq2;
07209                 }
07210                 for (i=1; i<=lsd/2+1; i++) {
07211                         fout(i,ny/4+1+ny/2,1) = sq2*fout(i,ny/4+1,1);
07212                         fout(i,ny/4+1,1) *= sq2;
07213                 }
07214         }
07215 
07216         ret->set_complex(true);
07217         ret->set_ri(1);
07218 
07219         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
07220         if(RetReal) {
07221                 ret->do_ift_inplace();
07222                 ret->depad();
07223         }
07224         ret->update();
07225 
07226         delete temp_ft;
07227         temp_ft = 0;
07228         return ret;
07229 }

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

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

04107                                                                              {
04108         if (2 != get_ndim())
04109                 throw ImageDimensionException("fouriergridrot2d needs a 2-D image.");
04110         if (!is_complex())
04111                 throw ImageFormatException("fouriergridrot2d requires a fourier image");
04112         int nxreal = nx - 2 + int(is_fftodd());
04113         if (nxreal != ny)
04114                 throw ImageDimensionException("fouriergridrot2d requires ny == nx(real)");
04115         if (0 != nxreal%2)
04116                 throw ImageDimensionException("fouriergridrot2d needs an even image.");
04117         if (scale == 0.0f) scale = 1.0f;
04118         int nxhalf = nxreal/2;
04119         int nyhalf = ny/2;
04120         float cir = (float)((nxhalf-1)*(nxhalf-1));
04121 
04122         if (!is_shuffled()) fft_shuffle();
04123 
04124         EMData* result = copy_head();
04125         set_array_offsets(0,-nyhalf);
04126         result->set_array_offsets(0,-nyhalf);
04127 
04128 
04129 
04130         ang = ang*(float)DGR_TO_RAD;
04131         float cang = cos(ang);
04132         float sang = sin(ang);
04133         for (int iy = -nyhalf; iy < nyhalf; iy++) {
04134                 float ycang = iy*cang;
04135                 float ysang = iy*sang;
04136                 for (int ix = 0; ix <= nxhalf; ix++) {
04137                         float nuxold = (ix*cang - ysang)*scale;
04138                         float nuyold = (ix*sang + ycang)*scale;
04139                         if (nuxold*nuxold+nuyold*nuyold<cir) result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04140                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04141                 }
04142         }
04143         result->set_array_offsets();
04144         result->fft_shuffle(); // reset to an unshuffled result
04145         result->update();
04146         set_array_offsets();
04147         fft_shuffle(); // reset to an unshuffled complex image
04148         return result;
04149 }

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

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

04151                                                                                           {
04152         if (2 != get_ndim())
04153                 throw ImageDimensionException("fouriergridrot_shift2d needs a 2-D image.");
04154         if (!is_complex())
04155                 throw ImageFormatException("fouriergridrot_shift2d requires a fourier image");
04156         int nxreal = nx - 2 + int(is_fftodd());
04157         if (nxreal != ny)
04158                 throw ImageDimensionException("fouriergridrot_shift2d requires ny == nx(real)");
04159         if (0 != nxreal%2)
04160                 throw ImageDimensionException("fouriergridrot_shift2d needs an even image.");
04161         int nxhalf = nxreal/2;
04162         int nyhalf = ny/2;
04163 
04164         if (!is_shuffled()) fft_shuffle();
04165 
04166         EMData* result = copy_head();
04167         set_array_offsets(0, -nyhalf);
04168         result->set_array_offsets(0, -nyhalf);
04169 
04170         ang = ang*(float)DGR_TO_RAD;
04171         float cang = cos(ang);
04172         float sang = sin(ang);
04173         float temp = -2.0f*M_PI/nxreal;
04174         for (int iy = -nyhalf; iy < nyhalf; iy++) {
04175                 float ycang = iy*cang;
04176                 float ysang = iy*sang;
04177                 for (int ix = 0; ix <= nxhalf; ix++) {
04178                         float nuxold = ix*cang - ysang;
04179                         float nuyold = ix*sang + ycang;
04180                         result->cmplx(ix,iy) = Util::extractpoint2(nx, ny, nuxold, nuyold, this, kb);
04181                         //result->cmplx(ix,iy) = extractpoint(nuxold, nuyold, kb);
04182                         float phase_ang = temp*(sx*ix+sy*iy);
04183                         result->cmplx(ix,iy) *= complex<float>(cos(phase_ang), sin(phase_ang));
04184                 }
04185         }
04186         result->set_array_offsets();
04187         result->fft_shuffle(); // reset to an unshuffled result
04188         result->update();
04189         set_array_offsets();
04190         fft_shuffle(); // reset to an unshuffled complex image
04191         return result;
04192 }

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

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

06766                                                                       {
06767 
06768         int nyn, nzn, lsd, lsdn, inx, iny, inz;
06769         int i, j, k;
06770         if (is_complex())
06771                 throw ImageFormatException("Input image has to be real");
06772 
06773         if(ny > 1) {
06774                 nyn = nyni;
06775                 if(nz > 1) {
06776                         nzn = nzni;
06777                 }  else {
06778                         nzn = 1;
06779                 }
06780         } else {
06781                 nyn = 1; nzn = 1;
06782         }
06783         if(nxn<nx || nyn<ny || nzn<nz)  throw ImageDimensionException("Cannot reduce the image size");
06784         lsd = nx + 2 - nx%2;
06785         lsdn = nxn + 2 - nxn%2;
06786 //  do out of place ft
06787         EMData *temp_ft = do_fft();
06788         EMData *ret = this->copy();
06789         ret->set_size(lsdn, nyn, nzn);
06790         ret->to_zero();
06791         float *fout = ret->get_data();
06792         float *fint = temp_ft->get_data();
06793 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
06794 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
06795         float  sq2 = 1.0f/std::sqrt(2.0f);
06796         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
06797         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
06798         inx = nxn-nx; iny = nyn - ny; inz = nzn - nz;
06799         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);
06800         if(nyn>1) {
06801         //cout << "  " <<nxn<<"  " <<nyn<<" A " <<nzn<<endl;
06802                 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);
06803                 if(nzn>1) {
06804                         for (k=nz/2+2+inz; k<=nzn; k++) {
06805                                 for (j=1; j<=ny/2+1; j++) {
06806                                         for (i=1; i<=lsd; i++) {
06807                                                 fout(i,j,k)=fint(i,j,k-inz);
06808                                         }
06809                                 }
06810                                 for (j=ny/2+2+iny; j<=nyn; j++) {
06811                                         for (i=1; i<=lsd; i++) {
06812                                                 fout(i,j,k)=fint(i,j-iny,k-inz);
06813                                         }
06814                                 }
06815                         }
06816                 }
06817         }
06818 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
06819 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
06820 //       ELEMENT.
06821         if(nx%2 == 0 && inx !=0) {
06822                 for (k=1; k<=nzn; k++) {
06823                         for (j=1; j<=nyn; j++) {
06824                                 fout(nx+1,j,k) *= sq2;
06825                                 fout(nx+2,j,k) *= sq2;
06826                         }
06827                 }
06828                 if(nyn>1) {
06829                         for (k=1; k<=nzn; k++) {
06830                           for (i=1; i<=lsd; i++) {
06831                             fout(i,ny/2+1+iny,k) = sq2*fout(i,ny/2+1,k);
06832                             fout(i,ny/2+1,k) *= sq2;
06833                           }
06834                         }
06835                         if(nzn>1) {
06836                                 for (j=1; j<=nyn; j++) {
06837                                         for (i=1; i<=lsd; i++) {
06838                                                 fout(i,j,nz/2+1+inz) = sq2*fout(i,j,nz/2+1);
06839                                                 fout(i,j,nz/2+1) *= sq2;
06840                                         }
06841                                 }
06842                         }
06843                 }
06844         }
06845         ret->set_complex(true);
06846 /*
06847 //  For padding from odd to even dimension additional shift by 1 pixel is necessary.
06848         float  xshift = 0.f, yshift = 0.f, zshift = 0.f;
06849         int nyn2, nzn2;
06850         if(nxn > nx && nx%2 == 1)  xshift = 1.0f;
06851         if(ny > 1) {
06852                 if(nyn > ny && ny%2 == 1)  yshift = 1.0f;
06853                 nyn2 = nyn/2;
06854                 if(nz > 1) {
06855                         if(nzn > nz && nz%2 == 1)  zshift = 1.0f;
06856                         nzn2 = nzn/2;
06857                 }  else {
06858                         nzn2 = 0;
06859                 }
06860         } else {
06861                 nyn2 = 0; nzn2 = 0;
06862         }
06863         if(xshift == 1.0 || yshift == 1.0 || zshift == 1.0)  {
06864                 ret->set_array_offsets(1,1,1);
06865                 int  lsdn2 = lsd/2;
06866                 for (int iz = 1; iz <= nzn; iz++) {
06867                         int jz=iz-1; if(jz>nzn2) jz=jz-nzn;
06868                         for (int iy = 1; iy <= nyn; iy++) {
06869                                 int jy=iy-1; if(jy>nyn2) jy=jy-nyn;
06870                                 for (int ix = 1; ix <= lsdn2; ix++) {
06871                                         int jx=ix-1;
06872                                         ret->cmplx(ix,iy,iz) *=
06873                                         exp(-float(twopi)*iimag*(xshift*jx/nxn + yshift*jy/nyn+ zshift*jz/nzn));
06874                                 }
06875                         }
06876                 }
06877                 ret->set_array_offsets(0,0,0);
06878         }*/
06879         ret->set_ri(1);
06880         ret->set_fftpad(true);
06881         ret->set_attr("npad", 1);
06882         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
06883         if(RetReal) {
06884                 ret->do_ift_inplace();
06885                 ret->depad();
06886         }
06887         ret->update();
06888 
06889         /*Dict d1 = temp_ft->get_attr_dict();
06890         Dict d2 = ret->get_attr_dict();
06891         printf("-----------------Attribute Dict for temp_ft--------------\n");
06892         EMUtil::dump_dict(d1);
06893         printf("-----------------Attribute Dict for ret--------------\n");
06894         EMUtil::dump_dict(d2);*/
06895         delete temp_ft;
06896         temp_ft = 0;
06897         return ret;
06898 }

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

06900                                                                       {
06901 
06902         int nyn, nzn, lsd, lsdn, inx, iny, inz;
06903         int i, j, k;
06904         float  *fint;
06905         EMData *temp_ft = NULL;
06906         //if (is_complex())
06907         //      throw ImageFormatException("Input image has to be real");
06908 
06909         if(ny > 1) {
06910                 nyn = nyni;
06911                 if(nz > 1) {
06912                         nzn = nzni;
06913                 }  else {
06914                         nzn = 1;
06915                 }
06916         } else {
06917                 nyn = 1; nzn = 1;
06918         }
06919         if (is_complex()) {
06920                 nx = nx - 2 + nx%2;
06921                 fint = get_data();
06922         } else {
06923                 //  do out of place ft
06924                 temp_ft = do_fft();
06925                 fint = temp_ft->get_data();
06926         }
06927         if(nxn>nx || nyn>ny || nzn>nz)  throw ImageDimensionException("Cannot increase the image size");
06928         lsd = nx + 2 - nx%2;
06929         lsdn = nxn + 2 - nxn%2;
06930         EMData *ret = this->copy_head();
06931         ret->set_size(lsdn, nyn, nzn);
06932         float *fout = ret->get_data();
06933 //  TO KEEP EXACT VALUES ON THE ORIGINAL GRID ONE SHOULD USE
06934 //  SQ2     = 2.0. HOWEVER, TOTAL ENERGY WILL NOT BE CONSERVED
06935         //float  sq2 = std::sqrt(2.0f);
06936         float  anorm = (float) nxn* (float) nyn* (float) nzn/(float) nx/ (float) ny/ (float) nz;
06937         for (i = 0; i < lsd*ny*nz; i++)  fint[i] *= anorm;
06938         inx = nx - nxn;  iny = ny - nyn;  inz = nz - nzn;
06939         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);
06940         if(nyn>1) {
06941                 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);
06942                 if(nzn>1) {
06943                         for (k=nzn/2+2; k<=nzn; k++) {
06944                                 for (j=1; j<=nyn/2+1; j++) {
06945                                         for (i=1; i<=lsdn; i++) {
06946                                                 fout(i,j,k)=fint(i,j,k+inz);
06947                                         }
06948                                 }
06949                                 for (j=nyn/2+2; j<=nyn; j++) {
06950                                         for (i=1; i<=lsdn; i++) {
06951                                                 fout(i,j,k)=fint(i,j+iny,k+inz);
06952                                         }
06953                                 }
06954                         }
06955                 }
06956         }
06957 //       WEIGHTING FACTOR USED FOR EVEN NSAM. REQUIRED SINCE ADDING ZERO FOR
06958 //       INTERPOLATION WILL INTRODUCE A COMPLEX CONJUGATE FOR NSAM/2'TH
06959 //       ELEMENT.
06960         /*
06961         if(nxn%2 == 0 && inx !=0) {
06962                 for (k=1; k<=nzn; k++) {
06963                         for (j=1; j<=nyn; j++) {
06964                                 fout(nxn+1,j,k) *= sq2;
06965                                 fout(nxn+2,j,k) *= sq2;
06966                         }
06967                 }
06968                 if(nyn>1) {
06969                         for (k=1; k<=nzn; k++) {
06970                           for (i=1; i<=lsdn; i++) {
06971                             fout(i,nyn/2+1+iny,k) = sq2*fout(i,nyn/2+1,k);
06972                             fout(i,nyn/2+1,k) *= sq2;
06973                           }
06974                         }
06975                         if(nzn>1) {
06976                                 for (j=1; j<=nyn; j++) {
06977                                         for (i=1; i<=lsdn; i++) {
06978                                                 fout(i,j,nzn/2+1+inz) = sq2*fout(i,j,nzn/2+1);
06979                                                 fout(i,j,nzn/2+1) *= sq2;
06980                                         }
06981                                 }
06982                         }
06983                 }
06984         }*/
06985         ret->set_complex(true);
06986         ret->set_ri(1);
06987         ret->set_fftpad(true);
06988         ret->set_attr("npad", 1);
06989         if (nxn%2 == 1) {ret->set_fftodd(true);} else {ret->set_fftodd(false);}
06990         if(RetReal) {
06991                 ret->do_ift_inplace();
06992                 ret->depad();
06993         }
06994         ret->update();
06995 
06996         /*Dict d1 = temp_ft->get_attr_dict();
06997         Dict d2 = ret->get_attr_dict();
06998         printf("-----------------Attribute Dict for temp_ft--------------\n");
06999         EMUtil::dump_dict(d1);
07000         printf("-----------------Attribute Dict for ret--------------\n");
07001         EMUtil::dump_dict(d2);*/
07002         if (!is_complex()) {
07003                 delete temp_ft;
07004                 temp_ft = 0;
07005         }
07006         return ret;
07007 }

void EMData::free_memory  ) 
 

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

Definition at line 54 of file emdata_core.cpp.

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

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

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

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

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

00896 {
00897         const int ndims = 2;
00898         if (get_ndim() != ndims) {
00899                 throw ImageDimensionException("2D only");
00900         }
00901         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00902         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00903         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00904         boost::array<std::size_t,ndims> bases={{x0, y0}};
00905         marray.reindex(bases);
00906         return marray;
00907 }

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

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

00837 {
00838         const int ndims = 2;
00839         if (get_ndim() != ndims) {
00840                 throw ImageDimensionException("2D only");
00841         }
00842         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00843         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00844         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00845         return marray;
00846 }

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

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

00871 {
00872         const int ndims = 2;
00873         if (get_ndim() != ndims) {
00874                 throw ImageDimensionException("2D only");
00875         }
00876         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00877         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00878         boost::array<std::size_t,ndims> bases={{x0, y0}};
00879         marray.reindex(bases);
00880         return marray;
00881 }

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

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

00816 {
00817         const int ndims = 2;
00818         if (get_ndim() != ndims) {
00819                 throw ImageDimensionException("2D only");
00820         }
00821         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00822         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00823         return marray;
00824 }

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

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

00911 {
00912         const int ndims = 3;
00913         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00914         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00915         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00916         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
00917         marray.reindex(bases);
00918         return marray;
00919 }

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

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

00850 {
00851         const int ndims = 3;
00852         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00853         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00854         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00855         return marray;
00856 }

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

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

00860 {
00861         const int ndims = 3;
00862         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00863         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00864         MCArray3D* marray = new MCArray3D(cdata, dims,
00865                                                                           boost::fortran_storage_order());
00866         return marray;
00867 }

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

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

00885 {
00886         const int ndims = 3;
00887         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00888         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00889         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
00890         marray.reindex(bases);
00891         return marray;
00892 }

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

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

00828 {
00829         const int ndims = 3;
00830         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00831         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00832         return marray;
00833 }

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

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

01198 {
01199 
01200         if (thres < 0 || thres > 1){
01201                 LOGERR("threshold bust be between 0 and 1.");
01202                 throw InvalidValueException(thres, "thres: 0 <= thres <= 1");
01203         }
01204                 
01205         EMData * amps = get_fft_amplitude();
01206         vector<float> ampvector = amps->get_data_as_vector();
01207         // 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!
01208         sort (ampvector.begin(), ampvector.end()); 
01209         int thresidx = int(thres * ampvector.size());
01210         float thresamp =  ampvector[thresidx];
01211 
01212         return thresamp;
01213 }

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

Definition at line 2304 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(), 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 931 of file emdata_metadata.cpp.

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

Referenced by EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::CtfCAutoAverager::add_image(), EMAN::CtfCWautoAverager::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(), 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(), EMAN::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), EMAN::BackProjectionReconstructor::insert_slice(), little_big_dot(), main(), EMAN::PointArray::match_points(), EMAN::Util::multiref_polar_ali_2d_local(), EMAN::Util::multiref_polar_ali_2d_local_psi(), nn_ctf(), nn_ctf_applied(), nn_SSNR_ctf(), norm_pad(), EMAN::Util::pad(), EMAN::LowpassAutoBProcessor::preprocess(), EMAN::Wiener2DFourierProcessor::process(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::TomoTiltAngleWeightProcessor::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::NSigmaClampingProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::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(), EMAN::PointArray::set_from_density_map(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00932 {
00933         ENTERFUNC;
00934 
00935         size_t size = nx * ny * nz;
00936         if ((flags & EMDATA_NEEDUPD) && (key != "is_fftpad")){update_stat();} //this gives a spped up of 7.3% according to e2speedtest
00937         //update_stat();
00938         
00939         if (key == "kurtosis") {
00940                 float mean = attr_dict["mean"];
00941                 float sigma = attr_dict["sigma"];
00942 
00943                 float *data = get_data();
00944                 double kurtosis_sum = 0;
00945 
00946                 for (size_t k = 0; k < size; k++) {
00947                         float t = (data[k] - mean) / sigma;
00948                         float tt = t * t;
00949                         kurtosis_sum += tt * tt;
00950                 }
00951 
00952                 float kurtosis = (float)(kurtosis_sum / size - 3.0);
00953                 return kurtosis;
00954         }
00955         else if (key == "skewness") {
00956                 float mean = attr_dict["mean"];
00957                 float sigma = attr_dict["sigma"];
00958 
00959                 float *data = get_data();
00960                 double skewness_sum = 0;
00961                 for (size_t k = 0; k < size; k++) {
00962                         float t = (data[k] - mean) / sigma;
00963                         skewness_sum +=  t * t * t;
00964                 }
00965                 float skewness = (float)(skewness_sum / size);
00966                 return skewness;
00967         }
00968         else if (key == "median")
00969         {
00970                 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
00971                 size_t n = size;
00972                 float* tmp = new float[n];
00973                 float* d = get_data();
00974                 if (tmp == 0 ) throw BadAllocException("Error - could not create deep copy of image data");
00975                 for(size_t i=0; i < n; ++i) tmp[i] = d[i]; // should just be a memcpy
00976                 qsort(tmp, n, sizeof(float), &greaterthan);
00977                 float median;
00978                 if (n%2==1) median = tmp[n/2];
00979                 else median = (tmp[n/2-1]+tmp[n/2])/2.0f;
00980                 delete [] tmp;
00981                 return median;
00982         }
00983         else if (key == "nonzero_median")
00984         {
00985                 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
00986                 vector<float> tmp;
00987                 size_t n = size;
00988                 float* d = get_data();
00989                 for( size_t i = 0; i < n; ++i ) {
00990                         if ( d[i] != 0 ) tmp.push_back(d[i]);
00991                 }
00992                 sort(tmp.begin(), tmp.end());
00993                 unsigned int vsize = tmp.size();
00994                 float median;
00995                 if (vsize%2==1) median = tmp[vsize/2];
00996                 else median = (tmp[vsize/2-1]+tmp[vsize/2])/2.0f;
00997                 return median;
00998         }
00999         else if (key == "changecount") return EMObject(changecount);
01000         else if (key == "nx") return nx;
01001         else if (key == "ny") return ny;
01002         else if (key == "nz") return nz;
01003 
01004         if(attr_dict.has_key(key)) {
01005                 return attr_dict[key];
01006         }
01007         else {
01008                 throw NotExistingObjectException(key, "The requested key does not exist");
01009         }
01010 
01011         EXITFUNC;
01012 }

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 1014 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::nnSSNR_ctfReconstructor::insert_slice(), EMAN::nn4_ctf_rectReconstructor::insert_slice(), EMAN::nn4_ctfReconstructor::insert_slice(), EMAN::nnSSNR_Reconstructor::insert_slice(), EMAN::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierReconstructor::insert_slice(), onelinenn_ctf(), onelinenn_ctf_applied(), EMAN::padfft_slice(), and rotavg().

01015 {
01016         ENTERFUNC;
01017 
01018         if(attr_dict.has_key(key)) {
01019                 return get_attr(key);
01020         }
01021         else {
01022                 return em_obj;
01023         }
01024 
01025         EXITFUNC;
01026 }

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

01029 {
01030         update_stat();
01031         
01032         Dict tmp=Dict(attr_dict);
01033         tmp["nx"]=nx;
01034         tmp["ny"]=ny;
01035         tmp["nz"]=nz;
01036         tmp["changecount"]=changecount;
01037 
01038         return tmp;
01039 }

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

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

00649 {
00650         ENTERFUNC;
00651 
00652         static bool busy = false;
00653         static EMData *mask = 0;
00654 
00655         while (busy);
00656         busy = true;
00657 
00658         if (!mask || !EMUtil::is_same_size(this, mask)) {
00659                 if (!mask) {
00660                         mask = new EMData();
00661                 }
00662                 mask->set_size(nx, ny, nz);
00663                 mask->to_one();
00664 
00665                 float radius = (float)(ny / 2 - 2);
00666                 mask->process_inplace("mask.sharp", Dict("inner_radius", radius - 1,
00667                                                                            "outer_radius", radius + 1));
00668 
00669         }
00670         double n = 0,s=0;
00671         float *d = mask->get_data();
00672         float * data = get_data();
00673         size_t size = nx*ny*nz;
00674         for (size_t i = 0; i < size; i++) {
00675                 if (d[i]) { n+=1.0; s+=data[i]; }
00676         }
00677 
00678 
00679         float result = (float)(s/n);
00680         busy = false;
00681 
00682         EXITFUNC;
00683         return result;
00684 }

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

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

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

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

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

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

00127                                                                                     {
00128         if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return std::complex<float>(0,0);
00129 
00130         if (x<0) {
00131                 int idx=-x*2+(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nxy;
00132                 return std::complex<float>(rdata[idx],rdata[idx+1]);
00133         }
00134 
00135         int idx=x*2+(y<0?ny+y:y)*nx+(z<0?nz+z:z)*nxy;
00136         return std::complex<float>(rdata[idx],rdata[idx+1]);
00137 }

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

00119                                                                        {
00120         if (abs(x)>=nx/2 || abs(y)>ny/2) return std::complex<float>(0,0);
00121         if (x>=0 && y>=0) return std::complex<float>(rdata[ x*2+y*nx],      rdata[x*2+y*nx+1]);
00122         if (x>0 && y<0) return std::complex<float>(  rdata[ x*2+(ny+y)*nx], rdata[x*2+(ny+y)*nx+1]);
00123         if (x<0 && y>0) return std::complex<float>(  rdata[-x*2+(ny-y)*nx],-rdata[-x*2+(ny-y)*nx+1]);
00124         return std::complex<float>(rdata[-x*2-y*nx],-rdata[-x*2+-y*nx+1]);
00125 }

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

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

00147                                                                                                                                                                  {
00148 if (abs(x)>=fullnx/2 || abs(y)>fullny/2 || abs(z)>fullnz/2) return nxyz;
00149 
00150 if (x<0) {
00151         x*=-1;
00152         y*=-1;
00153         z*=-1;
00154 }
00155 if (y<0) y=fullny+y;
00156 if (z<0) z=fullnz+z;
00157 
00158 if (x<subx0||y<suby0||z<subz0||x>=subx0+nx||y>=suby0+ny||z>=subz0+nz) return nxyz;
00159 
00160 return (x-subx0)*2+(y-suby0)*(size_t)nx+(z-subz0)*(size_t)nx*(size_t)ny;
00161 }

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

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

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

00139                                                                              {
00140         if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return nxyz;
00141         if (x<0) {
00142                 return -x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00143         }
00144         return x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00145 }

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

Definition at line 1935 of file emdata.h.

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

const float* const 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 338 of file emdata.h.

References process_inplace().

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

00344 {

Ctf * EMData::get_ctf  )  const
 

Get ctf parameter of this image.

Returns:
The ctf parameter.

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

00698 {
00699         if(attr_dict.has_key("ctf")) {
00700                 EMAN1Ctf * ctf = new EMAN1Ctf();
00701                 ctf->from_vector(attr_dict["ctf"]);
00702 
00703                 return dynamic_cast<Ctf *>(ctf);
00704         }
00705         else {
00706                 return 0;
00707         }
00708 }

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 332 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::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::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_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(), 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(), 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::BackProjectionReconstructor::insert_slice(), EMAN::FourierReconstructorSimple2D::insert_slice(), 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::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_translate(), 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().

00344 {

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

Referenced by get_amplitude_thres().

00886                                                 {}

std::string EMData::get_data_pickle  )  const
 

Definition at line 1166 of file emdata_metadata.cpp.

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

01167 {
01168 //      vector<float> vf;
01169 //      vf.resize(nx*ny*nz);
01170 //      std::copy(rdata, rdata+nx*ny*nz, vf.begin());
01171 
01172         std::string vf((const char *)get_data(),nx*ny*nz*sizeof(float));
01173 
01174         return vf;
01175 }

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

References data, get_data(), nx, nx, nxy, 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().

00595 {
00596         ENTERFUNC;
00597 
00598         int di = 0;
00599         double edge_sum = 0;
00600         float edge_mean = 0;
00601         size_t nxy = nx * ny;
00602         float * data = get_data();
00603         if (nz == 1) {
00604                 for (int i = 0, j = (ny - 1) * nx; i < nx; ++i, ++j) {
00605                         edge_sum += data[i] + data[j];
00606                 }
00607                 for (size_t i = 0, j = nx - 1; i < nxy; i += nx, j += nx) {
00608                         edge_sum += data[i] + data[j];
00609                 }
00610                 edge_mean = (float)edge_sum / (nx * 2 + ny * 2);
00611         }
00612         else {
00613                 if (nx == ny && nx == nz * 2 - 1) {
00614                         for (size_t j = (nxy * (nz - 1)); j < nxy * nz; ++j, ++di) {
00615                                 edge_sum += data[j];
00616                         }
00617                 }
00618                 else {
00619                         for (size_t i = 0, j = (nxy * (nz - 1)); i < nxy; ++i, ++j, ++di) {
00620                                 edge_sum += data[i] + data[j];
00621                         }
00622                 }
00623 
00624                 int nxy2 = nx * (ny - 1);
00625                 for (int k = 1; k < nz - 1; ++k) {
00626                         size_t k2 = k * nxy;
00627                         size_t k3 = k2 + nxy2;
00628                         for (int i = 0; i < nx; ++i, ++di) {
00629                                 edge_sum += data[i + k2] + data[i + k3];
00630                         }
00631                 }
00632                 for (int k = 1; k < nz - 1; ++k) {
00633                         size_t k2 = k * nxy;
00634                         size_t k3 = nx - 1 + k2;
00635                         for (int i = 1; i < ny - 1; ++i, ++di) {
00636                                 edge_sum += data[i * nx + k2] + data[i * nx + k3];
00637                         }
00638                 }
00639 
00640                 edge_mean = (float)edge_sum / (di * 2);
00641         }
00642         EXITFUNC;
00643 
00644         return edge_mean;
00645 }

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

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

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

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

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

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

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

Definition at line 1193 of file emdata.h.

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

Get image dimension.

Returns:
image dimension.

Definition at line 884 of file emdata.h.

Referenced by ali3d_d(), EMAN::Refine3DAligner::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_rect(), insert_scaled_sum(), EMAN::FourierReconstructorSimple2D::insert_slice(), 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::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().

00886                                                 {}
00887 
00888                         int prv_nx, prv_ny, prv_nz, new_nx, new_ny, new_nz;
00889                         int xshift, yshift, zshift;
00890                         int x_iter, y_iter, z_iter;
00891                         int new_z_top, new_z_bottom, new_y_back, new_y_front, new_x_left, new_x_right;
00892                         int prv_z_top, prv_z_bottom,  prv_y_back, prv_y_front, prv_x_left, prv_x_right;
00893                 };
00894 
00895 
00896 

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

Definition at line 1242 of file emdata.h.

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

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

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

03554                                                                                       {
03555 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03556 
03557         int K     = kb.get_window_size();
03558         int kbmin = -K/2;
03559         int kbmax = -kbmin;
03560         int kbc   = kbmax+1;
03561 
03562         float pixel =0.0f;
03563         float w=0.0f;
03564 
03565         delx = restrict2(delx, nx);
03566         int inxold = int(Util::round(delx));
03567         if(ny<2) {  //1D
03568                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03569                         //  loop for ends
03570                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03571                                 float q = kb.i0win_tab(delx - inxold-m1);
03572                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03573                         }
03574                 } else {
03575                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03576                                 float q = kb.i0win_tab(delx - inxold-m1);
03577                                 pixel += (*this)(inxold+m1)*q; w+=q;
03578                         }
03579                 }
03580 
03581         } else if(nz<2) {  // 2D
03582                 dely = restrict2(dely, ny);
03583                 int inyold = int(Util::round(dely));
03584                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03585                         //  loop for strips
03586                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03587                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03588                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q; w+=q;}
03589                         }
03590                 } else {
03591                         for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03592                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2);
03593                                 pixel += (*this)(inxold+m1,inyold+m2)*q; w+=q;}
03594                         }
03595                 }
03596         } else {  //  3D
03597                 dely = restrict2(dely, ny);
03598                 int inyold = int(Util::round(dely));
03599                 delz = restrict2(delz, nz);
03600                 int inzold = int(Util::round(delz));
03601                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03602                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03603                         //  loop for strips
03604                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03605                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03606                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03607                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03608                         }
03609                 } else {
03610                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03611                                 float q = kb.i0win_tab(delx - inxold-m1)*kb.i0win_tab(dely - inyold-m2)*kb.i0win_tab(delz - inzold-m3);
03612                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03613                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03614                         }
03615                 }
03616         }
03617         return pixel/w;
03618 }

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

Definition at line 3698 of file emdata_sparx.cpp.

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

03698                                                                                        {
03699 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03700 
03701         float *image=(this->get_data());
03702         int nx = this->get_xsize();
03703         int ny = this->get_ysize();
03704         int nz = this->get_zsize();
03705 
03706         float result;
03707 
03708         result = Util::get_pixel_conv_new(nx,ny,nz,delx,dely,delz,image,kb);
03709         return result;
03710 }

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

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

03621                                                                                           {
03622 //  here counting is in C style, so coordinates of the pixel delx should be [0-nx-1]
03623 
03624         int K     = kb.get_sB_size();
03625         int kbmin = -K/2;
03626         int kbmax = -kbmin;
03627         int kbc   = kbmax+1;
03628 
03629         float pixel =0.0f;
03630         float w=0.0f;
03631 
03632         //delx = restrict2(delx, nx);   //  In this function the old location is always within the      image
03633         int inxold = int(Util::round(delx));
03634         /*if(ny<2) {  //1D
03635                 if(inxold <= kbc || inxold >=nx-kbc-2 )  {
03636                         //  loop for ends
03637                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03638                                 float q = kb.sBwin_tab(delx - inxold-m1);
03639                                 pixel += (*this)((inxold+m1+nx)%nx)*q; w+=q;
03640                         }
03641                 } else {
03642                         for (int m1 =kbmin; m1 <=kbmax; m1++) {
03643                                 float q = kb.sBwin_tab(delx - inxold-m1);
03644                                 pixel += (*this)(inxold+m1)*q; w+=q;
03645                         }
03646                 }
03647 
03648         } else if(nz<2) {  // 2D*/
03649                 //dely = restrict2(dely, ny);
03650                 int inyold = int(Util::round(dely));
03651                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2 )  {
03652                         //  loop for strips
03653                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03654                                 float t = kb.sBwin_tab(dely - inyold-m2);
03655                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03656                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03657                                         pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny)*q;
03658                                         w += q;
03659                                 }
03660                         }
03661                 } else {
03662                         for (int m2 =kbmin; m2 <=kbmax; m2++){
03663                                 float t = kb.sBwin_tab(dely - inyold-m2);
03664                                 for (int m1 =kbmin; m1 <=kbmax; m1++) {
03665                                         float q = kb.sBwin_tab(delx - inxold-m1)*t;
03666                                         pixel += (*this)(inxold+m1,inyold+m2)*q;
03667                                         w += q;
03668                                 }
03669                         }
03670                 }
03671         /*} else {  //  3D
03672                 dely = restrict2(dely, ny);
03673                 int inyold = int(Util::round(dely));
03674                 delz = restrict2(delz, nz);
03675                 int inzold = int(Util::round(delz));
03676                     //cout << inxold<<"  "<< kbc<<"  "<< nx-kbc-2<<"  "<< endl;
03677                 if(inxold <= kbc || inxold >=nx-kbc-2 || inyold <= kbc || inyold >=ny-kbc-2  || inzold <= kbc || inzold >=nz-kbc-2 )  {
03678                         //  loop for strips
03679                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03680                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03681                                 //cout << "BB  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)<< endl;
03682                                 pixel += (*this)((inxold+m1+nx)%nx,(inyold+m2+ny)%ny,(inzold+m3+nz)%nz)*q ;w+=q;}}
03683                         }
03684                 } else {
03685                         for (int m3 =kbmin; m3 <=kbmax; m3++){ for (int m2 =kbmin; m2 <=kbmax; m2++){ for (int m1 =kbmin; m1 <=kbmax; m1++) {
03686                                 float q = kb.sBwin_tab(delx - inxold-m1)*kb.sBwin_tab(dely - inyold-m2)*kb.sBwin_tab(delz - inzold-m3);
03687                                 //cout << "OO  "<<m1<<"  "<< m2<<"  "<< m3<<"  "<< q<<"  "<< q<<"  "<<(*this)(inxold+m1,inyold+m2,inzold+m3)<< endl;
03688                                 pixel += (*this)(inxold+m1,inyold+m2,inzold+m3)*q; w+=q;}}
03689                         }
03690                 }
03691         }*/
03692         return pixel/w;
03693 }

EMData * EMData::get_pow float  n_pow  ) 
 

Definition at line 6181 of file emdata_sparx.cpp.

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

06182 {
06183         EMData* buf_new = this->copy_head();
06184         float *in  = this->get_data();
06185         float *out = buf_new->get_data();
06186         for(int i=0; i<nx*ny*nz; i++) out[i] = pow(in[i],n_pow);
06187         return buf_new;
06188 }

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

00678 {
00679         EMData *result = new EMData();
00680         result->set_size(size[0],size[1],size[2]);
00681 
00682         if (nz==1) {
00683                 for (int y=-size[1]/2; y<(size[1]+1)/2; y++) {
00684                         for (int x=-size[0]/2; x<(size[0]+1)/2; x++) {
00685                                 Vec3f xv=xform.transform(Vec3f((float)x,(float)y,0.0f));
00686                                 float v = 0;
00687 
00688                                 if (xv[0]<0||xv[1]<0||xv[0]>nx-2||xv[1]>ny-2) v=0.;
00689                                 else v=sget_value_at_interp(xv[0],xv[1]);
00690                                 result->set_value_at(x+size[0]/2,y+size[1]/2,v);
00691                         }
00692                 }
00693         }
00694         else {
00695                 for (int z=-size[2]/2; z<(size[2]+1)/2; z++) {
00696                         for (int y=-size[1]/2; y<(size[1]+1)/2; y++) {
00697                                 for (int x=-size[0]/2; x<(size[0]+1)/2; x++) {
00698                                         Vec3f xv=xform.transform(Vec3f((float)x,(float)y,0.0f));
00699                                         float v = 0;
00700 
00701                                         if (xv[0]<0||xv[1]<0||xv[2]<0||xv[0]>nx-2||xv[1]>ny-2||xv[2]>nz-2) v=0.;
00702                                         else v=sget_value_at_interp(xv[0],xv[1],xv[2]);
00703                                         result->set_value_at(x+size[0]/2,y+size[1]/2,z+size[2]/2,v);
00704                                 }
00705                         }
00706                 }
00707         }
00708         result->update();
00709 
00710         return result;
00711 }

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

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

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

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

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

00867                                 {
00868                                         prv_y_back = prv_ny - new_ny - ytrans;

int EMData::get_supp_pickle  )  const
 

Definition at line 1187 of file emdata_metadata.cpp.

01188 {
01189         return 0;
01190 }

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

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

00651 {
00652         ENTERFUNC;
00653 
00654         if (get_ndim() != 3) {
00655                 throw ImageDimensionException("3D only");
00656         }
00657 
00658         EMData *half = new EMData();
00659         half->attr_dict = attr_dict;
00660         half->set_size(nx, ny, nz / 2);
00661 
00662         float *half_data = half->get_data();
00663         EMUtil::em_memcpy(half_data, &(get_data()[nz / 2 * nx * ny]), sizeof(float) * nx * ny * nz / 2);
00664 
00665         float apix_z = attr_dict["apix_z"];
00666         float origin_z = attr_dict["origin_z"];
00667         origin_z += apix_z * nz / 2;
00668         half->attr_dict["origin_z"] = origin_z;
00669         half->update();
00670 
00671         EXITFUNC;
00672         return half;
00673 }

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

Get the 3D orientation of 'this' image.

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

Definition at line 550 of file emdata.h.

Referenced by main().

00749                                           {

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

00749                                           {

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 1887 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 1874 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 1854 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::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), 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 1862 of file emdata.h.

float & EMData::get_value_at_wrap int  x  ) 
 

Definition at line 740 of file emdata_core.cpp.

References get_data(), nx, and x.

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

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

References get_data(), nx, and x.

00768 {
00769         if (x < 0) x = nx - x;
00770         return get_data()[x];
00771 }

float & EMData::get_value_at_wrap int  x,
int  y
 

Definition at line 746 of file emdata_core.cpp.

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

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

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

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

00774 {
00775         if (x < 0) x = nx - x;
00776         if (y < 0) y = ny - y;
00777 
00778         return get_data()[x + y * nx];
00779 }

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

Definition at line 754 of file emdata_core.cpp.

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

00755 {
00756         int lx = x;
00757         int ly = y;
00758         int lz = z;
00759         if (lx < 0) lx = nx + lx;
00760         if (ly < 0) ly = ny + ly;
00761         if (lz < 0) lz = nz + lz;
00762 
00763         return get_data()[lx + ly * nx + lz * nxy];
00764 }

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

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

Referenced by calc_max_location_wrap(), EMAN::TomoCccCmp::cmp(), and zero_corner_circulant().

00782 {
00783         int lx = x;
00784         int ly = y;
00785         int lz = z;
00786         if (lx < 0) lx = nx + lx;
00787         if (ly < 0) ly = ny + ly;
00788         if (lz < 0) lz = nz + lz;
00789 
00790         return get_data()[lx + ly * nx + lz * nxy];
00791 }

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

Definition at line 1213 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 838 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::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::FRM2DAligner::align(), EMAN::Refine3DAligner::align(), EMAN::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::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(), 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::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::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::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::nnSSNR_ctfReconstructor::insert_slice(), EMAN::nn4_ctf_rectReconstructor::insert_slice(), EMAN::nn4_ctfReconstructor::insert_slice(), EMAN::nnSSNR_Reconstructor::insert_slice(), EMAN::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), EMAN::BackProjectionReconstructor::insert_slice(), EMAN::FourierReconstructorSimple2D::insert_slice(), 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::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(), and EMAN::Util::WTM().

00840                 {
00841                         public:

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

Definition at line 1218 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 847 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::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::FRM2DAligner::align(), EMAN::RTFExhaustiveAligner::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(), 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::XYZCmp::cmp(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::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::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::nnSSNR_ctfReconstructor::insert_slice(), EMAN::nn4_ctf_rectReconstructor::insert_slice(), EMAN::nn4_ctfReconstructor::insert_slice(), EMAN::nnSSNR_Reconstructor::insert_slice(), EMAN::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), EMAN::BackProjectionReconstructor::insert_slice(), 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::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(), and EMAN::Util::WTM().

00862                                 {

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

Definition at line 1223 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 856 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::Util::add_img(), EMAN::Util::add_img2(), EMAN::Util::add_img_abs(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), 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(), 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::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::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(), do_fft(), do_ift(), 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::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::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(), and EMAN::Util::window().

00862                                 {

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

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

03712                                                                                        {
03713         const int nxhalf = nx/2;
03714         const int nyhalf = ny/2;
03715         const int bd = size/2;
03716         float* wxarr = new float[size];
03717         float* wyarr = new float[size];
03718         float* wx = wxarr + bd; // wx[-bd] = wxarr[0]
03719         float* wy = wyarr + bd;
03720         int ixc = int(x + 0.5f*Util::sgn(x));
03721         int iyc = int(y + 0.5f*Util::sgn(y));
03722         if (abs(ixc) > nxhalf)
03723                 throw InvalidValueException(ixc, "getconv: X value out of range");
03724         if (abs(iyc) > nyhalf)
03725                 throw InvalidValueException(ixc, "getconv: Y value out of range");
03726         for (int i = -bd; i <= bd; i++) {
03727                 int iyp = iyc + i;
03728                 wy[i] = win(y - iyp);
03729                 int ixp = ixc + i;
03730                 wx[i] = win(x - ixp);
03731         }
03732         vector<int> saved_offsets = get_array_offsets();
03733         set_array_offsets(-nxhalf, -nyhalf);
03734         float conv = 0.f, wsum = 0.f;
03735         for (int iy = -bd; iy <= bd; iy++) {
03736                 int iyp = iyc + iy;
03737                 for (int ix = -bd; ix <= bd; ix++) {
03738                         int ixp = ixc + ix;
03739                         float wg = wx[ix]*wy[iy];
03740                         conv += (*this)(ixp,iyp)*wg;
03741                         wsum += wg;
03742                 }
03743         }
03744         set_array_offsets(saved_offsets);
03745         delete [] wxarr;
03746         delete [] wyarr;
03747         //return conv/wsum;
03748         return conv;
03749 }

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

function for MarchingCubes, for 3D image display

Returns:
the resolution

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

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

00805                :

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

Referenced by EMAN::CtfAverager::add_image(), and EMAN::EMUtil::is_same_ctf().

00428                           : 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 6242 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().

06242                                                                                                               {
06243         if (3 != get_ndim())
06244                 throw ImageDimensionException("helicise needs a 3-D image.");
06245         if (is_complex())
06246                 throw ImageFormatException("helicise requires a real image");
06247 
06248         EMData* result = this->copy_head();
06249         result->to_zero();
06250         int nyc = ny/2;
06251         int nxc = nx/2;
06252         int nb = int(nz*(1.0f - section_use)/2.);
06253         int ne = nz - nb -1;
06254         int numst = int((ne - nb)/dp*pixel_size + 0.5);
06255         // how many steps needed
06256         int nst = int(nz*pixel_size/dp+0.5);
06257         float r2, ir;
06258         if(radius < 0.0f) r2 = (float)((nxc-1)*(nxc-1));
06259         else r2 = radius*radius;
06260         if(minrad < 0.0f) ir = 0.0f;
06261         else ir = minrad*minrad;
06262         for (int k = 0; k<nz; k++) {
06263                 for (int j = 0; j<ny; j++) {
06264                         int jy = j - nyc;
06265                         int jj = jy*jy;
06266                         for (int i = 0; i<nx; i++) {
06267                                 int ix = i - nxc;
06268                                 float d2 = (float)(ix*ix + jj);
06269                                 if(d2 <= r2 && d2>=ir) {
06270                                         int nq = 1;
06271                                         for ( int ist = -nst; ist <= nst; ist++) {
06272                                                 float zold = (k*pixel_size + ist*dp)/pixel_size;
06273                                                 int IOZ = int(zold);
06274                                                 if(IOZ >= nb && IOZ <= ne) {
06275                                                         // now x-y position
06276                                                         float cphi = ist*dphi*(float)DGR_TO_RAD;
06277                                                         float ca = cos(cphi);
06278                                                         float sa = sin(cphi);
06279                                                         float xold = ix*ca - jy*sa + nxc;
06280                                                         float yold = ix*sa + jy*ca + nyc;
06281                                                         nq++;
06282 
06283 
06284                                         //  Do tri-linear interpolation
06285                                         int IOX = int(xold);
06286                                         int IOY = int(yold);
06287                                         //int IOZ = int(zold);
06288 
06289                                         #ifdef _WIN32
06290                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
06291                                         #else
06292                                         int IOXp1 = std::min( nx-1 ,IOX+1);
06293                                         #endif  //_WIN32
06294 
06295                                         #ifdef _WIN32
06296                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
06297                                         #else
06298                                         int IOYp1 = std::min( ny-1 ,IOY+1);
06299                                         #endif  //_WIN32
06300 
06301                                         #ifdef _WIN32
06302                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
06303                                         #else
06304                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
06305                                         #endif  //_WIN32
06306 
06307                                         float dx = xold-IOX;
06308                                         float dy = yold-IOY;
06309                                         float dz = zold-IOZ;
06310 
06311                                         float a1 = (*this)(IOX,IOY,IOZ);
06312                                         float a2 = (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZ);
06313                                         float a3 = (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZ);
06314                                         float a4 = (*this)(IOX,IOY,IOZp1) - (*this)(IOX,IOY,IOZ);
06315                                         float a5 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) + (*this)(IOXp1,IOYp1,IOZ);
06316                                         float a6 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOXp1,IOY,IOZp1);
06317                                         float a7 = (*this)(IOX,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOX,IOYp1,IOZp1);
06318                                         float a8 = (*this)(IOXp1,IOY,IOZ) + (*this)(IOX,IOYp1,IOZ)+ (*this)(IOX,IOY,IOZp1)
06319                                                         - (*this)(IOX,IOY,IOZ)- (*this)(IOXp1,IOYp1,IOZ) - (*this)(IOXp1,IOY,IOZp1)
06320                                                         - (*this)(IOX,IOYp1,IOZp1) + (*this)(IOXp1,IOYp1,IOZp1);
06321                                         (*result)(i,j,k) += a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
06322 
06323                                                         //(*result)(i,j,k) += (*this)(IOX, IOY, IOZ);
06324                                                         if(nq == numst) break;
06325                                                 }
06326                                         }
06327                                         if(nq != numst)
06328                                                 throw InvalidValueException(nq, "incorrect number of repeats encoutered.");
06329                                 }
06330                         }
06331                 }
06332         }
06333         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 ;
06334 
06335         result->update();
06336         return result;
06337 }

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

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

06340                                                                                                                    {
06341         if (3 != get_ndim())
06342                 throw ImageDimensionException("helicise needs a 3-D image.");
06343         if (is_complex())
06344                 throw ImageFormatException("helicise requires a real image");
06345 
06346         EMData* result = this->copy_head();
06347         result->to_zero();
06348         int nyc = ny/2;
06349         int nxc = nx/2;
06350         int nb = int(nz*(1.0f - section_use)/2.);
06351         int ne = nz - nb -1;
06352         int numst = int((ne - nb)/dp*pixel_size + 0.5);
06353         // how many steps needed
06354         int nst = int(nz*pixel_size/dp+0.5);
06355         float r2, ir;
06356         if(radius < 0.0f) r2 = (float)((nxc-1)*(nxc-1));
06357         else r2 = radius*radius;
06358         if(minrad < 0.0f) ir = 0.0f;
06359         else ir = minrad*minrad;
06360         for (int k = 0; k<nz; k++) {
06361                 for (int j = 0; j<ny; j++) {
06362                         int jy = j - nyc;
06363                         int jj = jy*jy;
06364                         for (int i = 0; i<nx; i++) {
06365                                 int ix = i - nxc;
06366                                 float d2 = (float)(ix*ix + jj);
06367                                 if(d2 <= r2 && d2>=ir) {
06368                                         int nq = 1;
06369                                         for ( int ist = -nst; ist <= nst; ist++) {
06370                                                 float zold = (k*pixel_size + ist*dp)/pixel_size;
06371                                                 int IOZ = int(zold);
06372                                                 if(IOZ >= nb && IOZ <= ne) {
06373                                                         // now x-y position
06374                                                         float cphi = ist*dphi*(float)DGR_TO_RAD;
06375                                                         float ca = cos(cphi);
06376                                                         float sa = sin(cphi);
06377                                                         float xold = ix*ca - jy*sa + nxc;
06378                                                         float yold = ix*sa + jy*ca + nyc;
06379                                                         nq++;
06380 
06381 
06382                                         //  Do tri-linear interpolation
06383                                         int IOX = int(xold);
06384                                         int IOY = int(yold);
06385                                         //int IOZ = int(zold);
06386 
06387                                         #ifdef _WIN32
06388                                         int IOXp1 = _cpp_min( nx-1 ,IOX+1);
06389                                         #else
06390                                         int IOXp1 = std::min( nx-1 ,IOX+1);
06391                                         #endif  //_WIN32
06392 
06393                                         #ifdef _WIN32
06394                                         int IOYp1 = _cpp_min( ny-1 ,IOY+1);
06395                                         #else
06396                                         int IOYp1 = std::min( ny-1 ,IOY+1);
06397                                         #endif  //_WIN32
06398 
06399                                         #ifdef _WIN32
06400                                         int IOZp1 = _cpp_min( nz-1 ,IOZ+1);
06401                                         #else
06402                                         int IOZp1 = std::min( nz-1 ,IOZ+1);
06403                                         #endif  //_WIN32
06404 
06405                                         float dx = xold-IOX;
06406                                         float dy = yold-IOY;
06407                                         float dz = zold-IOZ;
06408 
06409                                         float a1 = (*this)(IOX,IOY,IOZ);
06410                                         float a2 = (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZ);
06411                                         float a3 = (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZ);
06412                                         float a4 = (*this)(IOX,IOY,IOZp1) - (*this)(IOX,IOY,IOZ);
06413                                         float a5 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) + (*this)(IOXp1,IOYp1,IOZ);
06414                                         float a6 = (*this)(IOX,IOY,IOZ) - (*this)(IOXp1,IOY,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOXp1,IOY,IOZp1);
06415                                         float a7 = (*this)(IOX,IOY,IOZ) - (*this)(IOX,IOYp1,IOZ) - (*this)(IOX,IOY,IOZp1) + (*this)(IOX,IOYp1,IOZp1);
06416                                         float a8 = (*this)(IOXp1,IOY,IOZ) + (*this)(IOX,IOYp1,IOZ)+ (*this)(IOX,IOY,IOZp1)
06417                                                         - (*this)(IOX,IOY,IOZ)- (*this)(IOXp1,IOYp1,IOZ) - (*this)(IOXp1,IOY,IOZp1)
06418                                                         - (*this)(IOX,IOYp1,IOZp1) + (*this)(IOXp1,IOYp1,IOZp1);
06419                                         (*result)(i,j,k) += a1 + dz*(a4 + a6*dx + (a7 + a8*dx)*dy) + a3*dy + dx*(a2 + a5*dy);
06420 
06421                                                         //(*result)(i,j,k) += (*this)(IOX, IOY, IOZ);
06422                                                         if(nq == numst) break;
06423                                                 }
06424                                         }
06425                                         if(nq != numst)
06426                                                 throw InvalidValueException(nq, "incorrect number of repeats encoutered.");
06427                                 }
06428                         }
06429                 }
06430         }
06431         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 ;
06432 
06433         result->update();
06434         return result;
06435 }

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

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

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

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

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

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

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

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

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

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

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

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

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

Is this a complex image?

Returns:
Whether this is a complex image or not.

Definition at line 936 of file emdata.h.

Referenced by add(), EMAN::Util::add_img2(), add_incoherent(), EMAN::Util::addn_img(), addsquare(), ap2ri(), apply_radial_func(), calc_az_dist(), 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_rect(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::FourierReconstructorSimple2D::insert_slice(), 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 1015 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 1152 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 1119 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 919 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 1049 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 955 of file emdata.h.

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

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 1085 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 902 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 1249 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().

01250 {
01251         ENTERFUNC;
01252 
01253         if (get_ndim() > 2) {
01254                 throw ImageDimensionException("1D/2D only");
01255         }
01256 
01257         EMData *ret = copy_head();
01258         ret->set_size(nx,ny,nz);
01259         ret->to_zero();
01260 
01261         int nx2 = with->get_xsize();
01262         int ny2 = with->get_ysize();
01263         float em = with->get_edge_mean();
01264 
01265         float *data = get_data();
01266         float *with_data = with->get_data();
01267         float *ret_data = ret->get_data();
01268 
01269         float sum2 = (Util::square((float)with->get_attr("sigma")) +
01270                                   Util::square((float)with->get_attr("mean")));
01271         if (do_sigma) {
01272                 for (int j = ny2 / 2; j < ny - ny2 / 2; j++) {
01273                         for (int i = nx2 / 2; i < nx - nx2 / 2; i++) {
01274                                 float sum = 0;
01275                                 float sum1 = 0;
01276                                 float summ = 0;
01277                                 int k = 0;
01278 
01279                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01280                                         for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01281                                                 int l = ii + jj * nx;
01282                                                 sum1 += Util::square(data[l]);
01283                                                 summ += data[l];
01284                                                 sum += data[l] * with_data[k];
01285                                                 k++;
01286                                         }
01287                                 }
01288                                 float tmp_f1 = (sum1 / 2.0f - sum) / (nx2 * ny2);
01289                                 float tmp_f2 = Util::square((float)with->get_attr("mean") -
01290                                                                                         summ / (nx2 * ny2));
01291                                 ret_data[i + j * nx] = sum2 + tmp_f1 - tmp_f2;
01292                         }
01293                 }
01294         }
01295         else {
01296                 for (int j = ny2 / 2; j < ny - ny2 / 2; j++) {
01297                         for (int i = nx2 / 2; i < nx - nx2 / 2; i++) {
01298                                 float eml = 0;
01299                                 float dot = 0;
01300                                 float dot2 = 0;
01301 
01302                                 for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01303                                         eml += data[ii + (j - ny2 / 2) * nx] + data[ii + (j + ny2 / 2 - 1) * nx];
01304                                 }
01305 
01306                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01307                                         eml += data[i - nx2 / 2 + jj * nx] + data[i + nx2 / 2 - 1 + jj * nx];
01308                                 }
01309 
01310                                 eml /= (nx2 + ny2) * 2.0f;
01311                                 int k = 0;
01312 
01313                                 for (int jj = j - ny2 / 2; jj < j + ny2 / 2; jj++) {
01314                                         for (int ii = i - nx2 / 2; ii < i + nx2 / 2; ii++) {
01315                                                 dot += (data[ii + jj * nx] - eml) * (with_data[k] - em);
01316                                                 dot2 += Util::square(data[ii + jj * nx] - eml);
01317                                                 k++;
01318                                         }
01319                                 }
01320 
01321                                 dot2 = std::sqrt(dot2);
01322 
01323                                 if (dot2 == 0) {
01324                                         ret_data[i + j * nx] = 0;
01325                                 }
01326                                 else {
01327                                         ret_data[i + j * nx] = dot / (nx2 * ny2 * dot2 * (float)with->get_attr("sigma"));
01328                                 }
01329                         }
01330                 }
01331         }
01332 
01333         ret->update();
01334 
01335         EXITFUNC;
01336         return ret;
01337 }

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

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

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

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

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

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

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

01784 {
01785 //      printf("Make fp %d\n",type);
01786         if (type==0) {
01787                 EMData *un=make_rotational_footprint_e1(); // Use EMAN1's footprint strategy
01788                 if (un->get_ysize() <= 6) {
01789                         throw UnexpectedBehaviorException("In EMData::make_footprint. The rotational footprint is too small");
01790                 }
01791                 EMData *tmp=un->get_clip(Region(0,4,un->get_xsize(),un->get_ysize()-6));        // 4 and 6 are empirical
01792                 EMData *cx=tmp->calc_ccfx(tmp,0,-1,1);
01793                 EMData *fp=cx->get_clip(Region(0,0,cx->get_xsize()/2,cx->get_ysize()));
01794                 delete un;
01795                 delete tmp;
01796                 delete cx;
01797                 return fp;
01798         }
01799         else if (type==1 || type==2 ||type==5 || type==6) {
01800                 int i,j,kx,ky,lx,ly;
01801 
01802                 EMData *fft=do_fft();
01803 
01804                 // map for x,y -> radius for speed
01805                 int rmax=(get_xsize()+1)/2;
01806                 float *rmap=(float *)malloc(rmax*rmax*sizeof(float));
01807                 for (i=0; i<rmax; i++) {
01808                         for (j=0; j<rmax; j++) {
01809 #ifdef _WIN32
01810                                 rmap[i+j*rmax]=_hypotf((float)i,(float)j);
01811 #else
01812                                 rmap[i+j*rmax]=hypot((float)i,(float)j);
01813 #endif  //_WIN32
01814 //                              printf("%d\t%d\t%f\n",i,j,rmap[i+j*rmax]);
01815                         }
01816                 }
01817 
01818                 EMData *fp=new EMData(rmax*2+2,rmax*2,1);
01819                 fp->set_complex(1);
01820                 fp->to_zero();
01821 
01822                 // Two vectors in to complex space (kx,ky) and (lx,ly)
01823                 // We are computing the bispectrum, f(k).f(l).f*(k+l)
01824                 // but integrating out two dimensions, leaving |k|,|l|
01825                 for (kx=-rmax+1; kx<rmax; kx++) {
01826                         for (ky=-rmax+1; ky<rmax; ky++) {
01827                                 for (lx=-rmax+1; lx<rmax; lx++) {
01828                                         for (ly=-rmax+1; ly<rmax; ly++) {
01829                                                 int ax=kx+lx;
01830                                                 int ay=ky+ly;
01831                                                 if (abs(ax)>=rmax || abs(ay)>=rmax) continue;
01832                                                 int r1=(int)floor(.5+rmap[abs(kx)+rmax*abs(ky)]);
01833                                                 int r2=(int)floor(.5+rmap[abs(lx)+rmax*abs(ly)]);
01834 //                                              if (r1>500 ||r2>500) printf("%d\t%d\t%d\t%d\t%d\t%d\n",kx,ky,lx,ly,r1,r2);
01835 //                                              float r3=rmap[ax+rmax*ay];
01836                                                 if (r1+r2>=rmax) continue;
01837 
01838                                                 std::complex<float> p=fft->get_complex_at(kx,ky)*fft->get_complex_at(lx,ly)*conj(fft->get_complex_at(ax,ay));
01839                                                 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
01840 //                                              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
01841 //                                              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
01842                                                 fp->set_value_at(r1*2+1,r2,fp->get_value_at(r1*2+1,r2)+1);                      // a normalization counter
01843                                         }
01844                                 }
01845                         }
01846                 }
01847 
01848                 // Normalizes the pixels based on the accumulated counts then sets the imaginary components back to zero
01849                 if (type==5 || type==6) {
01850                         for (i=0; i<rmax*2; i+=2) {
01851                                 for (j=0; j<rmax; j++) {
01852                                         float norm=fp->get_value_at(i+1,j);
01853 #ifdef _WIN32
01854                                         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));
01855                                         fp->set_value_at(i,j,pow(fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm), 1.0f/3.0f));
01856 #else
01857                                         fp->set_value_at(i,rmax*2-j-1,cbrt(fp->get_value_at(i,j)/(norm==0?1.0:norm)));
01858                                         fp->set_value_at(i,j,cbrt(fp->get_value_at(i,j)/(norm==0?1.0:norm)));
01859 #endif  //_WIN32
01860                                         fp->set_value_at(i+1,j,0.0);
01861                                 }
01862                         }
01863                 }
01864                 else {
01865                         for (i=0; i<rmax*2; i+=2) {
01866                                 for (j=0; j<rmax; j++) {
01867                                         float norm=fp->get_value_at(i+1,j);
01868                                         fp->set_value_at(i,rmax*2-j-1,fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm));
01869                                         fp->set_value_at(i,j,fp->get_value_at(i,j)/(norm==0.0f?1.0f:norm));
01870                                         fp->set_value_at(i+1,j,0.0);
01871                                 }
01872                         }
01873                 }
01874 
01875                 free(rmap);
01876                 if (type==2||type==6) {
01877                         EMData *f2=fp->do_ift();
01878                         if (f2->get_value_at(0,0)<0) f2->mult(-1.0f);
01879                         f2->process_inplace("xform.phaseorigin.tocorner");
01880                         delete fp;
01881                         return f2;
01882                 }
01883                 return fp;
01884         }
01885         else if (type==3 || type==4) {
01886                 int h,i,j,kx,ky,lx,ly;
01887 
01888                 EMData *fft=do_fft();
01889 
01890                 // map for x,y -> radius for speed
01891                 int rmax=(get_xsize()+1)/2;
01892                 float *rmap=(float *)malloc(rmax*rmax*sizeof(float));
01893                 for (i=0; i<rmax; i++) {
01894                         for (j=0; j<rmax; j++) {
01895 #ifdef _WIN32
01896                                 rmap[i+j*rmax]=_hypotf((float)i,(float)j);
01897 #else
01898                                 rmap[i+j*rmax]=hypot((float)i,(float)j);
01899 #endif  //_WIN32
01900 //                              printf("%d\t%d\t%f\n",i,j,rmap[i+j*rmax]);
01901                         }
01902                 }
01903 
01904                 EMData *fp=new EMData(rmax*2+2,rmax*2,16);
01905 
01906                 fp->set_complex(1);
01907                 fp->to_zero();
01908 
01909                 // Two vectors in to complex space (kx,ky) and (lx,ly)
01910                 // We are computing the bispectrum, f(k).f(l).f*(k+l)
01911                 // but integrating out two dimensions, leaving |k|,|l|
01912                 for (kx=-rmax+1; kx<rmax; kx++) {
01913                         for (ky=-rmax+1; ky<rmax; ky++) {
01914                                 for (lx=-rmax+1; lx<rmax; lx++) {
01915                                         for (ly=-rmax+1; ly<rmax; ly++) {
01916                                                 int ax=kx+lx;
01917                                                 int ay=ky+ly;
01918                                                 if (abs(ax)>=rmax || abs(ay)>=rmax) continue;
01919                                                 float rr1=rmap[abs(kx)+rmax*abs(ky)];
01920                                                 float rr2=rmap[abs(lx)+rmax*abs(ly)];
01921                                                 int r1=(int)floor(.5+rr1);
01922                                                 int r2=(int)floor(.5+rr2);
01923 //                                              if (r1>500 ||r2>500) printf("%d\t%d\t%d\t%d\t%d\t%d\n",kx,ky,lx,ly,r1,r2);
01924 //                                              float r3=rmap[ax+rmax*ay];
01925                                                 if (r1+r2>=rmax || rr1==0 ||rr2==0) continue;
01926 
01927                                                 std::complex<float> p=fft->get_complex_at(kx,ky)*fft->get_complex_at(lx,ly)*conj(fft->get_complex_at(ax,ay));
01928                                                 int dot=(int)floor((kx*lx+ky*ly)/(rr1*rr2)*7.5);                                        // projection of k on l 0-31
01929                                                 if (dot<0) dot=16+dot;
01930 //                                              int dot=(int)floor((kx*lx+ky*ly)/(rr1*rr2)*7.5+8.0);                                    // projection of k on l 0-15
01931                                                 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
01932 //                                              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
01933 //                                              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
01934                                                 fp->set_value_at(r1*2+1,r2,dot,fp->get_value_at(r1*2+1,r2,dot)+1);                      // a normalization counter
01935                                         }
01936                                 }
01937                         }
01938                 }
01939 
01940                 // Normalizes the pixels based on the accumulated counts then sets the imaginary components back to zero
01941                 for (i=0; i<rmax*2; i+=2) {
01942                         for (j=0; j<rmax; j++) {
01943                                 for (h=0; h<16; h++) {
01944                                         float norm=fp->get_value_at(i+1,j,h);
01945 //                                      fp->set_value_at(i,rmax*2-j-1,h,cbrt(fp->get_value_at(i,j,h)/(norm==0?1.0:norm)));
01946 //                                      fp->set_value_at(i,j,h,cbrt(fp->get_value_at(i,j,h)/(norm==0?1.0:norm)));
01947                                         fp->set_value_at(i,rmax*2-j-1,h,(fp->get_value_at(i,j,h)/(norm==0.0f?1.0f:norm)));
01948                                         fp->set_value_at(i,j,h,(fp->get_value_at(i,j,h)/(norm==0.0f?1.0f:norm)));
01949         //                              fp->set_value_at(i,rmax*2-j-1,fp->get_value_at(i,j)/(norm==0?1.0:norm));
01950         //                              fp->set_value_at(i,j,fp->get_value_at(i,j)/(norm==0?1.0:norm));
01951                                         fp->set_value_at(i+1,j,h,0.0);
01952                                 }
01953                         }
01954                 }
01955 
01956                 free(rmap);
01957                 if (type==4) {
01958                         EMData *f2=fp->do_ift();
01959                         if (f2->get_value_at(0,0,0)<0) f2->mult(-1.0f);
01960                         f2->process_inplace("xform.phaseorigin.tocorner");
01961                         delete fp;
01962                         return f2;
01963                 }
01964                 return fp;
01965         }
01966         throw UnexpectedBehaviorException("There is not implementation for the parameters you specified");
01967 }

EMData * EMData::make_rotational_footprint_cmc bool  unwrap = true  ) 
 

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

01576                                                           {
01577         ENTERFUNC;
01578         update_stat();
01579         // Note that rotational_footprint caching saves a large amount of time
01580         // but this is at the expense of memory. Note that a policy is hardcoded here,
01581         // that is that caching is only employed when premasked is false and unwrap
01582         // is true - this is probably going to be what is used in most scenarios
01583         // as advised by Steve Ludtke - In terms of performance this caching doubles the metric
01584         // generated by e2speedtest.
01585         if ( rot_fp != 0 && unwrap == true) {
01586                 return new EMData(*rot_fp);
01587         }
01588 
01589         static EMData obj_filt;
01590         EMData* filt = &obj_filt;
01591         filt->set_complex(true);
01592 
01593 
01594         // The filter object is nothing more than a cached high pass filter
01595         // Ultimately it is used an argument to the EMData::mult(EMData,prevent_complex_multiplication (bool))
01596         // function in calc_mutual_correlation. Note that in the function the prevent_complex_multiplication
01597         // set to true, which is used for speed reasons.
01598         if (filt->get_xsize() != nx+2-(nx%2) || filt->get_ysize() != ny ||
01599                    filt->get_zsize() != nz ) {
01600                 filt->set_size(nx+2-(nx%2), ny, nz);
01601                 filt->to_one();
01602 
01603                 filt->process_inplace("filter.highpass.gauss", Dict("cutoff_abs", 1.5f/nx));
01604         }
01605 
01606         EMData *ccf = this->calc_mutual_correlation(this, true,filt);
01607         ccf->sub(ccf->get_edge_mean());
01608         EMData *result = ccf->unwrap();
01609         delete ccf; ccf = 0;
01610 
01611         EXITFUNC;
01612         if ( unwrap == true)
01613         {
01614         // this if statement reflects a strict policy of caching in only one scenario see comments at beginning of function block
01615 
01616 // Note that the if statement at the beginning of this function ensures that rot_fp is not zero, so there is no need
01617 // to throw any exception
01618 // if ( rot_fp != 0 ) throw UnexpectedBehaviorException("The rotational foot print is only expected to be cached if it is not NULL");
01619 
01620 // Here is where the caching occurs - the rot_fp takes ownsherhip of the pointer, and a deep copied EMData object is returned.
01621 // The deep copy invokes a cost in terms of CPU cycles and memory, but prevents the need for complicated memory management (reference counting)
01622                 rot_fp = result;
01623                 return new EMData(*rot_fp);
01624         }
01625         else return result;
01626 }

EMData * EMData::make_rotational_footprint_e1 bool  unwrap = true  ) 
 

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

01664 {
01665         ENTERFUNC;
01666 #ifdef EMAN2_USING_CUDA
01667         if (gpu_operation_preferred()) {
01668                 EXITFUNC;
01669                 return make_rotational_footprint_cuda(unwrap);
01670         }
01671 #endif
01672 
01673         update_stat();
01674         // Note that rotational_footprint caching saves a large amount of time
01675         // but this is at the expense of memory. Note that a policy is hardcoded here,
01676         // that is that caching is only employed when premasked is false and unwrap
01677         // is true - this is probably going to be what is used in most scenarios
01678         // as advised by Steve Ludtke - In terms of performance this caching doubles the metric
01679         // generated by e2speedtest.
01680         if ( rot_fp != 0 && unwrap == true) {
01681                 return new EMData(*rot_fp);
01682         }
01683 
01684         static EMData obj_filt;
01685         EMData* filt = &obj_filt;
01686         filt->set_complex(true);
01687 //      Region filt_region;
01688 
01689 //      if (nx & 1) {
01690 //              LOGERR("even image xsize only");                throw ImageFormatException("even image xsize only");
01691 //      }
01692 
01693         int cs = (((nx * 7 / 4) & 0xfffff8) - nx) / 2; // this pads the image to 1 3/4 * size with result divis. by 8
01694 
01695         static EMData big_clip;
01696         int big_x = nx+2*cs;
01697         int big_y = ny+2*cs;
01698         int big_z = 1;
01699         if ( nz != 1 ) {
01700                 big_z = nz+2*cs;
01701         }
01702 
01703 
01704         if ( big_clip.get_xsize() != big_x || big_clip.get_ysize() != big_y || big_clip.get_zsize() != big_z ) {
01705                 big_clip.set_size(big_x,big_y,big_z);
01706         }
01707         // It is important to set all newly established pixels around the boundaries to the mean
01708         // If this is not done then the associated rotational alignment routine breaks, in fact
01709         // everythin just goes foo.
01710         big_clip.to_value(get_edge_mean());
01711 
01712         if (nz != 1) {
01713                 big_clip.insert_clip(this,IntPoint(cs,cs,cs));
01714         } else  {
01715                 big_clip.insert_clip(this,IntPoint(cs,cs,0));
01716         }
01717 
01718 
01719         // The filter object is nothing more than a cached high pass filter
01720         // Ultimately it is used an argument to the EMData::mult(EMData,prevent_complex_multiplication (bool))
01721         // function in calc_mutual_correlation. Note that in the function the prevent_complex_multiplication
01722         // set to true, which is used for speed reasons.
01723         if (filt->get_xsize() != big_clip.get_xsize() +2-(big_clip.get_xsize()%2) || filt->get_ysize() != big_clip.get_ysize() ||
01724                    filt->get_zsize() != big_clip.get_zsize()) {
01725                 filt->set_size(big_clip.get_xsize() + 2-(big_clip.get_xsize()%2), big_clip.get_ysize(), big_clip.get_zsize());
01726         filt->to_one();
01727         filt->process_inplace("filter.highpass.gauss", Dict("cutoff_abs", 1.5f/nx));
01728         }
01729         EMData *mc = big_clip.calc_mutual_correlation(&big_clip, true,filt);
01730         mc->sub(mc->get_edge_mean());
01731 
01732         static EMData sml_clip;
01733         int sml_x = nx * 3 / 2;
01734         int sml_y = ny * 3 / 2;
01735         int sml_z = 1;
01736         if ( nz != 1 ) {
01737                 sml_z = nz * 3 / 2;
01738         }
01739 
01740         if ( sml_clip.get_xsize() != sml_x || sml_clip.get_ysize() != sml_y || sml_clip.get_zsize() != sml_z ) {
01741                 sml_clip.set_size(sml_x,sml_y,sml_z);   }
01742         if (nz != 1) {
01743                 sml_clip.insert_clip(mc,IntPoint(-cs+nx/4,-cs+ny/4,-cs+nz/4));
01744         } else {
01745                 sml_clip.insert_clip(mc,IntPoint(-cs+nx/4,-cs+ny/4,0));
01746         }
01747 
01748         delete mc; mc = 0;
01749         EMData * result = NULL;
01750 
01751         if (nz == 1) {
01752                 if (!unwrap) {
01753                         result = sml_clip.process("mask.sharp", Dict("outer_radius", -1, "value", 0));
01754 
01755                 }
01756                 else {
01757                         result = sml_clip.unwrap();
01758                 }
01759         }
01760         else {
01761                 // I am not sure why there is any consideration of non 2D images, but it was here
01762                 // in the first port so I kept when I cleaned this function up (d.woolford)
01763 //              result = clipped_mc;
01764                 result = new EMData(sml_clip);
01765         }
01766 
01767         EXITFUNC;
01768         if ( unwrap == true)
01769         { // this if statement reflects a strict policy of caching in only one scenario see comments at beginning of function block
01770 
01771                 // Note that the if statement at the beginning of this function ensures that rot_fp is not zero, so there is no need
01772                 // to throw any exception
01773                 if ( rot_fp != 0 ) throw UnexpectedBehaviorException("The rotational foot print is only expected to be cached if it is not NULL");
01774 
01775                 // Here is where the caching occurs - the rot_fp takes ownsherhip of the pointer, and a deep copied EMData object is returned.
01776                 // The deep copy invokes a cost in terms of CPU cycles and memory, but prevents the need for complicated memory management (reference counting)
01777                 rot_fp = result;
01778                 return new EMData(*rot_fp);
01779         }
01780         else return result;
01781 }

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

Definition at line 1253 of file emdata_metadata.cpp.

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

01253                                                                               {
01254         Vec3i coord(seed[0],seed[1],seed[2]);
01255         vector<Vec3i> region;
01256         region.push_back(coord);
01257         vector<Vec3i> find_region_input = region;
01258         while (true) {
01259                 vector<Vec3i> v = find_region(this,find_region_input, value, region);
01260                 if (v.size() == 0 ) break;
01261                 else find_region_input = v;
01262         }
01263         return region;
01264 }

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

Definition at line 915 of file emdata.cpp.

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

00915                                                                                    {
00916         
00917         Transform t;
00918         int r0 = (int)r;
00919         float ddmax = 0.0f;
00920 
00921         t = t2*t1.inverse();
00922         for (int i=0; i<int(2*M_PI*r0+0.5); i++) {
00923                 Vec3f v = Vec3f(r0*cos((float)i), r0*sin((float)i), 0);
00924                 Vec3f d = t*v-v;
00925                 float dd = d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
00926                 if (dd > ddmax) ddmax = dd; 
00927         }
00928         return std::sqrt(ddmax);
00929 }

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

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

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

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

00472 {
00473         ENTERFUNC;
00474 
00475 
00476         if (is_complex()) {
00477                 ap2ri();
00478         }
00479         if (f != 1.0) {
00480 #ifdef EMAN2_USING_CUDA
00481                 if ( gpu_operation_preferred () ) {
00482                         EMDataForCuda tmp = get_data_struct_for_cuda();
00483                         emdata_processor_mult(&tmp,f);
00484                         gpu_update();
00485                         EXITFUNC;
00486                         return;
00487                 }
00488 #endif // EMAN2_USING_CUDA
00489                 float* data = get_data();
00490                 size_t size = nxyz;
00491                 for (size_t i = 0; i < size; i++) {
00492                         data[i] *= f;
00493                 }
00494                 update();
00495         }
00496         EXITFUNC;
00497 }

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

Referenced by calc_fast_sigma_image(), calc_flcf(), calc_mutual_correlation(), div(), do_ift(), do_ift_inplace(), EMAN::BackProjectionReconstructor::finish(), EMAN::BackProjectionReconstructor::insert_slice(), 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 540 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().

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

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

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

00666                                           {
00667 
00668         ENTERFUNC;
00669         if ( ny == 1 && nz == 1 ) {
00670                 LOGERR("Input image must be 2-D or 3-D!");
00671                 throw ImageDimensionException("Input image must be 2-D or 3-D!");
00672         }
00673 
00674         EMData* result = this->copy_head();
00675 
00676         result->to_zero();
00677         result->set_array_offsets(-nx/2, -ny/2, -nz/2);
00678         this->set_array_offsets(-nx/2, -ny/2, -nz/2);
00679         int rmax = radial->get_xsize();
00680         int i, j, k, ir;
00681         float r;
00682         for ( k = -nz/2; k < nz/2+nz%2; k++) {
00683                 for ( j = -ny/2; j < ny/2+ny%2; j++) {
00684                         for ( i = -nx/2; i < nx/2+nx%2; i++)  {
00685                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00686                                 ir = int(r);
00687                                 if(ir < rmax-1)  (*result)(i,j,k) = (*this)(i,j,k) * ((*radial)(ir)+((*radial)(ir+1)-(*radial)(ir))*(r - float(ir)));
00688                         }
00689                 }
00690         }
00691         result->update();
00692         result->set_array_offsets(0,0,0);
00693         this->set_array_offsets(0,0,0);
00694         EXITFUNC;
00695         return result;
00696 }

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

01165 {
01166         ENTERFUNC;
01167         int nxc = attr_dict["nxc"]; // # of complex elements along x
01168         // let's treat nr, bi, and local data as matrices
01169         vector<int> saved_offsets = get_array_offsets();
01170         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01171         set_array_offsets(0,1,1);
01172         myfft->set_array_offsets(0,1);
01173         // loop over frequencies in y
01174         if( mult == 1 ) {
01175                 for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn(iy, ny, nxc, wptr, myfft, tf);
01176         } else {
01177                 for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_mult(iy, ny, nxc, wptr, myfft, tf, mult);
01178         }
01179 
01180         set_array_offsets(saved_offsets);
01181         myfft->set_array_offsets(myfft_saved_offsets);
01182         EXITFUNC;
01183 }

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 Transform3D reference
mult 

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

01774                                                                       {
01775         ENTERFUNC;
01776         int nxc = attr_dict["nxc"]; // # of complex elements along x
01777         // let's treat nr, bi, and local data as matrices
01778         vector<int> saved_offsets = get_array_offsets();
01779         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01780         set_array_offsets(0,1,1);
01781         myfft->set_array_offsets(0,1);
01782 
01783         Ctf* ctf = myfft->get_attr("ctf");
01784         ctf_store::init( ny, ctf );
01785         if(ctf) {delete ctf; ctf=0;}
01786 
01787         // loop over frequencies in y
01788         for (int iy = -ny/2 + 1; iy <= ny/2; iy++) onelinenn_ctf(iy, ny, nxc, w, myfft, tf, mult);
01789         set_array_offsets(saved_offsets);
01790         myfft->set_array_offsets(myfft_saved_offsets);
01791         EXITFUNC;
01792 }

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 Transform3D reference
mult 

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

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

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

01316 {
01317         ENTERFUNC;
01318         int nxc = attr_dict["nxc"];
01319 
01320         vector<int> saved_offsets = get_array_offsets();
01321         vector<int> myfft_saved_offsets = myfft->get_array_offsets();
01322 
01323         set_array_offsets(0,1,1);
01324         myfft->set_array_offsets(0,1);
01325 
01326         int iymin = is_fftodd() ? -ny/2 : -ny/2 + 1 ;
01327         int iymax = ny/2;
01328         int izmin = is_fftodd() ? -nz/2 : -nz/2 + 1 ;
01329         int izmax = nz/2;
01330 
01331         for (int iy = iymin; iy <= iymax; iy++) {
01332                 int jp = iy >= 0 ? iy+1 : ny+iy+1; //checked, works for both odd and even
01333                 for (int ix = 0; ix <= nxc; ix++) {
01334                         if (( 4*(ix*ix+iy*iy) < ny*ny ) && !( ix == 0 && iy < 0 ) ) {
01335                                 float xnew = ix*tf[0][0] + iy*tf[1][0];
01336                                 float ynew = ix*tf[0][1] + iy*tf[1][1];
01337                                 float znew = ix*tf[0][2] + iy*tf[1][2];
01338                                 std::complex<float> btq;
01339                                 if (xnew < 0.0) {
01340                                         xnew = -xnew; // ensures xnew>=0.0
01341                                         ynew = -ynew;
01342                                         znew = -znew;
01343                                         btq = conj(myfft->cmplx(ix,jp));
01344                                 } else {
01345                                         btq = myfft->cmplx(ix,jp);
01346                                 }
01347                                 int ixn = int(xnew + 0.5 + nx) - nx; // ensures ixn >= 0
01348                                 int iyn = int(ynew + 0.5 + ny) - ny;
01349                                 int izn = int(znew + 0.5 + nz) - nz;
01350                                 if ((ixn <= nxc) && (iyn >= iymin) && (iyn <= iymax) && (izn >= izmin) && (izn <= izmax)) {
01351                                         if (ixn >= 0) {
01352                                                 int iza, iya;
01353                                                 if (izn >= 0)  iza = izn + 1;
01354                                                 else           iza = nz + izn + 1;
01355 
01356                                                 if (iyn >= 0) iya = iyn + 1;
01357                                                 else          iya = ny + iyn + 1;
01358 
01359                                                 cmplx(ixn,iya,iza) += btq;
01360                                                 (*wptr)(ixn,iya,iza)++;
01361                                                 (*wptr2)(ixn,iya,iza) += norm(btq);
01362                                         } else {
01363                                                 int izt, iyt;
01364                                                 if (izn > 0) izt = nz - izn + 1;
01365                                                 else         izt = -izn + 1;
01366 
01367                                                 if (iyn > 0) iyt = ny - iyn + 1;
01368                                                 else         iyt = -iyn + 1;
01369 
01370                                                 cmplx(-ixn,iyt,izt) += conj(btq);
01371                                                 (*wptr)(-ixn,iyt,izt)++;
01372                                                 (*wptr2)(-ixn,iyt,izt) += norm(btq);
01373                                         }
01374                                 }
01375                         }
01376                 }
01377         }
01378         set_array_offsets(saved_offsets);
01379         myfft->set_array_offsets(myfft_saved_offsets);
01380         EXITFUNC;
01381 }

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

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

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

06603                                                            {
06604         if (this->is_complex())
06605                 throw ImageFormatException("Padding of complex images not supported");
06606         int nx = this->get_xsize();
06607         int ny = this->get_ysize();
06608         int nz = this->get_zsize();
06609         float mean = 0., stddev = 1.;
06610         if(donorm) { // Normalization requested
06611                 mean = this->get_attr("mean");
06612                 stddev = this->get_attr("sigma");
06613         }
06614         // sanity check
06615         if (npad < 1) npad = 1;
06616         int nxpad = npad*nx;
06617         int nypad = npad*ny;
06618         int nzpad = npad*nz;
06619         if (1 == ny) {
06620                 // 1-d image, don't want to pad along y or z
06621                 // Also, assuming that we can't have an image sized as nx=5, ny=1, nz=5.
06622                 nypad = ny;
06623                 nzpad = nz;
06624         } else if (nz == 1) {
06625                 // 2-d image, don't want to pad along z
06626                 nzpad = nz;
06627         }
06628         size_t bytes;
06629         size_t offset;
06630         // Not currently fft-extended, so we want to extend for ffts
06631         offset = 2 - nxpad%2;
06632         bytes = nx*sizeof(float);
06633         EMData* fpimage = copy_head();
06634         fpimage->set_size(nxpad+offset, nypad, nzpad);
06635         int xstart = 0, ystart = 0, zstart = 0;
06636         if( npad > 1) {
06637                 if( valtype==0 ) {
06638                         fpimage->to_zero();
06639                 } else {
06640                         float val = circumference(this, 1);
06641                         float* data = fpimage->get_data();
06642                         int nxyz = (nxpad+offset)*nypad*nzpad;
06643                         for( int i=0; i < nxyz; ++i )  data[i] = val;
06644                 }
06645 
06646                 xstart = (nxpad - nx)/2 + nx%2;
06647                 if(ny > 1) {
06648                         ystart = (nypad - ny)/2 + ny%2;
06649                         if(nz > 1) {
06650                                 zstart = (nzpad - nz)/2 + nz%2;
06651                         }
06652                 }
06653         }
06654 
06655 
06656         vector<int> saved_offsets = this->get_array_offsets();
06657         this->set_array_offsets( 0, 0, 0 );
06658         for (int iz = 0; iz < nz; iz++) {
06659                 for (int iy = 0; iy < ny; iy++) {
06660                         memcpy(&(*fpimage)(xstart,iy+ystart,iz+zstart), &(*this)(0,iy,iz), bytes);
06661                 }
06662         }
06663         this->set_array_offsets( saved_offsets );
06664 
06665 
06666         //  Perform the actual normalization (only on the
06667         //  non-zero section of the image)
06668         if (donorm) { // Normalization requested
06669                 for (int iz = zstart; iz < nz+zstart; iz++)
06670                         for (int iy = ystart; iy < ny+ystart; iy++)
06671                                 for (int ix = xstart; ix < nx+xstart; ix++)
06672                                         (*fpimage)(ix,iy,iz) = ((*fpimage)(ix,iy,iz)-mean)/stddev;
06673         }
06674 
06675         fpimage->set_fftpad(true);
06676         fpimage->set_attr("npad", npad);
06677         if (offset == 1) fpimage->set_fftodd(true);
06678         else             fpimage->set_fftodd(false);
06679         return fpimage;
06680 }

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

Definition at line 3804 of file emdata.cpp.

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

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

03804                                                             {           // sent MAXR value here later!!
03805         float *pcs=get_data();
03806         EMData *imagepcsfft = new EMData;
03807         imagepcsfft->set_size((size+2), (int)MAXR+1, 1);
03808         float *d=imagepcsfft->get_data();
03809 
03810         EMData *data_in=new EMData;
03811         data_in->set_size(size,1,1);
03812         float *in=data_in->get_data();
03813 
03814         for(int row=0; row<=(int)MAXR; ++row){
03815                 if(row<=(int)rmax) {
03816                         for(int i=0; i<size;++i)        in[i] = pcs[i+row*size]; // ming
03817                         data_in->set_complex(false);
03818                         data_in->do_fft_inplace();
03819                         for(int j=0;j<size+2;j++)  d[j+row*(size+2)]=in[j];
03820                 }
03821                 else for(int j=0;j<size+2;j++) d[j+row*(size+2)]=0.0;
03822         }
03823         imagepcsfft->update();
03824         delete data_in;
03825         return imagepcsfft;
03826 }

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 Transform3D reference

Definition at line 1035 of file emdata_sparx.cpp.

References bi, and cmplx().

Referenced by nn().

01036 {
01037         //std::cout<<"   onelinenn  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01038         int jp = (j >= 0) ? j+1 : n+j+1;
01039         //for(int i = 0; i <= 1; i++){for(int l = 0; l <= 2; l++){std::cout<<"  "<<tf[i][l]<<"  "<<std::endl;}}
01040         // loop over x
01041         for (int i = 0; i <= n2; i++) {
01042                 if (((i*i+j*j) < n*n/4) && !((0 == i) && (j < 0))) {
01043 //        if ( !((0 == i) && (j < 0))) {
01044                         float xnew = i*tf[0][0] + j*tf[1][0];
01045                         float ynew = i*tf[0][1] + j*tf[1][1];
01046                         float znew = i*tf[0][2] + j*tf[1][2];
01047                         std::complex<float> btq;
01048                         if (xnew < 0.) {
01049                                 xnew = -xnew;
01050                                 ynew = -ynew;
01051                                 znew = -znew;
01052                                 btq = conj(bi->cmplx(i,jp));
01053                         } else {
01054                                 btq = bi->cmplx(i,jp);
01055                         }
01056                         int ixn = int(xnew + 0.5 + n) - n;
01057                         int iyn = int(ynew + 0.5 + n) - n;
01058                         int izn = int(znew + 0.5 + n) - n;
01059                         
01060                         int iza, iya;
01061                         if (izn >= 0)  iza = izn + 1;
01062                         else           iza = n + izn + 1;
01063 
01064                         if (iyn >= 0) iya = iyn + 1;
01065                         else          iya = n + iyn + 1;
01066 
01067                         cmplx(ixn,iya,iza) += btq;
01068                         //std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<btq<<std::endl;
01069                         (*wptr)(ixn,iya,iza)++;
01070                         
01071                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2)  && (izn >= -n2) && (izn <= n2)) {
01072                                 if (ixn >= 0) {
01073                                         int iza, iya;
01074                                         if (izn >= 0)  iza = izn + 1;
01075                                         else           iza = n + izn + 1;
01076 
01077                                         if (iyn >= 0) iya = iyn + 1;
01078                                         else          iya = n + iyn + 1;
01079 
01080                                         cmplx(ixn,iya,iza) += btq;
01081                                         //std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<btq<<std::endl;
01082                                         (*wptr)(ixn,iya,iza)++;
01083                                 } else {
01084                                         int izt, iyt;
01085                                         if (izn > 0) izt = n - izn + 1;
01086                                         else         izt = -izn + 1;
01087 
01088                                         if (iyn > 0) iyt = n - iyn + 1;
01089                                         else         iyt = -iyn + 1;
01090 
01091                                         cmplx(-ixn,iyt,izt) += conj(btq);
01092                                         //std::cout<<" *  "<<j<<"  "<<ixn<<"  "<<iyt<<"  "<<izt<<"  "<<btq<<std::endl;
01093                                         (*wptr)(-ixn,iyt,izt)++;
01094                                 }
01095                         }*/
01096                 }
01097         }
01098 }

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 Transform3D reference
mult 

Definition at line 1607 of file emdata_sparx.cpp.

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

Referenced by nn_ctf().

01608                                                                                 {//std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01609 
01610         int remove = bi->get_attr_default( "remove", 0 );
01611 
01612         int jp = (j >= 0) ? j+1 : n+j+1;
01613         // loop over x
01614         for (int i = 0; i <= n2; i++) {
01615                 int r2 = i*i+j*j;
01616                 if ( (r2<n*n/4) && !((0==i) && (j<0)) ) {
01617                         float  ctf = ctf_store::get_ctf( r2 );
01618                         float xnew = i*tf[0][0] + j*tf[1][0];
01619                         float ynew = i*tf[0][1] + j*tf[1][1];
01620                         float znew = i*tf[0][2] + j*tf[1][2];
01621                         std::complex<float> btq;
01622                         if (xnew < 0.) {
01623                                 xnew = -xnew;
01624                                 ynew = -ynew;
01625                                 znew = -znew;
01626                                 btq = conj(bi->cmplx(i,jp));
01627                         } else  btq = bi->cmplx(i,jp);
01628                         int ixn = int(xnew + 0.5 + n) - n;
01629                         int iyn = int(ynew + 0.5 + n) - n;
01630                         int izn = int(znew + 0.5 + n) - n;
01631                         
01632                         int iza, iya;
01633                         if (izn >= 0)  iza = izn + 1;
01634                         else           iza = n + izn + 1;
01635 
01636                         if (iyn >= 0) iya = iyn + 1;
01637                         else          iya = n + iyn + 1;
01638 
01639                         if(remove > 0 ) {
01640                                 cmplx(ixn,iya,iza) -= btq*ctf*float(mult);
01641                                 (*w)(ixn,iya,iza) -= ctf*ctf*mult;
01642                         } else {
01643                                 cmplx(ixn,iya,iza) += btq*ctf*float(mult);
01644                                 (*w)(ixn,iya,iza) += ctf*ctf*mult;
01645                         }
01646 
01647                                        //       std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<ctf<<std::endl;
01648                 
01649                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2) && (izn >= -n2) && (izn <= n2)) {
01650                                 if (ixn >= 0) {
01651                                         int iza, iya;
01652                                         if (izn >= 0)  iza = izn + 1;
01653                                         else           iza = n + izn + 1;
01654 
01655                                         if (iyn >= 0) iya = iyn + 1;
01656                                         else          iya = n + iyn + 1;
01657 
01658                                         if(remove > 0 ) {
01659                                             cmplx(ixn,iya,iza) -= btq*ctf*float(mult);
01660                                             (*w)(ixn,iya,iza) -= ctf*ctf*mult;
01661                                         } else {
01662                                             cmplx(ixn,iya,iza) += btq*ctf*float(mult);
01663                                             (*w)(ixn,iya,iza) += ctf*ctf*mult;
01664                                         }
01665 
01666                                        //       std::cout<<"    "<<j<<"  "<<ixn<<"  "<<iya<<"  "<<iza<<"  "<<ctf<<std::endl;
01667                                 } else {
01668                                         int izt, iyt;
01669                                         if (izn > 0) izt = n - izn + 1;
01670                                         else         izt = -izn + 1;
01671 
01672                                         if (iyn > 0) iyt = n - iyn + 1;
01673                                         else         iyt = -iyn + 1;
01674 
01675                                         if( remove > 0 ) {
01676                                             cmplx(-ixn,iyt,izt) -= conj(btq)*ctf*float(mult);
01677                                             (*w)(-ixn,iyt,izt) -= ctf*ctf*float(mult);
01678                                         } else {
01679                                             cmplx(-ixn,iyt,izt) += conj(btq)*ctf*float(mult);
01680                                             (*w)(-ixn,iyt,izt) += ctf*ctf*float(mult);
01681                                         }
01682 
01683                                         //      std::cout<<" *  " << j << "  " <<-ixn << "  " << iyt << "  " << izt << "  " << ctf <<std::endl;
01684                                 }
01685                         }*/
01686                 }
01687         }
01688 }

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

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

Referenced by nn_ctf_applied().

01691                                                                                 {//std::cout<<"   onelinenn_ctf  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01692 
01693         int remove = bi->get_attr_default( "remove", 0 );
01694 
01695         int jp = (j >= 0) ? j+1 : n+j+1;
01696         // loop over x
01697         for (int i = 0; i <= n2; i++) {
01698                 int r2 = i*i + j*j;
01699                 if ( (r2< n*n/4) && !((0==i) && (j< 0)) ) {
01700                         float  ctf = ctf_store::get_ctf(r2);
01701 
01702                          //        if ( !((0 == i) && (j < 0))) {
01703                         float xnew = i*tf[0][0] + j*tf[1][0];
01704                         float ynew = i*tf[0][1] + j*tf[1][1];
01705                         float znew = i*tf[0][2] + j*tf[1][2];
01706                         std::complex<float> btq;
01707                         if (xnew < 0.) {
01708                                 xnew = -xnew;
01709                                 ynew = -ynew;
01710                                 znew = -znew;
01711                                 btq = conj(bi->cmplx(i,jp));
01712                         } else  btq = bi->cmplx(i,jp);
01713                         int ixn = int(xnew + 0.5 + n) - n;
01714                         int iyn = int(ynew + 0.5 + n) - n;
01715                         int izn = int(znew + 0.5 + n) - n;
01716                         
01717                         int iza, iya;
01718                         if (izn >= 0)  iza = izn + 1;
01719                         else           iza = n + izn + 1;
01720 
01721                         if (iyn >= 0) iya = iyn + 1;
01722                         else          iya = n + iyn + 1;
01723 
01724                         if( remove > 0 ) {
01725                                 cmplx(ixn,iya,iza) -= btq*float(mult);
01726                                 (*w)(ixn,iya,iza) -= mult*ctf*ctf;
01727                         } else {
01728                                 cmplx(ixn,iya,iza) += btq*float(mult);
01729                                 (*w)(ixn,iya,iza) += mult*ctf*ctf;
01730                         }
01731 
01732 
01733                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2) && (izn >= -n2) && (izn <= n2)) {
01734                                 if (ixn >= 0) {
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                                 } else {
01751                                         int izt, iyt;
01752                                         if (izn > 0) izt = n - izn + 1;
01753                                         else         izt = -izn + 1;
01754 
01755                                         if (iyn > 0) iyt = n - iyn + 1;
01756                                         else         iyt = -iyn + 1;
01757 
01758 
01759                                         if( remove > 0 ) {
01760                                                 cmplx(-ixn,iyt,izt) -= conj(btq)*float(mult);
01761                                                 (*w)(-ixn,iyt,izt) -= mult*ctf*ctf;
01762                                         } else {
01763                                                 cmplx(-ixn,iyt,izt) += conj(btq)*float(mult);
01764                                                 (*w)(-ixn,iyt,izt) += mult*ctf*ctf;
01765                                         }
01766                                         //std::cout<<" *  "<<j<<"  "<<ixn<<"  "<<iyt<<"  "<<izt<<"  "<<btq<<std::endl;
01767                                 }
01768                         }*/
01769                 }
01770         }
01771 }

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

Definition at line 1101 of file emdata_sparx.cpp.

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

Referenced by nn().

01102 {
01103         //std::cout<<"   onelinenn  "<<j<<"  "<<n<<"  "<<n2<<"  "<<std::endl;
01104         int jp = (j >= 0) ? j+1 : n+j+1;
01105         //for(int i = 0; i <= 1; i++){for(int l = 0; l <= 2; l++){std::cout<<"  "<<tf[i][l]<<"  "<<std::endl;}}
01106         // loop over x
01107         for (int i = 0; i <= n2; i++) {
01108         if (((i*i+j*j) < n*n/4) && !((0 == i) && (j < 0))) {
01109 //        if ( !((0 == i) && (j < 0))) {
01110                         float xnew = i*tf[0][0] + j*tf[1][0];
01111                         float ynew = i*tf[0][1] + j*tf[1][1];
01112                         float znew = i*tf[0][2] + j*tf[1][2];
01113                         std::complex<float> btq;
01114                         if (xnew < 0.) {
01115                                 xnew = -xnew;
01116                                 ynew = -ynew;
01117                                 znew = -znew;
01118                                 btq = conj(bi->cmplx(i,jp));
01119                         } else {
01120                                 btq = bi->cmplx(i,jp);
01121                         }
01122                         int ixn = int(xnew + 0.5 + n) - n;
01123                         int iyn = int(ynew + 0.5 + n) - n;
01124                         int izn = int(znew + 0.5 + n) - n;
01125                         
01126                         
01127                         int iza, iya;
01128                         if (izn >= 0)  iza = izn + 1;
01129                         else           iza = n + izn + 1;
01130 
01131                         if (iyn >= 0) iya = iyn + 1;
01132                         else          iya = n + iyn + 1;
01133 
01134                         cmplx(ixn,iya,iza) += btq*float(mult);
01135                         (*wptr)(ixn,iya,iza)+=float(mult);
01136                         
01137                         /*if ((ixn <= n2) && (iyn >= -n2) && (iyn <= n2)  && (izn >= -n2) && (izn <= n2)) {
01138                                 if (ixn >= 0) {
01139                                         int iza, iya;
01140                                         if (izn >= 0)  iza = izn + 1;
01141                                         else           iza = n + izn + 1;
01142 
01143                                         if (iyn >= 0) iya = iyn + 1;
01144                                         else          iya = n + iyn + 1;
01145 
01146                                         cmplx(ixn,iya,iza) += btq*float(mult);
01147                                         (*wptr)(ixn,iya,iza)+=float(mult);
01148                                 } else {
01149                                         int izt, iyt;
01150                                         if (izn > 0) izt = n - izn + 1;
01151                                         else         izt = -izn + 1;
01152 
01153                                         if (iyn > 0) iyt = n - iyn + 1;
01154                                         else         iyt = -iyn + 1;
01155 
01156                                         cmplx(-ixn,iyt,izt) += conj(btq)*float(mult);
01157                                         (*wptr)(-ixn,iyt,izt)+=float(mult);
01158                                 }
01159                         }*/
01160                 }
01161         }
01162 }

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

Definition at line 910 of file emdata_core.cpp.

References mult(), and update().

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

EMData & EMData::operator *= float  n  ) 
 

Definition at line 875 of file emdata_core.cpp.

References mult(), and update().

00876 {
00877         mult(n);
00878         update();
00879         return *this;
00880 }

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

Definition at line 2282 of file emdata.h.

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

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

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

Definition at line 894 of file emdata_core.cpp.

References add(), and update().

00895 {
00896         add(em);
00897         update();
00898         return *this;
00899 }

EMData & EMData::operator+= float  n  ) 
 

Definition at line 860 of file emdata_core.cpp.

References add(), and update().

00861 {
00862         add(n);
00863         update();
00864         return *this;
00865 }

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

Definition at line 902 of file emdata_core.cpp.

References sub(), and update().

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

EMData & EMData::operator-= float  n  ) 
 

Definition at line 868 of file emdata_core.cpp.

00869 {
00870         *this += (-n);
00871         return *this;
00872 }

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

Definition at line 918 of file emdata_core.cpp.

References div(), and update().

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

EMData & EMData::operator/= float  n  ) 
 

Definition at line 883 of file emdata_core.cpp.

References LOGERR.

00884 {
00885         if (n == 0) {
00886                 LOGERR("divided by zero");
00887                 return *this;
00888         }
00889         *this *= (1.0f / n);
00890         return *this;
00891 }

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

Definition at line 2756 of file emdata.cpp.

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

02756                                                 {
02757         if (that.get_xsize() != nx || that.get_ysize() != ny || that.get_zsize() != nz ) return false;
02758 
02759         const float*  d1 = that.get_const_data();
02760         float* d2 = get_data();
02761 
02762         for(size_t i =0; i < get_size(); ++i,++d1,++d2) {
02763                 if ((*d1) != (*d2)) return false;
02764         }
02765         return true;
02766 
02767 }

void EMData::pad_corner float *  pad_image  ) 
 

Definition at line 4036 of file emdata_sparx.cpp.

References nx.

04036                                         {
04037         int nbytes = nx*sizeof(float);
04038         for (int iy=0; iy<ny; iy++)
04039                 memcpy(&(*this)(0,iy), pad_image+3+(iy+3)*nx, nbytes);
04040 }

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

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

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

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

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

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

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

Definition at line 4966 of file emdata_sparx.cpp.

References EMAN::Pixel::value.

04966                                                      {
04967     return (p1.value > p2.value);
04968 }

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

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

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

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

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

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

00927 {
00928         ENTERFUNC;
00929 
00930         if( n<0 ) {
00931                 throw InvalidValueException(n, "the power of negative integer not supported.");
00932         }
00933 
00934         EMData * r = this->copy();
00935         if( n == 0 ) {
00936                 r->to_one();
00937         }
00938         else if( n>1 ) {
00939                 for( int i=1; i<n; i++ ) {
00940                         *r *= *this;
00941                 }
00942         }
00943 
00944         r->update();
00945         return r;
00946 
00947         EXITFUNC;
00948 }

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

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

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

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::RT3DSphereAligner::align(), EMAN::RT3DGridAligner::align(), EMAN::Refine3DAligner::align(), EMAN::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::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(), EMAN::FourierReconstructorSimple2D::insert_slice(), make_rotational_footprint_e1(), EMAN::BackProjectionReconstructor::preprocess_slice(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::ScaleTransformProcessor::process(), refalifn(), refalifn3d(), 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::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::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(), and EMAN::Util::twoD_to_3D_ali().

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

References FileAccessException, get_data(), and portable_fseek().

00255                                                                                                                         {
00256         FILE *f = 0;
00257         f=fopen(fsp.c_str(), "rb");
00258         if (!f) throw FileAccessException(fsp);
00259         int fnx = nx;
00260         if (file_nx != 0) fnx = file_nx;
00261         int fny = ny;
00262         if (file_ny != 0) fny = file_ny;
00263         int fnz = nz;
00264         if (file_nz != 0) fnz = file_nz;
00265 
00266         portable_fseek(f,loc,SEEK_SET);
00267         EMUtil::process_region_io(get_data(), f, ImageIO::READ_ONLY,
00268                                                           0, 4,fnx,fny,fnz,area);
00269 //      portable_fseek(f,loc,SEEK_SET);
00270 //      if (fread(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00271         fclose(f);
00272 }

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 48 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(), read_images(), read_images_ext(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), recons3d_4nn(), and EMAN::TestUtil::verify_image_file_by_mode().

00050 {
00051         ENTERFUNC;
00052 
00053         ImageIO *imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY);
00054 
00055         if (!imageio) {
00056                 throw ImageFormatException("cannot create an image io");
00057         }
00058         else {
00059                 int err = imageio->read_header(attr_dict, img_index, region, is_3d);
00060                 if (err) {
00061                         throw ImageReadException(filename, "imageio read header failed");
00062                 }
00063                 else {
00064                         attr_dict["source_path"] = filename;
00065                         attr_dict["source_n"] = img_index;
00066                         if (imageio->is_complex_mode()) {
00067                                 set_complex(true);
00068                                 set_fftpad(true);
00069                         }
00070                         if (attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1) {
00071                                 set_fftodd(true);
00072                         }
00073                         if ((int) attr_dict["is_complex_ri"] == 1) {
00074                                 set_ri(true);
00075                         }
00076                         save_byteorder_to_dict(imageio);
00077 
00078                         nx = attr_dict["nx"];
00079                         ny = attr_dict["ny"];
00080                         nz = attr_dict["nz"];
00081 
00082 //                      if(attr_dict.has_key("ctf")) {
00083 //                              flags |= EMDATA_HASCTFF;
00084 //                      }
00085 //                      else {
00086 //                              flags &= ~EMDATA_HASCTFF;
00087 //                      }
00088 
00089                         if (!nodata) {
00090 
00091                                 if (region) {
00092                                         nx = (int)region->get_width();
00093                                         if (nx <= 0) nx = 1;
00094                                         ny = (int)region->get_height();
00095                                         if (ny <= 0) ny = 1;
00096                                         nz = (int)region->get_depth();
00097                                         if (nz <= 0) nz = 1;
00098                                         set_size(nx,ny,nz);
00099                                         to_zero(); // This could be avoided in favor of setting only the regions that were not read to to zero... but tedious
00100                                 } // else the dimensions of the file being read match those of this
00101                                 else {
00102                                         set_size(nx, ny, nz);
00103                                 }
00104 
00105                                 // If GPU features are enabled there is  danger that rdata will
00106                                 // not be allocated, but set_size takes care of this, so this
00107                                 // should be safe.
00108                                 int err = imageio->read_data(get_data(), img_index, region, is_3d);
00109                                 if (err) {
00110                                         throw ImageReadException(filename, "imageio read data failed");
00111                                 }
00112                                 else {
00113                                         update();
00114                                 }
00115                         }
00116                 }
00117         }
00118 
00119 #ifndef IMAGEIO_CACHE
00120         if( imageio )
00121         {
00122                 delete imageio;
00123                 imageio = 0;
00124         }
00125 #endif
00126         EXITFUNC;
00127 }

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

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

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

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

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

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

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

01042 {
01043         ENTERFUNC;
01044 
01045         EMData * e = new EMData();
01046 
01047         if( is_real() ) // a real image, return a copy of itself
01048         {
01049                 e = this->copy();
01050         }
01051         else //for a complex image
01052         {
01053                 if( !is_ri() )
01054                 {
01055                         delete e;
01056                         throw InvalidCallException("This image is in amplitude/phase format, this function call require a complex image in real/imaginary format.");
01057                 }
01058                 int nx = get_xsize();
01059                 int ny = get_ysize();
01060                 int nz = get_zsize();
01061                 e->set_size(nx/2, ny, nz);
01062                 float * edata = e->get_data();
01063                 float * data = get_data();
01064                 size_t idx1, idx2;
01065                 for( int i=0; i<nx; ++i )
01066                 {
01067                         for( int j=0; j<ny; ++j )
01068                         {
01069                                 for( int k=0; k<nz; ++k )
01070                                 {
01071                                         if( i%2 == 0 )
01072                                         {
01073                                                 //complex data in format [real, complex, real, complex...]
01074                                                 idx1 = i/2+j*(nx/2)+k*(nx/2)*ny;
01075                                                 idx2 = i+j*nx+k*nx*ny;
01076                                                 edata[idx1] = data[idx2];
01077                                         }
01078                                 }
01079                         }
01080                 }
01081         }
01082 
01083         e->set_complex(false);
01084         if(e->get_ysize()==1 && e->get_zsize()==1) {
01085                 e->set_complex_x(false);
01086         }
01087         e->update();
01088         return e;
01089 
01090         EXITFUNC;
01091 }

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

01299 {
01300         ENTERFUNC;
01301 
01302         if( is_complex() ) {
01303                 throw InvalidCallException("This function call only apply to real image");
01304         }
01305 
01306         EMData * e = new EMData();
01307         int nx = get_xsize();
01308         int ny = get_ysize();
01309         int nz = get_zsize();
01310         e->set_size(nx*2, ny, nz);
01311 
01312         for( int k=0; k<nz; ++k ) {
01313                 for( int j=0; j<ny; ++j ) {
01314                         for( int i=0; i<nx; ++i ) {
01315                                 (*e)(i*2,j,k) = (*this)(i,j,k);
01316                                 (*e)(i*2+1,j,k) = img;
01317                         }
01318                 }
01319         }
01320 
01321         e->set_complex(true);
01322         if(e->get_ysize()==1 && e->get_zsize()==1) {
01323                 e->set_complex_x(true);
01324         }
01325         e->set_ri(true);
01326         e->update();
01327         return e;
01328 
01329         EXITFUNC;
01330 }

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

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

00650 {
00651         ENTERFUNC;
00652 
00653         if (get_ndim() != 2) {
00654                 throw ImageDimensionException("2D only");
00655         }
00656 
00657         if (is_complex()) {
00658                 ri2ap();
00659         }
00660 
00661         if (render_max <= render_min) {
00662                 render_max = render_min + 0.01f;
00663         }
00664 
00665         std::string ret=std::string();
00666         ret.resize(iysize*bpl);
00667         unsigned char *data=(unsigned char *)ret.data();
00668 
00669         float rm = render_min;
00670         float inv_scale = 1.0f / scale;
00671         int ysize = iysize;
00672         int xsize = ixsize;
00673         const int scale_n = 100000;
00674 
00675         int ymin = 0;
00676         if ( iysize * inv_scale > ny) {
00677                 ymin = (int) (iysize - ny / inv_scale);
00678         }
00679         float gs = (maxgray - mingray) / (render_max - render_min);
00680         if (render_max < render_min) {
00681                 gs = 0;
00682                 rm = FLT_MAX;
00683         }
00684         int dsx = -1;
00685         int dsy = 0;
00686         if (inv_scale == floor(inv_scale)) {
00687                 dsx = (int) inv_scale;
00688                 dsy = (int) (inv_scale * nx);
00689         }
00690         int addi = 0;
00691         int addr = 0;
00692 
00693         if (dsx == -1) {
00694                 addi = (int) floor(inv_scale);
00695                 addr = (int) (scale_n * (inv_scale - floor(inv_scale)));
00696         }
00697 
00698         int remx = 0;
00699         int remy = 0;
00700         int xmin = 0;
00701         if (x0 < 0) {
00702                 xmin = (int) (-x0 / inv_scale);
00703                 xsize -= (int) floor(x0 / inv_scale);
00704                 x0 = 0;
00705         }
00706 
00707         if ((xsize - xmin) * inv_scale > (nx - x0)) {
00708                 xsize = (int) ((nx - x0) / inv_scale + xmin);
00709         }
00710         int ymax = ysize - 1;
00711         if (y0 < 0) {
00712                 ymax = (int) (ysize + y0 / inv_scale - 1);
00713                 ymin += (int) floor(y0 / inv_scale);
00714                 y0 = 0;
00715         }
00716 
00717 
00718         if (xmin < 0) {
00719                 xmin = 0;
00720         }
00721 
00722         if (ymin < 0) {
00723                 ymin = 0;
00724         }
00725         if (xsize > ixsize) {
00726                 xsize = ixsize;
00727         }
00728         if (ymax > iysize) {
00729                 ymax = iysize;
00730         }
00731 
00732         int lmax = nx * ny - 1;
00733         unsigned char tri[3];
00734         float* image_data = get_data();
00735         if (is_complex()) {
00736                 if (dsx != -1) {
00737                         int l = y0 * nx;
00738                         for (int j = ymax; j >= ymin; j--) {
00739                                 int ll = x0;
00740                                 for (int i = xmin; i < xsize; i++, ll += dsx) {
00741                                         if (l + ll > lmax || ll >= nx - 2) {
00742                                                 break;
00743                                         }
00744                                         int kk = 0;
00745                                         if (ll >= nx / 2) {
00746                                                 if (l >= (ny - inv_scale) * nx) {
00747                                                         kk = 2 * (ll - nx / 2) + 2;
00748                                                 }
00749                                                 else {
00750                                                         kk = 2 * (ll - nx / 2) + l + 2 + nx;
00751                                                 }
00752                                         }
00753                                         else {
00754                                                 kk = nx * ny - (l + 2 * ll) - 2;
00755                                         }
00756                                         int k = 0;
00757                                         float t = image_data[kk];
00758                                         if (t <= rm) {
00759                                                 k = mingray;
00760                                         }
00761                                         else if (t >= render_max) {
00762                                                 k = maxgray;
00763                                         }
00764                                         else {
00765                                                 k = (int) (gs * (t - render_min));
00766                                                 k += mingray;
00767                                         }
00768                                         tri[0] = static_cast < unsigned char >(k);
00769                                         cmap(ref, kk, tri);
00770                                         data[i * 3 + j * bpl] = tri[0];
00771                                         data[i * 3 + 1 + j * bpl] = tri[1];
00772                                         data[i * 3 + 2 + j * bpl] = tri[2];
00773                                 }
00774                                 l += dsy;
00775                         }
00776                 }
00777                 else {
00778                         remy = 10;
00779                         for (int j = ymax, l = y0 * nx; j >= ymin; j--) {
00780                                 int br = l;
00781                                 remx = 10;
00782                                 for (int i = xmin, ll = x0; i < xsize - 1; i++) {
00783                                         if (l + ll > lmax || ll >= nx - 2) {
00784                                                 break;
00785                                         }
00786                                         int kk = 0;
00787                                         if (ll >= nx / 2) {
00788                                                 if (l >= (ny * nx - nx)) {
00789                                                         kk = 2 * (ll - nx / 2) + 2;
00790                                                 }
00791                                                 else {
00792                                                         kk = 2 * (ll - nx / 2) + l + 2 + nx;
00793                                                 }
00794                                         }
00795                                         else {
00796                                                 kk = nx * ny - (l + 2 * ll) - 2;
00797                                         }
00798                                         int k = 0;
00799                                         float t = image_data[kk];
00800                                         if (t <= rm) {
00801                                                 k = mingray;
00802                                         }
00803                                         else if (t >= render_max) {
00804                                                 k = maxgray;
00805                                         }
00806                                         else {
00807                                                 k = (int) (gs * (t - render_min));
00808                                                 k += mingray;
00809                                         }
00810                                         tri[0] = static_cast < unsigned char >(k);
00811                                         cmap(ref, kk, tri);
00812                                         data[i * 3 + j * bpl] = tri[0];
00813                                         data[i * 3 + 1 + j * bpl] = tri[1];
00814                                         data[i * 3 + 2 + j * bpl] = tri[2];
00815                                         ll += addi;
00816                                         remx += addr;
00817                                         if (remx > scale_n) {
00818                                                 remx -= scale_n;
00819                                                 ll++;
00820                                         }
00821                                 }
00822                                 l = br + addi * nx;
00823                                 remy += addr;
00824                                 if (remy > scale_n) {
00825                                         remy -= scale_n;
00826                                         l += nx;
00827                                 }
00828                         }
00829                 }
00830         }
00831         else {
00832                 if (dsx != -1) {
00833                         for (int j = ymax, l = x0 + y0 * nx; j >= ymin; j--) {
00834                                 int br = l;
00835                                 for (int i = xmin; i < xsize; i++, l += dsx) {
00836                                         if (l > lmax) {
00837                                                 break;
00838                                         }
00839                                         float t = image_data[l];
00840                                         int k = 0;
00841                                         if (t <= rm) {
00842                                                 k = mingray;
00843                                         }
00844                                         else if (t >= render_max) {
00845                                                 k = maxgray;
00846                                         }
00847                                         else {
00848                                                 k = (int) (gs * (t - render_min));
00849                                                 k += mingray;
00850                                         }
00851                                         tri[0] = static_cast < unsigned char >(k);
00852                                         cmap(ref, l, tri);
00853                                         data[i * 3 + j * bpl] = tri[0];
00854                                         data[i * 3 + 1 + j * bpl] = tri[1];
00855                                         data[i * 3 + 2 + j * bpl] = tri[2];
00856                                 }
00857                                 l = br + dsy;
00858                         }
00859                 }
00860                 else {
00861                         remy = 10;
00862                         for (int j = ymax, l = x0 + y0 * nx; j >= ymin; j--) {
00863                                 int br = l;
00864                                 remx = 10;
00865                                 for (int i = xmin; i < xsize; i++) {
00866                                         if (l > lmax) {
00867                                                 break;
00868                                         }
00869                                         float t = image_data[l];
00870                                         int k = 0;
00871                                         if (t <= rm) {
00872                                                 k = mingray;
00873                                         }
00874                                         else if (t >= render_max) {
00875                                                 k = maxgray;
00876                                         }
00877                                         else {
00878                                                 k = (int) (gs * (t - render_min));
00879                                                 k += mingray;
00880                                         }
00881                                         tri[0] = static_cast < unsigned char >(k);
00882                                         cmap(ref, l, tri);
00883                                         data[i * 3 + j * bpl] = tri[0];
00884                                         data[i * 3 + 1 + j * bpl] = tri[1];
00885                                         data[i * 3 + 2 + j * bpl] = tri[2];
00886                                         l += addi;
00887                                         remx += addr;
00888                                         if (remx > scale_n) {
00889                                                 remx -= scale_n;
00890                                                 l++;
00891                                         }
00892                                 }
00893                                 l = br + addi * nx;
00894                                 remy += addr;
00895                                 if (remy > scale_n) {
00896                                         remy -= scale_n;
00897                                         l += nx;
00898                                 }
00899                         }
00900                 }
00901         }
00902 
00903         EXITFUNC;
00904 }

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

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

00377 {
00378         ENTERFUNC;
00379 
00380         int asrgb;
00381         int hist=(flags&2)/2;
00382         int invy=(flags&4)?1:0;
00383 
00384         if (!is_complex()) throw ImageDimensionException("complex only");
00385 
00386         if (get_ndim() != 2) {
00387                 throw ImageDimensionException("2D only");
00388         }
00389 
00390         if (is_complex()) ri2ap();
00391 
00392         if (render_max <= render_min) {
00393                 render_max = render_min + 0.01f;
00394         }
00395 
00396         if (gamma<=0) gamma=1.0;
00397 
00398         // Calculating a full floating point gamma for
00399         // each pixel in the image slows rendering unacceptably
00400         // however, applying a gamma-mapping to an 8 bit colorspace
00401         // has unaccepable accuracy. So, we oversample the 8 bit colorspace
00402         // as a 12 bit colorspace and apply the gamma mapping to that
00403         // This should produce good accuracy for gamma values
00404         // larger than 0.5 (and a high upper limit)
00405         static int smg0=0,smg1=0;       // while this destroys threadsafety in the rendering process
00406         static float sgam=0;            // it is necessary for speed when rendering large numbers of small images
00407         static unsigned char gammamap[4096];
00408         if (gamma!=1.0 && (smg0!=mingray || smg1!=maxgray || sgam!=gamma)) {
00409                 for (int i=0; i<4096; i++) {
00410                         if (mingray<maxgray) gammamap[i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00411                         else gammamap[4095-i]=(unsigned char)(mingray+(maxgray-mingray+0.999)*pow(((float)i/4096.0f),gamma));
00412                 }
00413         }
00414         smg0=mingray;   // so we don't recompute the map unless something changes
00415         smg1=maxgray;
00416         sgam=gamma;
00417 
00418         if (flags&8) asrgb=4;
00419         else if (flags&1) asrgb=3;
00420         else throw ImageDimensionException("must set flag 1 or 8");
00421 
00422         std::string ret=std::string();
00423 //      ret.resize(iysize*bpl);
00424         ret.assign(iysize*bpl+hist*1024,char(mingray));
00425         unsigned char *data=(unsigned char *)ret.data();
00426         unsigned int *histd=(unsigned int *)(data+iysize*bpl);
00427         if (hist) {
00428                 for (int i=0; i<256; i++) histd[i]=0;
00429         }
00430 
00431         float rm = render_min;
00432         float inv_scale = 1.0f / scale;
00433         int ysize = iysize;
00434         int xsize = ixsize;
00435 
00436         int ymin = 0;
00437         if (iysize * inv_scale > ny) {
00438                 ymin = (int) (iysize - ny / inv_scale);
00439         }
00440 
00441         float gs = (maxgray - mingray) / (render_max - render_min);
00442         float gs2 = 4095.999f / (render_max - render_min);
00443 //      float gs2 = 1.0 / (render_max - render_min);
00444         if (render_max < render_min) {
00445                 gs = 0;
00446                 rm = FLT_MAX;
00447         }
00448 
00449         int dsx = -1;
00450         int dsy = 0;
00451         int remx = 0;
00452         int remy = 0;
00453         const int scale_n = 100000;
00454 
00455         int addi = 0;
00456         int addr = 0;
00457         if (inv_scale == floor(inv_scale)) {
00458                 dsx = (int) inv_scale;
00459                 dsy = (int) (inv_scale * nx);
00460         }
00461         else {
00462                 addi = (int) floor(inv_scale);
00463                 addr = (int) (scale_n * (inv_scale - floor(inv_scale)));
00464         }
00465 
00466         int xmin = 0;
00467         if (x0 < 0) {
00468                 xmin = (int) (-x0 / inv_scale);
00469                 xsize -= (int) floor(x0 / inv_scale);
00470                 x0 = 0;
00471         }
00472 
00473         if ((xsize - xmin) * inv_scale > (nx - x0)) {
00474                 xsize = (int) ((nx - x0) / inv_scale + xmin);
00475         }
00476         int ymax = ysize - 1;
00477         if (y0 < 0) {
00478                 ymax = (int) (ysize + y0 / inv_scale - 1);
00479                 ymin += (int) floor(y0 / inv_scale);
00480                 y0 = 0;
00481         }
00482 
00483         if (xmin < 0) xmin = 0;
00484         if (ymin < 0) ymin = 0;
00485         if (xsize > ixsize) xsize = ixsize;
00486         if (ymax > iysize) ymax = iysize;
00487 
00488         int lmax = nx * ny - 1;
00489 
00490         int mid=nx*ny/2;
00491         float* image_data = get_data();
00492         if (dsx != -1) {
00493                 int l = y0 * nx;
00494                 for (int j = ymax; j >= ymin; j--) {
00495                         int ll = x0;
00496                         for (int i = xmin; i < xsize; i++) {
00497                                 if (l + ll > lmax || ll >= nx - 2) break;
00498 
00499                                 int k = 0;
00500                                 unsigned char p;
00501                                 int ph;
00502                                 if (ll >= nx / 2) {
00503                                         if (l >= (ny - inv_scale) * nx) k = 2 * (ll - nx / 2) + 2;
00504                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
00505                                         ph = (int)(image_data[k+1]*768/(2.0*M_PI))+384; // complex phase as integer 0-767
00506                                 }
00507                                 else {
00508                                         k = nx * ny - (l + 2 * ll) - 2;
00509                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00510                                 }
00511                                 if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00512                                 else k+=mid;
00513                                 float t = image_data[k];
00514                                 if (t <= rm)  p = mingray;
00515                                 else if (t >= render_max) p = maxgray;
00516                                 else if (gamma!=1.0) {
00517                                         k=(int)(gs2 * (t-render_min));          // map float value to 0-4096 range
00518                                         p = gammamap[k];                                        // apply gamma using precomputed gamma map
00519                                 }
00520                                 else {
00521                                         p = (unsigned char) (gs * (t - render_min));
00522                                         p += mingray;
00523                                 }
00524                                 if (ph<256) {
00525                                         data[i * asrgb + j * bpl] = p*(255-ph)/256;
00526                                         data[i * asrgb + j * bpl+1] = p*ph/256;
00527                                         data[i * asrgb + j * bpl+2] = 0;
00528                                 }
00529                                 else if (ph<512) {
00530                                         data[i * asrgb + j * bpl+1] = p*(511-ph)/256;
00531                                         data[i * asrgb + j * bpl+2] = p*(ph-256)/256;
00532                                         data[i * asrgb + j * bpl] = 0;
00533                                 }
00534                                 else {
00535                                         data[i * asrgb + j * bpl+2] = p*(767-ph)/256;
00536                                         data[i * asrgb + j * bpl] = p*(ph-512)/256;
00537                                         data[i * asrgb + j * bpl+1] = 0;
00538                                 }
00539                                 if (hist) histd[p]++;
00540                                 ll += dsx;
00541                         }
00542                         l += dsy;
00543                 }
00544         }
00545         else {
00546                 remy = 10;
00547                 int l = y0 * nx;
00548                 for (int j = ymax; j >= ymin; j--) {
00549                         int br = l;
00550                         remx = 10;
00551                         int ll = x0;
00552                         for (int i = xmin; i < xsize - 1; i++) {
00553                                 if (l + ll > lmax || ll >= nx - 2) {
00554                                         break;
00555                                 }
00556                                 int k = 0;
00557                                 unsigned char p;
00558                                 int ph;
00559                                 if (ll >= nx / 2) {
00560                                         if (l >= (ny * nx - nx)) k = 2 * (ll - nx / 2) + 2;
00561                                         else k = 2 * (ll - nx / 2) + l + 2 + nx;
00562                                         ph = (int)(image_data[k+1]*768/(2.0*M_PI))+384; // complex phase as integer 0-767
00563                                 }
00564                                 else {
00565                                         k = nx * ny - (l + 2 * ll) - 2;
00566                                         ph = (int)(-image_data[k+1]*768/(2.0*M_PI))+384;        // complex phase as integer 0-767
00567                                 }
00568                                 if (k>=mid) k-=mid;             // These 2 lines handle the Fourier origin being in the corner, not the middle
00569                                 else k+=mid;
00570 
00571                                 float t = image_data[k];
00572                                 if (t <= rm)
00573                                         p = mingray;
00574                                 else if (t >= render_max) {
00575                                         p = maxgray;
00576                                 }
00577                                 else if (gamma!=1.0) {
00578                                         k=(int)(gs2 * (t-render_min));          // map float value to 0-4096 range
00579                                         p = gammamap[k];                                        // apply gamma using precomputed gamma map
00580                                 }
00581                                 else {
00582                                         p = (unsigned char) (gs * (t - render_min));
00583                                         p += mingray;
00584                                 }
00585                                 if (ph<256) {
00586                                         data[i * asrgb + j * bpl] = p*(255-ph)/256;
00587                                         data[i * asrgb + j * bpl+1] = p*ph/256;
00588                                         data[i * asrgb + j * bpl+2] = 0;
00589                                 }
00590                                 else if (ph<512) {
00591                                         data[i * asrgb + j * bpl+1] = p*(511-ph)/256;
00592                                         data[i * asrgb + j * bpl+2] = p*(ph-256)/256;
00593                                         data[i * asrgb + j * bpl] = 0;
00594                                 }
00595                                 else {
00596                                         data[i * asrgb + j * bpl+2] = p*(767-ph)/256;
00597                                         data[i * asrgb + j * bpl] = p*(ph-512)/256;
00598                                         data[i * asrgb + j * bpl+1] = 0;
00599                                 }
00600                                 if (hist) histd[p]++;
00601                                 ll += addi;
00602                                 remx += addr;
00603                                 if (remx > scale_n) {
00604                                         remx -= scale_n;
00605                                         ll++;
00606                                 }
00607                         }
00608                         l = br + addi * nx;
00609                         remy += addr;
00610                         if (remy > scale_n) {
00611                                 remy -= scale_n;
00612                                 l += nx;
00613                         }
00614                 }
00615         }
00616 
00617         // this replicates r -> g,b
00618         if (asrgb==4) {
00619                 for (int j=ymin*bpl; j<=ymax*bpl; j+=bpl) {
00620                         for (int i=xmin; i<xsize*4; i+=4) {
00621                                 data[i+j+3]=255;
00622                         }
00623                 }
00624         }
00625 
00626         EXITFUNC;
00627 
00628         // ok, ok, not the most efficient place to do this, but it works
00629         if (invy) {
00630                 int x,y;
00631                 char swp;
00632                 for (y=0; y<iysize/2; y++) {
00633                         for (x=0; x<ixsize; x++) {
00634                                 swp=ret[y*bpl+x];
00635                                 ret[y*bpl+x]=ret[(iysize-y-1)*bpl+x];
00636                                 ret[(iysize-y-1)*bpl+x]=swp;
00637                         }
00638                 }
00639         }
00640 
00641     //  return PyString_FromStringAndSize((const char*) data,iysize*bpl);
00642         return ret;
00643 }

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

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

07288                                                               {
07289 
07290 
07291         bool   complex_input = this->is_complex();
07292         nx  = this->get_xsize();
07293         ny  = this->get_ysize();
07294         nz  = this->get_zsize();
07295         int nox;
07296         if (complex_input) nox = (nx - 2 + this->is_fftodd()); else nox = nx;
07297 
07298         EMData* fp = NULL; // output image
07299         if(complex_input) {
07300                 // fimage must remain pristine
07301                 fp = this->copy();
07302         } else {
07303                 fp = this->norm_pad( false, 1);
07304                 fp->do_fft_inplace();
07305         }
07306         float *fout = fp->get_data();
07307         float *fint = image->get_data();
07308         for ( int iz = 0; iz < nz; iz++) {
07309                 for ( int iy = 0; iy < ny; iy++) {
07310                         for ( int ix = 0; ix < nx; ix+=2) {
07311                                 float qt = fint(ix,iy,iz)*fint(ix,iy,iz)+fint(ix+1,iy,iz)*fint(ix+1,iy,iz);
07312                                 float rt = fout(ix,iy,iz)*fout(ix,iy,iz)+fout(ix+1,iy,iz)*fout(ix+1,iy,iz);
07313                                 if(rt > 1.0e-20) {
07314                                                 fout(ix,iy,iz) *= (qt/rt);
07315                                                 fout(ix+1,iy,iz) *= (qt/rt);
07316                                 } else {
07317                                                 qt = std::sqrt(qt/2.0f);
07318                                                 fout(ix,iy,iz) = qt;
07319                                                 fout(ix+1,iy,iz) = qt;
07320                                 }
07321                         }
07322                 }
07323         }
07324 
07325         fp->set_ri(1);
07326         fp->set_fftpad(true);
07327         fp->set_attr("npad", 1);
07328         if (nx%2 == 1) fp->set_fftodd(true);
07329         else fp->set_fftodd(false);
07330         if(RetReal) {
07331                 fp->do_ift_inplace();
07332                 fp->depad();
07333         }
07334         fp->set_array_offsets(0,0,0);
07335         fp->update();
07336 
07337         return fp;
07338 }

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

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

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

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

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

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

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

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

Definition at line 3270 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.

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

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
 

Definition at line 3331 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.

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

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

Definition at line 3410 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.

03410                                                                                                                         {
03411 
03412         int nxn, nyn, nzn;
03413 
03414         if (scale_input == 0.0f) scale_input = 1.0f;
03415         float  scale = 0.5f*scale_input;
03416 
03417         if (1 >= ny)
03418                 throw ImageDimensionException("Can't rotate 1D image");
03419         if (1 < nz)
03420                 throw ImageDimensionException("Use rot_scale_conv_new_background_3D for volumes");
03421         nxn = nx/2; nyn = ny/2; nzn = nz/2;
03422 
03423         vector<int> saved_offsets = get_array_offsets();
03424         set_array_offsets(0,0,0);
03425         EMData* ret = this->copy_head();
03426 #ifdef _WIN32
03427         ret->set_size(nxn, _cpp_max(nyn,1), _cpp_max(nzn,1));
03428 #else
03429         ret->set_size(nxn, std::max(nyn,1), std::max(nzn,1));
03430 #endif  //_WIN32
03431         //ret->to_zero();  //we will leave margins zeroed.
03432         delx = restrict2(delx, nx);
03433         dely = restrict2(dely, ny);
03434         // center of big image,
03435         int xc = nxn;
03436         int ixs = nxn%2;  // extra shift on account of odd-sized images
03437         int yc = nyn;
03438         int iys = nyn%2;
03439         // center of small image
03440         int xcn = nxn/2;
03441         int ycn = nyn/2;
03442         // shifted center for rotation
03443         float shiftxc = xcn + delx;
03444         float shiftyc = ycn + dely;
03445         // bounds if origin at center
03446         float ymin = -ny/2.0f;
03447         float xmin = -nx/2.0f;
03448         float ymax = -ymin;
03449         float xmax = -xmin;
03450         if (0 == nx%2) xmax--;
03451         if (0 == ny%2) ymax--;
03452 
03453         float* data = this->get_data();
03454 
03455         // trig
03456         float cang = cos(ang);
03457         float sang = sin(ang);
03458         for (int iy = 0; iy < nyn; iy++) {
03459                 float y = float(iy) - shiftyc;
03460                 float ycang = y*cang/scale + yc;
03461                 float ysang = -y*sang/scale + xc;
03462                 for (int ix = 0; ix < nxn; ix++) {
03463                         float x = float(ix) - shiftxc;
03464                         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
03465                         float yold = x*sang/scale + ycang-iys;
03466 
03467                         (*ret)(ix,iy) = Util::get_pixel_conv_new_background(nx, ny, 1, xold, yold, 1, data, kb, ix, iy);
03468                 }
03469         }
03470         set_array_offsets(saved_offsets);
03471         return ret;
03472 }

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
 

Definition at line 3474 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.

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

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 Transform3D object
Exceptions:
ImageDimensionException can not rotate 1 D image
Returns:
New rotated/shifted/scaled image

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

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

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

02412                                                                                    { // quadratic, no background, 2D
02413         float ang=angDeg*M_PI/180.0f;
02414         if (1 >= ny)
02415                 throw ImageDimensionException("Can't rotate 1D image");
02416         if (nz<2) {
02417                 vector<int> saved_offsets = get_array_offsets();
02418                 set_array_offsets(0,0,0);
02419                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02420                 EMData* ret = copy_head();
02421                 delx = restrict2(delx, nx);
02422                 dely = restrict2(dely, ny);
02423                 // center of image
02424                 int xc = nx/2;
02425                 int yc = ny/2;
02426                 // shifted center for rotation
02427                 float shiftxc = xc + delx;
02428                 float shiftyc = yc + dely;
02429                 // trig
02430                 float cang = cos(ang);
02431                 float sang = sin(ang);
02432                         for (int iy = 0; iy < ny; iy++) {
02433                                 float y = float(iy) - shiftyc;
02434                                 float ycang = y*cang/scale + yc;
02435                                 float ysang = -y*sang/scale + xc;
02436                                 for (int ix = 0; ix < nx; ix++) {
02437                                         float x = float(ix) - shiftxc;
02438                                         float xold = x*cang/scale + ysang ;
02439                                         float yold = x*sang/scale + ycang ;
02440                                         //  quadri is taking care of cyclic count
02441                                         (*ret)(ix,iy) = Util::quadri(xold+1.0f, yold+1.0f, nx, ny, get_data());
02442                                            //have to add one as quadri uses Fortran counting
02443                                 }
02444                         }
02445                 set_array_offsets(saved_offsets);
02446                 return ret;
02447         } else {
02448                 throw ImageDimensionException("Volume not currently supported");
02449         }
02450 }

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

02452                                                                                               { // quadratic, no background, 2D
02453     float ang=angDeg*M_PI/180.0f;
02454         if (1 >= ny)
02455                 throw ImageDimensionException("Can't rotate 1D image");
02456         if (nz<2) {
02457                 vector<int> saved_offsets = get_array_offsets();
02458                 set_array_offsets(0,0,0);
02459                 if (0.0f == scale) scale = 1.0f; // silently fix common user error
02460                 EMData* ret = copy_head();
02461                 delx = restrict2(delx, nx);
02462                 dely = restrict2(dely, ny);
02463                 // center of image
02464                 int xc = nx/2;
02465                 int yc = ny/2;
02466                 // shifted center for rotation
02467                 float shiftxc = xc + delx;
02468                 float shiftyc = yc + dely;
02469                 // trig
02470                 float cang = cos(ang);
02471                 float sang = sin(ang);
02472                         for (int iy = 0; iy < ny; iy++) {
02473                                 float y = float(iy) - shiftyc;
02474                                 float ycang = y*cang/scale + yc;
02475                                 float ysang = -y*sang/scale + xc;
02476                                 for (int ix = 0; ix < nx; ix++) {
02477                                         float x = float(ix) - shiftxc;
02478                                         float xold = x*cang/scale + ysang ;
02479                                         float yold = x*sang/scale + ycang ;
02480                                         //  in quadri_background, wrap around is not done circulantly; if (xold,yold) is not in the image, then it's replaced by (ix,iy)
02481                                         (*ret)(ix,iy) = Util::quadri_background(xold+1.0f, yold+1.0f, nx, ny, get_data(),ix+1,iy+1);
02482                                            //have to add one as quadri uses Fortran counting
02483                                 }
02484                         }
02485                 set_array_offsets(saved_offsets);
02486                 return ret;
02487         } else {
02488                 throw ImageDimensionException("Volume not currently supported");
02489         }
02490 }

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 Transform3D object
Exceptions:
ImageDimensionException can not rotate 1 D image
Returns:
New rotated/shifted/scaled image

Definition at line 2763 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.

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

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

References t, and transform().

00898 {
00899         Dict d("type","eman");
00900         d["az"] = az;
00901         d["alt"] = alt;
00902         d["phi"] = phi;
00903         Transform t(d);
00904         transform(t);
00905 }

void EMData::rotate const Transform3D t  ) 
 

Rotate this image.

DEPRECATED USE EMData::Transform

Parameters:
t Transformation rotation.

Definition at line 909 of file emdata.cpp.

References rotate_translate(), and t.

Referenced by frm_2d_Align(), and main().

00910 {
00911         cout << "Deprecation warning in EMData::rotate. Please consider using EMData::transform() instead " << endl;
00912         rotate_translate(t);
00913 }

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

References phi, rotate_translate(), t, and EMAN::Vec3f.

00941 {
00942         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00943         Transform3D t(Vec3f(dx, dy, dz), az, alt, phi, Vec3f(pdx,pdy,pdz));
00944         rotate_translate(t);
00945 }

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

References phi, rotate_translate(), t, and EMAN::Vec3f.

00932 {
00933         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00934         Transform3D t( az, alt, phi,Vec3f(dx, dy, dz));
00935         rotate_translate(t);
00936 }

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

void EMData::rotate_translate const Transform3D t  ) 
 

Rotate then translate the image.

DEPRECATED USE EMData::Transform

Parameters:
t The rotation and translation transformation to be done.

Definition at line 947 of file emdata.cpp.

References all_translation, attr_dict, EMAN::Dict::end(), EMAN::EMObject::f, EMAN::Dict::get(), EMAN::Transform3D::get_center(), get_data(), EMAN::Transform3D::get_posttrans(), EMAN::Transform3D::get_rotation(), EMAN::Transform3D::get_scale(), EMAN::Transform3D::inverse(), EMAN::Dict::keys(), nx, nx, nxy, ny, ny, nz, rdata, scale(), scale_pixel(), EMAN::Transform3D::set_scale(), t, update(), EMAN::Vec3f, x, and y.

Referenced by main(), rotate(), and rotate_translate().

00948 {
00949         cout << "Deprecation warning in EMData::rotate_translate. Please consider using EMData::transform() instead " << endl;
00950         ENTERFUNC;
00951 
00952 #if EMDATA_EMAN2_DEBUG
00953         std::cout << "start rotate_translate..." << std::endl;
00954 #endif
00955 
00956         float scale       = RA.get_scale();
00957         Vec3f dcenter     = RA.get_center();
00958         Vec3f translation = RA.get_posttrans();
00959         Dict rotation      = RA.get_rotation(Transform3D::EMAN);
00960 //      Transform3D mx = RA;
00961         Transform3D RAInv = RA.inverse(); // We're rotating the coordinate system, not the data
00962 //      RAInv.printme();
00963 #if EMDATA_EMAN2_DEBUG
00964         vector<string> keys = rotation.keys();
00965         vector<string>::const_iterator it;
00966         for(it=keys.begin(); it!=keys.end(); ++it) {
00967 //              std::cout << *it << " : " << rotation[*it] << std::endl;
00968                 std::cout << *it << " : " << (float)rotation.get(*it) << std::endl;
00969         }
00970 #endif
00971         float inv_scale = 1.0f;
00972 
00973         if (scale != 0) {
00974                 inv_scale = 1.0f / scale;
00975         }
00976 
00977         float *src_data = 0;
00978         float *des_data = 0;
00979 
00980         src_data = get_data();
00981         des_data = (float *) EMUtil::em_malloc(nx * ny * nz * sizeof(float));
00982 
00983         if (nz == 1) {
00984                 float x2c =  nx / 2 - dcenter[0] + RAInv[0][3];
00985                 float y2c =  ny / 2 - dcenter[1] + RAInv[1][3];
00986                 float y   = -ny / 2 + dcenter[1]; // changed 0 to 1 in dcenter and below
00987                 for (int j = 0; j < ny; j++, y += 1.0f) {
00988                         float x = -nx / 2 + dcenter[0];
00989                         for (int i = 0; i < nx; i++, x += 1.0f) {
00990                                 float x2 = RAInv[0][0]*x + RAInv[0][1]*y + x2c;
00991                                 float y2 = RAInv[1][0]*x + RAInv[1][1]*y + y2c;
00992 
00993                                 if (x2 < 0 || x2 >= nx || y2 < 0 || y2 >= ny ) {
00994                                         des_data[i + j * nx] = 0; // It may be tempting to set this value to the
00995                                         // mean but in fact this is not a good thing to do. Talk to S.Ludtke about it.
00996                                 }
00997                                 else {
00998                                         int ii = Util::fast_floor(x2);
00999                                         int jj = Util::fast_floor(y2);
01000                                         int k0 = ii + jj * nx;
01001                                         int k1 = k0 + 1;
01002                                         int k2 = k0 + nx;
01003                                         int k3 = k0 + nx + 1;
01004 
01005                                         if (ii == nx - 1) {
01006                                                 k1--;
01007                                                 k3--;
01008                                         }
01009                                         if (jj == ny - 1) {
01010                                                 k2 -= nx;
01011                                                 k3 -= nx;
01012                                         }
01013 
01014                                         float t = x2 - ii;
01015                                         float u = y2 - jj;
01016 
01017                                         des_data[i + j * nx] = Util::bilinear_interpolate(src_data[k0],src_data[k1], src_data[k2], src_data[k3],t,u); // This is essentially basic interpolation
01018                                 }
01019                         }
01020                 }
01021         }
01022         else {
01023 #if EMDATA_EMAN2_DEBUG
01024                 std::cout << "This is the 3D case." << std::endl    ;
01025 #endif
01026 
01027                 Transform3D mx = RA;
01028                 mx.set_scale(inv_scale);
01029 
01030 #if EMDATA_EMAN2_DEBUG
01031 //              std::cout << v4[0] << " " << v4[1]<< " " << v4[2]<< " "
01032 //                      << dcenter2[0]<< " "<< dcenter2[1]<< " "<< dcenter2[2] << std::endl;
01033 #endif
01034 
01035                 int nxy = nx * ny;
01036                 int l = 0;
01037 
01038                 float x2c =  nx / 2 - dcenter[0] + RAInv[0][3];;
01039                 float y2c =  ny / 2 - dcenter[1] + RAInv[1][3];;
01040                 float z2c =  nz / 2 - dcenter[2] + RAInv[2][3];;
01041 
01042                 float z   = -nz / 2 + dcenter[2]; //
01043 
01044                 size_t ii, k0, k1, k2, k3, k4, k5, k6, k7;
01045                 for (int k = 0; k < nz; k++, z += 1.0f) {
01046                         float y   = -ny / 2 + dcenter[1]; //
01047                         for (int j = 0; j < ny; j++,   y += 1.0f) {
01048                                 float x = -nx / 2 + dcenter[0];
01049                                 for (int i = 0; i < nx; i++, l++ ,  x += 1.0f) {
01050                                         float x2 = RAInv[0][0] * x + RAInv[0][1] * y + RAInv[0][2] * z + x2c;
01051                                         float y2 = RAInv[1][0] * x + RAInv[1][1] * y + RAInv[1][2] * z + y2c;
01052                                         float z2 = RAInv[2][0] * x + RAInv[2][1] * y + RAInv[2][2] * z + z2c;
01053 
01054 
01055                                         if (x2 < 0 || y2 < 0 || z2 < 0 ||
01056                                                 x2 >= nx  || y2 >= ny  || z2>= nz ) {
01057                                                 des_data[l] = 0;
01058                                         }
01059                                         else {
01060                                                 int ix = Util::fast_floor(x2);
01061                                                 int iy = Util::fast_floor(y2);
01062                                                 int iz = Util::fast_floor(z2);
01063                                                 float tuvx = x2-ix;
01064                                                 float tuvy = y2-iy;
01065                                                 float tuvz = z2-iz;
01066                                                 ii = ix + iy * nx + iz * nxy;
01067 
01068                                                 k0 = ii;
01069                                                 k1 = k0 + 1;
01070                                                 k2 = k0 + nx;
01071                                                 k3 = k0 + nx+1;
01072                                                 k4 = k0 + nxy;
01073                                                 k5 = k1 + nxy;
01074                                                 k6 = k2 + nxy;
01075                                                 k7 = k3 + nxy;
01076 
01077                                                 if (ix == nx - 1) {
01078                                                         k1--;
01079                                                         k3--;
01080                                                         k5--;
01081                                                         k7--;
01082                                                 }
01083                                                 if (iy == ny - 1) {
01084                                                         k2 -= nx;
01085                                                         k3 -= nx;
01086                                                         k6 -= nx;
01087                                                         k7 -= nx;
01088                                                 }
01089                                                 if (iz == nz - 1) {
01090                                                         k4 -= nxy;
01091                                                         k5 -= nxy;
01092                                                         k6 -= nxy;
01093                                                         k7 -= nxy;
01094                                                 }
01095 
01096                                                 des_data[l] = Util::trilinear_interpolate(src_data[k0],
01097                                                           src_data[k1],
01098                                                           src_data[k2],
01099                                                           src_data[k3],
01100                                                           src_data[k4],
01101                                                           src_data[k5],
01102                                                           src_data[k6],
01103                                                           src_data[k7],
01104                                                           tuvx, tuvy, tuvz);
01105 #if EMDATA_EMAN2_DEBUG
01106                                                 printf(" ix=%d \t iy=%d \t iz=%d \t value=%f \n", ix ,iy, iz, des_data[l] );
01107                                                 std::cout << src_data[ii] << std::endl;
01108 #endif
01109                                         }
01110                                 }
01111                         }
01112                 }
01113         }
01114 
01115         if( rdata )
01116         {
01117                 EMUtil::em_free(rdata);
01118                 rdata = 0;
01119         }
01120         rdata = des_data;
01121 
01122         scale_pixel(inv_scale);
01123 
01124         attr_dict["origin_x"] = (float) attr_dict["origin_x"] * inv_scale;
01125         attr_dict["origin_y"] = (float) attr_dict["origin_y"] * inv_scale;
01126         attr_dict["origin_z"] = (float) attr_dict["origin_z"] * inv_scale;
01127 
01128         update();
01129         all_translation += translation;
01130         EXITFUNC;
01131 }

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

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

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

01137 {
01138         ENTERFUNC;
01139 
01140         if (get_ndim() > 2) {
01141                 throw ImageDimensionException("no 3D image");
01142         }
01143 
01144 
01145         size_t row_size = nx * sizeof(float);
01146         float *tmp = (float*)EMUtil::em_malloc(row_size);
01147         float * data = get_data();
01148 
01149         for (int y = 0; y < ny; y++) {
01150                 int y_nx = y * nx;
01151                 for (int x = 0; x < nx; x++) {
01152                         tmp[x] = data[y_nx + (x + dx) % nx];
01153                 }
01154                 EMUtil::em_memcpy(&data[y_nx], tmp, row_size);
01155         }
01156 
01157         update();
01158         if( tmp )
01159         {
01160                 delete[]tmp;
01161                 tmp = 0;
01162         }
01163         EXITFUNC;
01164 }

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

00511                        {
00512 
00513         int rmax;
00514 
00515         ENTERFUNC;
00516 
00517 
00518         if (ny<2 && nz <2) {
00519                 LOGERR("No 1D images.");
00520                 throw ImageDimensionException("No 1D images!");
00521         }
00522         
00523         float apix[3];
00524         apix[0] = get_attr_default("apix_x",1.0);
00525         apix[1] = get_attr_default("apix_y",1.0);
00526         apix[2] = get_attr_default("apix_z",1.0);
00527         float min_apix = *std::min_element(&apix[0],&apix[3]);
00528         //here,only the relative value of apix_x, apix_y, apix_z are considered
00529         float apix_x = apix[0]/min_apix;
00530         float apix_y = apix[1]/min_apix;
00531         float apix_z = 1.0;
00532         if( nz > 1) 
00533                 apix_z=apix[2]/min_apix;
00534         float apix_x2 = apix_x*apix_x;
00535         float apix_y2 = apix_y*apix_y;
00536         float apix_z2 = apix_z*apix_z;
00537         
00538         vector<int> saved_offsets = get_array_offsets();
00539         set_array_offsets(-nx/2,-ny/2,-nz/2);
00540         
00541         
00542 #ifdef _WIN32
00543         //int rmax = _cpp_min(nx/2 + nx%2, ny/2 + ny%2);
00544         if ( nz == 1 ) {
00545                 rmax = _cpp_min( nx/2 + nx%2, ny/2 + ny%2);
00546         } else {
00547                 rmax = _cpp_min(nx/2 + nx%2, _cpp_min(ny/2 + ny%2, nz/2 + nz%2));
00548         }
00549 #else
00550         //int rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00551         if ( nz == 1 ) {
00552                 rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00553         } else {
00554                 rmax = std::min(nx/2 + nx%2, std::min(ny/2 + ny%2, nz/2 + nz%2));
00555         }
00556 #endif  //_WIN32
00557 
00558         float rmax_ratio = 0.0;
00559         if (rmax == nx/2 + nx%2 )
00560                 rmax_ratio = apix_x;
00561         else if (rmax == ny/2 + ny%2)
00562                 rmax_ratio = apix_y;
00563         else
00564                 rmax_ratio = apix_z;
00565         
00566         EMData* ret = new EMData();
00567         ret->set_size(rmax+1, 1, 1);
00568         ret->to_zero();
00569         vector<float> count(rmax+1);
00570         for (int k = -nz/2; k < nz/2 + nz%2; k++) {
00571                 if (abs( k*apix_z) > rmax*rmax_ratio ) continue;
00572                 for (int j = -ny/2; j < ny/2 + ny%2; j++) {
00573                         if (abs( j*apix_y ) > rmax*rmax_ratio) continue;
00574                         for (int i = -nx/2; i < nx/2 + nx%2; i++) {
00575                                 float r = std::sqrt(float(k*k*apix_z2) + float(j*j*apix_y2) + float(i*i*apix_x2))/rmax_ratio;
00576                                 int ir = int(r);
00577                                 if (ir >= rmax) continue;
00578                                 float frac = r - float(ir);
00579                                 (*ret)(ir) += (*this)(i,j,k)*(1.0f - frac);
00580                                 (*ret)(ir+1) += (*this)(i,j,k)*frac;
00581                                 count[ir] += 1.0f - frac;
00582                                 count[ir+1] += frac;
00583                         }
00584                 }
00585         }
00586         for (int ir = 0; ir <= rmax; ir++) {
00587         #ifdef _WIN32
00588                 (*ret)(ir) /= _cpp_max(count[ir],1.0f);
00589         #else
00590                 (*ret)(ir) /= std::max(count[ir],1.0f);
00591         #endif  //_WIN32
00592         }
00593 
00594         set_array_offsets(saved_offsets);
00595         ret->update();
00596         EXITFUNC;
00597         return ret;
00598 }

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

00600                          {
00601 
00602         int rmax;
00603         ENTERFUNC;
00604         if ( ny == 1 && nz == 1 ) {
00605                 LOGERR("Input image must be 2-D or 3-D!");
00606                 throw ImageDimensionException("Input image must be 2-D or 3-D!");
00607         }
00608 
00609         EMData* avg1D  = new EMData();
00610         EMData* result = new EMData();
00611 
00612         result->set_size(nx,ny,nz);
00613         result->to_zero();
00614         result->set_array_offsets(-nx/2, -ny/2, -nz/2);
00615 
00616         if ( nz == 1 ) {
00617 #ifdef  _WIN32
00618                 rmax = _cpp_min(nx/2 + nx%2, ny/2 + ny%2);
00619         } else {
00620                 rmax = _cpp_min(nx/2 + nx%2, _cpp_min(ny/2 + ny%2, nz/2 + nz%2));
00621 #else
00622                 rmax = std::min(nx/2 + nx%2, ny/2 + ny%2);
00623         } else {
00624                 rmax = std::min(nx/2 + nx%2, std::min(ny/2 + ny%2, nz/2 + nz%2));
00625 #endif  //_WIN32
00626         }
00627 
00628         avg1D = rotavg();
00629         float padded_value = 0.0, r;
00630         int i, j, k, ir;
00631         long int number_of_pixels = 0;
00632         for ( k = -nz/2; k < nz/2 + nz%2; k++) {
00633                 if (abs(k) > rmax) continue;
00634                 for ( j = -ny/2; j < ny/2 + ny%2; j++) {
00635                         if (abs(j) > rmax) continue;
00636                         for (i = -nx/2; i < nx/2 + nx%2; i++) {
00637                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00638                                 ir = int(r);
00639                                 if (ir > rmax || ir < rmax-2 ) continue ;
00640                                 else {
00641                                         padded_value += (*avg1D)(ir) ;
00642                                         number_of_pixels++ ;
00643                                 }
00644                         }
00645                 }
00646         }
00647         padded_value /= number_of_pixels;
00648         for ( k = -nz/2; k < nz/2 + nz%2; k++) {
00649                 for ( j = -ny/2; j < ny/2 + ny%2; j++) {
00650                         for ( i = -nx/2; i < nx/2 + nx%2; i++)  {
00651                                 r = std::sqrt(float(k*k) + float(j*j) + float(i*i));
00652                                 ir = int(r);
00653                                 if (ir >= rmax) (*result)(i,j,k) = padded_value ;
00654                                 else            (*result)(i,j,k) = (*avg1D)(ir)+((*avg1D)(ir+1)-(*avg1D)(ir))*(r - float(ir));
00655 
00656                         }
00657                 }
00658         }
00659         result->update();
00660         result->set_array_offsets(0,0,0);
00661         EXITFUNC;
00662         return result;
00663 }

void EMData::save_byteorder_to_dict ImageIO imageio  )  [private]
 

Definition at line 3926 of file emdata.cpp.

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

Referenced by read_image().

03927 {
03928         string image_endian = "ImageEndian";
03929         string host_endian = "HostEndian";
03930 
03931         if (imageio->is_image_big_endian()) {
03932                 attr_dict[image_endian] = "big";
03933         }
03934         else {
03935                 attr_dict[image_endian] = "little";
03936         }
03937 
03938         if (ByteOrder::is_host_big_endian()) {
03939                 attr_dict[host_endian] = "big";
03940         }
03941         else {
03942                 attr_dict[host_endian] = "little";
03943         }
03944 }

void EMData::scale float  scale_factor  ) 
 

scale the image by a factor.

Parameters:
scale_factor scale factor.

Definition at line 824 of file emdata.cpp.

References EMAN::Transform::set_scale(), t, and transform().

Referenced by do_ift(), do_ift_inplace(), 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(), and rotate_translate().

00825 {
00826         ENTERFUNC;
00827         Transform t;
00828         t.set_scale(s);
00829         transform(t);
00830         EXITFUNC;
00831 }

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 1151 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(), EMAN::FFTResampleProcessor::process_inplace(), and rotate_translate().

01152 {
01153         attr_dict["apix_x"] = ((float) attr_dict["apix_x"]) * scale;
01154         attr_dict["apix_y"] = ((float) attr_dict["apix_y"]) * scale;
01155         attr_dict["apix_z"] = ((float) attr_dict["apix_z"]) * scale;
01156         if (attr_dict.has_key("ctf")) {
01157                 Ctf *ctf=(Ctf *)attr_dict["ctf"];
01158                 ctf->apix*=scale;
01159                 attr_dict["ctf"]=ctf;
01160                 if(ctf) {delete ctf; ctf=0;}
01161         }
01162 }

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

Definition at line 2299 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 2293 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(), 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 1089 of file emdata_metadata.cpp.

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

Referenced by ali3d_d(), EMAN::RT3DSphereAligner::align(), EMAN::RT3DGridAligner::align(), EMAN::Refine3DAligner::align(), EMAN::RefineAligner::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::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::TomoCccCmp::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(), 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().

01090 {
01091         if( key == "nx" && nx != (int)val) { set_size((int)val,ny,nz); return; }
01092         if( key == "ny" && ny != (int)val) { set_size(nx,(int)val,nz); return; }
01093         if( key == "nz" && nz != (int)val) { set_size(nx,ny,(int)val); return; }
01094 
01095         /* Ignore 'read only' attribute. */
01096         if(key == "sigma" ||
01097                 key == "sigma_nonzero" ||
01098                 key == "square_sum" ||
01099                 key == "maximum" ||
01100                 key == "minimum" ||
01101                 key == "mean" ||
01102                 key == "mean_nonzero" )
01103         {
01104                 LOGWARN("Ignore setting read only attribute %s", key.c_str());
01105                 return;
01106         }
01107 
01108         attr_dict[key] = val;
01109 
01110 
01111 
01112 }

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

01042 {
01043         /*set nx, ny nz may resize the image*/
01044         // This wasn't supposed to 'clip' the image, but just redefine the size --steve
01045         if( ( new_dict.has_key("nx") && nx!=(int)new_dict["nx"] )
01046                 || ( new_dict.has_key("ny") && ny!=(int)new_dict["ny"] )
01047                 || ( new_dict.has_key("nz") && nz!=(int)new_dict["nz"] ) ) {
01048 
01049                 int newx, newy, newz;
01050                 newx = new_dict.has_key("nx") ? (int)new_dict["nx"] : nx;
01051                 newy = new_dict.has_key("ny") ? (int)new_dict["ny"] : ny;
01052                 newz = new_dict.has_key("nz") ? (int)new_dict["nz"] : nz;
01053 
01054                 set_size(newx,newy,newz);
01055 
01056 //              EMData * new_image = get_clip(Region((nx-newx)/2, (ny-newy)/2, (nz=newz)/2, newx, newy, newz));
01057 //              if(new_image) {
01058 //                      this->operator=(*new_image);
01059 //                      delete new_image;
01060 //                      new_image = 0;
01061 //              }
01062         }
01063 
01064         vector<string> new_keys = new_dict.keys();
01065         vector<string>::const_iterator it;
01066         for(it = new_keys.begin(); it!=new_keys.end(); ++it) {
01067                 this->set_attr(*it, new_dict[*it]);
01068         }
01069 }

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

References attr_dict.

01072 {
01073         attr_dict = new_dict;
01074 }

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

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

01115 {
01116         if( key == "nx" && nx != (int)val) { set_size((int)val,ny,nz); return; }
01117         if( key == "ny" && ny != (int)val) { set_size(nx,(int)val,nz); return; }
01118         if( key == "nz" && nz != (int)val) { set_size(nx,ny,(int)val); return; }
01119 
01120         /* Ignore 'read only' attribute. */
01121         if(key == "sigma" ||
01122                   key == "sigma_nonzero" ||
01123                   key == "square_sum" ||
01124                   key == "maximum" ||
01125                   key == "minimum" ||
01126                   key == "mean" ||
01127                   key == "mean_nonzero" )
01128         {
01129                 LOGWARN("Ignore setting read only attribute %s", key.c_str());
01130                 return;
01131         }
01132 
01133         EMObject::ObjectType argtype = val.get_type();
01134         if (argtype == EMObject::EMDATA) {
01135                 EMData* e = (EMData*) val;
01136                 e = e->copy();
01137                 EMObject v(e);
01138                 attr_dict[key] = v;
01139         }
01140         else if (argtype == EMObject::TRANSFORM) {
01141                 Transform* t = new Transform(*((Transform*) val));
01142                 EMObject v(t);
01143                 attr_dict[key] = v;
01144                 delete t; t=0;
01145         } else {
01146                 attr_dict[key] = val;
01147         }
01148 
01149 }

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

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

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

00719 {
00720         ENTERFUNC;
00721 
00722         if (get_ndim() != 2) {
00723                 throw ImageDimensionException("2D image only");
00724         }
00725         if (d->get_ndim() != 1) {
00726                 throw ImageDimensionException("1D image only");
00727         }
00728 
00729         float *dst = get_data();
00730         float *src = d->get_data();
00731 
00732         for (int i = 0; i < ny; i++) {
00733                 dst[i * nx + n] = src[i];
00734         }
00735 
00736         update();
00737         EXITFUNC;
00738 }

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

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

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

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

00173                                                                                                {
00174 if (abs(x)>=nx/2 || abs(y)>ny/2 || abs(z)>nz/2) return;
00175 //if (x==0 && (y!=0 || z!=0)) set_complex_at(0,-y,-z,conj(val));
00176 
00177 // for x=0, we need to insert the value in 2 places
00178 // complex conjugate insertion. Removed due to ambiguity with returned index
00179 /*if (x==0 && (y!=0 || z!=0)) {
00180         size_t idx=(y<=0?-y:ny-y)*nx+(z<=0?-z:nz-z)*nx*ny;
00181         rdata[idx]=(float)val.real();
00182         rdata[idx+1]=(float)-val.imag();
00183 }*/
00184 
00185 size_t idx;
00186 if (x<0) {
00187         idx=-x*2+(y<=0?-y:ny-y)*(size_t)nx+(z<=0?-z:nz-z)*(size_t)nxy;
00188         rdata[idx]=(float)val.real();
00189         rdata[idx+1]=-(float)val.imag();
00190         return;
00191 }
00192 
00193 idx=x*2+(y<0?ny+y:y)*(size_t)nx+(z<0?nz+z:z)*(size_t)nxy;
00194 rdata[idx]=(float)val.real();
00195 rdata[idx+1]=(float)val.imag();
00196 
00197 return;
00198 }

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

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

00164                                                                                   {
00165         if (abs(x)>=nx/2 || abs(y)>ny/2) return;
00166         if (x>=0 && y>=0) { rdata[ x*2+y*nx]=val.real(); rdata[x*2+y*nx+1]=val.imag(); }
00167         else if (x>0 && y<0) { rdata[ x*2+(ny+y)*nx]=val.real(); rdata[x*2+(ny+y)*nx+1]=val.imag(); }
00168         else if (x<0 && y>0) { rdata[-x*2+(ny-y)*nx]=val.real(); rdata[-x*2+(ny-y)*nx+1]=-val.imag(); }
00169         else { rdata[-x*2-y*nx]=val.real(); rdata[-x*2+-y*nx+1]=-val.imag(); }
00170         return;
00171 }

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

00749                                           {

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

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

References attr_dict, and EMAN::Ctf::to_vector().

00688 {
00689         ENTERFUNC;
00690 
00691         vector<float> vctf = new_ctf->to_vector();
00692         attr_dict["ctf"] = vctf;
00693 
00694         EXITFUNC;
00695 }

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

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

00380                                    : an algorithm that transforms an original

void EMData::set_data_pickle std::string  vf  ) 
 

Definition at line 1178 of file emdata_metadata.cpp.

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

01179 {
01180 //      if (rdata) printf("rdata exists\n");
01181 //      rdata = (float *)malloc(nx*ny*nz*sizeof(float));
01182 //      std::copy(vf.begin(), vf.end(), rdata);
01183         EMUtil::em_memcpy(get_data(),vf.data(),nx*ny*nz*sizeof(float));
01184 
01185 }

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 1170 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 1138 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 983 of file emdata.h.

Referenced by FH2F(), and real2FH().

00988         {
00989                 return Transform3D((float)attr_dict["euler_alt"],
00990                                    (float)attr_dict["euler_az"],
00991                                    (float)attr_dict["euler_phi"]);
00992         }
00993 */

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

Definition at line 1198 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 1070 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 1184 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 631 of file emdata.h.

Referenced by calc_mutual_correlation(), and get_clip().

00749                                           {

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

Set the number of paths.

Parameters:
n The number of paths.

Definition at line 640 of file emdata.h.

Referenced by get_clip().

00749                                           {

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 1105 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 Transform3D t3d  )  [inline]
 

Define the 3D orientation of this particle Orientation information is extracted from a Transform3D object and stored internally in EMAN (az,alt,phi) format.

Parameters:
t3d a Transform3D object containing the particle orientation

Definition at line 586 of file emdata.h.

00749                                           {

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

Referenced by main().

00749                                           {

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

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

00678 {
00679         ENTERFUNC;
00680 
00681         if (get_ndim() > 2) {
00682                 throw ImageDimensionException("1D/2D image only");
00683         }
00684         if (d->get_ndim() != 1) {
00685                 throw ImageDimensionException("1D image only");
00686         }
00687 
00688         float *dst = get_data();
00689         float *src = d->get_data();
00690         memcpy(dst + nx * row_index, src, nx * sizeof(float));
00691         update();
00692         EXITFUNC;
00693 }

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

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 714 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_ift_inplace(), 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(), EMAN::Util::im_diff(), imag(), EMAN::BackProjectionReconstructor::insert_slice(), 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().

00715 {
00716         ENTERFUNC;
00717 
00718         if (x <= 0) {
00719                 throw InvalidValueException(x, "x size <= 0");
00720         }
00721         else if (y <= 0) {
00722                 throw InvalidValueException(y, "y size <= 0");
00723         }
00724         else if (z <= 0) {
00725                 throw InvalidValueException(z, "z size <= 0");
00726         }
00727 
00728         int old_nx = nx;
00729 
00730         size_t size = (size_t)(x) * (size_t)y * (size_t)z * sizeof(float);
00731 
00732         if (rdata != 0) {
00733                 rdata = (float*)EMUtil::em_realloc(rdata,size);
00734         } else {
00735                 // Just pass on this for a while....see what happens
00736                 rdata = (float*)EMUtil::em_malloc(size);
00737         }
00738 //      rdata = static_cast < float *>(realloc(rdata, size));
00739         if ( rdata == 0 )
00740         {
00741                 stringstream ss;
00742                 string gigs;
00743                 ss << (float) size/1000000000.0;
00744                 ss >> gigs;
00745                 string message = "Cannot allocate " + gigs + " GB - not enough memory.";
00746                 throw BadAllocException(message);
00747         }
00748 
00749 #ifdef EMAN2_USING_CUDA
00750         // This is important
00751         free_cuda_memory();
00752 #endif // EMAN2_USING_CUDA
00753 
00754         nx = x;
00755         ny = y;
00756         nz = z;
00757         nxy = nx*ny;
00758         nxyz = nx*ny*nz;
00759 
00760         if (old_nx == 0) {
00761                 EMUtil::em_memset(get_data(),0,size);
00762         }
00763 
00764         if (supp) {
00765                 EMUtil::em_free(supp);
00766                 supp = 0;
00767         }
00768 
00769         update();
00770         EXITFUNC;
00771 }

void EMData::set_supp_pickle int  i  ) 
 

Definition at line 1192 of file emdata_metadata.cpp.

References supp.

01193 {
01194         this->supp = 0;
01195 }

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

00749                                           {

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

00749                                           {

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 2214 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 2173 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 2115 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 2234 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 2199 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 2147 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 2160 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 2868 of file emdata.cpp.

References attr_dict.

Referenced by clip_inplace(), and get_clip().

02869 {
02870         attr_dict["origin_x"] = origin_x;
02871         attr_dict["origin_y"] = origin_y;
02872         attr_dict["origin_z"] = origin_z;
02873 }

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

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

00761 {
00762         ENTERFUNC;
00763 
00764         if (!is_complex()) {
00765                 throw ImageFormatException("complex image only");
00766         }
00767 
00768         if (get_ndim() != 3) {
00769                 throw ImageDimensionException("3D only");
00770         }
00771 
00772         if (supp) {
00773                 if (redo) {
00774                         EMUtil::em_free(supp);
00775                         supp = 0;
00776                 }
00777                 else {
00778                         EXITFUNC;
00779                         return supp;
00780                 }
00781         }
00782 
00783         const int SUPP_ROW_SIZE = 8;
00784         const int SUPP_ROW_OFFSET = 4;
00785         const int supp_size = SUPP_ROW_SIZE + SUPP_ROW_OFFSET;
00786 
00787         supp = (float *) EMUtil::em_calloc(supp_size * ny * nz, sizeof(float));
00788         int nxy = nx * ny;
00789         int supp_xy = supp_size * ny;
00790         float * data = get_data();
00791 
00792         for (int z = 0; z < nz; z++) {
00793                 size_t cur_z1 = z * nxy;
00794                 size_t cur_z2 = z * supp_xy;
00795 
00796                 for (int y = 0; y < ny; y++) {
00797                         size_t cur_y1 = y * nx;
00798                         size_t cur_y2 = y * supp_size;
00799 
00800                         for (int x = 0; x < SUPP_ROW_SIZE; x++) {
00801                                 size_t k = (x + SUPP_ROW_OFFSET) + cur_y2 + cur_z2;
00802                                 supp[k] = data[x + cur_y1 + cur_z1];
00803                         }
00804                 }
00805         }
00806 
00807         for (int z = 1, zz = nz - 1; z < nz; z++, zz--) {
00808                 size_t cur_z1 = zz * nxy;
00809                 size_t cur_z2 = z * supp_xy;
00810 
00811                 for (int y = 1, yy = ny - 1; y < ny; y++, yy--) {
00812                         supp[y * 12 + cur_z2] = data[4 + yy * nx + cur_z1];
00813                         supp[1 + y * 12 + cur_z2] = -data[5 + yy * nx + cur_z1];
00814                         supp[2 + y * 12 + cur_z2] = data[2 + yy * nx + cur_z1];
00815                         supp[3 + y * 12 + cur_z2] = -data[3 + yy * nx + cur_z1];
00816                 }
00817         }
00818 
00819         EXITFUNC;
00820         return supp;
00821 }

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

References get_data(), and nx.

00812 {
00813         size_t size = nx*ny;
00814         size *= nz;
00815         if (i >= size) {
00816                 return 0;
00817         }
00818         return get_data()[i];
00819 }

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

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

00803 {
00804         if (x < 0 || x >= nx || y < 0 || y >= ny) {
00805                 return 0;
00806         }
00807         return get_data()[x + y * nx];
00808 }

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

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

Referenced by sget_value_at_interp().

00794 {
00795         if (x < 0 || x >= nx || y < 0 || y >= ny || z < 0 || z >= nz) {
00796                 return 0;
00797         }
00798         return get_data()[x + y * nx + z * nxy];
00799 }

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

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

00838 {
00839         int x = (int) Util::fast_floor(xx);
00840         int y = (int) Util::fast_floor(yy);
00841         int z = (int) Util::fast_floor(zz);
00842 
00843         float p1 = sget_value_at(x, y, z);
00844         float p2 = sget_value_at(x + 1, y, z);
00845         float p3 = sget_value_at(x, y + 1, z);
00846         float p4 = sget_value_at(x + 1, y + 1, z);
00847 
00848         float p5 = sget_value_at(x, y, z + 1);
00849         float p6 = sget_value_at(x + 1, y, z + 1);
00850         float p7 = sget_value_at(x, y + 1, z + 1);
00851         float p8 = sget_value_at(x + 1, y + 1, z + 1);
00852 
00853         float result = Util::trilinear_interpolate(p1, p2, p3, p4, p5, p6, p7, p8,
00854                                                                                            xx - x, yy - y, zz - z);
00855 
00856         return result;
00857 }

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

00823 {
00824         int x = static_cast < int >(Util::fast_floor(xx));
00825         int y = static_cast < int >(Util::fast_floor(yy));
00826 
00827         float p1 = sget_value_at(x, y);
00828         float p2 = sget_value_at(x + 1, y);
00829         float p3 = sget_value_at(x, y + 1);
00830         float p4 = sget_value_at(x + 1, y + 1);
00831 
00832         float result = Util::bilinear_interpolate(p1, p2, p3, p4, xx - x, yy - y);
00833         return result;
00834 }

void EMData::shuffle_pad_corner float *  pad_image  ) 
 

Definition at line 4042 of file emdata_sparx.cpp.

References nx, nx, and ny.

04042                                                 {
04043         int nyhalf = ny/2;
04044         int nbytes = nx*sizeof(float);
04045         for (int iy = 0; iy < nyhalf; iy++)
04046                 memcpy(&(*this)(0,iy), pad_image+6+(iy+nyhalf+3)*nx, nbytes);
04047         for (int iy = nyhalf; iy < ny; iy++)
04048                 memcpy(&(*this)(0,iy), pad_image+6+(iy-nyhalf+3)*nx, nbytes);
04049 }

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

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

00952 {
00953         ENTERFUNC;
00954 
00955         if (is_complex()) {
00956                 throw ImageFormatException("real image only");
00957         }
00958 
00959         EMData * r = this->copy();
00960         float * new_data = r->get_data();
00961         float * data = get_data();
00962         size_t size = nxyz;
00963         for (size_t i = 0; i < size; ++i) {
00964                 if(data[i] < 0) {
00965                         throw InvalidValueException(data[i], "pixel value must be non-negative for logrithm");
00966                 }
00967                 else {
00968                         if(data[i]) {   //do nothing with pixel has value zero
00969                                 new_data[i] = std::sqrt(data[i]);
00970                         }
00971                 }
00972         }
00973 
00974         r->update();
00975         return r;
00976 
00977         EXITFUNC;
00978 }

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

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

00447 {
00448         ENTERFUNC;
00449 
00450         if (nx != em.get_xsize() || ny != em.get_ysize() || nz != em.get_zsize()) {
00451                 throw ImageFormatException("images not same sizes");
00452         }
00453         else if( (is_real()^em.is_real()) == true )
00454         {
00455                 throw ImageFormatException( "not support sub between real image and complex image");
00456         }
00457         else {
00458                 const float *src_data = em.get_data();
00459                 size_t size = nxyz;
00460                 float* data = get_data();
00461 
00462                 for (size_t i = 0; i < size; i++) {
00463                         data[i] -= src_data[i];
00464                 }
00465                 update();
00466         }
00467         EXITFUNC;
00468 }

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

References data, emdata_processor_add(), get_data(), ImageFormatException, is_complex(), is_real(), 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().

00401 {
00402         ENTERFUNC;
00403 
00404         float* data = get_data();
00405         if( is_real() )
00406         {
00407                 if (f != 0) {
00408 #ifdef EMAN2_USING_CUDA
00409                 if ( gpu_operation_preferred () ) {
00410                         EMDataForCuda tmp = get_data_struct_for_cuda();
00411                         emdata_processor_add(&tmp,-f);
00412                         gpu_update();
00413                         EXITFUNC;
00414                         return;
00415                 }
00416 #endif // EMAN2_USING_CUDA
00417                         size_t size = nxyz;
00418                         for (size_t i = 0; i < size; i++) {
00419                                 data[i] -= f;
00420                         }
00421                 }
00422                 update();
00423         }
00424         else if( is_complex() )
00425         {
00426                 if( f != 0 )
00427                 {
00428                         size_t size = nxyz;
00429                         for( size_t i=0; i<size; i+=2 )
00430                         {
00431                                 data[i] -= f;
00432                         }
00433                 }
00434                 update();
00435         }
00436         else
00437         {
00438                 throw ImageFormatException("This image is neither a real nor a complex image.");
00439         }
00440 
00441         EXITFUNC;
00442 }

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

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

00376 {
00377         ENTERFUNC;
00378         if (nx != image.get_xsize() || ny != image.get_ysize() || nz != image.get_zsize()) {
00379                 throw ImageFormatException( "images not same sizes");
00380         }
00381         else if( this->is_complex() || image.is_complex() )
00382         {
00383                 throw ImageFormatException( "Cannot addsquare() with complex images");
00384         }
00385         else {
00386 
00387                 const float *src_data = image.get_data();
00388                 size_t size = nxyz;
00389                 float* data = get_data();
00390 
00391                 for (size_t i = 0; i < size; i++) {
00392                         data[i] -= src_data[i]*src_data[i];
00393                 }
00394                 update();
00395         }
00396         EXITFUNC;
00397 }

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

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

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

01385                                    {
01386         ENTERFUNC;
01387         int nxc = attr_dict["nxc"];
01388         int n = nxc*2;
01389         // let's treat the local data as a matrix
01390         vector<int> saved_offsets = get_array_offsets();
01391         set_array_offsets(0,1,1);
01392         for (int iza = 2; iza <= nxc; iza++) {
01393                 for (int iya = 2; iya <= nxc; iya++) {
01394                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01395                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01396                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01397                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01398                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01399                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01400                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01401                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01402                 }
01403         }
01404         for (int iya = 2; iya <= nxc; iya++) {
01405                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01406                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01407                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01408                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01409         }
01410         for (int iza = 2; iza <= nxc; iza++) {
01411                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01412                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01413                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01414                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01415         }
01416         EXITFUNC;
01417 }

void EMData::symplane0_ctf EMData w  ) 
 

Symmetrize plane 0 Modifies the current object.

Parameters:
w Normalization data.

Definition at line 2339 of file emdata_sparx.cpp.

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

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

02339                                     {
02340         ENTERFUNC;
02341         int nxc = attr_dict["nxc"];
02342         int n = nxc*2;
02343         // let's treat the local data as a matrix
02344         vector<int> saved_offsets = get_array_offsets();
02345         set_array_offsets(0,1,1);
02346         for (int iza = 2; iza <= nxc; iza++) {
02347                 for (int iya = 2; iya <= nxc; iya++) {
02348                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
02349                         (*w)(0,iya,iza) += (*w)(0,n-iya+2,n-iza+2);
02350                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
02351                         (*w)(0,n-iya+2,n-iza+2) = (*w)(0,iya,iza);
02352                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
02353                         (*w)(0,n-iya+2,iza) += (*w)(0,iya,n-iza+2);
02354                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
02355                         (*w)(0,iya,n-iza+2) = (*w)(0,n-iya+2,iza);
02356                 }
02357         }
02358         for (int iya = 2; iya <= nxc; iya++) {
02359                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
02360                 (*w)(0,iya,1) += (*w)(0,n-iya+2,1);
02361                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
02362                 (*w)(0,n-iya+2,1) = (*w)(0,iya,1);
02363         }
02364         for (int iza = 2; iza <= nxc; iza++) {
02365                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
02366                 (*w)(0,1,iza) += (*w)(0,1,n-iza+2);
02367                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
02368                 (*w)(0,1,n-iza+2) = (*w)(0,1,iza);
02369         }
02370         EXITFUNC;
02371 }

void EMData::symplane0_rect EMData w  ) 
 

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

02373                                      {
02374         ENTERFUNC;
02375         nx=get_xsize();
02376         ny=get_ysize();
02377         nz=get_zsize();
02378         int nzc=nz/2;
02379         int nyc=ny/2;
02380 
02381         
02382         // let's treat the local data as a matrix
02383         vector<int> saved_offsets = get_array_offsets();
02384         set_array_offsets(0,1,1);
02385         for (int iza = 2; iza <= nzc; iza++) {
02386                 for (int iya = 2; iya <= nyc; iya++) {
02387                         cmplx(0,iya,iza) += conj(cmplx(0,ny-iya+2,nz-iza+2));
02388                         (*w)(0,iya,iza) += (*w)(0,ny-iya+2,nz-iza+2);
02389                         cmplx(0,ny-iya+2,nz-iza+2) = conj(cmplx(0,iya,iza));
02390                         (*w)(0,ny-iya+2,nz-iza+2) = (*w)(0,iya,iza);
02391                         cmplx(0,ny-iya+2,iza) += conj(cmplx(0,iya,nz-iza+2));
02392                         (*w)(0,ny-iya+2,iza) += (*w)(0,iya,nz-iza+2);
02393                         cmplx(0,iya,nz-iza+2) = conj(cmplx(0,ny-iya+2,iza));
02394                         (*w)(0,iya,nz-iza+2) = (*w)(0,ny-iya+2,iza);
02395                 }
02396         }
02397         for (int iya = 2; iya <= nyc; iya++) {
02398                 cmplx(0,iya,1) += conj(cmplx(0,ny-iya+2,1));
02399                 (*w)(0,iya,1) += (*w)(0,ny-iya+2,1);
02400                 cmplx(0,ny-iya+2,1) = conj(cmplx(0,iya,1));
02401                 (*w)(0,ny-iya+2,1) = (*w)(0,iya,1);
02402         }
02403         for (int iza = 2; iza <= nzc; iza++) {
02404                 cmplx(0,1,iza) += conj(cmplx(0,1,nz-iza+2));
02405                 (*w)(0,1,iza) += (*w)(0,1,nz-iza+2);
02406                 cmplx(0,1,nz-iza+2) = conj(cmplx(0,1,iza));
02407                 (*w)(0,1,nz-iza+2) = (*w)(0,1,iza);
02408         }
02409         EXITFUNC;
02410 }

void EMData::symplane1 EMData norm,
EMData norm2
 

Symmetrize plane 0 Modifies the current object.

Parameters:
norm Normalization data.
norm2 

Definition at line 1419 of file emdata_sparx.cpp.

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

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

01419                                                   {
01420         ENTERFUNC;
01421         int nxc = attr_dict["nxc"];
01422         int n = nxc*2;
01423         vector<int> saved_offsets = get_array_offsets();
01424         set_array_offsets(0,1,1);
01425         for (int iza = 2; iza <= nxc; iza++) {
01426                 for (int iya = 2; iya <= nxc; iya++) {
01427                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01428                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01429                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01430                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01431                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01432                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01433                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01434                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01435                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01436                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01437                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01438                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01439                 }
01440         }
01441         for (int iya = 2; iya <= nxc; iya++) {
01442                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01443                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01444                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01445                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01446                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01447                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01448         }
01449         for (int iza = 2; iza <= nxc; iza++) {
01450                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01451                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01452                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01453                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01454                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01455                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01456         }
01457         EXITFUNC;
01458 }

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

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

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

01460                                                                  {
01461         ENTERFUNC;
01462         int nxc = attr_dict["nxc"];
01463         int n = nxc*2;
01464         vector<int> saved_offsets = get_array_offsets();
01465         set_array_offsets(0,1,1);
01466         for (int iza = 2; iza <= nxc; iza++) {
01467                 for (int iya = 2; iya <= nxc; iya++) {
01468                         cmplx(0,iya,iza) += conj(cmplx(0,n-iya+2,n-iza+2));
01469                         (*wptr)(0,iya,iza) += (*wptr)(0,n-iya+2,n-iza+2);
01470                         (*wptr2)(0,iya,iza) += (*wptr2)(0,n-iya+2,n-iza+2);
01471                         (*wptr3)(0,iya,iza) += (*wptr3)(0,n-iya+2,n-iza+2);
01472 
01473                         cmplx(0,n-iya+2,n-iza+2) = conj(cmplx(0,iya,iza));
01474                         (*wptr)(0,n-iya+2,n-iza+2) = (*wptr)(0,iya,iza);
01475                         (*wptr2)(0,n-iya+2,n-iza+2) = (*wptr2)(0,iya,iza);
01476                         (*wptr3)(0,n-iya+2,n-iza+2) = (*wptr3)(0,iya,iza);
01477 
01478                         cmplx(0,n-iya+2,iza) += conj(cmplx(0,iya,n-iza+2));
01479                         (*wptr)(0,n-iya+2,iza) += (*wptr)(0,iya,n-iza+2);
01480                         (*wptr2)(0,n-iya+2,iza) += (*wptr2)(0,iya,n-iza+2);
01481                         (*wptr3)(0,n-iya+2,iza) += (*wptr3)(0,iya,n-iza+2);
01482 
01483                         cmplx(0,iya,n-iza+2) = conj(cmplx(0,n-iya+2,iza));
01484                         (*wptr)(0,iya,n-iza+2) = (*wptr)(0,n-iya+2,iza);
01485                         (*wptr2)(0,iya,n-iza+2) = (*wptr2)(0,n-iya+2,iza);
01486                         (*wptr3)(0,iya,n-iza+2) = (*wptr3)(0,n-iya+2,iza);
01487                 }
01488         }
01489         for (int iya = 2; iya <= nxc; iya++) {
01490                 cmplx(0,iya,1) += conj(cmplx(0,n-iya+2,1));
01491                 (*wptr)(0,iya,1) += (*wptr)(0,n-iya+2,1);
01492                 (*wptr2)(0,iya,1) += (*wptr2)(0,n-iya+2,1);
01493                 (*wptr3)(0,iya,1) += (*wptr3)(0,n-iya+2,1);
01494 
01495                 cmplx(0,n-iya+2,1) = conj(cmplx(0,iya,1));
01496                 (*wptr)(0,n-iya+2,1) = (*wptr)(0,iya,1);
01497                 (*wptr2)(0,n-iya+2,1) = (*wptr2)(0,iya,1);
01498                 (*wptr3)(0,n-iya+2,1) = (*wptr3)(0,iya,1);
01499         }
01500         for (int iza = 2; iza <= nxc; iza++) {
01501                 cmplx(0,1,iza) += conj(cmplx(0,1,n-iza+2));
01502                 (*wptr)(0,1,iza) += (*wptr)(0,1,n-iza+2);
01503                 (*wptr2)(0,1,iza) += (*wptr2)(0,1,n-iza+2);
01504                 (*wptr3)(0,1,iza) += (*wptr3)(0,1,n-iza+2);
01505 
01506                 cmplx(0,1,n-iza+2) = conj(cmplx(0,1,iza));
01507                 (*wptr)(0,1,n-iza+2) = (*wptr)(0,1,iza);
01508                 (*wptr2)(0,1,n-iza+2) = (*wptr2)(0,1,iza);
01509                 (*wptr3)(0,1,n-iza+2) = (*wptr3)(0,1,iza);
01510         }
01511         EXITFUNC;
01512 }

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

References EMAN::Transform::get_sym(), nx, ny, nz, rot_scale_trans(), set_size(), to_zero(), and update().

00962                                        {
00963         ENTERFUNC;
00964         int nsym = Transform::get_nsym(symString); // number of symmetries
00965         Transform sym;
00966         // set up output volume
00967         EMData *svol = new EMData;
00968         svol->set_size(nx, ny, nz);
00969         svol->to_zero();
00970         // set up new copy
00971         //EMData* symcopy = new EMData;
00972         //symcopy->set_size(nx, ny, nz);
00973         // set up coord grid
00974         // actual work -- loop over symmetries and symmetrize
00975         for (int isym = 0; isym < nsym; isym++) {
00976                  Transform rm = sym.get_sym(symString, isym);
00977                  EMData* symcopy = this -> rot_scale_trans(rm);
00978                  *svol += (*symcopy);
00979                  delete symcopy;
00980                 
00981         }
00982         
00983         *svol /=  ((float) nsym);
00984         svol->update();
00985         EXITFUNC;
00986         return svol;
00987 }

void EMData::to_one  ) 
 

set all the pixel values = 1.

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

01350 {
01351         ENTERFUNC;
01352 
01353         if (is_complex()) {
01354                 set_ri(true);
01355         }
01356         else {
01357                 set_ri(false);
01358         }
01359         to_value(1.0);
01360 
01361         update();
01362         EXITFUNC;
01363 }

void EMData::to_value const float &  value  ) 
 

set all the pixel values to a value.

Definition at line 1365 of file emdata_core.cpp.

References data, EMAN::EMUtil::em_memset(), emdata_processor_to_value(), get_data(), get_size(), nxyz, and update().

Referenced by get_clip(), wustl_mm::SkeletonMaker::VolumeData::InitializeVolumeData(), make_rotational_footprint_e1(), EMAN::FourierReconstructor::setup_seed(), to_one(), and to_zero().

01366 {
01367         ENTERFUNC;
01368 
01369 #ifdef EMAN2_USING_CUDA
01370         if ( gpu_operation_preferred() ) {
01371                 EMDataForCuda tmp = get_data_struct_for_cuda();
01372                 emdata_processor_to_value(&tmp,value);
01373                 gpu_update();
01374                 EXITFUNC;
01375                 return;
01376         }
01377 #endif // EMAN2_USING_CUDA
01378         float* data = get_data();
01379         if ( value != 0 ) std::fill(data,data+get_size(),value);
01380         else EMUtil::em_memset(data, 0, nxyz * sizeof(float)); // This might be faster, I don't know
01381 
01382         update();
01383         EXITFUNC;
01384 }

void EMData::to_zero  ) 
 

Set all the pixel value = 0.

Definition at line 1332 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::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(), 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_rect(), 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().

01333 {
01334         ENTERFUNC;
01335 
01336         if (is_complex()) {
01337                 set_ri(true);
01338         }
01339         else {
01340                 set_ri(false);
01341         }
01342 
01343         //EMUtil::em_memset(get_data(), 0, nxyz * sizeof(float));
01344         to_value(0.0);
01345         update();
01346         EXITFUNC;
01347 }

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

Referenced by EMAN::RTFSlowExhaustiveAligner::align(), common_lines_real(), do_radon(), EMAN::BackProjectionReconstructor::finish(), EMAN::BackProjectionReconstructor::insert_slice(), 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 858 of file emdata.cpp.

References all_translation, process_inplace(), and EMAN::Vec3i.

00859 {
00860         ENTERFUNC;
00861 
00862         //if traslation is 0, do nothing
00863         if( translation[0] == 0 && translation[1] == 0 && translation[2] == 0) {
00864                 EXITFUNC;
00865                 return;
00866         }
00867 
00868         Dict params("trans",static_cast< vector<int> >(translation));
00869         process_inplace("math.translate.int",params);
00870 
00871         // update() - clip_inplace does the update
00872         all_translation += translation;
00873 
00874         EXITFUNC;
00875 }

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

References translate(), and EMAN::Vec3i.

00835 {
00836         ENTERFUNC;
00837         translate(Vec3i(dx, dy, dz));
00838         EXITFUNC;
00839 }

void EMData::translate const Vec3f translation  ) 
 

Translate this image.

Parameters:
translation The translation distance vector.

Definition at line 878 of file emdata.cpp.

References all_translation, process_inplace(), EMAN::Transform::set_trans(), t, and EMAN::Vec3f.

00879 {
00880         ENTERFUNC;
00881 
00882         if( translation[0] == 0.0f && translation[1] == 0.0f && translation[2] == 0.0f ) {
00883                 EXITFUNC;
00884                 return;
00885         }
00886 
00887         Transform* t = new Transform();
00888         t->set_trans(translation);
00889         process_inplace("xform",Dict("transform",t));
00890         delete t;
00891 
00892         all_translation += translation;
00893         EXITFUNC;
00894 }

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

00843 {
00844         ENTERFUNC;
00845         int dx_ = Util::round(dx);
00846         int dy_ = Util::round(dy);
00847         int dz_ = Util::round(dz);
00848         if( ( (dx-dx_) == 0 ) && ( (dy-dy_) == 0 ) && ( (dz-dz_) == 0 )) {
00849                 translate(dx_, dy_, dz_);
00850         }
00851         else {
00852                 translate(Vec3f(dx, dy, dz));
00853         }
00854         EXITFUNC;
00855 }

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

03862 {
03863         ENTERFUNC;
03864 
03865         if (!map) throw NullPointerException("NULL image");
03866         // These restrictions should be ultimately restricted so that all that matters is get_ndim() = (map->get_ndim() -1)
03867         if ( get_ndim() != 2 ) throw ImageDimensionException("Can not call cut slice on an image that is not 2D");
03868         if ( map->get_ndim() != 3 ) throw ImageDimensionException("Can not cut slice from an image that is not 3D");
03869         // Now check for complex images - this is really just being thorough
03870         if ( is_complex() ) throw ImageFormatException("Can not call cut slice on an image that is complex");
03871         if ( map->is_complex() ) throw ImageFormatException("Can not cut slice from a complex image");
03872 
03873 //      Transform3D r( 0, 0, 0); // EMAN by default
03874 //      if (!ort) {
03875 //              ort = &r;
03876 //      }
03877 
03878         float *ddata = map->get_data();
03879         float *sdata = get_data();
03880 
03881         int map_nx = map->get_xsize();
03882         int map_ny = map->get_ysize();
03883         int map_nz = map->get_zsize();
03884         int map_nxy = map_nx * map_ny;
03885         float map_nz_round_limit = (float) map_nz-0.5f;
03886         float map_ny_round_limit = (float) map_ny-0.5f;
03887         float map_nx_round_limit = (float) map_nx-0.5f;
03888 /*
03889         Vec3f posttrans = ort->get_posttrans();
03890         Vec3f pretrans = ort->get_pretrans();*/
03891 
03892         int ymax = ny/2;
03893         if ( ny % 2 == 1 ) ymax += 1;
03894         int xmax = nx/2;
03895         if ( nx % 2 == 1 ) xmax += 1;
03896         for (int y = -ny/2; y < ymax; y++) {
03897                 for (int x = -nx/2; x < xmax; x++) {
03898                         Vec3f coord(x,y,0);
03899                         Vec3f soln = transform*coord;
03900 //                      float xx = (x+pretrans[0]) * (*ort)[0][0] +  (y+pretrans[1]) * (*ort)[0][1] + pretrans[2] * (*ort)[0][2] + posttrans[0];
03901 //                      float yy = (x+pretrans[0]) * (*ort)[1][0] +  (y+pretrans[1]) * (*ort)[1][1] + pretrans[2] * (*ort)[1][2] + posttrans[1];
03902 //                      float zz = (x+pretrans[0]) * (*ort)[2][0] +  (y+pretrans[1]) * (*ort)[2][1] + pretrans[2] * (*ort)[2][2] + posttrans[2];
03903 //
03904 //                      xx += map_nx/2;
03905 //                      yy += map_ny/2;
03906 //                      zz += map_nz/2;
03907 //
03908                         float xx = soln[0]+map_nx/2;
03909                         float yy = soln[1]+map_ny/2;
03910                         float zz = soln[2]+map_nz/2;
03911 
03912                         // These 0.5 offsets are here because the round function rounds to the nearest whole number.
03913                         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;
03914 
03915                         int k = Util::round(xx) + Util::round(yy) * map_nx + Util::round(zz) * map_nxy;
03916                         int l = (x+nx/2) + (y+ny/2) * nx;
03917                         ddata[k] = sdata[l];
03918                 }
03919         }
03920 
03921         map->update();
03922         EXITFUNC;
03923 }

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

Definition at line 3727 of file emdata.cpp.

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

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

03727                                                                  {
03728         float *d,*dd;
03729         int do360=2;
03730         int rmax = (int)(rmax_f+0.5f);
03731         unsigned long i;
03732         unsigned int nvox=get_xsize()*get_ysize();//ming
03733         float maxmap=0.0f, minmap=0.0f;
03734         float temp=0.0f, diff_den=0.0f, norm=0.0f;
03735         float cut_off_va =0.0f;
03736 
03737         d=get_data();
03738         maxmap=-1000000.0f;
03739         minmap=1000000.0f;
03740         for (i=0;i<nvox;i++){
03741                 if(d[i]>maxmap) maxmap=d[i];
03742                 if(d[i]<minmap) minmap=d[i];
03743         }
03744         diff_den = maxmap-minmap;
03745         for(i=0;i<nvox;i++) {
03746                 temp = (d[i]-minmap)/diff_den;
03747                 if(cut_off_va != 0.0) {               // cut off the lowerset ?% noisy information
03748                         if(temp < cut_off_va)
03749                                 d[i] = 0.0f;                   // set the empty part density=0.0
03750                         else
03751                                 d[i] = temp-cut_off_va;
03752                 }
03753                 else    d[i] = temp;
03754         }
03755 
03756         for(i=0;i<nvox;i++) {
03757                 temp=d[i];
03758                 norm += temp*temp;
03759         }
03760         for(i=0;i<nvox;i++)             d[i] /= norm;                      //  y' = y/norm(y)
03761 
03762         if (xs<1) {
03763                 xs = (int) floor(do360*M_PI*get_ysize()/4); // ming
03764                 xs=Util::calc_best_fft_size(xs); // ming
03765         }
03766         if (r1<0) r1=0;
03767         float maxext=ceil(0.6f*std::sqrt((float)(get_xsize()*get_xsize()+get_ysize()*get_ysize())));// ming add std::
03768 
03769         if (r2<r1) r2=(int)maxext;
03770         EMData *ret = new EMData;
03771 
03772         ret->set_size(xs,r2+1,1);
03773 
03774         dd=ret->get_data();
03775 
03776         for (int i=0; i<xs; i++) {
03777                 float si=sin(i*M_PI*2/xs);
03778                 float co=cos(i*M_PI*2/xs);
03779                 for (int r=0; r<=maxext; r++) {
03780                         float x=(r+r1)*co+get_xsize()/2; // ming
03781                         float y=(r+r1)*si+get_ysize()/2; // ming
03782                         if(x<0.0 || x>=get_xsize()-1.0 || y<0.0 || y>=get_ysize()-1.0 || r>rmax){    //Ming , ~~~~ rmax need pass here
03783                                 for(;r<=r2;r++)                                   // here r2=MAXR
03784                                         dd[i+r*xs]=0.0;
03785                         break;
03786                     }
03787                         int x1=(int)floor(x);
03788                         int y1=(int)floor(y);
03789                         float t=x-x1;
03790                         float u=y-y1;
03791                         float f11= d[x1+y1*get_xsize()]; // ming
03792                         float f21= d[(x1+1)+y1*get_xsize()]; // ming
03793                         float f12= d[x1+(y1+1)*get_xsize()]; // ming
03794                         float f22= d[(x1+1)+(y1+1)*get_xsize()]; // ming
03795                         dd[i+r*xs] = (1-t)*(1-u)*f11+t*(1-u)*f21+t*u*f22+(1-t)*u*f12;
03796                 }
03797         }
03798         update();
03799         ret->update();
03800         return ret;
03801 }

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

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

Definition at line 388 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_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_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(), 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_rect(), 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::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_translate(), 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().

00397                                 : this method internally just calls the

void EMData::update_stat  )  const [private]
 

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

02680 {
02681         ENTERFUNC;
02682 //      printf("update stat %f %d\n",(float)attr_dict["mean"],flags);
02683         if (!(flags & EMDATA_NEEDUPD))
02684         {
02685                 EXITFUNC;
02686                 return;
02687         }
02688 
02689         float* data = get_data();
02690         float max = -FLT_MAX;
02691         float min = -max;
02692 
02693         double sum = 0;
02694         double square_sum = 0;
02695 
02696         int step = 1;
02697         if (is_complex() && !is_ri()) {
02698                 step = 2;
02699         }
02700 
02701         int n_nonzero = 0;
02702 
02703         //cout << "point 1" << endl;
02704         //cout << "size is " << nx << " " << ny << " " << nz << endl;
02705 
02706         size_t size = nx*ny*nz;
02707         for (size_t i = 0; i < size; i += step) {
02708                 float v = data[i];
02709         #ifdef _WIN32
02710                 max = _cpp_max(max,v);
02711                 min = _cpp_min(min,v);
02712         #else
02713                 max=std::max<float>(max,v);
02714                 min=std::min<float>(min,v);
02715         #endif  //_WIN32
02716                 sum += v;
02717                 square_sum += v * (double)(v);
02718                 if (v != 0) n_nonzero++;
02719         }
02720         //cout << "Point 2" << endl;
02721         size_t n = size / step;
02722         double mean = sum / n;
02723 
02724 #ifdef _WIN32
02725         float sigma = (float)std::sqrt( _cpp_max(0.0,(square_sum - sum*sum / n)/(n-1)));
02726         n_nonzero = _cpp_max(1,n_nonzero);
02727         double sigma_nonzero = std::sqrt( _cpp_max(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02728 #else
02729         float sigma = (float)std::sqrt(std::max<double>(0.0,(square_sum - sum*sum / n)/(n-1)));
02730         n_nonzero = std::max<int>(1,n_nonzero);
02731         double sigma_nonzero = std::sqrt(std::max<double>(0,(square_sum  - sum*sum/n_nonzero)/(n_nonzero-1)));
02732 #endif  //_WIN32
02733         double mean_nonzero = sum / n_nonzero; // previous version overcounted! G2
02734 
02735         attr_dict["minimum"] = min;
02736         attr_dict["maximum"] = max;
02737         attr_dict["mean"] = (float)(mean);
02738         attr_dict["sigma"] = (float)(sigma);
02739         attr_dict["square_sum"] = (float)(square_sum);
02740         attr_dict["mean_nonzero"] = (float)(mean_nonzero);
02741         attr_dict["sigma_nonzero"] = (float)(sigma_nonzero);
02742         attr_dict["is_complex"] = (int) is_complex();
02743         attr_dict["is_complex_ri"] = (int) is_ri();
02744 
02745         flags &= ~EMDATA_NEEDUPD;
02746 
02747         if (rot_fp != 0)
02748         {
02749                 delete rot_fp; rot_fp = 0;
02750         }
02751 
02752         EXITFUNC;
02753 //      printf("done stat %f %f %f\n",(float)mean,(float)max,(float)sigma);
02754 }

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

00714                                    {
00715         ENTERFUNC;
00716         // sanity checks
00717         int n = nx;
00718         if (is_complex()) {
00719                 LOGERR("Need real-space data for window_center()");
00720                 throw ImageFormatException(
00721                         "Complex input image; real-space expected.");
00722         }
00723         if (is_fftpadded()) {
00724                 // image has been fft-padded, compute the real-space size
00725                 n -= (2 - int(is_fftodd()));
00726         }
00727         int corner = n/2 - l/2;
00728         int ndim = get_ndim();
00729         EMData* ret;
00730         switch (ndim) {
00731                 case 3:
00732                         if ((n != ny) || (n != nz)) {
00733                                 LOGERR("Need the real-space image to be cubic.");
00734                                 throw ImageFormatException(
00735                                                 "Need cubic real-space image.");
00736                         }
00737                         ret = get_clip(Region(corner, corner, corner, l, l, l));
00738                         break;
00739                 case 2:
00740                         if (n != ny) {
00741                                 LOGERR("Need the real-space image to be square.");
00742                                 throw ImageFormatException(
00743                                                 "Need square real-space image.");
00744                         }
00745                         //cout << "Using corner " << corner << endl;
00746                         ret = get_clip(Region(corner, corner, l, l));
00747                         break;
00748                 case 1:
00749                         ret = get_clip(Region(corner, l));
00750                         break;
00751                 default:
00752                         throw ImageDimensionException(
00753                                         "window_center only supports 1-d, 2-d, and 3-d images");
00754         }
00755         return ret;
00756         EXITFUNC;
00757 }

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

References FileAccessException, get_data(), nx, ny, nz, portable_fseek(), and UnexpectedBehaviorException.

00226                                                                                                                         {
00227 
00228         if (area) {
00229                 struct stat fileinfo;
00230                 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");
00231         }
00232 
00233 
00234         FILE *f = 0;
00235         f=fopen(fsp.c_str(), "rb+");
00236         if (!f) f=fopen(fsp.c_str(), "wb");
00237         if (!f) throw FileAccessException(fsp);
00238         portable_fseek(f,loc,SEEK_SET);
00239         if (!area) {
00240                 if (fwrite(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00241         } else {
00242                 int fnx = nx;
00243                 if (file_nx != 0) fnx = file_nx;
00244                 int fny = ny;
00245                 if (file_ny != 0) fny = file_ny;
00246                 int fnz = nz;
00247                 if (file_nz != 0) fnz = file_nz;
00248 
00249                 EMUtil::process_region_io(get_data(), f, ImageIO::READ_WRITE,
00250                                                                   0, 4,fnx,fny,fnz,area);
00251         }
00252         fclose(f);
00253 }

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 131 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(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), unified(), and write_lst().

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

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

References attr_dict, and write_image().

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

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

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

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

01390 {
01391         if ( nz > 1 && nz < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nz is too small");
01392         if ( ny > 1 && ny < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - ny is too small");
01393         if ( nx > 1 && nx < (2*radius+1) ) throw ImageDimensionException("Error: cannot zero corner - nx is too small");
01394 
01395         int it_z = radius;
01396         int it_y = radius;
01397         int it_x = radius;
01398 
01399         if ( nz == 1 ) it_z = 0;
01400         if ( ny == 1 ) it_y = 0;
01401         if ( nx == 1 ) it_z = 0;
01402 
01403         if ( nz == 1 && ny == 1 )
01404         {
01405                 for ( int x = -it_x; x <= it_x; ++x )
01406                         get_value_at_wrap(x) = 0;
01407 
01408         }
01409         else if ( nz == 1 )
01410         {
01411                 for ( int y = -it_y; y <= it_y; ++y)
01412                         for ( int x = -it_x; x <= it_x; ++x )
01413                                 get_value_at_wrap(x,y) = 0;
01414         }
01415         else
01416         {
01417                 for( int z = -it_z; z <= it_z; ++z )
01418                         for ( int y = -it_y; y <= it_y; ++y)
01419                                 for ( int x = -it_x; x < it_x; ++x )
01420                                         get_value_at_wrap(x,y,z) = 0;
01421 
01422         }
01423 
01424 }


Friends And Related Function Documentation

friend class GLUtil [friend]
 

Definition at line 90 of file emdata.h.


Member Data Documentation

Vec3f EMAN::EMData::all_translation [private]
 

translation from the original location

Definition at line 3842 of file emdata.h.

Referenced by copy_head(), operator=(), rotate_translate(), and translate().

Dict EMAN::EMData::attr_dict [mutable, private]
 

to store all image header info

Definition at line 3821 of file emdata.h.

Referenced by clip_inplace(), 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(), rotate_translate(), 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 3834 of file emdata.h.

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

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

flags

Definition at line 3832 of file emdata.h.

Referenced by copy_head(), EMData(), get_attr(), operator=(), and update_stat().

int EMAN::EMData::nx [private]
 

image size

Definition at line 3836 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_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_rect(), 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_translate(), 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(), uncut_slice(), unwrap(), update_stat(), write_data(), and zero_corner_circulant().

int EMAN::EMData::nxy [private]
 

image size

Definition at line 3836 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(), rotate_translate(), set_size(), and setup4slice().

size_t EMAN::EMData::nxyz [private]
 

Definition at line 3837 of file emdata.h.

Referenced by norm_pad(), set_size(), and to_value().

int EMAN::EMData::ny [private]
 

image size

Definition at line 3836 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_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_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_rect(), 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(), rotate_translate(), 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(), uncut_slice(), unwrap(), update_stat(), write_data(), and zero_corner_circulant().

int EMAN::EMData::nz [private]
 

image size

Definition at line 3836 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_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_rect(), 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(), rotate_translate(), 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(), write_data(), and zero_corner_circulant().

string EMAN::EMData::path [private]
 

Definition at line 3845 of file emdata.h.

Referenced by copy_head(), get_clip(), operator=(), and write_image().

int EMAN::EMData::pathnum [private]
 

Definition at line 3846 of file emdata.h.

Referenced by copy_head(), get_clip(), and operator=().

float* EMAN::EMData::rdata [mutable, private]
 

image real data

Definition at line 3823 of file emdata.h.

Referenced by add_complex_at(), clip_inplace(), cog(), do_fft_inplace(), do_ift(), EMData(), find_3d_threshold(), free_memory(), get_complex_at(), operator=(), phase_cog(), rotate_translate(), 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 3849 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 3825 of file emdata.h.

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

int EMData::totalalloc = 0 [static]
 

Definition at line 70 of file emdata.cpp.

int EMAN::EMData::xoff [private]
 

array index offsets

Definition at line 3839 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::yoff [private]
 

array index offsets

Definition at line 3839 of file emdata.h.

Referenced by operator=().

int EMAN::EMData::zoff [private]
 

array index offsets

Definition at line 3839 of file emdata.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:47:22 2010 for EMAN2 by  doxygen 1.3.9.1