 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
45 long i, j, xx, yy, zz, slice_size(x*y);
47 double mn, mx, zdis, scale;
52 mn = mx = resolution*0.5;
57 for ( i=0; i<slice_size; i++ )
63 for ( i=0; i<slice_size; i++ )
80 cout <<
"Converting a 2D image into a 3D surface density" << endl;
81 cout <<
"New z dimension: " << nz << endl;
82 cout <<
"Dimension scale: " <<
sampling(0) <<
" A/pixel" << endl;
83 cout <<
"Density scale: " << scale <<
" A/(unit density)" << endl;
86 cout <<
"Resolution: " << resolution <<
" A" << endl;
89 cout <<
"Density within surface: " <<
density <<
" Da/A3" << endl << endl;
91 cout <<
"Converting a 2D image into a 3D surface density" << endl << endl;
93 for ( i=yy=0; yy<y; yy++ ) {
94 for ( xx=0; xx<x; xx++, i++ ) {
95 zdis = loz + scale*((*this)[i]-min);
96 for ( j=i, zz=0; zz<psurf->z; zz++, j+=slice_size )
97 psurf->
set(j, voxel_density/(1+exp(factor*(zz-zdis)/(*psd)[i])));
101 if ( local_psd )
delete psd;
121 long i, j, xx, yy, zz, nn;
126 cout <<
"Converting a 3D image into a 2D height image" << endl;
127 cout <<
"Threshold: " << threshold << endl << endl;
130 for ( i=nn=0; nn<n; nn++ ) {
131 for ( zz=0; zz<z; zz++ ) {
132 for ( yy=0; yy<y; yy++ ) {
133 for ( xx=0; xx<x; xx++, i++ ) {
137 if ( (*
this)[i] >= threshold ) p->
set(j, zz);
139 if ( (*
this)[i] <= threshold ) p->
set(j, zz);
170 double radial_cutoff = x;
171 if ( radial_cutoff < 1 ) radial_cutoff = x;
181 cout <<
"Rotating around the map center and calculating height:" << endl;
182 cout <<
"Rotation origin: " << oldorigin << endl;
183 cout << matinv << endl;
184 if ( translate[0] != 0 || translate[1] != 0 || translate[2] != 0 )
185 cout <<
"Translation: " << translate << endl;
187 cout <<
"Threshold: " << threshold << endl;
193 pheight->
origin(nuorigin[0], nuorigin[1], 0);
195 double d, dz, bottom(u[2]*z);
197 for ( i=yy=0; yy<y; yy++ ) {
198 nuvec[1] = yy - nuorigin[1];
199 for ( xx=0; xx<x; xx++, i++ ) {
200 nuvec[0] = xx - nuorigin[0];
201 for ( zz=z-1; zz; zz-- ) {
202 nuvec[2] = zz - nuorigin[2];
203 old = mat * nuvec + oldorigin;
205 if ( d > threshold ) {
207 if ( (*pheight)[i] <= 0 ) pheight->
set(i, dz);
208 if ( bottom > dz ) bottom = dz;
214 for ( i=0; i<x*y; ++i )
if ( (*pheight)[i] ) pheight->
add(i, -bottom);
233 error_show(
"Error in Bimage::height: No views defined!", __FILE__, __LINE__);
249 for ( v=views, i=0; v; v = v->
next, i++ ) vlist[i] = *v;
252 cout <<
"Calculating height images:" << endl;
253 cout <<
"Number of images: " << nviews << endl;
254 cout <<
"Threshold: " << threshold << endl << endl;
262 dispatch_apply(nviews, dispatch_get_global_queue(0, 0), ^(
size_t i){
268 pheight->
replace(i, one_height);
275 #pragma omp parallel for
276 for (
long i=0; i<nviews; i++ ) {
282 pheight->
replace(i, one_height);
Bimage * height(View *views, double threshold=0)
Calculates a set of height images from a 3D density map.
void set(long j, double v)
Sets a single value at the given index.
Matrix3 transpose() const
Bimage()
Initializes an image.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Bimage * surface_to_topograph(double threshold, int dir=0)
Converts a 3D image to a 2D height image.
void view(double x, double y, double z, double a)
long count_list(char *list)
Counts the number of items in a linked list.
double density(long nn, Vector3< double > coord, double radius, double &sigma)
Calculates the density in a sphere around a coordinate in an image.
void origin(double x, double y, double z)
int shift_background(double bkg)
Sets the background for each sub-image to a given value.
void add(long j, double v)
General image parameter class.
Bimage * rotate_height(Matrix3 mat, Vector3< double > translate, double threshold=0)
Rotates a 3D map and calculates the height along the z-axis.
unsigned char * data_alloc()
int replace(Bimage *img)
Replaces the data with that from the given image.
Header file for image class.
Header file for general utilities.
double interpolate(long cc, double xx, double yy=0, double zz=0, long nn=0, double fill=0) const
Interpolates using a given location.
void origin(double ox, double oy, double oz)
Bimage * topograph_to_surface(Bimage *psd, long nz, double density, double resolution)
Converts a 2D AFM image to a 3D density map.
void sampling(double x, double y, double z)
Header file for generalized linked list functions.
vector< Vector3< double > > sampling()
void sampling(long nn, Vector3< double > u)
long statistics()
Calculates the statistics for an image.