35 void ProgLocalVolumeAdjust::defineParams() {
37 addUsageLine(
"This program modifies a volume in order to adjust its intensity locally to a reference volume");
41 addParamsLine(
"[-o <structure=\"\">]\t: Volume 2 modified or volume difference");
42 addParamsLine(
"\t: If no name is given, then output_volume.mrc");
44 addParamsLine(
"[--sampling <sampling=1>]\t: Sampling rate (A/pixel)");
45 addParamsLine(
"[--neighborhood <n=5>]\t: side length (in Angstroms) of a square which will define the region of adjustment");
46 addParamsLine(
"[--sub]\t: Perform the subtraction of the volumes. Output will be the difference");
47 addParamsLine(
"--save <structure=\"\">\t: Path for saving occupancy volume");
51 void ProgLocalVolumeAdjust::readParams() {
56 fnOutVol =
"output_volume.mrc";
65 void ProgLocalVolumeAdjust::show()
const {
66 std::cout <<
"Input volume 1 (reference):\t" << fnVol1 << std::endl
67 <<
"Input volume 2:\t" << fnVol2 << std::endl
68 <<
"Input mask:\t" << fnMask << std::endl
69 <<
"Output:\t" << fnOutVol << std::endl;
72 void ProgLocalVolumeAdjust::run() {
89 neighborhood_px =
round(neighborhood/sampling);
90 int cubic_neighborhood;
91 cubic_neighborhood = neighborhood_px*neighborhood_px*neighborhood_px;
93 int xsize =
XSIZE(mV);
94 int ysize =
YSIZE(mV);
95 int zsize =
ZSIZE(mV);
105 for (
size_t s=0; s < iters; s++)
110 for (k=0; k < neighborhood_px; ++k)
112 for (i=0; i < neighborhood_px; ++i)
114 for (j=0; j < neighborhood_px; ++j)
133 c = sumV_Vref/sumVref2;
136 for (k=0; k < neighborhood_px; ++k)
138 for (i=0; i < neighborhood_px; ++i)
140 for (j=0; j < neighborhood_px; ++j)
152 if (ji < (xsize-neighborhood_px))
153 ji += neighborhood_px;
158 if (ii < (ysize-neighborhood_px))
159 ii += neighborhood_px;
163 if (ii == 0 && ji == 0)
165 if (ki < (zsize-neighborhood_px))
166 ki += neighborhood_px;
175 if (performSubtraction)
void min(Image< double > &op1, const Image< double > &op2)
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
const char * getParam(const char *param, int arg=0)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
#define DIRECT_A3D_ELEM(v, k, i, j)
String formatString(const char *format,...)
bool checkParam(const char *param)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
int getIntParam(const char *param, int arg=0)
void addParamsLine(const String &line)