36 addParamsLine(
" [--oroot <fn=\"estimated\">]: Estimated corrections and gains");
37 addParamsLine(
" :+(Ideal=Observed*Corr, Observed=Ideal*Gain)");
39 addParamsLine(
" [--sigma <s=-1>]: Sigma to use, if negative, then it is searched");
40 addParamsLine(
" [--maxSigma <s=3>]: Maximum number of neighbour rows/columns to analyze");
41 addParamsLine(
" [--frameStep <s=1>]: Skip frames during the estimation");
42 addParamsLine(
" : Set to 1 to process all frames, set to 2 to process 1 every 2 frames, ...");
44 addParamsLine(
" [--singleRef] : Use a single histogram reference");
45 addParamsLine(
" :+This assumes that there is no image contamination or carbon holes");
46 addParamsLine(
" [--gainImage <fn=\"\">] : Reference to external gain image (we will divide by it)");
47 addParamsLine(
" [--applyGain <fnOut>] : Flag for using external gain image");
48 addParamsLine(
" : applyGain=True will use external gain image");
93 IGain().initConstant(1);
104 Iframe.
read(fnFrame);
117 for (
size_t i=0;
i<=numIterations; ++
i)
124 auto *weights=
new double[jmax+1];
128 for (
int j=0;
j<=jmax; ++
j)
129 weights[
j]=exp(K*
j*
j);
139 <<
"Input movie: " <<
fnIn << std::endl
140 <<
"Output rootname: " <<
fnRoot << std::endl
141 <<
"N. Iterations: " <<
Niter << std::endl
142 <<
"Sigma: " <<
sigma << std::endl
143 <<
"Max. Sigma: " <<
maxSigma << std::endl
144 <<
"Sigma step: " <<
sigmaStep << std::endl
146 <<
"Frame step: " <<
frameStep << std::endl
147 <<
"Ext. gain image: " <<
fnGain << std::endl
148 <<
"Apply ext. gain: " <<
applyGain << std::endl
167 for (
size_t objId :
mdIn.
ids())
170 Iframe.
read(fnFrame);
181 std::cout <<
"Iteration " <<
n << std::endl;
184 for (
size_t objId :
mdIn.
ids())
189 std::cout <<
" Frame " << fnFrame << std::endl;
190 Iframe.
read(fnFrame);
191 IframeIdeal = Iframe();
197 size_t bestSigmaCol = 0;
200 double bestDistance=1e38;
210 std::cout <<
" sigmaCol: " <<
listOfSigmas[bestSigmaCol] << std::endl;
211 size_t bestSigmaRow = 0;
215 double bestDistance=1e38;
225 std::cout <<
" sigmaRow: " <<
listOfSigmas[bestSigmaRow] << std::endl;
253 save.
write(
"PPPSumIdeal.xmp");
255 save.
write(
"PPPSumObs.xmp");
266 auto* auxElemC=
new double[
Ydim];
267 auto* auxElemR=
new double[
Xdim];
291 save.
write(
"PPPcolumnH.xmp");
293 save.
write(
"PPProwH.xmp");
304 double sumWeightsC = 0;
305 for(
int k = -width;
k<=width; ++
k)
309 double actualWeightC = listOfWeights[
abs(
k)];
310 sumWeightsC += actualWeightC;
315 double iSumWeightsC=1/sumWeightsC;
327 double iXdim=1.0/
Xdim;
339 save.
write(
"PPPsmoothColumnH.xmp");
348 double sumWeightsR = 0;
349 for(
int k = -width;
k<=width; ++
k)
353 double actualWeightR = listOfWeights[
abs(
k)];
354 sumWeightsR += actualWeightR;
358 double iSumWeightsR=1/sumWeightsR;
370 double iYdim=1.0/
Ydim;
383 save.
write(
"PPPsmoothRowH.xmp");
404 double *pixvalPtr=std::upper_bound(aSingleColumnH0,aSingleColumnHF,pixval);
406 int idx=pixvalPtr-aSingleColumnH0;
414 typeCast(IframeTransformedColumn,save());
415 save.
write(
"PPPIframeTransformedColumn.xmp");
417 save.
write(
"PPPIframe.xmp");
418 std::cout <<
"Press any key to continue\n";
419 char c; std::cin >>
c;
438 double *pixvalPtrR=std::upper_bound(aSingleRowH0,aSingleRowHF,pixvalR);
440 int idxR=pixvalPtrR-aSingleRowH0;
447 typeCast(IframeTransformedRow,save());
448 save.
write(
"PPPIframeTransformedRow.xmp");
450 save.
write(
"PPPIframe.xmp");
451 std::cout <<
"Press any key to continue\n";
452 char c; std::cin >>
c;
479 double bestAvgTV=1e38;
499 double bestAvgTV=1e38;
MultidimArray< double > rowH
size_t selectBestSigmaByRow(const MultidimArray< double > &Iframe)
#define A2D_ELEM(v, i, j)
std::vector< double > listOfSigmas
std::vector< double * > listOfWeights
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
void resizeNoCopy(const MultidimArray< T1 > &v)
void constructSmoothHistogramsByColumn(const double *listOfWeights, int width)
#define DIRECT_A2D_ELEM(v, i, j)
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)
void computeHistograms(const MultidimArray< double > &Iframe)
void abs(Image< double > &op)
Incorrect MultidimArray size.
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
MultidimArray< double > sumObs
MultidimArray< double > columnH
double computeTVColumns(MultidimArray< double > &I)
String getExtension() const
#define DIRECT_A1D_ELEM(v, i)
const char * getParam(const char *param, int arg=0)
MultidimArray< double > smoothRowH
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
void transformGrayValuesRow(const MultidimArray< double > &Iframe, MultidimArray< double > &IframeTransformedRow)
#define DIRECT_MULTIDIM_ELEM(v, n)
void createEmptyFile(const FileName &filename, int xdim, int ydim, int Zdim, size_t select_img, bool isStack, int mode, int _swapWrite, const MDRowVec *md)
int verbose
Verbosity level.
void sort(struct DCEL_T *dcel)
MultidimArray< double > smoothColumnH
void transformGrayValuesColumn(const MultidimArray< double > &Iframe, MultidimArray< double > &IframeTransformedColumn)
MultidimArray< double > aSingleRowH
std::vector< double > listOfWidths
MultidimArray< double > aSingleColumnH
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
void constructSmoothHistogramsByRow(const double *listOfWeights, int width)
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)
double computeAvg() const
double computeTVRows(MultidimArray< double > &I)
int getIntParam(const char *param, int arg=0)
void addParamsLine(const String &line)
size_t selectBestSigmaByColumn(const MultidimArray< double > &Iframe)