本文整理汇总了C++中Image::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Close方法的具体用法?C++ Image::Close怎么用?C++ Image::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::Close方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void Run() {
Image datImg;
datImg.LoadRaw(input.c_str());
const RawImage *datRaw = datImg.GetImage();
// ShiftTraces(*bfT0, *wellT0, datRaw->frames, datRaw->baseFrameRate, datRaw->timestamps, datRaw->image);
SynchDat sdat; //GridMesh<TraceChunk> traceChunks;
AddMetaData(sdat, datRaw, acqNum);
GenerateDataChunks(*config, *bfT0, datRaw, config->row_step, config->col_step, *sigmaTMid, sdat.mChunks, datImg);
serializer.Write(output.c_str(), sdat);
if (config->doDebug) {
char buffer[2048];
string tmp = input.substr(input.size()-8,8);
snprintf(buffer, sizeof(buffer), "comIn_%s", tmp.c_str());
OutputTraceChunks(sdat.mChunks,buffer);
TraceChunkSerializer readSer;
// GridMesh<TraceChunk> traceIn;
SynchDat sdatIn;
readSer.Read(output.c_str(),sdatIn);
snprintf(buffer, sizeof(buffer), "decomOut_%s", tmp.c_str());
OutputTraceChunks(sdatIn.mChunks,buffer);
}
datImg.Close();
}
示例2: CalculateGainCorrectionFromBeadfindFlow
//@TODO: Bad to have side effects on every image load from now on
// should be >explicit< pass of gain correction information to image loader
void ImageTransformer::CalculateGainCorrectionFromBeadfindFlow (char *_datDir, bool gain_debug_output)
{
// calculate gain of each well from the beadfind and use for correction of all images thereafter
Mask *gainCalcMask;
std::string datdir = _datDir;
std::string preBeadFind = datdir + "/beadfind_pre_0003.dat";
Image bfImg;
bfImg.SetImgLoadImmediate (false);
bool loaded = bfImg.LoadRaw (preBeadFind.c_str());
if (!loaded)
{
ION_ABORT ("*Error* - No beadfind file found, did beadfind run? are files transferred? (" + preBeadFind + ")");
}
gainCalcMask = new Mask (bfImg.GetCols(),bfImg.GetRows());
bfImg.FilterForPinned (gainCalcMask, MaskEmpty, false);
bfImg.SetMeanOfFramesToZero (1,3);
//@TODO: implicit global variable->explicit global variable-> explicit variable
GainCalculationFromBeadfind (gainCalcMask,bfImg.raw);
printf ("Computed gain for each pixel using beadind image\n");
if (gain_debug_output)
{
DumpTextGain(bfImg.GetCols(),bfImg.GetRows());
}
bfImg.Close();
delete gainCalcMask;
}
示例3: DeriveSpecsFromDat
void ImageSpecClass::DeriveSpecsFromDat ( SystemContext &sys_context, ImageControlOpts &img_control, SpatialContext &loc_context )
{
Image img;
ReadFirstImage(img, sys_context, img_control, loc_context);
TimeStampsFromImage(img,img_control);
DimensionsFromImage(img,loc_context);
img.Close();
}
示例4: LoadTraces
void LoadTraces(Mask &mask, vector<string> &files, vector<Traces> &flows) {
flows.resize(files.size());
for (size_t i = 0; i < files.size(); i++) {
Image img;
bool loaded = img.LoadRaw(files[i].c_str());
if (!loaded) {
ION_ABORT("Couldn't load file: " + files[i]);
}
flows[i].Init(&img, &mask, FRAMEZERO, FRAMELAST, FIRSTDCFRAME,LASTDCFRAME);
img.Close();
flows[i].CalcT0(true);
flows[i].FillCriticalFrames();
flows[i].CalcReference(50,50,flows[i].mGridMedian);
}
}
示例5: ChkFile
void ChkFile(char *fname, size_t maxX=0, size_t maxY=0, size_t maxF=0, bool verbose=false)
{
Image loader;
if (loader.LoadRaw(fname))
{
// this one is ok
//printf("File %s OK\n",fname);
cout << fname << " rows=" << loader.GetRows() << " cols=" << loader.GetCols() << " fames=" << loader.GetFrames() << endl << flush;
const RawImage *raw = loader.GetImage();
if (verbose)
{
size_t frames = loader.GetFrames();
size_t rows = loader.GetRows();
size_t cols = loader.GetCols();
size_t stride = rows*cols;
cout << "flow\tx(col)\ty(row)\tvalue" << endl << flush;
for (size_t f = 0; f < frames; f++) {
if (maxF>0 && f>=maxF)
break;
// First image copied in for this frame
for (size_t r = 0; r < rows; r++) {
if (maxY>0 && r>=maxY)
break;
for (size_t c = 0; c < cols; c++) {
if (maxX>0 && c>=maxX)
break;
cout << f << "\t" << c << "\t" << r << "\t" << raw->image[r * cols + c + stride * f] << endl << flush;
}
}
}
}
loader.Close();
}
else
{
printf("File %s FAILED\n",fname);
Error=1;
exit(-1);
}
}
示例6: main
//.........这里部分代码省略.........
const RawImage *bf1raw = bfImg1.GetImage();
Mask mask(bf1raw->cols, bf1raw->rows);
ImageTransformer::XTChannelCorrect(bfImg1.raw,bfImg1.results_folder);
bfImg1.FilterForPinned (&mask, MaskEmpty, false);
Image bfImg2;
string bfFile2 = inputDir + "/beadfind_pre_0001.dat";
bfImg2.LoadRaw(bfFile2.c_str());
ImageTransformer::XTChannelCorrect(bfImg2.raw,bfImg1.results_folder);
bfImg2.FilterForPinned (&mask, MaskEmpty, false);
const RawImage *bf2raw = bfImg2.GetImage();
GridMesh<T0Prior> t0Prior;
T0Calc bfT0;
/* Calc t0 and get prior. */
cout << "Doing beadfind t0" << endl;
GenerateBfT0Prior(config, bf1raw->image, bf1raw->baseFrameRate, bf1raw->rows, bf1raw->cols,
bf1raw->frames, bf1raw->timestamps,
config.row_step, config.col_step, &mask, bfT0, t0Prior);
GridMesh<T0Prior> t0Prior2;
T0Calc bfT02;
GenerateBfT0Prior(config, bf2raw->image, bf2raw->baseFrameRate, bf2raw->rows, bf2raw->cols,
bf2raw->frames, bf2raw->timestamps,
config.row_step, config.col_step, &mask, bfT02, t0Prior2);
SigmaTMidNucEstimation sigmaEst;
sigmaEst.Init(config.rate_sigma_intercept, config.rate_sigma_slope,
config.t0_tmid_intercept, config.t0_tmid_slope, bf1raw->baseFrameRate);
GridMesh<SigmaEst> sigmaTMid;
bfImg1.Close();
bfImg2.Close();
// Calculate individual well t0 by looking at neighboring regions
vector<float> wellT0;
bfT0.CalcIndividualT0(wellT0, 0);
vector<float> wellT02;
bfT02.CalcIndividualT0(wellT02, 0);
for (size_t i =0; i< wellT0.size();i++) {
if (wellT0[i] > 0 && wellT02[i] > 0) {
wellT0[i] = (wellT0[i] + wellT02[i])/2.0f;
}
else {
wellT0[i] = max(wellT0[i], wellT02[i]);
}
}
// Average the region level t0, should we do this first and then just do sinle well level?
for (size_t bIx = 0; bIx < bfT0.GetNumRegions(); bIx++) {
double t1 = bfT0.GetT0(bIx);
double t2 = bfT02.GetT0(bIx);
if (t1 > 0 && t2 > 0) {
t1 = (t1 + t2)/2.0;
}
else {
t1 = max(t1,t2);
}
bfT0.SetT0(bIx, t1);
}
// Single thread first dat
for (size_t datIx = 0; datIx < 1; ++datIx) {
cout << "Doing: " << datIx << endl;
示例7: CalcSignalReference
void BFReference::CalcSignalReference(const std::string &datFile, const std::string &bgFile,
Mask &mask, int traceFrame) {
Image bfImg;
Image bfBkgImg;
bfImg.SetImgLoadImmediate (false);
bfBkgImg.SetImgLoadImmediate (false);
bool loaded = bfImg.LoadRaw(datFile.c_str());
bool bgLoaded = bfBkgImg.LoadRaw(bgFile.c_str());
if (!loaded) {
ION_ABORT("*Error* - No beadfind file found, did beadfind run? are files transferred? (" + datFile + ")");
}
if (!bgLoaded) {
ION_ABORT("*Error* - No beadfind background file found, did beadfind run? are files transferred? (" + bgFile + ")");
}
const RawImage *raw = bfImg.GetImage();
assert(raw->cols == GetNumCol());
assert(raw->rows == GetNumRow());
assert(raw->cols == mask.W());
assert(raw->rows == mask.H());
bfImg.FilterForPinned(&mask, MaskEmpty, false);
bfBkgImg.FilterForPinned(&mask, MaskEmpty, false);
// bfImg.XTChannelCorrect(&mask);
bfImg.XTChannelCorrect();
// bfBkgImg.XTChannelCorrect(&mask);
bfBkgImg.XTChannelCorrect();
Traces trace;
trace.Init(&bfImg, &mask, FRAMEZERO, FRAMELAST, FIRSTDCFRAME,LASTDCFRAME);
bfImg.Close();
Traces bgTrace;
bgTrace.Init(&bfBkgImg, &mask, FRAMEZERO, FRAMELAST, FIRSTDCFRAME,LASTDCFRAME);
bfBkgImg.Close();
if (mDoRegionalBgSub) {
trace.SetMeshDist(0);
bgTrace.SetMeshDist(0);
}
trace.SetT0Step(mRegionXSize);
bgTrace.SetT0Step(mRegionXSize);
trace.CalcT0(true);
size_t numWells = trace.GetNumRow() * trace.GetNumCol();
for (size_t i = 0; i < numWells; i++) {
trace.SetT0(max(trace.GetT0(i) - 3, 0.0f), i);
}
bgTrace.SetT0(trace.GetT0());
trace.T0DcOffset(0,4);
trace.FillCriticalFrames();
trace.CalcReference(mRegionXSize,mRegionYSize,trace.mGridMedian);
bgTrace.T0DcOffset(0,4);
bgTrace.FillCriticalFrames();
bgTrace.CalcReference(mRegionXSize,mRegionYSize,bgTrace.mGridMedian);
int length = GetNumRow() * GetNumCol();
mBfMetric.resize(length, std::numeric_limits<double>::signaling_NaN());
vector<double> rawTrace(trace.GetNumFrames());
vector<double> bgRawTrace(bgTrace.GetNumFrames());
int pinned =0, excluded = 0;
for (int i = 0; i < length; i++) {
if (mask[i] & MaskExclude || mask[i] & MaskPinned) {
continue;
if (mask[i] & MaskExclude) {
excluded++;
}
else if (mask[i] & MaskPinned) {
pinned++;
}
}
trace.GetTraces(i, rawTrace.begin());
bgTrace.GetTraces(i, bgRawTrace.begin());
mBfMetric[i] = 0;
for (int s = 3; s < 15; s++) {
mBfMetric[i] += rawTrace[s] - bgRawTrace[s];
}
}
cout << "Pinned: " << pinned << " excluded: " << excluded << endl;
for (int i = 0; i < length; i++) {
if (mask[i] & MaskExclude || mask[i] & MaskPinned || mask[i] & MaskIgnore) {
mWells[i] = Exclude;
}
else {
mask[i] = MaskIgnore;
}
}
cout << "Filling reference. " << endl;
FillInReference(mWells, mBfMetric, mGrid, mMinQuantile, mMaxQuantile, mNumEmptiesPerRegion);
for (int i = 0; i < length; i++) {
if (mWells[i] == Reference) {
mask[i] = MaskEmpty;
}
}
bfImg.Close();
}
示例8: assert
void BFReference::CalcSignalReference2(const std::string &datFile, const std::string &bgFile,
Mask &mask, int traceFrame) {
Image bfImg;
Image bfBkgImg;
bfImg.SetImgLoadImmediate (false);
bfBkgImg.SetImgLoadImmediate (false);
bool loaded = bfImg.LoadRaw(datFile.c_str());
bool bgLoaded = bfBkgImg.LoadRaw(bgFile.c_str());
if (!loaded) {
ION_ABORT("*Error* - No beadfind file found, did beadfind run? are files transferred? (" + datFile + ")");
}
if (!bgLoaded) {
ION_ABORT("*Error* - No beadfind background file found, did beadfind run? are files transferred? (" + bgFile + ")");
}
const RawImage *raw = bfImg.GetImage();
assert(raw->cols == GetNumCol());
assert(raw->rows == GetNumRow());
assert(raw->cols == mask.W());
assert(raw->rows == mask.H());
int StartFrame = bfImg.GetFrame(-663); //5
int EndFrame = bfImg.GetFrame(350); //20
int NNinnerx = 1, NNinnery = 1, NNouterx = 12, NNoutery = 8;
cout << "DC start frame: " << StartFrame << " end frame: " << EndFrame << endl;
bfImg.FilterForPinned(&mask, MaskEmpty, false);
bfImg.XTChannelCorrect();
// bfImg.XTChannelCorrect(&mask);
Traces trace;
trace.Init(&bfImg, &mask, FRAMEZERO, FRAMELAST, FIRSTDCFRAME,LASTDCFRAME);
bfImg.Normalize(StartFrame, EndFrame);
if (mDoRegionalBgSub) {
trace.SetMeshDist(0);
}
trace.CalcT0(true);
if (mDoRegionalBgSub) {
GridMesh<float> grid;
grid.Init(raw->rows, raw->cols, mRegionYSize, mRegionXSize);
int numBin = grid.GetNumBin();
int rowStart = -1, rowEnd = -1, colStart = -1, colEnd = -1;
for (int binIx = 0; binIx < numBin; binIx++) {
cout << "BG Subtract Region: " << binIx << endl;
grid.GetBinCoords(binIx, rowStart, rowEnd, colStart, colEnd);
Region reg;
reg.row = rowStart;
reg.h = rowEnd - rowStart;
reg.col = colStart;
reg.w = colEnd - colStart;
bfImg.BackgroundCorrectRegion(&mask, reg, MaskAll, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
}
}
else {
bfImg.BackgroundCorrect(&mask, MaskEmpty, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
}
int length = GetNumRow() * GetNumCol();
mBfMetric.resize(length, std::numeric_limits<double>::signaling_NaN());
for (int wIx = 0; wIx < length; wIx++) {
if (mask[wIx] & MaskExclude || mask[wIx] & MaskPinned)
continue;
int t0 = (int)trace.GetT0(wIx);
mBfMetric[wIx] = 0;
float zSum = 0;
int count = 0;
for (int fIx = min(t0-20, 0); fIx < t0-10; fIx++) {
zSum += bfImg.At(wIx,fIx);
count ++;
}
for (int fIx = t0+3; fIx < t0+15; fIx++) {
mBfMetric[wIx] += (bfImg.At(wIx,fIx) - (zSum / count));
}
}
bfImg.Close();
for (int i = 0; i < length; i++) {
if (mask[i] & MaskExclude || mWells[i] == Exclude) {
mWells[i] = Exclude;
}
else {
mask[i] = MaskIgnore;
}
}
cout << "Filling reference. " << endl;
FillInReference(mWells, mBfMetric, mGrid, mMinQuantile, mMaxQuantile, mNumEmptiesPerRegion);
for (int i = 0; i < length; i++) {
if (mWells[i] == Reference) {
mask[i] = MaskEmpty;
}
}
}
示例9: CalcReference
void BFReference::CalcReference(const std::string &datFile, Mask &mask, std::vector<float> &metric) {
Image bfImg;
bfImg.SetImgLoadImmediate (false);
bool loaded = bfImg.LoadRaw(datFile.c_str());
if (!loaded) {
ION_ABORT("*Error* - No beadfind file found, did beadfind run? are files transferred? (" + datFile + ")");
}
const RawImage *raw = bfImg.GetImage();
assert(raw->cols == GetNumCol());
assert(raw->rows == GetNumRow());
assert(raw->cols == mask.W());
assert(raw->rows == mask.H());
if (!mDebugFile.empty()) {
DebugTraces(mDebugFile, mask, bfImg);
}
bfImg.FilterForPinned(&mask, MaskEmpty, false);
// int StartFrame= bfImg.GetFrame((GetDcStart()*1000/15)-1000);
// int EndFrame = bfImg.GetFrame((GetDcEnd()*1000/15)-1000);
int StartFrame = bfImg.GetFrame(-663); //5
int EndFrame = bfImg.GetFrame(350); //20
cout << "DC start frame: " << StartFrame << " end frame: " << EndFrame << endl;
bfImg.XTChannelCorrect();
FilterForOutliers(bfImg, mask, mIqrOutlierMult, mRegionYSize, mRegionXSize);
bfImg.Normalize(StartFrame, EndFrame);
// bfImg.XTChannelCorrect(&mask);
int NNinnerx = 1, NNinnery = 1, NNouterx = 12, NNoutery = 8;
if (mDoRegionalBgSub) {
GridMesh<float> grid;
grid.Init(raw->rows, raw->cols, mRegionYSize, mRegionXSize);
int numBin = grid.GetNumBin();
int rowStart = -1, rowEnd = -1, colStart = -1, colEnd = -1;
for (int binIx = 0; binIx < numBin; binIx++) {
grid.GetBinCoords(binIx, rowStart, rowEnd, colStart, colEnd);
Region reg;
reg.row = rowStart;
reg.h = rowEnd - rowStart;
reg.col = colStart;
reg.w = colEnd - colStart;
bfImg.BackgroundCorrectRegion(&mask, reg, MaskAll, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
}
}
else {
bfImg.BackgroundCorrect(&mask, MaskEmpty, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
}
Region region;
region.col = 0;
region.row = 0;
region.w = GetNumCol(); //mGrid.GetColStep();
region.h = GetNumRow(); // mGrid.GetRowStep();
int startFrame = bfImg.GetFrame(12); // frame 15 on uncompressed 314
// int endFrame = bfImg.GetFrame(raw->timestamps[bfImg.Ge]5300); // frame 77 or so
int endFrame = bfImg.GetFrame(5000); // frame 77 or so
bfImg.CalcBeadfindMetric_1(&mask, region, "pre", startFrame, endFrame);
const double *results = bfImg.GetResults();
int length = GetNumRow() * GetNumCol();
metric.resize(length);
copy(&results[0], &results[0] + (length), metric.begin());
bfImg.Close();
}