Bsoft 2.1.4
Bernard's software package
Bimage Class Reference

General image parameter class. More...

#include <Bimage.h>

Public Member Functions

 Bimage ()
 Initializes an image. More...
 
 Bimage (const Bimage &p)
 The copy constructor. More...
 
 Bimage (Bstring &fn, int readdata, int img_select)
 Reads an image from a file. More...
 
 Bimage (DataType type, CompoundType ctype, long nx, long ny, long nz, long nn)
 Initializes an image. More...
 
 Bimage (DataType type, CompoundType ctype, Vector3< long > size, long nn)
 Initializes an image. More...
 
 Bimage (DataType type, CompoundType ctype, vector< long > size, long nn)
 Initializes an image. More...
 
 Bimage (DataType type, long nc, long nx, long ny, long nz, long nn)
 Initializes a generic multi-channel image. More...
 
 Bimage (DataType type, long nc, Vector3< long > size, long nn)
 Initializes a generic multi-channel image. More...
 
 Bimage (Matrix &mat, long scale)
 Initializes an image from a 2D matrix. More...
 
 ~Bimage ()
 Image destructor. More...
 
CompoundType guess_compoundtype (long nc)
 
bool check_compoundtype (long nc, CompoundType ct)
 
void check ()
 Checks an image for reasonable properties. More...
 
bool check_if_same_size (Bimage *p)
 Check if two images are the same size. More...
 
bool check_if_same_image_size (Bimage *p)
 Check if two images are the same size. More...
 
void check_sampling ()
 Checks that the sampling is properly specified. More...
 
void check_resolution (double &resolution)
 Checks that the resolution falls within reasonable limits. More...
 
void set_hi_lo_resolution (double &hi, double &lo)
 
bool compatible (Bimage *p)
 Check if this image has the same number of channels and data type as another. More...
 
void identifier (Bstring s)
 
Bstringidentifier ()
 
JSvaluemeta_data ()
 
JSvalueoperator[] (string tag)
 
vector< JSvalue * > query (string &path)
 
long erase (string tag)
 
void meta_data_update ()
 Update metadata from the sub-image information. More...
 
void update_from_meta_data ()
 Update sub-image information from the metadata. More...
 
void meta_data_retain_one_image (long img_num)
 Erases all sub-image records from the meta data except one. More...
 
void file_name (string s)
 
string & file_name ()
 
Bimagefind (Bstring fn)
 
void label (string s)
 
string & label ()
 
time_t get_time ()
 
tm * get_localtime ()
 
void set_time (time_t t)
 
void set_time (tm *t)
 
long alloc_size () const
 
long data_size ()
 
unsigned char * data_alloc ()
 
unsigned char * data_alloc_and_clear ()
 
unsigned char * data_alloc (long nbytes)
 Allocate image data. More...
 
unsigned char * data_alloc_and_clear (long nbytes)
 
unsigned char * data_alloc (DataType type, CompoundType ctype, long nx, long ny, long nz, long nn)
 Allocate image data with size parameters. More...
 
unsigned char * data_alloc_and_clear (DataType type, CompoundType ctype, long nx, long ny, long nz, long nn)
 
unsigned char * data_assign (unsigned char *nudata)
 Assign image data. More...
 
unsigned char * data_pointer ()
 
unsigned char * data_pointer (long offset)
 
void data_pointer (unsigned char *ptr)
 
void data_delete ()
 Deallocates the image data. More...
 
long data_offset ()
 
void data_offset (long doff)
 
long image_size ()
 
Bimageoperator= (const Bimage &p)
 Assigns an image. More...
 
double operator[] (long j) const
 Returns the data value at the given index. More...
 
double get (long nn, long xx, long yy, long zz, long cc=0)
 Returns the data value at the given coordinates. More...
 
double get (long nn, Vector3< double > vox, long cc=0)
 Returns the data value at the given coordinates. More...
 
vector< double > values (long i)
 
void values (long i, vector< double > val)
 
vector< double > values (long nn, Vector3< double > vox)
 Returns an array with all channel data at the given coordinates. More...
 
Complex< double > complex (long j)
 Returns a complex value at the given index. More...
 
Vector3< double > vector3 (long j)
 Returns a 3-value vector at the given index. More...
 
RGB< double > rgb (long j)
 Returns a color value at the given index. More...
 
RGBA< double > rgba (long j)
 Returns a color value at the given index. More...
 
CMYK< double > cmyk (long j)
 Returns a color value at the given index. More...
 
TypePointer fill_value (double v)
 
void set (long j, double v)
 Sets a single value at the given index. More...
 
void set (long j, Complex< double > cv)
 Sets a complex value at the given index. More...
 
void set (long j, RGB< double > color)
 Sets a color value at the given index. More...
 
void set (long j, RGBA< double > color)
 Sets a color value at the given index. More...
 
void set (long j, CMYK< double > color)
 Sets a color value at the given index. More...
 
void set (long j, Vector3< double > vec)
 Sets a 3-value vector at the given index. More...
 
void set (long j, View view)
 Sets a 3-value vector at the given index. More...
 
void add (long j, double v)
 
void add (long j, Complex< double > cv)
 
void add (double xx, double yy, double zz, long nn, double v)
 Adds a value at a given location to neigboring data elements. More...
 
void set_max (double xx, double yy, double zz, long nn, double v)
 Sets a value at a given location to neigboring data elements if it is larger. More...
 
void multiply (long j, Complex< double > cv)
 
double average2D (long cc, double xf, double yf, double zf, long nn, double iscale)
 Averages in the xy plane when scaling is less than 1. More...
 
double average (long cc, double xf, double yf, double zf, long nn, double iscale)
 Averages in 3D when scaling is less than 1. More...
 
double interpolate (long cc, double xx, double yy=0, double zz=0, long nn=0, double fill=0) const
 Interpolates using a given location. More...
 
double interpolate (long cc, Vector3< double > vec, long nn=0, double fill=0) const
 
double interpolate (Vector3< double > vec, long nn=0, double fill=0) const
 
double interpolate (vector< double > vec, long nn=0, double fill=0) const
 
double interpolate_wrap (long cc, double xx, double yy=0, double zz=0, long nn=0) const
 Interpolates using a given location with wrapping. More...
 
double interpolate_wrap (double xx, double yy=0, double zz=0, long nn=0) const
 
double interpolate_wrap (long cc, Vector3< double > vec, long nn=0) const
 
double interpolate_wrap (Vector3< double > vec, long nn=0) const
 
DataType data_type ()
 
void data_type (DataType dt)
 
CompoundType compound_type ()
 
long compound_type (CompoundType ct)
 
long data_type_bits () const
 Returns the size of the datatype in bits. More...
 
long data_type_size () const
 Returns the size of the datatype in bytes. More...
 
long compound_type_size ()
 
double data_type_min ()
 Get the minimum of a datatype. More...
 
double data_type_max ()
 Get the maximum of a datatype. More...
 
Bstring data_type_string ()
 Get the string representation of a datatype. More...
 
Bstring compound_type_string ()
 Get the string representation of a datatype. More...
 
void fix_type ()
 Determines the replacement data type. More...
 
void change_type (char letter)
 Get the data type indicated by a single letter code. More...
 
void change_type (char *string)
 Get the data type from a string. More...
 
void change_type (DataType nutype)
 Change the data to the new type. More...
 
Bimagesplit_channels ()
 Splits the channels into individual sub-images. More...
 
Bimagesplit_channels_to_images ()
 Splits the channels into individual images in a linked list. More...
 
void combine_channels (long nc, CompoundType ct=TSimple)
 Combines images as channels. More...
 
FourierType fourier_type ()
 
void fourier_type (FourierType tf)
 
void zero_fourier_origin ()
 Zeroes the first voxel in each image. More...
 
long channels ()
 
void channels (long cc)
 
Vector3< long > size () const
 
void size (long nx, long ny, long nz)
 
void size (Vector3< long > vec)
 
void size (vector< long > vec)
 
void sizeX (long nx)
 
void sizeY (long ny)
 
void sizeZ (long nz)
 
long sizeX () const
 
long sizeY () const
 
long sizeZ () const
 
long index (long nx, long ny) const
 
long index (long nx, long ny, long nz) const
 
long index (long nx, long ny, long nz, long nn) const
 
long index (long nc, long nx, long ny, long nz, long nn) const
 
long index (Vector3< long > vox, long nn) const
 
long index (vector< long > vox, long nn) const
 
long index_wrap (long nx, long ny, long nz) const
 
long index_wrap (Vector3< long > coor) const
 
long index_wrap (vector< long > coor) const
 
void coordinates (long i, long &nx, long &ny, long &nz)
 
void coordinates (long i, long &nx, long &ny, long &nz, long &nn)
 
void coordinates (long i, long &nc, long &nx, long &ny, long &nz, long &nn)
 
Vector3< long > coordinates (long i)
 
Vector3< double > real_coordinates (long i)
 
template<typename T >
bool within_boundaries (Vector3< T > loc)
 
bool within_boundaries (long xx, long yy, long zz)
 
Vector3< long > kernel_low (long i, long k=1)
 
Vector3< long > kernel_high (long i, long k=1)
 
Vector3< long > kernel_low (long i, Vector3< long > k)
 
Vector3< long > kernel_high (long i, Vector3< long > k)
 
long kernel_min (long idx, long ksize)
 Finds the highest value in a kernel. More...
 
long kernel_max (long idx, long ksize)
 Finds the highest value in a kernel. More...
 
double kernel_average (long idx, long ksize, double tmin, double tmax)
 Calculates the average value in a kernel. More...
 
double kernel_sum (long idx, long ksize)
 Calculates the sum in a kernel. More...
 
double kernel_neighbor_average (long idx, long ksize)
 Finds the average of neigbor values in a kernel. More...
 
long kernel_max_neigbor (long idx, long ksize)
 Finds the highest value in a kernel excluding the central voxel. More...
 
long kernel_max_wrap (long idx, long ksize)
 Finds the highest value in a kernel with wrapping. More...
 
multimap< double, long > kernel_order (long idx, long ksize)
 Orders the values in a kernel. More...
 
multimap< double, long > kernel_order_neighbors (long idx, long ksize)
 Orders the neigbor values in a kernel. More...
 
Vector3< long > page_size ()
 
void page_size (long nx, long ny, long nz)
 
void page_size (Vector3< long > vec)
 
void page_size (vector< long > vec)
 
Vector3< double > real_size ()
 
long images ()
 
void images (long nn)
 
double voxel_size ()
 
void sampling (long nn, Vector3< double > u)
 
void sampling (long nn, double ux, double uy, double uz)
 
void sampling (Vector3< double > u)
 
void sampling (double ux, double uy, double uz)
 
Vector3< double > sampling (long nn)
 
vector< Vector3< double > > sampling ()
 
void sampling (vector< Vector3< double > > sam)
 
double minimum ()
 
double maximum ()
 
double average ()
 
double standard_deviation ()
 
double variance ()
 
void minimum (double d)
 
void maximum (double d)
 
void average (double d)
 
void standard_deviation (double d)
 
double background (long nn)
 
void background (long nn, double bkg)
 
void background (double bkg)
 
long show_image ()
 
void show_image (long nn)
 
long show_slice ()
 
void show_slice (long nz)
 
double show_scale ()
 
void show_scale (double scale)
 
double show_minimum ()
 
double show_maximum ()
 
void show_minimum (double v)
 
void show_maximum (double v)
 
void origin (double ox, double oy, double oz)
 
void origin (vector< double > vec)
 
void origin (Vector3< double > vec)
 
void origin (long nn, Vector3< double > vec)
 
void origin (long nn, vector< double > ori)
 
void origin (long nn, double ox, double oy, double oz)
 
Vector3< double > default_origin ()
 
void view (double vx, double vy, double vz, double va)
 
void view (View vw)
 
long space_group ()
 
void space_group (unsigned int grp)
 
string & symmetry ()
 
void symmetry (string grp)
 
void unit_cell_check ()
 
void unit_cell (UnitCell uc)
 
UnitCell unit_cell ()
 
double maximum_included_radius ()
 Returns the radius of the enclosed sphere or circle. More...
 
int slices_to_images ()
 Changes the slices in a 3D image into a set of 2D images. More...
 
int images_to_slices ()
 Changes the 2D images to slices in a 3D image. More...
 
int channels_to_images ()
 
int images_to_channels (long nc, CompoundType ct)
 
long set_subset_selection (Bstring list)
 Sets the sub-image selections based on a list. More...
 
long delete_images (Bstring list, int retain=0)
 Retains or deletes sub-images from a multi-image structure. More...
 
long select_images (Bstring list)
 
unsigned char * read_data (ifstream *fimg, int img_select, int sb, int vax, long pad)
 Read image data in a generalized style. More...
 
int write (Bstring &fn)
 
int unpack_transform (unsigned char *data, FourierType tf)
 
int unpack_transform (int img_select, unsigned char *data, FourierType tf)
 
int pack_transform (unsigned char *data, FourierType tf)
 
int pack_transform (int img_select, unsigned char *data, FourierType tf)
 
long statistics ()
 Calculates the statistics for an image. More...
 
long statistics (long img_num)
 Calculates the statistics for a sub-image. More...
 
long statistics (Bimage *pmask, double &regavg, double &regstd)
 Calculates the statistics for a region in an image. More...
 
double poisson_statistics_check ()
 Checks whether the statistics conform to a Poisson distribution. More...
 
vector< double > stats_within_radii (long nn, Vector3< double > loc, double rad_min, double rad_max)
 Calculates the statistics for an image within given radii from a location. More...
 
vector< double > stats_in_shape (long nn, int type, Vector3< long > start, Vector3< long > end)
 Calculates the statistics for an image within the given box. More...
 
vector< double > stats_in_poly (long nn, int nvert, Vector3< double > *poly)
 Calculates the statistics for an image within the given polyhedron. More...
 
long stats_in_mask (long nn, Bimage *pmask)
 Calculates the statistics for an image for each level in a mask. More...
 
int variance (long kernel_size, int flag=0)
 Calculates the local variance within the given kernel. More...
 
int variance (Vector3< long > kernel_size, int flag=0)
 Calculates the local variance within the given kernel. More...
 
int variance (Bimage *pweight)
 Calculates the local variance weighed with the given image. More...
 
int information ()
 Prints out header information for an image. More...
 
int subimage_information ()
 Prints out header information for all sub-images. More...
 
int moments (long max_order)
 Prints out moments for all sub-images. More...
 
int moments (long max_order, long nn)
 Prints out moments for one sub-image. More...
 
void get (Bstring tag)
 Prints out header information associated with a tag string. More...
 
Bimagecopy ()
 Copies the header information and data of an image into a new image structure. More...
 
Bimagecopy (long nu_nimg)
 Copies the header information and data of an image into a new image structure. More...
 
Bimagecopy_header ()
 
Bimagecopy_header (long nu_nimg)
 Copy an image structure into a new one. More...
 
Bimageextract (long nn)
 Extracts one sub-image into new image structure. More...
 
Bimageextract (long n1, long n2)
 Extracts a set of sub-images into new image structure. More...
 
Bimageextract (long nn, Vector3< long > coords, Vector3< long > size, int fill_type=0, double fill=0)
 Extracts a region of one sub-image into new image structure. More...
 
Bimageextract (long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin)
 
Bimageextract (long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin, Matrix3 mat)
 Extracts a region of one sub-image into new image structure. More...
 
Bimageextract (long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin, View view)
 
Bimageextract_wrap (long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin, Matrix3 mat)
 Extracts a region of one sub-image into new image structure with wrapping. More...
 
Bimageextract_wrap (long nn, Vector3< long > size, Matrix3 mat)
 
Bimageextract_shell (long nn, double minrad, double maxrad)
 Extracts a shell from an image into a new image. More...
 
vector< Vector3< long > > tile_coordinates (Vector3< long > &start, Vector3< long > &region, Vector3< long > &tile_size, Vector3< long > &step_size, int exceed)
 Generates a set of tile coordinates for an image. More...
 
vector< Vector3< long > > tile_coordinates (Vector3< long > tile_size, Vector3< long > &step_size)
 Generates a set of tile coordinates to fit in the image dimensions. More...
 
Bimageextract_tiles (long nn, vector< Vector3< long > > &coords, Vector3< long > tile_size)
 Extracts a set of tiles at specified positions from an image into a new image. More...
 
Bimageextract_tiles (long nn, Vector3< long > start, Vector3< long > region, Vector3< long > tile_size, Vector3< long > step_size, int exceed)
 Extracts a set of tiles from an image into a new image. More...
 
Bimageextract_tiles (long nn, Vector3< long > tile_size, double fraction=0.2)
 Extracts a set of tiles from an image into a new image. More...
 
Bimageextract_tile_stack (Vector3< long > coords, Vector3< long > tile_size, int fill_type=0, double fill=0)
 Extracts a stack of tiles at a specified position from an image into a new image. More...
 
Bimage ** extract_tile_stacks (vector< Vector3< long > > &coords, Vector3< long > tile_size)
 Extracts stacks of tiles at a specified positions from an image into an array of new images. More...
 
Bimageextract_line (long nn, Vector3< double > start, Vector3< double > end, long width)
 Extracts a line from an image into a new image. More...
 
Bimageextract_tetrahedron (Vector3< double > *tet, int fill_type=0, double fill=0)
 Extracts a tetrahedral part of the image. More...
 
Bimageorthogonal_slices (long nn, Vector3< long > voxel, Vector3< long > ext_size)
 Extracts orthogonal views around a voxel. More...
 
Bimageorthogonal_montage (Vector3< long > voxel, Vector3< long > ext_size, int pad=0, int fill_type=0, double fill=0)
 Extracts orthogonal views around a voxel and create a montage. More...
 
int extract_show_chunk (Bimage *pshow, int aflag, long i, long len)
 
Bimageextract_show (int aflag)
 Converts a slice from an image to a 2D plane for display. More...
 
Bimageextract_magnify (long nn, Vector3< long > center, Vector3< long > ext_size, double scale)
 Extracts a region from an image to magnify. More...
 
Bimageextract_slice (long nz)
 Extracts a given slice or slices from an image. More...
 
Bimageextract_filament (long img_num, double width, int axis, long nspline, Vector3< double > *spline)
 Extracts a filament defined by a series of coordinates. More...
 
int replace (Bimage *img)
 Replaces the data with that from the given image. More...
 
int replace (long nn, Bimage *img, long nr=0)
 Replaces one sub-image in an image structure. More...
 
int replace (long nn, Bimage *img, long nr, double fill)
 Replaces one sub-image in an image structure. More...
 
void clear ()
 
void fill (double v)
 
double density (long nn, Vector3< double > coord, double radius, double &sigma)
 Calculates the density in a sphere around a coordinate in an image. More...
 
double density (long nn, Vector3< double > coord, double radius)
 
double relative_density (Bimage *pmask)
 Calculates the relative density in a region defined by a mask. More...
 
void invert ()
 Inverts the data in the image. More...
 
void reslice (const char *order)
 
void reslice (Bstring order)
 Switches axes of an image. More...
 
void absolute ()
 Converts to absolute values. More...
 
void add (double v)
 Adds a constant value to an image. More...
 
void phase_add (double v)
 Adds a constant value to a phase image and wraps as necssary. More...
 
void multiply (double v)
 Multiplies an image with a constant value. More...
 
void multiply (long nn, double v)
 Multiplies a sub-image with a constant value. More...
 
void power (double v)
 Calculates the power of an image. More...
 
void sine ()
 Calculates the sine of a phase image. More...
 
void arcsine ()
 Calculates the arcsine of an image. More...
 
void cosine ()
 Calculates the cosine of a phase image. More...
 
void arccosine ()
 Calculates the arccosine of an image. More...
 
void tangent ()
 Calculates the tangent of a phase image. More...
 
void arctangent ()
 Calculates the arctangent of an image. More...
 
void sum_images ()
 Adds all sub-images. More...
 
void average_images ()
 
Bimageaverage_images (bool sd)
 Averages all sub-images and optionally calculates standard deviation image. More...
 
Bimagemoving_sum (long window, long step=1, int flag=0)
 Calculates a moving sum of the sub-images. More...
 
void progressive_sum ()
 Progressive sum of the sub-images. More...
 
void add (Bimage *p)
 Adds another image to an image. More...
 
void add (long nn, Bimage *p)
 Adds another image to a sub-image. More...
 
void subtract (Bimage *p)
 Subtracts another image from an image. More...
 
void add (Bimage *p, double scale, double shift)
 Adds another image to an image. More...
 
void add (long nn, Bimage *p, double scale, double shift)
 Adds another image to an image. More...
 
void multiply (Bimage *p, double scale, double shift=0)
 Multiplies an image with another image. More...
 
void multiply (long nn, Bimage *p)
 Multiplies a sub-image with another image. More...
 
void multiply (Bimage *p)
 Multiplies all sub-images with the first sub-image of the other image. More...
 
void divide (Bimage *p, double scale=1, double shift=0)
 Divides the first image by the second. More...
 
void divide_one (Bimage *p, double scale=1, double shift=0)
 Divides the first image by the first sub-image of the second. More...
 
void inverse (double minval=0)
 Calculates the inverse of the image. More...
 
void largest (Bimage *p)
 Selects the largest of each pixel from two images. More...
 
void smallest (Bimage *p)
 Selects the smallest of each pixel from two images. More...
 
void arctangent (Bimage *p)
 Calculates the inverse tangent from two images. More...
 
Bimageoperator+ (Bimage &p)
 Adds two images together, adjusting for size difference. More...
 
Bplotplot ()
 Converts a one-dimensional image into a plot. More...
 
void vector_to_simple ()
 A vector image is converted to a simple image. More...
 
void sum (long m, Bimage **p)
 Sums an array of images with their FOM blocks. More...
 
void catenate (long m, Bimage **p)
 Catenates an array of images of the same size into a multi-image structure. More...
 
Bimageblend (Bimage *p, long number)
 Blends the two images, creating a new set of sub-images. More...
 
int place (long nn, Bimage *p, Vector3< double > loc, double radius=0, double scale=1, double shift=0, int operation=0)
 Places a small image into a large image. More...
 
int place_with_addition (Bimage *p, long nn)
 Packs a tile into a new composite image with addition within overlap. More...
 
int place_with_overlap (Bimage *p, long nn)
 Packs a tile into a new composite image with weighted overlap. More...
 
int place_central_part (Bimage *p, long nn)
 Packs a tile into a new composite image, retaining only the central part. More...
 
int assemble_tiles (Bimage *pt, int flag=0)
 Assembles overlapping tiles into this image. More...
 
double linear_fit (Bimage *p, Bimage *pmask, double max_exclude)
 Linear least squares fit of two images. More...
 
int histomatch (Bimage *p, long bins)
 Fits two images by matching the histogram of the second to the first. More...
 
int replace_half (Bimage *p)
 Replaces values for >x/2 with the given image. More...
 
int kernel_gaussian (double sigma, double max)
 Generates a gaussian kernel image. More...
 
int kernel_laplacian_of_gaussian (double sigma, double max)
 Generates a laplacian-of-gaussian kernel. More...
 
int filter_average (long kernel_size)
 Applies an averaging filter to an image. More...
 
int filter_average (Vector3< long > k)
 
Bimagegradient ()
 Calculates the central difference gradient image. More...
 
Bimagegradient3x3 ()
 Calculates the difference gradient image in a 3x3 kernel. More...
 
int filter_gaussian (long kernel_size, double sigma=0)
 Applies a gaussian filter to an image. More...
 
int filter_sinc ()
 Weighs an image with a sinc function. More...
 
int convolve_chunk (Bimage *pkernel, float *nudata, long i, long len)
 
int convolve (Bimage *pkernel)
 Convolves an image with an arbitrary size convolution filter. More...
 
int filter_ortho (int type)
 Convolves the image with an orthogonal kernel with wrapping. More...
 
int filter_dog (double sigma1, double sigma2)
 Convolves the image with a difference of gausians kernel. More...
 
int filter_bilateral_chunk (Bimage *pkernel, double sigma2, int kernel_type, float *nudata, long i, long len, int first)
 
int filter_bilateral (double sigma1, double sigma2, int kernel_type, long kernel_radius)
 Denoise an image with combined gaussian distance and density difference kernel. More...
 
int filter_rolling_ball (long radius, double scale)
 Apply a rolling ball filter. More...
 
int filter_rank_chunk (long kernel_size, double rank, float *nudata, long i, long len)
 
int filter_rank (long kernel_size, double rank)
 Applies a median filter to an image. More...
 
Bimagefilter_peak (long kernel_size)
 Finds the peaks in an image. More...
 
Bimageperiodic_averaging (Vector3< double > period)
 Calculates an average within a periodic frame. More...
 
Bimageaniso_average (long ksize, double w)
 Calculates an anisotropic average within a kernel based on the local gradient. More...
 
int filter_by_difference (Bimage *p)
 Calculates an anisotropic average within a kernel based on the local gradient. More...
 
Bimagenad_2D (double ht, double lambda, double C, double alpha)
 Denoises a 2D image by non-linear anisotropic diffusion. More...
 
Bimagenad (double ht, long zw, double lambda, double C, double alpha)
 Denoises a 3D density map by non-linear anisotropic diffusion. More...
 
void simple_to_complex ()
 A simple image is converted to a complex image. More...
 
void two_to_complex ()
 Two sub-images converted to a complex image. More...
 
void multi_channel_to_complex ()
 A multi-channel image is converted to a set of complex images. More...
 
Bimagecomplex_split ()
 A complex image is split into two simple images. More...
 
void phase_to_complex ()
 A phase image is converted to a complex image. More...
 
void complex_to_real ()
 The real part of a complex image is written to a simple image. More...
 
void complex_to_imaginary ()
 The imaginary part of a complex image is written to a simple image. More...
 
void complex_to_intensities ()
 The intensities from a complex image is written to a simple image. More...
 
void complex_to_amplitudes ()
 The amplitudes from a complex image is written to a simple image. More...
 
void complex_to_signed_amplitudes ()
 The signed amplitudes from a complex image is written to a simple image. More...
 
void complex_to_phases ()
 The phases from a complex image is written to a simple image. More...
 
void complex_conjugate ()
 Calculates the complex conjugate image. More...
 
double complex_power ()
 Calculates the power in a complex image. More...
 
double complex_normalize ()
 Normalizes the power in a complex image. More...
 
int complex_invert ()
 Inverts a complex image. More...
 
int complex_convert (ComplexConversion conv)
 Converts a complex image to a simple image. More...
 
int phase_shift (Vector3< double > shift)
 Phase shifts a complex image. More...
 
int phase_shift (long nn, Vector3< double > shift)
 Phase shifts a complex sub-image. More...
 
int phase_shift_to_origin ()
 Phase shifts a set of reflections to the image origin. More...
 
int phase_shift_to_center ()
 Phase shifts a set of reflections to the nominal center of the image origin. More...
 
int complex_multiply (Bimage *p)
 Calculates the product of a complex image with a simple image. More...
 
int complex_product (Bimage *p)
 Calculates the complex product of two complex images. More...
 
int complex_conjugate_product (Bimage *p, int norm=0)
 Calculates the product of a complex image with the conjugate of a second. More...
 
Bimagecomplex_conjugate_product_one2many (Bimage *p)
 Calculates the product of a complex image with the conjugate of a second. More...
 
int complex_apply_mask (Bimage *pmask)
 Applies a mask to a complex image. More...
 
int complex_apply_negative_mask (Bimage *pmask)
 Applies a negative mask to a complex image. More...
 
int complex_apply_dual_mask (Bimage *pmask)
 Applies a dual mask to a complex image. More...
 
int complex_bandpass (double hires, double lores)
 Bandpasses a Fourier transform. More...
 
Bimagepack_two_in_complex (Bimage *p)
 Packs two real images into one complex image. More...
 
Bimageunpack_combined_transform ()
 Unpacks a complex transform obtained from two real images. More...
 
int combined_complex_product ()
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int combined_complex_product (Bimage *pmask)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int combined_complex_product (double hires, double lores, Bimage *pmask=NULL)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int combined_phase_product (double hires, double lores, Bimage *pmask=NULL)
 Calculates the phase product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int combined_complex_product_implicit_mask (double hires, double lores)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
double merge_amplitudes_and_phases (Bimage *pamp)
 Merges the amplitudes from one map with the phases of another. More...
 
double merge_amplitudes_and_phases (Bimage *pref, double res_hi, double res_lo)
 Keeps selected phases and replaces amplitudes and other phases from a reference transform. More...
 
Bimageintensities_phase_colored (double scale)
 Generates a power spectrum with phases colored according to a color wheel. More...
 
int phase_colour_wheel ()
 Generates a phase color wheel. More...
 
fft_plan fft_setup (fft_direction dir, int opt=0)
 Sets up a plan for fast Fourier transforms. More...
 
int fft (fft_direction dir, int norm_flag, ComplexConversion conv)
 Fast Fourier transforms an image with a specified conversion. More...
 
int fft (fft_direction dir, int norm_flag)
 Fast Fourier transforms an image. More...
 
int fft (fft_plan plan, int norm_flag=1)
 Fast Fourier transforms an image. More...
 
int fft ()
 
int fft_back ()
 
int fft_back (fft_plan plan, int norm_flag=1)
 
int fft (fft_direction dir, Vector3< long > tile_size, int norm_flag=1)
 Tiled Fourier transform. More...
 
int fftz (fft_direction dir, int norm_flag=1)
 Fourier transform only of the z columns. More...
 
int fftz ()
 
Vector3< double > change_transform_size (Vector3< long > nusize)
 Resizes a "standard" transform. More...
 
int power_spectrum (int flags=0)
 Calculates a power spectrum. More...
 
Bimagepowerspectrum_tiled (long img_num, Vector3< long > tile_size, int flags=0)
 Prepares a tiled power spectrum from an image for determining CTF parameters. More...
 
Bimagepowerspectrum_tiled_exact (long img_num, Vector3< long > tile_size, int flags=0)
 
Bimagepowerspectrum_tilt_axis (long img_num, Vector3< long > tile_size, double tilt_axis, double tilt_offset, int flags=0)
 Prepares a tiled powerspectrum from a tilted image for determining CTF parameters. More...
 
Bimagedefocus_scale (long nn, double df, double df2, double iCL2, int fill_type)
 
Bimagepowerspectrum_tilted (long img_num, Vector3< long > tile_size, double tilt_axis, double tilt_angle, double defocus, double iCL2, int flags=0)
 Prepares a tiled powerspectrum from a tilted image for determining CTF parameters. More...
 
Bimagepowerspectrum_tiled_and_tilted (Vector3< long > tile_size, double tilt_axis, double tilt_angle, double tilt_offset, double defocus, double iCL2, int flags=0)
 Prepares a tiled powerspectrum from a tilted image for determining CTF parameters. More...
 
vector< double > powerspectrum_isotropy (long n, double &lores, double &hires)
 Calculates a measure of anisotropy in a power spectrum. More...
 
double average_line (long xx, long yy, long zz, long nn, long len, int dir)
 
long fix_power_spectrum (int dir, double ratio)
 Removes high-intensity artifacts on the zero-frequency lines in a power spectrum. More...
 
long fspace_maximum_radius (double resolution, double sampling_ratio=1)
 Calculates the maximum radius in frequency space from a given resolution. More...
 
int fspace_background ()
 Calculates the background for a Fourier transform. More...
 
Complex< double > fspace_interpolate (long img_num, Vector3< double > m, FSI_Kernel *kernel)
 Calculates the complex value at an image location by kernel-based interpolation. More...
 
int fspace_2D_interpolate (Complex< float > cv, Vector3< double > m, double part_weight, int interp_type)
 Interpolates a 2D image for packing ito a 3D reciprocal space volume.
More...
 
int fspace_pack_2D (Bimage *p, Matrix3 mat, double hi_res, double lo_res, Vector3< double > scale, double ewald_wavelength=0, double part_weight=1, int interp_type=0)
 Packs a 2D Fourier transform into a 3D reciprocal space volume.
More...
 
int fspace_pack_2D (Bimage *p, View asu_view, Bsymmetry &sym, double hi_res, double lo_res, Vector3< double > scale, double ewald_wavelength=0, double part_weight=1, int interp_type=0)
 Packs a 2D Fourier transform into a 3D reciprocal space volume.
More...
 
long fspace_pack_2D_into_central_section (Bimage *p, long ft_size, double scale, double hi_res, double lo_res, Matrix3 matr, Matrix3 mat)
 Packs a 2D Fourier transform into a central section of a 3D reciprocal space volume.
More...
 
int fspace_pack_3D (Bimage *p, double hi_res=0, double threshold=0)
 Packs a 3D Fourier transform into a 3D reciprocal space volume. More...
 
long fspace_reconstruction_add (Bimage *p)
 Adds all components to a reconstruction. More...
 
long fspace_reconstruction_weigh ()
 Weighs a reconstruction. More...
 
int fspace_reconstruction_stats (double resolution, double sampling_ratio=1)
 Calculates Fourier shell statistics. More...
 
long fspace_reconstruction_snr ()
 Calculates the SNR map. More...
 
int fspace_translate (Vector3< double > shift)
 Translates an image in frequency space to avoid interpolation. More...
 
int fspace_translate (long nn, Vector3< double > shift)
 Translates an image in frequency space to avoid interpolation. More...
 
int fspace_resize (double scale, double res_hi, double res_lo)
 Resizes an image in frequency space to avoid interpolation. More...
 
Bimagefspace_resize (Bimage *pref)
 Resizes an image in frequency space to avoid interpolation. More...
 
int fspace_amp_one ()
 Sets all amplitudes to one. More...
 
int fspace_amp_threshold (double threshold)
 Filters the amplitudes of the Fourier transform of an image. More...
 
int fspace_sqrt_amp ()
 Change the amlitudes to their square roots. More...
 
int fspace_square_amp ()
 Change the amlitudes to their squares. More...
 
int fspace_bandpass (double res_hi, double res_lo=0, double width=0)
 Applies a bandpass filter to an image. More...
 
int fspace_bandpass (double res_hi, double res_lo, double width, fft_plan planf, fft_plan planb)
 Applies a bandpass filter to an image. More...
 
int fspace_frequency_filter (double freq, double sigma)
 Applies a frequency filter to an image. More...
 
int fspace_frequency_filter (double freq, double sigma, fft_plan planf, fft_plan planb)
 Applies a frequency filter to an image. More...
 
int fspace_gabor_filter (Vector3< double > freq, double fsigma, double psigma)
 Applies a Gabor filter to an image. More...
 
int fspace_gabor_filter (Vector3< double > freq, double fsigma, double psigma, fft_plan planf, fft_plan planb)
 Applies a Gabor filter to an image. More...
 
Bimagefspace_radial_power (double resolution, double sampling_ratio=1)
 Calculates the radial power spectrum from a Fourier transform. More...
 
vector< double > fspace_radial (long nn, long maxrad, int flag=0)
 Calculates the radial power spectrum from a Fourier transform. More...
 
int fspace_weigh (vector< double > &curve, int flag=0)
 
int fspace_scale (vector< double > &scale, Bimage *pmask=NULL)
 
int fspace_scale (long nn, vector< double > &scale, Bimage *pmask=NULL)
 
double fspace_fit_B_factor (double res_hi=0)
 Determines the overall B-factor of an image. More...
 
int fspace_weigh_ramp (double resolution, fft_plan planf, fft_plan planb)
 Weighs a transform with a ramp. More...
 
int fspace_weigh_ramp (double resolution, double axis, fft_plan planf, fft_plan planb)
 Weighs a transform with a ramp. More...
 
int fspace_weigh_B_factor (double B, double resolution=0)
 Weighs an image's amplitudes with B-factor (gaussian) curve. More...
 
int fspace_butterworth_band (double res_hi, double res_lo, int order=16)
 Calculates a Butterworth band-pass filter profile. More...
 
int fspace_weigh_C_curve (double resolution=0)
 Weighs an image's amplitudes with the carbon scattering curve. More...
 
int fspace_weigh_LoG (double resolution, double sigma)
 Weighs an image's amplitudes with a Laplacian-of-Gaussian function. More...
 
int fspace_weigh_RPS_curve (Bplot *plot, double resolution=0)
 Weighs an image's amplitudes with a given RPS curve. More...
 
int fspace_weigh_FSC_curve (Bplot *plot, double resolution=0)
 Weighs an image's amplitudes with a given FSC curve. More...
 
int fspace_weigh_gaussian (long nn, Vector3< double > sigma, int dir=0)
 Weighs an image's amplitudes with an anisotropic Gaussian function. More...
 
Bimagefspace_gradient (Vector3< double > sigma)
 Generates a image with orthogonal gradients encoded in 3-value vectors. More...
 
int fspace_weigh (Bimage *pref, Bimage *pmask, double resolution=0)
 Weighs an image's amplitudes with the radial power spectrum of another. More...
 
int fspace_weigh_dose (long nn, double dose_per_frame, vector< double > critdose)
 
int fspace_weigh_dose (double dose_per_frame, int flag=0)
 Weighs an image's amplitudes with the accumulated dose. More...
 
int fspace_weigh_accumulated_dose (vector< double > dose)
 Weighs an image's amplitudes with the accumulated dose. More...
 
int fspace_normalize ()
 Normalizes an image's amplitudes. More...
 
int fspace_normalize_radial (Bimage *pmask, double resolution=0, int flag=0)
 Normalizes an image's amplitudes. More...
 
int fspace_positive ()
 Sets the image to positive definite. More...
 
double friedel_check ()
 Checks Friedel symmetry. More...
 
double friedel_difference ()
 Calculates the difference between Friedel pairs. More...
 
int friedel_apply ()
 Applies Friedel symmetry. More...
 
Bimageproject (char axis, int flags=1)
 Projects a 3D image to a 2D image down one of the three major axes. More...
 
Bimagerotate_project (Matrix3 mat, Vector3< double > translate, double radial_cutoff, int norm_flag=1)
 Rotates a 3D map and projects it along the z-axis. More...
 
Bimageproject (View *view, int norm_flag=1)
 Calculates a set of projections from a 3D density map. More...
 
Bimagecentral_section (Matrix3 mat, double resolution, FSI_Kernel *kernel, double wavelength=0)
 Calculates a central section of a 3D fourier transform. More...
 
Bimageproject (View *view, double resolution, FSI_Kernel *kernel, double wavelength=0, bool back=1, ComplexConversion conv=NoConversion)
 Calculates a set of projections as central sections from a 3D fourier transform. More...
 
int back_project (Bimage *p, double resolution, double axis, fft_plan planf, fft_plan planb)
 
int opposite_ewald ()
 
int combine_ewald ()
 
Bimageresolution_prepare (Bimage *p)
 
Bimageresolution_prepare (Bimage *p, fft_plan plan)
 
Bplotfsc_dpr (double hi_res, double sampling_ratio=1, int flag=0)
 Calculates an FSC and DPR curves from two images. More...
 
Bplotfsc (double hi_res, double sampling_ratio, vector< double > &fsccut)
 
Bplotfsc (Bimage *p, double hi_res, double sampling_ratio=1)
 
Bimagefsc_shell (Bimage *p, double hi_res, double *cutoff, int thickness, int step, int minrad, int maxrad, int pad=1, int smooth=0, double fill=0)
 Determine the resolution for each concentric shell in a map. More...
 
Bimagefsc_local (Bimage *p, Bimage *pmask, double resolution, double *cutoff, int mask_level, int size, int pad, Vector3< long > vedge, int step=1, int taper=1, double fill=0)
 Determine the local resolution at each masked voxel in a map. More...
 
Bimagelocal_filter (Bimage *pmask, int mask_level, Bimage *resmap, int size, Vector3< long > vedge)
 Applies a local resolution filter to a map. More...
 
Bimagephase_difference (Bimage *p, int type=0, double res_hi=0, double res_lo=0)
 Calculates the cosine of the phase difference between two images. More...
 
double average_phase_difference (Bimage *p, double res_hi, double res_lo, int weighting=1)
 Calculates the average of the absolute phase difference between two images within given resolution shells. More...
 
int phase_flip (Bimage *pd)
 Flips the phases of an image based on a phase difference map. More...
 
int ewald_sphere (double volt, double t)
 Imposes an Ewald sphere weighting on a 3D frequency space volume. More...
 
double correlate (Bimage *p)
 Calculates correlation coefficient between two images. More...
 
double correlate (Bimage *p, double rmin, double rmax, Bimage *pmask=NULL, int flag=0)
 Calculates a correlation coefficient between two images. More...
 
double rotate_correlate (Vector3< double > axis, double angle)
 Rotates a copy of an image and correlates it with the original. More...
 
double R_factor (Bimage *p)
 Calculates an R factor between two images. More...
 
int auto_correlate (double hires, double lores)
 Calculates an autocorrelation map by Fast Fourier transformation. More...
 
Bimagecross_correlate (Bimage *p, double hires, double lores, fft_plan planf, fft_plan planb)
 Calculates a cross-correlation map by Fast Fourier transformation. More...
 
Bimagecross_correlate (Bimage *p, Bimage *pmask=NULL)
 
Bimagecross_correlate (Bimage *p, double hires, double lores, Bimage *pmask=NULL)
 Calculates a cross-correlation map by Fast Fourier transformation. More...
 
Bimagephase_correlate (Bimage *p, double hires, double lores, Bimage *pmask=NULL)
 Calculates a phase correlation map by Fast Fourier transformation. More...
 
double correlation_coefficient (Vector3< double > shift)
 Calculates a coefficient from a Fourier correlation transform given a shift. More...
 
Vector3< double > find_shift_in_transform (double shift_limit)
 Finds the shift by brute force backtransformation for selected shifts. More...
 
Bimagecross_correlate_fspace (Bimage *p, double hires, double lores, double shift_limit)
 Calculates a cross-correlation map by Fast Fourier transformation. More...
 
Bimagecross_correlate (Bimage *p, double hires, double lores, Bimage *pmask, fft_plan planf, fft_plan planb)
 
Bimagecross_correlate_two_way (Bimage *p, double hires, double lores, fft_plan planf, fft_plan planb)
 Calculates a cross-correlation map by Fast Fourier transformation. More...
 
Bimagecross_correlate_validate (Bimage *p, Bimage *pmask)
 Calculates a masked cross-correlation map by Fast Fourier transformation. More...
 
Vector3< double > rotate_cross_correlate (Bimage *pref, View view, double hires, double lores, double search_radius, Bimage *pmask, double &cc, fft_plan planf, fft_plan planb)
 
double rotate_cross_correlate_two_way (Bimage *pref, double angle, double res_hi, double res_lo, double shift_limit, fft_plan planf, fft_plan planb)
 
int find_shift (Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
 Calculates a cross-correlation map to find the shift for the pair of images. More...
 
Vector3< double > find_shift (Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag, double &cc)
 
Vector3< double > find_shift (Bimage *pref, double hires, double lores, double radius, double sigma, int refine_flag, fft_plan planf, fft_plan planb)
 Calculates a cross-correlation map to find the shift for the pair of images. More...
 
Vector3< double > find_shift (Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag, fft_plan planf, fft_plan planb, double &cc)
 Calculates a cross-correlation map to find the shift for the pair of images. More...
 
Vector3< double > find_shift (long nn, Bimage *pref, Bimage *pmask, double hi_res, double lo_res, double shift_limit, fft_plan planf, fft_plan planb)
 Calculates a cross-correlation map to find the shift for the pair of images. More...
 
Bimagefind_template (Bimage *ptemp, Bimage *pmask, double hires, double lores, int bin, fft_plan planf, fft_plan planb)
 Finds one or more matches to a template. More...
 
int find_center (Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
 Finds the center of mass of an image by cross-correlation with its inverse. More...
 
Vector3< double > rotate_find_shift (Matrix3 mat, double hires, double lores, double radius, double sigma, int refine_flag, fft_plan planf, fft_plan planb, double &cc)
 Rotates and find shift by cross-correlation. More...
 
int find_peak (double radius=1e30, double sigma=0)
 Finds the peak in an image to the nearest voxel. More...
 
Vector3< double > fit_peak ()
 Fits an elliptic parabole to locate the position of the peak to sub-voxel resolution. More...
 
int refine_peak_new ()
 Refines the position of a peak to sub-voxel resolution. More...
 
int refine_peak ()
 Refines the position of a peak to sub-voxel resolution. More...
 
int refine_peak (long kernel_size)
 Refines the position of a peak to sub-voxel resolution. More...
 
Bimagefind_peaks (long kernelsize)
 Finds peaks in a map with periodic boundaries. More...
 
Vector3< double > * find_peaks (double excl_dist, long &ncoor, double &threshold_min, double &threshold_max, double pix_min=2, double pix_max=10)
 Finds the peaks in a cross-correlation map to find template matches. More...
 
double ccmap_confidence (long nn)
 Calculates a confidence level to associate with a cross-correlation peak. More...
 
double peak_sigma (long nn, Vector3< long > coor, long kernel_size)
 Calculates a sigma value for a cross-correlation peak. More...
 
double search_views (Bimage *ptemp, View *view, double hires, double lores, double search_radius, Bimage *pmask, View &currview, Vector3< double > &currshift)
 Searches a 2D/3D density map for a template. More...
 
double search_volume_view (Bimage *ptemp, View view, double hires, double lores, Bimage *pmask, double threshold, Bimage *pfit)
 Searches a 2D/3D density map for a template using a specific view. More...
 
Bimagesearch_volume (Bimage *ptemp, View *view, double alpha, double alpha_step, double hires, double lores, Bimage *pmask, double threshold)
 Searches a 2D/3D density map for a template. More...
 
Vector3< double > find_shift_in_transform (long nn, Bimage *pref, double shift_limit)
 
Bimagealign_progressive_fast (long nref, double shift_limit)
 Aligns and sums a set of sub-images using a progressive algorithm. More...
 
Bimagealign_progressive (long nref, Bimage *pmask, double hi_res, double lo_res, double shift_limit, fft_plan planf, fft_plan planb)
 Aligns and sums a set of sub-images using a progressive algorithm. More...
 
Bimagealign_local (long nref, Bimage *pmask, double hi_res, double lo_res, double shift_limit, fft_plan planf, fft_plan planb)
 Aligns and sums a set of sub-images using a progressive algorithm. More...
 
vector< Vector3< double > > align (long ref_num, long window, long step, Bimage *pmask, double hi_res, double lo_res, double shift_limit, double edge_width, double gauss_width, Vector3< long > bin, int mode=0)
 Aligns and sums a set of sub-images, first progressively and then iteratively. More...
 
JSvalue align_fast (long ref_num, Bimage *pmask, double hi_res, double lo_res, double shift_limit, double edge_width, double gauss_width)
 Aligns and sums a set of sub-images, first progressively and then iteratively. More...
 
Bimagefspace_sum (int shift=0)
 
Bimagefspace_shift_sum ()
 
Bimagefspace_subset_sums (int subset, int flag=0)
 
Bplotfspace_ssnr (long nimg, double res_hi, double sampling_ratio)
 
Bplotfspace_subset_ssnr (int subset, double res_hi, double sampling_ratio, int flag=0)
 
double correlate_annuli (Bimage *polref, int ann_min, int ann_max, double ang_min, double ang_max, fft_plan planf, fft_plan planb, double &cc_max)
 Correlate annuli of a polar image. More...
 
vector< double > pps_angular_correlation (Bimage *pref, double res_hi, double res_lo, long nang, fft_plan planf)
 
double align2D_pps (Bimage *pref, double res_hi, double res_lo, double shift_limit, double angle_limit, fft_plan planf, fft_plan planb)
 Finds the best in-plane alignment for two 2D images using polar power spectra. More...
 
double align2D (Bimage *pref, double res_polar, int ann_min, int ann_max, Bimage *prs_mask, double shift_limit, double angle_limit, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D)
 Finds the best in-plane alignment for two 2D images using polar power spectra. More...
 
int align2D (Bimage *pref, int ann_min, int ann_max, double res_lo, double res_hi, double shift_limit, double angle_limit)
 Finds the best in-plane alignment for two 2D images using polar power spectra. More...
 
void simple_to_rgb ()
 A simple image is converted to a color image. More...
 
void simple_to_rgba ()
 A simple image is converted to a color image. More...
 
void color_to_simple ()
 A color image is converted to a simple image. More...
 
void rgb_to_rgba ()
 An alpha channel is added to a RGB color image. More...
 
void rgba_to_rgb ()
 The alpha channel is delete from an RGBA color image. More...
 
void rgb_to_cmyk ()
 Converts an RGB color image to CMYK. More...
 
void cmyk_to_rgb ()
 Converts a CMYK color image to RGB. More...
 
int one_color (int color, double cmin, double cmax, int flag=0)
 Converts a gray-scale image to a single color. More...
 
int color_red (double cmin, double cmax, int flag=0)
 Converts a gray-scale image to red. More...
 
int color_green (double cmin, double cmax, int flag=0)
 Converts a gray-scale image to green. More...
 
int color_blue (double cmin, double cmax, int flag=0)
 Converts a gray-scale image to blue. More...
 
int pure_color ()
 Generates a pure color image without intensity. More...
 
int color_combine (Bimage *p)
 Combines two colored images. More...
 
Bimagecolor_spectrum (double cmin, double cmax)
 Colorizes an image to a spectrum. More...
 
Bimagered_white_blue (double red_min, double white_min, double white_max, double blue_max)
 Colorizes an image with blue positive and red negative. More...
 
int rescale (double scale, double shift)
 Rescales the image data with a given multiplier and offset. More...
 
int rescale (long nn, double scale, double shift)
 Rescales the image data with a given multiplier and offset. More...
 
int rescale_to_min_max (double numin, double numax)
 Rescales the image data to a given minimum and maximum. More...
 
int rescale_to_min_max (long nn, double numin, double numax)
 Rescales the image data to a given minimum and maximum. More...
 
int rescale_to_avg_std (double nuavg, double nustd)
 Rescales the image data to a given average and standard deviation. More...
 
int rescale_to_avg_std (long nn, double nuavg, double nustd)
 Rescales the image data to a given average and standard deviation. More...
 
int rescale_to_avg_std (double nuavg, double nustd, Bimage *pmask)
 Rescales the image data to a given average and standard deviation. More...
 
int truncate (double minim, double maxim, double setmin, double setmax)
 Truncates image data to a given minimum and maximum. More...
 
int truncate_to_min_max (double minim, double maxim)
 Truncates image data to a given minimum and maximum. More...
 
int truncate_to_avg (double minim, double maxim)
 Sets voxels in image data exceeding a given minimum and maximum to the average. More...
 
int truncate_to_background (double minim, double maxim)
 Sets voxels in image data exceeding a given minimum and maximum to the image background. More...
 
int limit_levels (int nlevels)
 Converts a full gray scale image to a limited level image. More...
 
int normalize (long imgnum, double average, double stdev, int norm_type, long bins)
 Normalizes a sub-image to a desired average and standard deviation. More...
 
int normalize (double average, double stdev, int norm_type)
 Normalizes a set of images to a desired average and standard deviation. More...
 
int normalize_local (long kernel_size)
 Normalizes by subtracting local average and dividing by local standard deviation. More...
 
int normalize_local (Vector3< long > kernel)
 Normalizes by subtracting local average and dividing by local standard deviation. More...
 
void square ()
 Calculates the square of an image. More...
 
void square_root ()
 Calculates the square root of an image. More...
 
void logarithm ()
 Calculates the logarithm of the image data. More...
 
void exponential ()
 Calculates the exponential of the image data. More...
 
int gradient_correction ()
 Calculates and corrects for a linear gradient across an image. More...
 
int quadric_correct (vector< double > param)
 Corrects for a quadric surface. More...
 
vector< double > quadric_fit ()
 Fits the whole image to a quadric surface. More...
 
Bimagethickness (double reference, double emfp)
 Calculates a thickness based on intensities with respect to a reference. More...
 
int calculate_background (long nn, int flag)
 Calculates the background for one sub-image. More...
 
int calculate_background (int flag=0)
 Calculates the background for each sub-image. More...
 
int calculate_background (Bimage *pmask, long nn, int flag=0)
 Calculates the background for one sub-image. More...
 
int calculate_background (Bimage *pmask, int flag=0)
 Calculates the background for each sub-image. More...
 
int correct_background (long nn, int flag)
 Corrects the background for one sub-image. More...
 
int correct_background (int flag=0)
 Corrects the background for each sub-image. More...
 
int correct_background (Bimage *pmask, int flag=0)
 Corrects the background for each sub-image. More...
 
int subtract_background ()
 Subtracts the background for each sub-image. More...
 
int shift_background (double bkg)
 Sets the background for each sub-image to a given value. More...
 
vector< long > histogram (long bins, double &scale, double &offset)
 Calculates the histogram of an image. More...
 
Bplothistogram (long bins)
 Calculates the histogram of an image. More...
 
Bplothistogram_counts (int flags=0)
 Finds the peaks in a quantized image from the histogram. More...
 
Bplotpercentiles ()
 Calculates the percentiles from the histogram of an image. More...
 
int histogram_minmax (double &tmin, double &tmax)
 Calculates minimum and maximum thresholds for truncation. More...
 
Bplothistogram_otsu_variance (long bins)
 Calculates the inter-set variance of the bisection of a historgram using the method of Otsu. More...
 
double otsu_threshold (long bins)
 Calculates the threshold from a histogram according to Otsu. More...
 
vector< double > otsu_variance (vector< long > h)
 Calculates the inter-set variance of the bisection of a historgram using the method of Otsu. More...
 
vector< double > histogram_multi_thresholds (long bins, long number)
 Calculates multiple thresholds from a histogram. More...
 
vector< double > histogram_gauss_fit (long bins, long ngauss=1)
 Fits a gaussian function to a histogram of an image. More...
 
vector< double > histogram_gauss_fit2 (long bins, long ngauss=1)
 
Bplothistogram_gauss_plot (long bins, long ngauss=1)
 Fits a gaussian function to a histogram of an image. More...
 
Bplothistogram_poisson_fit (long bins, int flag=0)
 Fits a poisson function to a histogram of an image. More...
 
int resize (Vector3< long > nusize, Vector3< long > translate, int fill_type=0, double fill=0)
 Resizes without interpolation or rescaling. More...
 
Bimageresize_copy (Vector3< long > nusize, Vector3< long > translate, int fill_type=0, double fill=0)
 Resizes without interpolation or rescaling. More...
 
int resize_wrap (Vector3< long > nusize, Vector3< long > translate)
 Resizes without interpolation or rescaling. More...
 
Bimageresize_wrap_copy (Vector3< long > nusize, Vector3< long > translate)
 Resizes with wrapping without interpolation or rescaling. More...
 
int pad (long sz, int fill_type=0, double fill=0)
 Pads an image to a new size with a given fill value. More...
 
int pad (Vector3< long > sz, int fill_type=0, double fill=0)
 Pads an image to a new size with a given fill value. More...
 
Bimagepad_copy (long sz, int fill_type=0, double fill=0)
 Pads an image to a new size with a given fill value. More...
 
Bimagepad_copy (Vector3< long > sz, int fill_type=0, double fill=0)
 Pads an image to a new size with a given fill value. More...
 
int shrink_wrap (Vector3< long > nusize, Vector3< long > translate)
 Shrinks an image to a new size with wrapping of the excluded edges. More...
 
int enlarge (Vector3< long > scale)
 Enlarges an image by an inetger scale. More...
 
Bimagemontage (int first, int cols, int rows, int skip=0, int flipy=0)
 Rearranges an image into a montage of 2D slices for display. More...
 
int shape (int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0, bool wrap=0)
 Creates a shape in an image and fills it with a constant value. More...
 
int shape (long nn, int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0, bool wrap=0)
 Creates a shape in an image and fills it with a constant value. More...
 
int line (Vector3< double > start, Vector3< double > end, double width, int fill_type=0, double fill=0)
 Creates a line in an image and fills it with a constant value. More...
 
Bimageedge_mask (int type, Vector3< long > rect, Vector3< double > start, double width)
 Creates a mask with the edge approaching zero. More...
 
int edge (int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0)
 Smooths the image edge with a soft rectangular function. More...
 
int edge (long nn, int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0)
 Smooths the image edge with a soft rectangular function. More...
 
Bimageextract_edge_difference ()
 Extracts all the edge pixels into a new image. More...
 
int hanning_taper (double fill=0)
 Apply Hanning taper window to the image. More...
 
int sphere (Vector3< double > center, double radius, double width=0, int fill_type=0, double fill=0, bool wrap=0)
 Fills a sphere within an image with a uniform value. More...
 
int cylinder (Vector3< double > center, double radius, double height, double width, int fill_type=0, double fill=0, bool wrap=0)
 Fills a cylinder within an image with a uniform value. More...
 
int gaussian_sphere (long nn, Vector3< double > center, double sigma, double amp, bool wrap=0)
 Fills a gaussian sphere within an image with a uniform value. More...
 
int shell (Vector3< double > center, double minrad, double maxrad, double width, int fill_type=0, double fill=0)
 Fills a shell within an image with a uniform value. More...
 
int shell (long nn, Vector3< double > center, double minrad, double maxrad, double width, int fill_type=0, double fill=0)
 Fills a shell within an image with a uniform value. More...
 
int shell_wrap (Vector3< double > center, double minrad, double maxrad, double width, int fill_type, double fill)
 Fills a shell within an image with a uniform value. More...
 
int shell_wrap (long nn, Vector3< double > center, double minrad, double maxrad, double width, int fill_type=0, double fill=0)
 Fills a shell within an image with a uniform value with wrapping. More...
 
int bar (Vector3< double > start, Vector3< double > end, double width, double edge_width, int fill_type=0, double fill=0)
 Generates a bar between start and end points. More...
 
int bar (long nn, Vector3< double > start, Vector3< double > end, double width, double edge_width, int fill_type=0, double fill=0)
 Generates a bar between start and end points. More...
 
int quadric (double *param)
 Generates a quadric surface over the whole image. More...
 
int chirp (double freq_scale, double freq_shift=0)
 Generates a chirp image. More...
 
int fill_gaps (long step)
 Fill the voxels that are not calculated. More...
 
int interpolate_gaps (long step)
 Interpolate the voxels that are not calculated. More...
 
int transform (Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
 Transforms an image by translation, rotation, scaling and skewing, in place. More...
 
Bimagetransform (Vector3< long > nusize, Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
 Transforms an image by translation, rotation, scaling and skewing, returning a new image. More...
 
void transform_voxel (long i, Bimage *pt, long nn, Vector3< double > oldorigin, Vector3< double > nuorigin, Matrix3 affmat, double fill)
 
Bimagetransform (long nn, Vector3< long > nusize, Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
 Transforms a sub-image by translation, rotation, scaling and skewing, returning a single new image. More...
 
int rotate ()
 Rotates an image using parameters defined in the image in place. More...
 
int rotate (double angle)
 Rotates an image around the z-axis by the given angle in place. More...
 
int rotate (Vector3< double > axis, double angle)
 Rotates an image using an axis and angle in place. More...
 
int rotate (View view)
 Rotates an image to a specified view in place. More...
 
int rotate (Vector3< double > translate, View view)
 Rotates an image to a specified view in place. More...
 
int rotate (Matrix3 mat)
 Rotates an image using the specified matrix. More...
 
int rotate (Vector3< double > translate, Matrix3 mat)
 Rotates an image using the specified shift and matrix. More...
 
Bimagerotate (Vector3< long > nusize)
 Rotates an image using parameters defined in the image. More...
 
Bimagerotate (Vector3< long > nusize, double angle)
 Rotates an image around the z-axis by the given angle. More...
 
Bimagerotate (Vector3< long > nusize, Vector3< double > axis, double angle)
 Rotates an image using an axis and angle. More...
 
Bimagerotate (Vector3< long > nusize, View view)
 Rotates an image to a specified view. More...
 
Bimagerotate (Vector3< long > nusize, Vector3< double > translate, View view)
 Rotates an image to a specified view. More...
 
Bimagerotate (Vector3< long > nusize, Matrix3 mat)
 Rotates an image using the specified matrix. More...
 
int rotate_and_add (Bimage *p, Vector3< double > origin, View view)
 Rotates an image to a specified view and adds it to another image. More...
 
Bimageorient (View *views)
 Calculates multiple copies oriented according to views. More...
 
int mirror ()
 Inverts/mirrors each image through its origin. More...
 
int shift (Vector3< double > vec, int fill_type=0, double fill=0)
 Shifts an image. More...
 
int shift (long nn, Vector3< double > vec, int fill_type=0, double fill=0)
 Shifts one sub-image. More...
 
int shift_wrap (Vector3< double > vec)
 Shifts an image. More...
 
int shift_wrap (long nn, Vector3< double > vec)
 Shifts one sub-image with wrapping. More...
 
int center (int fill_type=0, double fill=0)
 Centers an image. More...
 
int center_wrap ()
 Centers an image with wrapping. More...
 
int zero_origin ()
 Shifts the origins to zero with wrapping. More...
 
Vector3< long > reciprocal_half ()
 
Bimagescale_to_same_size (Bimage *pref)
 Scales and image to the given reference. More...
 
Bimagescale_to_reference (Bimage *pref, Bimage *pmask, double scalemin, double scalemax, double step)
 Scales and image to the given reference, searching for the correct scale. More...
 
Bimagescale_to_reference (Bimage *pref, Bimage *pmask=NULL)
 Scales and image to the given reference, searching for the correct scale. More...
 
double symmetrize (Bstring &symmetry_string, int flag)
 
double symmetrize (Bsymmetry sym, int flag)
 
double symmetrize (Bstring &symmetry_string, View ref_view, int flag)
 
double symmetrize_cyclic (int cyclic, int flag)
 
double symmetrize (Bsymmetry sym, View ref_view, int flag)
 Applies point group symmetry to an image. More...
 
double check_point_group (Bstring &check_string)
 Checks for the requested symmetries. More...
 
double find_cyclic_point_group (Bsymmetry &sym, int binfac, double hires, double lores)
 Finds the orientation for an image with a cyclic point group symmetry. More...
 
double find_point_group (Bsymmetry &sym, double angle_step, int binfac, double hires, double lores, int flags)
 Finds the orientation for an image with a specific point group symmetry. More...
 
long rotate_to_axis (Bsymmetry &sym, long axis, long axis_flag)
 Rotates to a symmetry axis. More...
 
int change_symmetry (Bsymmetry &symold, Bsymmetry &symnu, double radius, double z_slope)
 Changes the symmetry order for cyclic and dihedral maps. More...
 
Matrix3 symmetry_equivalent (Bimage *ptemp, Bimage *pmask, Bsymmetry &sym)
 Finds the symmetry equivalent orientation of a particle with respect to a template. More...
 
Matrix3 symmetry_equivalent_cyclic (Bimage *pref, Bimage *pmask, Bsymmetry &sym)
 Finds the cyclic symmetry equivalent orientation of a particle with respect to a template. More...
 
Bimagelevelmask_asymmetric_units (Bsymmetry &sym, int index)
 Calculates a multi-level mask to indicate asymmetric units. More...
 
int replicate_asymmetric_unit (Bsymmetry &sym)
 Calculates a full map from one asymmetric unit. More...
 
Bimagefind_symmetric_view (Bimage *ptemp, Bsymmetry &sym, double phi_step, double theta_step, double alpha_step, Vector3< double > shift)
 Finds the view that on symmetrizing fits best to a symmetric template.
More...
 
double helix_interpolate (long i, double helix_rise, double helix_angle, int zmin, int zmax, double radius, int norm_flag=1)
 
double dyad_interpolate (long i, int norm_flag=1)
 
double tube_interpolate (long i, int h, int k, double latconst, int zmin, int zmax, double radius, int norm_flag=1)
 
double helix_symmetrize (double helix_rise, double helix_angle, int dyad_axis, int zmin, int zmax, double radius, int norm_flag=1)
 Symmetrizes an image given helical symmetry parameters. More...
 
Bplotseamed_helix_symmetrize (double helix_rise, double helix_angle, double seam_shift, int dyad_axis, int zmin, int zmax, double radius, int norm_flag)
 Symmetrizes an image given helical symmetry parameters and seam shift parameter. More...
 
Bimagesymmetrize_cylinder (int flag)
 Calculates a cylindrically symmetrized map. More...
 
int symmetrize_cylinder ()
 Calculates a cylindrically symmetrized map. More...
 
double tube_symmetrize (int h, int k, double latconst, int zmin, int zmax, double radius, int norm_flag=1)
 Symmetrizes an image given tubular lattice parameters. More...
 
double convert_to_helix (double helix_rise, double helix_angle, Vector3< double > offset)
 Converts a map to a helix. More...
 
int distort_elliptically (double angle, double shift)
 Transforms a tubular cylinder to an elliptical profile. More...
 
Vector3< double > test_helix_parameters (double angle, double hires, double lores, Vector3< long > mask_size, Vector3< long > mask_start, long max_iter, fft_plan planf, fft_plan planb, double &cc)
 
Bplotfind_helix_parameters (double angle_start, double angle_end, double angle_step, int bin, double hires, double lores, double radius)
 Finds the best helix parameters for helical map. More...
 
double test_helix_parameters (double rise, double angle, Vector3< long > mask_size, Vector3< long > mask_start)
 
Bplotfind_helix_parameters (double rise_start, double rise_end, double rise_step, double angle_start, double angle_end, double angle_step, int bin, double radius)
 Finds the best helix parameters for helical map. More...
 
int helix_segment_correlation_one (long i, double angle_start, double angle_end, double angle_step, int bin, double hires, double lores, double radius, fft_plan planf, fft_plan planb, double *cc)
 
Bplothelix_segment_correlation (int thickness, double angle_start, double angle_end, double angle_step, int bin, double hires, double lores, double radius)
 Calculates the correlation over rotation angles between helical segments. More...
 
int transform_lines ()
 
Bimagehelical_cross_section (double helix_rise, double helix_angle, double scale, double hires)
 Calculates a helical cross section from line transforms of a filament. More...
 
double snvariance (double snradius)
 Calculates the ratio of variance inside and outside a given radius. More...
 
int extrude_cross_section (long length, double helix_rise, double helix_angle, int fill_type, double fill)
 Extrudes a 2D cross section into a 3D continuous helix. More...
 
Bplotfilament_width (long width, long lim_lo, long lim_hi)
 Estimates the width of a filament. More...
 
Bimagefilament_density (double width)
 Estimates the density per pixel length of a filament. More...
 
Bimagefilament_from_projections (double hi_res, int flag=0)
 Reconstructs a filament from a set of projections. More...
 
Bimageradial (long minrad, long maxrad, double rad_step=1, int wrap=0)
 Calculates the radial average of an image. More...
 
Bimageradial (long minrad, long maxrad, double rad_step, Bimage *pmask, int wrap=0)
 Calculates the radial average of an image. More...
 
Bimageradial (long minrad, long maxrad, double rad_step, double ellipticity, double angle, Bimage *pmask, int wrap=0)
 Calculates the radial average of an image. More...
 
Bimageradial_symmetry_adjusted (double rad_start, double rad_end, double rad_step, double spherical_fraction, Bsymmetry &sym)
 Calculates the symmetry-adjusted radial average of an image. More...
 
double * radial_fit (Bimage *pref)
 Fits a radial profile to a reference radial profile. More...
 
Bimageradial_to_full (Vector3< long > nusize, Vector3< double > origin)
 Generates a full 2D or 3D image from a radial profile in a 1D image. More...
 
Bimagecartesian_to_spherical (long nannuli, long nphi, long ntheta)
 Calculates an image with spherical coordinates. More...
 
Bimagecartesian_to_cylindrical (long nannuli, long nphi, int flag=0)
 Calculates an image with cylindrical coordinates. More...
 
Bimagepolar_transform (long nangles, long ann_min, long ann_max, long dann, long zmin, long zmax, long zinc)
 Calculates an image with cylindrical coordinates by integration. More...
 
Bimagepolar_power_spectrum (double resolution, long num_angle)
 Calculates the polar power spectrum of a 2D transform amplitude or intensity image. More...
 
int line_powerspectra (fft_plan plan)
 Calculates the 1D power spectrum of each line in an image. More...
 
int radial_shells ()
 Calculates an image with slices representing radial shell projections. More...
 
int cylindrical_shells ()
 Calculates an image with slices representing cylindrical shell projections. More...
 
Bimageradial_sections (double rad_start, double rad_end, double rad_step, double spherical_fraction, Bsymmetry &sym, int fill_type=FILL_USER, double fill=0)
 Calculates an image with slices giving the radial section projections. More...
 
Bimageradial_coverage (double threshold, double rad_step=1)
 Calculates the coverage in each radial shell. More...
 
Bimagetopograph_to_surface (Bimage *psd, long nz, double density, double resolution)
 Converts a 2D AFM image to a 3D density map. More...
 
Bimagesurface_to_topograph (double threshold, int dir=0)
 Converts a 3D image to a 2D height image. More...
 
Bimagerotate_height (Matrix3 mat, Vector3< double > translate, double threshold=0)
 Rotates a 3D map and calculates the height along the z-axis. More...
 
Bimageheight (View *views, double threshold=0)
 Calculates a set of height images from a 3D density map. More...
 
int integer_interpolation (int integer_factor)
 
int integer_interpolation (int integer_factor, int odd)
 Interpolates by an integer scale with a density-preserving overlapping kernel. More...
 
int bin (long b)
 
int bin (Vector3< long > bk)
 Bins by an integer size in place. More...
 
Bimagebin_copy (long b)
 
Bimagebin_copy (Vector3< long > bk)
 Bins by an integer size and returns a new image. More...
 
Bimagebin_around_origin (int bin)
 Bins by an integer size making sure the origin falls on a binned voxel, and returns a new image. More...
 
int median_bin (int binning)
 Bins by an integer size, selecting the kernel median. More...
 
int noise_uniform (double rmin, double rmax)
 Generates an image with a uniform random distribution of densities. More...
 
int noise_gaussian (double ravg=0, double rstd=1)
 Generates an image with a gaussian random distribution of densities. More...
 
int noise_poisson (double ravg)
 Generates an image with a poisson random distribution of densities. More...
 
int noise_logistical (double ravg, double rstd)
 Generates an image with a gaussian random distribution of densities. More...
 
int noise_spectral (double alpha)
 Generates a noise map with a defined spectral decay. More...
 
int noise_uniform_distance (long number)
 Generates an image based on a uniform random distribution of distances. More...
 
int noise_gaussian_distance (long number, double stdev)
 Generates an image based on a gaussian random distribution of distances. More...
 
long mask (Bimage *pmask, double fill)
 Masks an image. More...
 
long to_mask ()
 
long to_mask (double threshold)
 Change the image to a mask. More...
 
Bimagemask_by_threshold (double threshold)
 Generates a mask based on an image at a given threshold. More...
 
Bimagemask_by_thresholds (vector< double > threshold)
 Generates a mask based on an image at given thresholds. More...
 
Bimagemask_by_conditional_thresholds (vector< double > threshold)
 Generates a mask based on a conditional hierarchy of thresholds. More...
 
long mask_stats ()
 Calculates statistics for a mask. More...
 
long mask_invert ()
 Inverts a mask. More...
 
long mask_combine (Bimage *p, int operation)
 Combines two masks with different operations. More...
 
Bimagemask_extract (Bimage *pmask)
 Zeroes everything outside the mask and return the excised feature. More...
 
int max_in_kernel (long ksize)
 
long mask_dilate_erode (unsigned char dir)
 Dilates or erodes a binary mask. More...
 
long mask_dilate (long times=1)
 Dilates a binary mask. More...
 
long mask_erode (long times=1)
 Erodes a binary mask. More...
 
long mask_open (int times=1)
 Opens a binary mask. More...
 
long mask_close (int times=1)
 Closes a binary mask. More...
 
long mask_fill (Vector3< long > voxel)
 Fills an empty part of a mask indicated by the given voxel. More...
 
long mask_shell (Vector3< double > origin, double rad_min, double rad_max)
 
long mask_shell_wrap (Vector3< double > origin, double rad_min, double rad_max)
 
long mask_plane (Vector3< double > origin, Vector3< double > normal)
 Generates a mask on one side of a plane. More...
 
long mask_rectangle (double length, double width, double rect_angle, int wrap)
 Generates a mask along an axis within a 2D image. More...
 
long mask_symmetrize (Bsymmetry &sym)
 Symetrizes a mask. More...
 
Vector3< double > mask_fspace_resize (Vector3< long > nusize)
 Resizes a reciprocal space mask. More...
 
vector< double > fspace_default_bands (double res_lo, double res_hi)
 Sets up default frequency space bands to generate a mask. More...
 
int mask_fspace_banded (vector< double > &band)
 Generate reciprocal space mask based on a specification of bands. More...
 
long mask_missing_wedge (Vector3< double > origin, double tilt_axis, double tilt_neg, double tilt_pos, double resolution)
 Generates a mask with a missing wedge. More...
 
long mask_missing_pyramid (Vector3< double > origin, double tilt_axis1, double tilt_axis2, double tilt_neg1, double tilt_pos1, double tilt_neg2, double tilt_pos2, double resolution)
 Generates a mask with a missing pyramid. More...
 
long mask_missing_cone (Vector3< double > origin, double mis_ang, double resolution)
 Generates a mask with a missing cone. More...
 
long mask_missing_find (Vector3< double > ori, double resolution, Bstring &mis_type)
 Generates a missing mask from an example image. More...
 
long mask_pack_plane (Matrix3 mat, double hi_res, double scale)
 Packs a 2D mask into a 3D reciprocal space volume.
More...
 
double variance_threshold (double lowvar)
 Calculates a threshold for a local variance image. More...
 
Bimagevariance_mask (long kernel_size, double lowvar=1e-6, int bkg_flag=0)
 Calculates a mask based on local variance. More...
 
Bimagetile_mask (long step)
 Converts a mask to a tiled multilevel mask. More...
 
long mask_split (long voxels_per_level)
 Converts a mask to a multilevel mask with a given number of voxels per level. More...
 
long levelmask_collapse ()
 Collapse a multi-level mask to a binary mask. More...
 
long levelmask_add (Bimage *pmask, int add_level=1)
 Adds a bilevel mask to a level mask. More...
 
long levelmask_dilate (int times)
 Dilates a level mask. More...
 
long levelmask_dilate ()
 Dilates a level mask. More...
 
long levelmask_select (Bstring &select_list, int flag=0)
 Retains the selected levels in a multi-level mask. More...
 
long levelmask_combine (Bstring &select_list)
 Combines the selected levels in a multi-level mask and renumber. More...
 
long levelmask_select (long nn, Vector3< long > voxel)
 Retains the selected levels in a multi-level mask. More...
 
long levelmask_select (Bimage *pmask)
 Selects regions overlapping a mask. More...
 
long levelmask_switch (long index1, long index2)
 Switches two segments in a multi-level mask. More...
 
int level_masked_stats (Bimage *pmask)
 Caclulates statistics for all the regions defined by a multi-level mask. More...
 
long levelmask_symmetrize (Bsymmetry &sym)
 Symetrizes a multi-level mask. More...
 
Bimagelevel_mask_extract (Bimage *pmask, int fill_type=0, double fill=0)
 Extracts all the regions associated with a multi-level mask. More...
 
double levelmask_average_region_size ()
 Calculates the average size of regions in a level mask. More...
 
long levelmask_clean ()
 Removes empty levels from a multi-level mask. More...
 
long levelmask_colorize ()
 Colorizes a multi-level mask with random color assignments. More...
 
Bimagelevelmask_color_by_size ()
 Color a multi-level mask based on the volumes of regions. More...
 
int levelmask_region_size ()
 Convert a mask to reflect region sizes. More...
 
Bplotlevelmask_size_histogram ()
 Color a multi-level mask based on the volumes of regions. More...
 
Matrix mask_interface_matrix (int img_num)
 Calculates the interfaces between regions. More...
 
long mask_region_interfaces (int reg_num)
 Reports the whole interface matrix or interfaces for one region only. More...
 
long mask_merge_delete (long min_size, long min_if)
 Calculates the interfaces between regions and deletes/merges small ones. More...
 
long apply_soft_mask (long nn, Bimage *pmask, int fill_type, double fill)
 Applies a soft mask to a sub-image. More...
 
Bimageregions (double threshold, int sign)
 Segments an image into contiguous regions. More...
 
long region_assign (Bimage *pmask, long idx, long region_number, double threshold, int sign)
 Finds all the pixels that are part of the same region. More...
 
int region_threshold_series (double threshold_first, double threshold_last, double threshold_step)
 Segments a map through a series of thresholds and reports results. More...
 
long region_flood (Bimage *pmask, double threshold_hi, double threshold_lo, double threshold_step, int fill_borders)
 Creates and expands a region map from a starting to ending threshold value. More...
 
long check_neighbors (long idx)
 Check neighbors in region map and assign a value if a neighbor is assigned. More...
 
Bimagetrack_gradient (double threshold, int flag=0)
 Generates a segmented image from peaks above a threshold value. More...
 
Bimageregion_peaks (long kernel_size, double threshold, int flood=0, int wrap=0)
 Generates a segmented image from peaks above a threshold value. More...
 
long blobs (double threshold, double min_size, double max_size, double setvalue, int sign)
 Identifies contiguous regions above a given threshold (blobs) and eliminate those less than a minimum size. More...
 
int filter_extremes ()
 Filters the extremes out of a micrograph image. More...
 
int filter_extremes (int mod_flag)
 Filters the extremes out of an image. More...
 
int filter_extremes (double tmin, double tmax, int kernel=3)
 Filters the extremes out of an image by replacing with adjacent averages. More...
 
long replace_maxima (double threshold)
 Replaces maxima above a threshold using local averages. More...
 
double mass_threshold (long img_num, double mol_weight, double rho)
 Finds the density threshold associated with a particular molecular weight. More...
 
double mass_at_threshold (long img_num, double threshold, double rho)
 Calculates the mass from the density threshold. More...
 
Bimageinternal_volume (double threshold)
 Calculates the internal volume of a shell. More...
 
Bimageinternal_volume (double threshold, int mask_out_freq)
 Calculates the internal volume of a shell. More...
 
Bimagekmeans_segment (long nregion=2, long max_iter=10, double ratio=1)
 Segments an image based on K-means. More...
 
GSgraph graph_setup (int connect_type)
 Initializing voxels and edges for graph-based segmentation. More...
 
GSgraph graph_segment (int type=1, int connect_type=0, double complexity=0, long min_size=0)
 Graph-based segmentation of an image. More...
 
Bimagegraph_segments_to_image (GSgraph &g)
 Converting a graph-based segmentation to an image. More...
 
Bimagegraph_segments_to_mask (GSgraph &g)
 Converting a graph-based segmentation to a multi-level mask. More...
 
int superpixels_update (Bimage *pmask, vector< long > vstep, double colorweight, vector< Bsuperpixel > &seg)
 
vector< Bsuperpixelsuperpixels_from_mask (long cc, long step)
 Create superpixels from a multilevel mask. More...
 
vector< Bsuperpixelsuperpixels (long step, double colorweight=0.2, long iterations=10, double stop=1)
 Segment the image into superpixels. More...
 
vector< Bsuperpixelsuperpixels (long step, double colorweight=0.2, long iterations=10, long bin_levels=1, double stop=1)
 
int impose_superpixels (Bimage *pmask, vector< Bsuperpixel > &seg, int impose)
 Impose superpixel features onto an image. More...
 

Public Attributes

Bimagenext
 
Bsub_imageimage
 

Detailed Description

General image parameter class.

All floating point coordinates are in angstroms and converted 
using the voxel units parameters.

Constructor & Destructor Documentation

◆ Bimage() [1/9]

Bimage::Bimage ( )

Initializes an image.

The internal initialization function is called.

◆ Bimage() [2/9]

Bimage::Bimage ( const Bimage p)

The copy constructor.

The internal copy function is called.

◆ Bimage() [3/9]

Bimage::Bimage ( Bstring fn,
int  readdata,
int  img_select 
)

Reads an image from a file.

The internal initialization function is called.

◆ Bimage() [4/9]

Bimage::Bimage ( DataType  type,
CompoundType  ctype,
long  nx,
long  ny,
long  nz,
long  nn 
)

Initializes an image.

Parameters
typedata type.
ctypecompound type.
nxx dimension.
nyy dimension.
nzz dimension.
nnnumber of sub-images.
The internal initialization function is called.
The basic properties and size is set up and the data allocated.

◆ Bimage() [5/9]

Bimage::Bimage ( DataType  type,
CompoundType  ctype,
Vector3< long >  size,
long  nn 
)

Initializes an image.

Parameters
typedata type.
ctypecompound type.
sizeimage size.
nnnumber of sub-images.
The internal initialization function is called.
The basic properties and size is set up and the data allocated.

◆ Bimage() [6/9]

Bimage::Bimage ( DataType  type,
CompoundType  ctype,
vector< long >  size,
long  nn 
)

Initializes an image.

Parameters
typedata type.
ctypecompound type.
sizeimage size.
nnnumber of sub-images.

The internal initialization function is called. The basic properties and size is set up and the data allocated.

◆ Bimage() [7/9]

Bimage::Bimage ( DataType  type,
long  nc,
long  nx,
long  ny,
long  nz,
long  nn 
)

Initializes a generic multi-channel image.

Parameters
typedata type.
ncnumber of channels.
nxx dimension.
nyy dimension.
nzz dimension.
nnnumber of sub-images.
The internal initialization function is called.
The basic properties and size is set up and the data allocated.

◆ Bimage() [8/9]

Bimage::Bimage ( DataType  type,
long  nc,
Vector3< long >  size,
long  nn 
)

Initializes a generic multi-channel image.

Parameters
typedata type.
ncnumber of channels.
sizeimage size.
nnnumber of sub-images.
The internal initialization function is called.
The basic properties and size is set up and the data allocated.

◆ Bimage() [9/9]

Bimage::Bimage ( Matrix mat,
long  scale 
)

Initializes an image from a 2D matrix.

Parameters
matmatrix.
scaleinteger scale for enlarging the image.
The internal initialization function is called.
The basic properties and size is set up and the data allocated.
The matrix contents are transferred with dimension scaling.

◆ ~Bimage()

Bimage::~Bimage ( )

Image destructor.

All properties and associated data are deallocated.

Member Function Documentation

◆ absolute()

void Bimage::absolute ( )

Converts to absolute values.

◆ add() [1/8]

void Bimage::add ( Bimage p)

Adds another image to an image.

Parameters
*pimage to be added.
Requirement: The images must have the same size.

◆ add() [2/8]

void Bimage::add ( Bimage p,
double  scale,
double  shift 
)

Adds another image to an image.

Parameters
*pimage to be added.
scaledensity scale to other image
shiftdensity shift to other image.
Requirement: The images must have the same size.

◆ add() [3/8]

void Bimage::add ( double  v)

Adds a constant value to an image.

Parameters
vconstant to be added.

◆ add() [4/8]

void Bimage::add ( double  xx,
double  yy,
double  zz,
long  nn,
double  v 
)

Adds a value at a given location to neigboring data elements.

Parameters
xxx location.
yyy location.
zzz location.
nnimage number (4 th dimension).
vvalue to add.
Inverse of trilinear interpolation.

◆ add() [5/8]

void Bimage::add ( long  j,
Complex< double >  cv 
)
inline

◆ add() [6/8]

void Bimage::add ( long  j,
double  v 
)
inline

◆ add() [7/8]

void Bimage::add ( long  nn,
Bimage p 
)

Adds another image to a sub-image.

Parameters
nnsub-image.
*pimage to be added.
Requirement: The images must have the same size.
If the FOM block is defined, it is used to accumulate a sum of:
    the FOM block of the added image if it exists,
    or otherwise the square of the data added.

◆ add() [8/8]

void Bimage::add ( long  nn,
Bimage p,
double  scale,
double  shift 
)

Adds another image to an image.

Parameters
nnsub-image.
*pimage to be added.
scaledensity scale to other image
shiftdensity shift to other image.
Requirement: The images must have the same size.

◆ align()

vector< Vector3< double > > Bimage::align ( long  ref_num,
long  window,
long  step,
Bimage pmask,
double  hi_res,
double  lo_res,
double  shift_limit,
double  edge_width,
double  gauss_width,
Vector3< long >  aln_bin,
int  mode = 0 
)

Aligns and sums a set of sub-images, first progressively and then iteratively.

Parameters
ref_numreference sub-image.
windowmoving sum window.
stepmoving sum interval.
*pmaskcross-correlation mask.
hi_reshigh resolution limit.
lo_reslow resolution limit.
shift_limitlimit on extent of search for shift.
edge_widthwidth of smoothing edge.
gauss_widthdecay coefficient for smoothing edge.
aln_bin3-value vector indicating binning level.
modeflag to select initial alignment: 0=progressive, 1=local.
Returns
vector<Vector3<double>> vector of shifts.
The images are first aligned using a progressive algorith starting with 
the indicated reference image.
The images are then aligned iteratively using the average image to 
improve the average.
The image is extensively modified and should not be used for further processing.

◆ align2D() [1/2]

double Bimage::align2D ( Bimage pref,
double  res_polar,
int  ann_min,
int  ann_max,
Bimage prs_mask,
double  shift_limit,
double  angle_limit,
fft_plan  planf_1D,
fft_plan  planb_1D,
fft_plan  planf_2D,
fft_plan  planb_2D 
)

Finds the best in-plane alignment for two 2D images using polar power spectra.

Parameters
*prefreference 2D image.
res_polarpolar resolution limit.
ann_minminimum annulus (>=0).
ann_maxmaximum annulus (< image radius).
*prs_maskdual mask.
shift_limitmaximum shift from nominal origin of box.
angle_limitmaximum rotation from original in-plane rotation angle.
planf_1DFFT forward plan for polar images.
planb_1DFFT backward plan for polar images.
planf_2DFFT forward plan for 2D images.
planb_2DFFT backward plan for 2D images.
Returns
double correlation coefficient.
Both the image and reference is converted to polar images using the 
current origins. The annuli of the polar images are cross-correlated
to find the rotation angle. The reference is rotated and cross-correlated
with the image to determine a new origin for the image. This is iterated
untill the rotation angle and origin of the image does not change any more,
or a maximum number of iterations.
The cross-correlation is done with the provided mask..
The correlation coefficient return is the cross-correlation peak.
The input images must be equal-sized square 2D images.

◆ align2D() [2/2]

int Bimage::align2D ( Bimage pref,
int  ann_min,
int  ann_max,
double  res_lo,
double  res_hi,
double  shift_limit,
double  angle_limit 
)

Finds the best in-plane alignment for two 2D images using polar power spectra.

Parameters
*prefreference 2D image.
ann_minminimum annulus (>=0).
ann_maxmaximum annulus (< image radius).
res_lolow resolution limit (angstrom).
res_hihigh resolution limit (angstrom).
shift_limitmaximum shift from nominal origin of box.
angle_limitmaximum rotation from original in-plane rotation angle.
Returns
double correlation coefficient.
This is a simplified interface to the other function Bimage::align2D.
All the fourier transform and rotation functions are handled internally.

◆ align2D_pps()

double Bimage::align2D_pps ( Bimage pref,
double  res_hi,
double  res_lo,
double  shift_limit,
double  angle_limit,
fft_plan  planf,
fft_plan  planb 
)

Finds the best in-plane alignment for two 2D images using polar power spectra.

Parameters
*prefreference 2D image.
res_hihigh resolution limit.
res_lolow resolution limit.
shift_limitmaximum shift from nominal origin of box.
angle_limitmaximum rotation from original in-plane rotation angle.
planfFFT forward plan.
planbFFT backward plan.
Returns
double correlation coefficient.
The rotation angle is found by cross-correlating the annuli
of the polar transforms of the power spectra of the image and the
reference image. If the full asu flag is not set, the annular cross-correlation
is done both forwards and backwards to detect mirror images, with the sign 
of the angle indicating which direction is best (>0 => forwards, <0 => backwards).
The resolution limit specified in the image is used to low-pass filter 
the cross-correlation. The shift is then determined by cross-correlation 
after rotating the reference image, as well as its 180° rotation to deal with
that ambiguity in the power spectrum.
The correlation coefficient return is the cross-correlation peak.
The input images must be equal-sized square 2D images.
The origin and rotation angle is returned in the image structure.

◆ align_fast()

JSvalue Bimage::align_fast ( long  ref_num,
Bimage pmask,
double  hi_res,
double  lo_res,
double  shift_limit,
double  edge_width,
double  gauss_width 
)

Aligns and sums a set of sub-images, first progressively and then iteratively.

Parameters
ref_numreference sub-image.
*pmaskcross-correlation mask.
hi_reshigh resolution limit.
lo_reslow resolution limit.
shift_limitlimit on extent of search for shift.
edge_widthwidth of smoothing edge.
gauss_widthdecay coefficient for smoothing edge.
Returns
double average shift.
The images are first aligned using a progressive algorith starting with 
the indicated reference image.
The images are then aligned iteratively using the average image to 
improve the average.

◆ align_local()

Bimage * Bimage::align_local ( long  nref,
Bimage pmask,
double  hi_res,
double  lo_res,
double  shift_limit,
fft_plan  planf,
fft_plan  planb 
)

Aligns and sums a set of sub-images using a progressive algorithm.

Parameters
nrefreference sub-image.
*pmaskcross-correlation mask.
hi_reshigh resolution limit.
lo_reslow resolution limit.
shift_limitlimit on extent of search for shift.
planfplan for forward Fourier transform.
planbplan for backward Fourier transform.
Returns
Bimage* summed reference image.
The images are aligned against the reference images with progressive
addition to reference to decrease noise.

◆ align_progressive()

Bimage * Bimage::align_progressive ( long  nref,
Bimage pmask,
double  hi_res,
double  lo_res,
double  shift_limit,
fft_plan  planf,
fft_plan  planb 
)

Aligns and sums a set of sub-images using a progressive algorithm.

Parameters
nrefreference sub-image.
*pmaskcross-correlation mask.
hi_reshigh resolution limit.
lo_reslow resolution limit.
shift_limitlimit on extent of search for shift.
planfplan for forward Fourier transform.
planbplan for backward Fourier transform.
Returns
Bimage* summed reference image.
The images are aligned against the reference images with progressive
addition to reference to decrease noise.

◆ align_progressive_fast()

Bimage * Bimage::align_progressive_fast ( long  nref,
double  shift_limit 
)

Aligns and sums a set of sub-images using a progressive algorithm.

Parameters
nrefreference sub-image.
shift_limitlimit on extent of search for shift.
Returns
Bimage* summed reference image.
The images are aligned against the reference images with progressive
addition to reference to decrease noise.

◆ alloc_size()

long Bimage::alloc_size ( ) const
inline

◆ aniso_average()

Bimage * Bimage::aniso_average ( long  ksize,
double  w 
)

Calculates an anisotropic average within a kernel based on the local gradient.

Parameters
ksizekernel radius.
wgradient weight (0 reverts to isotropic).
Returns
Bimage* new image.

◆ apply_soft_mask()

long Bimage::apply_soft_mask ( long  nn,
Bimage pmask,
int  fill_type,
double  fill 
)

Applies a soft mask to a sub-image.

Parameters
nnsub-image.
pmasksoft mask: [0,1].
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue of edge voxels.
Returns
int 0.
The image is multiplied with the mask, filling in the remainder 
with the fill value.
Requirement: The mask must range from 0 to 1.

◆ arccosine()

void Bimage::arccosine ( )

Calculates the arccosine of an image.

The values are truncated to be within [-1,1].

◆ arcsine()

void Bimage::arcsine ( )

Calculates the arcsine of an image.

The values are truncated to be within [-1,1].

◆ arctangent() [1/2]

void Bimage::arctangent ( )

Calculates the arctangent of an image.

The values are truncated to be within [-1,1].

◆ arctangent() [2/2]

void Bimage::arctangent ( Bimage p)

Calculates the inverse tangent from two images.

Parameters
*pdenominator (x) image.

◆ assemble_tiles()

int Bimage::assemble_tiles ( Bimage pt,
int  flag = 0 
)

Assembles overlapping tiles into this image.

Parameters
*ptmulti-image containing tiles.
flagflag to set overlap handling.
Returns
int 0.
The origin in each tile specifies the starting location.
Where tiles overlap, the integration is determined by the flag:
0 = simple addition with averaging afterwards.
1 = a gradual transition from one tile to the other.
2 = place just the central part of each tile.
The original data in the image is overwritten.

◆ auto_correlate()

int Bimage::auto_correlate ( double  hires,
double  lores 
)

Calculates an autocorrelation map by Fast Fourier transformation.

Parameters
hireshigh resolution limit.
loreslow resolution limit.
Returns
int 0.
FFTW library (www.fftw.org).
A multi-image 1D, 2D and 3D data set is transformed forward, the 
transform multiplied by its complex conjugate, followed by backward 
transformation and rescaling by 1/(N*N). Data beyond the resolution 
set in the image structure are zeroed. Therefore the correct setting 
of units and resolution in the image are required. Defaults for the 
units are usually 1 Angstrom/voxel and a zero resolution would
include the whole image (i.e., no resolution limitation).
The resultant image is Float.

◆ average() [1/3]

double Bimage::average ( )
inline

◆ average() [2/3]

void Bimage::average ( double  d)
inline

◆ average() [3/3]

double Bimage::average ( long  cc,
double  xf,
double  yf,
double  zf,
long  nn,
double  iscale 
)

Averages in 3D when scaling is less than 1.

Parameters
ccchannel.
xfx location.
yfy location.
zfz location.
nnimage number.
iscaleinverse scale.
Returns
double average.
All neighboring voxels in x, y and z are averaged and result returned.

◆ average2D()

double Bimage::average2D ( long  cc,
double  xf,
double  yf,
double  zf,
long  nn,
double  iscale 
)

Averages in the xy plane when scaling is less than 1.

Parameters
ccchannel.
xfx location.
yfy location.
zfz location.
nnimage number.
iscaleinverse scale.
Returns
double average.
All neighboring voxels in x and y are averaged and result returned.

◆ average_images() [1/2]

void Bimage::average_images ( )
inline

◆ average_images() [2/2]

Bimage * Bimage::average_images ( bool  sd)

Averages all sub-images and optionally calculates standard deviation image.

Parameters
sdflag to calculate linked standard deviation image.
Returns
Bimage* average image.

◆ average_line()

double Bimage::average_line ( long  xx,
long  yy,
long  zz,
long  nn,
long  len,
int  dir 
)

◆ average_phase_difference()

double Bimage::average_phase_difference ( Bimage p,
double  res_hi,
double  res_lo,
int  weighting = 1 
)

Calculates the average of the absolute phase difference between two images within given resolution shells.

Parameters
*preal space reference image.
res_hiupper resolution limit.
res_lolower resolution limit.
weightingweighting type: 0, none; 1, p1-amp; 2, p2-amp; 3, both amps
Returns
double average of the cosine of the phase difference.
Both images are Fourier transformed and the absolute phase
difference calculated and averaged.

◆ back_project()

int Bimage::back_project ( Bimage p,
double  resolution,
double  axis,
fft_plan  planf,
fft_plan  planb 
)

◆ background() [1/3]

void Bimage::background ( double  bkg)
inline

◆ background() [2/3]

double Bimage::background ( long  nn)
inline

◆ background() [3/3]

void Bimage::background ( long  nn,
double  bkg 
)
inline

◆ bar() [1/2]

int Bimage::bar ( long  nn,
Vector3< double >  start,
Vector3< double >  end,
double  width,
double  edge_width,
int  fill_type = 0,
double  fill = 0 
)

Generates a bar between start and end points.

Parameters
nnsub-image.
startstart of bar.
endend of bar.
widthwidth of bar.
edge_widthbar edge width.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
A bar is generated with the given fill value from the start point
to the end point and with a defined width and gaussian edge.

◆ bar() [2/2]

int Bimage::bar ( Vector3< double >  start,
Vector3< double >  end,
double  width,
double  edge_width,
int  fill_type = 0,
double  fill = 0 
)

Generates a bar between start and end points.

Parameters
startstart of bar.
endend of bar.
widthwidth of bar.
edge_widthbar edge width.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
A bar is generated with the given fill value from the start point
to the end point and with a defined width and gaussian edge.

◆ bin() [1/2]

int Bimage::bin ( long  b)
inline

◆ bin() [2/2]

int Bimage::bin ( Vector3< long >  bk)

Bins by an integer size in place.

Parameters
bk3-value vector of integer bin factors.
Returns
int 0.
An image is binned by an integer size.

◆ bin_around_origin()

Bimage * Bimage::bin_around_origin ( int  bin)

Bins by an integer size making sure the origin falls on a binned voxel, and returns a new image.

Parameters
bininteger bin factor.
Returns
Bimage* new image.
An image is binned by an integer size, square in 2D and cubic in 3D.

◆ bin_copy() [1/2]

Bimage * Bimage::bin_copy ( long  b)
inline

◆ bin_copy() [2/2]

Bimage * Bimage::bin_copy ( Vector3< long >  bk)

Bins by an integer size and returns a new image.

Parameters
bk3-value vector of integer bin factors.
Returns
Bimage* new image.
An image is binned by an integer size.

◆ blend()

Bimage * Bimage::blend ( Bimage p,
long  number 
)

Blends the two images, creating a new set of sub-images.

Parameters
*psecond image.
numbernumber of images in the series.
Returns
Bimage* new image structure, NULL if error.
A number of images are created by blending the two input images in
different ratios. The input images become the first and last sub-images of 
the new image structure, with the intermediate images changing over from
the first to the last:
        new_data = (1-fraction)*data1 + fraction*data2
where fraction = index/(number - 1)
At least 3 new sub-images are packed into the new image. 
All of the header information in the first image is copied into the new image.
Both images are converted to floating point.

◆ blobs()

long Bimage::blobs ( double  threshold,
double  min_size,
double  max_size,
double  setvalue,
int  sign 
)

Identifies contiguous regions above a given threshold (blobs) and eliminate those less than a minimum size.

Parameters
thresholdthreshold to define contiguous regions.
min_sizeminimum number of voxels to keep a region.
max_sizemaximum number of voxels to keep a region.
setvaluevalue to assign to deleted regions (typically set to threshold).
signsign controlling direction of thresholding.
Returns
long number of voxels set to threshold.
All contiguous regions in an image are indexed and their sizes 
calculated. Whether a region is contiguous is defined by a
threshold. Regions smaller than a minimum number of voxels are
set to the threshold value. The input image is modified and
left as a floating point image.

◆ calculate_background() [1/4]

int Bimage::calculate_background ( Bimage pmask,
int  flag = 0 
)

Calculates the background for each sub-image.

Parameters
*pmaskforeground mask.
flagflag to specify where to calculate the background: [0,1]
Returns
int 0, <0 on error.
If the mask is specified, it is used to define the part of the 
image to be used for background calculation (where the mask is zero).

◆ calculate_background() [2/4]

int Bimage::calculate_background ( Bimage pmask,
long  nn,
int  flag = 0 
)

Calculates the background for one sub-image.

Parameters
*pmaskforeground mask.
nnsub-image.
flagflag to specify where to calculate the background: [0,1]
Returns
int 0, <0 on error.
If the mask is specified, it is used to define the part of the 
image to be used for background calculation (where the mask is zero).

◆ calculate_background() [3/4]

int Bimage::calculate_background ( int  flag = 0)

Calculates the background for each sub-image.

Parameters
flagflag to specify where to calculate the background: [0,3]
Returns
int 0, <0 on error.
The background is taken as the average of the values outside the
circle or sphere enclosed by the image.

◆ calculate_background() [4/4]

int Bimage::calculate_background ( long  nn,
int  flag 
)

Calculates the background for one sub-image.

Parameters
nnsub-image.
flagflag to specify where to calculate the background: [0,3]
Returns
int 0, <0 on error.
The background is taken as the average of the values for:
flag=0,1    outside the circle or sphere enclosed by the image
flag=2      inside the circle or sphere enclosed by the image
flag=3      inside the half-radius circle in the center of the image.

◆ cartesian_to_cylindrical()

Bimage * Bimage::cartesian_to_cylindrical ( long  nannuli,
long  nphi,
int  flag = 0 
)

Calculates an image with cylindrical coordinates.

Parameters
nannulinumber of annuli.
nphinumber of phi angles.
flagswitch: annulus-angle-z (0), angle-annulus-z (1), z-annulus-angle (2)
Returns
Bimage* cylindrical image.
The image is converted to cylindrical form with a specified number of 
annuli and angles. 
A point vector p = {x,y,z} with respect to the image origin (typically
the center of the image) is converted to cylindrical coordinates as follows:
    The distance from the z-origin gives the annulus:
        |p| = sqrt(x*x+y*y)
    Phi is the rotation angle around the z-axis, starting at the x-axis:
        phi = atan(y/x)
    The z-coordinate remains unchanged.
The new dimensions are mapped as follows with their maximum ranges:
    |p|   ===> x_dimension (0 - max(x_size,y_size,z_size)
    phi   ===> y_dimension (0 - 2*PI)
    z     ===> z_dimension
The sampling within these ranges are given by the calling function.
The sampling must be isotropic.
The origins within the sub-image structures are used.
The interpolation routine actually calculates the old cartesian 
coordinates for each set of cylindrical coordinates.

◆ cartesian_to_spherical()

Bimage * Bimage::cartesian_to_spherical ( long  nannuli,
long  nphi,
long  ntheta 
)

Calculates an image with spherical coordinates.

Parameters
nannulinumber of annuli.
nphinumber of phi angles.
nthetanumber of theta angles.
Returns
Bimage* spherical image.
The image is converted to polar form with a specified number of annuli
and angles in one (a 2D image) or two (a 3D map) directions. The 
angular convention is consistent with the Euler angles used for 3D
image processing. 
A point vector p = {x,y,z} with respect to the image origin (typically
the center of the image) is converted to polar coordinates as follows:
    The size of the vector gives the annulus:
        |p| = sqrt(x*x+y*y+z*z)
    Phi is the rotation angle around the z-axis, starting at the x-axis:
        phi = atan(y/x)
    Theta is the angle between the positive z-axis and the point vector:
        theta = acos(z/|p|)
The new dimensions are mapped as follows with their maximum ranges:
    |p|   ===> x_dimension (0 - max(x_size,y_size,z_size)
    phi   ===> y_dimension (0 - 2*PI)
    theta ===> z_dimension (0 - PI)
The sampling within these ranges are given by the calling function.
The sampling must be isotropic.
The origins within the sub-image structures are used.
The interpolation routine actually calculates the old cartesian 
coordinates for each set of spherical coordinates.

◆ catenate()

void Bimage::catenate ( long  m,
Bimage **  p 
)

Catenates an array of images of the same size into a multi-image structure.

Parameters
mnumber of images in the array.
**parray of images.
The images must all have the same dimensions.

◆ ccmap_confidence()

double Bimage::ccmap_confidence ( long  nn)

Calculates a confidence level to associate with a cross-correlation peak.

Author
Bernard Heymann and Xiange Zheng
Parameters
nnsub-image.
Returns
double P value.
The highest two peak maxima are found and used to calculate a
confidence level for the hypothesis that the second highest peak is
different from the first. The two maxima are found by a kernel search
which implicitly assumes that the values associated with a peak
monotonically decays with distance from the peak.
Fisher's z-transform is used to calculate the confidence level:
    P = erfc((zmax - zmax2)/(2*z_sigma))
where
    zmax, zmax2: z-transforms of the highest two peaks.
    z_sigma: standard deviation of the z-transform of the cc map.
The P value is returned

◆ center()

int Bimage::center ( int  fill_type = 0,
double  fill = 0 
)

Centers an image.

Parameters
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
int error code.

◆ center_wrap()

int Bimage::center_wrap ( )

Centers an image with wrapping.

Returns
int error code.

◆ central_section()

Bimage * Bimage::central_section ( Matrix3  mat,
double  resolution,
FSI_Kernel kernel,
double  wavelength = 0 
)

Calculates a central section of a 3D fourier transform.

Parameters
mat3x3 rotation or skewing matrix.
resolutionhigh resolution limit.
*kernelfrequency space interpolation kernel.
wavelengthfor Ewald sphere projection, default zero, ± for front or back curvature.
Returns
Bimage* new 2D central section.
The orientation of the central section is defined by a rotation matrix
and the interpolation is done with a reciprocal space kernel.
The rotation origin is obtained from the map origin.

◆ change_symmetry()

int Bimage::change_symmetry ( Bsymmetry symold,
Bsymmetry symnu,
double  radius,
double  z_slope 
)

Changes the symmetry order for cyclic and dihedral maps.

Parameters
*symoldoriginal symmetry.
*symnunew symmetry.
radiusradius in voxels of repeating units.
z_slopeslope along z to adjust radius.
Returns
int 0.
If the radius is zero, the change in symmetry is done with proportional
shifts that distorts the units in the map.
If the radius is positive, it is used to determine the radial shift for
each unit, giving much less distortion than the proportional shifts.
Variation of the radius of the specimen along z can be handled with
a non-zero z slope parameter.

◆ change_transform_size()

Vector3< double > Bimage::change_transform_size ( Vector3< long >  nusize)

Resizes a "standard" transform.

Parameters
nusizenew image size.
Returns
Vector3<double> scale.
A standard transform is resized by inserting or removing
rows or columns in the middle of the data set.

◆ change_type() [1/3]

void Bimage::change_type ( char *  string)

Get the data type from a string.

Parameters
*stringstring describing the data type.

◆ change_type() [2/3]

void Bimage::change_type ( char  letter)

Get the data type indicated by a single letter code.

Parameters
letterletter indicating data type.
This function is used in optional command-line arguments to indicate 
a new data type for an image.

◆ change_type() [3/3]

void Bimage::change_type ( DataType  nutype)

Change the data to the new type.

Parameters
nutypenew data type.

◆ channels() [1/2]

long Bimage::channels ( )
inline

◆ channels() [2/2]

void Bimage::channels ( long  cc)
inline

◆ channels_to_images()

int Bimage::channels_to_images ( )

◆ check()

void Bimage::check ( )

Checks an image for reasonable properties.

◆ check_compoundtype()

bool Bimage::check_compoundtype ( long  nc,
CompoundType  ct 
)

◆ check_if_same_image_size()

bool Bimage::check_if_same_image_size ( Bimage p)

Check if two images are the same size.

Parameters
*pimage to check.
Returns
bool 1 if yes, 0 if no.
The function returns the answer and leaves the calling function to 
deal with the result.

◆ check_if_same_size()

bool Bimage::check_if_same_size ( Bimage p)

Check if two images are the same size.

Parameters
*pimage to check.
Returns
bool 1 if yes, 0 if no.
The function returns the answer and leaves the calling function to 
deal with the result.

◆ check_neighbors()

long Bimage::check_neighbors ( long  idx)

Check neighbors in region map and assign a value if a neighbor is assigned.

Parameters
idxindex in multi-image.
Returns
long new value assigned.

◆ check_point_group()

double Bimage::check_point_group ( Bstring check_string)

Checks for the requested symmetries.

Parameters
&check_stringstring with requested point groups.
Returns
double symmetry correlation coefficient.
Requirement: The input map must be in standard orientation for the symmetry.
For each different symmetry operation, the map is rotated and compared by
real space correlation to the original. 

◆ check_resolution()

void Bimage::check_resolution ( double &  resolution)

Checks that the resolution falls within reasonable limits.

Parameters
&resolutionresolution (modified).
The resolution is set to between the real size and the sampling.

◆ check_sampling()

void Bimage::check_sampling ( )

Checks that the sampling is properly specified.

If the sampling is zero or less it is set to 1.
If a dimension size is one, the sampling is set to 1.

◆ chirp()

int Bimage::chirp ( double  freq_scale,
double  freq_shift = 0 
)

Generates a chirp image.

Parameters
freq_scalefrequency scale.
freq_shiftfrequency shift (radians).
Returns
int 0.

◆ clear()

void Bimage::clear ( )
inline

◆ cmyk()

CMYK< double > Bimage::cmyk ( long  j)

Returns a color value at the given index.

Parameters
jindex.
Returns
CMYK<double> the color value.
The index refers to compound values.

◆ cmyk_to_rgb()

void Bimage::cmyk_to_rgb ( )

Converts a CMYK color image to RGB.

◆ color_blue()

int Bimage::color_blue ( double  cmin,
double  cmax,
int  flag = 0 
)

Converts a gray-scale image to blue.

Parameters
cminlower grayscale boundary.
cmaxupper grayscale boundary.
flagsets the type of conversion
Returns
int 0.
A grayscale image is converted to blue between the given minimum and maximum.

◆ color_combine()

int Bimage::color_combine ( Bimage p)

Combines two colored images.

Parameters
*psecond image.
Returns
int 0.
Each pair of voxels is summed and the result truncated to 255.

◆ color_green()

int Bimage::color_green ( double  cmin,
double  cmax,
int  flag = 0 
)

Converts a gray-scale image to green.

Parameters
cminlower grayscale boundary.
cmaxupper grayscale boundary.
flagsets the type of conversion
Returns
int 0.
A grayscale image is converted to green between the given minimum and maximum.

◆ color_red()

int Bimage::color_red ( double  cmin,
double  cmax,
int  flag = 0 
)

Converts a gray-scale image to red.

Parameters
cminlower grayscale boundary.
cmaxupper grayscale boundary.
flagsets the type of conversion
Returns
int 0.
A grayscale image is converted to red between the given minimum and maximum.

◆ color_spectrum()

Bimage * Bimage::color_spectrum ( double  cmin,
double  cmax 
)

Colorizes an image to a spectrum.

Parameters
cminlower grayscale boundary.
cmaxupper grayscale boundary.
Returns
Bimage* color scale image.
A grayscale image is converted to RGB and colored from blue (low) to 
red (high). Only the values between the given minimum and maximum is used.

◆ color_to_simple()

void Bimage::color_to_simple ( )

A color image is converted to a simple image.

The new value for each voxel is the average of the RGB color values.

◆ combine_channels()

void Bimage::combine_channels ( long  nc,
CompoundType  ct = TSimple 
)

Combines images as channels.

Parameters
ncnumber of channels to create.
ctcompound type.
The input image is replaced with a new image.
If the compound type is single value, the compound type
is inferred from the number of channels.

◆ combine_ewald()

int Bimage::combine_ewald ( )

◆ combined_complex_product() [1/3]

int Bimage::combined_complex_product ( )

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function Bimage::pack_two_in_complex and then
    transformed with the function Bimage::fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms, yielding 
the correlation coefficient when the product is backtransformed into 
the cross-correlation map.

◆ combined_complex_product() [2/3]

int Bimage::combined_complex_product ( Bimage pmask)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function Bimage::pack_two_in_complex and then
    transformed with the function Bimage::fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms, yielding 
the correlation coefficient when the product is backtransformed into 
the cross-correlation map.

◆ combined_complex_product() [3/3]

int Bimage::combined_complex_product ( double  hires,
double  lores,
Bimage pmask = NULL 
)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
hireshigh resolution limit.
loreslow resolution limit.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function Bimage::pack_two_in_complex and then
    transformed with the function Bimage::fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms within
the resolution limits, yielding the correlation coefficient when
the product is backtransformed into the cross-correlation map.

◆ combined_complex_product_implicit_mask()

int Bimage::combined_complex_product_implicit_mask ( double  hires,
double  lores 
)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
hireshigh resolution limit.
loreslow resolution limit.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function Bimage::pack_two_in_complex and then
    transformed with the function Bimage::fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
An implicit mask is assumed: Only non-zero values in both transforms are considered.
The result is scaled by the total power of the two transforms within
the resolution limits, yielding the correlation coefficient when
the product is backtransformed into the cross-correlation map.

◆ combined_phase_product()

int Bimage::combined_phase_product ( double  hires,
double  lores,
Bimage pmask = NULL 
)

Calculates the phase product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
hireshigh resolution limit.
loreslow resolution limit.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function Bimage::pack_two_in_complex and then
    transformed with the function Bimage::fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the
phase product .
The result is scaled by the size, yielding the phase the correlation coefficient when
the product is backtransformed into the phasecorrelation map.

◆ compatible()

bool Bimage::compatible ( Bimage p)

Check if this image has the same number of channels and data type as another.

Parameters
*preference image.
Returns
bool 1 if yes, 0 if no.
The function returns the answer and leaves the calling function to 
deal with the result.

◆ complex()

Complex< double > Bimage::complex ( long  j)

Returns a complex value at the given index.

Parameters
jindex.
Returns
Complex<double> the complex floating point value.
The index refers to compound values.

◆ complex_apply_dual_mask()

int Bimage::complex_apply_dual_mask ( Bimage pmask)

Applies a dual mask to a complex image.

Parameters
*pmaskmask (converted to floating point).
Returns
int error code.
The mask is applied to an image, generating two images, the first 
with values retained where the mask is positive, and the second with
values where the mask is negative.
The input image is replaced and the second is created and linked to
the first.
Requirement: The two input images must be the same size.
No statistics are calculated.

◆ complex_apply_mask()

int Bimage::complex_apply_mask ( Bimage pmask)

Applies a mask to a complex image.

Parameters
*pmaskmask (converted to floating point).
Returns
int error code.
Wherever the mask is <= 0, the data is set to zero.
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_apply_negative_mask()

int Bimage::complex_apply_negative_mask ( Bimage pmask)

Applies a negative mask to a complex image.

Parameters
*pmaskmask (converted to floating point).
Returns
int error code.
Wherever the mask is >= 0, the data is set to zero.
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_bandpass()

int Bimage::complex_bandpass ( double  hires,
double  lores 
)

Bandpasses a Fourier transform.

Parameters
hireshigh resolution limit.
loreslow resolution limit.
Returns
int error code.
Requirement: a complex Fourier transform.
All data outside the band limits are set to zero.

◆ complex_conjugate()

void Bimage::complex_conjugate ( )

Calculates the complex conjugate image.

◆ complex_conjugate_product()

int Bimage::complex_conjugate_product ( Bimage p,
int  norm = 0 
)

Calculates the product of a complex image with the conjugate of a second.

Parameters
*pcomplex image.
normnormalize.
Returns
int error code.
Complex conjugate product:
    (a + ib)*(c - id) = (a*c + b*d) + i(b*c - a*d).
Normalization is determined by the norm flag:
    1   square root of the power sum product of the two images
    2   the power sum of the first image
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_conjugate_product_one2many()

Bimage * Bimage::complex_conjugate_product_one2many ( Bimage p)

Calculates the product of a complex image with the conjugate of a second.

Parameters
*pcomplex image.
Returns
int error code.
Complex conjugate product:
    (a + ib)*(c - id) = (a*c + b*d) + i(b*c - a*d).
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_convert()

int Bimage::complex_convert ( ComplexConversion  conv)

Converts a complex image to a simple image.

Parameters
conva flag for converting the complex image.
Returns
int 0.

◆ complex_invert()

int Bimage::complex_invert ( )

Inverts a complex image.

Returns
int 0.
The image is scaled by the remaining total power, i.e., the sum of the intensities.

◆ complex_multiply()

int Bimage::complex_multiply ( Bimage p)

Calculates the product of a complex image with a simple image.

Parameters
*psimple image.
Returns
int error code.
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_normalize()

double Bimage::complex_normalize ( )

Normalizes the power in a complex image.

Returns
double power.
The first element is set to zero.
The image is scaled by the remaining total power, i.e., the sum of the intensities.

◆ complex_power()

double Bimage::complex_power ( )

Calculates the power in a complex image.

Returns
double power.
The first element is set to zero.
The image is scaled by the remaining total power, i.e., the sum of the intensities.

◆ complex_product()

int Bimage::complex_product ( Bimage p)

Calculates the complex product of two complex images.

Parameters
*pcomplex image.
Returns
int error code.
Complex product:
    (a + ib)*(c + id) = (a*c - b*d) + i(b*c + a*d).
Requirement: The two images must be the same size.
No statistics are calculated.

◆ complex_split()

Bimage * Bimage::complex_split ( )

A complex image is split into two simple images.

Returns
Bimage* new image with the imaginary part.
The imaginary part is written into the new image.
The complex image is replaced by its real part.

◆ complex_to_amplitudes()

void Bimage::complex_to_amplitudes ( )

The amplitudes from a complex image is written to a simple image.

◆ complex_to_imaginary()

void Bimage::complex_to_imaginary ( )

The imaginary part of a complex image is written to a simple image.

◆ complex_to_intensities()

void Bimage::complex_to_intensities ( )

The intensities from a complex image is written to a simple image.

◆ complex_to_phases()

void Bimage::complex_to_phases ( )

The phases from a complex image is written to a simple image.

◆ complex_to_real()

void Bimage::complex_to_real ( )

The real part of a complex image is written to a simple image.

◆ complex_to_signed_amplitudes()

void Bimage::complex_to_signed_amplitudes ( )

The signed amplitudes from a complex image is written to a simple image.

◆ compound_type() [1/2]

CompoundType Bimage::compound_type ( )
inline

◆ compound_type() [2/2]

long Bimage::compound_type ( CompoundType  ct)

◆ compound_type_size()

long Bimage::compound_type_size ( )
inline

◆ compound_type_string()

Bstring Bimage::compound_type_string ( )

Get the string representation of a datatype.

Returns
Bstring string representation of a datatype.

◆ convert_to_helix()

double Bimage::convert_to_helix ( double  helix_rise,
double  helix_angle,
Vector3< double >  offset 
)

Converts a map to a helix.

Parameters
helix_riserise per asymmetric unit
helix_anglerotation angle per asymmetric unit.
offsetoffset in the xy plane.
Returns
double 0.
The data is offset from the central axis based on helical parameters along the axis.
The data is rotated around the offset vector based on the helix rise 
and helix angle by an angle:
                  distance * (1 - cos(helix_angle))
    angle2 = atan ---------------------------------
                            helix_rise

◆ convolve()

int Bimage::convolve ( Bimage pkernel)

Convolves an image with an arbitrary size convolution filter.

Parameters
*pkernelkernel encoded as an image.
Returns
int 0, <0 on error.
The kernel is multiplied with each area surrounding the current voxel
with wrapping to avoid image edge effects.
The convolution is threaded if compiled with OpenMP.

◆ convolve_chunk()

int Bimage::convolve_chunk ( Bimage pkernel,
float *  nudata,
long  i,
long  len 
)

◆ coordinates() [1/4]

Vector3< long > Bimage::coordinates ( long  i)
inline

◆ coordinates() [2/4]

void Bimage::coordinates ( long  i,
long &  nc,
long &  nx,
long &  ny,
long &  nz,
long &  nn 
)
inline

◆ coordinates() [3/4]

void Bimage::coordinates ( long  i,
long &  nx,
long &  ny,
long &  nz 
)
inline

◆ coordinates() [4/4]

void Bimage::coordinates ( long  i,
long &  nx,
long &  ny,
long &  nz,
long &  nn 
)
inline

◆ copy() [1/2]

Bimage * Bimage::copy ( )

Copies the header information and data of an image into a new image structure.

Returns
Bimage* copied image, NULL if copy failed.

◆ copy() [2/2]

Bimage * Bimage::copy ( long  nu_nimg)

Copies the header information and data of an image into a new image structure.

Parameters
nu_nimgnew number of images (if < 1, keep the old number)
Returns
Bimage* copied image, NULL if copy failed.

◆ copy_header() [1/2]

Bimage * Bimage::copy_header ( )
inline

◆ copy_header() [2/2]

Bimage * Bimage::copy_header ( long  nu_nimg)

Copy an image structure into a new one.

Parameters
nu_nimgnew number of images (if < 1, keep the old number)
Returns
Bimage* the new image structure, NULL if copy failed.
All information from an old image structure is copied into a new one.
This takes care of the internal arrays in the structure.
The data pointer is left to point to the original data.

◆ correct_background() [1/3]

int Bimage::correct_background ( Bimage pmask,
int  flag = 0 
)

Corrects the background for each sub-image.

Parameters
*pmaskforeground mask.
flagflag to specify where to calculate the background: [0,3]
Returns
int 0.
The background is taken as the average of the values outside the
circle or sphere enclosed by the image.
If the mask is specified, it is used to define the foreground of the 
image. The correction then includes the area outside the circle or 
sphere as well as the area where the mask is zero.

◆ correct_background() [2/3]

int Bimage::correct_background ( int  flag = 0)

Corrects the background for each sub-image.

Parameters
flagflag to specify where to calculate the background: [0,1]
Returns
int 0, <0 on error.
The background is taken as the average of the values outside the
circle or sphere enclosed by the image.

◆ correct_background() [3/3]

int Bimage::correct_background ( long  nn,
int  flag 
)

Corrects the background for one sub-image.

Parameters
nnsub-image.
flagflag to specify where to calculate the background: [0,3]
Returns
int 0, <0 on error.
The background is taken as the average of the values outside the
circle or sphere enclosed by the image.

◆ correlate() [1/2]

double Bimage::correlate ( Bimage p)

Calculates correlation coefficient between two images.

Parameters
*pimage to correlate with.
Returns
double correlation coefficient, -1 if not run.
The correlation between two images is calculated and normalized as:
               sum((image1 - avg1)*(image2 - avg2))
    CC = -------------------------------------------------
         sqrt(sum(image1 - avg1)^2 * sum(image2 - avg2)^2)
.
Both images are converted to floating point.
Only the first image is used.

◆ correlate() [2/2]

double Bimage::correlate ( Bimage p,
double  rmin,
double  rmax,
Bimage pmask = NULL,
int  flag = 0 
)

Calculates a correlation coefficient between two images.

Parameters
*psecond image.
rminminimum radius (pixel units).
rmaxmaximum radius (pixel units).
*pmaskmask (can be NULL).
flagflag to modify second image.
Returns
double correlation coefficient, -1 if error.
The correlation between two images is calculated and normalized as:
             sum((image1 - avg1)*(image2 - avg2))
    CC = -------------------------------------------------
         sqrt(sum(image1 - avg1)^2 * sum(image2 - avg2)^2)

◆ correlate_annuli()

double Bimage::correlate_annuli ( Bimage polref,
int  ann_min,
int  ann_max,
double  ang_min,
double  ang_max,
fft_plan  planf,
fft_plan  planb,
double &  cc_max 
)

Correlate annuli of a polar image.

Parameters
*polrefreference image polar power spectrum transform.
ann_minlow resolution cutoff (in inverse pixels).
ann_maxhigh resolution cutoff (in inverse pixels).
ang_minminimum angle to test for (radians).
ang_maxmaximum angle to test for (radians).
planfFFT forward plan.
planbFFT backward plan.
&cc_maxpointer to correlation coefficient for return.
Returns
double angle.
The input images must be transformed polar images, with each annulus
corresponding to a row in the image.
The polar image annuli between the given limits are cross-correlated
one by one, and a sum of all annuli calculated, weighted by annulus index.
The maximum value in the annulus sum corresponds to the best fit angle.
Both image and mirror image are assessed, yielding a negative angle
when the mirror image gives a larger correlation.
FFTW library (www.fftw.org).

◆ correlation_coefficient()

double Bimage::correlation_coefficient ( Vector3< double >  shift)

Calculates a coefficient from a Fourier correlation transform given a shift.

Parameters
shiftreal space shift.
Returns
double correlation coefficient.
The input image is a cross-correlation transform.
A brute force backtransform integration is done for the given shift to 
calculate the corresponding correlation coefficient.

◆ cosine()

void Bimage::cosine ( )

Calculates the cosine of a phase image.

The values must be in radians.

◆ cross_correlate() [1/4]

Bimage * Bimage::cross_correlate ( Bimage p,
Bimage pmask = NULL 
)
inline

◆ cross_correlate() [2/4]

Bimage * Bimage::cross_correlate ( Bimage p,
double  hires,
double  lores,
Bimage pmask,
fft_plan  planf,
fft_plan  planb 
)

write_img("pccp.mrc", pc, 0);

◆ cross_correlate() [3/4]

Bimage * Bimage::cross_correlate ( Bimage p,
double  hires,
double  lores,
Bimage pmask = NULL 
)

Calculates a cross-correlation map by Fast Fourier transformation.

Parameters
*psecond image.
hireshigh resolution limit.
loreslow resolution limit.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are 
packed into a complex data set and transformed forward. The transform
is unpacked before the first transform is multiplied with the complex 
conjugate of the second transform. This is then back-transformed to 
obtain the cross-correlation map in real space.
The low resolution limit can be 0, in which case no limits are applied.
The resultant cross-correlation image data type is floating point.

◆ cross_correlate() [4/4]

Bimage * Bimage::cross_correlate ( Bimage p,
double  hires,
double  lores,
fft_plan  planf,
fft_plan  planb 
)

Calculates a cross-correlation map by Fast Fourier transformation.

Parameters
*psecond image.
hireshigh resolution limit.
loreslow resolution limit.
planfforward transform plan.
planbbackward transform plan.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are 
packed into a complex data set and transformed forward. The transform
is unpacked before the first transform is multiplied with the complex 
conjugate of the second transform. This is then back-transformed to 
obtain the cross-correlation map in real space.
Zero-valued data in the transforms are implicitly excluded.
The low resolution limit can be 0, in which case no limits are applied.
The resultant cross-correlation image data type is floating point.

◆ cross_correlate_fspace()

Bimage * Bimage::cross_correlate_fspace ( Bimage p,
double  hires,
double  lores,
double  shift_limit 
)

Calculates a cross-correlation map by Fast Fourier transformation.

Parameters
*psecond image.
hireshigh resolution limit.
loreslow resolution limit.
shift_limitmaximum real space shift.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are 
packed into a complex data set and transformed forward. The transform
is unpacked before the first transform is multiplied with the complex 
conjugate of the second transform. This is then back-transformed to 
obtain the cross-correlation map in real space.
The low resolution limit can be 0, in which case no limits are applied.
The resultant cross-correlation image data type is floating point.

◆ cross_correlate_two_way()

Bimage * Bimage::cross_correlate_two_way ( Bimage p,
double  hires,
double  lores,
fft_plan  planf,
fft_plan  planb 
)

Calculates a cross-correlation map by Fast Fourier transformation.

Parameters
*psecond image.
hireshigh resolution limit.
loreslow resolution limit.
planfFFT forward plan.
planbFFT backward plan.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are 
packed into a complex data set and transformed forward. The transform
is bandpass filtered to the given resolution limits and unpacked.
The two transforms are normalized, and multiplied in two ways:
    prod1 = data1 * data2.conjugate
    prod2 = data1 * data2
The second product represents a cross-correlation with a 180 degree 
rotation of the second image.
Both are back-transformed to obtain the two cross-correlation map in real space.
The one with the highest maximum is selected to return.
The resultant cross-correlation image data type is floating point.
The angle in the cross-correlation image is set to zero if the first
map is selected, otherwise it is set to PI.

◆ cross_correlate_validate()

Bimage * Bimage::cross_correlate_validate ( Bimage p,
Bimage pmask 
)

Calculates a masked cross-correlation map by Fast Fourier transformation.

Parameters
*psecond image.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are 
packed into a complex data set and transformed forward. The transform
is unpacked and masked with mask image before the first transform is
multiplied with the complex conjugate of the second transform. This is 
then back-transformed to obtain the cross-correlation map in real space.
The mask must be composed of 0 and 1, and is converted to floating point.
The mask can be omitted (NULL).
The resultant cross-correlation image data type is floating point.

◆ cylinder()

int Bimage::cylinder ( Vector3< double >  center,
double  radius,
double  height,
double  width,
int  fill_type = 0,
double  fill = 0,
bool  wrap = 0 
)

Fills a cylinder within an image with a uniform value.

Parameters
centerthree vector center of cylinder.
radiuscylinder radius.
heightcylinder heigth.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
wrapwrap around boundaries (default not).
Returns
int 0.
All voxels within a cylinder at a given location are set to a given fill value.
The height is along the z-direction.
The new data replaces the old data.
The default center is {0,0,0}.

◆ cylindrical_shells()

int Bimage::cylindrical_shells ( )

Calculates an image with slices representing cylindrical shell projections.

Returns
int 0.
The 3D image is converted so that the sections contain 2D projections
of cylindrical shells. The projection in slice i is defined for:
    i >= sqrt(x^2 + y^2)
The first projection is placed at the z origin and radiates out into
both positive and negative directions.
Sampling in x and y is not changed.
The sampling must be isotropic.

◆ data_alloc() [1/3]

unsigned char * Bimage::data_alloc ( )
inline

◆ data_alloc() [2/3]

unsigned char * Bimage::data_alloc ( DataType  type,
CompoundType  ctype,
long  nx,
long  ny,
long  nz,
long  nn 
)

Allocate image data with size parameters.

Parameters
typedata type.
ctypecompound type.
nxx dimension.
nyy dimension.
nzz dimension.
nnnumber of sub-images.
Returns
unsigned char* pointer to data.
The image parameters are set and a new data block allocated.

◆ data_alloc() [3/3]

unsigned char * Bimage::data_alloc ( long  nbytes)

Allocate image data.

Parameters
nbytesnumber of bytes to allocate.
Returns
unsigned char* pointer to data.
Any old data block is deleted.

◆ data_alloc_and_clear() [1/3]

unsigned char * Bimage::data_alloc_and_clear ( )
inline

◆ data_alloc_and_clear() [2/3]

unsigned char * Bimage::data_alloc_and_clear ( DataType  type,
CompoundType  ctype,
long  nx,
long  ny,
long  nz,
long  nn 
)
inline

◆ data_alloc_and_clear() [3/3]

unsigned char * Bimage::data_alloc_and_clear ( long  nbytes)
inline

◆ data_assign()

unsigned char * Bimage::data_assign ( unsigned char *  nudata)

Assign image data.

Parameters
*nudataallocated data pointer.
Returns
unsigned char* pointer to data.
Note: The size of the data block must correspond to the image dimensions!

◆ data_delete()

void Bimage::data_delete ( )

Deallocates the image data.

◆ data_offset() [1/2]

long Bimage::data_offset ( )
inline

◆ data_offset() [2/2]

void Bimage::data_offset ( long  doff)
inline

◆ data_pointer() [1/3]

unsigned char * Bimage::data_pointer ( )
inline

◆ data_pointer() [2/3]

unsigned char * Bimage::data_pointer ( long  offset)
inline

◆ data_pointer() [3/3]

void Bimage::data_pointer ( unsigned char *  ptr)
inline

◆ data_size()

long Bimage::data_size ( )
inline

◆ data_type() [1/2]

DataType Bimage::data_type ( )
inline

◆ data_type() [2/2]

void Bimage::data_type ( DataType  dt)
inline

◆ data_type_bits()

long Bimage::data_type_bits ( ) const

Returns the size of the datatype in bits.

Returns
long data type size in bits.
The Bit type returns 1.

◆ data_type_max()

double Bimage::data_type_max ( )

Get the maximum of a datatype.

Returns
double maximum value.
This function is used for returning the maximum value
a data type can hold.

◆ data_type_min()

double Bimage::data_type_min ( )

Get the minimum of a datatype.

Returns
double minimum value.
This function is used for returning the minimum value
a data type can hold.

◆ data_type_size()

long Bimage::data_type_size ( ) const

Returns the size of the datatype in bytes.

Returns
long data type size.
The Bit type returns 1.

◆ data_type_string()

Bstring Bimage::data_type_string ( )

Get the string representation of a datatype.

Returns
Bstring string representation of a datatype.

◆ default_origin()

Vector3< double > Bimage::default_origin ( )
inline

◆ defocus_scale()

Bimage * Bimage::defocus_scale ( long  nn,
double  df,
double  df2,
double  iCL2,
int  fill_type 
)

◆ delete_images()

long Bimage::delete_images ( Bstring  list,
int  retain = 0 
)

Retains or deletes sub-images from a multi-image structure.

Parameters
listlist of sub-images to retain or delete.
retain0=delete list, 1=retain list.
Returns
long error code (<0 means failure) or number of sub-images remaining.
Sub-images specified in a list are either retained or deleted.
The new data replaces the old data.

◆ density() [1/2]

double Bimage::density ( long  nn,
Vector3< double >  coord,
double  radius 
)
inline

◆ density() [2/2]

double Bimage::density ( long  nn,
Vector3< double >  coord,
double  radius,
double &  sigma 
)

Calculates the density in a sphere around a coordinate in an image.

Author
Daniel Nemecek and Bernard Heymann
Parameters
nnsub-image number.
coordposition of density in map (voxels).
radiusspherical radius.
sigmastandard deviation result.
Returns
double average density.
The density origin is positioned on the component.

◆ distort_elliptically()

int Bimage::distort_elliptically ( double  angle,
double  shift 
)

Transforms a tubular cylinder to an elliptical profile.

Parameters
angleangle of elliptical maximum.
shiftoutward shift at elliptical maximum radius.
Returns
int 0.
The density is shifted towards or away from the origin by a specific
amount and in a direction determined by an elliptical profile.

◆ divide()

void Bimage::divide ( Bimage p,
double  scale = 1,
double  shift = 0 
)

Divides the first image by the second.

Parameters
*pother image.
scaledensity scale to apply to other image
shiftdensity shift to apply to other image.
The image is divided by the other with exceptions:
    image /= other*scale + shift
Both images are converted to floating point.

◆ divide_one()

void Bimage::divide_one ( Bimage p,
double  scale = 1,
double  shift = 0 
)

Divides the first image by the first sub-image of the second.

Parameters
*pother image.
scaledensity scale to apply to other image
shiftdensity shift to apply to other image.
The image is divided by the other with exceptions:
    image /= other*scale + shift
Both images are converted to floating point.

◆ dyad_interpolate()

double Bimage::dyad_interpolate ( long  i,
int  norm_flag = 1 
)

◆ edge() [1/2]

int Bimage::edge ( int  type,
Vector3< long >  rect,
Vector3< double >  start,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Smooths the image edge with a soft rectangular function.

Parameters
typetype of edge: 0=rectangle, 1=oval, 2=cylinder
rectthree-value size of the area to be smoothed.
startthree-value start for smoothing.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue of edge voxels.
Returns
int 0.
The edge of the image is smoothed with a function:
                    v_old(x,y,z) + fill*exp(1.618*dist/width)
    v_new(x,y,z) = ------------------------------------------
                           1 + exp(1.618*dist/width)
where   fill is the desired edge value.
        dist is the distance to the rectangular boundary defined by 
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.
With negative width values, the area filled is outside the shape.

◆ edge() [2/2]

int Bimage::edge ( long  nn,
int  type,
Vector3< long >  rect,
Vector3< double >  start,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Smooths the image edge with a soft rectangular function.

Parameters
nnsub-image.
typetype of edge: 0=rectangle, 1=oval, 2=cylinder
rectthree-value size of the area to be smoothed.
startthree-value start for smoothing.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue of edge voxels.
Returns
int 0.
The edge of the image is smoothed with a function:
                    v_old(x,y,z) + fill*exp(1.618*dist/width)
    v_new(x,y,z) = ------------------------------------------
                           1 + exp(1.618*dist/width)
where   fill is the desired edge value.
        dist is the distance to the rectangular boundary defined by 
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.
With negative width values, the area filled is outside the shape.

◆ edge_mask()

Bimage * Bimage::edge_mask ( int  type,
Vector3< long >  rect,
Vector3< double >  start,
double  width 
)

Creates a mask with the edge approaching zero.

Parameters
typetype of edge: 0=rectangle, 1=oval, 2=cylinder
rectthree-value size of the area to be masked.
startthree-value start for mask.
widthgaussian width of smoothing function.
Returns
Bimage* new soft mask.
The edge of the image is smoothed with a function:
                                1
    v_new(x,y,z) =  -------------------------
                    1 + exp(1.618*dist/width)
where   dist is the distance to the boundary defined by 
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.
With negative width values, the area filled is outside the shape.

◆ enlarge()

int Bimage::enlarge ( Vector3< long >  scale)

Enlarges an image by an inetger scale.

Parameters
scalethree-value scale.
Returns
int 0.
An image is enlarged by integer amounts.
The new data replaces the old data.

◆ erase()

long Bimage::erase ( string  tag)
inline

◆ ewald_sphere()

int Bimage::ewald_sphere ( double  volt,
double  t 
)

Imposes an Ewald sphere weighting on a 3D frequency space volume.

Parameters
voltacceleration voltage (angstrom).
tthickness.
Returns
int 0.

◆ exponential()

void Bimage::exponential ( )

Calculates the exponential of the image data.

The image is first converted to floating point.
The new data replaces the old data.
Image statistics are recalculated.

◆ extract() [1/6]

Bimage * Bimage::extract ( long  n1,
long  n2 
)

Extracts a set of sub-images into new image structure.

Parameters
n1first sub-image to extract.
n2last sub-image to extract.
Returns
Bimage* the new image structure, NULL if copy failed.

◆ extract() [2/6]

Bimage * Bimage::extract ( long  nn)

Extracts one sub-image into new image structure.

Parameters
nnimage number to extract.
Returns
Bimage* the new image structure, NULL if copy failed.

◆ extract() [3/6]

Bimage * Bimage::extract ( long  nn,
Vector3< double >  loc,
Vector3< long >  size,
Vector3< double >  origin 
)
inline

◆ extract() [4/6]

Bimage * Bimage::extract ( long  nn,
Vector3< double >  loc,
Vector3< long >  size,
Vector3< double >  ori,
Matrix3  mat 
)

Extracts a region of one sub-image into new image structure.

Parameters
nnimage number to extract.
locextraction location.
sizeextraction size.
oriextraction origin.
matorientation matrix.
Returns
Bimage* the new image structure, NULL if copy failed.

◆ extract() [5/6]

Bimage * Bimage::extract ( long  nn,
Vector3< double >  loc,
Vector3< long >  size,
Vector3< double >  origin,
View  view 
)
inline

◆ extract() [6/6]

Bimage * Bimage::extract ( long  nn,
Vector3< long >  coords,
Vector3< long >  ext_size,
int  fill_type = 0,
double  fill = 0 
)

Extracts a region of one sub-image into new image structure.

Parameters
nnimage number to extract.
coordsextraction start.
ext_sizeextraction size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
Bimage* the new image structure, NULL if copy failed.

◆ extract_edge_difference()

Bimage * Bimage::extract_edge_difference ( )

Extracts all the edge pixels into a new image.

Returns
Bimage* edge image.

◆ extract_filament()

Bimage * Bimage::extract_filament ( long  img_num,
double  width,
int  axis,
long  nspline,
Vector3< double > *  spline 
)

Extracts a filament defined by a series of coordinates.

Parameters
img_numimage number from which to extract filament.
widthwidth of filament image to extract.
axishelical axis alignment: x=1, y=2, z=3.
nsplinenumber of coordinates in spline curve.
*splinespline curve.
Returns
Bimage* one filament image.
A single filament is extracted and returned.

◆ extract_line()

Bimage * Bimage::extract_line ( long  nn,
Vector3< double >  start,
Vector3< double >  end,
long  width 
)

Extracts a line from an image into a new image.

Parameters
nnimage number from which to extract.
start3-vector start of line.
end3-vector end of line.
widthwidth of integration perpendicular to line.
Returns
Bimage* extracted line image (1D).
The line values extracted are the interpolated values along the vector
defined by start and end coordinates..

◆ extract_magnify()

Bimage * Bimage::extract_magnify ( long  nn,
Vector3< long >  center,
Vector3< long >  ext_size,
double  scale 
)

Extracts a region from an image to magnify.

Parameters
nnimage number to extract.
centercenter of region to magnify.
ext_sizesize of region to magnify.
scaledimensional scaling.
Returns
Bimage* extracted slice for 2D and 3 slices for 3D.
Only the desired region is extracted from the original image and
resized based on the given scale argument.
The dynamic range is rescaled using the image display minimum and 
maximum:
    new_data = data*255/(max-min)
with truncation of the data below 0 and above 255.
Bit data are converted to 0 (black) and 255 (white).
RGB data are rescaled as for gray scale images.
Complex data types are converted to intensities.

◆ extract_shell()

Bimage * Bimage::extract_shell ( long  nn,
double  minrad,
double  maxrad 
)

Extracts a shell from an image into a new image.

Parameters
nnimage number from which to extract, -1 indicates all images.
minradminimum shell radius.
maxradmaximum shell radius.
Returns
Bimage* extracted image.
A single image (only one sub-image) is extracted from a given sub-image
in an image structure, starting at a specified point and with a 
specified size.
The old data is not affected.
Statistics for the extracted image are calculated.

◆ extract_show()

Bimage * Bimage::extract_show ( int  aflag)

Converts a slice from an image to a 2D plane for display.

Parameters
aflagaveraging flag.
Returns
Bimage* extracted slice.
Only the desired image slice is extracted from the original image and
resized based on the given scale argument.
The image, slice and scale values are encoded in the image structure.
The dynamic range is rescaled using the image display minimum and maximum:
    new_data = data*255/(max-min)
with truncation of the data below 0 and above 255.
Bit data are converted to 0 (black) and 255 (white).
RGB data are rescaled as for gray scale images.
Complex data types are converted to intensities.

◆ extract_show_chunk()

int Bimage::extract_show_chunk ( Bimage pshow,
int  aflag,
long  i,
long  len 
)

◆ extract_slice()

Bimage * Bimage::extract_slice ( long  nz)

Extracts a given slice or slices from an image.

Parameters
nzslice number to extract.
Returns
Bimage* extracted slice(s).
Only the desired slices are extracted from the original image.
The dynamic range is rescaled using the image display minimum and 
maximum:
    new_data = data*255/(max-min)
with truncation of the data below 0 and above 255.
Bit data are converted to 0 (black) and 255 (white).
RGB data are rescaled as for gray scale images.
Complex data types are converted to intensities.

◆ extract_tetrahedron()

Bimage * Bimage::extract_tetrahedron ( Vector3< double > *  tet,
int  fill_type = 0,
double  fill = 0 
)

Extracts a tetrahedral part of the image.

Parameters
*tetfour 3-value vectors defining the tetrahedron.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
All voxels outside a tetrahedron defined by four points or vectors 
are set to a given fill value.
The new data replaces the old data.

◆ extract_tile_stack()

Bimage * Bimage::extract_tile_stack ( Vector3< long >  coords,
Vector3< long >  tile_size,
int  fill_type = 0,
double  fill = 0 
)

Extracts a stack of tiles at a specified position from an image into a new image.

Parameters
coordscoordinates for the tile origins.
tile_size3-vector size of extracted image.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
Bimage* p extracted stack of tiles.
A stack of tiles of specified size are extracted from all the sub-images
in an image structure, using given coordinates for the tiles.
The origins of the tiles are inserted into the sub-image origin fields.
The old data is not affected.

◆ extract_tile_stacks()

Bimage ** Bimage::extract_tile_stacks ( vector< Vector3< long > > &  coords,
Vector3< long >  tile_size 
)

Extracts stacks of tiles at a specified positions from an image into an array of new images.

Extracts a set of tiles at specified positions from an image into a new image.

Parameters
coordscoordinates for the tile origins.
tile_size3-vector size of extracted image.
Returns
Bimage** extracted stacks of tiles.
Stacks of tiles of specified size are extracted from all the sub-images
in an image structure, using given coordinates for the tiles.
The origins of the tiles are inserted into the sub-image origin fields.
The old data is not affected.

◆ extract_tiles() [1/3]

Bimage * Bimage::extract_tiles ( long  nn,
Vector3< long >  start,
Vector3< long >  region,
Vector3< long >  tile_size,
Vector3< long >  step_size,
int  exceed 
)

Extracts a set of tiles from an image into a new image.

Parameters
nnimage number from which to extract.
start3-vector start for first tile to be extracted.
region3-vector size of part of image to be extracted (0 = whole image).
tile_size3-vector size of extracted image.
step_size3-vector size of tile intervals.
exceedflag to allow tiles to exceed the input image size.
Returns
Bimage* extracted set of sub-images.
A set of tiles of specified size are extracted from a given sub-image
in an image structure, starting from a point and generating
as many tiles as would fit into the image size given. If the image size
given is zero, then the whole image is used. The origins of the tiles
are inserted into the sub-image origin fields.
The old data is not affected.

◆ extract_tiles() [2/3]

Bimage * Bimage::extract_tiles ( long  nn,
Vector3< long >  tile_size,
double  fraction = 0.2 
)

Extracts a set of tiles from an image into a new image.

Parameters
nnimage number from which to extract.
tile_size3-vector size of extracted image.
fractionoverlap fraction to aim for.
Returns
Bimage* extracted set of sub-images.
A set of tiles of specified size are extracted from a given sub-image
in an image structure. The tiles are located with overlap (~20% of tile width)
with the aim of covering the whole image but not exceeding it.
The origins of the tiles are inserted into the sub-image origin fields.
The old data is not affected.

◆ extract_tiles() [3/3]

Bimage * Bimage::extract_tiles ( long  nn,
vector< Vector3< long > > &  coords,
Vector3< long >  tile_size 
)

Extracts a set of tiles at specified positions from an image into a new image.

Parameters
nnimage number from which to extract, -1 indicates all images.
coordscoordinates for the tile origins.
tile_size3-vector size of extracted image.
Returns
Bimage* p extracted set of sub-images.
A set of tiles of specified size are extracted from a given sub-image 
in an image structure, using given coordinates for the tiles, which have
to fit into the image size. The origins of the tiles are inserted into 
the sub-image origin fields.
The old data is not affected.

◆ extract_wrap() [1/2]

Bimage * Bimage::extract_wrap ( long  nn,
Vector3< double >  loc,
Vector3< long >  size,
Vector3< double >  ori,
Matrix3  mat 
)

Extracts a region of one sub-image into new image structure with wrapping.

Parameters
nnimage number to extract.
locextraction location.
sizeextraction size.
oriextraction origin.
matorientation matrix.
Returns
Bimage* the new image structure, NULL if copy failed.

◆ extract_wrap() [2/2]

Bimage * Bimage::extract_wrap ( long  nn,
Vector3< long >  size,
Matrix3  mat 
)
inline

◆ extrude_cross_section()

int Bimage::extrude_cross_section ( long  length,
double  helix_rise,
double  helix_angle,
int  fill_type,
double  fill 
)

Extrudes a 2D cross section into a 3D continuous helix.

Parameters
lengthlength in z.
helix_risehelical subunit rise in angstrom.
helix_anglehelical subunit rotation in radians.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue of edge voxels.
Returns
int 0.
The helical axis is at the origin and alongthe a axis.

◆ fft() [1/5]

int Bimage::fft ( )
inline

◆ fft() [2/5]

int Bimage::fft ( fft_direction  dir,
int  norm_flag 
)

Fast Fourier transforms an image.

Parameters
dirdirection of transformation (FFTW_FORWARD or FFTW_BACKWARD)
norm_flagnormalization: 0=none, 1=sqrtN, 2=N.
Returns
int error code.
FFTW library (www.fftw.org).
A multi-image 1D, 2D and 3D data set is transformed forward or backward 
and optionally rescaled by 1/sqrt(N) or N.  The forward transformation 
has a negative signed exponent in the kernel and the backward transform 
a positive sign. The transformation is done in place and the resultant 
data are returned within the original image structure.
For both directions the resultant image is complex.

◆ fft() [3/5]

int Bimage::fft ( fft_direction  dir,
int  norm_flag,
ComplexConversion  conv 
)

Fast Fourier transforms an image with a specified conversion.

Parameters
dirdirection of transformation (FFTW_FORWARD or FFTW_BACKWARD)
norm_flagnormalization: 0=none, 1=sqrtN, 2=N.
conva flag for converting after transform.
Returns
int error code.

◆ fft() [4/5]

int Bimage::fft ( fft_direction  dir,
Vector3< long >  tile_size,
int  norm_flag = 1 
)

Tiled Fourier transform.

Parameters
dirdirection of transformation (FFTW_FORWARD or FFTW_BACKWARD)
tile_sizetile size.
norm_flagnormalization: 0=none, 1=sqrtN, 2=N.
Returns
int error code.
The 2d/3d image is tiled, each tile transformed and phase shifted.
The tiles are then averaged and returned as a new image.

◆ fft() [5/5]

int Bimage::fft ( fft_plan  plan,
int  norm_flag = 1 
)

Fast Fourier transforms an image.

Parameters
planFourier transform plan.
norm_flagnormalization: 0=none, 1=sqrtN, 2=N.
Returns
int error code.
FFTW library (www.fftw.org).
A multi-image 1D, 2D and 3D data set is transformed forward or backward 
and optionally rescaled by 1/sqrt(N) or N.  The forward transformation 
has a negative signed exponent in the kernel and the backward transform 
a positive sign. The transformation is done in place and the resultant 
data are returned within the original image structure.
For both directions the resultant image is complex.
Requirement: The plan must be derived from the same size image.

◆ fft_back() [1/2]

int Bimage::fft_back ( )
inline

◆ fft_back() [2/2]

int Bimage::fft_back ( fft_plan  plan,
int  norm_flag = 1 
)
inline

◆ fft_setup()

fft_plan Bimage::fft_setup ( fft_direction  dir,
int  opt = 0 
)

Sets up a plan for fast Fourier transforms.

Parameters
dirdirection of transformation (FFTW_FORWARD or FFTW_BACKWARD)
optoptimization (0=FFTW_ESTIMATE, 1=FFTW_MEASURE, 2=FFTW_PATIENT, 3=FFTW_EXHAUSTIVE).
Returns
fft_plan FFTW plan.
FFTW library (www.fftw.org).
The size and direction determines the plan.
Both FFTW versions 2 and 3 are supported.

◆ fftz() [1/2]

int Bimage::fftz ( )
inline

◆ fftz() [2/2]

int Bimage::fftz ( fft_direction  dir,
int  norm_flag = 1 
)

Fourier transform only of the z columns.

Parameters
dirdirection of transformation (FFTW_FORWARD or FFTW_BACKWARD)
norm_flagnormalization: 0=none, 1=sqrtZ, 2=Z.
Returns
int error code.
Only the z columns are transformed.

◆ filament_density()

Bimage * Bimage::filament_density ( double  width)

Estimates the density per pixel length of a filament.

Parameters
widthfilament width (pixels).
Returns
Bimage* one dimensional image with line integrals.
The filament axis must be along the long axis (x or y).
The filament width must be about half of the image width.
The background is calculated for each line from the regions 
outside the width of the filament and subtracted from all
values in the line.

◆ filament_from_projections()

Bimage * Bimage::filament_from_projections ( double  hi_res,
int  flag = 0 
)

Reconstructs a filament from a set of projections.

Parameters
hi_reshigh resolution limit.
flag0=sequential, 1=random.
Returns
Bimage* reconstructed filament.
The views are set at equally spaced angles around the z-axis.

◆ filament_width()

Bplot * Bimage::filament_width ( long  width,
long  lim_lo,
long  lim_hi 
)

Estimates the width of a filament.

Parameters
widthwindow size.
lim_lominimum filament width.
lim_himaximum filament width.
Returns
Bplot* plot of filament widths.
The filament axis must be along the y axis.

◆ file_name() [1/2]

string & Bimage::file_name ( )
inline

◆ file_name() [2/2]

void Bimage::file_name ( string  s)
inline

◆ fill()

void Bimage::fill ( double  v)
inline

◆ fill_gaps()

int Bimage::fill_gaps ( long  step)

Fill the voxels that are not calculated.

Parameters
stepstep increment for voxels with proper values.
Returns
int 0, <0 if error.
The step size used to calculate sparse voxels is here used to determine
a kernel size for the filling operation. For each sparse voxel, all the
neighbors within the kernel are filled with the center value.

◆ fill_value()

TypePointer Bimage::fill_value ( double  v)

◆ filter_average() [1/2]

int Bimage::filter_average ( long  kernel_size)

Applies an averaging filter to an image.

Parameters
kernel_sizelength of kernel edge (typically 3).
Returns
int 0, <0 if error.
A kernel of a given size is passed over the image and the average
value within the kernel assigned to the central voxel.

◆ filter_average() [2/2]

int Bimage::filter_average ( Vector3< long >  k)

◆ filter_bilateral()

int Bimage::filter_bilateral ( double  sigma1,
double  sigma2,
int  kernel_type,
long  kernel_radius 
)

Denoise an image with combined gaussian distance and density difference kernel.

Parameters
sigma1sigma for distance weighting function.
sigma2sigma for density difference weighting function.
kernel_typekernel type for range filter.
kernel_radiuskernel radius.
Returns
int 0.
The kernel is multiplied with each area surrounding the current voxel.
Kernel types:
    1.  Gaussian
    2.  Lorentzian
    3.  Tukey

◆ filter_bilateral_chunk()

int Bimage::filter_bilateral_chunk ( Bimage pkernel,
double  sigma2,
int  kernel_type,
float *  nudata,
long  i,
long  len,
int  first 
)

◆ filter_by_difference()

int Bimage::filter_by_difference ( Bimage p)

Calculates an anisotropic average within a kernel based on the local gradient.

Parameters
*pimage to compare with.
Returns
int 0.

◆ filter_dog()

int Bimage::filter_dog ( double  sigma1,
double  sigma2 
)

Convolves the image with a difference of gausians kernel.

Parameters
sigma1sigma for the inner gaussian.
sigma2sigma for the outer gaussian.
Returns
int 0, <0 on error.

◆ filter_extremes() [1/3]

int Bimage::filter_extremes ( )

Filters the extremes out of a micrograph image.

Returns
int 0.
Segmentation is used to identify large contiguous regions of high
and low values, and these regions are set to the average.

◆ filter_extremes() [2/3]

int Bimage::filter_extremes ( double  tmin,
double  tmax,
int  kernel = 3 
)

Filters the extremes out of an image by replacing with adjacent averages.

Parameters
tminminimum.
tmaxmaximum.
kernelkernel edge size.
Returns
int 0.
Pixels smaller than the minimum or larger than the maximum are set to
the average within a defined kernel.

◆ filter_extremes() [3/3]

int Bimage::filter_extremes ( int  mod_flag)

Filters the extremes out of an image.

Parameters
mod_flagmodification flag (0=set to avg, 1=set to min_max).
Returns
int 0.
A histogram of an image is calculated.  The first minimum in the first
quarter of the histogram and the last minimum in the last quarter
are taken to define the small and large outliers.  Pixel outside
these minima are then either set to average or to minimum or maximum
(depending on the mod_flag argument) to remove the outliers.

◆ filter_gaussian()

int Bimage::filter_gaussian ( long  kernel_size,
double  sigma = 0 
)

Applies a gaussian filter to an image.

Parameters
kernel_sizelength of kernel edge.
sigmagaussian decay.
Returns
int 0, <0 if error.
The image is comvolved with a Gaussian kernel.
If the sigma value is zero, it is set to a sixth of the kernel size.

◆ filter_ortho()

int Bimage::filter_ortho ( int  type)

Convolves the image with an orthogonal kernel with wrapping.

Parameters
typetype of kernel: 0=gradient magnitude, 1=laplacian.
Returns
int 0, <0 on error.
The gradient kernel is:
    0  0  0    0 -1  0    0  0  0
    0 -1  0   -1  0  1    0  1  0
    0  0  0    0  1  0    0  0  0

The Laplacian filter kernel for a 3D volume is:
    0  0  0    0  1  0    0  0  0
    0  1  0    1 -6  1    0  1  0
    0  0  0    0  1  0    0  0  0
For 1D and 2D the central value is -2 and -4 respectively.

◆ filter_peak()

Bimage * Bimage::filter_peak ( long  kernel_size)

Finds the peaks in an image.

Parameters
kernel_sizelength of kernel edge (typically 3).
Returns
int 0, <0 if error.
A kernel of a given size is passed over the image and if the central
voxel is the maximum, it is kept, otherwise it is set to background.

◆ filter_rank()

int Bimage::filter_rank ( long  kernel_size,
double  rank 
)

Applies a median filter to an image.

Parameters
kernel_sizelength of kernel edge (typically 3).
rankwhich value in the kernel to retain.
Returns
int 0, <0 if error.
A kernel of a given size is passed over the image and the median
value within the kernel assigned to the central voxel.

◆ filter_rank_chunk()

int Bimage::filter_rank_chunk ( long  kernel_size,
double  rank,
float *  nudata,
long  i,
long  len 
)

◆ filter_rolling_ball()

int Bimage::filter_rolling_ball ( long  radius,
double  scale 
)

Apply a rolling ball filter.

Parameters
radiusradius of rolling ball.
scaledensity scale.
Returns
int 0.

◆ filter_sinc()

int Bimage::filter_sinc ( )

Weighs an image with a sinc function.

Returns
int 0.
This filter compensates for trilinear interpolation during reconstruction.
The origin must be properly defined.

◆ find()

Bimage * Bimage::find ( Bstring  fn)
inline

◆ find_center()

int Bimage::find_center ( Bimage pmask,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag 
)

Finds the center of mass of an image by cross-correlation with its inverse.

Parameters
*pmaskbinary mask (only 0 and 1).
hireshigh resolution limit.
loreslow resolution limit.
radiussearch radius (if < 1, default 1e30).
sigmaattenuation around radius.
refine_flagset to refine shift to subpixel resolution.
Returns
int 0.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D data sets are transformed 
forward, the first transform multiplied by the complex conjugate of
the second transform, followed by backward transformation and 
rescaling by 1/(N*N). Data beyond the resolution set in the first 
image structure are not used. Therefore the correct setting 
of units and resolution in the image are required. Defaults for the 
units are usually 1 Angstrom/voxel and a zero resolution would
include the whole image (i.e., no resolution limitation).
A shift vector for each pair of images is calculated to
determine the cross-correlation peak to sub-pixel resolution.
Note: The first image is the reference and the shift returned is to
    transform the second to fit the first.

◆ find_cyclic_point_group()

double Bimage::find_cyclic_point_group ( Bsymmetry sym,
int  binfac,
double  hires,
double  lores 
)

Finds the orientation for an image with a cyclic point group symmetry.

Parameters
sympoint group.
binfacbinning for faster searching (limited to 1,2,3).
hireshigh resolution limit in angstroms.
loreslow resolution limit in angstroms.
Returns
double symmetry correlation coefficient.
The cyclic point group symmetry operation is applied to an image using
the reference symmetry axis, aslo the 2D rotation axis (default {0,0,1}). 

◆ find_helix_parameters() [1/2]

Bplot * Bimage::find_helix_parameters ( double  angle_start,
double  angle_end,
double  angle_step,
int  bin,
double  hires,
double  lores,
double  radius 
)

Finds the best helix parameters for helical map.

Parameters
angle_startstart value for angle.
angle_endend value for angle.
angle_stepstep size for angle.
binbin image for faster searching (limited to 1,2,3).
hireshigh resolution limit in angstroms.
loreslow resolution limit in angstroms.
radiusradius for mask (voxels).
Returns
Bplot* plot with search results.
An incremental search is done for the rotation angle, with the rise
inferred from the cross-correlation shift.

◆ find_helix_parameters() [2/2]

Bplot * Bimage::find_helix_parameters ( double  rise_start,
double  rise_end,
double  rise_step,
double  angle_start,
double  angle_end,
double  angle_step,
int  bin,
double  radius 
)

Finds the best helix parameters for helical map.

Parameters
rise_startstart value for rise.
rise_endend value for rise.
rise_stepstep size for rise.
angle_startstart value for angle.
angle_endend value for angle.
angle_stepstep size for angle.
binbin image for faster searching (limited to 1,2,3).
radiusradius for mask (voxels).
Returns
Bplot* plot with search results.
An incremental search is done for the rise and rotation angle.

◆ find_peak()

int Bimage::find_peak ( double  radius = 1e30,
double  sigma = 0 
)

Finds the peak in an image to the nearest voxel.

Parameters
radiussearch radius (if < 1, default 1e30).
sigmaattenuation around radius.
Returns
int error code.
An image is searched for the global maximum (typically used to find
the shift vector in a cross-correlation map).
The peak vectors returned are in actual pixel coordinates (no wrapping).
The location around which to search is taken from the image origins.

◆ find_peaks() [1/2]

Vector3< double > * Bimage::find_peaks ( double  excl_dist,
long &  ncoor,
double &  threshold_min,
double &  threshold_max,
double  pix_min = 2,
double  pix_max = 10 
)

Finds the peaks in a cross-correlation map to find template matches.

Parameters
excl_distexclusion distance between peaks.
&ncoornumber of coordinates.
&threshold_minminimum threshold to choose peaks.
&threshold_maxmaximum threshold to choose peaks.
pix_minminimum peak width.
pix_maxmaximum peak width.
Returns
Vector3<double>* list of coordinates.
The map is searched in increments of the particle radius to identify
peaks above the threshold and within a box the size of the
particle radius. The identified peaks are further examined to eliminate 
ones that are too close to a higher scoring peak. The acceptable distance
between peaks is set to 1.8 times the particle radius.

◆ find_peaks() [2/2]

Bimage * Bimage::find_peaks ( long  kernelsize)

Finds peaks in a map with periodic boundaries.

Parameters
kernelsizesize of kernel side (must be ≥3).
Returns
Bimage* image with peaks.
A peak is defined as the local maximum within a specified kernel, where the
maximum is also larger than a given threshold. This assumes that the region
around a peak decreases monotonically on the scale length of the size of
the kernel. With kernel edge of 3 (+-1 in all directions), the values around
the peak shows a strict monotonicity with distance from the peak maximum.
The peak positions and values are returned in the new image.

◆ find_point_group()

double Bimage::find_point_group ( Bsymmetry sym,
double  angle_step,
int  binfac,
double  hires,
double  lores,
int  flags 
)

Finds the orientation for an image with a specific point group symmetry.

Parameters
sympoint group.
angle_stepangular step size for search.
binfacbinning for faster searching (limited to 1,2,3).
hireshigh resolution limit in angstroms.
loreslow resolution limit in angstroms.
flagsflag to search only for minor axes.
Returns
double symmetry correlation coefficient.
The point group symmetry operations are applied to an image with an
orientation defined by the reference symmetry axis (default {0,0,1}). 

◆ find_shift() [1/5]

int Bimage::find_shift ( Bimage pref,
Bimage pmask,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag 
)

Calculates a cross-correlation map to find the shift for the pair of images.

Parameters
*prefreference image.
*pmaskbinary mask (only 0 and 1).
hireshigh resolution limit.
loreslow resolution limit.
radiussearch radius (if < 1, default 1e30).
sigmaattenuation around radius.
refine_flagset to refine shift to subpixel resolution.
Returns
int error code.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D data sets are transformed 
forward, the first transform multiplied by the complex conjugate of
the second transform, followed by backward transformation and 
rescaling by 1/(N*N). Data beyond the resolution set in the first 
image structure are not used. Therefore the correct setting 
of units and resolution in the image are required. Defaults for the 
units are usually 1 Angstrom/voxel and a zero resolution would
include the whole image (i.e., no resolution limitation).
A shift vector for each pair of images is calculated to
determine the cross-correlation peak to sub-pixel resolution.
Note: The first image is the reference and the shift returned is to
    transform the second to fit the first.

◆ find_shift() [2/5]

Vector3< double > Bimage::find_shift ( Bimage pref,
Bimage pmask,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag,
double &  cc 
)

◆ find_shift() [3/5]

Vector3< double > Bimage::find_shift ( Bimage pref,
Bimage pmask,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag,
fft_plan  planf,
fft_plan  planb,
double &  cc 
)

Calculates a cross-correlation map to find the shift for the pair of images.

Parameters
*prefreference image.
*pmaskbinary mask (only 0 and 1).
hireshigh resolution limit.
loreslow resolution limit.
radiussearch radius (if < 1, default 1e30).
sigmaattenuation around radius.
refine_flagset to refine shift to subpixel resolution.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
&cccorrelation coefficient
Returns
Vector3<double> shift.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D data sets are transformed 
forward, the first transform multiplied by the complex conjugate of
the second transform, followed by backward transformation and 
rescaling by 1/(N*N). Data beyond the resolution set in the first 
image structure are not used. Therefore the correct setting 
of units and resolution in the image are required. Defaults for the 
units are usually 1 Angstrom/voxel and a zero resolution would
include the whole image (i.e., no resolution limitation).
A shift vector for each pair of images is calculated to
determine the cross-correlation peak to sub-pixel resolution.
Note: The first image is the reference and the shift returned is to
    transform the second to fit the first.

Only the first sub-image shift is calculated.

◆ find_shift() [4/5]

Vector3< double > Bimage::find_shift ( Bimage pref,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag,
fft_plan  planf,
fft_plan  planb 
)

Calculates a cross-correlation map to find the shift for the pair of images.

Parameters
*prefreference image.
hireshigh resolution limit.
loreslow resolution limit.
radiussearch radius (if < 1, default 1e30).
sigmaattenuation around radius.
refine_flagset to refine shift to subpixel resolution.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
Vector3<double> shift.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D data sets are transformed 
forward, the first transform multiplied by the complex conjugate of
the second transform, followed by backward transformation and 
rescaling by 1/(N*N). Data beyond the resolution set in the first 
image structure are not used. Therefore the correct setting 
of units and resolution in the image are required. Defaults for the 
units are usually 1 Angstrom/voxel and a zero resolution would
include the whole image (i.e., no resolution limitation).
A shift vector for each pair of images is calculated to
determine the cross-correlation peak to sub-pixel resolution.
Note: The first image is the reference and the shift returned is to
    transform the second to fit the first.

Only the first sub-image shift is calculated.

◆ find_shift() [5/5]

Vector3< double > Bimage::find_shift ( long  nn,
Bimage pref,
Bimage pmask,
double  hi_res,
double  lo_res,
double  shift_limit,
fft_plan  planf,
fft_plan  planb 
)

Calculates a cross-correlation map to find the shift for the pair of images.

Parameters
nnsub-image to align.
*prefreference image.
*pmaskbinary mask for cross-correlation (only 0 and 1).
hi_reshigh resolution limit.
lo_reslow resolution limit.
shift_limitsearch radius (if < 1, default 1e30).
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
double correlation coefficient.
The shift is returned as the origin of each sub-image relative to
the reference origin.

◆ find_shift_in_transform() [1/2]

Vector3< double > Bimage::find_shift_in_transform ( double  shift_limit)

Finds the shift by brute force backtransformation for selected shifts.

Parameters
shift_limitmaximum real space shift.
Returns
Vector3<double> best shift.
The input image is a cross-correlation transform.
A brute force integration is done for the given shift to calculate
the corresponding correlation coefficient.
The correlation coefficient is return in the FOM field of the sub-image.

◆ find_shift_in_transform() [2/2]

Vector3< double > Bimage::find_shift_in_transform ( long  nn,
Bimage pref,
double  shift_limit 
)

◆ find_symmetric_view()

Bimage * Bimage::find_symmetric_view ( Bimage ptemp,
Bsymmetry sym,
double  phi_step,
double  theta_step,
double  alpha_step,
Vector3< double >  shift 
)

Finds the view that on symmetrizing fits best to a symmetric template.

Parameters
*ptempsymmetric template.
&symsymmetry.
phi_stepphi angle step size (radians).
theta_steptheta angle step size (radians).
alpha_steprotation angle step size (radians).
shiftshift to impose before symmetrization.
Returns
Bimage* image rotated to the best view.
The orientation parameters, view vector, angle of rotation and origin,
of each image is packed into 3D reciprocal space.
An image is used in the reconstruction if its selection flag has been set.
The fill value is taken from image's background value.  

◆ find_template()

Bimage * Bimage::find_template ( Bimage ptemp,
Bimage pmask,
double  hires,
double  lores,
int  bin,
fft_plan  planf,
fft_plan  planb 
)

Finds one or more matches to a template.

Parameters
*ptemptemplate image.
*pmaskreciprocal space mask.
hireshigh resolution limit.
loreslow resolution limit.
binlevel of image binning.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
Bimage* cross-correlation map.
A template is cross-correlated with the input image including
bandpass filtering to target the size of the template particle.

◆ fit_peak()

Vector3< double > Bimage::fit_peak ( )

Fits an elliptic parabole to locate the position of the peak to sub-voxel resolution.

Returns
Vector3<double> shift from input origin.
The peak is expected to be near the middle of the image, close to the input origin.
The function fits a 10-parameter parabola to the image.
The shift is retrieved from the parameters by matrix inversion.
The refined peak returned is the offset from the input origin.

◆ fix_power_spectrum()

long Bimage::fix_power_spectrum ( int  dir,
double  ratio 
)

Removes high-intensity artifacts on the zero-frequency lines in a power spectrum.

Parameters
dirline direction: 1=horizontal, 2=vertical, 3=both.
ratiothreshold ratio.
Returns
long number of fixed pixels. The average of the lines above and below a pixel are calculated. If the pixel vale divided by this average exceeds the given threshod ratio. it is replaced by the average.

◆ fix_type()

void Bimage::fix_type ( )

Determines the replacement data type.

An integer data type is switched between signed and unsigned.

◆ fourier_type() [1/2]

FourierType Bimage::fourier_type ( )
inline

◆ fourier_type() [2/2]

void Bimage::fourier_type ( FourierType  tf)
inline

◆ friedel_apply()

int Bimage::friedel_apply ( )

Applies Friedel symmetry.

Returns
int 0.
The Friedel-related voxels are converted to polar form and the 
in difference in amplitude and phase calculated (taking into account
the phases should differ by sign). The voxels are then set to the
average and its conjugate.

◆ friedel_check()

double Bimage::friedel_check ( )

Checks Friedel symmetry.

Returns
double overall RMSD or residual.
The differences between the complex and polar forms of Friedel-related 
voxels are calculated and accumulated as squared sums weighted by their
average intensities. The residuals are then calculated as 
root-mean-square-deviations.

◆ friedel_difference()

double Bimage::friedel_difference ( )

Calculates the difference between Friedel pairs.

Returns
0 .
The differences between each the complex Friedel-related
voxels are calculated and accumulated as squared sums weighted by their
average intensities. The residuals are then calculated as
root-mean-square-deviations.

◆ fsc() [1/2]

Bplot * Bimage::fsc ( Bimage p,
double  hi_res,
double  sampling_ratio = 1 
)

◆ fsc() [2/2]

Bplot * Bimage::fsc ( double  hi_res,
double  sampling_ratio,
vector< double > &  fsccut 
)

◆ fsc_dpr()

Bplot * Bimage::fsc_dpr ( double  hi_res,
double  sampling_ratio = 1,
int  flag = 0 
)

Calculates an FSC and DPR curves from two images.

Parameters
hi_reshigh resolution limit.
sampling_ratioradial sampling ratio (1 for per voxel sampling).
flagif 1 calculate only the FSC.
Returns
Bplot* FSC curve.
FRC: Fourier ring/shell correlation 
-----------------------------------
Saxton & Baumeister (1982) J. Microscopy 127, 127-138 
de la Fraga et al. (1995) Ultramicroscopy 60, 385-391 
           sum(|F1|*|F2|) 
FRC/FSC = --------------------------------- 
          sqrt( sum(|F1|^2) * sum(|F2|^2) ) 

◆ fsc_local()

Bimage * Bimage::fsc_local ( Bimage p,
Bimage pmask,
double  hi_res,
double *  cutoff,
int  mask_level,
int  size,
int  pad,
Vector3< long >  vedge,
int  step = 1,
int  taper = 1,
double  fill = 0 
)

Determine the local resolution at each masked voxel in a map.

Author
Giovanni Cardone and Bernard Heymann
Parameters
*psecond image.
*pmaskmask.
hi_reshigh resolution limit.
*cutoffcorrelation threshold(s).
mask_levelmask level index.
sizekernel size.
padpadding factor.
vedgeedge size.
stepvoxel step size.
taperkernel tapering function.
fillbackground fill value.
Returns
Bimage* local resolution image.
For each voxel specified in the mask, within the edge limits, and at
the step size given, two kernels are extracted from the two input maps.
These kernels are then compared to determine the resolution based FSC.
The resultant resolution value is then written into a new map.

◆ fsc_shell()

Bimage * Bimage::fsc_shell ( Bimage p,
double  hi_res,
double *  cutoff,
int  thickness,
int  step,
int  minrad,
int  maxrad,
int  pad = 1,
int  smooth = 0,
double  fill = 0 
)

Determine the resolution for each concentric shell in a map.

Parameters
*psecond image.
hi_reshigh resolution limit.
*cutoffcorrelation threshold(s).
thicknessshell thickness.
stepstep size between shells.
minradminimum radius.
maxradmaximum radius.
padpadding factor.
smoothflag for edge smooting.
fillbackground fill value.
Returns
Bimage* a 1D image containing the shell resolutions.

◆ fspace_2D_interpolate()

int Bimage::fspace_2D_interpolate ( Complex< float >  cv,
Vector3< double >  m,
double  part_weight,
int  interp_type 
)

Interpolates a 2D image for packing ito a 3D reciprocal space volume.

Parameters
cvcomplex value from 2D transform.
mlocation in 3D relative to origin.
part_weightweight to assign to value (usually 1).
interp_typeinterpolation type (0=nearest neighbor, 1=weighted nearest neigbor, 2=trilinear).
Returns
int 0, <0 on error.

◆ fspace_amp_one()

int Bimage::fspace_amp_one ( )

Sets all amplitudes to one.

Returns
int 0.
If the image is a not a Fourier transform, it is transformed, modified,
and backtransformed. If the image is a Fourier transform, it is just
modified. The resultant image is floating point for real space or
complex for reciprocal space.

◆ fspace_amp_threshold()

int Bimage::fspace_amp_threshold ( double  threshold)

Filters the amplitudes of the Fourier transform of an image.

Parameters
thresholdMiminum amplitude to accept.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered. The filtering sets all amplitudes below the given threshold
to zero. The resultant image is floating point for real space or
complex for reciprocal space.

◆ fspace_background()

int Bimage::fspace_background ( )

Calculates the background for a Fourier transform.

Returns
int 0. The background is taken to be the area outside Nyquest.

◆ fspace_bandpass() [1/2]

int Bimage::fspace_bandpass ( double  res_hi,
double  res_lo,
double  width,
fft_plan  planf,
fft_plan  planb 
)

Applies a bandpass filter to an image.

Parameters
res_hihigh resolution limit.
res_lolow resolution limit.
widthgaussian width of edge.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered. The filtering sets all values with frequencies above the
given high resolution limit and below the given low resolution limit
to zero.

◆ fspace_bandpass() [2/2]

int Bimage::fspace_bandpass ( double  res_hi,
double  res_lo = 0,
double  width = 0 
)

Applies a bandpass filter to an image.

Parameters
res_hihigh resolution limit.
res_lolow resolution limit.
widthgaussian width of edge.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered. The filtering sets all values with frequencies above the
given high resolution limit and below the given low resolution limit
to zero.

◆ fspace_butterworth_band()

int Bimage::fspace_butterworth_band ( double  res_hi,
double  res_lo,
int  order = 16 
)

Calculates a Butterworth band-pass filter profile.

Parameters
res_hihigh resolution limit.
res_lolow resolution limit.
orderButtorworth filter order.
Returns
int 0.
The image is Fourier transformed and weighed with a gaussian curve:
    Fnew = F*(1/sqrt(1+(s/shi)^n) - 1/sqrt(1+(s/slo)^n))

◆ fspace_default_bands()

vector< double > Bimage::fspace_default_bands ( double  res_lo,
double  res_hi 
)

Sets up default frequency space bands to generate a mask.

Parameters
res_lolow resolution limit (angstrom).
res_hihigh resolution limit (angstrom).
Returns
vector<double> array of band specifications.
The band argument is a list of pairs of values, each pair indicating
a resolution shell (in angstrom) and a flag indicating whether the 
following shells should be:
    0: excluded - also the high resolution limit
    1: included in the FOM
    -1: included in the cross-validation FOM
The high resolution limit for the mask is set in the image structure.

◆ fspace_fit_B_factor()

double Bimage::fspace_fit_B_factor ( double  res_hi = 0)

Determines the overall B-factor of an image.

Parameters
res_hihigh resolution limit.
Returns
double B-factor.
The input image must a real space image. A radial power spectrum
is calculated and fitted to the linearized version of the function:
    f^2 = scale * F^2 * exp(-B_factor/2 * s^2)
where:
    f:  scattering profile for carbon
    F:  radial average amplitude
    s:  reciprocal space distance
    scale:  arbitrary scale
The linear form of the function is:
    4*(log(f) - log(F)) = 2*log(scale) - B * s^2

◆ fspace_frequency_filter() [1/2]

int Bimage::fspace_frequency_filter ( double  freq,
double  sigma 
)

Applies a frequency filter to an image.

Parameters
freqfrequency or inverse frequency.
sigmagaussian envelope width around frequency.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered.
The filter imposes a guassian envelope at the given frequency.
If the frequency value is greater than one, it is assumed to be given
as the inverse.

◆ fspace_frequency_filter() [2/2]

int Bimage::fspace_frequency_filter ( double  freq,
double  sigma,
fft_plan  planf,
fft_plan  planb 
)

Applies a frequency filter to an image.

Parameters
freqfrequency or inverse frequency.
sigmagaussian envelope width around frequency.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered.
The filter imposes a guassian envelope at the given frequency.
If the frequency value is greater than one, it is assumed to be given
as the inverse.

◆ fspace_gabor_filter() [1/2]

int Bimage::fspace_gabor_filter ( Vector3< double >  freq,
double  fsigma,
double  psigma 
)

Applies a Gabor filter to an image.

Parameters
freqfrequency or inverse frequency location.
fsigmagaussian envelope width in the direction of the frequency vector.
psigmagaussian envelope width perpendicular to the frequency vector.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered.
The filter imposes a guassian envelope at the given frequency location.
If the frequency vector size is greater than one, it is assumed to be given
as the inverse.

◆ fspace_gabor_filter() [2/2]

int Bimage::fspace_gabor_filter ( Vector3< double >  freq,
double  fsigma,
double  psigma,
fft_plan  planf,
fft_plan  planb 
)

Applies a Gabor filter to an image.

Parameters
freqfrequency or inverse frequency direction location.
fsigmagaussian envelope width in the direction of the frequency vector.
psigmagaussian envelope width perpendicular to the frequency vector.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.
Returns
int 0.
If the image is a not a Fourier transform, it is transformed, filtered,
and backtransformed. If the image is a Fourier transform, it is just
filtered.
The filter imposes a guassian envelope at the given frequency location.
If the frequency vector size is greater than one, it is assumed to be given
as the inverse.

◆ fspace_gradient()

Bimage * Bimage::fspace_gradient ( Vector3< double >  sigma)

Generates a image with orthogonal gradients encoded in 3-value vectors.

Parameters
sigmaGaussian sigma values.
Returns
int 0.
The image is Fourier transformed if needed.
An anisotropic weight function is calculated at each voxel and applied to the transform.

◆ fspace_interpolate()

Complex< double > Bimage::fspace_interpolate ( long  img_num,
Vector3< double >  m,
FSI_Kernel kernel 
)

Calculates the complex value at an image location by kernel-based interpolation.

Parameters
img_numsub-image number.
mlocation in image.
kernelinterpolation kernel.
Returns
Complex<double> interpolated value. The kernel lookup table must be precalculated.

◆ fspace_maximum_radius()

long Bimage::fspace_maximum_radius ( double  resolution,
double  sampling_ratio = 1 
)

Calculates the maximum radius in frequency space from a given resolution.

Parameters
resolutionhigh resolution limit.
sampling_ratiofrequency space sampling (default 1 pixel/sample).
Returns
long maximum radius.
The maximum radius is either the physical image size divided by the resolution,
or Nyquist frequency.

◆ fspace_normalize()

int Bimage::fspace_normalize ( )

Normalizes an image's amplitudes.

Returns
int 0.

◆ fspace_normalize_radial()

int Bimage::fspace_normalize_radial ( Bimage pmask,
double  resolution = 0,
int  flag = 0 
)

Normalizes an image's amplitudes.

Parameters
*pmaskreciprocal space mask (0 & 1, indicating inclusion of structure factors).
resolutionhigh resolution limit.
flagflag to calculate power (0) or amplitude (1).
Returns
int 0.

◆ fspace_pack_2D() [1/2]

int Bimage::fspace_pack_2D ( Bimage p,
Matrix3  mat,
double  hi_res,
double  lo_res,
Vector3< double >  scale,
double  ewald_wavelength = 0,
double  part_weight = 1,
int  interp_type = 0 
)

Packs a 2D Fourier transform into a 3D reciprocal space volume.

Parameters
*p2D particle image transform.
matrotation matrix.
hi_reshigh resolution limit.
lo_reslow resolution limit (infinite if 0).
scalescale of reconstruction and particle magnification.
ewald_wavelengthEwald sphere wavelength, if 0, not applied.
part_weightweight of particle (usually 1).
interp_typeinterpolation type (0=nearest neighbor, 1=weighted nearest neigbor, 2=trilinear).
Returns
int 0, <0 on error.
The rotation matrix is used to determine the plane in reciprocal space
to which the 2D transform data is added. The map is assumed to be cubic
and the 2D transform square. The orientation parameters must be written
into the image structure.
The Ewald sphere offset is stored in the third scale element.
Positive or negative for the corresponding sphere, or zero
if not applied.

◆ fspace_pack_2D() [2/2]

int Bimage::fspace_pack_2D ( Bimage p,
View  asu_view,
Bsymmetry sym,
double  hi_res,
double  lo_res,
Vector3< double >  scale,
double  ewald_wavelength = 0,
double  part_weight = 1,
int  interp_type = 0 
)

Packs a 2D Fourier transform into a 3D reciprocal space volume.

Parameters
*p2D particle image transform.
asu_viewview of asymmetric unit.
*sympoint group symmetry.
hi_reshigh resolution limit.
lo_reslow resolution limit (infinite if 0).
scalescale of reconstruction and particle magnification.
ewald_wavelengthEwald sphere wavelength, if 0, not applied.
part_weightweight of particle (usually 1).
interp_typeinterpolation type (0=nearest neighbor, 1=weighted nearest neigbor, 2=trilinear).
Returns
int 0, <0 on error.
The rotation matrix is used to determine the plane in reciprocal space
to which the 2D transform data is added. The map is assumed to be cubic
and the 2D transform square. The orientation parameters must be written
into the image structure.

◆ fspace_pack_2D_into_central_section()

long Bimage::fspace_pack_2D_into_central_section ( Bimage p,
long  ft_size,
double  scale,
double  hi_res,
double  lo_res,
Matrix3  matr,
Matrix3  mat 
)

Packs a 2D Fourier transform into a central section of a 3D reciprocal space volume.

Parameters
*p2D particle image transform.
ft_sizeFourier transform size.
scalescale of reconstruction and particle magnification.
hi_reshigh resolution limit.
lo_reslow resolution limit (infinite if 0).
matrcentral section orientation matrix.
matimage orientation matrix.
Returns
int 0, <0 on error.
The rotation matrix is used to determine the plane in reciprocal space
to which the 2D transform data is added in reference to the rotation
matrix of the central section. The map is assumed to be cubic
and the 2D transform square. The orientation parameters must be written
into the image structure. 

Vector3<double> vn(mat[2][0]/mat[2][2], mat[2][1]/mat[2][2], 0);

matr = matr.transpose();

m = mat * iv; m[2] = m.scalar(vn); m = matr * m;

◆ fspace_pack_3D()

int Bimage::fspace_pack_3D ( Bimage p,
double  hi_res = 0,
double  threshold = 0 
)

Packs a 3D Fourier transform into a 3D reciprocal space volume.

Parameters
*p3D particle image transform.
hi_reshigh resolution limit.
thresholdthreshold to exclude low intensities.
Returns
int 0, <0 on error.
The image is added up to the high resolution limit and excluding
low intensities as defined by the threshold.

◆ fspace_positive()

int Bimage::fspace_positive ( )

Sets the image to positive definite.

Returns
int 0. Scales the amplitudes to give a zero (DC) value of one.

◆ fspace_radial()

vector< double > Bimage::fspace_radial ( long  nn,
long  maxrad,
int  flag = 0 
)

Calculates the radial power spectrum from a Fourier transform.

Parameters
nnsub-image number.
maxradmaximum radius (i.e., high resolution limit).
flagflag to calculate power (0) or amplitude (1), and not normalize (2).
Returns
double* radial power spectrum in the form of a 1D image.

A radial average of a 2D or 3D Fourier transform is calculated. An interpolative method is used where the value of a voxel is distributed between the two nearest radial annuli. The final sum in an annulus is normalized by the number of voxels contributing to the annulus sum.

◆ fspace_radial_power()

Bimage * Bimage::fspace_radial_power ( double  resolution,
double  sampling_ratio = 1 
)

Calculates the radial power spectrum from a Fourier transform.

Parameters
resolutionhigh resolution limit.
sampling_ratiofrequency space sampling (default 1 pixel/sample).
Returns
Bimage* radial power spectrum in the form of a 1D image.
A radial average of a 2D or 3D Fourier transform is calculated.  
An interpolative method is used where the value of 
a voxel is distributed between the two nearest radial annuli.
The final sum in an annulus is normalized by the number of voxels 
contributing to the annulus sum.

◆ fspace_reconstruction_add()

long Bimage::fspace_reconstruction_add ( Bimage p)

Adds all components to a reconstruction.

Parameters
*pfrequency space reconstruction to add.
Returns
long 0.
The FOM block contains the sum of powers, the next image conatins the
weight sum, and the next image FOM block contains the sum of the
weight squared.

◆ fspace_reconstruction_snr()

long Bimage::fspace_reconstruction_snr ( )

Calculates the SNR map.

Returns
long coverage.
The FOM block contains the sum of powers, the next image conatins the
weight sum, and the next image FOM block contains the sum of the
weight squared.

◆ fspace_reconstruction_stats()

int Bimage::fspace_reconstruction_stats ( double  resolution,
double  sampling_ratio = 1 
)

Calculates Fourier shell statistics.

Parameters
resolutionhigh resolution limit.
sampling_ratiofrequency space sampling (default 1 pixel/sample).
Returns
int 0.
The average FOM and number of FOM values in each resolution shell is determined.

◆ fspace_reconstruction_weigh()

long Bimage::fspace_reconstruction_weigh ( )

Weighs a reconstruction.

Returns
long coverage.
The FOM block contains the sum of powers, the next image conatins the
weight sum, and the next image FOM block contains the sum of the
weight squared.

◆ fspace_resize() [1/2]

Bimage * Bimage::fspace_resize ( Bimage pref)

Resizes an image in frequency space to avoid interpolation.

Parameters
prefreference.
Returns
Bimage* resized image. The image is first resized to approximate the real size of the reference map.

◆ fspace_resize() [2/2]

int Bimage::fspace_resize ( double  scale,
double  res_hi,
double  res_lo 
)

Resizes an image in frequency space to avoid interpolation.

Parameters
scaleisotropic scaling.
res_hihigh resolution limit.
res_lolow resolution limit.
Returns
int 0.

◆ fspace_scale() [1/2]

int Bimage::fspace_scale ( long  nn,
vector< double > &  scale,
Bimage pmask = NULL 
)

◆ fspace_scale() [2/2]

int Bimage::fspace_scale ( vector< double > &  scale,
Bimage pmask = NULL 
)

◆ fspace_shift_sum()

Bimage * Bimage::fspace_shift_sum ( )
inline

◆ fspace_sqrt_amp()

int Bimage::fspace_sqrt_amp ( )

Change the amlitudes to their square roots.

Returns
int 0.

◆ fspace_square_amp()

int Bimage::fspace_square_amp ( )

Change the amlitudes to their squares.

Returns
int 0.

◆ fspace_ssnr()

Bplot * Bimage::fspace_ssnr ( long  nimg,
double  res_hi,
double  sampling_ratio 
)

◆ fspace_subset_ssnr()

Bplot * Bimage::fspace_subset_ssnr ( int  subset,
double  res_hi,
double  sampling_ratio,
int  flag = 0 
)

◆ fspace_subset_sums()

Bimage * Bimage::fspace_subset_sums ( int  subset,
int  flag = 0 
)

◆ fspace_sum()

Bimage * Bimage::fspace_sum ( int  shift = 0)

◆ fspace_translate() [1/2]

int Bimage::fspace_translate ( long  nn,
Vector3< double >  shift 
)

Translates an image in frequency space to avoid interpolation.

Parameters
nnsub-image to transform.
shift3-value real space shift vector.
Returns
int 0.

◆ fspace_translate() [2/2]

int Bimage::fspace_translate ( Vector3< double >  shift)

Translates an image in frequency space to avoid interpolation.

Parameters
shift3-value real space shift vector.
Returns
int error code.

◆ fspace_weigh() [1/2]

int Bimage::fspace_weigh ( Bimage pref,
Bimage pmask,
double  resolution = 0 
)

Weighs an image's amplitudes with the radial power spectrum of another.

Parameters
*prefreference image.
*pmaskreciprocal space mask (0 & 1, indicating inclusion of structure factors).
resolutionhigh resolution limit.
Returns
int 0.
The two images must be of the same dimensions.
The radial power spectra of the two images are calculated
and used to calculate the ratio of the second to the first in each shell.
This ratio is then used to rescale the amplitudes of the first image.

◆ fspace_weigh() [2/2]

int Bimage::fspace_weigh ( vector< double > &  curve,
int  flag = 0 
)

◆ fspace_weigh_accumulated_dose()

int Bimage::fspace_weigh_accumulated_dose ( vector< double >  dose)

Weighs an image's amplitudes with the accumulated dose.

Parameters
dosearray containing accumulated dose and parameters.
Returns
int 0.
The amplitudes are weighed using:
1. with 2 parameters: the formula of Grant and Grigorieff (2015).
2. with 3 parameters: exponential decay.

◆ fspace_weigh_B_factor()

int Bimage::fspace_weigh_B_factor ( double  B,
double  resolution = 0 
)

Weighs an image's amplitudes with B-factor (gaussian) curve.

Parameters
BB factor.
resolutionhigh resolution limit.
Returns
int 0.
The image is Fourier transformed and weighed with a gaussian curve:
    Fnew = F*exp(-B*s2/4)

◆ fspace_weigh_C_curve()

int Bimage::fspace_weigh_C_curve ( double  resolution = 0)

Weighs an image's amplitudes with the carbon scattering curve.

Parameters
resolutionhigh resolution limit.
Returns
int 0.
The image is Fourier transformed and the radial power spectrum calculated.
The ratio between the C curve and the average amplitudes in each shell
is calculated and used to rescale the amplitudes of the image.

◆ fspace_weigh_dose() [1/2]

int Bimage::fspace_weigh_dose ( double  dose_per_frame,
int  flag = 0 
)

Weighs an image's amplitudes with the accumulated dose.

Parameters
dose_per_frameelectron dose per frame.
flag0=Grant, 1=exponential decay.
Returns
int 0.
The image is Fourier transformed and the amplitudes weighed using 
the formula of Grant and Grigorieff (2015) or an exponential decay curve.

◆ fspace_weigh_dose() [2/2]

int Bimage::fspace_weigh_dose ( long  nn,
double  dose_per_frame,
vector< double >  critdose 
)

◆ fspace_weigh_FSC_curve()

int Bimage::fspace_weigh_FSC_curve ( Bplot plot,
double  resolution = 0 
)

Weighs an image's amplitudes with a given FSC curve.

Parameters
*plotFSC plot.
resolutionhigh resolution limit.
Returns
int 0.
The image is Fourier transformed and the radial power spectrum calculated.
The ratio between the square root of the FSC curve and the average 
amplitudes in each shell is calculated and used to rescale the amplitudes 
of the image.

◆ fspace_weigh_gaussian()

int Bimage::fspace_weigh_gaussian ( long  nn,
Vector3< double >  sigma,
int  dir = 0 
)

Weighs an image's amplitudes with an anisotropic Gaussian function.

Parameters
nnimage index.
sigmaGaussian sigma values.
dirderivative direction: 0=none, 1=x, 2=y, 3=z.
Returns
int 0.
The image must be a complex Fourier transform.
An anisotropic weight function is calculated at each voxel and applied to the transform.

◆ fspace_weigh_LoG()

int Bimage::fspace_weigh_LoG ( double  resolution,
double  sigma 
)

Weighs an image's amplitudes with a Laplacian-of-Gaussian function.

Parameters
resolutionhigh resolution limit.
sigmagaussian sigma.
Returns
int 0.
The image is Fourier transformed and the radial power spectrum calculated.
The ratio between the C curve and the average amplitudes in each shell
is calculated and used to rescale the amplitudes of the image.

◆ fspace_weigh_ramp() [1/2]

int Bimage::fspace_weigh_ramp ( double  resolution,
double  axis,
fft_plan  planf,
fft_plan  planb 
)

Weighs a transform with a ramp.

Parameters
resolutionhigh resolution limit.
axistilt axis for single tilt series (radians).
planf2D forward Fourier transform plan.
planb2D backward Fourier transform plan.
Returns
int 0.
Requirements:
    The data must be complex float and the FOM block must be allocated.

◆ fspace_weigh_ramp() [2/2]

int Bimage::fspace_weigh_ramp ( double  resolution,
fft_plan  planf,
fft_plan  planb 
)

Weighs a transform with a ramp.

Parameters
resolutionhigh resolution limit.
planf2D forward Fourier transform plan.
planb2D backward Fourier transform plan.
Returns
int 0.
Requirements:
    The data must be complex float and the FOM block must be allocated.

◆ fspace_weigh_RPS_curve()

int Bimage::fspace_weigh_RPS_curve ( Bplot plot,
double  resolution = 0 
)

Weighs an image's amplitudes with a given RPS curve.

Parameters
*plotRPS plot.
resolutionhigh resolution limit.
Returns
int 0.
The image is Fourier transformed and the radial power spectrum calculated.
The ratio between the square root of the RPS curve and the average 
amplitudes in each shell is calculated and used to rescale the amplitudes 
of the image.

◆ gaussian_sphere()

int Bimage::gaussian_sphere ( long  nn,
Vector3< double >  center,
double  sigma,
double  amp,
bool  wrap = 0 
)

Fills a gaussian sphere within an image with a uniform value.

Parameters
nnsub-image.
centercenter of sphere.
sigmaGaussian sigma value.
ampamplitude.
wrapwrap around boundaries.
Returns
int 0.
All voxels within a sphere at a given location and with a given radius 
are increased by a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ get() [1/3]

void Bimage::get ( Bstring  tag)

Prints out header information associated with a tag string.

Parameters
tagtag string.

Recognized tags: size, ch(annel), x, y, z, im(age), sam(pling), ori(gen), view, min(imum), max(imum), av(erage), st(andard deviation), var(iance), stat(istics), text, json

◆ get() [2/3]

double Bimage::get ( long  nn,
long  xx,
long  yy,
long  zz,
long  cc = 0 
)

Returns the data value at the given coordinates.

Parameters
nnimage index.
xxx coordinate.
yyy coordinate.
zzz coordinate.
ccchannel index.
Returns
double value.
The elemental data value is returned in double precision.

◆ get() [3/3]

double Bimage::get ( long  nn,
Vector3< double >  vox,
long  cc = 0 
)

Returns the data value at the given coordinates.

Parameters
nnimage index.
voxvoxel coordinates.
ccchannel index.
Returns
double value.
The elemental data value is returned in double precision.

◆ get_localtime()

tm * Bimage::get_localtime ( )
inline

◆ get_time()

time_t Bimage::get_time ( )
inline

◆ gradient()

Bimage * Bimage::gradient ( )

Calculates the central difference gradient image.

Returns
Bimage* an image with 3-value gradient vectors.
The central differences are calculated in the three orthogonal
directions and written into 3-value vectors.

◆ gradient3x3()

Bimage * Bimage::gradient3x3 ( )

Calculates the difference gradient image in a 3x3 kernel.

Returns
Bimage* an image with 3-value gradient vectors.
The central differences are calculated in the three orthogonal
directions and written into 3-value vectors.

◆ gradient_correction()

int Bimage::gradient_correction ( )

Calculates and corrects for a linear gradient across an image.

Returns
int 0.
The linear gradient across an image is calculated as:
    density(x,y,z) = b0 + b1*x + b2*y + b3*z
The image is converted to floating point and corrected for the gradient.

◆ graph_segment()

GSgraph Bimage::graph_segment ( int  type = 1,
int  connect_type = 0,
double  complexity = 0,
long  min_size = 0 
)

Graph-based segmentation of an image.

Parameters
typesegmentation type: 1=threshold, 2=statistical region merging.
connect_typeconnection type: 0=direct neighbors, 1=all neighbors.
complexitya value determining the number of segments.
min_sizeminimum segment size.
Returns
GSgraph graph with segment designations.
An array of edges between neighboring voxels is set up and sorted in
non-decreasing order. The voxels are then aggregated into regions based
on two selectable criteria:
simple      edge difference with adjustable threshold.
srm         statistical region merging.
Regions below a given cutoff size are merged.
Only the first sub-image is segmented.
Remarks
R. Nock, F. Nielsen: Statistical Region Merging. IEEE Trans. Pattern Anal. Mach. Intell. 26(11): 1452-1458 (2004)

◆ graph_segments_to_image()

Bimage * Bimage::graph_segments_to_image ( GSgraph g)

Converting a graph-based segmentation to an image.

Parameters
ggraph segmentation.
Returns
Bimage* segmented image.

◆ graph_segments_to_mask()

Bimage * Bimage::graph_segments_to_mask ( GSgraph g)

Converting a graph-based segmentation to a multi-level mask.

Parameters
ggraph segmentation.
Returns
Bimage* segmented image.

◆ graph_setup()

GSgraph Bimage::graph_setup ( int  connect_type)

Initializing voxels and edges for graph-based segmentation.

Parameters
connect_typeconnection type: 0=direct neighbors, 1=all neighbors.
Returns
GSgraph graph with segment designations.
Remarks
R. Nock, F. Nielsen: Statistical Region Merging. IEEE Trans. Pattern Anal. Mach. Intell. 26(11): 1452-1458 (2004)

Edges are set up with 6 or 26 neighbors.

◆ guess_compoundtype()

CompoundType Bimage::guess_compoundtype ( long  nc)

◆ hanning_taper()

int Bimage::hanning_taper ( double  fill = 0)

Apply Hanning taper window to the image.

Parameters
fillvalue of edge voxels.
Returns
int 0.
Along each dimension, the image is multiplied with a function:
    v_new(i) = fill + ( v_old(i) - fill )* 0.5 * ( 1 - cos( 2*PI*i/(n-1) )) i=0,...,n-1
where   fill is the desired edge value.
        n is the size of the image

◆ height()

Bimage * Bimage::height ( View views,
double  threshold = 0 
)

Calculates a set of height images from a 3D density map.

Parameters
*viewslinked list of views.
thresholddensity threshold to consider as object.
Returns
Bimage* 2D height images as sub-images.
A set of height images is calculated according to a list of views.

◆ helical_cross_section()

Bimage * Bimage::helical_cross_section ( double  helix_rise,
double  helix_angle,
double  scale,
double  hires 
)

Calculates a helical cross section from line transforms of a filament.

Parameters
helix_risehelical subunit rise in angstrom.
helix_anglehelical subunit rotation in radians.
scalescale of cross section.
hireshigh resolution limit.
Returns
Bimage* 2D cross section image.
The filament image must be oriented with the helical axis coinciding with 
the y axis. Each row of pixels is transformed and written into a
2D transform based on an orientation calculated from given helical
parameters.

◆ helix_interpolate()

double Bimage::helix_interpolate ( long  i,
double  helix_rise,
double  helix_angle,
int  zmin,
int  zmax,
double  radius,
int  norm_flag = 1 
)

◆ helix_segment_correlation()

Bplot * Bimage::helix_segment_correlation ( int  thickness,
double  angle_start,
double  angle_end,
double  angle_step,
int  bin,
double  hires,
double  lores,
double  radius 
)

Calculates the correlation over rotation angles between helical segments.

Parameters
thicknesssegment thickness.
angle_startstart value for angle.
angle_endend value for angle.
angle_stepstep size for angle.
binbin image for faster searching (limited to 1,2,3).
hireshigh resolution limit in angstroms.
loreslow resolution limit in angstroms.
radiusradius for mask (voxels).
Returns
Bplot* plot with coefficients over all rotations results.
The image is split up into segments in the z direction. Every adjacent pair
of segments are cross-correlated over an angular range to find the best
rotation. The cross-correlation can be resolution-limited. The image may
also be masked beyond a radius and binned to speed up execution.

◆ helix_segment_correlation_one()

int Bimage::helix_segment_correlation_one ( long  i,
double  angle_start,
double  angle_end,
double  angle_step,
int  bin,
double  hires,
double  lores,
double  radius,
fft_plan  planf,
fft_plan  planb,
double *  cc 
)

◆ helix_symmetrize()

double Bimage::helix_symmetrize ( double  helix_rise,
double  helix_angle,
int  dyad_axis,
int  zmin,
int  zmax,
double  radius,
int  norm_flag = 1 
)

Symmetrizes an image given helical symmetry parameters.

Parameters
helix_riserise per asymmetric unit (angstrom).
helix_anglerotation angle per asymmetric unit (radians).
dyad_axisdyad axis indicator: 2=dyad axis on x-axis, otherwise none.
zminmimimum z slice to include.
zmaxmaximum z slice to include.
radiusradius to do symmetrizing over (pixels).
norm_flagif 1, normalize
Returns
double R factor.
The data between the z limits are replicated along the helical axis
according to the helical rise and rotation to fill the new volume.

◆ histogram() [1/2]

Bplot * Bimage::histogram ( long  bins)

Calculates the histogram of an image.

Parameters
binsnumber of bins in the histogram.
Returns
Bplot* 0.
A histogram of an image is calculated with a given number of bins.
Multiple channels are output as successive one-dimensional arrays.
The image data is not affected.
The statistics for the input image must be correctly calculated.
If the postscript file name is given, a postscript plot is produced.

◆ histogram() [2/2]

vector< long > Bimage::histogram ( long  bins,
double &  scale,
double &  offset 
)

Calculates the histogram of an image.

Parameters
binsnumber of bins in the histogram.
&scalescale.
&offsetoffset.
Returns
vector<long> histogram.
A histogram of an image is calculated with a given number of bins.
Multiple channels are output as successive one-dimensional arrays.
The image data is not affected.
The statistics for the input image must be correctly calculated.

◆ histogram_counts()

Bplot * Bimage::histogram_counts ( int  flags = 0)

Finds the peaks in a quantized image from the histogram.

Parameters
flags1=plot, 2=convert image.
Returns
Bplot* plot of fits.
A histogram of an image with quantized data is calculated.
The peaks are determined and the image converted.

◆ histogram_gauss_fit()

vector< double > Bimage::histogram_gauss_fit ( long  bins,
long  ngauss = 1 
)

Fits a gaussian function to a histogram of an image.

Parameters
binsnumber of bins in the histogram.
ngaussnumber of gaussians.
Returns
vector<double> array with 3 values for each gaussian.
A histogram of an image is calculated with a given number of bins.
The return has (in order) the gaussian amplitude, the offset, and the sigma value.

◆ histogram_gauss_fit2()

vector< double > Bimage::histogram_gauss_fit2 ( long  bins,
long  ngauss = 1 
)

◆ histogram_gauss_plot()

Bplot * Bimage::histogram_gauss_plot ( long  bins,
long  ngauss = 1 
)

Fits a gaussian function to a histogram of an image.

Parameters
binsnumber of bins in the histogram.
ngaussnumber of gaussians.
Returns
Bplot* plot of the histogram and the gaussian fit.
A histogram of an image is calculated with a given number of bins.

◆ histogram_minmax()

int Bimage::histogram_minmax ( double &  tmin,
double &  tmax 
)

Calculates minimum and maximum thresholds for truncation.

Parameters
&tminminumum threshold.
&tmaxmaxumum threshold.
Returns
int 0.
A histogram of an image is calculated.  The first minimum in the first
quarter of the histogram and the last minimum in the last quarter
are taken to define the small and large outliers.

◆ histogram_multi_thresholds()

vector< double > Bimage::histogram_multi_thresholds ( long  bins,
long  number 
)

Calculates multiple thresholds from a histogram.

Parameters
binsnumber bins in histogram.
numbernumber of clusters (one more than thresholds).
Returns
vector<double> thresholds.
Reference: PS.Liao, TS.Chen, and PC. Chung,
       Journal of Information Science and Engineering, vol 17, 713-727 (2001)

◆ histogram_otsu_variance()

Bplot * Bimage::histogram_otsu_variance ( long  bins)

Calculates the inter-set variance of the bisection of a historgram using the method of Otsu.

Parameters
binsnumber bins in histogram.
Returns
double threshold.
Reference: NOBUYUKI OTSU, IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICS, VOL. SMC-9, NO. 1, JANUARY 1979

◆ histogram_poisson_fit()

Bplot * Bimage::histogram_poisson_fit ( long  bins,
int  flag = 0 
)

Fits a poisson function to a histogram of an image.

Parameters
binsnumber of bins in the histogram.
flag1=plot.
Returns
Bplot* plot of the histogram and the poisson fit.
A histogram of an image is calculated with a given number of bins.
The histogram is fit to the Poisson function:
               lambda * exp(-lambda)
    f(x) = Amp ---------------------
                        x!
by first converting it to a linear form:
    ln(f(x)) = ln(Amp) + x*ln(lambda) - lambda - lgamma(x+1)
and then using the downhill simplex method to find the solution.

◆ histomatch()

int Bimage::histomatch ( Bimage p,
long  bins 
)

Fits two images by matching the histogram of the second to the first.

Parameters
*psecond image.
binsnumber of bins in the histograms.
Returns
int 0, <0 if error.
Both images are converted to floating point.

◆ identifier() [1/2]

Bstring & Bimage::identifier ( )
inline

◆ identifier() [2/2]

void Bimage::identifier ( Bstring  s)
inline

◆ image_size()

long Bimage::image_size ( )
inline

◆ images() [1/2]

long Bimage::images ( )
inline

◆ images() [2/2]

void Bimage::images ( long  nn)

◆ images_to_channels()

int Bimage::images_to_channels ( long  nc,
CompoundType  ct 
)

◆ images_to_slices()

int Bimage::images_to_slices ( )

Changes the 2D images to slices in a 3D image.

Returns
int error code (<0 means failure).

◆ impose_superpixels()

int Bimage::impose_superpixels ( Bimage pmask,
vector< Bsuperpixel > &  seg,
int  impose 
)

Impose superpixel features onto an image.

Parameters
*pmaskmask defining superpixels.
segarray of superpixels.
imposeflag to select feature
Returns
0 .
Features to select:
0   none
1   segment average
2   lowest neighboring segment
3   difference from lowest neighbor
4   higest neigboring segment
5   difference from highest neighbor

◆ index() [1/6]

long Bimage::index ( long  nc,
long  nx,
long  ny,
long  nz,
long  nn 
) const
inline

◆ index() [2/6]

long Bimage::index ( long  nx,
long  ny 
) const
inline

◆ index() [3/6]

long Bimage::index ( long  nx,
long  ny,
long  nz 
) const
inline

◆ index() [4/6]

long Bimage::index ( long  nx,
long  ny,
long  nz,
long  nn 
) const
inline

◆ index() [5/6]

long Bimage::index ( Vector3< long >  vox,
long  nn 
) const
inline

◆ index() [6/6]

long Bimage::index ( vector< long >  vox,
long  nn 
) const
inline

◆ index_wrap() [1/3]

long Bimage::index_wrap ( long  nx,
long  ny,
long  nz 
) const
inline

◆ index_wrap() [2/3]

long Bimage::index_wrap ( Vector3< long >  coor) const
inline

◆ index_wrap() [3/3]

long Bimage::index_wrap ( vector< long >  coor) const
inline

◆ information()

int Bimage::information ( )

Prints out header information for an image.

Returns
int error code (<0 means failure).

◆ integer_interpolation() [1/2]

int Bimage::integer_interpolation ( int  integer_factor)

◆ integer_interpolation() [2/2]

int Bimage::integer_interpolation ( int  integer_factor,
int  odd 
)

Interpolates by an integer scale with a density-preserving overlapping kernel.

Parameters
integer_factorinteger interpolation factor.
oddflag to ensure the dimensions are odd.
Returns
int 0.
An image is interpolated by integer scaling (i.e., 2, 3, 4-fold or 
more) sometimes referred to as a form of binning.  A kernel is used
such that it overlaps with its neighbouring positions.  Voxels where
neighbouring kernel positions overlap contribute to 2, 4 or 8 new
voxels based on the number of overlapping kernel positions.  Only
the central voxel is unique to a kernel position.  The kernel is 
calculated as:
    w(i,j,k) = (1/s^2n)*(s-|s-1-i|)*(s-|s-1-j|)*(s-|s-1-k|)
where   s is the integer interpolation factor.
        n is the number of dimensions (1D, 2D or 3D).
The flag determines whether the dimensions are forced to be even or odd:
    0       No forcing
    1       x odd
    2       x even
    4       y odd
    8       y even
    16      z odd
    32      z even
    21      all odd
    42      all even
and any other combination.

◆ intensities_phase_colored()

Bimage * Bimage::intensities_phase_colored ( double  scale)

Generates a power spectrum with phases colored according to a color wheel.

Parameters
scaleamplitude scaling.
Returns
Bimage* color power spectrum.
A polar data type image (such as a Fourier transform) is converted
to indicate the phases as colors. The primary colors are located
0 degrees (red), 120 degrees (green) and -120 degrees (blue). All
three color values are down-weighted based on the amplitude. The
weighting is calculated as:
    weight = amplitude/(average+2*standard_deviation)
The origin specified in the image is used to shift the phases.
The scale is multiplied with the amplitude and cut off at one
to give the user the ability to enhance the image.
Default:
    scale = 1/(average_amplitude + standard_deviation_of_amplitude) 

◆ internal_volume() [1/2]

Bimage * Bimage::internal_volume ( double  threshold)

Calculates the internal volume of a shell.

Parameters
thresholdthreshold to define density.
Returns
Bimage* internal volume mask.

◆ internal_volume() [2/2]

Bimage * Bimage::internal_volume ( double  threshold,
int  mask_out_freq 
)

Calculates the internal volume of a shell.

Parameters
thresholdthreshold to define density.
mask_out_freqmask output frequency.
Returns
Bimage* internal volume mask.

◆ interpolate() [1/4]

double Bimage::interpolate ( long  cc,
double  xx,
double  yy = 0,
double  zz = 0,
long  nn = 0,
double  fill = 0 
) const

Interpolates using a given location.

Parameters
ccchannel.
xxx location.
yyy location.
zzz location.
nnimage number.
fillfill value if outside boundaries.
Returns
double interpolated value.
Trilinear interpolation.

◆ interpolate() [2/4]

double Bimage::interpolate ( long  cc,
Vector3< double >  vec,
long  nn = 0,
double  fill = 0 
) const
inline

◆ interpolate() [3/4]

double Bimage::interpolate ( Vector3< double >  vec,
long  nn = 0,
double  fill = 0 
) const
inline

◆ interpolate() [4/4]

double Bimage::interpolate ( vector< double >  vec,
long  nn = 0,
double  fill = 0 
) const
inline

◆ interpolate_gaps()

int Bimage::interpolate_gaps ( long  step)

Interpolate the voxels that are not calculated.

Parameters
stepstep increment for voxels with proper values.
Returns
int 0, <0 if error.
Sparse voxels calculated on a regular grid with the given step size are 
used to fill intermediate voxels with linearly interpolated values.

◆ interpolate_wrap() [1/4]

double Bimage::interpolate_wrap ( double  xx,
double  yy = 0,
double  zz = 0,
long  nn = 0 
) const
inline

◆ interpolate_wrap() [2/4]

double Bimage::interpolate_wrap ( long  cc,
double  xx,
double  yy = 0,
double  zz = 0,
long  nn = 0 
) const

Interpolates using a given location with wrapping.

Parameters
ccchannel.
xxx location.
yyy location.
zzz location.
nnimage number.
Returns
double interpolated value.
Trilinear interpolation with wrapping around periodic image boundaries.

◆ interpolate_wrap() [3/4]

double Bimage::interpolate_wrap ( long  cc,
Vector3< double >  vec,
long  nn = 0 
) const
inline

◆ interpolate_wrap() [4/4]

double Bimage::interpolate_wrap ( Vector3< double >  vec,
long  nn = 0 
) const
inline

◆ inverse()

void Bimage::inverse ( double  minval = 0)

Calculates the inverse of the image.

Parameters
minvalthe minimum absolute value considered not zero.
The inverse of every pixel is calculated.
If the minumum value is given as zero, zero pixels are retained.

◆ invert()

void Bimage::invert ( )

Inverts the data in the image.

The Bit data type is negated.
An unsigned data type is subtracted from its type maximum.
A signed data type is negated.

◆ kernel_average()

double Bimage::kernel_average ( long  idx,
long  ksize,
double  tmin,
double  tmax 
)

Calculates the average value in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size.
tminmiminum to exclude.
tmaxmaximum to exclude
Returns
double average value.

◆ kernel_gaussian()

int Bimage::kernel_gaussian ( double  sigma,
double  max 
)

Generates a gaussian kernel image.

Parameters
sigmagaussian width.
maxkernel maximum.
Returns
int 0.

◆ kernel_high() [1/2]

Vector3< long > Bimage::kernel_high ( long  i,
long  k = 1 
)
inline

◆ kernel_high() [2/2]

Vector3< long > Bimage::kernel_high ( long  i,
Vector3< long >  k 
)
inline

◆ kernel_laplacian_of_gaussian()

int Bimage::kernel_laplacian_of_gaussian ( double  sigma,
double  max 
)

Generates a laplacian-of-gaussian kernel.

Parameters
sigmagaussian width.
maxkernel maximum.
Returns
Bimage* kernel image.

◆ kernel_low() [1/2]

Vector3< long > Bimage::kernel_low ( long  i,
long  k = 1 
)
inline

◆ kernel_low() [2/2]

Vector3< long > Bimage::kernel_low ( long  i,
Vector3< long >  k 
)
inline

◆ kernel_max()

long Bimage::kernel_max ( long  idx,
long  ksize 
)

Finds the highest value in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
long index of highest value.

◆ kernel_max_neigbor()

long Bimage::kernel_max_neigbor ( long  idx,
long  ksize 
)

Finds the highest value in a kernel excluding the central voxel.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
long index of highest value.

◆ kernel_max_wrap()

long Bimage::kernel_max_wrap ( long  idx,
long  ksize 
)

Finds the highest value in a kernel with wrapping.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
long index of highest value.

◆ kernel_min()

long Bimage::kernel_min ( long  idx,
long  ksize 
)

Finds the highest value in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
long index of highest value.

◆ kernel_neighbor_average()

double Bimage::kernel_neighbor_average ( long  idx,
long  ksize 
)

Finds the average of neigbor values in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size.
Returns
double average value.

◆ kernel_order()

multimap< double, long > Bimage::kernel_order ( long  idx,
long  ksize 
)

Orders the values in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
multimap<double,long> index of highest value.

◆ kernel_order_neighbors()

multimap< double, long > Bimage::kernel_order_neighbors ( long  idx,
long  ksize 
)

Orders the neigbor values in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size
Returns
multimap<double,long> index of highest value.

◆ kernel_sum()

double Bimage::kernel_sum ( long  idx,
long  ksize 
)

Calculates the sum in a kernel.

Parameters
idxindex in multi-image.
ksizekernel edge half size.
Returns
double sum.

◆ kmeans_segment()

Bimage * Bimage::kmeans_segment ( long  nregion = 2,
long  max_iter = 10,
double  ratio = 1 
)

Segments an image based on K-means.

Parameters
nregionnumber of regions.
max_itermaximum number of iterations.
ratiobalance between density and distance.
Returns
Bimage* segmentation mask.
The metric to choose region membership is based on the minimum of:
    d = |<c>-c|/s + r|<v>-v|
for:
    c:      coordinates
    <c>:    region average coordinates.
    s:      image size.
    v:      density.
    <v>:    region average density.
    r:      ratio.

◆ label() [1/2]

string & Bimage::label ( )
inline

◆ label() [2/2]

void Bimage::label ( string  s)
inline

◆ largest()

void Bimage::largest ( Bimage p)

Selects the largest of each pixel from two images.

Parameters
*pother image.

◆ level_mask_extract()

Bimage * Bimage::level_mask_extract ( Bimage pmask,
int  fill_type = 0,
double  fill = 0 
)

Extracts all the regions associated with a multi-level mask.

Parameters
*pmaskmulti-level mask map.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue of edge voxels.
Returns
Bimage* image with excised regions.
The feature index is found in a feature map and the corresponding voxels
in the density maps are extracted.

◆ level_masked_stats()

int Bimage::level_masked_stats ( Bimage pmask)

Caclulates statistics for all the regions defined by a multi-level mask.

Parameters
*pmaskmulti-level mask map.
Returns
int 0.
The input data is replaced by the average for each region.
A linked image is created to hold the variance for each region.

◆ levelmask_add()

long Bimage::levelmask_add ( Bimage pmask,
int  add_level = 1 
)

Adds a bilevel mask to a level mask.

Parameters
pmaskbilevel mask to add.
add_levelthe level index to add.
Returns
long number of selected regions.
Where the bilevel mask is one, the level mask is set to given level value.

◆ levelmask_asymmetric_units()

Bimage * Bimage::levelmask_asymmetric_units ( Bsymmetry sym,
int  index 
)

Calculates a multi-level mask to indicate asymmetric units.

Parameters
*symsymmetry structure.
indexasu index (<1 means all).
Returns
Bimage* multi-level mask.
A reference view for each point group is generated such that it is
located close to the center of the canonical asymmetric unit.
A set of symmetry-related reference views are then generated from 
the original reference.
The distance of each voxel is then calculated to each reference
view, and assigned to asymmetric unit with the closest reference view.
If the given index is larger than one, a mask is generated only for the
asymmetric unit with that index. 

◆ levelmask_average_region_size()

double Bimage::levelmask_average_region_size ( )

Calculates the average size of regions in a level mask.

Returns
double average feature size.

◆ levelmask_clean()

long Bimage::levelmask_clean ( )

Removes empty levels from a multi-level mask.

Returns
long 0.
The mask is converted to an integer mask.

◆ levelmask_collapse()

long Bimage::levelmask_collapse ( )

Collapse a multi-level mask to a binary mask.

Returns
long number of voxels retained.
All non-zero segments are converted to ones.

◆ levelmask_color_by_size()

Bimage * Bimage::levelmask_color_by_size ( )

Color a multi-level mask based on the volumes of regions.

Returns
Bimage* new colored image.

◆ levelmask_colorize()

long Bimage::levelmask_colorize ( )

Colorizes a multi-level mask with random color assignments.

Returns
long number of levels.
A lookup table (LUT) is calculated for the range of gray-scale values
and random colors assigned to each value.
The image is then converted to RGB using the LUT.

◆ levelmask_combine()

long Bimage::levelmask_combine ( Bstring select_list)

Combines the selected levels in a multi-level mask and renumber.

Parameters
&select_listcomma_separated list of levels to select.
Returns
long number of voxels retained.
The new data replaces the old data.
The result is a multi-level mask where the selected levels are combined into one.
Image statistics are recalculated.

◆ levelmask_dilate() [1/2]

long Bimage::levelmask_dilate ( )

Dilates a level mask.

Returns
long 0.
Traditional 3^dim kernel dilation.  Any pixel with a value of 1 turns 
all of its neighbors to a value of 1.

◆ levelmask_dilate() [2/2]

long Bimage::levelmask_dilate ( int  times)

Dilates a level mask.

Parameters
timesnumber of dilation operations.
Returns
long 0.
Traditional 3^dim kernel dilation.  Any pixel with a value of 1 turns 
all of its neighbors to a value of 1.

◆ levelmask_region_size()

int Bimage::levelmask_region_size ( )

Convert a mask to reflect region sizes.

Returns
int 0.

◆ levelmask_select() [1/3]

long Bimage::levelmask_select ( Bimage pmask)

Selects regions overlapping a mask.

Parameters
pmaskoverlap template mask.
Returns
long number of selected regions.
The input mask can be of any form. All non-zero parts of this mask is used.

◆ levelmask_select() [2/3]

long Bimage::levelmask_select ( Bstring select_list,
int  flag = 0 
)

Retains the selected levels in a multi-level mask.

Parameters
&select_listcomma_separated list of levels to select.
flag0=binary mask, 1=multi-level mask.
Returns
long number of voxels retained.
The new data replaces the old data.
The result is either a binary mask (flag=0) or a multi-level mask where
the level indices changed to reflect the new range of selected levels (flag=1).
Image statistics are recalculated.

◆ levelmask_select() [3/3]

long Bimage::levelmask_select ( long  nn,
Vector3< long >  voxel 
)

Retains the selected levels in a multi-level mask.

Parameters
nnimage number.
voxelvoxel with level to select.
Returns
long number of voxels retained.
The new data replaces the old data.
Image statistics are recalculated.

◆ levelmask_size_histogram()

Bplot * Bimage::levelmask_size_histogram ( )

Color a multi-level mask based on the volumes of regions.

Returns
Bplot* region size histogram.

◆ levelmask_switch()

long Bimage::levelmask_switch ( long  index1,
long  index2 
)

Switches two segments in a multi-level mask.

Parameters
index1first index.
index2second index.
Returns
long number of levels.
If the two indices are not found, the mask is not modified.

◆ levelmask_symmetrize()

long Bimage::levelmask_symmetrize ( Bsymmetry sym)

Symetrizes a multi-level mask.

Parameters
sympoint group symmetry.
Returns
long maximum level index.

◆ limit_levels()

int Bimage::limit_levels ( int  nlevels)

Converts a full gray scale image to a limited level image.

Parameters
nlevelsnumber of levels.
Returns
int 0.
The dynamic range of the image is decreased to a given number of gray
scale levels.
The new data replaces the old data.
Image statistics are recalculated.

◆ line()

int Bimage::line ( Vector3< double >  start,
Vector3< double >  end,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Creates a line in an image and fills it with a constant value.

Parameters
startthree-value start of line.
endthree-value end of line.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
The edge of the area is smoothed with a function:
                    v_old(x,y,z) + fill*exp(1.618*dist/width)
    v_new(x,y,z) = ------------------------------------------
                           1 + exp(1.618*dist/width)
where   fill is the constant fill value.
        dist is the distance to the rectangular boundary defined by
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.

◆ line_powerspectra()

int Bimage::line_powerspectra ( fft_plan  plan)

Calculates the 1D power spectrum of each line in an image.

Parameters
planfft plan.
Returns
int 0.
Each line is transformed to a power spectrum in place.

◆ linear_fit()

double Bimage::linear_fit ( Bimage p,
Bimage pmask,
double  max_exclude 
)

Linear least squares fit of two images.

Parameters
*psecond image.
*pmaskmask to limit calculation to a certain region.
max_excludemaximum percentage of outlying points to exclude.
Returns
double first R factor.
The data blocks from two images are fit by a simple linear least squares
regression algorithm with exclusion of a percentage of outliers:
    image2 = intercept + slope * image1
The first image is modified to return the difference:
    difference = intercept + slope * image1 - image2
The residual returned is:
    R = sqrt(sum(difference^2) / sum((image2-avg2)^2))
Note: A linear fit is not symmetric with respect to the two input
data sets - the order of the input images determine the output.
The two data blocks must have the same size and are converted to
floating point.

◆ local_filter()

Bimage * Bimage::local_filter ( Bimage pmask,
int  mask_level,
Bimage resmap,
int  size,
Vector3< long >  vedge 
)

Applies a local resolution filter to a map.

Author
Giovanni Cardone and Bernard Heymann
Parameters
*pmaskmask of areas to generate.
mask_levelmask level.
*resmaplocal resolution map.
sizekernel size.
vedgeedge size.
Returns
Bimage* filtered image, NULL on error.
At each voxel, a kernel/small box is extracted and lowpass filtered
to the resolution limit for that voxel in the local resolution map.
A mask may be used to limit the region of application.

◆ logarithm()

void Bimage::logarithm ( )

Calculates the logarithm of the image data.

The image is first converted to floating point, or intensities
for complex data. The logarithm is calculated to place the minmum at
zero and scale it to the standard deviation:
                data - min
    new_data = log ------------- + 1
                   std
The new data replaces the old data.
Image statistics are recalculated.

◆ mask()

long Bimage::mask ( Bimage pmask,
double  fill 
)

Masks an image.

Author
Samuel Payne
Parameters
*pmaskbinary mask.
fillvalue to use where mask is zero.
Returns
long 0.
If the mask value for that pixel is 0, the image pixel is changed
to the fill value.  Otherwise it is left alone.

◆ mask_by_conditional_thresholds()

Bimage * Bimage::mask_by_conditional_thresholds ( vector< double >  threshold)

Generates a mask based on a conditional hierarchy of thresholds.

Parameters
thresholdarray of gray scale levels.
Returns
Bimage* unsigned char mask.
A multi-level mask is generated using the given threshold values.
Image statistics are recalculated.

◆ mask_by_threshold()

Bimage * Bimage::mask_by_threshold ( double  threshold)

Generates a mask based on an image at a given threshold.

Author
Samuel Payne & Bernard Heymann
Parameters
thresholdgray scale level.
Returns
Bimage* unsigned char mask.
A binary mask is generated using the given threshold.
Image statistics are recalculated.

◆ mask_by_thresholds()

Bimage * Bimage::mask_by_thresholds ( vector< double >  threshold)

Generates a mask based on an image at given thresholds.

Parameters
thresholdarray of gray scale levels.
Returns
Bimage* unsigned char mask.
A multi-level mask is generated using the given threshold values.
Image statistics are recalculated.

◆ mask_close()

long Bimage::mask_close ( int  times = 1)

Closes a binary mask.

Parameters
timesthe number of times to dilate and erode the mask.
Returns
long masked voxels.
Closing a mask is a dilation followed by an erosion.

◆ mask_combine()

long Bimage::mask_combine ( Bimage p,
int  operation 
)

Combines two masks with different operations.

Parameters
*psecond mask.
operationcombining operation.
Returns
Bimage* unsigned char mask.
The input images are assumed to be a masks of 0's and 1's and are
modified according to the operation requested:
    0   val1 = val2
    1   val1 = val1 and val2
    2   val1 = val1 or  val2
    3   val1 = val1 xor val2
where val1 and val2 are the data in the two images. 
Image statistics of the first image are recalculated.

◆ mask_dilate()

long Bimage::mask_dilate ( long  times = 1)

Dilates a binary mask.

Author
Samuel Payne & Bernard Heymann
Parameters
timesthe number of times to dilate the mask.
Returns
long masked voxels.
Traditional 3^dim kernel dilation.  Any pixel with a value of 1 turns 
all of its neighbors to a value of 1.

◆ mask_dilate_erode()

long Bimage::mask_dilate_erode ( unsigned char  dir)

Dilates or erodes a binary mask.

Author
Samuel Payne & Bernard Heymann
Parameters
dir0=erode, 1=dilate.
Returns
long masked voxels.
Traditional 3^dim kernel dilation.  Any pixel with a value of 1 turns 
all of its neighbors to a value of 1.

◆ mask_erode()

long Bimage::mask_erode ( long  times = 1)

Erodes a binary mask.

Author
Samuel Payne & Bernard Heymann
Parameters
timesthe number of times to erode the mask
Returns
long masked voxels.
Traditional 3^dim kernel erosion.  If all the neighboring pixels have
value of 1, then that pixel is left at 1. Otherwise it is changed to 0.

◆ mask_extract()

Bimage * Bimage::mask_extract ( Bimage pmask)

Zeroes everything outside the mask and return the excised feature.

Parameters
*pmaskmask.
Returns
Bimage* excised feature.
The mask must be the same size as the image.

◆ mask_fill()

long Bimage::mask_fill ( Vector3< long >  voxel)

Fills an empty part of a mask indicated by the given voxel.

Parameters
voxelpoint from which to fill the mask.
Returns
long masked voxels.

◆ mask_fspace_banded()

int Bimage::mask_fspace_banded ( vector< double > &  band)

Generate reciprocal space mask based on a specification of bands.

Parameters
&bandarray of number pairs, each a shell and value.
Returns
int 0.
The band argument is a list of pairs of values, each pair indicating
a resolution shell (in angstrom) and a flag indicating whether the 
following shells should be:
    0: excluded - also the high resolution limit
    1: included in the FOM
    -1: included in the cross-validation FOM
The high resolution limit for the mask is set in the image structure.

◆ mask_fspace_resize()

Vector3< double > Bimage::mask_fspace_resize ( Vector3< long >  nusize)

Resizes a reciprocal space mask.

Parameters
nusizenew mask size.
Returns
Vector3<double> scale.
The mask is assumed to be centered at (0,0,0).
The image is resized by inserting or removing
rows or columns in the middle of the data set.

◆ mask_interface_matrix()

Matrix Bimage::mask_interface_matrix ( int  img_num)

Calculates the interfaces between regions.

Parameters
img_numsub-image number.
Returns
Matrix interface matrix.
The mask must be an integer image.
An interface matrix is calculated to count the number of connected
voxels between every pair of regions.
Each value i in a row j gives the number of voxels of the region j that
are adjacent to one or more voxels in region i.
Row 0 and column 0 are excluded from the calculation.

◆ mask_invert()

long Bimage::mask_invert ( )

Inverts a mask.

Returns
long number of mask voxels.
The mask is assumed to be in range [0,1].
    new_mask = 1 - old_mask.
Image statistics of the mask are recalculated.

◆ mask_merge_delete()

long Bimage::mask_merge_delete ( long  min_size,
long  min_if 
)

Calculates the interfaces between regions and deletes/merges small ones.

Parameters
min_sizeminimum size to accept regions, small ones are deleted/merged.
min_ifminimum interface size to consider a small region connected.
Returns
long 0.
The mask is converted to an integer mask.
An interface matrix is calculated to count the number of connected
voxels between every pair of regions.
Regions that are smaller than the minimum size are either deleted or
merged with other regions.
If the maximum interface size for a small region is less than the minimum
specified, the region is deleted, otherwise, it is added to that
neighboring region with which it shares the biggest interface.

◆ mask_missing_cone()

long Bimage::mask_missing_cone ( Vector3< double >  ori,
double  mis_ang,
double  resolution 
)

Generates a mask with a missing cone.

Parameters
oriimage origin.
mis_angcone angle from xy plane.
resolutionhigh resolution limit.
Returns
long number of mask voxels.
The given image is used to generate a binary mask of the same size.
If the input origin is {0,0,0}, the origin in the image is used as 
the center for the missing part.

◆ mask_missing_find()

long Bimage::mask_missing_find ( Vector3< double >  ori,
double  resolution,
Bstring mis_type 
)

Generates a missing mask from an example image.

Parameters
oriimage origin.
resolutionhigh resolution limit.
mis_typemissing region type: wedge.
Returns
long number of mask voxels.
The given image is used to generate a binary mask of the same size.
If the input origin is {0,0,0}, the origin in the image is used as 
the center for the missing part.

◆ mask_missing_pyramid()

long Bimage::mask_missing_pyramid ( Vector3< double >  ori,
double  tilt_axis1,
double  tilt_axis2,
double  tilt_neg1,
double  tilt_pos1,
double  tilt_neg2,
double  tilt_pos2,
double  resolution 
)

Generates a mask with a missing pyramid.

Parameters
oriimage origin.
tilt_axis1tilt axis angle 1.
tilt_axis2tilt axis angle 2.
tilt_neg1negative tilt angle for axis 1.
tilt_pos1positive tilt angle for axis 1.
tilt_neg2negative tilt angle for axis 2.
tilt_pos2positive tilt angle for axis 2.
resolutionhigh resolution limit.
Returns
long number of mask voxels.
The given image is used to generate a binary mask of the same size.
If the input origin is {0,0,0}, the origin in the image is used as 
the center for the missing part.

◆ mask_missing_wedge()

long Bimage::mask_missing_wedge ( Vector3< double >  ori,
double  tilt_axis,
double  tilt_neg,
double  tilt_pos,
double  resolution 
)

Generates a mask with a missing wedge.

Parameters
oriimage origin.
tilt_axistilt axis angle.
tilt_negnegative tilt angle.
tilt_pospositive tilt angle.
resolutionhigh resolution limit.
Returns
long number of mask voxels.
The given image is used to generate a binary mask of the same size.
If the input origin is {0,0,0}, the origin in the image is used as 
the center for the missing part.

◆ mask_open()

long Bimage::mask_open ( int  times = 1)

Opens a binary mask.

Parameters
timesthe number of times to erode and dilate the mask.
Returns
long masked voxels.
Opening a mask is an erosion followed by a dilation.

◆ mask_pack_plane()

long Bimage::mask_pack_plane ( Matrix3  mat,
double  hi_res,
double  scale 
)

Packs a 2D mask into a 3D reciprocal space volume.

Parameters
mataffine orientation matrix.
hi_reshigh resolution limit.
scalescale.
Returns
long 0.
The rotation matrix is used to determine the plane in reciprocal space
to set as one.
Both the high resolution limit and the scale must correspond to the 
associated reconstruction.

◆ mask_plane()

long Bimage::mask_plane ( Vector3< double >  origin,
Vector3< double >  normal 
)

Generates a mask on one side of a plane.

Parameters
originany point on plane.
normalplane normal.
Returns
long 0.
The given image is used to generate a binary mask of the same size.

◆ mask_rectangle()

long Bimage::mask_rectangle ( double  length,
double  width,
double  rect_angle,
int  wrap 
)

Generates a mask along an axis within a 2D image.

Parameters
lengthlength along axis (pixels).
widthwidth perpendicular to axis (pixels).
rect_angleangle from x-axis (radians).
wrapflag to wrap around boundaries.
Returns
long 0.
The input image is assumed to be a mask of 0's and 1's and is modified
according to the operation requested.
Only an axis in the xy plane is used, generating a rectangular mask
of given length and width around the axis, with its center at the
origins given in the image structure.

◆ mask_region_interfaces()

long Bimage::mask_region_interfaces ( int  reg_num)

Reports the whole interface matrix or interfaces for one region only.

Parameters
reg_numregion to report for (<0 whole interface matrix).
Returns
long 0.
The mask is converted to an integer mask.
An interface matrix is calculated to count the number of connected
voxels between every pair of regions.

◆ mask_shell()

long Bimage::mask_shell ( Vector3< double >  origin,
double  rad_min,
double  rad_max 
)
inline

◆ mask_shell_wrap()

long Bimage::mask_shell_wrap ( Vector3< double >  origin,
double  rad_min,
double  rad_max 
)
inline

◆ mask_split()

long Bimage::mask_split ( long  voxels_per_level)

Converts a mask to a multilevel mask with a given number of voxels per level.

Parameters
voxels_per_levelnumber of voxels per level.
Returns
long number of voxels retained.
The new data replaces the old data.
Image statistics are recalculated.

◆ mask_stats()

long Bimage::mask_stats ( )

Calculates statistics for a mask.

Returns
long voxels in positive levels.
The mask can be any type, but the regions in the mask are rounded to
the nearest integer for counting statistics.

◆ mask_symmetrize()

long Bimage::mask_symmetrize ( Bsymmetry sym)

Symetrizes a mask.

Parameters
sympoint group symmetry.
Returns
long maximum level index.

◆ mass_at_threshold()

double Bimage::mass_at_threshold ( long  img_num,
double  threshold,
double  rho 
)

Calculates the mass from the density threshold.

Parameters
img_numsub-image number (first = 0).
thresholddensity threshold.
rhoprotein density in Da/A3.
Returns
double threshold.
An image is assumed to have density represented by higher (white) values.

◆ mass_threshold()

double Bimage::mass_threshold ( long  img_num,
double  mol_weight,
double  rho 
)

Finds the density threshold associated with a particular molecular weight.

Parameters
img_numsub-image number (first = 0,).
mol_weightmolecular weight.
rhoprotein density in Da/A3.
Returns
float threshold.
A threshold value is determined which contour a density such that
it corresponds to 100% of the given molecular weight.
An image is assumed to have density represented by higher (white) values.

◆ max_in_kernel()

int Bimage::max_in_kernel ( long  ksize)

◆ maximum() [1/2]

double Bimage::maximum ( )
inline

◆ maximum() [2/2]

void Bimage::maximum ( double  d)
inline

◆ maximum_included_radius()

double Bimage::maximum_included_radius ( )

Returns the radius of the enclosed sphere or circle.

Returns
double radius of largest sphere that will fit in an image.
Returns the radius of the largest sphere or circle that will fit
inside a three- or two-dimensional image, respectively, or the 
midpoint of a one-dimensional image.
Assumes that the x, y, and z dimensions are the number of data points
in those respective directions, and that the length (in pixels)
of the respective dimensions is x, y, or z minus one.  The minimum 
length is two times the radius of the largest sphere that will fit 
inside the image.

◆ median_bin()

int Bimage::median_bin ( int  binning)

Bins by an integer size, selecting the kernel median.

Parameters
binninginteger bin factor.
Returns
int 0.
An image is binned by an integer size, square in 2D and cubic in 3D.

◆ merge_amplitudes_and_phases() [1/2]

double Bimage::merge_amplitudes_and_phases ( Bimage pamp)

Merges the amplitudes from one map with the phases of another.

Parameters
*pampamplitude image (simple or complex).
Returns
double RMSD of amplitudes.
The amplitude image can be a floating point image or a complex image.
The phase image must be complex and its amplitudes are replaced by
the values from the amplitude image.
No statistics are calculated.

◆ merge_amplitudes_and_phases() [2/2]

double Bimage::merge_amplitudes_and_phases ( Bimage pref,
double  res_hi,
double  res_lo 
)

Keeps selected phases and replaces amplitudes and other phases from a reference transform.

Parameters
*prefreference Fourier transform.
res_hihigh resolution limit.
res_lolow resolution limit.
Returns
double RMSD of amplitudes.
The input transform is considered to be modified in some way (such as solvent flattening).
Only the phases in the specified resolution shell are kept, while all
the other phases and amplitudes within the high resolution limit is
retrieved from the reference transform.
No statistics are calculated.

◆ meta_data()

JSvalue & Bimage::meta_data ( )
inline

◆ meta_data_retain_one_image()

void Bimage::meta_data_retain_one_image ( long  img_num)

Erases all sub-image records from the meta data except one.

Parameters
img_numsub-image number.

◆ meta_data_update()

void Bimage::meta_data_update ( )

Update metadata from the sub-image information.

The sub-image information is encoded in the metadata in JSON format.

◆ minimum() [1/2]

double Bimage::minimum ( )
inline

◆ minimum() [2/2]

void Bimage::minimum ( double  d)
inline

◆ mirror()

int Bimage::mirror ( )

Inverts/mirrors each image through its origin.

Returns
int number of images.
Each image in a Bimage structure is inverted.

◆ moments() [1/2]

int Bimage::moments ( long  max_order)

Prints out moments for all sub-images.

Returns
int error code (<0 means failure).

◆ moments() [2/2]

int Bimage::moments ( long  max_order,
long  nn 
)

Prints out moments for one sub-image.

Parameters
max_ordermaximum order.
nnsub-image.
Returns
int error code (<0 means failure).

◆ montage()

Bimage * Bimage::montage ( int  first,
int  cols,
int  rows,
int  skip = 0,
int  flip = 0 
)

Rearranges an image into a montage of 2D slices for display.

Parameters
colscolumns in montage.
rowsrows in montage.
firstfirst slice in montage.
skipnumber of slices to skip.
flipflip the order of panels on: 1=x axis, 2=y axis.
Returns
Bimage* montaged image.
The slices of a 3D image are packed into a 2D montage.
The background value for the image is used for empty regions.

◆ moving_sum()

Bimage * Bimage::moving_sum ( long  window,
long  step = 1,
int  flag = 0 
)

Calculates a moving sum of the sub-images.

Parameters
windownumber of successive images to sum.
stepintervals between windows.
flagif set, calculate average.
Returns
Bimage* moving sum/average image.
Each successive subset of sub-images of size set by the window parameter are summed.
Where the window extends beyond the limits for the number of images,
the summation is just over the existing images.
The number of images depends on the step size.

◆ multi_channel_to_complex()

void Bimage::multi_channel_to_complex ( )

A multi-channel image is converted to a set of complex images.

The input image channels are written into the real part of the complex image.

◆ multiply() [1/6]

void Bimage::multiply ( Bimage p)

Multiplies all sub-images with the first sub-image of the other image.

Parameters
*pimage multiplier.
The other image is multiplied with the first.
Both images are converted to floating point.

◆ multiply() [2/6]

void Bimage::multiply ( Bimage p,
double  scale,
double  shift = 0 
)

Multiplies an image with another image.

Parameters
*pimage multiplier.
scaledensity scale to other image
shiftdensity shift to other image.
Requirement: The images must have the same size.

◆ multiply() [3/6]

void Bimage::multiply ( double  v)

Multiplies an image with a constant value.

Parameters
vconstant multiplier.

◆ multiply() [4/6]

void Bimage::multiply ( long  j,
Complex< double >  cv 
)
inline

◆ multiply() [5/6]

void Bimage::multiply ( long  nn,
Bimage p 
)

Multiplies a sub-image with another image.

Parameters
nnsub-image to multiply.
*pimage multiplier.
Requirement: The images must have the same size.

◆ multiply() [6/6]

void Bimage::multiply ( long  nn,
double  v 
)

Multiplies a sub-image with a constant value.

Parameters
nnsub-image.
vconstant multiplier.

◆ nad()

Bimage * Bimage::nad ( double  ht,
long  zw,
double  lambda,
double  C,
double  alpha 
)

Denoises a 3D density map by non-linear anisotropic diffusion.

Parameters
httime step size, 0 < ht <= 0.25.
zwslab size for piece-wise denoising.
lambdalamda parameter for EED.
Ccoherence parameter for CED.
alpha.
Returns
Bimage* new image.
The diffusion tensor is calculated with the aim of enhancing edges (EED)
or planes (CED).

◆ nad_2D()

Bimage * Bimage::nad_2D ( double  ht,
double  lambda,
double  C,
double  alpha 
)

Denoises a 2D image by non-linear anisotropic diffusion.

Parameters
httime step size, 0 < ht <= 0.25.
lambdalamda parameter for EED.
Ccoherence parameter for CED.
alpha.
Returns
Bimage* new image.
The diffusion tensor is calculated with the aim of enhancing edges (EED)
or planes (CED).

◆ noise_gaussian()

int Bimage::noise_gaussian ( double  ravg = 0,
double  rstd = 1 
)

Generates an image with a gaussian random distribution of densities.

Parameters
ravgaverage.
rstdstandard deviation.
Returns
int 0.
The image is populated with densities with a gaussian distribution with a given
average and standard deviation:
    density = average + std_dev*sqrt(-2*log(random_value))*
                    cos(2*PI*random_value);
where random_value is between 0 and 1.
The output image is floating point.
Statistics are calculated before returning.

◆ noise_gaussian_distance()

int Bimage::noise_gaussian_distance ( long  number,
double  stdev 
)

Generates an image based on a gaussian random distribution of distances.

Parameters
numbernumber of hits to place
stdevstandard deviation.
Returns
int 0.
The image is populated with single hits at distances with
a uniform random distrubution within the image boundaries.
Statistics are calculated before returning.

◆ noise_logistical()

int Bimage::noise_logistical ( double  ravg,
double  rstd 
)

Generates an image with a gaussian random distribution of densities.

Parameters
ravgaverage.
rstdstandard deviation.
Returns
int 0.
The image is populated with densities with a logistical differential distribution
with a given average and standard deviation:
    density = average + (std_dev/golden)*ln(1/random_value - 1)
where random_value is between 0 and 1 and:
    golden  = (sqrt(5) + 1)/2
The output image is floating point.
Statistics are calculated before returning.
Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ noise_poisson()

int Bimage::noise_poisson ( double  ravg)

Generates an image with a poisson random distribution of densities.

Parameters
ravgaverage.
Returns
int 0.
Algorithm taken from Numerical Recipes in C.
The poisson distribution is given for j = 0,1,... by:
            avg^j * exp(-avg)
    P(j) = -----------------
                   j!
Note that only positive integer values are defined for j and sum(P(j)) = 1.
An array of floating point numbers is generated with a poisson 
distribution with a given average. The standard deviation is:
    std = sqrt(avg)
If the average <= 0, the function exits.
Statistics are calculated before returning.
Reference: Press W.H. et al (1992) Numerical Recipes in C.

◆ noise_spectral()

int Bimage::noise_spectral ( double  alpha)

Generates a noise map with a defined spectral decay.

Parameters
alphaspectral decay.
Returns
int 0.
Uniform random phases are generated and the amplitudes are set to:
    amp = s^(-alpha/2).

◆ noise_uniform()

int Bimage::noise_uniform ( double  rmin,
double  rmax 
)

Generates an image with a uniform random distribution of densities.

Parameters
rminminimum density value.
rmaxmaximum density value.
Returns
int 0.
The image is populated with densities distributed uniformly in the range of the
given minimum and maximum:
    density = random_value*(max - min) + min
where random_value is between 0 and 1.
The average and standard deviation are:
    average = (max + min)/2
    standard deviation = 0.5*sqrt(1/3)*(max - min).
The output image is floating point.
Statistics are calculated before returning.

◆ noise_uniform_distance()

int Bimage::noise_uniform_distance ( long  number)

Generates an image based on a uniform random distribution of distances.

Parameters
numbernumber of hits to place
Returns
int 0.
The image is populated with single hits at distances with a uniform random distrubution
within the image boundaries.
Statistics are calculated before returning.

◆ normalize() [1/2]

int Bimage::normalize ( double  average,
double  stdev,
int  norm_type 
)

Normalizes a set of images to a desired average and standard deviation.

Parameters
averagedesired average.
stdevdesired standard deviation (if 0, use defaults).
norm_typetype of determining the effective average and standard deviation: 0=simple, 1=Gaussian, 2=Poisson.
Returns
int 0.
The effective average and standard deviation for each image is obtained
in one of three ways:
    0.      The simple avergae and standard devaition for the image.
    1.      Gaussian fit of the histogram.
    2.      Poisson fit of the histogram.
A histogram of an image is calculated with a given number of bins.
The histogram is fit to a Gaussian or Poisson function with exclusion of a
small number of bins in the histogram (defined as outliers).
The effective average and standard deviation are used to 
rescale the data for each image.

◆ normalize() [2/2]

int Bimage::normalize ( long  imgnum,
double  average,
double  stdev,
int  norm_type,
long  bins 
)

Normalizes a sub-image to a desired average and standard deviation.

Parameters
imgnumsub-image number.
averagedesired average.
stdevdesired standard deviation (if 0, use defaults).
norm_typetype of determining the effective average and standard deviation: 0=simple, 1=Gaussian, 2=Poisson.
binsnumber of histogram bins required to fit distributions.
Returns
int 0.
The effective average and standard deviation for each image is obtained
in one of three ways:
    0.      The simple avergae and standard devaition for the image.
    1.      Gaussian fit of the histogram.
    2.      Poisson fit of the histogram.
A histogram of an image is calculated with a given number of bins.
The histogram is fit to a Gaussian or Poisson function with exclusion of a
small number of bins in the histogram (defined as outliers).
The effective average and standard deviation are used to 
rescale the data for each image.

◆ normalize_local() [1/2]

int Bimage::normalize_local ( long  kernel_size)

Normalizes by subtracting local average and dividing by local standard deviation.

Parameters
kernel_sizesize of kernel edge.
Returns
int 0.
The local average and standard deviation within a kernel is calculated 
and used to normalize the image.
The convolution is threaded if compiled with GCD or OpenMP.

◆ normalize_local() [2/2]

int Bimage::normalize_local ( Vector3< long >  kernel)

Normalizes by subtracting local average and dividing by local standard deviation.

Parameters
kernelsize of kernel edge.
Returns
int 0.
The local average and standard deviation within a kernel is calculated 
and used to normalize the image.
The convolution is threaded if compiled with GCD or OpenMP.

◆ one_color()

int Bimage::one_color ( int  color,
double  cmin,
double  cmax,
int  flag = 0 
)

Converts a gray-scale image to a single color.

Parameters
colorcolor selection (0=red, 1=green, 2=blue).
cminlower grayscale boundary.
cmaxupper grayscale boundary.
flagsets the type of conversion.
Returns
int 0.
A grayscale image is converted to a selected color between the given minimum and maximum.
The flag parameter bit:
    bit 1       calculate a subtractive color range.
    bit 2       keep the ranges beyond the minimum and maximum as gray

◆ operator+()

Bimage * Bimage::operator+ ( Bimage p)

Adds two images together, adjusting for size difference.

Parameters
&pimage to add.
Returns
Bimage* summed image, NULL on error.
The second image is added to the first:
    image1 = image1 + image2*scale + shift
The resultant image size is the bigger of the two.

◆ operator=()

Bimage & Bimage::operator= ( const Bimage p)

Assigns an image.

The internal copy function is called.

◆ operator[]() [1/2]

double Bimage::operator[] ( long  j) const

Returns the data value at the given index.

Parameters
jindex.
Returns
double value.
The elemental data value is returned in double precision.

◆ operator[]() [2/2]

JSvalue & Bimage::operator[] ( string  tag)
inline

◆ opposite_ewald()

int Bimage::opposite_ewald ( )

◆ orient()

Bimage * Bimage::orient ( View views)

Calculates multiple copies oriented according to views.

Parameters
viewsorientations for new images.
Returns
Bimage* new set of images.
Each image in a Bimage structure is rotated to the corresponding view.

◆ origin() [1/6]

void Bimage::origin ( double  ox,
double  oy,
double  oz 
)
inline

◆ origin() [2/6]

void Bimage::origin ( long  nn,
double  ox,
double  oy,
double  oz 
)
inline

◆ origin() [3/6]

void Bimage::origin ( long  nn,
Vector3< double >  vec 
)
inline

◆ origin() [4/6]

void Bimage::origin ( long  nn,
vector< double >  ori 
)
inline

◆ origin() [5/6]

void Bimage::origin ( Vector3< double >  vec)
inline

◆ origin() [6/6]

void Bimage::origin ( vector< double >  vec)
inline

◆ orthogonal_montage()

Bimage * Bimage::orthogonal_montage ( Vector3< long >  voxel,
Vector3< long >  ext_size,
int  pad = 0,
int  fill_type = 0,
double  fill = 0 
)

Extracts orthogonal views around a voxel and create a montage.

Parameters
voxelvoxel of intersection.
ext_sizesize of slices to extract.
padpadding size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
Bimage* extracted slice for 2D and 3 slices for 3D.
Only the desired region is extracted from the original image.
The fill value is taken from the image background.

◆ orthogonal_slices()

Bimage * Bimage::orthogonal_slices ( long  nn,
Vector3< long >  voxel,
Vector3< long >  ext_size 
)

Extracts orthogonal views around a voxel.

Parameters
nnimage number to extract.
voxelvoxel of intersection.
ext_sizesize of slices to extract.
Returns
Bimage* extracted slice for 2D and 3 slices for 3D.
Only the desired region is extracted from the original image.
The fill value is taken from the image background.

◆ otsu_threshold()

double Bimage::otsu_threshold ( long  bins)

Calculates the threshold from a histogram according to Otsu.

Parameters
binsnumber bins in histogram.
Returns
double threshold.
Reference: NOBUYUKI OTSU, IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICS, VOL. SMC-9, NO. 1, JANUARY 1979

◆ otsu_variance()

vector< double > Bimage::otsu_variance ( vector< long >  h)

Calculates the inter-set variance of the bisection of a historgram using the method of Otsu.

Parameters
hhistogram.
Returns
vector<double> variance.
Reference: NOBUYUKI OTSU, IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICS, VOL. SMC-9, NO. 1, JANUARY 1979

◆ pack_transform() [1/2]

int Bimage::pack_transform ( int  img_select,
unsigned char *  data,
FourierType  tf 
)

◆ pack_transform() [2/2]

int Bimage::pack_transform ( unsigned char *  data,
FourierType  tf 
)

◆ pack_two_in_complex()

Bimage * Bimage::pack_two_in_complex ( Bimage p)

Packs two real images into one complex image.

Parameters
*psecond image.
Returns
Bimage* the new complex image, NULL on error.
Two real space images are packed into the real and imaginary parts
of a new data block with conversion from the original non-complex type.
The header values of the first image are adopted for the new image.
No statistics are calculated.

◆ pad() [1/2]

int Bimage::pad ( long  sz,
int  fill_type = 0,
double  fill = 0 
)

Pads an image to a new size with a given fill value.

Parameters
sznew size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to use when padding the image.
Returns
int 0.
The image is enlarged with padding only on one side in each
dimension with an input size greater than one.
The data type is preserved.

◆ pad() [2/2]

int Bimage::pad ( Vector3< long >  sz,
int  fill_type = 0,
double  fill = 0 
)

Pads an image to a new size with a given fill value.

Parameters
sznew size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to use when padding the image.
Returns
int 0.

The image is enlarged with padding only on one side in each dimension with an input size greater than one. The data type is preserved.

◆ pad_copy() [1/2]

Bimage * Bimage::pad_copy ( long  sz,
int  fill_type = 0,
double  fill = 0 
)

Pads an image to a new size with a given fill value.

Parameters
sznew size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to use when padding the image.
Returns
Bimage* resized image.
The image is enlarged with padding only on one side in each
dimension with an input size greater than one.
The data type is preserved.

◆ pad_copy() [2/2]

Bimage * Bimage::pad_copy ( Vector3< long >  sz,
int  fill_type = 0,
double  fill = 0 
)

Pads an image to a new size with a given fill value.

Parameters
sznew size.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to use when padding the image.
Returns
Bimage* resized image.

The image is enlarged with padding only on one side in each dimension with an input size greater than one. The data type is preserved.

◆ page_size() [1/4]

Vector3< long > Bimage::page_size ( )
inline

◆ page_size() [2/4]

void Bimage::page_size ( long  nx,
long  ny,
long  nz 
)
inline

◆ page_size() [3/4]

void Bimage::page_size ( Vector3< long >  vec)
inline

◆ page_size() [4/4]

void Bimage::page_size ( vector< long >  vec)
inline

◆ peak_sigma()

double Bimage::peak_sigma ( long  nn,
Vector3< long >  coor,
long  kernel_size 
)

Calculates a sigma value for a cross-correlation peak.

Parameters
nnsub-image.
coorcoordinates in the image.
kernel_sizekernel size to fit the gaussian.
Returns
double sigma value.
The peak is assumed to be close to a gaussian.
The sigma is calculated for each kernel location and averaged:
    sigma = sqrt(rad^2/2(ln(vmax)-ln(v)))

◆ percentiles()

Bplot * Bimage::percentiles ( )

Calculates the percentiles from the histogram of an image.

Returns
Bplot* plot of the percentiles.
A histogram of an image is calculated with 10000 bins.
The percentiles are calculated from the running sum of the histogram
and returned in a plot.

◆ periodic_averaging()

Bimage * Bimage::periodic_averaging ( Vector3< double >  period)

Calculates an average within a periodic frame.

Parameters
periodsize of periodic frame.
Returns
Bimage* new image.

◆ phase_add()

void Bimage::phase_add ( double  v)

Adds a constant value to a phase image and wraps as necssary.

Parameters
vconstant to be added.

◆ phase_colour_wheel()

int Bimage::phase_colour_wheel ( )

Generates a phase color wheel.

Returns
int 0.
The image is filled with a color wheel where the location (x,y) 
is converted to polar form:
    a = arctan(y/x)
    r = sqrt(x^2+y^2)
The color is a function of the angle a and saturation is a function
of the distance from the origin.

◆ phase_correlate()

Bimage * Bimage::phase_correlate ( Bimage p,
double  hires,
double  lores,
Bimage pmask = NULL 
)

Calculates a phase correlation map by Fast Fourier transformation.

Parameters
*psecond image.
hireshigh resolution limit.
loreslow resolution limit.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
Bimage* cross-correlation image.
FFTW library (www.fftw.org).
Two equally sized multi-image 1D, 2D and 3D real space data sets are
packed into a complex data set and transformed forward. The transform
is unpacked before the first transform is multiplied with the complex
conjugate of the second transform. This is then back-transformed to
obtain the phase correlation map in real space.
The low resolution limit can be 0, in which case no limits are applied.
The resultant phase correlation image data type is floating point.

◆ phase_difference()

Bimage * Bimage::phase_difference ( Bimage p,
int  type = 0,
double  res_hi = 0,
double  res_lo = 0 
)

Calculates the cosine of the phase difference between two images.

Parameters
*preal space reference image.
type0=phase angle difference, 1=phase angle sum, 2=cos(angle), 4=scale by amplitude product
res_hiupper resolution limit.
res_lolower resolution limit.
Returns
Bimage* phase difference image.
Both images are Fourier transformed and the cosine of the phase
difference calculated.

◆ phase_flip()

int Bimage::phase_flip ( Bimage pd)

Flips the phases of an image based on a phase difference map.

Parameters
*pdreciprocal space phase difference map.
Returns
int 0.

◆ phase_shift() [1/2]

int Bimage::phase_shift ( long  nn,
Vector3< double >  shift 
)

Phase shifts a complex sub-image.

Parameters
nnsub-image to transform.
shiftthree-value real space shift vector.
Returns
int error code.
A real space translation with wrapping is equivalent to phase shifting
in reciprocal space.

◆ phase_shift() [2/2]

int Bimage::phase_shift ( Vector3< double >  shift)

Phase shifts a complex image.

Parameters
shiftthree-value real space shift vector.
Returns
int error code.
A real space translation with wrapping is equivalent to phase shifting
in reciprocal space.

◆ phase_shift_to_center()

int Bimage::phase_shift_to_center ( )

Phase shifts a set of reflections to the nominal center of the image origin.

Returns
int 0.
A real space translation with wrapping is equivalent to phase shifting
in reciprocal space. The phases are shifted based on the embedded
sub-image origins.

◆ phase_shift_to_origin()

int Bimage::phase_shift_to_origin ( )

Phase shifts a set of reflections to the image origin.

Returns
int 0.
A real space translation with wrapping is equivalent to phase shifting
in reciprocal space. The phases are shifted based on the embedded
sub-image origins.

◆ phase_to_complex()

void Bimage::phase_to_complex ( )

A phase image is converted to a complex image.

◆ place()

int Bimage::place ( long  nn,
Bimage p,
Vector3< double >  loc,
double  radius = 0,
double  scale = 1,
double  shift = 0,
int  operation = 0 
)

Places a small image into a large image.

Parameters
nnsub-image.
*pimage to place.
loclocation in large image of small image origin.
radiusradial mask to transfer small image.
scaledensity scale to apply to second image.
shiftdensity shift to apply to second image.
operationoperation to apply.
Returns
int 0, <0 if error.
The small image is placed with its origin at given origin in the large image.
The second image is scaled and shifted before placing into the first:
    image1 = image1 + image2*scale + shift
Both images are converted to floating point.
The operation can be selected:
    0   simple addition.
    1   replace if smaller.
    2   replace if larger.
Requirement: Both images must have the same pixel size.

◆ place_central_part()

int Bimage::place_central_part ( Bimage p,
long  nn 
)

Packs a tile into a new composite image, retaining only the central part.

Parameters
*pimage = tiles.
nntile image (can be a sub-image).
Returns
int 0.
The overlaps between tiles are divided between the neighboring tiles.
The tile placement is in the sub-image origins.

◆ place_with_addition()

int Bimage::place_with_addition ( Bimage p,
long  nn 
)

Packs a tile into a new composite image with addition within overlap.

Parameters
*pimage = tiles.
nntile image (can be a sub-image).
Returns
int 0.
The tiles are added to the image.
The contributions at each voxel are counted in a linked image.
The tile placement is in the sub-image origins.

◆ place_with_overlap()

int Bimage::place_with_overlap ( Bimage p,
long  nn 
)

Packs a tile into a new composite image with weighted overlap.

Parameters
*pimage = tiles.
nntile image (can be a sub-image).
Returns
int 0.
The overlaps between tiles are filled in with a weighted average based
on a linear transition from one to the other.
The tile placement is in the sub-image origins.

◆ plot()

Bplot * Bimage::plot ( )

Converts a one-dimensional image into a plot.

Returns
Bplot* plot structure.

Each image generates one plot with each channel converted to a curve.

◆ poisson_statistics_check()

double Bimage::poisson_statistics_check ( )

Checks whether the statistics conform to a Poisson distribution.

Returns
double variance-to-average scale.
A warning is issued when the variance/average differs more than 5% from one.

◆ polar_power_spectrum()

Bimage * Bimage::polar_power_spectrum ( double  resolution,
long  num_angle 
)

Calculates the polar power spectrum of a 2D transform amplitude or intensity image.

Parameters
resolutionhigh resolution limit.
num_anglenumber of angles to use for interpolation.
Returns
Bimage* polar power spectrum.
The length of each annulus is number of angles times the radial offset.
The samples on each annulus are calculated by bilinear interpolation.
The maximum annulus calculated depends on the resolution limit specified
in the input image.

◆ polar_transform()

Bimage * Bimage::polar_transform ( long  nangles,
long  ann_min,
long  ann_max,
long  dann,
long  zmin,
long  zmax,
long  zinc 
)

Calculates an image with cylindrical coordinates by integration.

Parameters
nanglesnumber of angles in each annulus.
ann_minminimum annulus (pixels).
ann_maxmaximum annulus (pixels).
dannwidth of annulus (pixels).
zminminimum z (pixels).
zmaxmaximum z (pixels).
zincincrement in z (pixels).
Returns
Bimage* cylindrical image.
The image is converted to cylindrical form by integrating blocks 
    with a defined annular width and thickness in z at each angle. 
The resultant image contains lines corresponding to integrated blocks
    covering 360° of angle.
The sampling must be isotropic.
The origins within the sub-image structures are used.
The interpolation routine actually calculates the old cartesian 
coordinates for each set of cylindrical coordinates.

◆ power()

void Bimage::power ( double  v)

Calculates the power of an image.

Parameters
vpower value.

◆ power_spectrum()

int Bimage::power_spectrum ( int  flags = 0)

Calculates a power spectrum.

Parameters
flags1=norm, 2=avg, 4=shift, 8=log.
Returns
int error code.
All the sub-images are Fourier transformed.
The flags variable controls options based on which bits are set:
    1   normalize image before transformation
    2   average all power spectra
    4   shift the origin to the center
    8   calculate the logarithm of the power spectrum
    16  do edge smoothing to get rid of the cross artifact
    32  fix peaks on the horizontal zero-line
    64  fix peaks on the vertical zero-line

◆ powerspectrum_isotropy()

vector< double > Bimage::powerspectrum_isotropy ( long  n,
double &  lores,
double &  hires 
)

Calculates a measure of anisotropy in a power spectrum.

Parameters
nsub-image number.
&loreslow resolution limit.
&hireshigh resolution limit
Returns
vector<double> 3-vlaue vector: power average and deviation and maximum power angle. The power between the indicated resolution shells are averaged for each angle and fitted to an equation for anisotropy: P = Pavg + Pdev*cos(2(a-phi)) where phi is the direction of maximum power.

◆ powerspectrum_tiled()

Bimage * Bimage::powerspectrum_tiled ( long  img_num,
Vector3< long >  tile_size,
int  flags = 0 
)

Prepares a tiled power spectrum from an image for determining CTF parameters.

Parameters
img_numsub-image to transform.
tile_sizetile size (if (0,0,0) don't tile).
flags1=norm, 2=avg, 4=shift, 8=log.
Returns
Bimage* power spectrum.
A large single image (a micrograph) is converted to a number of tiles
packed into a multi-image structure.
All the sub-images are Fourier transformed and the power spectra calculated.
The flag indicates if the images are normalized, averaged, shifted and
the logarithm calculated

◆ powerspectrum_tiled_and_tilted()

Bimage * Bimage::powerspectrum_tiled_and_tilted ( Vector3< long >  tile_size,
double  tilt_axis,
double  tilt_angle,
double  tilt_offset,
double  defocus,
double  iCL2,
int  flags = 0 
)

Prepares a tiled powerspectrum from a tilted image for determining CTF parameters.

Parameters
tile_sizetile size (if (0,0,0) don't tile).
tilt_axistilt axis angle (in radians).
tilt_angletilt angle (in radians).
tilt_offsetoffset perpendicular to tilt axis (in pixels).
defocusaverage defocus to adjust for change in focus.
iCL2inverse of product of spherical aberration and wavelenght squared.
flags1=norm, 2=avg, 4=shift, 8=log, 16=add.
Returns
Bimage* power spectrum.
A large single image (a micrograph) is converted to a number of tiles
packed into a multi-image structure.
All the sub-images are Fourier transformed and the power spectra calculated.
The power spectra are scaled based on the tilt and average defocus of the image.
The flag indicates if the images are normalized, averaged, shifted and
the logarithm calculated

◆ powerspectrum_tiled_exact()

Bimage * Bimage::powerspectrum_tiled_exact ( long  img_num,
Vector3< long >  tile_size,
int  flags = 0 
)

◆ powerspectrum_tilt_axis()

Bimage * Bimage::powerspectrum_tilt_axis ( long  img_num,
Vector3< long >  tile_size,
double  tilt_axis,
double  tilt_offset,
int  flags = 0 
)

Prepares a tiled powerspectrum from a tilted image for determining CTF parameters.

Parameters
img_numsub-image to transform.
tile_sizetile size (if (0,0,0) don't tile).
tilt_axistilt axis angle (in radians).
tilt_offsetoffset perpendicular to tilt axis (in pixels).
flags1=norm, 2=avg, 4=shift, 8=log.
Returns
Bimage* power spectrum.
A large single image (a micrograph) is converted to a number of tiles
along the tilt axis packed into a multi-image structure.
All the sub-images are Fourier transformed and the power spectra calculated.
The flag indicates if the images are normalized, averaged, shifted and
the logarithm calculated

◆ powerspectrum_tilted()

Bimage * Bimage::powerspectrum_tilted ( long  img_num,
Vector3< long >  tile_size,
double  tilt_axis,
double  tilt_angle,
double  defocus,
double  iCL2,
int  flags = 0 
)

Prepares a tiled powerspectrum from a tilted image for determining CTF parameters.

Parameters
img_numsub-image to transform.
tile_sizetile size (if (0,0,0) don't tile).
tilt_axistilt axis angle (in radians).
tilt_angletilt angle (in radians).
defocusaverage defocus to adjust for change in focus.
iCL2inverse of product of spherical aberration and wavelenght squared.
flags1=norm, 2=avg, 4=shift, 8=log.
Returns
Bimage* power spectrum.
A large single image (a micrograph) is converted to a number of tiles
packed into a multi-image structure.
All the sub-images are Fourier transformed and the power spectra calculated.
The power spectra are scaled based on the tilt and average defocus of the image.
The flag indicates if the images are normalized, averaged, shifted and
the logarithm calculated

◆ pps_angular_correlation()

vector< double > Bimage::pps_angular_correlation ( Bimage pref,
double  res_hi,
double  res_lo,
long  nang,
fft_plan  planf 
)

◆ progressive_sum()

void Bimage::progressive_sum ( )

Progressive sum of the sub-images.

Each sub-image is summed with all previous sub-images.

◆ project() [1/3]

Bimage * Bimage::project ( char  axis,
int  flags = 1 
)

Projects a 3D image to a 2D image down one of the three major axes.

Parameters
axisaxis of projection.
flags1=scale projection, 2=minimum, 4=maximum.
Returns
Bimage* projection image (floating point).
The sums of the z-planes are accumulated into a new floating point data 
block.  This block is then rescaled and converted back to the original 
data type.
The new data replaces the old data.

◆ project() [2/3]

Bimage * Bimage::project ( View view,
double  resolution,
FSI_Kernel kernel,
double  wavelength = 0,
bool  back = 1,
ComplexConversion  conv = NoConversion 
)

Calculates a set of projections as central sections from a 3D fourier transform.

Parameters
*viewlinked list of views.
resolutionhigh resolution limit.
*kernelfrequency space interpolation kernel.
wavelengthfor Ewald sphere projection, default zero, ± for front or back curvature.
backflag to backtransform the projections.
convconversion type.
Returns
Bimage* projections as sub-images.
The map is Fourier transformed and shifted to its phase origin.
For each view, a central section or Ewald sphere projection is calculated using reciprocal space interpolation.
All the projections are phase shifted to a central origin.
The projections may be back-transformed to real space as specified by the back flag.
The image is converted as specified by the conversion flag:
    0   no conversion.
    1   real.
    2   imaginary.
    3   amplitude.
    4   intensity.

◆ project() [3/3]

Bimage * Bimage::project ( View view,
int  norm_flag = 1 
)

Calculates a set of projections from a 3D density map.

Parameters
*viewlinked list of views.
norm_flagflag to normalize projection.
Returns
Bimage* projections as sub-images.
A set of projections is calculated according to a list of views.

◆ pure_color()

int Bimage::pure_color ( )

Generates a pure color image without intensity.

Returns
int 0.
Pure color is defined as:
            col
    col = --------
          sum(col)

◆ quadric()

int Bimage::quadric ( double *  param)

Generates a quadric surface over the whole image.

Parameters
param7-value array of parameters.
Returns
int 0.

◆ quadric_correct()

int Bimage::quadric_correct ( vector< double >  param)

Corrects for a quadric surface.

Parameters
param7-value array of parameters.
Returns
int error code.

◆ quadric_fit()

vector< double > Bimage::quadric_fit ( )

Fits the whole image to a quadric surface.

Returns
vector<double> 7-value array of parameters.
A quadric surface is defined as:
v = a0 + a1*dx + a2*dy + a3*dz + a4*dx^2 + a5*dy^2 + a6*dz^2

◆ query()

vector< JSvalue * > Bimage::query ( string &  path)
inline

◆ R_factor()

double Bimage::R_factor ( Bimage p)

Calculates an R factor between two images.

Parameters
*psecond image.
Returns
double R factor, -1 if not run.
The difference between two images is calculated and normalized as:
                          sum(image1 - image2)^2
    R = sqrt(-------------------------------------------------)
             sqrt(sum(image1 - avg1)^2 * sum(image2 - avg2)^2)
Both images are converted to floating point.

◆ radial() [1/3]

Bimage * Bimage::radial ( long  minrad,
long  maxrad,
double  rad_step,
Bimage pmask,
int  wrap = 0 
)

Calculates the radial average of an image.

Parameters
minradminimum radius in voxels.
maxradmaximum radius in voxels.
rad_stepstep size in voxels.
*pmaskmask to limit calculation.
wrapflag to wrap the data.
Returns
Bimage* radial average in the form of a 1D image.
A radial average of a 2D or 3D image is calculated between a minimum
and maximum radius.  An interpolative method is used where the value of 
a voxel is distributed between the two nearest radial annuli.
The final sum in an annulus is normalized by the number of voxels 
contributing to the annulus sum.
The origins within the sub-image structures are used.

◆ radial() [2/3]

Bimage * Bimage::radial ( long  minrad,
long  maxrad,
double  rad_step,
double  ellipticity,
double  angle,
Bimage pmask,
int  wrap = 0 
)

Calculates the radial average of an image.

Parameters
minradminimum radius in voxels.
maxradmaximum radius in voxels.
rad_stepstep size in voxels.
ellipticityratio of major and minor axes.
angleangle of major axis.
*pmaskmask to limit calculation.
wrapflag to wrap the data.
Returns
Bimage* radial average in the form of a 1D image.
A radial average of a 2D or 3D image is calculated between a minimum
and maximum radius.  An interpolative method is used where the value of 
a voxel is distributed between the two nearest radial annuli.
The final sum in an annulus is normalized by the number of voxels 
contributing to the annulus sum.
The origins within the sub-image structures are used.

◆ radial() [3/3]

Bimage * Bimage::radial ( long  minrad,
long  maxrad,
double  rad_step = 1,
int  wrap = 0 
)

Calculates the radial average of an image.

Parameters
minradminimum radius in voxels.
maxradmaximum radius in voxels.
rad_stepstep size in voxels.
wrapflag to wrap the data.
Returns
Bimage* radial average in the form of a 1D image.
A radial average of a 2D or 3D image is calculated between a minimum
and maximum radius.  An interpolative method is used where the value of 
a voxel is distributed between the two nearest radial annuli.
The final sum in an annulus is normalized by the number of voxels 
contributing to the annulus sum.
The origins within the sub-image structures are used.

◆ radial_coverage()

Bimage * Bimage::radial_coverage ( double  threshold,
double  rad_step = 1 
)

Calculates the coverage in each radial shell.

Parameters
thresholddensity threshold to distinguish for- and background.
rad_stepradial step size (voxels).
Returns
int 0.

◆ radial_fit()

double * Bimage::radial_fit ( Bimage pref)

Fits a radial profile to a reference radial profile.

Parameters
*prefreference radial profile as a 1D image.
Returns
double* 3-value result vector: dimension scale, amplitude scale and amplitude shift.
A radial profile is fitted to a reference profile using an iterative
simplex down-hill method.  The equations solved are:
    x(new) = x(old)*m
    y(new) = y(old)*a + b
where   m is the dimension scaling (or magnification).
        a is the amplitude scaling.
        b is the amplitude shift.

◆ radial_sections()

Bimage * Bimage::radial_sections ( double  rad_start,
double  rad_end,
double  rad_step,
double  spherical_fraction,
Bsymmetry sym,
int  fill_type = FILL_USER,
double  fill = 0 
)

Calculates an image with slices giving the radial section projections.

Parameters
rad_startstarting radius (voxels).
rad_endending radius (voxels).
rad_stepradial step size (voxels).
spherical_fractionfraction of spherical section (requires symmetry).
*symsymmetry for non-spherical sections.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to fill in excluded regions.
Returns
Bimage* image with radial sections.
The 3D image is converted so that the sections contain 2D projections
of radial shells. The projection in slice i is defined for:
    i >= sqrt(x^2 + y^2)
Non-spherical sections can be generated by specifying the symmetry and
the fraction of spherical nature (1=spherical, 0=based on symmetry).
Sampling in x and y is not changed.
The sampling in the input map must be isotropic.

◆ radial_shells()

int Bimage::radial_shells ( )

Calculates an image with slices representing radial shell projections.

Returns
int 0.
The 3D image is converted so that the sections contain 2D projections
of radial shells. The projection in slice z is defined for:
    z >= sqrt((x-xo)^2 + (y-yo)^2) + zo
The first projection is placed at the z origin and radiates out into
both positive and negative directions.
Sampling in x and y is not changed.
The sampling must be isotropic.

◆ radial_symmetry_adjusted()

Bimage * Bimage::radial_symmetry_adjusted ( double  rad_start,
double  rad_end,
double  rad_step,
double  spherical_fraction,
Bsymmetry sym 
)

Calculates the symmetry-adjusted radial average of an image.

Parameters
rad_startminimum radius in voxels.
rad_endmaximum radius in voxels.
rad_stepstep size in voxels.
spherical_fractionratio of major and minor axes.
*sympoint group symmetry.
Returns
Bimage* radial average in the form of a 1D image.
A radial average of a 2D or 3D image is calculated between a minimum
and maximum radius.  An interpolative method is used where the value of
a voxel is distributed between the two nearest radial annuli.
The final sum in an annulus is normalized by the number of voxels
contributing to the annulus sum.
The symmetry is used to adjust the radius to follow the contours of a shell.
The origins within the sub-image structures are used.

◆ radial_to_full()

Bimage * Bimage::radial_to_full ( Vector3< long >  nusize,
Vector3< double >  origin 
)

Generates a full 2D or 3D image from a radial profile in a 1D image.

Parameters
nusizesize of image to expand to.
originorigin for radial profile.
Returns
Bimage* new 2D or 3D image.
It assumes the resultant image is square or cubic.

◆ read_data()

unsigned char * Bimage::read_data ( ifstream *  fimg,
int  img_select,
int  sb,
int  vax,
long  pad 
)

Read image data in a generalized style.

Parameters
*fimgfile descriptor: file opened in calling function.
img_selectimage selection: if -1, all images, if >= 0, one image.
sbflag activates byte swapping.
vaxindicate vax style floating point - activates conversion.
padany interspersed control or separation bytes.
Returns
unsigned char* data pointer, NULL if reading failed. The whole file or a single image from a file may be read. The data is read in the largest blocks possible for efficiency. Any interspersed padding and page sizes not matching the data size contribute to inefficiency in reading. Swapping: sb = 1: swap bytes the size of the data type sb > 1: swap these number of bytes regardless of the data type

◆ real_coordinates()

Vector3< double > Bimage::real_coordinates ( long  i)
inline

◆ real_size()

Vector3< double > Bimage::real_size ( )
inline

◆ reciprocal_half()

Vector3< long > Bimage::reciprocal_half ( )
inline

◆ red_white_blue()

Bimage * Bimage::red_white_blue ( double  red_min,
double  white_min,
double  white_max,
double  blue_max 
)

Colorizes an image with blue positive and red negative.

Parameters
red_minbeginning of red gradient (most negative).
white_minend of red gradient (fade into white).
white_maxbeginning of blue gradient (start with white).
blue_maxend of blue gradient (most positive)
Returns
Bimage* color scale image.
A grayscale image is converted to RGB and colored with blue positive, 
red negative, and white in between.

◆ refine_peak() [1/2]

int Bimage::refine_peak ( )

Refines the position of a peak to sub-voxel resolution.

Returns
int error code.
The sub-voxel resolution peak in the vicinity of a voxel is defined 
by fitting a 2D/3D second order function around the voxel.
(typically used to find the shift vector in a cross-correlation map).

The image origin is modified to reflect the shift in pixels.

◆ refine_peak() [2/2]

int Bimage::refine_peak ( long  kernel_size)

Refines the position of a peak to sub-voxel resolution.

Parameters
kernel_sizeedge length of kernel.
Returns
int error code.
The sub-voxel resolution peak in the vicinity of a voxel is defined
by fitting a 2D/3D second order function around the voxel.
(typically used to find the shift vector in a cross-correlation map).

The image origin is modified to reflect the peak position in pixels.

◆ refine_peak_new()

int Bimage::refine_peak_new ( )

Refines the position of a peak to sub-voxel resolution.

Returns
int error code.
The sub-voxel resolution peak in the vicinity of a voxel is defined 
by fitting a 2D/3D second order function around the voxel.
(typically used to find the shift vector in a cross-correlation map).

◆ region_assign()

long Bimage::region_assign ( Bimage pmask,
long  idx,
long  region_number,
double  threshold,
int  sign 
)

Finds all the pixels that are part of the same region.

Author
Bernard Heymann and Samuel Payne
Parameters
*pmaska mask holding region assignments.
idxthe first voxel of a region.
region_numberthe region number that voxels are assigned.
thresholdthe level to define background.
signsign controlling direction of thresholding.
Returns
int 0.
This method uses a list to keep track of voxels assigned to a region.
In subsequent iterations the non-assigned voxels next to those in
the list are assigned if they exceed the threshold, and their indices
are kept in a new list. The new list is transferred to the old list
and the process iteratively continued until the new list contains
no more voxels.

◆ region_flood()

long Bimage::region_flood ( Bimage pmask,
double  threshold_hi,
double  threshold_lo,
double  threshold_step,
int  fill_borders 
)

Creates and expands a region map from a starting to ending threshold value.

Parameters
*pmaskregion map (if NULL, generate from high threshold).
threshold_hithe level to pick initial regions.
threshold_lothe lowest level to include voxels in regions.
threshold_stepthe incremental change in threshold.
fill_bordersflag to assign borders between regions (default not).
Returns
long number of regions.
A region map is calculated at the threshold furthest from the average.
The region map is then expanded by lowering the threshold gradually 
and assigning newly included voxels to neighboring regions (i.e., flooding).
Voxels with neighbours assigned to two or more different regions are tagged
as indeterminate to indicate borders between regions. These border voxels
are counted and can be used to estimate the extent of interfaces.
The indices of all the final regions are packed into an integer data block
within a new image.
The image is assumed to have high values for objects (i.e., density is white).

◆ region_peaks()

Bimage * Bimage::region_peaks ( long  kernel_size,
double  threshold,
int  flood = 0,
int  wrap = 0 
)

Generates a segmented image from peaks above a threshold value.

Parameters
kernel_sizesize of kernel to determine peaks.
thresholdthe lowest level to include voxels in regions.
floodflag to flood to the threshold.
wrapflag to wrap the kernel around image boundaries.
Returns
Bimage* integer image containing region index numbers.
Every voxel with a value above the threshold is tagged by a pointer 
pointing to the highest value within a kernel. 
A peak is defined as pointing to itself, while every other voxel
points towards a peak.
The voxels in the mask are then iteratively assigned to the peaks
they point to.
The indices of all the final regions are packed into an integer data block
within a new image.

◆ region_threshold_series()

int Bimage::region_threshold_series ( double  threshold_first,
double  threshold_last,
double  threshold_step 
)

Segments a map through a series of thresholds and reports results.

Parameters
threshold_firstthe level to pick initial regions.
threshold_lastthe lowest level to include voxels in regions.
threshold_stepthe incremental change in threshold.
Returns
int 0.

◆ regions()

Bimage * Bimage::regions ( double  threshold,
int  sign 
)

Segments an image into contiguous regions.

Parameters
thresholdthe level at which things are ignored.
signsign controlling direction of thresholding.
Returns
Bimage* level mask with indexed regions.
The image is segmented into contiguous regions where a region is 
defined as all those voxels exceeding the given threshold and
adjacent to each other.
This method uses a list to keep track of voxels assigned to a region.
In subsequent iterations the non-assigned voxels next to those in
the list are assigned if they exceed the threshold, and their indices
are kept in a new list. The new list is transferred to the old list
and the process iteratively continued until the new list contains
no more voxels. The indices of all the regions are packed into
an integer data block within a new image.
The new image maps the indices of the regions starting from one to as
many regions as were found (the maximum gives the number of regions).
The new image has zeroes for all voxels outside the regions.

◆ relative_density()

double Bimage::relative_density ( Bimage pmask)

Calculates the relative density in a region defined by a mask.

Parameters
*pmaska 4 level mask.
Returns
double relative density.
The mask is assumed to have 4 levels:
0       region of no interest
1       region to estimate relative density
2       reference region
3       background region

◆ replace() [1/3]

int Bimage::replace ( Bimage img)

Replaces the data with that from the given image.

Parameters
*imgsource image.
Returns
int 0.
The input image must be the same size as the receiving image.

◆ replace() [2/3]

int Bimage::replace ( long  nn,
Bimage img,
long  nr,
double  fill 
)

Replaces one sub-image in an image structure.

Parameters
nnimage number to replace.
*imgsource image.
nrsource sub-image number.
fillfill vlue.
Returns
int 0.
The input image may have a different size as the receiving image.

◆ replace() [3/3]

int Bimage::replace ( long  nn,
Bimage img,
long  nr = 0 
)

Replaces one sub-image in an image structure.

Parameters
nnimage number to replace.
*imgsource image.
nrsource sub-image number.
Returns
int 0.
The input image must be the same size as the receiving image.

◆ replace_half()

int Bimage::replace_half ( Bimage p)

Replaces values for >x/2 with the given image.

Parameters
*psecond image.
Returns
int 0, <0 if error.

◆ replace_maxima()

long Bimage::replace_maxima ( double  threshold)

Replaces maxima above a threshold using local averages.

Parameters
thresholdthreshold.
Returns
long number of voxels replaced.
The image is first segemented into regions, each defined as a 
contiguous cluster of voxels with values above the threshold. 
Each region is encoded in an integer image, with all the values
in this image set to the indices of the regions, or zero elsewhere.
The regions are iteratively filled in, where in every iteration, 
the border values of the regions are replaced by the average 
of the neighbouring voxels outside the region. After each iteration, 
every region is shrunk by excluding the newly replaced voxels.

◆ replicate_asymmetric_unit()

int Bimage::replicate_asymmetric_unit ( Bsymmetry sym)

Calculates a full map from one asymmetric unit.

Parameters
*symsymmetry structure.
Returns
int 0.
A reference view for each point group is generated such that it is
located close to the center of the canonical asymmetric unit.
For each voxel in the target map, a set of symmetry-related views 
are generated and the one closest to the reference view used
to determine the corresponding voxels within the asymmetric unit.
The new voxel value is calculated by trilinear interpolation of the
voxels in the asymmetric unit. 

◆ rescale() [1/2]

int Bimage::rescale ( double  scale,
double  shift 
)

Rescales the image data with a given multiplier and offset.

Parameters
scalemultiplier.
shiftaddition or offset.
Returns
int error code.
The new data is calculated as:
    new_datum = datum*scale + shift
The new data replaces the old data.
Image statistics are recalculated.

◆ rescale() [2/2]

int Bimage::rescale ( long  nn,
double  scale,
double  shift 
)

Rescales the image data with a given multiplier and offset.

Parameters
nnsub-image.
scalemultiplier.
shiftaddition or offset.
Returns
int error code.
Requirement: The images must have the same size.

◆ rescale_to_avg_std() [1/3]

int Bimage::rescale_to_avg_std ( double  nuavg,
double  nustd 
)

Rescales the image data to a given average and standard deviation.

Parameters
nuavgnew average.
nustdnew standard deviation.
Returns
int error code.
The new data is calculated as:
                                new_std_dev
    new_datum = (datum - avg) * ----------- + new_avg
                                  std_dev
The new data replaces the old data.
Image statistics are recalculated.

◆ rescale_to_avg_std() [2/3]

int Bimage::rescale_to_avg_std ( double  nuavg,
double  nustd,
Bimage pmask 
)

Rescales the image data to a given average and standard deviation.

Parameters
nuavgnew average.
nustdnew standard deviation.
*pmaskstatistical calculations limited to the masked region.
Returns
int error code.
The new data is calculated as:
                                new_std_dev
    new_datum = (datum - avg) * ----------- + new_avg
                                  std_dev
The new data replaces the old data.
Image statistics are recalculated.

◆ rescale_to_avg_std() [3/3]

int Bimage::rescale_to_avg_std ( long  nn,
double  nuavg,
double  nustd 
)

Rescales the image data to a given average and standard deviation.

Parameters
nnsub-image.
nuavgnew average.
nustdnew standard deviation.
Returns
int error code.
The new data is calculated as:
                                new_std_dev
    new_datum = (datum - avg) * ----------- + new_avg
                                  std_dev
The new data replaces the old data.
Image statistics are recalculated.

◆ rescale_to_min_max() [1/2]

int Bimage::rescale_to_min_max ( double  numin,
double  numax 
)

Rescales the image data to a given minimum and maximum.

Parameters
numinnew minimum.
numaxnew maximum.
Returns
int error code.
The new data is calculated as:
                                new_max - new_min
    new_datum = (datum - min) * ----------------- + new_min
                                    max - min
The new data replaces the old data.
Image statistics are recalculated.

◆ rescale_to_min_max() [2/2]

int Bimage::rescale_to_min_max ( long  nn,
double  numin,
double  numax 
)

Rescales the image data to a given minimum and maximum.

Parameters
nnsub-image.
numinnew minimum.
numaxnew maximum.
Returns
int error code.
The new data is calculated as:
                                new_max - new_min
    new_datum = (datum - min) * ----------------- + new_min
                                    max - min
The new data replaces the old data.
Image statistics are recalculated.

◆ resize()

int Bimage::resize ( Vector3< long >  nusize,
Vector3< long >  translate,
int  fill_type = 0,
double  fill = 0 
)

Resizes without interpolation or rescaling.

Parameters
nusizenew image size three-value vector.
translatethree-value translation vector.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER
fillvalue to fill in new regions.
Returns
int 0.
An image is resized with translation and filling of new regions with 
a given value.

◆ resize_copy()

Bimage * Bimage::resize_copy ( Vector3< long >  nusize,
Vector3< long >  translate,
int  fill_type = 0,
double  fill = 0 
)

Resizes without interpolation or rescaling.

Parameters
nusizenew image size three-value vector.
translatethree-value translation vector.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER
fillvalue to fill in new regions.
Returns
Bimage* resized image.
An image is resized with translation and filling of new regions with 
a given value.

◆ resize_wrap()

int Bimage::resize_wrap ( Vector3< long >  nusize,
Vector3< long >  translate 
)

Resizes without interpolation or rescaling.

Parameters
nusizenew image size three-value vector.
translatethree-value translation vector.
Returns
int 0.
An image is resized with translation and filling of new regions with 
a given value.

◆ resize_wrap_copy()

Bimage * Bimage::resize_wrap_copy ( Vector3< long >  nusize,
Vector3< long >  translate 
)

Resizes with wrapping without interpolation or rescaling.

Parameters
nusizenew image size three-value vector.
translatethree-value translation vector.
Returns
Bimage* resized image.
An image is resized with translation and filling of new regions with 
a given value.

◆ reslice() [1/2]

void Bimage::reslice ( Bstring  order)

Switches axes of an image.

Parameters
orderstring encoding the reslicing order.
Reslicing refers to switching the axes of a multidimensional image.
The equivalent is rotation around angles that are multiples of pi/2.
The reslicing is encoded as a string of x, y and z, with the order
and sign indicating the type of reslicing to be done.
The new data replaces the old data.

◆ reslice() [2/2]

void Bimage::reslice ( const char *  order)
inline

◆ resolution_prepare() [1/2]

Bimage * Bimage::resolution_prepare ( Bimage p)

◆ resolution_prepare() [2/2]

Bimage * Bimage::resolution_prepare ( Bimage p,
fft_plan  plan 
)

◆ rgb()

RGB< double > Bimage::rgb ( long  j)

Returns a color value at the given index.

Parameters
jindex.
Returns
RGB<double> the color value.
The index refers to compound values.

◆ rgb_to_cmyk()

void Bimage::rgb_to_cmyk ( )

Converts an RGB color image to CMYK.

◆ rgb_to_rgba()

void Bimage::rgb_to_rgba ( )

An alpha channel is added to a RGB color image.

The alpha channel value is set to 255.

◆ rgba()

RGBA< double > Bimage::rgba ( long  j)

Returns a color value at the given index.

The index refers to compound values.
Parameters
jindex.
Returns
RGBA<double> the color value.

◆ rgba_to_rgb()

void Bimage::rgba_to_rgb ( )

The alpha channel is delete from an RGBA color image.

◆ rotate() [1/13]

int Bimage::rotate ( )

Rotates an image using parameters defined in the image in place.

Returns
0 error code.
The image is rotated according to the view and origin encoded
for the sub-image.

◆ rotate() [2/13]

int Bimage::rotate ( double  angle)

Rotates an image around the z-axis by the given angle in place.

Parameters
anglerotation angle in radians.
Returns
0 error code.
The image is rotated according to the axis and angle given.

◆ rotate() [3/13]

int Bimage::rotate ( Matrix3  mat)

Rotates an image using the specified matrix.

Parameters
mat3x3 rotation matrix.
Returns
0 error code.
An image is rotated according to the input matrix.
The input image origin is the rotation center.

◆ rotate() [4/13]

int Bimage::rotate ( Vector3< double >  axis,
double  angle 
)

Rotates an image using an axis and angle in place.

Parameters
axis3-value rotation axis.
anglerotation angle in radians.
Returns
0 error code.
The image is rotated according to the axis and angle given.

◆ rotate() [5/13]

int Bimage::rotate ( Vector3< double >  translate,
Matrix3  mat 
)

Rotates an image using the specified shift and matrix.

Parameters
translatetranslation after rotation.
mat3x3 rotation matrix.
Returns
0 error code.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.

◆ rotate() [6/13]

int Bimage::rotate ( Vector3< double >  translate,
View  view 
)

Rotates an image to a specified view in place.

Parameters
translatetranslation after rotation.
*viewview vector and angle.
Returns
0 error code.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.

◆ rotate() [7/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize)

Rotates an image using parameters defined in the image.

Parameters
nusize3-value new image size.
Returns
Bimage* rotated image.
The image is rotated according to the view and origin encoded
for the sub-image.

◆ rotate() [8/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize,
double  angle 
)

Rotates an image around the z-axis by the given angle.

Parameters
nusize3-value new image size.
anglerotation angle in radians.
Returns
Bimage* rotated image.
The image is rotated according to the axis and angle given.

◆ rotate() [9/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize,
Matrix3  mat 
)

Rotates an image using the specified matrix.

Parameters
nusizenew image size.
mat3x3 rotation matrix.
Returns
Bimage* rotated image.
An image is rotated according to the input matrix.
The input image origin is the rotation center.

◆ rotate() [10/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize,
Vector3< double >  axis,
double  angle 
)

Rotates an image using an axis and angle.

Parameters
nusize3-value new image size.
axis3-value rotation axis.
anglerotation angle in radians.
Returns
Bimage* rotated image.
The image is rotated according to the axis and angle given.

◆ rotate() [11/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize,
Vector3< double >  translate,
View  view 
)

Rotates an image to a specified view.

Parameters
nusize3-value new image size.
translatetranslation after rotation.
*viewview vector and angle.
Returns
Bimage* rotated image.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.

◆ rotate() [12/13]

Bimage * Bimage::rotate ( Vector3< long >  nusize,
View  view 
)

Rotates an image to a specified view.

Parameters
nusize3-value new image size.
*viewview vector and angle.
Returns
Bimage* rotated image.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.

◆ rotate() [13/13]

int Bimage::rotate ( View  view)

Rotates an image to a specified view in place.

Parameters
*viewview vector and angle.
Returns
0 error code.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.

◆ rotate_and_add()

int Bimage::rotate_and_add ( Bimage p,
Vector3< double >  origin,
View  view 
)

Rotates an image to a specified view and adds it to another image.

Parameters
*pthe image to rotate and add (modified).
originorigin in input image.
*viewview vector and angle.
Returns
int 0.
An image is rotated according to the input view vector and angle. 
The input image origin is the rotation center.
The rotated image is translated to the input origin.
The result is added to the current image.

◆ rotate_correlate()

double Bimage::rotate_correlate ( Vector3< double >  axis,
double  angle 
)

Rotates a copy of an image and correlates it with the original.

Parameters
axisrotation axis.
anglerotation angle.
Returns
double correlation coefficient, -1 if error.
This mainly used to determine the symmetry of a map.

◆ rotate_cross_correlate()

Vector3< double > Bimage::rotate_cross_correlate ( Bimage pref,
View  view,
double  hires,
double  lores,
double  search_radius,
Bimage pmask,
double &  cc,
fft_plan  planf,
fft_plan  planb 
)

◆ rotate_cross_correlate_two_way()

double Bimage::rotate_cross_correlate_two_way ( Bimage pref,
double  angle,
double  res_hi,
double  res_lo,
double  shift_limit,
fft_plan  planf,
fft_plan  planb 
)

◆ rotate_find_shift()

Vector3< double > Bimage::rotate_find_shift ( Matrix3  mat,
double  hires,
double  lores,
double  radius,
double  sigma,
int  refine_flag,
fft_plan  planf,
fft_plan  planb,
double &  cc 
)

Rotates and find shift by cross-correlation.

Parameters
matrotation matrix.
hireshigh resolution limit in angstroms.
loreslow resolution limit in angstroms.
radiussearch radius.
sigmasoften search radius cutoff.
refine_flagrefine shift.
planfforward Fourier transform plan.
planbbackward Fourier transform plan.k
&cccorrelation coefficient
Returns
Vector3<double> origin.
The point group symmetry operations are applied to an image with an
orientation defined by the reference symmetry axis (default {0,0,1}). 

◆ rotate_height()

Bimage * Bimage::rotate_height ( Matrix3  mat,
Vector3< double >  translate,
double  threshold = 0 
)

Rotates a 3D map and calculates the height along the z-axis.

Parameters
mat3x3 rotation or skewing matrix.
translate3-value vector for translation after transformation.
thresholddensity threshold to consider as object.
Returns
Bimage* new 2D height image.
The 3D map is rotated around its center as origin and the height 
calculated along the z-direction.
The resultant 2D image is translated if the translation vector is 
non-zero.
The rotation origin is obtained from the map origin.

◆ rotate_project()

Bimage * Bimage::rotate_project ( Matrix3  mat,
Vector3< double >  translate,
double  radial_cutoff,
int  norm_flag = 1 
)

Rotates a 3D map and projects it along the z-axis.

Parameters
mat3x3 rotation or skewing matrix.
translate3-value vector for translation after transformation.
radial_cutoffspherical cutoff to apply.
norm_flagflag to normalize projection.
Returns
Bimage* new 2D projection image.
The 3D map is rotated around its center as origin and the data 
integrated along the z-direction after subtraction of the
background (which must be calculated before this function).
The resultant 2D image is translated if the translation vector is 
non-zero. A radial cutoff can be applied to decrease the computation 
time. A value of zero or less sets the default to the length of the 
x-axis (i.e., no effective cutoff).
The rotation origin is obtained from the map origin.

◆ rotate_to_axis()

long Bimage::rotate_to_axis ( Bsymmetry sym,
long  axis,
long  axis_flag 
)

Rotates to a symmetry axis.

Parameters
*symsymmetry structure.
axisdesired symmetry axis order.
axis_flagview modifier.
Returns
long 0.

◆ sampling() [1/7]

vector< Vector3< double > > Bimage::sampling ( )
inline

◆ sampling() [2/7]

void Bimage::sampling ( double  ux,
double  uy,
double  uz 
)
inline

◆ sampling() [3/7]

Vector3< double > Bimage::sampling ( long  nn)
inline

◆ sampling() [4/7]

void Bimage::sampling ( long  nn,
double  ux,
double  uy,
double  uz 
)
inline

◆ sampling() [5/7]

void Bimage::sampling ( long  nn,
Vector3< double >  u 
)
inline

◆ sampling() [6/7]

void Bimage::sampling ( Vector3< double >  u)
inline

◆ sampling() [7/7]

void Bimage::sampling ( vector< Vector3< double > >  sam)
inline

◆ scale_to_reference() [1/2]

Bimage * Bimage::scale_to_reference ( Bimage pref,
Bimage pmask,
double  scalemin,
double  scalemax,
double  step 
)

Scales and image to the given reference, searching for the correct scale.

Parameters
prefreference/template image.
pmaskmask to limit correlation calculation (can be NULL).
scaleminminimum scaling to start search.
scalemaxmaximum scaling to end search.
stepscaling search step size.
Returns
Bimage* scaled image.

◆ scale_to_reference() [2/2]

Bimage * Bimage::scale_to_reference ( Bimage pref,
Bimage pmask = NULL 
)

Scales and image to the given reference, searching for the correct scale.

Parameters
prefreference/template image.
pmaskmask to limit correlation calculation (can be NULL).
Returns
Bimage* scaled image.

◆ scale_to_same_size()

Bimage * Bimage::scale_to_same_size ( Bimage pref)

Scales and image to the given reference.

Parameters
prefreference/template image.
Returns
Bimage* scaled image.

◆ seamed_helix_symmetrize()

Bplot * Bimage::seamed_helix_symmetrize ( double  helix_rise,
double  helix_angle,
double  seam_shift,
int  dyad_axis,
int  zmin,
int  zmax,
double  radius,
int  norm_flag 
)

Symmetrizes an image given helical symmetry parameters and seam shift parameter.

Parameters
helix_riserise per asymmetric unit (angstrom).
helix_anglerotation angle per asymmetric unit (radians).
seam_shifttranslation along the seam (subunit height units).
dyad_axisdyad axis indicator: 2=dyad axis on x-axis, otherwise none.
zminmimimum z slice to include.
zmaxmaximum z slice to include.
radiusradius to do symmetrizing over (pixels).
norm_flagif 1, normalize
Returns
Bplot* plot.
The data between the z limits are replicated along the helical axis
according to the helical rise and rotation and the seam to fill the new volume.

◆ search_views()

double Bimage::search_views ( Bimage ptemp,
View views,
double  hires,
double  lores,
double  search_radius,
Bimage pmask,
View currview,
Vector3< double > &  currshift 
)

Searches a 2D/3D density map for a template.

Parameters
*ptempthe template to be searched for.
*viewslist of views to search.
hireshigh resolution limit.
loreslow resolution limit.
search_radiusradius for shift search.
*pmaskmask for cross-correlation (ignored if NULL).
&currviewbest current view to return.
&currshiftbest current shift to return.
Returns
double the best correlation coefficient.
The template is rotated and cross-correlated to find the best fit.
The views must be calculated externally to allow for custom sets.

◆ search_volume()

Bimage * Bimage::search_volume ( Bimage ptemp,
View view,
double  alpha,
double  alpha_step,
double  hires,
double  lores,
Bimage pmask,
double  threshold 
)

Searches a 2D/3D density map for a template.

Parameters
*ptempthe template to be searched for.
*viewviews.
alpharotation around view vector, <0 = use 2*PI (radians).
alpha_stepangular step size around view vector (radians).
hireshigh resolution limit.
loreslow resolution limit.
*pmaskmask for cross-correlation (ignored if NULL).
thresholdthreshold value, if 0, threshold = FOMmax/2.
Returns
Bimage* image with the best view at each voxel and FOM block.
The template is rotated and cross-correlated to find the best fit.
The views must be calculated externally to allow for custom sets.

◆ search_volume_view()

double Bimage::search_volume_view ( Bimage ptemp,
View  view,
double  hires,
double  lores,
Bimage pmask,
double  threshold,
Bimage pfit 
)

Searches a 2D/3D density map for a template using a specific view.

Parameters
*ptempthe template to be searched for.
viewview.
hireshigh resolution limit.
loreslow resolution limit.
*pmaskmask for cross-correlation (ignored if NULL).
thresholdthreshold value, if 0, threshold = FOMmax/2.
*pfitview image with FOM block to hold results.
Returns
double maximum FOM.
The template is rotated to the view and cross-correlated.
A view image is updated with the results where the correlation coefficients are higher.
The views must be calculated externally to allow for custom sets.

◆ select_images()

long Bimage::select_images ( Bstring  list)

◆ set() [1/7]

void Bimage::set ( long  j,
CMYK< double >  color 
)

Sets a color value at the given index.

Parameters
jindex.
colorcolor value.
The index refers to compound values.

◆ set() [2/7]

void Bimage::set ( long  j,
Complex< double >  cv 
)

Sets a complex value at the given index.

Parameters
jindex.
cvcomplex value.
The index refers to compound values.

◆ set() [3/7]

void Bimage::set ( long  j,
double  v 
)

Sets a single value at the given index.

Parameters
jindex.
vvalue.

◆ set() [4/7]

void Bimage::set ( long  j,
RGB< double >  color 
)

Sets a color value at the given index.

Parameters
jindex.
colorcolor value.
The index refers to compound values.

◆ set() [5/7]

void Bimage::set ( long  j,
RGBA< double >  color 
)

Sets a color value at the given index.

Parameters
jindex.
colorcolor value.
The index refers to compound values.

◆ set() [6/7]

void Bimage::set ( long  j,
Vector3< double >  vec 
)

Sets a 3-value vector at the given index.

Parameters
jindex.
vec3-value vector.
The index refers to compound values.

◆ set() [7/7]

void Bimage::set ( long  j,
View  view 
)

Sets a 3-value vector at the given index.

Parameters
jindex.
view4-value view.
The index refers to compound values.

◆ set_hi_lo_resolution()

void Bimage::set_hi_lo_resolution ( double &  hi,
double &  lo 
)

◆ set_max()

void Bimage::set_max ( double  xx,
double  yy,
double  zz,
long  nn,
double  v 
)

Sets a value at a given location to neigboring data elements if it is larger.

Parameters
xxx location.
yyy location.
zzz location.
nnimage number (4 th dimension).
vvalue to assess and set.
All neighboring voxels are checked and set to the given value if it is larger.

◆ set_subset_selection()

long Bimage::set_subset_selection ( Bstring  list)

Sets the sub-image selections based on a list.

Parameters
listlist of sub-images to select.
Returns
long number of images selected.
The data is not altered.

◆ set_time() [1/2]

void Bimage::set_time ( time_t  t)
inline

◆ set_time() [2/2]

void Bimage::set_time ( tm *  t)
inline

◆ shape() [1/2]

int Bimage::shape ( int  type,
Vector3< long >  rect,
Vector3< double >  start,
double  width,
int  fill_type = 0,
double  fill = 0,
bool  wrap = 0 
)

Creates a shape in an image and fills it with a constant value.

Parameters
typetype of shape: 0=rectangle, 1=oval, 2=cylinder
rectthree-value size of the area to be filled.
startthree-value start of area.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
wrapwrap around boundaries (default not).
Returns
int 0.
The edge of the area is smoothed with a function:
                    v_old(x,y,z) + fill*exp(1.618*dist/width)
    v_new(x,y,z) = ------------------------------------------
                           1 + exp(1.618*dist/width)
where   fill is the constant fill value.
        dist is the distance to the rectangular boundary defined by 
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.

◆ shape() [2/2]

int Bimage::shape ( long  nn,
int  type,
Vector3< long >  rect,
Vector3< double >  start,
double  width,
int  fill_type = 0,
double  fill = 0,
bool  wrap = 0 
)

Creates a shape in an image and fills it with a constant value.

Parameters
typetype of edge: 0=rectangle, 1=oval, 2=cylinder
nnsub-image.
rectthree-value size of the area to be filled.
startthree-value start of area.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
wrapwrap around boundaries (default not).
Returns
int 0.
The edge of the area is smoothed with a function:
                    v_old(x,y,z) + fill*exp(1.618*dist/width)
    v_new(x,y,z) = ------------------------------------------
                           1 + exp(1.618*dist/width)
where   fill is the constant fill value.
        dist is the distance to the rectangular boundary defined by 
            the input size and start
        width is the gaussian width (softness)
With very small values of the gaussian width, the edge approaches a
step function.

◆ shell() [1/2]

int Bimage::shell ( long  nn,
Vector3< double >  center,
double  minrad,
double  maxrad,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Fills a shell within an image with a uniform value.

Parameters
nnsub-image.
centercenter of shell.
minradminimum radius of shell.
maxradmaximum radius of shell.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
All voxels within a shell at a given location and within given radii
are set to a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ shell() [2/2]

int Bimage::shell ( Vector3< double >  center,
double  minrad,
double  maxrad,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Fills a shell within an image with a uniform value.

Parameters
centercenter of shell.
minradminimum radius of shell.
maxradmaximum radius of shell.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
All voxels within a shell at a given location and within given radii
are set to a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ shell_wrap() [1/2]

int Bimage::shell_wrap ( long  nn,
Vector3< double >  center,
double  minrad,
double  maxrad,
double  width,
int  fill_type = 0,
double  fill = 0 
)

Fills a shell within an image with a uniform value with wrapping.

Parameters
nnsub-image.
centercenter of shell.
minradminimum radius of shell.
maxradmaximum radius of shell.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
All voxels within a shell at a given location and within given radii
are set to a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ shell_wrap() [2/2]

int Bimage::shell_wrap ( Vector3< double >  center,
double  minrad,
double  maxrad,
double  width,
int  fill_type,
double  fill 
)

Fills a shell within an image with a uniform value.

Parameters
centercenter of shell.
minradminimum radius of shell.
maxradmaximum radius of shell.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
Returns
int 0.
All voxels within a shell at a given location and within given radii
are set to a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ shift() [1/2]

int Bimage::shift ( long  nn,
Vector3< double >  vec,
int  fill_type = 0,
double  fill = 0 
)

Shifts one sub-image.

Parameters
nnsub-image.
vec3-value real space shift vector.
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
int error code.

◆ shift() [2/2]

int Bimage::shift ( Vector3< double >  vec,
int  fill_type = 0,
double  fill = 0 
)

Shifts an image.

Parameters
vec3-value real space shift vector.
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
int error code.

◆ shift_background()

int Bimage::shift_background ( double  bkg)

Sets the background for each sub-image to a given value.

Parameters
bkgnew background value.
Returns
int 0, <0 on error.
The background is taken as the average of the values outside the
circle or sphere enclosed by the image.

◆ shift_wrap() [1/2]

int Bimage::shift_wrap ( long  nn,
Vector3< double >  vec 
)

Shifts one sub-image with wrapping.

Parameters
nnsub-image.
vec3-value real space shift vector.
Returns
int error code.

◆ shift_wrap() [2/2]

int Bimage::shift_wrap ( Vector3< double >  vec)

Shifts an image.

Parameters
vec3-value real space shift vector.
Returns
int error code.

◆ show_image() [1/2]

long Bimage::show_image ( )
inline

◆ show_image() [2/2]

void Bimage::show_image ( long  nn)
inline

◆ show_maximum() [1/2]

double Bimage::show_maximum ( )
inline

◆ show_maximum() [2/2]

void Bimage::show_maximum ( double  v)
inline

◆ show_minimum() [1/2]

double Bimage::show_minimum ( )
inline

◆ show_minimum() [2/2]

void Bimage::show_minimum ( double  v)
inline

◆ show_scale() [1/2]

double Bimage::show_scale ( )
inline

◆ show_scale() [2/2]

void Bimage::show_scale ( double  scale)
inline

◆ show_slice() [1/2]

long Bimage::show_slice ( )
inline

◆ show_slice() [2/2]

void Bimage::show_slice ( long  nz)
inline

◆ shrink_wrap()

int Bimage::shrink_wrap ( Vector3< long >  nusize,
Vector3< long >  translate 
)

Shrinks an image to a new size with wrapping of the excluded edges.

Parameters
nusizenew image size three-value vector.
translatethree-value translation vector.
Returns
int 0.
An image is resized to a smaller size with translation and wrapping
of the excluded edges to complete periodic boundaries. The image is
first converted to floating point to prevent overflows of smaller 
data types. The new image is finally converted back to the original
data type.
The new data replaces the old data.

◆ simple_to_complex()

void Bimage::simple_to_complex ( )

A simple image is converted to a complex image.

The input image is written into the real part of the complex image.

◆ simple_to_rgb()

void Bimage::simple_to_rgb ( )

A simple image is converted to a color image.

All three color values in each voxel are the same (i.e., gray).

◆ simple_to_rgba()

void Bimage::simple_to_rgba ( )

A simple image is converted to a color image.

All three color values in each voxel are the same (i.e., gray).
The alpha value is set to 255.

◆ sine()

void Bimage::sine ( )

Calculates the sine of a phase image.

The values must be in radians.

◆ size() [1/4]

Vector3< long > Bimage::size ( ) const
inline

◆ size() [2/4]

void Bimage::size ( long  nx,
long  ny,
long  nz 
)
inline

◆ size() [3/4]

void Bimage::size ( Vector3< long >  vec)
inline

◆ size() [4/4]

void Bimage::size ( vector< long >  vec)
inline

◆ sizeX() [1/2]

long Bimage::sizeX ( ) const
inline

◆ sizeX() [2/2]

void Bimage::sizeX ( long  nx)
inline

◆ sizeY() [1/2]

long Bimage::sizeY ( ) const
inline

◆ sizeY() [2/2]

void Bimage::sizeY ( long  ny)
inline

◆ sizeZ() [1/2]

long Bimage::sizeZ ( ) const
inline

◆ sizeZ() [2/2]

void Bimage::sizeZ ( long  nz)
inline

◆ slices_to_images()

int Bimage::slices_to_images ( )

Changes the slices in a 3D image into a set of 2D images.

Returns
int error code (<0 means failure).

◆ smallest()

void Bimage::smallest ( Bimage p)

Selects the smallest of each pixel from two images.

Parameters
*pother image.

◆ snvariance()

double Bimage::snvariance ( double  snradius)

Calculates the ratio of variance inside and outside a given radius.

Parameters
snradiusradius of signal.
Returns
double the SNR.
The region outside the radial limit is considered noise and the region
inside is considered signal plus noise.

◆ space_group() [1/2]

long Bimage::space_group ( )
inline

◆ space_group() [2/2]

void Bimage::space_group ( unsigned int  grp)
inline

◆ sphere()

int Bimage::sphere ( Vector3< double >  center,
double  radius,
double  width = 0,
int  fill_type = 0,
double  fill = 0,
bool  wrap = 0 
)

Fills a sphere within an image with a uniform value.

Parameters
centerthree vector center of sphere.
radiussphere radius.
widthgaussian width of smoothing function.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillfill value.
wrapwrap around boundaries (default not).
Returns
int 0.
All voxels within a sphere at a given location and with a given radius 
are increased by a given fill value.
The new data replaces the old data.
The default center is {0,0,0}.

◆ split_channels()

Bimage * Bimage::split_channels ( )

Splits the channels into individual sub-images.

Returns
Bimage* new image.
The channels are converted to successive sets of images.

◆ split_channels_to_images()

Bimage * Bimage::split_channels_to_images ( )

Splits the channels into individual images in a linked list.

Returns
Bimage* new image.
Each channels is converted to a separate image in the list.

◆ square()

void Bimage::square ( )

Calculates the square of an image.

Values less than zero are set to zero.
Values greater than the data type maximum are set to the maximum.

◆ square_root()

void Bimage::square_root ( )

Calculates the square root of an image.

Values less than zero are set to zero.
Values greater than the data type maximum are set to the maximum.

◆ standard_deviation() [1/2]

double Bimage::standard_deviation ( )
inline

◆ standard_deviation() [2/2]

void Bimage::standard_deviation ( double  d)
inline

◆ statistics() [1/3]

long Bimage::statistics ( )

Calculates the statistics for an image.

Returns
long number of errors.

◆ statistics() [2/3]

long Bimage::statistics ( Bimage pmask,
double &  regavg,
double &  regstd 
)

Calculates the statistics for a region in an image.

Parameters
*pmaskregion.
&regavgregion average to be calculated.
&regstdregion standard deviation to be calculated.
Returns
long number of voxels.

◆ statistics() [3/3]

long Bimage::statistics ( long  img_num)

Calculates the statistics for a sub-image.

Parameters
img_numsub-image number.
Returns
long number of errors.

◆ stats_in_mask()

long Bimage::stats_in_mask ( long  nn,
Bimage pmask 
)

Calculates the statistics for an image for each level in a mask.

Parameters
nnsub-image number.
*pmaskmask with two or more levels
Returns
long number of levels (0 means failure).

◆ stats_in_poly()

vector< double > Bimage::stats_in_poly ( long  nn,
int  nvert,
Vector3< double > *  poly 
)

Calculates the statistics for an image within the given polyhedron.

Parameters
nnsub-image number.
nvertnumber of polygon vertices.
*polyarray of polygon vertices.
Returns
vector<double> statistical values (none means failure).
If a voxel lies within the specified polyhedron, it is included in
the statistical calculations.

Return vector:  num, min, max, avg, std

◆ stats_in_shape()

vector< double > Bimage::stats_in_shape ( long  nn,
int  type,
Vector3< long >  start,
Vector3< long >  end 
)

Calculates the statistics for an image within the given box.

Parameters
nnsub-image number.
typetype of selection: 1=rectangle, 2=ellipse.
startstarting coordinates.
endending coordinates.
Returns
vector<double> statistical values (none means failure).
If a voxel lies within the specified box, it is included in
the statistical calculations.

Return vector:  num, min, max, avg, std

◆ stats_within_radii()

vector< double > Bimage::stats_within_radii ( long  nn,
Vector3< double >  loc,
double  rad_min,
double  rad_max 
)

Calculates the statistics for an image within given radii from a location.

Parameters
nnsub-image number.
loccenter of shell.
rad_minminimum radius (pixel units).
rad_maxmaximum radius (pixel units).
Returns
vector<double> statistical values (none means failure).
If a voxel lies within the specified radii, it is included in
the statistical calculations.

Return vector:  num, min, max, avg, std

◆ subimage_information()

int Bimage::subimage_information ( )

Prints out header information for all sub-images.

Returns
int error code (<0 means failure).

◆ subtract()

void Bimage::subtract ( Bimage p)

Subtracts another image from an image.

Parameters
*pimage to be added.
Requirement: The images must have the same size.

◆ subtract_background()

int Bimage::subtract_background ( )

Subtracts the background for each sub-image.

Returns
int 0, <0 on error.
The background is taken from the sub-image structures.

◆ sum()

void Bimage::sum ( long  m,
Bimage **  p 
)

Sums an array of images with their FOM blocks.

Parameters
mnumber of images in the array.
**parray of images.
The images must all have the same dimensions.

◆ sum_images()

void Bimage::sum_images ( )

Adds all sub-images.

◆ superpixels() [1/2]

vector< Bsuperpixel > Bimage::superpixels ( long  step,
double  colorweight = 0.2,
long  iterations = 10,
double  stop = 1 
)

Segment the image into superpixels.

Parameters
stepinitial superpixel intervals.
colorweightweight of color differences compared to spatial distances.
iterationsmaximum number of iterations.
stopstopping condition as a percent of voxel changes.
Returns
vector<Bsuperpixel> array of superpixels.
The segment array contents are:
0       count
1-3     coordinates
4+      channels
last    color weight for the segment - maximum squared distance

The mask is linked to the original image for return.

◆ superpixels() [2/2]

vector< Bsuperpixel > Bimage::superpixels ( long  step,
double  colorweight = 0.2,
long  iterations = 10,
long  bin_levels = 1,
double  stop = 1 
)

◆ superpixels_from_mask()

vector< Bsuperpixel > Bimage::superpixels_from_mask ( long  cc,
long  step 
)

Create superpixels from a multilevel mask.

Parameters
ccnumber of channels in the original image.
stepdistance limit to determine neigbors.
Returns
vector<Bsuperpixel> array of superpixels.

◆ superpixels_update()

int Bimage::superpixels_update ( Bimage pmask,
vector< long >  vstep,
double  colorweight,
vector< Bsuperpixel > &  seg 
)

◆ surface_to_topograph()

Bimage * Bimage::surface_to_topograph ( double  threshold,
int  dir = 0 
)

Converts a 3D image to a 2D height image.

Parameters
thresholdthreshold to define the surface (assuming positive density).
dirdirection: 0=bottom up, 1=top down.
Returns
Bimage* 2D height image.
The threshold defines the surface of the positive density in the 3D image.
Each line of voxels in the z-direction is scanned for the voxel
exceeding the threshold with the highest z-index.

◆ symmetrize() [1/4]

double Bimage::symmetrize ( Bstring symmetry_string,
int  flag 
)
inline

◆ symmetrize() [2/4]

double Bimage::symmetrize ( Bstring symmetry_string,
View  ref_view,
int  flag 
)
inline

◆ symmetrize() [3/4]

double Bimage::symmetrize ( Bsymmetry  sym,
int  flag 
)
inline

◆ symmetrize() [4/4]

double Bimage::symmetrize ( Bsymmetry  sym,
View  ref_view,
int  flag 
)

Applies point group symmetry to an image.

Parameters
sympoint group.
ref_viewreference view vector and rotation angle.
flagflag to normalize after symmetrization.
Returns
double symmetry FOM.
The point group symmetry operations are applied to an image with an
orientation defined by the reference symmetry axis (default {0,0,1}). 
The fill value is taken from image's background value.
The symmetry FOM is taken as the ratio of the power after to before
symmetrization. 

◆ symmetrize_cyclic()

double Bimage::symmetrize_cyclic ( int  cyclic,
int  flag 
)
inline

◆ symmetrize_cylinder() [1/2]

int Bimage::symmetrize_cylinder ( )

Calculates a cylindrically symmetrized map.

Returns
int 0.
The image is replaced with its cylindrically symmetrized version.

◆ symmetrize_cylinder() [2/2]

Bimage * Bimage::symmetrize_cylinder ( int  flag)

Calculates a cylindrically symmetrized map.

Parameters
flag0:
Returns
Bimage* 2D image with the cylindrical average.
A 2D cylindrically symmetrized average is calculated.

◆ symmetry() [1/2]

string & Bimage::symmetry ( )
inline

◆ symmetry() [2/2]

void Bimage::symmetry ( string  grp)
inline

◆ symmetry_equivalent()

Matrix3 Bimage::symmetry_equivalent ( Bimage pref,
Bimage pmask,
Bsymmetry sym 
)

Finds the symmetry equivalent orientation of a particle with respect to a template.

Parameters
*preftemplate to test against (same size as input image).
*pmaskmask to limit correlation calculation.
*symsymmetry structure.
Returns
Matrix3 transformed image.
For point groups up to tetrahedral symmetry, there is an ambiguity in the
orientation of a particle even though it is oriented according to the 
standard orientation for the symmetry.
A template is used to select the desired orientation and the image is transformed.
Both the input image and template must be in the standard orientation
for the point group.

◆ symmetry_equivalent_cyclic()

Matrix3 Bimage::symmetry_equivalent_cyclic ( Bimage pref,
Bimage pmask,
Bsymmetry sym 
)

Finds the cyclic symmetry equivalent orientation of a particle with respect to a template.

Parameters
*preftemplate to test against (same size as input image).
*pmaskmask to limit correlation calculation.
*symsymmetry structure.
Returns
Matrix3 transformed image.
For point groups up to tetrahedral symmetry, there is an ambiguity in the
orientation of a particle even though it is oriented according to the 
standard orientation for the symmetry.
A template is used to select the desired orientation and the image is transformed.
Both the input image and template must be in the standard orientation
for the point group.

◆ tangent()

void Bimage::tangent ( )

Calculates the tangent of a phase image.

The values must be in radians.

◆ test_helix_parameters() [1/2]

Vector3< double > Bimage::test_helix_parameters ( double  angle,
double  hires,
double  lores,
Vector3< long >  mask_size,
Vector3< long >  mask_start,
long  max_iter,
fft_plan  planf,
fft_plan  planb,
double &  cc 
)

◆ test_helix_parameters() [2/2]

double Bimage::test_helix_parameters ( double  rise,
double  angle,
Vector3< long >  mask_size,
Vector3< long >  mask_start 
)

◆ thickness()

Bimage * Bimage::thickness ( double  reference,
double  emfp 
)

Calculates a thickness based on intensities with respect to a reference.

Parameters
referencereference intensity.
emfpproportionaility coefficient.
Returns
vector<double> 7-value array of parameters.
The thickness for each pixel is:
    t = emfp * ln(Iref/Ipix)
If Ipix <= 0, t = 0

◆ tile_coordinates() [1/2]

vector< Vector3< long > > Bimage::tile_coordinates ( Vector3< long > &  start,
Vector3< long > &  region,
Vector3< long > &  tile_size,
Vector3< long > &  step_size,
int  exceed 
)

Generates a set of tile coordinates for an image.

Parameters
&start3-vector start for first tile to be extracted.
&region3-vector size of part of image to be extracted (0 = whole image).
&tile_size3-vector size of extracted image.
&step_size3-vector size of intervals between tiles.
exceedflag to allow tiles to exceed the input image size.
Returns
vector<Vector3<long>> set of coordinates.
Calculating the coordinates of tiles of a specified size and within
a specified region within the image. The overlap is specified by
the step size and a flag indicates the option to exceed the
bounds of the image.
The old data is not affected.

◆ tile_coordinates() [2/2]

vector< Vector3< long > > Bimage::tile_coordinates ( Vector3< long >  tile_size,
Vector3< long > &  step_size 
)

Generates a set of tile coordinates to fit in the image dimensions.

Parameters
tile_size3-vector size of extracted image.
&step_size3-vector size of intervals between tiles.
Returns
vector<Vector3<long>> set of coordinates.
Calculating the coordinates of tiles of a specified size to fit within
the bounds of the image. The overlap is specified by
the given step size, which is adjusted to fit the image bounds.
The old data is not affected.

◆ tile_mask()

Bimage * Bimage::tile_mask ( long  step)

Converts a mask to a tiled multilevel mask.

Parameters
stepisotropic tile edge size.
Returns
Bimage* new mask.
The old data is unmodified.

◆ to_mask() [1/2]

long Bimage::to_mask ( )
inline

◆ to_mask() [2/2]

long Bimage::to_mask ( double  threshold)

Change the image to a mask.

Parameters
thresholdset mask above this value.
Returns
long number of mask voxels.
The input image is effectively thresholded and a mask with 0 and 1 generated.
The new data type is unsigned char/byte.

◆ topograph_to_surface()

Bimage * Bimage::topograph_to_surface ( Bimage psd,
long  nz,
double  density,
double  resolution 
)

Converts a 2D AFM image to a 3D density map.

Parameters
*psd2D standard deviation image.
nzz dimension of the new 3D map.
densitydensity inside the surface (Da/A3).
resolutionsigma bounds.
Returns
int 0.
The 2D image is expanded in the z direction according to:
                          voxel_density
dens[x,y,z] = --------------------------------------
              1+exp(factor*(z-zdis[x,y])/sigma[x,y])
where   voxel_density is the total density attributed to a voxel
        factor = 1.618
        z - zdis[x,y] is the z distance from the surface
        sigma is a standard deviation term to describe the surface variability.
The sigma term can be set automatically or given by an input standard deviation map.
The position of the surface is calculated as:
zdis[x,y] = loz + (hiz - loz)*(image[x,y] - min)/(max - min)
where   loz and hiz are the lowest and highest points of the surface in the 3D map
        min and max are the image minimum and maximum values

◆ track_gradient()

Bimage * Bimage::track_gradient ( double  threshold,
int  flag = 0 
)

Generates a segmented image from peaks above a threshold value.

Parameters
thresholdthe lowest level to include voxels in regions.
flagTrack towards maxima (0) or minima (1).
Returns
Bimage* integer image containing tracking indices.
Every voxel with a value above (below) the threshold is tagged by a pointer
pointing to the highest (lowest) value within a kernel of 3x3x3.
A peak is defined as pointing to itself, while every other voxel
points towards a peak.

◆ transform() [1/3]

Bimage * Bimage::transform ( long  nn,
Vector3< long >  nusize,
Vector3< double >  scale,
Vector3< double >  origin,
Vector3< double >  translate,
Matrix3  mat,
int  fill_type = 0,
double  fill = 0 
)

Transforms a sub-image by translation, rotation, scaling and skewing, returning a single new image.

Parameters
nnsub-image to process.
nusize3-value new image size.
scale3-value scale factor vector to apply.
origin3-value origin for rotation and skewing.
translate3-value vector for translation after transformation.
mat3x3 rotation or skewing matrix.
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
Bimage* new image.
A number of transformation types are combined in this function for
efficiency. The basic operation is the conversion of the image data 
from the original data block to a new data block, applying a 
transformation matrix and translation vector with a specified origin 
followed by an optional translation:
    y = R*x + t
where   R is the rotation/skewing/scaling matrix.
        t is the translation vector.
Note: The image is converted to floating point to improve interpolation.

◆ transform() [2/3]

int Bimage::transform ( Vector3< double >  scale,
Vector3< double >  origin,
Vector3< double >  translate,
Matrix3  mat,
int  fill_type = 0,
double  fill = 0 
)

Transforms an image by translation, rotation, scaling and skewing, in place.

Parameters
scale3-value scale factor vector to apply.
origin3-value origin for rotation and skewing.
translate3-value vector for translation after transformation.
mat3x3 rotation or skewing matrix.
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
0 error code.
A number of transformation types are combined in this function for
efficiency. The basic operation is the conversion of the image data 
from the original data block to a new data block, applying a 
transformation matrix and translation vector with a specified origin 
followed by an optional translation:
    y = R*x + t
where   R is the rotation/skewing/scaling matrix.
        t is the translation vector.
Note: The image is converted to floating point to improve interpolation.

◆ transform() [3/3]

Bimage * Bimage::transform ( Vector3< long >  nusize,
Vector3< double >  scale,
Vector3< double >  origin,
Vector3< double >  translate,
Matrix3  mat,
int  fill_type = 0,
double  fill = 0 
)

Transforms an image by translation, rotation, scaling and skewing, returning a new image.

Parameters
nusize3-value new image size.
scale3-value scale factor vector to apply.
origin3-value origin for rotation and skewing.
translate3-value vector for translation after transformation.
mat3x3 rotation or skewing matrix.
fill_typefill type for filling empty regions.
fillvalue to fill in empty regions.
Returns
Bimage* new image.
A number of transformation types are combined in this function for
efficiency. The basic operation is the conversion of the image data 
from the original data block to a new data block, applying a 
transformation matrix and translation vector with a specified origin 
followed by an optional translation:
    y = R*x + t
where   R is the rotation/skewing/scaling matrix.
        t is the translation vector.
Note: The image is converted to floating point to improve interpolation.

◆ transform_lines()

int Bimage::transform_lines ( )

◆ transform_voxel()

void Bimage::transform_voxel ( long  i,
Bimage pt,
long  nn,
Vector3< double >  oldorigin,
Vector3< double >  nuorigin,
Matrix3  affmat,
double  fill 
)

◆ truncate()

int Bimage::truncate ( double  minim,
double  maxim,
double  setmin,
double  setmax 
)

Truncates image data to a given minimum and maximum.

Parameters
minimminimum.
maximmaximum.
setminvalue to set voxels smaller than minimum.
setmaxvalue to set voxels larger than maximum.
Returns
int 0.
All values smaller than the new minimum are set to the new minimum
and all values larger than the new maximum are set to the new maximum.
In cases where the given minimum and maximum are outside the data
type ranges, they are reset to the data type range limits.
The new data replaces the old data.
Image statistics are recalculated.

◆ truncate_to_avg()

int Bimage::truncate_to_avg ( double  minim,
double  maxim 
)

Sets voxels in image data exceeding a given minimum and maximum to the average.

Parameters
minimminimum.
maximmaximum.
Returns
int 0.
All values smaller than the new minimum or larger than the new 
maximum are set to the image average.
The new data replaces the old data.
Image statistics are recalculated.

◆ truncate_to_background()

int Bimage::truncate_to_background ( double  minim,
double  maxim 
)

Sets voxels in image data exceeding a given minimum and maximum to the image background.

Parameters
minimminimum.
maximmaximum.
Returns
int 0.
All values smaller than the new minimum or larger than the new 
maximum are set to the background value.
The new data replaces the old data.
Image statistics are recalculated.

◆ truncate_to_min_max()

int Bimage::truncate_to_min_max ( double  minim,
double  maxim 
)

Truncates image data to a given minimum and maximum.

Parameters
minimminimum.
maximmaximum.
Returns
int 0.
All values smaller than the new minimum are set to the new minimum
and all values larger than the new maximum are set to the new maximum.
In cases where the given minimum and maximum are outside the data
type ranges, they are reset to the data type range limits.
The new data replaces the old data.
Image statistics are recalculated.

◆ tube_interpolate()

double Bimage::tube_interpolate ( long  i,
int  h,
int  k,
double  latconst,
int  zmin,
int  zmax,
double  radius,
int  norm_flag = 1 
)

◆ tube_symmetrize()

double Bimage::tube_symmetrize ( int  h,
int  k,
double  latconst,
int  zmin,
int  zmax,
double  radius,
int  norm_flag = 1 
)

Symmetrizes an image given tubular lattice parameters.

Parameters
hunits along u vector.
kunits along v vector.
latconstlattice constant (angstrom).
zminmimimum z slice to include.
zmaxmaximum z slice to include.
radiusradius to do symmetrizing over (pixels).
norm_flagif 1, normalize
Returns
double R factor.
The data between the z limits are replicated along the helical axis
according to the lattice parameters to fill the new volume.

◆ two_to_complex()

void Bimage::two_to_complex ( )

Two sub-images converted to a complex image.

◆ unit_cell() [1/2]

UnitCell Bimage::unit_cell ( )
inline

◆ unit_cell() [2/2]

void Bimage::unit_cell ( UnitCell  uc)
inline

◆ unit_cell_check()

void Bimage::unit_cell_check ( )
inline

◆ unpack_combined_transform()

Bimage * Bimage::unpack_combined_transform ( )

Unpacks a complex transform obtained from two real images.

Returns
Bimage* transform of second image.
The complex image must be a Fourier transform obtained from two real 
space images which were packed into the real and imaginary parts
of the complex image before Fourier transformation.
The input image is used to hold the transform of the first image.
A new image is created to hold the transform of the second image.
Both these images are complex floating point.
Note: Images with even dimensions cannot be unpacked exactly because
    the inverse is not present when x=nx/2 or y=ny/2 or z=nz/2.

◆ unpack_transform() [1/2]

int Bimage::unpack_transform ( int  img_select,
unsigned char *  data,
FourierType  tf 
)

◆ unpack_transform() [2/2]

int Bimage::unpack_transform ( unsigned char *  data,
FourierType  tf 
)

◆ update_from_meta_data()

void Bimage::update_from_meta_data ( )

Update sub-image information from the metadata.

The metadata in JSON format is transferred to the sub-image information.

◆ values() [1/3]

vector< double > Bimage::values ( long  i)
inline

◆ values() [2/3]

void Bimage::values ( long  i,
vector< double >  val 
)
inline

◆ values() [3/3]

vector< double > Bimage::values ( long  nn,
Vector3< double >  vox 
)

Returns an array with all channel data at the given coordinates.

Parameters
nnimage index.
voxvoxel coordinates.
Returns
vector<double> value array.
The values of all channels are returned in double precision.

◆ variance() [1/4]

double Bimage::variance ( )
inline

◆ variance() [2/4]

int Bimage::variance ( Bimage pweight)

Calculates the local variance weighed with the given image.

Parameters
pweightweight image.
Returns
int 0.
The local variance is calculated using the given image as kernel weights.
The calculation is threaded if compiled with GCD or OpenMP.

◆ variance() [3/4]

int Bimage::variance ( long  kernel_size,
int  flag = 0 
)

Calculates the local variance within the given kernel.

Parameters
kernel_sizesize of kernel edge.
flagselects type of output.
Returns
int 0.
The local variance within a kernel is calculated.
The calculation is threaded if compiled with GCD or OpenMP.
Flag values:
0   variance
1   standard deviation
2   poisson excess variance

◆ variance() [4/4]

int Bimage::variance ( Vector3< long >  kernel_size,
int  flag = 0 
)

Calculates the local variance within the given kernel.

Parameters
kernel_size3-value size of kernel edge.
flagselects type of output.
Returns
int 0.
The local variance within a kernel is calculated.
The calculation is threaded if compiled with GCD or OpenMP.
Flag values:
0   variance
1   standard deviation
2   poisson excess variance

◆ variance_mask()

Bimage * Bimage::variance_mask ( long  kernel_size,
double  lowvar = 1e-6,
int  bkg_flag = 0 
)

Calculates a mask based on local variance.

Parameters
kernel_sizesize of kernel edge.
lowvarlow variance threshold.
bkg_flagflag to generate a background with value -1.
Returns
Bimage* binary mask.
The local variance within a kernel is calculated and used to generate the mask.
A threshold is calculated to define the foreground and background.
Excluded regions are defined by a low variance parameter.
Foreground is set to 1, background is set to -1, excluded areas are set to 0.

◆ variance_threshold()

double Bimage::variance_threshold ( double  lowvar)

Calculates a threshold for a local variance image.

Parameters
lowvarlow variance threshold.
Returns
double threshold.
A threshold is calculated to define the foreground and background.
Excluded regions are defined by a low variance parameter.

◆ vector3()

Vector3< double > Bimage::vector3 ( long  j)

Returns a 3-value vector at the given index.

Parameters
jindex.
Returns
Vector3<double> the 3-value vector.
The index refers to compound values.

◆ vector_to_simple()

void Bimage::vector_to_simple ( )

A vector image is converted to a simple image.

The new value for each voxel is the length of each vector.

◆ view() [1/2]

void Bimage::view ( double  vx,
double  vy,
double  vz,
double  va 
)
inline

◆ view() [2/2]

void Bimage::view ( View  vw)
inline

◆ voxel_size()

double Bimage::voxel_size ( )
inline

◆ within_boundaries() [1/2]

bool Bimage::within_boundaries ( long  xx,
long  yy,
long  zz 
)
inline

◆ within_boundaries() [2/2]

template<typename T >
bool Bimage::within_boundaries ( Vector3< T >  loc)
inline

◆ write()

int Bimage::write ( Bstring fn)

◆ zero_fourier_origin()

void Bimage::zero_fourier_origin ( )

Zeroes the first voxel in each image.

◆ zero_origin()

int Bimage::zero_origin ( )

Shifts the origins to zero with wrapping.

Returns
int error code.

Member Data Documentation

◆ image

Bsub_image* Bimage::image

◆ next

Bimage* Bimage::next

The documentation for this class was generated from the following files: