38 cout <<
"DEBUG img_power_spectrum: flags=" << flags << endl;
46 return error_show(
"img_power_spectrum", __FILE__, __LINE__);
98 if ( pad < p->sizeY()/10 ) pad = p->
sizeY()/10;
104 tile_size = tile_size.
max(min_size);
106 if ( tile_size.
x() > p->
sizeX() ) tile_size[0] = p->
sizeX();
107 if ( tile_size.
y() > p->
sizeY() ) tile_size[1] = p->
sizeY();
108 if ( tile_size.
z() > p->
sizeZ() ) tile_size[2] = p->
sizeZ();
110 tile_size = tile_size.
min(max_size);
112 ext_size[0] = tile_size.
x()*((p->
sizeX() - 2*pad)/tile_size.
x());
113 ext_size[1] = tile_size.
y()*((p->
sizeY() - 2*pad)/tile_size.
y());
114 ext_size[2] = tile_size.
z()*((p->
sizeZ() - 2*pad)/tile_size.
z());
115 ext_size = ext_size.
max(1);
117 start[0] = (p->
sizeX() - ext_size.
x())/2;
118 start[1] = (p->
sizeY() - ext_size.
y())/2;
119 start[2] = (p->
sizeZ() - ext_size.
z())/2;
122 cout <<
"DEBUG img_tiled_powerspectrum: start=" << start << endl;
123 cout <<
"DEBUG img_tiled_powerspectrum: tile_size=" << tile_size << endl;
132 size[0] = pex->
sizeX();
135 if ( pex->
sizeY() > 1 ) size[1] = size.
x();
136 if ( pex->
sizeZ() > 1 ) size[2] = size.
x();
162 double tilt_axis,
double tilt_offset,
int flags)
168 int i, x, y, ntiles = 0;
169 double tan_a =
btan(tilt_axis);
170 double inv_tan_a = 1.0/tan_a;
175 tile_size = tile_size.
max(min_size);
177 if ( tile_size.
x() > p->
sizeX() ) tile_size[0] = p->
sizeX();
178 if ( tile_size.
y() > p->
sizeY() ) tile_size[1] = p->
sizeY();
179 if ( tile_size.
z() > p->
sizeZ() ) tile_size[2] = p->
sizeZ();
181 tile_size = tile_size.
min(max_size);
185 if ( fabs(tilt_axis) < ratang || fabs(tilt_axis) >
M_PI - ratang ) {
186 origin[1] += (int)tilt_offset;
187 ntiles = p->
sizeX()/tile_size.
x();
189 for ( i=0, x = origin.x() - (ntiles * tile_size.
x())/2; i<ntiles; i++, x += tile_size.
x() ) {
191 tile[i][1] = (int) (origin.y() + (x - origin.x())*tan_a);
194 origin[0] += (int)tilt_offset;
195 ntiles = p->
sizeY()/tile_size.
y();
197 for ( i=0, y = origin.y() - (ntiles * tile_size.
y())/2; i<ntiles; i++, y += tile_size.
y() ) {
198 tile[i][0] = (int) (origin.x() + (y - origin.y())*inv_tan_a);
204 cout <<
"DEBUG img_tilt_axis_powerspectrum: origin=" << origin << endl;
205 cout <<
"DEBUG img_tilt_axis_powerspectrum: tile_size=" << tile_size << endl;
206 cout <<
"DEBUG img_tilt_axis_powerspectrum: ntiles=" << ntiles << endl;
207 for ( i=0; i<ntiles; i++ )
208 cout <<
"DEBUG img_tilt_axis_powerspectrum: " << tile[i].x() <<
" " << tile[i].
y() << endl;
219 size[0] = pex->
sizeX();
222 if ( pex->
sizeY() > 1 ) size[1] = size.
x();
223 if ( pex->
sizeZ() > 1 ) size[2] = size.
x();
264 cout <<
"Generating a phase-coloured power spectrum" << endl;
266 cout <<
"Generating a phase-coloured power spectrum" << endl;
283 for ( i=0; i<datasize; i++ ) {
284 amp_ratio = (p->
complex(i)).amp()*scale;
285 if ( amp_ratio > 0 ) {
286 if ( amp_ratio > 255 ) amp_ratio = 255;
void change_type(char letter)
Get the data type indicated by a single letter code.
int img_write_phase_colour_wheel()
Generates a phase color wheel.
Header file for general utilities.
CompoundType compound_type()
Bimage * img_tilt_axis_powerspectrum(Bimage *p, Vector3< int > tile_size, double tilt_axis, double tilt_offset, int flags)
Prepares an tilted image for determining CTF parameters.
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
void logarithm()
Calculates the logarithm of the image data.
int center_wrap()
Centers an image with wrapping.
double average(size_t cc, double xf, double yf, double zf, size_t nn, double iscale)
Averages in the xy plane when scaling is less than 1.
size_t statistics()
Calculates the statistics for an image.
Functions to handle complex data sets.
Functions to handle RGB images.
General image parameter class.
Complex< double > complex(size_t j)
Returns a complex value at the given index.
double btan(double x)
Avoid non-zero values for tan(PI) and tan(-PI). ATTENTION: tan function return a bigg value for tan(P...
Library routines for interpolating images.
General FFT for n-dimensional data.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
Header file for combining two images in various ways.
int img_fft(Bimage *p)
Fast Fourier transforms an image.
double batan2(double y, double x)
Sets small values to zero before calling atan2.
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
void complex_to_intensities()
The intensities from a complex image is written to a simple image.
Header file for trigonometry functions.
void set(size_t j, double v)
Sets a single value at the given index.
int img_average(Bimage *p)
Averages images in a multi-image file.
double standard_deviation()
void color_to_simple()
A color image is converted to a simple image.
Bimage * img_colour_power_spectrum(Bimage *p, float scale)
Generates a power spectrum with phases coloured according to a colour wheel.
Bimage * img_tiled_powerspectrum(Bimage *p, Vector3< int > tile_size, int flags)
Prepares an image for determining CTF parameters.
void phase(double phi, double amp_ratio)
int resize(Vector3< int > nusize, Vector3< int > translate, int fill_type, double fill)
Resizes without interpolation or rescaling.
int img_power_spectrum(Bimage *p, int flags)
Calculates a power spectrum.
FourierType fourier_type()
void origin(double ox, double oy, double oz)