 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
101 void check_sampling() {
105 if ( ux <= 1e-10 ) ux = 1;
106 if ( uy <= 1e-10 ) uy = 1;
107 if ( uz <= 1e-10 ) uz = 1;
109 void check_origin() {
127 void sampling(
double x,
double y,
double z) { ux=x; uy=y; uz=z; check_sampling(); }
131 if ( vec.size() > 1 ) uy=vec[1];
132 if ( vec.size() > 2 ) uz=vec[2];
136 void origin(
double x,
double y,
double z) { ox=x; oy=y; oz=z; check_origin(); }
140 if ( vec.size() > 1 ) oy=vec[1];
141 if ( vec.size() > 2 ) oz=vec[2];
157 void view(
double x,
double y,
double z,
double a) { vx=x; vy=y; vz=z; angle=a; }
159 void view(vector<double> vw) { vx=vw[0]; vy=vw[1]; vz=vw[2]; angle=vw[3]; }
165 double FOM() {
return fom; }
166 void FOM(
double d) { fom = d; }
205 void initialize(
long nc,
long nx,
206 long ny,
long nz,
long nn);
208 long ny,
long nz,
long nn);
209 void internal_copy(
const Bimage& p);
236 return metadata[tag];
238 vector<JSvalue*>
query(
string& path) {
239 return metadata(path);
247 if ( !metadata.
exists(
"filename") ) metadata[
"filename"] =
"?";
248 return metadata[
"filename"].
value();
250 void label(
string s) { metadata[
"label"] = s; }
252 if ( !metadata.
exists(
"label") ) metadata[
"label"] =
"?";
253 return metadata[
"label"].
value();
257 if ( !metadata.
exists(
"time") ) metadata[
"time"] = time(NULL);
258 return metadata[
"time"].
integer();
262 return localtime(&time_sec);
265 void set_time(tm* t) { metadata[
"time"] = mktime(t); }
270 long data_size() { datasize = c*x*y*z*n;
return datasize; }
276 long ny,
long nz,
long nn);
278 long ny,
long nz,
long nn) {
295 double get(
long nn,
long xx,
long yy,
long zz,
long cc=0);
299 vector<double> val(c);
300 for ( i*=c, cc=0; cc<c; cc++, i++ ) val[cc] = (*
this)[i];
303 void values(
long i, vector<double> val) {
305 for ( i*=c, cc=0; cc<c; cc++, i++ ) val[cc] = (*
this)[i];
314 void set(
long j,
double v);
321 void add(
long j,
double v) {
set(j, (*
this)[j] + v); }
323 void add(
double xx,
double yy,
double zz,
long nn,
double v);
324 void set_max(
double xx,
double yy,
double zz,
long nn,
double v);
326 double average2D(
long cc,
double xf,
double yf,
327 double zf,
long nn,
double iscale);
328 double average(
long cc,
double xf,
double yf,
329 double zf,
long nn,
double iscale);
331 double yy=0,
double zz=0,
long nn=0,
double fill=0)
const;
333 long nn=0,
double fill=0)
const {
337 long nn=0,
double fill=0)
const {
341 long nn=0,
double fill=0)
const {
345 long nn=0,
double fill=0)
const {
349 double yy=0,
double zz=0,
long nn=0)
const;
387 void size(
long nx,
long ny,
long nz) { x=nx; y=ny; z=nz; }
396 long index(
long nx,
long ny)
const {
399 long index(
long nx,
long ny,
long nz)
const {
400 return (nz*y + ny)*x + nx;
402 long index(
long nx,
long ny,
long nz,
long nn)
const {
403 return ((nn*z + nz)*y + ny)*x + nx;
405 long index(
long nc,
long nx,
long ny,
long nz,
long nn)
const {
406 return (((nn*z + nz)*y + ny)*x + nx)*c + nc;
409 return ((nn*z + vox[2])*y + vox[1])*x + vox[0];
411 long index(vector<long> vox,
long nn)
const {
412 return ((nn*z + vox[2])*y + vox[1])*x + vox[0];
415 while ( nx < 0 ) nx += x;
416 while ( ny < 0 ) ny += y;
417 while ( nz < 0 ) nz += z;
418 while ( nx >= x ) nx -= x;
419 while ( ny >= y ) ny -= y;
420 while ( nz >= z ) nz -= z;
421 return (nz*y + ny)*x + nx;
436 void coordinates(
long i,
long &nx,
long &ny,
long &nz,
long &nn) {
445 void coordinates(
long i,
long &nc,
long &nx,
long &ny,
long &nz,
long &nn) {
457 long nc, nx, ny, nz, nn;
462 if ( loc[0] >= 0 && loc[0] < x && loc[1] >= 0 && loc[1] < y &&
463 loc[2] >= 0 && loc[2] < z )
return 1;
467 if ( xx >= 0 && xx < x && yy >= 0 && yy < y && zz >= 0 && zz < z )
return 1;
472 for (
long j=0; j<3; j++ )
473 lo[j] = ( lo[j] < k )? 0: lo[j] -= k;
482 for (
long j=0; j<3; j++ )
483 lo[j] = ( lo[j] < k[j] )? 0: lo[j] -= k[j];
496 if ( datatype==
Bit ) px = 8*((x-1)/8 + 1);
517 void sampling(
long nn,
double ux,
double uy,
double uz) {
524 for (
long nn=0; nn<n; ++nn )
image[nn].
sampling(ux, uy, uz);
530 vector<Vector3<double>> sam;
531 for (
long nn=0; nn<n; ++nn ) sam.push_back(
sampling(nn));
535 if ( n != sam.size() )
536 cerr <<
"Error in Bimage::sampling: number of images are not the same! ("
537 << n <<
" != " << sam.size() <<
")" << endl;
538 for (
long nn=0; nn<n && nn<sam.size(); ++nn )
image[nn].
sampling(sam[nn]);
570 void origin(
double ox,
double oy,
double oz) {
571 for (
long nn=0; nn<n; ++nn )
575 for (
long nn=0; nn<n; ++nn )
579 for (
long nn=0; nn<n; ++nn )
585 void origin(
long nn, vector<double> ori) {
586 while ( ori.size() < 3 ) ori.push_back(0);
589 void origin(
long nn,
double ox,
double oy,
double oz) {
596 void view(
double vx,
double vy,
double vz,
double va) {
for (
long j=0; j<n; j++ )
image[j].
view(vx, vy, vz, va); }
599 if ( !metadata.
exists(
"spacegroup") ) metadata[
"spacegroup"] = 1;
600 return metadata[
"spacegroup"].
integer();
602 void space_group(
unsigned int grp) { metadata[
"spacegroup"] = grp; }
604 if ( !metadata.
exists(
"pointgroup") ) metadata[
"pointgroup"] =
"C1";
605 return metadata[
"pointgroup"].
value();
607 void symmetry(
string grp) { metadata[
"pointgroup"] = grp; }
611 if ( !
isfinite(ucell.
a()) || ucell.
a() < u[0]*x ) ucell.
a(u[0]*x);
612 if ( !
isfinite(ucell.
b()) || ucell.
b() < u[1]*y ) ucell.
b(u[1]*y);
613 if ( !
isfinite(ucell.
c()) || ucell.
c() < u[2]*z ) ucell.
c(u[2]*z);
623 unsigned char*
read_data(ifstream* fimg,
int img_select,
int sb,
int vax,
long pad);
634 double rad_min,
double rad_max,
double& vavg,
double& vstd);
638 double& vavg,
double& vstd);
641 int kernel_sums(
long n,
long i,
long ik,
long nk);
642 int line_sums(
long n,
long ik,
long nk);
644 int variance(
long kernel_size,
int flag=0);
647 int kernel_sums(
long nn,
long i,
Bimage* pweight);
653 int moments(
long max_order,
long nn);
663 int fill_type=0,
double fill=0);
707 data_size();
for (
long j=0; j<datasize; j++ )
set(j, v);
713 return density(nn, coord, radius, sigma);
722 void power(
double v);
745 double radius=0,
double scale=1,
double shift=0,
int operation=0);
756 int average_line_sum(
long n,
long i,
long ik,
long nk);
757 int average_line_sums(
long n,
long ik,
long nk);
762 int gaussian_line_sum(
long nn,
long i,
long ik,
Bimage* pk);
763 int gaussian_line_sums(
long nn,
long ik,
Bimage* pk);
772 int kernel_type,
float* nudata,
long i,
long len,
int first);
774 int kernel_type,
long kernel_radius);
776 int filter_rank_chunk(
long kernel_size,
double rank,
float* nudata,
long i,
long len);
781 Bimage* structure_tensor_2D(
long nn=0);
782 Bimage* structure_tensor(
long zs,
long zw);
783 int diffusion_tensor_2D(
double lambda,
double C,
double alpha);
784 int diffusion_tensor(
double lambda,
double C,
double alpha);
785 int diffuse_2D(
Bimage* pdn,
Bimage* pd,
double ht,
long nn=0);
786 int diffuse(
Bimage* pdn,
Bimage* pd,
double ht,
long zs);
787 int nad_chunk_2D(
Bimage* pdn,
double lambda,
double C,
788 double alpha,
double ht,
long nn=0);
789 int nad_chunk(
Bimage* pdn,
double lambda,
double C,
790 double alpha,
double ht,
long zs,
long zw);
792 Bimage*
nad_2D(
double ht,
double lambda,
double C,
double alpha);
793 Bimage*
nad(
double ht,
long zw,
double lambda,
double C,
double alpha);
839 fft(plan, norm_flag);
851 double tilt_axis,
double tilt_offset,
int flags=0);
854 double tilt_axis,
double tilt_angle,
double defocus,
double iCL2,
int flags=0);
856 double tilt_axis,
double tilt_angle,
double tilt_offset,
857 double defocus,
double iCL2,
int flags=0);
863 double part_weight,
int interp_type);
865 double lo_res,
Vector3<double> scale,
double part_weight=1,
int interp_type=0);
867 double lo_res,
Vector3<double> scale,
double part_weight=1,
int interp_type=0);
869 long ft_size,
double scale,
double hi_res,
double lo_res,
878 int fspace_resize(
double scale,
double res_hi,
double res_lo);
889 int fspace_weigh(
long maxrad,
double* curve,
int flag=0);
916 double radial_cutoff,
int norm_flag=1);
925 Bplot*
fsc_dpr(
double hi_res,
double sampling_ratio=1,
int flag=0);
926 Bplot*
fsc(
double hi_res,
double sampling_ratio=1);
929 int thickness,
int step,
int minrad,
int maxrad,
930 int pad=1,
int smooth=0,
double fill=0);
932 double* fsc_local_voxel(
Bimage* p,
double resolution,
int size,
933 int pad,
int taper,
double* cutoff,
fft_plan plan,
long i);
934 double local_filter_voxel(
Bimage* resmap,
long size,
939 int step=1,
int taper=1,
double fill=0);
971 double hires,
double lores,
double search_radius,
Bimage* pmask,
974 double angle,
double res_hi,
double res_lo,
double shift_limit,
977 double lores,
double radius,
double sigma,
int refine_flag);
979 double lores,
double radius,
double sigma,
int refine_flag,
double& cc);
981 double lores,
double radius,
double sigma,
int refine_flag,
984 double lores,
double radius,
double sigma,
int refine_flag,
987 double hi_res,
double lo_res,
double shift_limit,
992 double lores,
double radius,
double sigma,
int refine_flag);
994 double hires,
double lores,
double radius,
double sigma,
996 int find_peak(
double radius=1e30,
double sigma=0);
1002 double& threshold_max,
double pix_min=2,
double pix_max=10);
1006 double hires,
double lores,
double search_radius,
1009 double hires,
double lores,
Bimage* pmask,
1010 double threshold,
Bimage* pfit);
1012 double alpha_step,
double hires,
double lores,
1013 Bimage* pmask,
double threshold);
1018 double hi_res,
double lo_res,
double shift_limit,
1021 double hi_res,
double lo_res,
double shift_limit,
1024 double hi_res,
double lo_res,
double shift_limit,
1025 double edge_width,
double gauss_width);
1027 int ann_min,
int ann_max,
double ang_min,
double ang_max,
1032 double res_hi,
double res_lo,
double shift_limit,
double angle_limit,
1035 int ann_min,
int ann_max,
Bimage* prs_mask,
double shift_limit,
double angle_limit,
1038 double res_lo,
double res_hi,
double shift_limit,
double angle_limit);
1047 int one_color(
int color,
double cmin,
double cmax,
int flag=0);
1048 int color_red(
double cmin,
double cmax,
int flag=0);
1049 int color_green(
double cmin,
double cmax,
int flag=0);
1050 int color_blue(
double cmin,
double cmax,
int flag=0);
1055 double white_max,
double blue_max);
1064 int truncate(
double minim,
double maxim,
double setmin,
double setmax);
1069 int normalize(
long imgnum,
double average,
double stdev,
int norm_type,
long bins);
1091 vector<long>
histogram(
long bins,
double& scale,
double& offset);
1102 int fill_type=0,
double fill=0);
1104 int fill_type=0,
double fill=0);
1107 int pad(
long sz,
int fill_type=0,
double fill=0);
1115 int montage_one(
Bimage* pm,
long zz,
long mi,
long cols,
long rows,
int flipy);
1117 Bimage*
montage(
int first,
int cols,
int rows,
int skip=0,
int flipy=0);
1120 double width,
int fill_type=0,
double fill=0);
1122 double width,
int fill_type=0,
double fill=0);
1126 double width,
int fill_type=0,
double fill=0);
1128 double width,
int fill_type=0,
double fill=0);
1131 double width=0,
int fill_type=0,
double fill=0);
1133 double height,
double width,
int fill_type=0,
double fill=0);
1136 double maxrad,
double width,
int fill_type=0,
double fill=0);
1138 double maxrad,
double width,
int fill_type=0,
double fill=0);
1140 double maxrad,
double width,
int fill_type=0,
double fill=0);
1142 double width,
double edge_width,
int fill_type=0,
double fill=0);
1144 double width,
double edge_width,
int fill_type=0,
double fill=0);
1161 int rotate(
double angle);
1185 double scalemax,
double step);
1190 return symmetrize(symmetry_string, ref_view, flag);
1205 int binfac,
double hires,
double lores);
1207 int binfac,
double hires,
double lores,
int flags);
1210 double radius,
double z_slope);
1219 int zmin,
int zmax,
double radius,
int norm_flag=1);
1222 double latconst,
int zmin,
int zmax,
double radius,
int norm_flag=1);
1224 int dyad_axis,
int zmin,
int zmax,
double radius,
int norm_flag=1);
1226 double seam_shift,
int dyad_axis,
int zmin,
int zmax,
1227 double radius,
int norm_flag);
1231 int zmin,
int zmax,
double radius,
int norm_flag=1);
1236 double angle_step,
int bin,
double hires,
double lores,
double radius);
1238 double rise_step,
double angle_start,
double angle_end,
double angle_step,
1239 int bin,
double radius);
1241 double angle_start,
double angle_end,
double angle_step,
1242 int bin,
double hires,
double lores,
double radius,
1245 double angle_start,
double angle_end,
double angle_step,
1246 int bin,
double hires,
double lores,
double radius);
1249 double scale,
double hires);
1252 double helix_angle,
int fill_type,
double fill);
1256 Bimage*
radial(
long minrad,
long maxrad,
double rad_step=1,
int wrap=0);
1257 Bimage*
radial(
long minrad,
long maxrad,
double rad_step,
Bimage* pmask,
int wrap=0);
1258 Bimage*
radial(
long minrad,
long maxrad,
double rad_step,
1259 double ellipticity,
double angle,
Bimage* pmask,
int wrap=0);
1261 double rad_end,
double rad_step,
1262 double spherical_fraction,
Bsymmetry* sym);
1268 long dann,
long zmin,
long zmax,
long zinc);
1274 int set_radial_distances(
double spherical_fraction,
Bsymmetry* sym);
1275 int radial_section(
Bimage* prad,
long nn,
1276 long zr,
double rad_start,
double rad_step,
double fill=0);
1279 double rad_step,
double spherical_fraction,
1314 long to_mask(
double threshold);
1333 double rect_angle,
int wrap);
1339 double tilt_neg,
double tilt_pos,
double resolution);
1341 double tilt_axis2,
double tilt_neg1,
double tilt_pos1,
1342 double tilt_neg2,
double tilt_pos2,
double resolution);
1344 double mis_ang,
double resolution);
1378 long region_number,
double threshold,
int sign);
1380 double threshold_last,
double threshold_step);
1382 double threshold_lo,
double threshold_step,
int fill_borders);
1385 long blobs(
double threshold,
double min_size,
double max_size,
1386 double setvalue,
int sign);
1390 double mass_threshold(
long img_num,
double mol_weight,
double rho);
1396 double complexity=0,
long min_size=0,
int return_type=0);
1398 double colorweight, vector<Bsuperpixel>& seg);
1400 vector<Bsuperpixel>
superpixels(
long step,
double colorweight=0.2,
long iterations=10,
double stop=1);
1401 vector<Bsuperpixel>
superpixels(
long step,
double colorweight=0.2,
long iterations=10,
long bin_levels=1,
double stop=1);
Bimage * regions(double threshold, int sign)
Segments an image into contiguous regions.
double R_factor(Bimage *p)
Calculates an R factor between two images.
void coordinates(long i, long &nx, long &ny, long &nz)
int color_green(double cmin, double cmax, int flag=0)
Converts a gray-scale image to green.
unsigned char * data_pointer(long offset)
Bimage * extract_filament(long img_num, double width, int axis, long nspline, Vector3< double > *spline)
Extracts a filament defined by a series of coordinates.
long mask_fill(Vector3< long > voxel)
Fills an empty part of a mask indicated by the given voxel.
Bimage * height(View *views, double threshold=0)
Calculates a set of height images from a 3D density map.
fft_plan fft_setup(fft_direction dir, int opt=0)
Sets up a plan for fast Fourier transforms.
int level_masked_stats(Bimage *pmask)
Caclulates statistics for all the regions defined by a multi-level mask.
void coordinates(long i, long &nx, long &ny, long &nz, long &nn)
int complex_multiply(Bimage *p)
Calculates the product of a complex image with a simple image.
void symmetry(string grp)
void rgb_to_cmyk()
Converts an RGB color image to CMYK.
int rescale(double scale, double shift)
Rescales the image data with a given multiplier and offset.
void complex_to_intensities()
The intensities from a complex image is written to a simple image.
Bimage * scale_to_same_size(Bimage *pref)
Scales and image to the given reference.
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.
long mask_erode(long times=1)
Erodes a binary mask.
void sampling(double ux, double uy, double uz)
int mirror()
Inverts/mirrors each image through its origin.
int region_threshold_series(double threshold_first, double threshold_last, double threshold_step)
Segments a map through a series of thresholds and reports results.
Vector3< double > real_size()
Bimage * fspace_radial_power(double resolution, double sampling_ratio=1)
Calculates the radial power spectrum from a Fourier transform.
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.
void compound_type(CompoundType ct)
Bimage * cross_correlate(Bimage *p, Bimage *pmask=NULL)
void background(double bkg)
Bimage * resize_wrap_copy(Vector3< long > nusize, Vector3< long > translate)
Resizes with wrapping without interpolation or rescaling.
void view(vector< double > vw)
void combine_channels(long nc)
The channels are composed from individual images.
int friedel_apply()
Applies Friedel symmetry.
Vector3< long > coordinates(long i)
int filter_gaussian(long kernel_size, double sigma)
Applies a gaussian filter to an image.
double interpolate_wrap(double xx, double yy=0, double zz=0, long nn=0) const
Bimage * edge_mask(int type, Vector3< long > rect, Vector3< double > start, double width)
Creates a mask with the edge approaching zero.
double variance_threshold(double lowvar)
Calculates a threshold for a local variance image.
double symmetrize(Bstring &symmetry_string, int flag)
Vector3< double > origin()
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.
vector< double > histogram_gauss_fit(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
JSvalue align(long ref_num, Bimage *pmask, double hi_res, double lo_res, double shift_limit, double edge_width, double gauss_width, Vector3< long > bin)
Aligns and sums a set of sub-images, first progressively and then iteratively.
int shrink_wrap(Vector3< long > nusize, Vector3< long > translate)
Shrinks an image to a new size with wrapping of the excluded edges.
Bplot * 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.
void page_size(long nx, long ny, long nz)
double correlation_coefficient(Vector3< double > shift)
Calculates a coefficient from a Fourier correlation transform given a shift.
int truncate(double minim, double maxim, double setmin, double setmax)
Truncates image data to a given minimum and maximum.
Bimage * operator+(Bimage &p)
Adds two images together, adjusting for size difference.
void inverse(double minval=0)
Calculates the inverse of the image.
double * fspace_radial(long nn, long maxrad, int flag=0)
Calculates the radial power spectrum from a Fourier transform.
void show_maximum(double v)
FourierType
Fourier transform format specifier.
Bimage * find_peaks(long kernelsize)
Finds peaks in a map with periodic boundaries.
Super pixel segmentation.
long mask_dilate(long times=1)
Dilates a binary mask.
long fspace_reconstruction_weigh()
Weighs a reconstruction.
int fspace_weigh_ramp(double resolution, fft_plan planf, fft_plan planb)
Weighs a transform with a ramp.
int shift(Vector3< double > vec, int fill_type=0, double fill=0)
Shifts an image.
bool within_boundaries(long xx, long yy, long zz)
double interpolate(Vector3< double > vec, long nn=0, double fill=0) const
double merge_amplitudes_and_phases(Bimage *pamp)
Merges the amplitudes from one map with the phases of another.
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.
void sampling(Vector3< double > u)
double get(long nn, long xx, long yy, long zz, long cc=0)
Returns the data value at the given coordinates.
Bplot * fsc_dpr(double hi_res, double sampling_ratio=1, int flag=0)
Calculates an FSC and DPR curves from two images.
int fill_gaps(long step)
Fill the voxels that are not calculated.
void reslice(const char *order)
Bimage * cross_correlate(Bimage *p, double hires, double lores, fft_plan planf, fft_plan planb)
Calculates a cross-correlation map by Fast Fourier transformation.
General sub-image parameter class.
vector< JSvalue >::iterator erase(long j)
void set(long j, double v)
Sets a single value at the given index.
int fspace_positive()
Sets the image to positive definite.
Bimage * levelmask_color_by_size()
Color a multi-level mask based on the volumes of regions.
vector< Bsuperpixel > superpixels_from_mask(long cc, long step)
Create superpixels from a multilevel mask.
void page_size(vector< long > vec)
Vector3< long > image_coordinates(Vector3< double > rc)
Bimage * extract_tetrahedron(Vector3< double > *tet, int fill_type=0, double fill=0)
Extracts a tetrahedral part of the image.
void zero_fourier_origin()
Zeroes the first voxel in each image.
int cylindrical_shells()
Calculates an image with slices representing cylindrical shell projections.
Bimage * level_mask_extract(Bimage *pmask)
Extracts all the regions associated with a multi-level mask.
double relative_density(Bimage *pmask)
Calculates the relative density in a region defined by a mask.
double standard_deviation()
Bstring compound_type_string()
Get the string representation of a datatype.
int fspace_background()
Calculates the background for a Fourier transform.
Bimage * extract(long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin, View view)
void view_angle(double d)
void size(Vector3< long > vec)
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.
double interpolate(vector< double > vec, long nn=0, double fill=0) const
Bimage * central_section(Matrix3 mat, double resolution, FSI_Kernel *kernel)
Calculates a central section of a 3D fourier transform.
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.
Bimage()
Initializes an image.
Bimage & operator=(const Bimage &p)
Assigns an image.
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.
Bimage * extract_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.
long mask_symmetrize(Bsymmetry *sym)
Symetrizes a mask.
Bimage * copy()
Copies the header information and data of an image into a new image structure.
void origin(long nn, double ox, double oy, double oz)
Header file for general symmetry functions.
int filter_sinc()
Weighs an image with a sinc function.
int center(int fill_type=0, double fill=0)
Centers an image.
Vector3< double > sampling(long nn)
int truncate_to_background(double minim, double maxim)
Sets voxels in image data exceeding a given minimum and maximum to the image background.
Bimage * extract_wrap(long nn, Vector3< long > size, Matrix3 mat)
long levelmask_select(Bstring &select_list, int flag=0)
Retains the selected levels in a multi-level mask.
double helix_interpolate(long i, double helix_rise, double helix_angle, int zmin, int zmax, double radius, int norm_flag=1)
Vector3< double > find_shift_in_transform(double shift_limit)
Finds the shift by brute force backtransformation for selected shifts.
void simple_to_complex()
A simple image is converted to a complex image.
int variance(long kernel_size, int flag=0)
Calculates the local variance within the given kernel.
Vector3< long > page_size()
void unit_cell(UnitCell uc)
Bimage * resize_copy(Vector3< long > nusize, Vector3< long > translate, int fill_type=0, double fill=0)
Resizes without interpolation or rescaling.
Bimage * pack_two_in_complex(Bimage *p)
Packs two real images into one complex image.
int find_peak(double radius=1e30, double sigma=0)
Finds the peak in an image to the nearest voxel.
void complex_to_imaginary()
The imaginary part of a complex image is written to a simple image.
unsigned char * data_alloc_and_clear(long nbytes)
int fspace_weigh_dose(long nn, double dose_per_frame, vector< double > critdose)
void sum(long m, Bimage **p)
Sums an array of images with their FOM blocks.
Vector3< double > default_origin()
Bplot * histogram_counts(int flags=0)
Finds the peaks in a quantized image from the histogram.
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.
vector< double > values(long i)
double mass_at_threshold(long img_num, double threshold, double rho)
Calculates the mass from the density threshold.
int line_powerspectra(fft_plan plan)
Calculates the 1D power spectrum of each line in an image.
double fspace_fit_B_factor(double res_hi=0)
Determines the overall B-factor of an image.
int fspace_square_amp()
Change the amlitudes to their squares.
long fspace_reconstruction_snr()
Calculates the SNR map.
Header file for frequency space interpolation kernel.
void sampling(vector< Vector3< double >> sam)
Bimage * cross_correlate_validate(Bimage *p, Bimage *pmask)
Calculates a masked cross-correlation map by Fast Fourier transformation.
Class for complex numbers.
int information()
Prints out header information for an image.
long data_type_bits() const
Returns the size of the datatype in bits.
void add(long j, Complex< double > cv)
Bimage * radial(long minrad, long maxrad, double rad_step=1, int wrap=0)
Calculates the radial average of an image.
int complex_apply_negative_mask(Bimage *pmask)
Applies a negative mask to a complex image.
int normalize(long imgnum, double average, double stdev, int norm_type, long bins)
Normalizes a sub-image to a desired average and standard deviation.
double background(long nn)
Vector3< long > size() const
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.
void meta_data_retain_one_image(long img_num)
Erases all sub-image records from the meta data except one.
Header file for unit cell functions.
double levelmask_average_region_size()
Calculates the average size of regions in a level mask.
long mask_missing_find(Vector3< double > ori, double resolution, Bstring &mis_type)
Generates a missing mask from an example image.
void values(long i, vector< double > val)
long data_type_size() const
Returns the size of the datatype in bytes.
long levelmask_symmetrize(Bsymmetry *sym)
Symetrizes a multi-level mask.
double symmetrize(Bsymmetry *sym, int flag)
void split_channels()
The channels are split into individual images.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
int place_with_addition(Bimage *p, long nn)
Packs a tile into a new composite image with addition within overlap.
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.
Bimage * surface_to_topograph(double threshold, int dir=0)
Converts a 3D image to a 2D height image.
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.
Bimage * kmeans_segment(long nregion=2, long max_iter=10, double ratio=1)
Segments an image based on K-means.
long levelmask_dilate()
Dilates a level mask.
int fspace_weigh_accumulated_dose(vector< double > dose)
Weighs an image's amplitudes with the accumulated dose.
void view(double x, double y, double z, double a)
int shift_wrap(Vector3< double > vec)
Shifts an image.
double data_type_min()
Get the minimum of a datatype.
int noise_uniform(double rmin, double rmax)
Generates an image with a uniform random distribution of densities.
int zero_origin()
Shifts the origins to zero with wrapping.
Bimage * thickness(double reference, double lambda)
Calculates a thickness based on intensities with respect to a reference.
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.
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.
double length(vector< T > v)
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.
int correct_background(long nn, int flag)
Corrects the background for one sub-image.
double symmetrize(Bstring &symmetry_string, View ref_view, int flag)
double tube_interpolate(long i, int h, int k, double latconst, int zmin, int zmax, double radius, int norm_flag=1)
int enlarge(Vector3< long > scale)
Enlarges an image by an inetger scale.
Bimage * internal_volume(double threshold)
Calculates the internal volume of a shell.
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.
int phase_colour_wheel()
Generates a phase color wheel.
int filter_rank(long kernel_size, double rank)
Applies a median filter to an image.
Matrix3 symmetry_equivalent_cyclic(Bimage *pref, Bimage *pmask, Bsymmetry *sym)
Finds the cyclic symmetry equivalent orientation of a particle with respect to a template.
int place_central_part(Bimage *p, long nn)
Packs a tile into a new composite image, retaining only the central part.
int radial_shells()
Calculates an image with slices representing radial shell projections.
double standard_deviation()
int integer_interpolation(int integer_factor)
RGBA< double > rgba(long j)
Returns a color value at the given index.
Header file for postscript output functions.
double ccmap_confidence(long nn)
Calculates a confidence level to associate with a cross-correlation peak.
Bimage * mask_by_thresholds(vector< double > threshold)
Generates a mask based on an image at a given threshold.
int fft_back(fft_plan plan, bool norm_flag=1)
long mask_dilate_erode(unsigned char dir)
Dilates or erodes a binary mask.
void sampling(long nn, double ux, double uy, double uz)
void sampling(vector< double > vec)
Vector3< long > kernel_low(long i, Vector3< long > k)
Bimage * color_spectrum(double cmin, double cmax)
Colorizes an image to a spectrum.
Bimage * cartesian_to_cylindrical(long nannuli, long nphi, int flag=0)
Calculates an image with cylindrical coordinates.
int refine_peak()
Refines the position of a peak to sub-voxel resolution.
int fspace_weigh_FSC_curve(Bplot *plot, double resolution=0)
Weighs an image's amplitudes with a given FSC curve.
int complex_apply_dual_mask(Bimage *pmask)
Applies a dual mask to a complex image.
Bimage * extract_slice(long nz)
Extracts a given slice or slices from an image.
int convolve(Bimage *pkernel)
Convolves an image with an arbitrary size convolution filter.
Bimage * filament_density(double width)
Estimates the density per pixel length of a filament.
int rotate_and_add(Bimage *p, Vector3< double > origin, View view)
Rotates an image to a specified view and adds it to another image.
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.
double * radial_fit(Bimage *pref)
Fits a radial profile to a reference radial profile.
int phase_shift(Vector3< double > shift)
Phase shifts a complex image.
Bimage * complex_conjugate_product_one2many(Bimage *p)
Calculates the product of a complex image with the conjugate of a second.
void rgba_to_rgb()
The alpha channel is delete from an RGBA color image.
long kernel_max_wrap(long idx, long ksize)
Finds the highest value in a kernel with wrapping.
int fspace_normalize()
Normalizes an image's amplitudes.
Vector3< double > vector3(long j)
Returns a 3-value vector at the given index.
Vector3< double > mask_fspace_resize(Vector3< long > nusize)
Resizes a reciprocal space mask.
long delete_images(Bstring list, int retain=0)
Retains or deletes sub-images from a multi-image structure.
Bsub_image()
Initializes a sub-image.
Classes for color objects.
double density(long nn, Vector3< double > coord, double radius, double &sigma)
Calculates the density in a sphere around a coordinate in an image.
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.
int images_to_slices()
Changes the 2D images to slices in a 3D image.
Bimage * local_filter(Bimage *pmask, int mask_level, Bimage *resmap, int size, Vector3< long > vedge)
Applies a local resolution filter to a map.
Bimage * radial_coverage(double threshold, double rad_step=1)
Calculates the coverage in each radial shell.
long index_wrap(Vector3< long > coor) const
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.
Bimage * unpack_combined_transform()
Unpacks a complex transform obtained from two real images.
double mass_threshold(long img_num, double mol_weight, double rho)
Finds the density threshold associated with a particular molecular weight.
void origin(double x, double y, double z)
long levelmask_clean()
Removes empty levels from a multi-level mask.
void data_offset(long doff)
void multiply(long j, Complex< double > cv)
void background(long nn, double bkg)
vector< double > fspace_default_bands(double res_lo, double res_hi)
Sets up default frequency space bands to generate a mask.
Bimage * project(char axis, int flags=1)
Projects a 3D image to a 2D image down one of the three major axes.
Vector3< double > change_transform_size(Vector3< long > nusize)
Resizes a "standard" transform.
Vector3< double > real_coordinates(Vector3< long > ic)
int shift_background(double bkg)
Sets the background for each sub-image to a given value.
long kernel_max(long idx, long ksize)
Finds the highest value in a kernel.
Bimage * orient(View *views)
Calculates multiple copies oriented according to views.
int fspace_weigh_C_curve(double resolution=0)
Weighs an image's amplitudes with the carbon scattering curve.
void add(long j, double v)
int quadric_correct(vector< double > param)
Corrects for a quadric surface.
int distort_elliptically(double angle, double shift)
Transforms a tubular cylinder to an elliptical profile.
int gradient_correction()
Calculates and corrects for a linear gradient across an image.
Bimage * align_progressive_fast(long nref, double shift_limit)
Aligns and sums a set of sub-images using a progressive algorithm.
Bimage * nad_2D(double ht, double lambda, double C, double alpha)
Denoises a 2D image by non-linear anisotropic diffusion.
long index(long nx, long ny, long nz) const
int combined_complex_product_implicit_mask(double hires, double lores)
Calculates the complex conjugate product of a complex image resulting from combining and Fourier tran...
void origin(long nn, vector< double > ori)
int pack_transform(unsigned char *data, FourierType tf)
int replicate_asymmetric_unit(Bsymmetry *sym)
Calculates a full map from one asymmetric unit.
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.
int resize_wrap(Vector3< long > nusize, Vector3< long > translate)
Resizes without interpolation or rescaling.
double correlate(Bimage *p)
Calculates correlation coefficient between two images.
int slices_to_images()
Changes the slices in a 3D image into a set of 2D images.
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)
int fspace_translate(Vector3< double > shift)
Translates an image in frequency space to avoid interpolation.
int noise_logistical(double ravg, double rstd)
Generates an image with a gaussian random distribution of densities.
long mask_stats()
Calculates statistics for a mask.
long mask_shell(Vector3< double > origin, double rad_min, double rad_max)
int histogram_thresholds(double &tmin, double &tmax)
Calculates minimum and maximum thresholds for truncation.
void standard_deviation(double d)
int interpolate_gaps(long step)
Interpolate the voxels that are not calculated.
JSvalue & operator[](string tag)
int rotate()
Rotates an image using parameters defined in the image in place.
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.
int normalize_local(long kernel_size)
Normalizes by subtracting local average and dividing by local standard deviation.
FourierType fourier_type()
void complex_conjugate()
Calculates the complex conjugate image.
int noise_gaussian(double ravg=0, double rstd=1)
Generates an image with a gaussian random distribution of densities.
int levelmask_region_size()
Convert a mask to reflect region sizes.
Bimage * bin_copy(long b)
Bimage * cross_correlate_fspace(Bimage *p, double hires, double lores, double shift_limit)
Calculates a cross-correlation map by Fast Fourier transformation.
int power_spectrum(int flags=0)
Calculates a power spectrum.
Bimage * mask_by_threshold(double threshold)
Generates a mask based on an image at a given threshold.
vector< Bsuperpixel > superpixels(long step, double colorweight=0.2, long iterations=10, double stop=1)
Segment the image into superpixels.
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 data_type_max()
Get the maximum of a datatype.
void cmyk_to_rgb()
Converts a CMYK color image to RGB.
int hanning_taper(double fill=0)
Apply Hanning taper window to the image.
long stats_in_poly(long nn, int nvert, Vector3< double > *poly, double &vavg, double &vstd)
Calculates the statistics for an image within the given polyhedron.
int truncate_to_avg(double minim, double maxim)
Sets voxels in image data exceeding a given minimum and maximum to the average.
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.
void data_pointer(unsigned char *ptr)
Bimage * graph_segment(int type=1, Bimage *pmask=NULL, int connect_type=0, double complexity=0, long min_size=0, int return_type=0)
Graph-based segmentation of an image.
int cylinder(Vector3< double > center, double radius, double height, double width, int fill_type=0, double fill=0)
Fills a cylinder within an image with a uniform value.
Bimage * extract_show(int aflag)
Converts a slice from an image to a 2D plane for display.
void smallest(Bimage *p)
Selects the smallest of each pixel from two images.
int place_with_overlap(Bimage *p, long nn)
Packs a tile into a new composite image with weighted overlap.
void divide_one(Bimage *p, double scale=1, double shift=0)
Divides the first image by the first sub-image of the second.
void divide(Bimage *p, double scale=1, double shift=0)
Divides the first image by the second.
int back_project(Bimage *p, double resolution, double axis, fft_plan planf, fft_plan planb)
General image parameter class.
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.
CompoundType compound_type()
int shape(int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0)
Creates a shape in an image and fills it with a constant value.
void size(vector< long > vec)
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.
Bstring data_type_string()
Get the string representation of a datatype.
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.
double interpolate_wrap(long cc, double xx, double yy=0, double zz=0, long nn=0) const
Interpolates using a given location with wrapping.
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.
Bimage * rotate_height(Matrix3 mat, Vector3< double > translate, double threshold=0)
Rotates a 3D map and calculates the height along the z-axis.
void power(double v)
Calculates the power of an image.
long index(long nx, long ny, long nz, long nn) const
long mask_region_interfaces(int reg_num)
Reports the whole interface matrix or interfaces for one region only.
unsigned char * data_alloc()
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.
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.
Class for 3-value vectors.
int fspace_reconstruction_stats(double resolution, double sampling_ratio=1)
Calculates Fourier shell statistics.
void color_to_simple()
A color image is converted to a simple image.
long mask_pack_plane(Matrix3 mat, double hi_res, double scale)
Packs a 2D mask into a 3D reciprocal space volume.
int filter_rank_chunk(long kernel_size, double rank, float *nudata, long i, long len)
long check_neighbors(long idx)
Check neighbors in region map and assign a value if a neighbor is assigned.
long mask(Bimage *pmask, double fill)
Masks an image.
Bimage * resolution_prepare(Bimage *p)
Bimage * extract(long nn, Vector3< double > loc, Vector3< long > size, Vector3< double > origin)
void show_scale(double scale)
long kernel_max_neigbor(long idx, long ksize)
Finds the highest value in a kernel excluding the central voxel.
Bimage * levelmask_asymmetric_units(Bsymmetry *sym, int index)
Calculates a multi-level mask to indicate asymmetric units.
int replace(Bimage *img)
Replaces the data with that from the given image.
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.
void fix_type()
Determines the replacement data type.
Bimage * fsc_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.
long index(Vector3< long > vox, long nn) const
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.
int fspace_weigh(long maxrad, double *curve, int flag=0)
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.
Header file for the string class.
Complex< double > complex(long j)
Returns a complex value at the given index.
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.
Bplot * levelmask_size_histogram()
Color a multi-level mask based on the volumes of regions.
void sum_images()
Adds all sub-images.
vector< double > quadric_fit()
Fits the whole image to a quadric surface.
int assemble_tiles(Bimage *pt, int flag=0)
Assembles overlapping tiles into this image.
int truncate_to_min_max(double minim, double maxim)
Truncates image data to a given minimum and maximum.
int center_wrap()
Centers an image with wrapping.
Bplot * plot()
Converts a one-dimensional image into a plot.
int change_symmetry(Bsymmetry *symold, Bsymmetry *symnu, double radius, double z_slope)
Changes the symmetry order for cyclic and dihedral maps.
long compound_type_size()
long apply_soft_mask(long nn, Bimage *pmask, int fill_type, double fill)
Applies a soft mask to a sub-image.
double complex_power()
Calculates the power in a complex image.
unsigned char * data_alloc_and_clear()
Bimage * region_peaks(long kernel_size, double threshold, int flood=0, int wrap=0)
Generates a segmented image from peaks above a threshold value.
Bimage * extract_magnify(long nn, Vector3< long > center, Vector3< long > ext_size, double scale)
Extracts a region from an image to magnify.
unsigned char * data_alloc_and_clear(DataType type, CompoundType ctype, long nx, long ny, long nz, long nn)
void show_minimum(double v)
Bimage * montage(int first, int cols, int rows, int skip=0, int flipy=0)
Rearranges an image into a montage of 2D slices for display.
double interpolate_wrap(Vector3< double > vec, long nn=0) const
Bplot * histogram_poisson_fit(long bins, int flag=0)
Fits a poisson function to a histogram of an image.
CompoundType
Compound data type specifier.
double density(long nn, Vector3< double > coord, double radius)
int convolve_chunk(Bimage *pkernel, float *nudata, long i, long len)
void subtract(Bimage *p)
Subtracts another image from an image.
int fspace_bandpass(double res_hi, double res_lo=0, double width=0)
Applies a bandpass filter to an image.
vector< double > pps_angular_correlation(Bimage *pref, double res_hi, double res_lo, long nang, fft_plan planf)
double peak_sigma(long nn, Vector3< long > coor, long kernel_size)
Calculates a sigma value for a cross-correlation peak.
long fspace_maximum_radius(double resolution, double sampling_ratio=1)
Calculates the maximum radius in frequency space from a given resolution.
Vector3< long > kernel_high(long i, Vector3< long > k)
int fspace_weigh_B_factor(double B, double resolution=0)
Weighs an image's amplitudes with B-factor (gaussian) curve.
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.
Bplot * percentiles()
Calculates the percentiles from the histogram of an image.
int color_blue(double cmin, double cmax, int flag=0)
Converts a gray-scale image to blue.
int kernel_gaussian(double sigma, double max)
Generates a gaussian kernel image.
int fspace_amp_threshold(double threshold)
Filters the amplitudes of the Fourier transform of an image.
int extract_show_chunk(Bimage *pshow, int aflag, long i, long len)
void data_delete()
Deallocates the image data.
double check_point_group(Bstring &check_string)
Checks for the requested symmetries.
void check_resolution(double &resolution)
Checks that the resolution falls within reasonable limits.
int fspace_normalize_radial(Bimage *pmask, double resolution=0, int flag=0)
Normalizes an image's amplitudes.
Bimage * pad_copy(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
double interpolate(double xx, double yy=0, double zz=0, long nn=0, double fill=0) const
unsigned char * read_data(ifstream *fimg, int img_select, int sb, int vax, long pad)
Read image data in a generalized style.
double interpolate(long cc, double xx, double yy=0, double zz=0, long nn=0, double fill=0) const
Interpolates using a given location.
vector< Vector3< long > > tile_coordinates(Vector3< long > &start, Vector3< long > ®ion, Vector3< long > &tile_size, Vector3< long > &step_size, int exceed)
Generates a set of tile coordinates for an image.
double complex_normalize()
Normalizes the power in a complex image.
Matrix3 symmetry_equivalent(Bimage *ptemp, Bimage *pmask, Bsymmetry *sym)
Finds the symmetry equivalent orientation of a particle with respect to a template.
int moments(long max_order)
Prints out moments for all sub-images.
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.
long levelmask_collapse()
Collapse a multi-level mask to a binary mask.
Bimage * nad(double ht, long zw, double lambda, double C, double alpha)
Denoises a 3D density map by non-linear anisotropic diffusion.
void origin(Vector3< double > vec)
bool isfinite(complex< T > &value)
int impose_superpixels(Bimage *pmask, vector< Bsuperpixel > &seg, int impose)
Impose superpixel features onto an image.
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
void complex_to_amplitudes()
The amplitudes from a complex image is written to a simple image.
Bimage * extract_shell(long nn, double minrad, double maxrad)
Extracts a shell from an image into a new image.
void origin(double ox, double oy, double oz)
long mask_invert()
Inverts a mask.
Bplot * histogram_gauss_plot(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
void complex_to_phases()
The phases from a complex image is written to a simple image.
long fspace_reconstruction_add(Bimage *p)
Adds all components to a reconstruction.
TypePointer fill_value(double v)
Bplot * fsc(double hi_res, double sampling_ratio=1)
Vector3< double > real_coordinates(long ix, long iy, long iz)
void origin(Vector3< double > vec)
void rgb_to_rgba()
An alpha channel is added to a RGB color image.
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.
long levelmask_add(Bimage *pmask, int add_level=1)
Adds a bilevel mask to a level mask.
void change_type(char letter)
Get the data type indicated by a single letter code.
long index(long nx, long ny) const
int refine_peak_new()
Refines the position of a peak to sub-voxel resolution.
vector< JSvalue * > query(string &path)
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)
Bimage * variance_mask(long kernel_size, double lowvar=1e-6, int bkg_flag=0)
Calculates a mask based on local variance.
Bimage * extract_line(long nn, Vector3< double > start, Vector3< double > end, long width)
Extracts a line from an image into a new image.
int fspace_amp_one()
Sets all amplitudes to one.
void square()
Calculates the square of an image.
void fourier_type(FourierType tf)
int complex_conjugate_product(Bimage *p)
Calculates the product of a complex image with the conjugate of a second.
void meta_data_update()
Update metadata from the sub-image information.
Bimage * mask_extract(Bimage *pmask)
Zeroes everything outside the mask and return the excised feature.
double interpolate(long cc, Vector3< double > vec, long nn=0, double fill=0) const
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.
Bimage * topograph_to_surface(Bimage *psd, long nz, double density, double resolution)
Converts a 2D AFM image to a 3D density map.
int one_color(int color, double cmin, double cmax, int flag=0)
Converts a gray-scale image to a single color.
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.
bool compatible(Bimage *p)
Check if this image has the same number of channels and data type as another.
int fspace_pack_2D(Bimage *p, Matrix3 mat, double hi_res, double lo_res, Vector3< double > scale, double part_weight=1, int interp_type=0)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
long stats_in_mask(long nn, Bimage *pmask)
Calculates the statistics for an image for each level in a mask.
long index(vector< long > vox, long nn) const
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.
void origin(vector< double > vec)
Generalized matrix class.
int filter_average(long kernel_size)
Applies an averaging filter to an image.
double linear_fit(Bimage *p, Bimage *pmask, double max_exclude)
Linear least squares fit of two images.
Vector3< long > kernel_high(long i, long k=1)
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
long mask_split(long voxels_per_level)
Converts a mask to a multilevel mask with a given number of voxels per level.
void catenate(long m, Bimage **p)
Catenates an array of images of the same size into a multi-image structure.
void check()
Checks an image for reasonable properties.
Bimage * periodic_averaging(Vector3< double > period)
Calculates an average within a periodic frame.
int rescale_to_min_max(double numin, double numax)
Rescales the image data to a given minimum and maximum.
void simple_to_rgb()
A simple image is converted to a color image.
int fspace_sqrt_amp()
Change the amlitudes to their square roots.
void sampling(double x, double y, double z)
Bplot * 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.
void page_size(Vector3< long > vec)
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
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.
long rotate_to_axis(Bsymmetry *sym, long axis, long axis_flag)
Rotates to a symmetry axis.
int noise_poisson(double ravg)
Generates an image with a poisson random distribution of densities.
CMYK< double > cmyk(long j)
Returns a color value at the given index.
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...
int subimage_information()
Prints out header information for all sub-images.
int filter_bilateral_chunk(Bimage *pkernel, double sigma2, int kernel_type, float *nudata, long i, long len, int first)
void invert()
Inverts the data in the image.
Bimage * filter_peak(long kernel_size)
Finds the peaks in an image.
unsigned char * data_pointer()
Matrix mask_interface_matrix(int img_num)
Calculates the interfaces between regions.
bool check_if_same_image_size(Bimage *p)
Check if two images are the same size.
vector< Vector3< double > > sampling()
int max_in_kernel(long ksize)
unsigned char * data_assign(unsigned char *nudata)
Assign image data.
~Bimage()
Image destructor.
General FFT for n-dimensional data.
void square_root()
Calculates the square root of an image.
Bimage * intensities_phase_colored(double scale)
Generates a power spectrum with phases colored according to a color wheel.
double rotate_correlate(Vector3< double > axis, double angle)
Rotates a copy of an image and correlates it with the original.
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
long mask_plane(Vector3< double > origin, Vector3< double > normal)
Generates a mask on one side of a plane.
double interpolate_wrap(long cc, Vector3< double > vec, long nn=0) const
int complex_product(Bimage *p)
Calculates the complex product of two complex images.
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.
int phase_flip(Bimage *pd)
Flips the phases of an image based on a phase difference map.
void check_sampling()
Checks that the sampling is properly specified.
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.
int color_combine(Bimage *p)
Combines two colored images.
void sampling(long nn, Vector3< double > u)
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.
int limit_levels(int nlevels)
Converts a full gray scale image to a limited level image.
void update_from_meta_data()
Update sub-image information from the metadata.
int subtract_background()
Subtracts the background for each sub-image.
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.
double snvariance(double snradius)
Calculates the ratio of variance inside and outside a given radius.
void coordinates(long i, long &nc, long &nx, long &ny, long &nz, long &nn)
int fspace_weigh_LoG(double resolution, double sigma)
Weighs an image's amplitudes with a Laplacian-of-Gaussian function.
long mask_combine(Bimage *p, int operation)
Combines two masks with different operations.
long levelmask_switch(long index1, long index2)
Switches two segments in a multi-level mask.
Bimage * blend(Bimage *p, long number)
Blends the two images, creating a new set of sub-images.
int fspace_weigh_RPS_curve(Bplot *plot, double resolution=0)
Weighs an image's amplitudes with a given RPS curve.
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.
long index_wrap(vector< long > coor) const
DataType
Base data type specifier.
Bimage * defocus_scale(long nn, double df, double df2, double iCL2, int fill_type)
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
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.
void origin(long nn, Vector3< double > vec)
void size(long nx, long ny, long nz)
long levelmask_colorize()
Colorizes a multi-level mask with random color assignments.
Bimage * tile_mask(long step)
Converts a mask to a tiled multilevel mask.
int pure_color()
Generates a pure color image without intensity.
void simple_to_rgba()
A simple image is converted to a color image.
void origin(vector< double > vec)
Vector3< double > sampling()
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.
bool within_boundaries(Vector3< double > loc)
int fspace_pack_3D(Bimage *p, double hi_res=0, double threshold=0)
Packs a 3D Fourier transform into a 3D reciprocal space volume.
Vector3< long > kernel_low(long i, long k=1)
int complex_apply_mask(Bimage *pmask)
Applies a mask to a complex image.
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.
int kernel_laplacian_of_gaussian(double sigma, double max)
Generates a laplacian-of-gaussian kernel.
Vector3< long > image_coordinates(double xx, double yy, double zz)
void identifier(Bstring s)
int median_bin(int binning)
Bins by an integer size, selecting the kernel median.
long mask_open(int times=1)
Opens a binary mask.
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.
int fspace_scale(long maxrad, double *scale, Bimage *pmask=NULL)
void background(double d)
int filter_dog(double sigma1, double sigma2)
Convolves the image with a difference of gausians kernel.
int filter_ortho(int type)
Convolves the image with an orthogonal kernel with wrapping.
int filter_rolling_ball(long radius, double scale)
Apply a rolling ball filter.
double convert_to_helix(double helix_rise, double helix_angle, Vector3< double > offset)
Converts a map to a helix.
void magnification(double d)
Bplot * filament_width(long width, long lim_lo, long lim_hi)
Estimates the width of a filament.
RGB< double > rgb(long j)
Returns a color value at the given index.
long mask_rectangle(double length, double width, double rect_angle, int wrap)
Generates a mask along an axis within a 2D image.
int complex_bandpass(double hires, double lores)
Bandpasses a Fourier transform.
void largest(Bimage *p)
Selects the largest of each pixel from two images.
Bimage * orthogonal_slices(long nn, Vector3< long > voxel, Vector3< long > ext_size)
Extracts orthogonal views around a voxel.
double maximum_included_radius()
Returns the radius of the enclosed sphere or circle.
void complex_to_signed_amplitudes()
The signed amplitudes from a complex image is written to a simple image.
int unpack_transform(unsigned char *data, FourierType tf)
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.
void logarithm()
Calculates the logarithm of the image data.
long stats_within_radii(long nn, Vector3< double > loc, double rad_min, double rad_max, double &vavg, double &vstd)
Calculates the statistics for an image within given radii from a location.
long index_wrap(long nx, long ny, long nz) const
void sampling(Vector3< double > vec)
long mask_close(int times=1)
Closes a binary mask.
vector< long > histogram(long bins, double &scale, double &offset)
Calculates the histogram of an image.
int mask_fspace_banded(vector< double > &band)
Generate reciprocal space mask based on a specification of bands.
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 sh...
double friedel_check()
Checks Friedel symmetry.
int combined_complex_product()
Calculates the complex conjugate product of a complex image resulting from combining and Fourier tran...
void space_group(unsigned int grp)
Vector3< double > fit_peak()
Fits an elliptic parabole to locate the position of the peak to sub-voxel resolution.
long mask_merge_delete(long min_size, long min_if)
Calculates the interfaces between regions and deletes/merges small ones.
int filter_bilateral(double sigma1, double sigma2, int kernel_type, long kernel_radius)
Denoise an image with combined gaussian distance and density difference kernel.
int symmetrize_cylinder()
Calculates a cylindrically symmetrized map.
int fspace_resize(double scale, double res_hi, double res_lo)
Resizes an image in frequency space to avoid interpolation.
Bplot * 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.
void view(double vx, double vy, double vz, double va)
int superpixels_update(Bimage *pmask, vector< long > vstep, double colorweight, vector< Bsuperpixel > &seg)
int histomatch(Bimage *p, long bins)
Fits two images by matching the histogram of the second to the first.
void complex_to_real()
The real part of a complex image is written to a simple image.
void transform_voxel(long i, Bimage *pt, long nn, Vector3< double > oldorigin, Vector3< double > nuorigin, Matrix3 affmat, double fill)
int quadric(double *param)
Generates a quadric surface over the whole image.
long mask_missing_cone(Vector3< double > origin, double mis_ang, double resolution)
Generates a mask with a missing cone.
Bimage * cartesian_to_spherical(long nannuli, long nphi, long ntheta)
Calculates an image with spherical coordinates.
long statistics()
Calculates the statistics for an image.
bool check_if_same_size(Bimage *p)
Check if two images are the same size.
int filter_extremes()
Filters the extremes out of a micrograph image.
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.
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.
int resize(Vector3< long > nusize, Vector3< long > translate, int fill_type=0, double fill=0)
Resizes without interpolation or rescaling.
long index(long nc, long nx, long ny, long nz, long nn) const
void standard_deviation(double d)
int sphere(Vector3< double > center, double radius, double width=0, int fill_type=0, double fill=0)
Fills a sphere within an image with a uniform value.
long select_images(Bstring list)
int noise_spectral(double alpha)
Generates a noise map with a defined spectral decay.
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.
long stats_in_shape(long nn, int type, Vector3< long > start, Vector3< long > end, double &vavg, double &vstd)
Calculates the statistics for an image within the given box.
int auto_correlate(double hires, double lores)
Calculates an autocorrelation map by Fast Fourier transformation.
int gaussian_sphere(long nn, Vector3< double > center, double sigma, double amp)
Fills a gaussian sphere within an image with a uniform value.
int color_red(double cmin, double cmax, int flag=0)
Converts a gray-scale image to red.
Bimage * polar_power_spectrum(double resolution, long num_angle)
Calculates the polar power spectrum of a 2D transform amplitude or intensity image.
long replace_maxima(double threshold)
Replaces maxima above a threshold using local averages.
double otsu_threshold(long bins)
Calculates the threshold on a histogram according to Otsu.
void data_type(DataType dt)
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
double dyad_interpolate(long i, int norm_flag=1)